/* ============================================================
   LifeOS — Design System (Revamp R1)
   Warm premium light identity. Token-driven: spacing, type,
   color, elevation scales. All component classes preserved from
   the reskin so views keep working during the refactor.
   ============================================================ */

/* ---------- 1. TOKENS ---------- */
:root {
  /* Color ramp — warm neutrals */
  --c-bg: #f2ecdf;
  --c-surface: #fffaf2;
  --c-surface-2: #f3ecdf;
  --c-surface-3: #eae0cf;
  --c-border: rgba(64, 46, 30, 0.11);
  --c-border-strong: rgba(64, 46, 30, 0.18);

  /* Ink ramp */
  --c-ink-950: #1c1511;
  --c-ink-700: #4a3f35;
  --c-ink-500: #7a6b5c;
  --c-ink-300: #75654f;

  --c-accent-600: #3d5ce0;
  --c-accent-500: #4a63d8;
  --c-accent-400: #7490ff;
  --c-accent-tint: rgba(85, 114, 242, 0.11);
  --c-accent-tint-strong: rgba(85, 114, 242, 0.18);
  --c-accent-grad: linear-gradient(135deg, #4a66ea 0%, #4d69e4 100%);

  /* Warm secondary */
  --c-warm-500: #c9802e;
  --c-warm-tint: rgba(201, 128, 46, 0.12);

  /* Status */
  --c-mint-600: #0e8f63;
  --c-mint-tint: rgba(14, 143, 99, 0.10);
  --c-amber-600: #a16207;
  --c-amber-tint: rgba(161, 98, 7, 0.12);
  --c-red-600: #d13438;
  --c-red-tint: rgba(209, 52, 56, 0.08);

  /* Type scale */
  --t-display: 26px;
  --t-h1: 21px;
  --t-h2: 18px;
  --t-h3: 16px;
  --t-body: 14px;
  --t-sm: 13px;
  --t-xs: 12px;
  --t-micro: 11px;

  /* Fonts */
  --f-display: 'Bricolage Grotesque', 'Figtree', system-ui, -apple-system, sans-serif;
  --f-body: 'Figtree', system-ui, -apple-system, 'Segoe UI', sans-serif;

  /* Spacing scale (4px base) */
  --sp-1: 4px;
  --sp-2: 8px;
  --sp-3: 12px;
  --sp-4: 16px;
  --sp-5: 20px;
  --sp-6: 24px;
  --sp-8: 32px;
  --sp-10: 40px;
  --sp-12: 48px;

  /* Radii */
  --r-sm: 8px;
  --r-md: 12px;
  --r-lg: 16px;
  --r-full: 999px;

  /* Elevation */
  --e-1: 0 1px 2px rgba(64, 46, 30, 0.05);
  --e-2: 0 1px 2px rgba(64, 46, 30, 0.05), 0 4px 14px rgba(64, 46, 30, 0.06);
  --e-3: 0 2px 4px rgba(64, 46, 30, 0.06), 0 18px 44px rgba(64, 46, 30, 0.12);
  --e-focus: 0 0 0 3px rgba(85, 114, 242, 0.18);

  /* Layout */
  --rail-w: 248px;
  --content-max: 1080px;

  /* Motion */
  --dur-fast: 120ms;
  --dur: 180ms;
  --dur-slow: 260ms;
  --ease: cubic-bezier(0.4, 0, 0.2, 1);
}

/* Back-compat aliases (old tokens → new) */
:root {
  --bg: var(--c-bg);
  --surface: var(--c-surface);
  --surface-2: var(--c-surface-2);
  --surface-3: var(--c-surface-3);
  --border: var(--c-border);
  --border-strong: var(--c-border-strong);
  --ink-950: var(--c-ink-950);
  --ink-700: var(--c-ink-700);
  --ink-500: var(--c-ink-500);
  --ink-300: var(--c-ink-300);
  --cobalt-600: var(--c-accent-600);
  --cobalt-500: var(--c-accent-500);
  --cobalt-400: var(--c-accent-400);
  --cobalt-tint: var(--c-accent-tint);
  --cobalt-tint-strong: var(--c-accent-tint-strong);
  --grad-primary: var(--c-accent-grad);
  --warm-500: var(--c-warm-500);
  --warm-tint: var(--c-warm-tint);
  --mint-600: var(--c-mint-600);
  --mint-tint: var(--c-mint-tint);
  --amber-600: var(--c-amber-600);
  --red-600: var(--c-red-600);
  --red-tint: var(--c-red-tint);
  --font-display: var(--f-display);
  --font: var(--f-body);
  --radius-sm: var(--r-sm);
  --radius: var(--r-md);
  --radius-lg: var(--r-lg);
  --shadow-sm: var(--e-1);
  --shadow: var(--e-2);
  --shadow-lg: var(--e-3);
  --shadow-focus: var(--e-focus);

  /* Phase-1 fog palette aliases (still referenced by views) */
  --color-ink-950: var(--c-ink-950);
  --color-ink-700: var(--c-ink-700);
  --color-ink-500: var(--c-ink-500);
  --color-ink-300: var(--c-ink-300);
  --color-cobalt-600: var(--c-accent-600);
  --color-mint-600: var(--c-mint-600);
  --color-amber-600: var(--c-amber-600);
  --color-red-600: var(--c-red-600);
  --color-fog-100: var(--c-border);
  --color-fog-200: var(--c-border-strong);
}

/* ---------- 2. BASE ---------- */
* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  font-family: var(--f-body);
  background: var(--c-bg);
  color: var(--c-ink-950);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

body {
  background-image:
    radial-gradient(ellipse 90% 55% at 100% 0%, rgba(196, 132, 66, 0.12), transparent),
    radial-gradient(ellipse 60% 45% at 0% 100%, rgba(85, 114, 242, 0.08), transparent),
    radial-gradient(rgba(64, 46, 30, 0.14) 0.8px, transparent 0.8px);
  background-size: 100% 100%, 100% 100%, 18px 18px;
  background-attachment: fixed;
}

h1, h2, h3, .page-title, .modal-title, .topbar-title, .rail-name {
  font-family: var(--f-display);
}

a { color: var(--c-accent-600); text-decoration: none; }

::selection { background: var(--c-accent-tint-strong); }

:focus-visible { outline: none; box-shadow: var(--e-focus); border-radius: 4px; }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--c-border-strong); border-radius: 6px; border: 3px solid var(--c-bg); }
::-webkit-scrollbar-track { background: transparent; }

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* ---------- 3. PRIMITIVES ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  font-family: var(--f-body); font-size: var(--t-sm); font-weight: 600;
  padding: 9px 14px; border-radius: var(--r-sm);
  border: 1px solid transparent; cursor: pointer;
  transition: transform var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease), background var(--dur-fast) var(--ease), border-color var(--dur-fast) var(--ease);
  white-space: nowrap;
}
.btn:active { transform: translateY(0.5px); }

