/**
 * ARTHA — Complete Design System
 * Warm light theme. Sharp typography. Intentional motion.
 * Includes: gate, ED quiz, energy check-in, focus session,
 *           celebrations, bottom sheets, skeleton loading,
 *           swipe gestures, activity rings, all modules.
 */

/* ═══════════════════════════════════════════════════════
   TOKENS
═══════════════════════════════════════════════════════ */
:root {
  /* Base — slightly warmer and brighter */
  --bg:          #F8F6F2;
  --surface:     #FFFFFF;
  --surface-2:   #FDFCFA;
  --surface-3:   #F2EFE8;

  /* Text — higher contrast, more readable */
  --text:        #1A1714;
  --text-2:      #3D3935;
  --text-3:      #6B6560;
  --text-4:      #9E9890;

  /* Borders */
  --border:      #E8E3D8;
  --border-mid:  #CFC8B8;

  /* 7 Accent colours — brighter, more vibrant */
  --sage:        #2E7D4F;
  --sage-pale:   #E8F5EE;
  --sage-border: #A8D5B8;

  --terra:       #C0442A;
  --terra-pale:  #FCEEE9;
  --terra-border:#F0B8A8;

  --slate:       #2C5F9E;
  --slate-pale:  #E5EEF8;
  --slate-border:#A8C4E8;

  --amber:       #B87A1A;
  --amber-pale:  #FDF4E3;
  --amber-border:#F0D090;

  --rose:        #A8355A;
  --rose-pale:   #FCEAF0;
  --rose-border: #E8A8BE;

  --teal:        #1A7A7A;
  --teal-pale:   #E3F5F5;
  --teal-border: #90D0D0;

  --plum:        #6A3A80;
  --plum-pale:   #F0E8F8;
  --plum-border: #C8A8E0;

  /* Typography — larger, more readable */
  --font-serif:  'Playfair Display', Georgia, serif;
  --font-sans:   'Inter', system-ui, sans-serif;
  --font-mono:   'JetBrains Mono', 'Courier New', monospace;
  --text-base:   16px;

  /* Spacing — 4pt grid */
  --s1:  4px;
  --s2:  8px;
  --s3:  12px;
  --s4:  16px;
  --s5:  24px;
  --s6:  32px;
  --s7:  48px;

  /* Radius */
  --r-sm:   8px;
  --r-md:   12px;
  --r-lg:   16px;
  --r-xl:   20px;
  --r-pill: 100px;

  /* Shadows */
  --sh-1: 0 1px 3px rgba(26,23,20,0.07), 0 1px 2px rgba(26,23,20,0.04);
  --sh-2: 0 2px 8px rgba(26,23,20,0.10), 0 1px 3px rgba(26,23,20,0.05);
  --sh-3: 0 4px 16px rgba(26,23,20,0.13), 0 2px 6px rgba(26,23,20,0.07);
  --sh-4: 0 8px 32px rgba(26,23,20,0.16), 0 4px 12px rgba(26,23,20,0.08);
  --sh-5: 0 20px 60px rgba(26,23,20,0.22), 0 8px 24px rgba(26,23,20,0.10);

  /* Motion */
  --ease:        cubic-bezier(0.16, 1, 0.3, 1);
  --dur-micro:   120ms;
  --dur-sheet:   280ms;
  --dur-page:    350ms;
  --dur-celebrate: 500ms;
}

/* ═══════════════════════════════════════════════════════
   RESET & BASE
═══════════════════════════════════════════════════════ */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html {
  font-size: var(--text-base);
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--text);
  line-height: 1.65;
  font-size: 15px;
  min-height: 100vh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Prevent iOS zoom on inputs */
input, textarea, select {
  font-size: 16px !important;
}

/* ═══════════════════════════════════════════════════════
   ANIMATIONS
═══════════════════════════════════════════════════════ */
@keyframes pageIn {
  from { opacity:0; transform:translateY(10px); }
  to   { opacity:1; transform:translateY(0); }
}

@keyframes slideUp {
  from { opacity:0; transform:translateY(20px); }
  to   { opacity:1; transform:translateY(0); }
}

@keyframes fadeIn {
  from { opacity:0; }
  to   { opacity:1; }
}

@keyframes shimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

@keyframes gateShake {
  0%, 100% { transform:translateX(0); }
  20%      { transform:translateX(-8px); }
  40%      { transform:translateX(8px); }
  60%      { transform:translateX(-5px); }
  80%      { transform:translateX(5px); }
}

@keyframes habitDone {
  0%   { transform:scale(1); }
  40%  { transform:scale(1.25); }
  70%  { transform:scale(0.92); }
  100% { transform:scale(1); }
}

@keyframes streakGlow {
  0%, 100% { text-shadow: none; }
  50%       { text-shadow: 0 0 12px rgba(154,111,46,0.6); }
}

