:root {
  --ink: #1C1917; --ink-muted: #6B7280; --ink-light: #B0B0B0;
  --terracotta: #C15C3C; --terracotta-dark: #A0472B; --terracotta-soft: #F8E8E2;
  --cream: #FBF8F4; --sand: #F1EBE2; --sand-dark: #E5DCD0; --white: #FFFFFF;
  --green: #059669; --green-soft: #ECFDF5; --red: #DC2626; --red-soft: #FEF2F2;
  --gold: #D97706; --gold-soft: #FEF3C7;
  --border: #F0EFEE; --shadow-sm: 0 2px 8px rgba(0,0,0,0.04); --shadow-md: 0 6px 16px rgba(0,0,0,0.08);
  --radius-sm: 8px; --radius-md: 12px; --radius-lg: 20px; --radius-full: 9999px;
  --font: 'Inter', sans-serif; --transition: all 0.2s ease;
}

.desktop-only { display: block !important; }
.mobile-only { display: none !important; }

* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
body { font-family: var(--font); background: var(--cream); color: var(--ink); line-height: 1.5; -webkit-font-smoothing: antialiased; display: flex; flex-direction: column; min-height: 100vh; }
a { text-decoration: none; color: inherit; }
button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }

/* ========== DESKTOP TOP BAR ========== */
.topbar { background: rgba(255,255,255,0.96); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 100; height: 64px; display: flex; align-items: center; padding: 0 20px; backdrop-filter: blur(12px); }
.topbar-inner { display: flex; align-items: center; justify-content: space-between; width: 100%; gap: 20px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 18px; letter-spacing: -0.02em; flex-shrink: 0; }
.brand-icon { width: 36px; height: 36px; border-radius: 11px; background: var(--terracotta); display: flex; align-items: center; justify-content: center; color: white; font-size: 12px; font-weight: 800; }
.brand span { color: var(--terracotta); }
.topbar-actions { display: flex; align-items: center; gap: 12px; flex-shrink: 0; }
.icon-btn { width: 38px; height: 38px; border-radius: 50%; border: 1.5px solid var(--border); background: white; color: var(--ink-muted); cursor: pointer; display: flex; align-items: center; justify-content: center; font-size: 13px; position: relative; }
.icon-btn .badge { position: absolute; top: -2px; right: -2px; min-width: 18px; height: 18px; border-radius: 9px; background: var(--terracotta); color: white; font-size: 10px; font-weight: 700; display: flex; align-items: center; justify-content: center; border: 2px solid white; }
.avatar { width: 38px; height: 38px; border-radius: 50%; background: linear-gradient(135deg, var(--terracotta), var(--terracotta-dark)); display: flex; align-items: center; justify-content: center; color: white; font-weight: 700; font-size: 13px; border: 2px solid white; cursor: pointer; }

/* ========== MOBILE HEADER ========== */
.mobile-header { 
  display: flex; 
  flex-direction: row !important; 
  align-items: center; 
  justify-content: flex-start; 
  padding: 16px 20px; 
  background: white; 
  border-bottom: 1px solid var(--border); 
  width: 100%;
}
.mobile-back-link {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  color: var(--ink);
  font-size: 18px;
  font-weight: 800;
  white-space: nowrap;
}
.mobile-back-link i { font-size: 16px; color: var(--ink-muted); }

.shell { display: flex; flex: 1; }

/* ========== SIDEBAR ========== */
.sidebar { width: 240px; background: white; border-right: 1px solid var(--border); padding: 18px 12px; flex-shrink: 0; overflow-y: auto; height: calc(100vh - 64px); position: sticky; top: 64px; display: flex; flex-direction: column; }
.sidebar-group { margin-bottom: 20px; }
.sidebar-label { font-size: 10.5px; font-weight: 700; color: var(--ink-light); text-transform: uppercase; letter-spacing: 0.08em; padding: 0 12px; margin-bottom: 6px; }
.sidebar-divider { height: 1px; background: var(--border); margin: 8px 12px 14px; }

.back-to-dash { display: flex; align-items: center; gap: 10px; padding: 12px; border-radius: var(--radius-sm); color: var(--ink-muted); font-size: 13.5px; font-weight: 600; text-decoration: none; transition: var(--transition); margin-bottom: 8px; }
.back-to-dash:hover { background: var(--cream); color: var(--ink); }
.back-to-dash i { font-size: 12px; }

.settings-nav-item { display: flex; align-items: center; gap: 11px; padding: 9px 12px; border-radius: var(--radius-sm); font-size: 13.5px; font-weight: 500; color: var(--ink-muted); cursor: pointer; transition: var(--transition); margin-bottom: 1px; }
.settings-nav-item i { width: 18px; text-align: center; font-size: 13px; flex-shrink: 0; }
.settings-nav-item:hover { background: var(--cream); color: var(--ink); }
.settings-nav-item.active { background: var(--terracotta-soft); color: var(--terracotta-dark); font-weight: 600; }
.settings-nav-item.active i { color: var(--terracotta); }

/* ========== MAIN ========== */
.main { flex: 1; padding: 26px 30px; min-width: 0; }
.desktop-page-header { margin-bottom: 32px; }
.desktop-page-header h1 { font-size: 24px; font-weight: 800; letter-spacing: -0.03em; }