.btn-primary {
  background: var(--c-accent-grad); color: #fff;
  box-shadow: 0 1px 2px rgba(85, 114, 242, 0.4), var(--e-1);
}
.btn-primary:hover { box-shadow: 0 2px 6px rgba(85, 114, 242, 0.45), var(--e-2); }

.btn-secondary {
  background: var(--c-surface); color: var(--c-ink-700);
  border-color: var(--c-border-strong);
  box-shadow: var(--e-1);
}
.btn-secondary:hover { background: var(--c-surface-2); border-color: rgba(64, 46, 30, 0.24); }

.btn-ghost { background: transparent; color: var(--c-ink-500); }
.btn-ghost:hover { background: var(--c-surface-3); color: var(--c-ink-700); }

.btn-danger { background: var(--c-red-tint); color: var(--c-red-600); }
.btn-danger:hover { background: rgba(209, 52, 56, 0.14); }

.btn-sm { padding: 5px 10px; font-size: var(--t-xs); border-radius: 7px; }

.icon-btn {
  background: transparent; border: none; cursor: pointer;
  color: var(--c-ink-300); font-size: 15px; padding: 4px 6px; border-radius: 6px;
  transition: color var(--dur-fast) var(--ease), background var(--dur-fast) var(--ease);
}
.icon-btn:hover { color: var(--c-ink-700); background: var(--c-surface-3); }
.icon-btn.danger:hover { color: var(--c-red-600); background: var(--c-red-tint); }

/* Cards */
.card {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--r-md);
  box-shadow: var(--e-2);
}

/* Inputs */
input[type='text'], input:not([type]), input[type='number'], input[type='date'], input[type='time'], input[type='password'], select, textarea {
  width: 100%; padding: 9px 12px;
  font-family: var(--f-body); font-size: var(--t-sm); color: var(--c-ink-950);
  background: var(--c-surface);
  border: 1px solid var(--c-border-strong); border-radius: var(--r-sm);
  transition: border-color var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease);
}
input[type='text']:focus, input:not([type]):focus, input[type='number']:focus, input[type='date']:focus, input[type='time']:focus, input[type='password']:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--c-accent-500);
  box-shadow: 0 0 0 3px var(--c-accent-tint);
}
input::placeholder { color: var(--c-ink-300); }

.form-field { margin-bottom: 14px; }
.form-field label {
  display: block; font-size: var(--t-xs); font-weight: 600; color: var(--c-ink-700);
  margin-bottom: 6px;
}
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; }
@media (max-width: 640px) { .form-row, .form-row-3 { grid-template-columns: 1fr; } }

.form-err {
  font-size: var(--t-xs); color: var(--c-red-600); margin-top: 8px;
  background: var(--c-red-tint); padding: 8px 10px; border-radius: 7px;
}

/* Password reveal */
.pw-wrap { position: relative; }
.pw-toggle {
  position: absolute; right: 10px; top: 50%; transform: translateY(-50%);
  background: none; border: none; cursor: pointer;
  font-size: var(--t-xs); font-weight: 600; color: var(--c-ink-300);
  font-family: var(--f-body); padding: 4px 6px; border-radius: 6px;
  transition: color var(--dur-fast) var(--ease);
}
.pw-toggle:hover { color: var(--c-accent-600); }

/* ============ 4. LAYOUT ============ */
.app-shell { display: flex; min-height: 100vh; }

/* Rail — full and mini (Linear-style icon rail) */
.rail {
  width: var(--rail-w); flex-shrink: 0;
  background: rgba(255, 250, 242, 0.75);
  backdrop-filter: blur(14px);
  border-right: 1px solid var(--c-border);
  display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh;
  padding: 18px 14px;
  transition: width var(--dur) var(--ease);
  overflow: hidden;
}
.rail-mini .rail { width: 62px; padding: 18px 8px; }

.rail-brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 18px; position: relative; }
.rail-mark {
  width: 34px; height: 34px; border-radius: 10px; flex-shrink: 0;
  background: var(--c-accent-grad);
  color: #fff; font-family: var(--f-display); font-weight: 700; font-size: 15px;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 2px 8px rgba(85, 114, 242, 0.4);
}
.rail-word { min-width: 0; transition: opacity var(--dur-fast) var(--ease); }
.rail-name { font-size: 16px; font-weight: 700; line-height: 1.1; white-space: nowrap; }
.rail-sub { font-size: 11px; color: var(--c-ink-300); font-weight: 500; white-space: nowrap; }
.rail-collapse {
  position: absolute; right: 2px; top: 2px;
  display: flex; align-items: center; justify-content: center;
  width: 24px; height: 24px;
  transition: transform var(--dur) var(--ease);
}
.rail-mini .rail-collapse { transform: rotate(180deg); right: 14px; }
.rail-mini .rail-word { opacity: 0; pointer-events: none; }