@keyframes arcFill {
  from { stroke-dashoffset: var(--arc-full); }
  to   { stroke-dashoffset: var(--arc-offset); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

/* ═══════════════════════════════════════════════════════
   GATE SCREEN
═══════════════════════════════════════════════════════ */
#artha-gate-screen {
  position: fixed;
  inset: 0;
  background: #0F0D0C;
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  animation: fadeIn 200ms ease;
}

.gate-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--s3);
  width: 100%;
  max-width: 280px;
}

.gate-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: rgba(255,255,255,0.15);
  margin-bottom: var(--s2);
}

.gate-input {
  width: 100%;
  background: rgba(255,255,255,0.06);
  border: 1.5px solid rgba(255,255,255,0.12);
  border-radius: var(--r-md);
  padding: var(--s3) var(--s4);
  color: white;
  font-family: var(--font-sans);
  font-size: 16px;
  text-align: center;
  letter-spacing: 0.15em;
  outline: none;
  transition: border-color var(--dur-micro) ease;
}
.gate-input:focus {
  border-color: rgba(255,255,255,0.3);
}
.gate-input::placeholder {
  color: rgba(255,255,255,0.2);
  letter-spacing: 0.05em;
}
.gate-input.gate-shake {
  animation: gateShake 450ms ease;
  border-color: rgba(160,80,58,0.6);
}

.gate-btn {
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.12);
  color: rgba(255,255,255,0.7);
  width: 44px;
  height: 44px;
  border-radius: 50%;
  font-size: 1rem;
  cursor: pointer;
  transition: all var(--dur-micro) ease;
}
.gate-btn:hover  { background: rgba(255,255,255,0.15); }
.gate-btn:active { transform: scale(0.93); }

.gate-error {
  font-size: 0.78rem;
  color: rgba(160,80,58,0.9);
  font-family: var(--font-sans);
}

/* ═══════════════════════════════════════════════════════
   APP LAYOUT
═══════════════════════════════════════════════════════ */
.app {
  display: flex;
  height: 100dvh;
  overflow: hidden;
  width: 100%;
}

/* ─── Sidebar ─ */
.sidebar {
  width: 240px;
  flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  z-index: 200;
  box-shadow: var(--sh-2);
  transition: transform var(--dur-sheet) var(--ease);
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: var(--s3);
  padding: var(--s5) var(--s5) var(--s4);
  border-bottom: 1px solid var(--border);
}
.sidebar-logo-icon {
  width: 36px; height: 36px;
  border-radius: var(--r-md);
  background: linear-gradient(135deg, #2A1F15, #1A150F);
  display: flex; align-items: center; justify-content: center;
  font-size: 1rem; color: #C49040;
  flex-shrink: 0;
}
.sidebar-logo h1 {
  font-family: var(--font-serif);
  font-size: 1.1rem;
  font-weight: 500;
  color: var(--text);
}
.sidebar-logo span {
  font-size: 0.65rem;
  color: var(--text-4);
  display: block;
  margin-top: 1px;
}

.nav-section {
  font-size: 0.6rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-4);
  font-weight: 700;
  padding: var(--s4) var(--s5) var(--s2);
}

.nav-item {
  display: flex;
  align-items: center;
  gap: var(--s3);
  padding: 0.55rem var(--s5);
  color: var(--text-3);
  cursor: pointer;
  font-size: 0.85rem;
  border-radius: 0;
  position: relative;
  transition: all var(--dur-micro) ease;
}
.nav-item svg { width:17px; height:17px; flex-shrink:0; opacity:0.65; }
.nav-item:hover { background: var(--surface-3); color: var(--text); }
.nav-item.active {
  color: var(--amber);
  background: var(--amber-pale);
  font-weight: 600;
}
.nav-item.active svg { opacity: 1; }
.nav-item.active::before {
  content: '';
  position: absolute;
  left: 0; top: 20%; bottom: 20%;
  width: 3px;
  background: var(--amber);
  border-radius: 0 2px 2px 0;
}

.nav-badge {
  background: var(--terra);
  color: white;
  font-size: 0.6rem;
  padding: 1px 5px;
  border-radius: var(--r-pill);
  margin-left: auto;
  font-weight: 700;
}

.sidebar-footer {
  margin-top: auto;
  padding: var(--s3) var(--s5);
  font-size: 0.72rem;
  color: var(--text-4);
  border-top: 1px solid var(--border);
}

/* ─── Main ─ */
.main {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: var(--s5) var(--s6) calc(var(--s7) + var(--s5));
  min-width: 0;
  width: 100%;
}

@media (max-width: 768px) {
  .sidebar {
    position: fixed;
    top: 0; bottom: 0; left: 0;
    transform: translateX(-100%);
    z-index: 300;
    box-shadow: var(--sh-5);
  }
  .sidebar.open { transform: translateX(0); }
  .main { padding: var(--s4) var(--s4) calc(5rem + var(--s5)); }
}