.btn-primary { background: var(--terracotta); color: white; padding: 10px 20px; border-radius: var(--radius-full); font-weight: 700; font-size: 13.5px; display: inline-flex; align-items: center; gap: 8px; transition: var(--transition); }
.btn-primary:hover { background: var(--terracotta-dark); transform: translateY(-1px); box-shadow: 0 4px 12px rgba(193,92,60,0.3); }

/* ========== DESKTOP SETTINGS CONTENT ========== */
.settings-content { min-width: 0; max-width: 800px; }
.settings-panel { display: none; }
.settings-panel.active { display: block; animation: fadeIn 0.3s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }

.settings-card { background: white; border-radius: var(--radius-lg); border: 1px solid var(--border); padding: 32px; margin-bottom: 24px; box-shadow: var(--shadow-sm); }
.card-title { font-size: 20px; font-weight: 800; margin-bottom: 24px; color: var(--ink); }

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-bottom: 24px; }
.form-group { display: flex; flex-direction: column; gap: 8px; }
.form-group.full-width { grid-column: 1 / -1; }
label { font-size: 13px; font-weight: 600; color: var(--ink); }
label span { color: var(--terracotta); }
input, select, textarea { width: 100%; padding: 12px 16px; border: 1px solid var(--border); border-radius: var(--radius-sm); font-size: 14px; font-family: inherit; outline: none; transition: var(--transition); background: var(--cream); color: var(--ink); }
input:focus, select:focus, textarea:focus { border-color: var(--terracotta); background: white; }

/* ========== TOGGLE SWITCH ========== */
.toggle-row { display: flex; justify-content: space-between; align-items: center; padding: 16px 0; border-bottom: 1px solid var(--border); }
.toggle-title { font-size: 14px; font-weight: 600; color: var(--ink); }
.toggle-desc { font-size: 12px; color: var(--ink-muted); margin-top: 2px; }
.switch { position: relative; display: inline-block; width: 44px; height: 24px; }
.switch input { opacity: 0; width: 0; height: 0; }
.slider { position: absolute; cursor: pointer; top: 0; left: 0; right: 0; bottom: 0; background-color: var(--sand-dark); transition: .4s; border-radius: 24px; }
.slider:before { position: absolute; content: ""; height: 18px; width: 18px; left: 3px; bottom: 3px; background-color: white; transition: .4s; border-radius: 50%; }
input:checked + .slider { background-color: var(--terracotta); }
input:checked + .slider:before { transform: translateX(20px); }

/* ========== MOBILE SETTINGS LIST ========== */
.settings-mobile-list { 
  display: none; 
  flex-direction: column; 
  padding: 16px; 
  gap: 8px; 
}

.mobile-list-item { 
  display: flex; 
  align-items: center; 
  gap: 16px; 
  background: white; 
  padding: 16px 20px; 
  border-radius: var(--radius-md); 
  border: 1px solid var(--border); 
  cursor: pointer; 
  box-shadow: var(--shadow-sm); 
}
.ml-icon { width: 40px; height: 40px; border-radius: 10px; background: var(--terracotta-soft); color: var(--terracotta); display: flex; align-items: center; justify-content: center; font-size: 16px; }
.ml-text { flex: 1; font-weight: 600; font-size: 14.5px; color: var(--ink); }
.ml-arrow { color: var(--ink-light); font-size: 14px; }

/* ========== MOBILE FULL PAGE MODAL ========== */
.mobile-modal-overlay { 
  position: fixed; 
  inset: 0; 
  background: var(--cream); 
  z-index: 1000; 
  opacity: 0; 
  visibility: hidden; 
  transition: 0.25s; 
  display: flex; 
  flex-direction: column;
}
.mobile-modal-overlay.show { 
  opacity: 1; 
  visibility: visible; 
}

.mobile-modal-content { 
  background: var(--cream); 
  width: 100%; 
  height: 100%; 
  display: flex; 
  flex-direction: column; 
  transform: translateX(100%);
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1); 
}
.mobile-modal-overlay.show .mobile-modal-content { 
  transform: translateX(0); 
}

.mobile-modal-header { 
  display: flex; 
  align-items: center; 
  gap: 12px;
  padding: 16px 20px; 
  background: white;
  border-bottom: 1px solid var(--border); 
  flex-shrink: 0; 
}

.modal-back-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--cream);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--ink);
  font-size: 16px;
  cursor: pointer;
  padding: 0; /* Fixes button padding issues */
  flex-shrink: 0;
}

.mobile-modal-header h3 { 
  font-size: 18px; 
  font-weight: 800; 
  color: var(--ink); 
}

.mobile-modal-body { 
  padding: 20px; 
  overflow-y: auto; 
  flex: 1; 
}

/* ========== RESPONSIVE CONTROLS ========== */
@media (max-width: 900px) {
  .desktop-only { display: none !important; }
  .mobile-only { display: block !important; }
  
  .shell { flex-direction: column; }
  .sidebar { display: none; }
  .settings-content { display: none; }
  .settings-mobile-list { display: flex; }
  .main { padding: 0; }
}

/* FORMS IN MODAL */
.mobile-modal-body .form-grid {
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.mobile-modal-body .form-group { margin-bottom: 0; }
.mobile-modal-body .settings-card { border: none; padding: 0; box-shadow: none; background: transparent; }
.mobile-modal-body .card-title { display: none; } /* Hide duplicate title inside modal */
.mobile-modal-body .btn-primary { width: 100%; justify-content: center; margin-top: 24px; padding: 16px; font-size: 15px; }