.nav-group { margin-bottom: 6px; }
.nav-group-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 8px 6px; font-size: 11px; font-weight: 700;
  letter-spacing: 0.08em; text-transform: uppercase; color: var(--c-ink-300);
  cursor: pointer; user-select: none; white-space: nowrap;
}
.nav-group-chev { font-size: 9px; transition: transform var(--dur-fast) var(--ease); }
.nav-group.collapsed .nav-group-chev { transform: rotate(-90deg); }
.nav-group.collapsed .nav-group-items { display: none; }
.rail-mini .nav-group-head { justify-content: center; padding: 8px 0 6px; }
.rail-mini .nav-group-label, .rail-mini .nav-group-chev { display: none; }
.rail-mini .nav-group.collapsed .nav-group-items { display: block; }
.rail-mini .nav-group.collapsed .nav-group-chev { transform: none; }

.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; border-radius: 9px;
  font-size: var(--t-sm); font-weight: 500; color: var(--c-ink-500);
  cursor: pointer; border: none; background: transparent; width: 100%;
  text-align: left; font-family: var(--f-body); text-decoration: none;
  transition: background var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease);
  white-space: nowrap;
}
.nav-item:hover { background: var(--c-surface-2); color: var(--c-ink-950); }
.nav-item.active {
  background: var(--c-accent-tint); color: var(--c-accent-600); font-weight: 600;
  box-shadow: inset 0 0 0 1px rgba(85, 114, 242, 0.14);
}
.nav-icon { width: 20px; text-align: center; display: inline-flex; justify-content: center; flex-shrink: 0; }
.rail-mini .nav-item { justify-content: center; padding: 9px 0; }
.rail-mini .nav-label { display: none; }

.rail-foot { margin-top: auto; padding-top: 12px; border-top: 1px solid var(--c-border); }

.main-col { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 28px;
  background: rgba(255, 250, 242, 0.65);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--c-border);
  position: sticky; top: 0; z-index: 20;
}
.topbar-left { display: flex; align-items: baseline; gap: 10px; min-width: 0; }
.topbar-title { font-size: var(--t-h2); font-weight: 700; white-space: nowrap; }
.topbar-route {
  font-size: var(--t-micro); font-weight: 600; letter-spacing: 0.04em;
  color: var(--c-ink-300); text-transform: uppercase; white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis;
}
.topbar-right { display: flex; align-items: center; gap: 12px; flex-shrink: 0; }

.xp-pill {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: var(--t-xs); font-weight: 600; color: var(--c-ink-700);
  background: var(--c-surface); border: 1px solid var(--c-border);
  padding: 6px 12px; border-radius: var(--r-full); box-shadow: var(--e-1);
}
.xp-pill b { color: var(--c-accent-600); font-variant-numeric: tabular-nums; }

.content { padding: 26px 28px 48px; max-width: var(--content-max); width: 100%; margin: 0 auto; }

/* Page header */
.page-hdr {
  display: flex; align-items: flex-end; justify-content: space-between;
  margin-bottom: 20px; gap: 16px; flex-wrap: wrap;
}
.page-title { font-size: var(--t-display); font-weight: 700; letter-spacing: -0.02em; }
.page-sub { font-size: var(--t-sm); color: var(--c-ink-500); margin-top: 3px; }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- 5. COMPONENTS ---------- */
/* Metrics */
.metric-grid {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px;
  margin-bottom: 22px;
}
.metric {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--r-md);
  padding: 16px 18px;
  box-shadow: var(--e-2);
  transition: transform var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease);
  position: relative; overflow: hidden;
}
.metric:hover { transform: translateY(-1px); box-shadow: var(--e-3); }
.metric::after {
  content: ''; position: absolute; inset: 0;
  background: radial-gradient(80% 60% at 100% 0%, var(--c-accent-tint), transparent);
  opacity: 0.6; pointer-events: none;
}
.metric-lbl, .metric-label {
  font-size: var(--t-micro); font-weight: 700; letter-spacing: 0.08em;
  text-transform: uppercase; color: var(--c-ink-300); margin-bottom: 8px;
}
.metric-val, .metric-value {
  font-family: var(--f-display); font-size: 26px; font-weight: 700;
  color: var(--c-ink-950); letter-spacing: -0.02em; font-variant-numeric: tabular-nums;
}
.metric-sub { font-size: var(--t-xs); color: var(--c-ink-500); margin-top: 4px; }

/* Sections */
.today-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 860px) { .today-grid { grid-template-columns: 1fr; } }

.section { margin-bottom: 18px; }
.section-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 10px; padding: 0 2px;
}
.section-title {
  font-size: var(--t-micro); font-weight: 700; letter-spacing: 0.08em;
  text-transform: uppercase; color: var(--c-ink-500);
}
.section-action { font-size: var(--t-xs); font-weight: 600; color: var(--c-accent-600); background: none; border: none; cursor: pointer; }
.section-action:hover { text-decoration: underline; }

/* Check rows */
.check-row {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  background: var(--c-surface); border: 1px solid var(--c-border);
  border-radius: var(--r-md); padding: 12px 14px; margin-bottom: 8px;
  box-shadow: var(--e-1);
  transition: border-color var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease);
}
.check-row:hover { border-color: var(--c-border-strong); box-shadow: var(--e-2); }
.cr-label { font-size: var(--t-body); font-weight: 600; color: var(--c-ink-950); }
.cr-meta { font-size: var(--t-xs); color: var(--c-ink-300); font-weight: 500; }
.cr-right { display: flex; align-items: center; gap: 8px; }