/* ─── Pages ─ */
.page { display: none; animation: pageIn var(--dur-page) var(--ease); }
.page.active { display: block; }

/* ─── Mobile bottom nav ─ */
.mobile-nav {
  display: none;
  position: fixed;
  bottom: 0; left: 0; right: 0;
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding: var(--s2) 0 calc(var(--s2) + env(safe-area-inset-bottom, 0px));
  z-index: 400;
  box-shadow: 0 -4px 20px rgba(28,25,23,0.08);
}
.mob-nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: var(--s2) var(--s1);
  font-size: 0.62rem;
  color: var(--text-4);
  cursor: pointer;
  transition: color var(--dur-micro) ease;
}
.mob-nav-item.active { color: var(--amber); font-weight: 600; }
.mob-nav-item svg { width:20px; height:20px; }

@media (max-width: 768px) { .mobile-nav { display: flex; } }

/* ─── Hamburger ─ */
.hamburger {
  display: none;
  position: fixed;
  top: var(--s4); left: var(--s4);
  z-index: 350;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  width: 40px; height: 40px;
  align-items: center; justify-content: center;
  cursor: pointer;
  box-shadow: var(--sh-2);
}
@media (max-width: 768px) { .hamburger { display: flex; } }

/* ─── Quick capture FAB ─ */
.quick-btn {
  position: fixed;
  bottom: 5rem; right: var(--s5);
  width: 50px; height: 50px;
  border-radius: 50%;
  background: var(--text);
  border: none;
  font-size: 1.4rem;
  color: white;
  box-shadow: var(--sh-4);
  z-index: 500;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: all var(--dur-micro) var(--ease);
}
.quick-btn:hover  { transform: scale(1.08); box-shadow: var(--sh-5); }
.quick-btn:active { transform: scale(0.94); }

/* ═══════════════════════════════════════════════════════
   CARDS
═══════════════════════════════════════════════════════ */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: var(--s5);
  margin-bottom: var(--s4);
  box-shadow: var(--sh-1);
  transition: transform var(--dur-micro) var(--ease),
              box-shadow var(--dur-micro) var(--ease);
}
.card:hover {
  transform: translateY(-1px);
  box-shadow: var(--sh-3);
}
.card-sm { padding: var(--s4); }

/* Accent card variants */
.card-sage  { background:var(--sage-pale);  border-color:var(--sage-border); }
.card-terra { background:var(--terra-pale); border-color:var(--terra-border); }
.card-slate { background:var(--slate-pale); border-color:var(--slate-border); }
.card-amber { background:var(--amber-pale); border-color:var(--amber-border); }
.card-rose  { background:var(--rose-pale);  border-color:var(--rose-border); }
.card-teal  { background:var(--teal-pale);  border-color:var(--teal-border); }
.card-plum  { background:var(--plum-pale);  border-color:var(--plum-border); }

.card-title {
  font-size: 0.65rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-4);
  font-weight: 700;
  margin-bottom: var(--s3);
}

/* ═══════════════════════════════════════════════════════
   TYPOGRAPHY
═══════════════════════════════════════════════════════ */
.page-title {
  font-family: var(--font-serif);
  font-size: 2rem;
  font-weight: 500;
  color: var(--text);
  line-height: 1.15;
}
.page-sub {
  font-size: 0.84rem;
  color: var(--text-3);
  margin-top: 0.2rem;
}
.page-header {
  margin-bottom: var(--s5);
  padding-top: var(--s2);
}

.stat-val {
  font-family: var(--font-serif);
  font-size: 2rem;
  font-weight: 500;
  line-height: 1.1;
}
.stat-val.stat-up   { color: var(--sage); }
.stat-val.stat-down { color: var(--terra); }
.stat-label {
  font-size: 0.72rem;
  color: var(--text-4);
  margin-top: 2px;
}

/* All financial figures in mono */
.mono { font-family: var(--font-mono); }

/* ═══════════════════════════════════════════════════════
   BUTTONS
═══════════════════════════════════════════════════════ */
.btn {
  display: inline-flex;
  align-items: center;
  gap: var(--s2);
  padding: 0.55rem var(--s4);
  border-radius: var(--r-md);
  font-family: var(--font-sans);
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  border: 1.5px solid var(--border-mid);
  background: var(--surface);
  color: var(--text-2);
  transition: all var(--dur-micro) var(--ease);
  white-space: nowrap;
  line-height: 1;
  -webkit-user-select: none;
}
.btn:hover  { background: var(--surface-3); transform: translateY(-1px); }
.btn:active { transform: translateY(0) scale(0.97); }

.btn-primary {
  background: var(--text);
  color: white;
  border-color: transparent;
}
.btn-primary:hover { background: #2C2927; }

.btn-sage  { background:var(--sage);  color:white; border-color:transparent; }
.btn-terra { background:var(--terra); color:white; border-color:transparent; }
.btn-amber { background:var(--amber); color:white; border-color:transparent; }

.btn-ghost { background:transparent; border-color:transparent; }
.btn-ghost:hover { background: var(--surface-3); }

.btn-sm { padding:0.38rem 0.75rem; font-size:0.78rem; }
.btn-icon { padding: 0.38rem; border-radius: var(--r-sm); min-width:30px; justify-content:center; }

.btns { display:flex; gap:var(--s2); flex-wrap:wrap; }

/* ═══════════════════════════════════════════════════════
   FORMS
═══════════════════════════════════════════════════════ */
.form-group { margin-bottom: var(--s4); }
.form-label {
  display: block;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-2);
  margin-bottom: var(--s2);
}
.form-label .req { color: var(--terra); }
.form-hint { font-size:0.7rem; color:var(--text-4); margin-top:4px; }

.form-input {
  width: 100%;
  padding: 0.6rem 0.85rem;
  background: var(--surface-2);
  border: 1.5px solid var(--border);
  border-radius: var(--r-md);
  font-family: var(--font-sans);
  font-size: 16px;
  color: var(--text);
  outline: none;
  transition: border-color var(--dur-micro) ease,
              box-shadow var(--dur-micro) ease;
  -webkit-appearance: none;
}
.form-input:focus {
  border-color: var(--amber);
  box-shadow: 0 0 0 3px var(--amber-pale);
  background: var(--surface);
}
.form-input::placeholder { color: var(--text-4); }

.form-row { display:grid; grid-template-columns:1fr 1fr; gap:var(--s3); }
@media (max-width:480px) { .form-row { grid-template-columns:1fr; } }

.form-check {
  display: flex;
  align-items: center;
  gap: var(--s3);
  margin-bottom: var(--s3);
  font-size: 0.82rem;
  color: var(--text-2);
  cursor: pointer;
}
.form-check input[type="checkbox"] {
  width: 16px; height: 16px;
  accent-color: var(--amber);
  cursor: pointer;
}

/* ═══════════════════════════════════════════════════════
   BOTTOM SHEETS (replaces all modals on mobile)
═══════════════════════════════════════════════════════ */
/* ─── Bottom sheet — mobile keyboard fix ─ */
.sheet-bg {
  position: fixed;
  inset: 0;
  background: rgba(28,25,23,0.5);
  z-index: 600;
  display: none;
  align-items: flex-end;
  justify-content: center;
  backdrop-filter: blur(2px);
  /* Prevent resize when keyboard opens on mobile */
  overscroll-behavior: none;
}
.sheet-bg.open { display: flex; }

.sheet {
  background: var(--surface);
  border-radius: var(--r-xl) var(--r-xl) 0 0;
  padding: var(--s4) var(--s5) calc(var(--s5) + env(safe-area-inset-bottom, 0px));
  width: 100%;
  max-width: 580px;
  /* Use max-height with dvh to handle keyboard on mobile */
  max-height: 85dvh;
  overflow-y: auto;
  box-shadow: var(--sh-5);
  transform: translateY(100%);
  transition: transform var(--dur-sheet) var(--ease);
  /* Prevent keyboard from pushing sheet off screen */
  position: relative;
}
.sheet-bg.open .sheet {
  transform: translateY(0);
}

.sheet-handle {
  width: 40px; height: 4px;
  border-radius: 2px;
  background: var(--border-mid);
  margin: 0 auto var(--s4);
}

.sheet-title {
  font-family: var(--font-serif);
  font-size: 1.3rem;
  font-weight: 500;
  margin-bottom: var(--s4);
  padding-bottom: var(--s3);
  border-bottom: 1px solid var(--border);
}

.sheet-footer {
  display: flex;
  gap: var(--s3);
  justify-content: flex-end;
  padding-top: var(--s4);
  border-top: 1px solid var(--border);
  margin-top: var(--s4);
}

/* Legacy modal (desktop fallback) */
.modal-bg {
  position: fixed; inset: 0;
  background: rgba(28,25,23,0.5);
  z-index: 600;
  display: none;
  align-items: center;
  justify-content: center;
  padding: var(--s5);
  backdrop-filter: blur(3px);
}
.modal-bg.open { display: flex; }
.modal {
  background: var(--surface);
  border-radius: var(--r-xl);
  padding: var(--s6);
  width: 100%; max-width: 520px;
  max-height: 90dvh;
  overflow-y: auto;
  box-shadow: var(--sh-5);
  animation: slideUp var(--dur-sheet) var(--ease);
}
.modal-title {
  font-family: var(--font-serif);
  font-size: 1.4rem; font-weight: 500;
  margin-bottom: var(--s5);
  padding-bottom: var(--s3);
  border-bottom: 1px solid var(--border);
}
.modal-footer {
  display:flex; gap:var(--s3); justify-content:flex-end;
  padding-top:var(--s4); border-top:1px solid var(--border);
  margin-top:var(--s4);
}