.check-box {
  width: 20px; height: 20px; border-radius: 7px;
  border: 2px solid var(--c-border-strong);
  background: var(--c-surface); cursor: pointer; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  transition: all var(--dur-fast) var(--ease); color: transparent; font-size: 12px; font-weight: 700;
}
.check-box:hover { border-color: var(--c-accent-500); box-shadow: 0 0 0 3px var(--c-accent-tint); }
.check-row.done .check-box {
  background: var(--c-accent-grad); border-color: transparent; color: #fff;
  box-shadow: 0 2px 6px rgba(85, 114, 242, 0.4);
}
.check-row.done .cr-label { color: var(--c-ink-300); text-decoration: line-through; }

/* Empty / loading states */
.empty-state, .state-box {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center; padding: 34px 20px;
  background: var(--c-surface);
  border: 1.5px dashed var(--c-border-strong);
  border-radius: var(--r-md);
  color: var(--c-ink-500);
}
.empty-state-icon, .state-icon { font-size: 26px; margin-bottom: 8px; opacity: 0.7; }
.empty-state-title, .state-title { font-size: var(--t-body); font-weight: 600; color: var(--c-ink-700); margin-bottom: 4px; }
.empty-state-sub, .state-sub { font-size: var(--t-xs); color: var(--c-ink-300); margin-bottom: 12px; }

.loading-state, .error-state {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 70px 20px; color: var(--c-ink-500); text-align: center;
}
.loading-state .spinner {
  width: 26px; height: 26px; border-radius: 50%;
  border: 3px solid var(--c-accent-tint); border-top-color: var(--c-accent-500);
  animation: spin 0.8s linear infinite; margin-bottom: 14px;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Modals & overlays */
.overlay {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(28, 21, 17, 0.42);
  backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
  animation: fadeIn var(--dur-fast) var(--ease);
}
.modal {
  background: var(--c-surface); border-radius: var(--r-lg);
  box-shadow: var(--e-3);
  width: 100%; max-width: 460px; max-height: 88vh; overflow-y: auto;
  padding: 22px; animation: modalIn var(--dur) var(--ease);
}
@keyframes modalIn { from { opacity: 0; transform: translateY(8px) scale(0.98); } to { opacity: 1; transform: none; } }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.modal-title { font-size: var(--t-h2); font-weight: 700; }
.modal-head {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  margin-bottom: 16px;
}
.modal-head .icon-btn { flex-shrink: 0; }
.modal-body { font-size: var(--t-body); color: var(--c-ink-700); }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }

.sheet {
  background: var(--c-surface); border-radius: var(--r-lg) var(--r-lg) 0 0;
  padding: 12px; width: 100%; box-shadow: var(--e-3);
  animation: sheetIn var(--dur) var(--ease);
}
@keyframes sheetIn { from { transform: translateY(24px); opacity: 0.6; } to { transform: none; opacity: 1; } }
.sheet-item {
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 12px 14px; font-size: var(--t-body); font-weight: 500; color: var(--c-ink-700);
  background: none; border: none; border-radius: 10px; cursor: pointer;
  font-family: var(--f-body);
}
.sheet-item:hover { background: var(--c-surface-2); }

/* Toasts */
.toast {
  position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%);
  background: var(--c-ink-950); color: #fff;
  font-size: var(--t-sm); font-weight: 500; padding: 10px 18px; border-radius: var(--r-full);
  box-shadow: var(--e-3); z-index: 200;
  animation: toastIn var(--dur) var(--ease);
}
@keyframes toastIn { from { opacity: 0; transform: translateX(-50%) translateY(10px); } to { opacity: 1; transform: translateX(-50%); } }

/* Auth */
.auth-wrap {
  min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px;
}
.auth-card {
  width: 100%; max-width: 380px; padding: 34px 32px;
  background: var(--c-surface); border: 1px solid var(--c-border);
  border-radius: var(--r-lg); box-shadow: var(--e-3);
}
.auth-logo { display: flex; align-items: center; gap: 10px; margin-bottom: 24px; }
.auth-logo .rail-mark { width: 40px; height: 40px; font-size: 17px; border-radius: 12px; }
.auth-logo .rail-name { font-size: 19px; }
.auth-card .auth-title { font-size: var(--t-h1); margin-bottom: 6px; font-family: var(--f-display); font-weight: 700; }
.auth-card .auth-sub { font-size: var(--t-sm); color: var(--c-ink-500); margin-bottom: 22px; }
.auth-card .btn-primary { width: 100%; padding: 11px; font-size: var(--t-body); }

/* Finance */
.fin-table-wrap { overflow-x: auto; }
.fin-table { width: 100%; border-collapse: collapse; font-size: var(--t-sm); }
.fin-table th {
  text-align: left; font-size: var(--t-micro); text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--c-ink-300); font-weight: 700; padding: 8px 10px;
  border-bottom: 1px solid var(--c-border);
}
.fin-table td { padding: 11px 10px; border-bottom: 1px solid var(--c-border); color: var(--c-ink-700); vertical-align: top; }
.fin-table tbody tr { transition: background var(--dur-fast) var(--ease); }
.fin-table tbody tr:hover { background: var(--c-surface-2); }
.fin-table tr:last-child td { border-bottom: none; }
.fin-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px 2px; border-bottom: 1px solid var(--c-border);
  font-size: var(--t-sm); color: var(--c-ink-700);
}
.fin-row:last-child { border-bottom: none; }
.util-bar { height: 5px; border-radius: 4px; background: var(--c-surface-3); margin: 2px 2px 10px; overflow: hidden; }
.util-bar div { height: 100%; border-radius: 4px; }