/* ═══════════════════════════════════════════════════════
   TOAST
═══════════════════════════════════════════════════════ */
.toast {
  position: fixed;
  bottom: 5.5rem; left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--text);
  color: white;
  padding: 0.6rem 1.25rem;
  border-radius: var(--r-pill);
  font-size: 0.8rem;
  font-weight: 500;
  z-index: 9000;
  white-space: nowrap;
  box-shadow: var(--sh-4);
  opacity: 0;
  pointer-events: none;
  transition: all 220ms ease;
}
.toast.toast-visible { opacity:1; transform:translateX(-50%) translateY(0); }
.toast.toast-error   { background: var(--terra); }
.toast.toast-sage    { background: var(--sage); }

/* ═══════════════════════════════════════════════════════
   SKELETON LOADING
═══════════════════════════════════════════════════════ */
.skeleton {
  background: linear-gradient(
    90deg,
    #F0EDE5 25%,
    #E5E1D8 50%,
    #F0EDE5 75%
  );
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: var(--r-sm);
}
.skel-line  { height: 16px; margin-bottom: 10px; border-radius: 4px; }
.skel-title { height: 24px; width: 60%; margin-bottom: 16px; }
.skel-stat  { height: 48px; border-radius: var(--r-md); }
.skel-card  {
  height: 120px;
  border-radius: var(--r-lg);
  margin-bottom: var(--s4);
}

/* ═══════════════════════════════════════════════════════
   HABIT DOTS + ACTIVITY RINGS
═══════════════════════════════════════════════════════ */
.h-dot {
  width: 28px; height: 28px;
  border-radius: 50%;
  border: 2px solid var(--border-mid);
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.7rem;
  flex-shrink: 0;
  transition: all var(--dur-micro) var(--ease);
  color: transparent;
}
.h-dot.done {
  background: var(--sage);
  border-color: var(--sage);
  color: white;
  animation: habitDone var(--dur-celebrate) var(--ease);
}
.h-dot:hover { border-color: var(--sage); transform: scale(1.1); }

/* SVG activity ring */
.activity-ring {
  --arc-full: calc(2 * 3.14159 * 42);
  --arc-offset: var(--arc-full);
}
.activity-ring circle.track {
  fill: none;
  stroke: var(--border);
  stroke-width: 7;
}
.activity-ring circle.fill {
  fill: none;
  stroke-width: 7;
  stroke-linecap: round;
  transform: rotate(-90deg);
  transform-origin: center;
  stroke-dasharray: var(--arc-full);
  stroke-dashoffset: var(--arc-offset);
  transition: stroke-dashoffset 600ms var(--ease);
}

/* ═══════════════════════════════════════════════════════
   PROGRESS BARS
═══════════════════════════════════════════════════════ */
.prog-bar {
  background: var(--border);
  border-radius: var(--r-pill);
  height: 6px;
  overflow: hidden;
}
.prog-fill {
  height: 100%;
  border-radius: var(--r-pill);
  transition: width 600ms var(--ease);
}
.prog-fill.sage  { background: var(--sage); }
.prog-fill.terra { background: var(--terra); }
.prog-fill.amber { background: var(--amber); }
.prog-fill.teal  { background: var(--teal); }
.prog-fill.slate { background: var(--slate); }
.prog-fill.rose  { background: var(--rose); }

/* ═══════════════════════════════════════════════════════
   BADGES
═══════════════════════════════════════════════════════ */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px var(--s2);
  border-radius: var(--r-pill);
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  white-space: nowrap;
}
.badge-sage  { background:var(--sage-pale);  color:var(--sage);  }
.badge-terra { background:var(--terra-pale); color:var(--terra); }
.badge-slate { background:var(--slate-pale); color:var(--slate); }
.badge-amber { background:var(--amber-pale); color:var(--amber); }
.badge-rose  { background:var(--rose-pale);  color:var(--rose);  }
.badge-teal  { background:var(--teal-pale);  color:var(--teal);  }
.badge-plum  { background:var(--plum-pale);  color:var(--plum);  }
.badge-soft  { background:var(--surface-3);  color:var(--text-3); }

/* ═══════════════════════════════════════════════════════
   URGENCY CLASSES
═══════════════════════════════════════════════════════ */
.urg-over { color:var(--terra); background:var(--terra-pale); }
.urg-crit { color:var(--terra); background:var(--terra-pale); }
.urg-high { color:var(--amber); background:var(--amber-pale); }
.urg-med  { color:var(--amber); background:var(--amber-pale); }
.urg-low  { color:var(--sage);  background:var(--sage-pale);  }
.urg-ok   { color:var(--text-4);background:var(--surface-3);  }

/* ═══════════════════════════════════════════════════════
   TRANSACTIONS
═══════════════════════════════════════════════════════ */
.txn-row {
  display: flex;
  align-items: center;
  gap: var(--s3);
  padding: 0.6rem 0;
  border-bottom: 1px solid var(--border);
  transition: background var(--dur-micro) ease;
}
.txn-row:hover { background: var(--surface-3); margin: 0 -var(--s5); padding: 0.6rem var(--s5); }

.txn-icon {
  width: 36px; height: 36px;
  border-radius: var(--r-md);
  display: flex; align-items: center; justify-content: center;
  font-size: 1rem; flex-shrink: 0;
}
.txn-name {
  font-size: 0.84rem;
  font-weight: 500;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.txn-meta { font-size: 0.7rem; color: var(--text-4); margin-top: 1px; }
.txn-amt  {
  font-family: var(--font-mono);
  font-size: 0.88rem;
  font-weight: 600;
  flex-shrink: 0;
  margin-left: auto;
}
.txn-amt.inc { color: var(--sage); }
.txn-amt.exp { color: var(--terra); }

/* ═══════════════════════════════════════════════════════
   CALENDARS & GRIDS
═══════════════════════════════════════════════════════ */
.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 2px;
}
.cal-dh {
  text-align: center;
  font-size: 0.65rem;
  color: var(--text-4);
  font-weight: 700;
  letter-spacing: 0.06em;
  padding: 0.2rem 0;
}
.cal-day {
  position: relative;
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.78rem;
  border-radius: var(--r-sm);
  cursor: pointer;
  transition: all var(--dur-micro) ease;
}
.cal-day:hover   { background: var(--surface-3); }
.cal-day.today   { background: var(--text); color: white; font-weight: 700; }
.cal-day.selected { background: var(--amber-pale); color: var(--amber); font-weight: 700; }
.cal-day.power   { color: var(--sage); font-weight: 600; }
.cal-day.other   { color: var(--text-4); }

/* ═══════════════════════════════════════════════════════
   LAYOUT HELPERS
═══════════════════════════════════════════════════════ */
.grid-2 { display:grid; grid-template-columns:1fr 1fr; gap:var(--s4); }
.grid-3 { display:grid; grid-template-columns:repeat(3,1fr); gap:var(--s3); }
.grid-4 { display:grid; grid-template-columns:repeat(4,1fr); gap:var(--s3); }
.grid-auto { display:grid; grid-template-columns:repeat(auto-fill,minmax(280px,1fr)); gap:var(--s4); }

@media (max-width:900px) {
  .grid-4 { grid-template-columns:repeat(2,1fr); }
  .grid-3 { grid-template-columns:repeat(2,1fr); }
}
@media (max-width:640px) {
  .grid-2, .grid-3, .grid-4, .grid-auto {
    grid-template-columns: 1fr;
  }
}

.sec-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--s4);
}
.sec-head h3 {
  font-family: var(--font-serif);
  font-size: 1rem;
  font-weight: 500;
}

.div { border:none; border-top:1px solid var(--border); margin:var(--s4) 0; }

/* Tables */
.tbl { width:100%; border-collapse:collapse; font-size:0.82rem; }
.tbl th {
  text-align:left; padding:0.5rem 0.75rem;
  font-size:0.65rem; letter-spacing:0.1em;
  text-transform:uppercase; color:var(--text-4);
  border-bottom:1px solid var(--border);
  font-weight:700;
}
.tbl td {
  padding:0.55rem 0.75rem;
  border-bottom:1px solid var(--border);
  color:var(--text-2);
}
.tbl tr:last-child td { border-bottom:none; }
.tbl tr:hover td { background:var(--surface-3); }

/* Toggle group */
.toggle-group {
  display:inline-flex;
  background:var(--surface-3);
  border-radius:var(--r-md);
  padding:3px; gap:2px;
}
.toggle-opt {
  padding:0.38rem 0.85rem;
  border-radius:calc(var(--r-md) - 2px);
  font-size:0.8rem; cursor:pointer;
  color:var(--text-3);
  transition:all var(--dur-micro) ease;
  white-space:nowrap;
}
.toggle-opt.active {
  background:var(--surface);
  color:var(--text);
  font-weight:600;
  box-shadow:var(--sh-1);
}

/* Insight cards */
.insight-card {
  padding:var(--s4);
  background:var(--surface-2);
  border:1px solid var(--border);
  border-left:3px solid var(--amber);
  border-radius:var(--r-md);
  margin-bottom:var(--s3);
}
.insight-tag {
  font-size:0.65rem; letter-spacing:0.1em;
  text-transform:uppercase; font-weight:700;
  color:var(--amber); margin-bottom:var(--s2);
}
.insight-text { font-size:0.82rem; color:var(--text-2); line-height:1.65; }

/* Avatar */
.avatar {
  border-radius:50%;
  display:flex; align-items:center; justify-content:center;
  font-weight:700; flex-shrink:0;
}
.avatar-rose  { background:var(--rose-pale);  color:var(--rose);  }
.avatar-sage  { background:var(--sage-pale);  color:var(--sage);  }
.avatar-teal  { background:var(--teal-pale);  color:var(--teal);  }
.avatar-slate { background:var(--slate-pale); color:var(--slate); }
.avatar-amber { background:var(--amber-pale); color:var(--amber); }
.avatar-plum  { background:var(--plum-pale);  color:var(--plum);  }