/* ---------- 6. COMMAND PALETTE (R2) ---------- */
.cmd-overlay { z-index: 300; }
.cmd-modal {
  max-width: 560px; padding: 0; overflow: hidden;
}
.cmd-input {
  width: 100%; border: none; border-bottom: 1px solid var(--c-border);
  padding: 16px 18px; font-size: var(--t-body); background: transparent;
  border-radius: 0; font-family: var(--f-body);
}
.cmd-input:focus { outline: none; box-shadow: none; border-bottom-color: var(--c-accent-500); }
.cmd-list { max-height: 320px; overflow-y: auto; padding: 8px; }
.cmd-item {
  display: flex; align-items: center; gap: 12px; width: 100%;
  padding: 10px 12px; font-size: var(--t-sm); font-weight: 500; color: var(--c-ink-700);
  background: none; border: none; border-radius: 8px; cursor: pointer;
  font-family: var(--f-body); text-align: left;
}
.cmd-item:hover, .cmd-item.selected { background: var(--c-accent-tint); color: var(--c-accent-600); }
.cmd-item .cmd-icon { width: 20px; text-align: center; }
.cmd-item .cmd-kbd { margin-left: auto; font-size: var(--t-micro); color: var(--c-ink-300); background: var(--c-surface-2); padding: 2px 6px; border-radius: 4px; }

/* ---------- 7. DARK MODE (R7) ---------- */
[data-theme='dark'] {
  --c-bg: #171310;
  --c-surface: #211b16;
  --c-surface-2: #2a231d;
  --c-surface-3: #352c24;
  --c-border: rgba(255, 250, 242, 0.08);
  --c-border-strong: rgba(255, 250, 242, 0.16);
  --c-ink-950: #f3ede4;
  --c-ink-700: #d4c9bb;
  --c-ink-500: #a89782;
  --c-ink-300: #948676;
  --c-accent-600: #8ba0ff;
  --c-accent-500: #6f86f5;
  --c-accent-400: #5a72e0;
  --c-accent-tint: rgba(111, 134, 245, 0.16);
  --c-accent-tint-strong: rgba(111, 134, 245, 0.24);
  --e-1: 0 1px 2px rgba(0, 0, 0, 0.4);
  --e-2: 0 1px 2px rgba(0, 0, 0, 0.4), 0 4px 14px rgba(0, 0, 0, 0.35);
  --e-3: 0 2px 4px rgba(0, 0, 0, 0.45), 0 18px 44px rgba(0, 0, 0, 0.5);
}
[data-theme='dark'] body {
  background-image:
    radial-gradient(ellipse 90% 55% at 100% 0%, rgba(196, 132, 66, 0.06), transparent),
    radial-gradient(ellipse 60% 45% at 0% 100%, rgba(85, 114, 242, 0.08), transparent),
    radial-gradient(rgba(255, 250, 242, 0.08) 0.8px, transparent 0.8px);
}
[data-theme='dark'] .rail { background: rgba(33, 27, 22, 0.75); }
[data-theme='dark'] .topbar { background: rgba(33, 27, 22, 0.65); }
[data-theme='dark'] .mobile-nav { background: rgba(33, 27, 22, 0.92); }
[data-theme='dark'] .btn-secondary { background: var(--c-surface-2); }
[data-theme='dark'] .overlay { background: rgba(0, 0, 0, 0.55); }
[data-theme='dark'] .toast { background: #f3ede4; color: #171310; }
[data-theme='dark'] .xp-pill, [data-theme='dark'] .auth-card, [data-theme='dark'] .modal, [data-theme='dark'] .sheet { background: var(--c-surface); }

/* ---------- 8. MOBILE ---------- */
.mobile-nav {
  display: none; position: fixed; bottom: 0; left: 0; right: 0; z-index: 50;
  background: rgba(255, 250, 242, 0.92); backdrop-filter: blur(14px);
  border-top: 1px solid var(--c-border);
}
.mobile-nav-item {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 3px;
  padding: 10px 4px 12px; font-size: 10.5px; font-weight: 600; color: var(--c-ink-300);
  background: none; border: none; cursor: pointer; font-family: var(--f-body);
  min-height: 48px;
}
.mobile-nav-item.active { color: var(--c-accent-600); }

@media (max-width: 760px) {
  .rail { display: none; }
  .mobile-nav { display: flex; }
  .content { padding: 18px 16px 90px; }
  .topbar { padding: 12px 16px; }
  .metric-grid { grid-template-columns: repeat(2, 1fr); }
}

/* ---------- 9. COMPONENT SYSTEM (R3) ---------- */
/* Chips */
.chip {
  display: inline-flex; align-items: center;
  font-size: 11px; font-weight: 600; letter-spacing: 0.02em;
  padding: 3px 9px; border-radius: var(--r-full);
  background: var(--c-surface-2); color: var(--c-ink-700);
  border: 1px solid var(--c-border);
  white-space: nowrap;
}
.chip-accent { background: var(--c-accent-tint); color: var(--c-accent-600); border-color: transparent; }
.chip-mint { background: var(--c-mint-tint); color: var(--c-mint-600); border-color: transparent; }
.chip-amber { background: var(--c-amber-tint); color: var(--c-amber-600); border-color: transparent; }
.chip-red { background: var(--c-red-tint); color: var(--c-red-600); border-color: transparent; }
.chip-warm { background: var(--c-warm-tint); color: var(--c-warm-500); border-color: transparent; }

/* Progress bars */
.progress {
  height: 6px; border-radius: 4px; background: var(--c-surface-3);
  overflow: hidden; position: relative;
}
.progress-fill {
  height: 100%; border-radius: 4px;
  transition: width var(--dur-slow) var(--ease);
}
.pb-cobalt { background: var(--c-accent-500); }
.pb-mint { background: var(--c-mint-600); }
.pb-amber { background: var(--c-amber-600); }
.pb-red { background: var(--c-red-600); }

/* Tabs */
.tabs {
  display: inline-flex; gap: 2px; padding: 3px;
  background: var(--c-surface-2); border-radius: 10px;
  border: 1px solid var(--c-border);
}
.tab {
  font-family: var(--f-body); font-size: var(--t-xs); font-weight: 600;
  padding: 6px 14px; border-radius: 7px; border: none; cursor: pointer;
  background: transparent; color: var(--c-ink-500);
  transition: background var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease);
}
.tab:hover { color: var(--c-ink-700); }
.tab.active { background: var(--c-surface); color: var(--c-accent-600); box-shadow: var(--e-1); }