/* Empty states */
.es {
  text-align:center; padding:2.5rem 1rem;
  color:var(--text-4); font-size:0.83rem;
  line-height:1.7;
}
.es-icon { font-size:2rem; margin-bottom:0.75rem; opacity:0.4; }

/* Auth screens */
.auth-screen {
  position:fixed; inset:0;
  background:var(--bg); z-index:9000;
  display:none; align-items:center;
  justify-content:center; padding:1rem;
  overflow-y:auto;
}

.onboard-card {
  background:var(--surface);
  border:1px solid var(--border);
  border-radius:var(--r-xl);
  padding:var(--s6);
  width:100%; max-width:480px;
  box-shadow:var(--sh-4);
  animation:slideUp var(--dur-page) var(--ease);
}

/* PIN screen */
.pin-dots { display:flex; gap:var(--s4); }
.pin-dot {
  width:14px; height:14px;
  border-radius:50%;
  border:2px solid var(--border-mid);
  transition:all var(--dur-micro) ease;
}
.pin-dot.filled { background:var(--text); border-color:var(--text); }

.pin-pad { display:grid; grid-template-columns:repeat(3,72px); gap:var(--s3); }
.pin-key {
  width:72px; height:72px;
  border-radius:50%;
  background:var(--surface-2);
  border:1.5px solid var(--border);
  font-family:var(--font-serif);
  font-size:1.4rem; font-weight:400;
  color:var(--text); cursor:pointer;
  transition:all var(--dur-micro) ease;
  display:flex; align-items:center; justify-content:center;
}
.pin-key:active { background:var(--surface-3); transform:scale(0.93); }

/* Step dots (onboarding) */
.step-dots { display:flex; gap:var(--s2); justify-content:center; margin-top:var(--s4); }
.step-dot {
  width:8px; height:8px; border-radius:50%;
  background:var(--border-mid);
  transition:all 300ms ease;
}
.step-dot.active { background:var(--amber); transform:scale(1.2); }
.step-dot.done   { background:var(--sage); }

.onboard-step {
  font-size:0.65rem; letter-spacing:0.12em;
  text-transform:uppercase; color:var(--amber);
  font-weight:700; margin-bottom:var(--s3);
}
.onboard-title {
  font-family:var(--font-serif);
  font-size:1.5rem; font-weight:500;
  margin-bottom:0.35rem;
}
.onboard-sub { font-size:0.84rem; color:var(--text-3); margin-bottom:var(--s5); }

/* Budget multiplier band */
.mult-band {
  display:flex; border-radius:var(--r-sm);
  overflow:hidden; height:28px;
}
.mult-seg {
  display:flex; align-items:center; justify-content:center;
  font-size:0.68rem; font-weight:700; color:white;
  transition:flex var(--ease) 400ms;
}

/* Sidebar overlay */
#sidebar-overlay {
  display:none; position:fixed; inset:0;
  background:rgba(28,25,23,0.45);
  z-index:250;
}
#sidebar-overlay.show { display:block; }

/* WA banner */
#wa-banner {
  position:fixed; bottom:5rem; left:1rem; right:1rem;
  background:var(--surface);
  border:1px solid var(--amber-border);
  border-radius:var(--r-lg);
  padding:1rem; z-index:800;
  display:none; align-items:center;
  gap:0.75rem; box-shadow:var(--sh-4);
  animation:slideUp 300ms var(--ease);
}

/* ═══════════════════════════════════════════════════════
   DESKTOP LAYOUT FIX — full screen readable at all sizes
═══════════════════════════════════════════════════════ */

/* Auth screens — centred, max-width, never overflow */
.auth-screen {
  position: fixed; inset: 0;
  background: var(--bg); z-index: 9000;
  display: none; align-items: center;
  justify-content: center;
  padding: 2rem 1rem;
  overflow-y: auto;
}

/* Landing screen — generous spacing on desktop */
#screen-landing > div {
  max-width: 460px;
  width: 100%;
  text-align: center;
  padding: 2rem;
}

/* All auth cards — readable on desktop */
.onboard-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  padding: clamp(1.5rem, 4vw, 2.5rem);
  width: 100%; max-width: 520px;
  box-shadow: var(--sh-4);
  animation: slideUp var(--dur-page) var(--ease);
  margin: auto;
}

/* App shell — sidebar + main never overflow */
.app {
  display: flex;
  height: 100dvh;
  overflow: hidden;
  max-width: 1400px;
  margin: 0 auto;
}

/* Main content area — readable at all widths */
.main {
  flex: 1;
  overflow-y: auto;
  padding: var(--s6) clamp(1rem, 4vw, 3rem) calc(var(--s7) + var(--s5));
}