/* Skeletons */
.skeleton-wrap { display: flex; flex-direction: column; gap: 10px; }
.skeleton-row {
  height: 46px; border-radius: var(--r-md);
  background: linear-gradient(90deg, var(--c-surface-2) 25%, var(--c-surface) 50%, var(--c-surface-2) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.4s infinite;
}
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }
@media (prefers-reduced-motion: reduce) {
  .skeleton-row { animation: none; background: var(--c-surface-2); }
}

/* Dark mode component tweaks */
[data-theme='dark'] .chip { background: var(--c-surface-2); color: var(--c-ink-500); }
[data-theme='dark'] .tab.active { background: var(--c-surface-2); }
[data-theme='dark'] .tabs { background: var(--c-surface-2); }

/* ---------- 10. TODAY COMMAND CENTER (R4) ---------- */
.next-strip {
  display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 18px;
}
.next-action {
  display: inline-flex; align-items: center; gap: 8px;
  font-family: var(--f-body); font-size: var(--t-sm); font-weight: 600;
  color: var(--c-ink-700); background: var(--c-surface);
  border: 1px solid var(--c-border); border-radius: 10px;
  padding: 8px 13px; cursor: pointer;
  box-shadow: var(--e-1);
  transition: border-color var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease), transform var(--dur-fast) var(--ease);
}
.next-action:hover { border-color: var(--c-accent-500); box-shadow: var(--e-2); transform: translateY(-1px); }
.next-icon { display: inline-flex; color: var(--c-accent-600); }
.next-arrow { margin-left: 6px; color: var(--c-ink-300); transition: transform var(--dur-fast) var(--ease); }
.next-action:hover .next-arrow { transform: translateX(3px); }

.xp-ring-wrap { position: relative; width: 44px; height: 44px; }
.xp-ring { width: 44px; height: 44px; transform: rotate(-90deg); }
.xp-ring circle { fill: none; stroke-width: 3; }
.xp-ring-bg { stroke: var(--c-surface-3); }
.xp-ring-fg {
  stroke: var(--c-accent-500); stroke-linecap: round;
  stroke-dasharray: 97.4; stroke-dashoffset: 40;
  transition: stroke-dashoffset var(--dur-slow) var(--ease);
}
.xp-ring-num {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  font-family: var(--f-display); font-size: 13px; font-weight: 700; color: var(--c-accent-600);
}
.xp-dot { color: var(--c-ink-300); }
.xp-today { color: var(--c-mint-600); }

/* ---------- 11. FINANCE DENSITY (R5) ---------- */
.currency-balance {
  display: flex; height: 6px; border-radius: 4px; overflow: hidden;
  margin: -2px 2px 10px; gap: 2px;
}
.currency-balance div { border-radius: 4px; min-width: 3px; }
.cb-loans { background: var(--c-accent-500); }
.cb-cards { background: var(--c-warm-500); }
.cb-borrowed { background: var(--c-mint-600); }

/* ---------- 12. MOTION (R6) ---------- */
.main-col .content { animation: viewIn var(--dur) var(--ease); }
@keyframes viewIn { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) {
  .main-col .content { animation: none; }
}

/* ---------- 13. TODAY HERO (Identity revamp) ---------- */
.hero {
  display: flex; justify-content: space-between; align-items: flex-start; gap: 20px;
  background: var(--c-accent-grad);
  border-radius: var(--r-lg);
  padding: 26px 28px; margin-bottom: 14px;
  color: #fff; position: relative; overflow: hidden;
}
.hero::after {
  content: ''; position: absolute; inset: 0;
  background:
    radial-gradient(60% 80% at 90% 10%, rgba(255, 255, 255, 0.22), transparent),
    radial-gradient(rgba(255, 255, 255, 0.12) 0.8px, transparent 0.8px);
  background-size: 100% 100%, 16px 16px;
  pointer-events: none;
}
.hero-main { position: relative; z-index: 1; min-width: 0; }
.hero-greet { font-size: var(--t-sm); font-weight: 600; opacity: 0.85; margin-bottom: 2px; }
.hero-title { font-family: var(--f-display); font-size: 24px; font-weight: 700; letter-spacing: -0.02em; }
.hero-sub { font-size: var(--t-xs); opacity: 0.85; margin-top: 4px; }
.streak-flame { font-size: 13px; }
.hero .next-strip { margin-top: 16px; }
.hero .next-action {
  background: rgba(255, 255, 255, 0.16); border-color: rgba(255, 255, 255, 0.28);
  color: #fff; box-shadow: none; backdrop-filter: blur(4px);
}
.hero .next-action:hover { background: rgba(255, 255, 255, 0.26); border-color: rgba(255, 255, 255, 0.4); }
.hero .next-icon { color: #fff; }
.hero .next-arrow { color: rgba(255, 255, 255, 0.7); }

.hero-side { position: relative; z-index: 1; display: flex; flex-direction: column; align-items: flex-end; gap: 4px; flex-shrink: 0; }
.hero-ring { position: relative; width: 56px; height: 56px; margin-bottom: 4px; }
.hero-ring .xp-ring { width: 56px; height: 56px; transform: rotate(-90deg); }
.hero-ring .xp-ring-bg { stroke: rgba(255, 255, 255, 0.25); }
.hero-ring .xp-ring-fg { stroke: #fff; stroke-dasharray: 97.4; stroke-dashoffset: 40; }
.hero-ring .xp-ring-num {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  font-family: var(--f-display); font-size: 17px; font-weight: 700;
}
.hero-ring-cap { position: absolute; left: 50%; transform: translateX(-50%); top: 100%; font-size: 10px; font-weight: 600; opacity: 0.85; white-space: nowrap; }
.hero-total, .hero-best { font-size: var(--t-xs); opacity: 0.9; }
.hero-total b, .hero-best b { font-family: var(--f-display); font-size: 13px; }

/* Heat strip */
.heat-strip {
  display: grid; grid-template-columns: repeat(7, 1fr); gap: 8px;
  margin-bottom: 18px;
}
.heat-cell {
  height: 34px; border-radius: 8px;
  background: var(--c-surface-2);
  display: flex; align-items: center; justify-content: center;
  font-size: var(--t-micro); font-weight: 700; color: var(--c-ink-300);
  border: 1px solid var(--c-border);
  transition: transform var(--dur-fast) var(--ease);
}
.heat-cell:hover { transform: translateY(-1px); }
.heat-1 { background: rgba(85, 114, 242, 0.18); color: var(--c-accent-600); border-color: transparent; }
.heat-2 { background: rgba(85, 114, 242, 0.40); color: #fff; border-color: transparent; }
.heat-3 { background: var(--c-accent-500); color: #fff; border-color: transparent; }

[data-theme='dark'] .hero { box-shadow: 0 4px 24px rgba(0, 0, 0, 0.35); }
[data-theme='dark'] .heat-1 { color: #fff; }

/* ---------- 15. MODULE HEROES (extended identity language) ---------- */
/* Module gradients — one per module, same structure as the Today hero */
.hero-habits { background: linear-gradient(120deg, #0e9f6e 0%, #34c98a 100%); }
.hero-nutrition { background: linear-gradient(120deg, #e07a2f 0%, #f0a055 100%); }
.hero-supplements { background: linear-gradient(120deg, #7c5cd6 0%, #a48aef 100%); }
.hero-focus { background: linear-gradient(120deg, #d14f6e 0%, #ef7d9a 100%); }
.hero-finance { background: linear-gradient(120deg, #0d9488 0%, #35c4b6 100%); }
.hero-today { background: linear-gradient(120deg, #4a66ea 0%, #7188ff 100%); }

/* Hero actions — glass pill buttons (matches Today) */
.hero-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }
.hero-actions .btn {
  background: rgba(255, 255, 255, 0.16); border-color: rgba(255, 255, 255, 0.28);
  color: #fff; box-shadow: none; backdrop-filter: blur(4px);
  font-weight: 600;
}
.hero-actions .btn:hover { background: rgba(255, 255, 255, 0.26); border-color: rgba(255, 255, 255, 0.4); }

/* Hero stats — compact stat stack on the right */
.hero-stats { align-items: flex-end; gap: 8px; }
.hero-stat {
  text-align: right; line-height: 1.25;
}
.hero-stat-lbl {
  display: block; font-size: 10px; font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.06em; opacity: 0.8;
}
.hero-stat b {
  font-family: var(--f-display); font-size: 17px; font-weight: 700;
}

/* Dark mode — heroes stay bright as focal points */
[data-theme='dark'] .hero-habits { background: linear-gradient(120deg, #0d8a5e 0%, #2fbd8d 100%); }
[data-theme='dark'] .hero-nutrition { background: linear-gradient(120deg, #c96a24 0%, #f09a55 100%); }
[data-theme='dark'] .hero-supplements { background: linear-gradient(120deg, #6a4cc4 0%, #a48aef 100%); }
[data-theme='dark'] .hero-focus { background: linear-gradient(120deg, #b9445f 0%, #ef7d9a 100%); }
[data-theme='dark'] .hero-finance { background: linear-gradient(120deg, #0a7d73 0%, #35c4b6 100%); }
[data-theme='dark'] .hero-today { background: linear-gradient(120deg, #3d5ce0 0%, #7d93ff 100%); }

/* ---------- 16. BATCH A — micro-details ---------- */
/* Check-box pop on done */
.check-row.done .check-box { animation: checkPop 0.28s var(--ease); }
@keyframes checkPop {
  0% { transform: scale(1); }
  40% { transform: scale(1.18); }
  70% { transform: scale(0.94); }
  100% { transform: scale(1); }
}
@media (prefers-reduced-motion: reduce) {
  .check-row.done .check-box { animation: none; }
}

/* Button press state */
.btn:active, .icon-btn:active, .next-action:active, .nav-item:active { transform: scale(0.97); }
@media (prefers-reduced-motion: reduce) {
  .btn:active, .icon-btn:active, .next-action:active, .nav-item:active { transform: none; }
}

/* Staggered section entrance */
.section { animation: sectionUp 0.32s var(--ease) backwards; }
.section:nth-child(1) { animation-delay: 0.03s; }
.section:nth-child(2) { animation-delay: 0.07s; }
.section:nth-child(3) { animation-delay: 0.11s; }
.section:nth-child(4) { animation-delay: 0.15s; }
.section:nth-child(5) { animation-delay: 0.19s; }
@keyframes sectionUp { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) {
  .section { animation: none; }
}

/* Toast variants */
.toast.toast-success { background: var(--c-mint-600); }
.toast.toast-error { background: var(--c-red-600); }
.toast.toast-neutral { background: var(--c-ink-950); }
[data-theme='dark'] .toast.toast-neutral { background: #f3ede4; color: #171310; }

/* ---------- 17. BATCH B — data visual ---------- */
/* Focus timer ring */
.timer-ring-wrap { position: relative; width: 112px; height: 112px; margin: 0 auto; }
.timer-ring { width: 112px; height: 112px; transform: rotate(-90deg); }
.timer-ring circle { fill: none; stroke-width: 5; }
.timer-ring .xp-ring-bg { stroke: var(--c-surface-3); }
.timer-ring-fg { stroke: var(--c-accent-500); stroke-linecap: round; stroke-dasharray: 97.4; transition: stroke-dashoffset 1s linear; }
.timer-ring-num {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  font-family: var(--f-display); font-size: 23px; font-weight: 700; font-variant-numeric: tabular-nums;
  color: var(--c-ink-950);
}
[data-theme='dark'] .timer-ring-num { color: var(--c-ink-950); }

/* Hero sparkline */
.hero-spark { margin-top: 2px; opacity: 0.9; }
.hero-spark svg { display: block; }

/* Nutrition macro bars */
.macro-bars { margin-top: 4px; }
.macro-row { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; font-size: 12px; }
.macro-lbl { width: 56px; color: var(--c-ink-500); font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; font-size: 10.5px; }
.macro-bar { flex: 1; height: 6px; border-radius: 4px; background: var(--c-surface-3); overflow: hidden; }
.macro-bar div { height: 100%; border-radius: 4px; transition: width var(--dur-slow) var(--ease); }
.macro-val { width: 64px; text-align: right; color: var(--c-ink-700); font-variant-numeric: tabular-nums; font-weight: 600; }

/* Finance donut */
.donut-wrap { display: flex; align-items: center; gap: 14px; padding: 6px 2px 12px; }
.donut-legend { display: flex; flex-direction: column; gap: 5px; font-size: 12.5px; color: var(--c-ink-700); }
.donut-legend .dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; }

/* ---------- 18. BATCH C — level/rank ---------- */
.level-card {
  display: flex; align-items: center; gap: 16px;
  background: var(--c-surface); border: 1px solid var(--c-border);
  border-radius: var(--r-md); padding: 14px 18px; margin-bottom: 18px;
  box-shadow: var(--e-1);
}
.level-rank {
  font-family: var(--f-display); font-size: 18px; font-weight: 700;
  background: var(--c-accent-grad); color: #fff;
  padding: 8px 16px; border-radius: 10px; white-space: nowrap;
  box-shadow: 0 2px 8px rgba(85, 114, 242, 0.3);
}
.level-num { font-size: 14px; color: var(--c-ink-700); font-weight: 600; white-space: nowrap; }
.level-num b { font-family: var(--f-display); font-size: 20px; color: var(--c-ink-950); }
.level-bar { flex: 1; min-width: 120px; }
.level-sub { font-size: 12px; color: var(--c-ink-300); white-space: nowrap; }

@media (max-width: 640px) {
  .level-card { flex-wrap: wrap; gap: 10px; }
  .level-sub { flex-basis: 100%; white-space: normal; }
}

/* ---------- 19. BATCH D — finishing screens ---------- */
/* Auth page — gradient-tinted backdrop to match the app */
.auth-wrap {
  background:
    radial-gradient(60% 80% at 10% 0%, rgba(74, 102, 234, 0.14), transparent),
    radial-gradient(50% 70% at 100% 20%, rgba(124, 92, 214, 0.12), transparent),
    radial-gradient(60% 70% at 50% 110%, rgba(14, 159, 110, 0.10), transparent),
    var(--c-bg);
}
[data-theme='dark'] .auth-wrap {
  background:
    radial-gradient(60% 80% at 10% 0%, rgba(74, 102, 234, 0.22), transparent),
    radial-gradient(50% 70% at 100% 20%, rgba(124, 92, 214, 0.18), transparent),
    radial-gradient(60% 70% at 50% 110%, rgba(14, 159, 110, 0.14), transparent),
    var(--c-bg);
}

/* Settings cards — consistent padding helper */
.today-grid .card { box-shadow: var(--e-1); }

/* ---------- 20. FOCUS TIMER (customizable + live) ---------- */
.focus-card { width: 100%; }
.focus-status {
  font-size: 12px; color: var(--c-ink-500); margin-top: 8px;
  text-transform: uppercase; letter-spacing: 0.08em;
}
.focus-status b { color: var(--c-ink-700); }
.focus-duration {
  display: flex; gap: 8px; justify-content: center; margin-top: 16px; flex-wrap: wrap;
}
.chip-btn {
  font-family: var(--f-body); font-size: var(--t-xs); font-weight: 600;
  padding: 7px 14px; border-radius: var(--r-full);
  border: 1px solid var(--c-border-strong); background: var(--c-surface);
  color: var(--c-ink-700); cursor: pointer;
  transition: all var(--dur-fast) var(--ease);
}
.chip-btn:hover { border-color: var(--c-accent-500); color: var(--c-accent-600); }
.chip-btn.active {
  background: var(--c-accent-grad); border-color: transparent; color: #fff;
  box-shadow: 0 2px 6px rgba(85, 114, 242, 0.35);
}
.btn-lg { padding: 12px 26px; font-size: var(--t-body); }