/* Page title — scales with screen */
.page-title {
  font-family: var(--font-serif);
  font-size: clamp(1.5rem, 3vw, 2.2rem);
  font-weight: 500;
  color: var(--text);
  line-height: 1.15;
}

/* Cards — never too wide on large screens */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: clamp(1rem, 2.5vw, 1.75rem);
  margin-bottom: var(--s4);
  box-shadow: var(--sh-1);
  transition: transform var(--dur-micro) var(--ease),
              box-shadow var(--dur-micro) var(--ease);
}

/* ═══════════════════════════════════════════════════════
   IMPROVED TYPOGRAPHY — sharper, more readable
═══════════════════════════════════════════════════════ */

/* Better base font rendering */
body {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-size: 16px;
  line-height: 1.65;
  letter-spacing: -0.01em;
}

/* Crisper headings */
h1, h2, h3, .page-title, .stat-val,
.onboard-title, .modal-title, .sheet-title {
  letter-spacing: -0.02em;
  -webkit-font-smoothing: antialiased;
}

/* Better form inputs */
.form-input {
  font-size: 15px !important;
  padding: 0.7rem 1rem;
  border-radius: var(--r-md);
  background: var(--surface);
  border: 1.5px solid var(--border-mid);
  transition: all var(--dur-micro) ease;
}
.form-input:focus {
  border-color: var(--amber);
  box-shadow: 0 0 0 3px rgba(154,111,46,0.12);
  background: var(--surface);
}

/* Better buttons */
.btn {
  font-size: 0.88rem;
  letter-spacing: 0.01em;
  font-weight: 500;
  border-radius: var(--r-md);
  padding: 0.6rem 1.25rem;
}
.btn-primary {
  background: #1C1917;
  color: white;
  border-color: transparent;
  letter-spacing: 0.02em;
}

/* ═══════════════════════════════════════════════════════
   HAPPIER COLOURS — brighter accents, better contrast
═══════════════════════════════════════════════════════ */
:root {
  /* Slightly warmer, more vibrant base */
  --bg:          #F8F5F0;
  --surface:     #FFFFFF;
  --surface-2:   #FDFCFA;
  --surface-3:   #F4F0E8;
  --text:        #1A1714;
  --text-2:      #3D3935;
  --text-3:      #6B6560;
  --text-4:      #A09890;
  --border:      #E8E2D8;
  --border-mid:  #CFC8B8;

  /* Brighter, more energetic accents */
  --sage:        #3D7A50;
  --sage-pale:   #E8F5ED;
  --sage-border: #B8D8C4;

  --terra:       #C05A3C;
  --terra-pale:  #FAEEE8;
  --terra-border:#E8C4B4;

  --slate:       #3D6898;
  --slate-pale:  #E8EFF8;
  --slate-border:#B4CCEC;

  --amber:       #B07820;
  --amber-pale:  #FBF3E0;
  --amber-border:#E8D090;

  --rose:        #A8406A;
  --rose-pale:   #FAECF2;
  --rose-border: #E8B8CC;

  --teal:        #207878;
  --teal-pale:   #E4F4F4;
  --teal-border: #98CCCC;

  --plum:        #6840A8;
  --plum-pale:   #F0ECFA;
  --plum-border: #C8B4E8;
}

/* ═══════════════════════════════════════════════════════
   PRE-FILLED SUGGESTION CHIPS
═══════════════════════════════════════════════════════ */
.suggestion-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}
.chip {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.4rem 0.75rem;
  background: var(--surface-3);
  border: 1.5px solid var(--border);
  border-radius: var(--r-pill);
  font-size: 0.8rem;
  color: var(--text-2);
  cursor: pointer;
  transition: all var(--dur-micro) ease;
  user-select: none;
  font-family: var(--font-sans);
  font-weight: 500;
}
.chip:hover {
  background: var(--amber-pale);
  border-color: var(--amber-border);
  color: var(--amber);
}
.chip.selected {
  background: var(--amber-pale);
  border-color: var(--amber);
  color: var(--amber);
  font-weight: 600;
}
.chip-label {
  font-size: 0.65rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-4);
  font-weight: 700;
  margin-bottom: 0.4rem;
  display: block;
}

/* ═══════════════════════════════════════════════════════
   FAMILY PROVISION — dormant but visible
═══════════════════════════════════════════════════════ */
.family-provision {
  background: var(--surface-2);
  border: 1.5px dashed var(--border-mid);
  border-radius: var(--r-lg);
  padding: 1.25rem;
  text-align: center;
  margin-top: 1rem;
}
.family-provision-icon {
  font-size: 1.75rem;
  margin-bottom: 0.5rem;
  opacity: 0.5;
}
.family-provision-title {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text-2);
  margin-bottom: 0.25rem;
}
.family-provision-sub {
  font-size: 0.75rem;
  color: var(--text-4);
  line-height: 1.6;
}
