/* ─────────────────────────────────────────────────────────────────────────
   LifeBase · design tokens + layout
   Warm neutral palette, subtle accents, comfortable typographic rhythm.
   ───────────────────────────────────────────────────────────────────────── */

:root {
  /* Surfaces */
  --bg: #f7f5f0;
  --surface: #ffffff;
  --surface-2: #f0ede5;
  --surface-3: #e7e3d8;

  /* Fallbacks for browsers without oklch() */
  --border: #e3e0d8;
  --border-strong: #d1cdc3;
  --text: #2b2924;
  --text-2: #6b665c;
  --text-3: #9b9689;
  --accent: #5266B8;
  --accent-soft: #e8ebf5;
  --positive: #3f8870;
  --positive-soft: #e3f3ed;
  --warning: #b5832c;
  --warning-soft: #f5efe0;
  --danger: #b5333a;
  --danger-soft: #f5e3e4;
  --shadow-1: 0 1px 0 rgba(255,255,255,0.5) inset, 0 1px 2px rgba(0,0,0,0.04);
  --shadow-2: 0 4px 16px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);

  /* oklch overrides (modern browsers) */
  --border: oklch(0.91 0.006 80);
  --border-strong: oklch(0.84 0.008 80);
  --text: oklch(0.22 0.012 80);
  --text-2: oklch(0.48 0.012 80);
  --text-3: oklch(0.66 0.012 80);
  --accent: oklch(0.55 0.12 245);
  --accent-soft: oklch(0.94 0.025 245);
  --positive: oklch(0.58 0.11 155);
  --positive-soft: oklch(0.94 0.04 155);
  --warning: oklch(0.68 0.13 70);
  --warning-soft: oklch(0.95 0.05 80);
  --danger: oklch(0.55 0.17 25);
  --danger-soft: oklch(0.95 0.04 30);
  --shadow-1: 0 1px 0 oklch(0.96 0 0 / 0.5) inset, 0 1px 2px oklch(0 0 0 / 0.04);
  --shadow-2: 0 4px 16px oklch(0 0 0 / 0.06), 0 1px 2px oklch(0 0 0 / 0.04);

  --radius: 14px;
  --radius-sm: 10px;
  --radius-lg: 20px;

  --gap-1: 4px;
  --gap-2: 8px;
  --gap-3: 12px;
  --gap-4: 16px;
  --gap-5: 20px;
  --gap-6: 24px;
  --gap-7: 32px;
  --gap-8: 48px;

  --font-sans: "Onest", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, monospace;
}

[data-theme="dark"] {
  --bg: #0d0d0c;
  --surface: #181816;
  --surface-2: #1f1f1d;
  --surface-3: #2a2a27;
  /* Fallbacks */
  --border: #3a3a36;
  --border-strong: #525249;
  --text: #f5f4f0;
  --text-2: #b5b1a6;
  --text-3: #7d796e;
  --accent-soft: #2a2d4a;
  --positive-soft: #1e3a30;
  --warning-soft: #3a3020;
  --danger-soft: #3a2022;
  --shadow-1: 0 1px 0 rgba(255,255,255,0.04) inset, 0 1px 2px rgba(0,0,0,0.2);
  --shadow-2: 0 6px 24px rgba(0,0,0,0.4), 0 1px 2px rgba(0,0,0,0.2);
  /* oklch overrides */
  --border: oklch(0.28 0.006 80);
  --border-strong: oklch(0.38 0.008 80);
  --text: oklch(0.97 0.01 80);
  --text-2: oklch(0.74 0.012 80);
  --text-3: oklch(0.55 0.012 80);
  --accent-soft: oklch(0.30 0.05 245);
  --positive-soft: oklch(0.28 0.06 155);
  --warning-soft: oklch(0.32 0.07 70);
  --danger-soft: oklch(0.30 0.08 25);
  --shadow-1: 0 1px 0 oklch(1 0 0 / 0.04) inset, 0 1px 2px oklch(0 0 0 / 0.2);
  --shadow-2: 0 6px 24px oklch(0 0 0 / 0.4), 0 1px 2px oklch(0 0 0 / 0.2);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; overflow-x: hidden; }

body {
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-feature-settings: "ss01", "cv11";
}

button { font-family: inherit; }
input, textarea, select { font-family: inherit; color: inherit; }

/* ── Layout ─────────────────────────────────────────────────────────────── */
.app {
  display: grid;
  grid-template-columns: 240px 1fr;
  min-height: 100vh;
  max-width: 100vw;
  overflow-x: hidden;
}

.sidebar {
  border-right: 1px solid var(--border);
  background: var(--surface);
  padding: 20px 16px;
  display: flex;
  flex-direction: column;
  gap: var(--gap-6);
  position: sticky;
  top: 0;
  height: 100vh;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 8px;
}
.brand-mark {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: var(--text);
  display: grid;
  place-items: center;
  color: var(--bg);
  font-weight: 700;
  font-size: 14px;
  letter-spacing: -0.02em;
}
.brand-name {
  font-weight: 600;
  letter-spacing: -0.01em;
  font-size: 15px;
}
.brand-sub {
  font-size: 11px;
  color: var(--text-3);
  margin-left: auto;
  font-variant-numeric: tabular-nums;
}

.nav { display: flex; flex-direction: column; gap: 2px; flex: 1; overflow-y: auto; min-height: 0; }
.nav-section {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-3);
  padding: 16px 8px 6px;
}
.nav-item {
  appearance: none;
  border: 0;
  background: transparent;
  text-align: left;
  width: 100%;
  padding: 8px 10px;
  border-radius: 8px;
  font-size: 13.5px;
  color: var(--text-2);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 500;
  transition: background 80ms;
}
.nav-item:hover { background: var(--surface-2); color: var(--text); }
.nav-item.active {
  background: var(--text);
  color: var(--bg);
}
.nav-item.active .nav-dot { background: var(--bg); opacity: 0.6; }
.nav-icon {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  stroke: currentColor;
  stroke-width: 1.6;
  fill: none;
}
.nav-badge {
  margin-left: auto;
  font-size: 10px;
  background: var(--danger);
  color: white;
  padding: 1px 6px;
  border-radius: 999px;
  font-variant-numeric: tabular-nums;
}

.sidebar-footer {
  /* kept for backward compat, now empty */
  display: none;
}

/* ── Profile block (top of sidebar, under logo) ─────────────────────────── */
.sidebar-profile {
  padding: 6px 8px 0;
  margin-bottom: 2px;
}
.sidebar-profile .user-chip {
  margin-top: 0;
  background: var(--surface-2);
  width: 100%;
  box-sizing: border-box;
}
.sidebar-profile .user-chip:hover {
  background: var(--surface-3, color-mix(in srgb, var(--text) 12%, var(--bg)));
}
.sf-meta {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 3px 4px 2px;
  font-size: 11px;
  color: var(--text-3);
}
.sf-row {
  display: flex;
  align-items: center;
  gap: 4px;
  font-variant-numeric: tabular-nums;
}

/* ── Top area ───────────────────────────────────────────────────────────── */
.main {
  padding: 24px 32px 64px;
  max-width: 1280px;
  margin: 0 auto;
  width: 100%;
  min-width: 0;
  overflow-x: hidden;
}

.topbar {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  margin-bottom: 28px;
  gap: 24px;
  flex-wrap: wrap;
}
.topbar h1 {
  margin: 0;
  font-size: 30px;
  font-weight: 600;
  letter-spacing: -0.02em;
}
.topbar .topbar-sub {
  color: var(--text-2);
  font-size: 14px;
  margin-top: 4px;
}
.topbar-right {
  display: flex;
  gap: 10px;
  align-items: center;
}

/* ── Cards ──────────────────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
}
.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}
.card-title {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-3);
}
.card-title-lg {
  font-size: 17px;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--text);
}

/* ── Numbers ────────────────────────────────────────────────────────────── */
.num {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum";
}
.num-xl {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: 40px;
  font-weight: 500;
  letter-spacing: -0.02em;
  line-height: 1.05;
}
.num-lg {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: 22px;
  font-weight: 500;
  letter-spacing: -0.01em;
}

.pos { color: var(--positive); }
.neg { color: var(--danger); }
.warn { color: var(--warning); }
.muted { color: var(--text-3); }

/* ── Buttons ────────────────────────────────────────────────────────────── */
.btn {
  appearance: none;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  padding: 8px 14px;
  border-radius: 10px;
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: background 80ms, border-color 80ms;
}
.btn:hover { background: var(--surface-2); }
.btn-primary {
  background: var(--text);
  color: var(--bg);
  border-color: var(--text);
}
.btn-primary:hover { background: #3a3832; background: oklch(0.32 0.012 80); }
.btn-ghost { border-color: transparent; background: transparent; }
.btn-ghost:hover { background: var(--surface-2); }
.btn-sm { padding: 5px 10px; font-size: 12.5px; border-radius: 8px; }
.btn-danger { color: #d44; border-color: #d442; }
.btn-danger:hover { background: #d441; }
.icon-btn {
  appearance: none;
  border: 1px solid var(--border);
  background: var(--surface);
  width: 34px; height: 34px;
  border-radius: 10px;
  color: var(--text-2);
  cursor: pointer;
  display: inline-grid;
  place-items: center;
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.icon-btn svg { width: 16px; height: 16px; stroke: currentColor; fill: none; stroke-width: 1.6; }

/* ── Inputs ─────────────────────────────────────────────────────────────── */
.input, .select {
  appearance: none;
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 10px;
  padding: 8px 12px;
  font-size: 14px;
  color: var(--text);
  outline: none;
  width: 100%;
  transition: border-color 100ms, box-shadow 100ms;
}
.input:focus, .select:focus {
  border-color: var(--text-2);
  box-shadow: 0 0 0 3px rgba(0,0,0,0.04);
}
.input::placeholder { color: var(--text-3); }
.field-label {
  display: block;
  font-size: 11.5px;
  font-weight: 500;
  color: var(--text-2);
  margin-bottom: 5px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

/* ── Pills & tags ───────────────────────────────────────────────────────── */
.pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 500;
  background: var(--surface-2);
  color: var(--text-2);
  white-space: nowrap;
}
.pill-pos { background: var(--positive-soft); color: var(--positive); }
.pill-neg { background: var(--danger-soft); color: var(--danger); }
.pill-warn { background: var(--warning-soft); color: var(--warning); }
.pill-info { background: var(--accent-soft); color: var(--accent); }
.dot {
  width: 6px; height: 6px;
  border-radius: 999px;
  background: currentColor;
}

/* ── List items ─────────────────────────────────────────────────────────── */
.list { display: flex; flex-direction: column; }
.list-row {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}
.list-row:last-child { border-bottom: 0; }
.list-row .lr-main {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.list-row .lr-title {
  font-weight: 500;
  font-size: 14px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.list-row .lr-meta {
  font-size: 12px;
  color: var(--text-3);
  display: flex;
  gap: 8px;
}
.list-row .lr-right {
  display: flex;
  align-items: center;
  gap: 12px;
}
.list-row .lr-amt {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-weight: 500;
  font-size: 14.5px;
}
.list-row .lr-actions { display: flex; gap: 4px; opacity: 0.4; transition: opacity 80ms; }
.list-row:hover .lr-actions { opacity: 1; }
.lr-actions .icon-btn { width: 28px; height: 28px; border-radius: 8px; }
.lr-actions .icon-btn svg { width: 13px; height: 13px; }

/* Compact icon-only mini button for inline list actions */
.mini-btn {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--text-3);
  cursor: pointer;
  padding: 4px;
  border-radius: 6px;
  display: inline-grid; place-items: center;
}
.mini-btn:hover { background: var(--surface-2); color: var(--text); }
.mini-btn svg { width: 14px; height: 14px; stroke: currentColor; fill: none; stroke-width: 1.6; }

/* ── KPI tiles ──────────────────────────────────────────────────────────── */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
}
.kpi {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
}
.kpi-label {
  font-size: 11.5px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-3);
  display: flex;
  align-items: center;
  gap: 6px;
}
.kpi-value {
  margin-top: 8px;
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: 24px;
  font-weight: 500;
  letter-spacing: -0.01em;
}
.kpi-foot {
  margin-top: 6px;
  font-size: 12px;
  color: var(--text-2);
  display: flex;
  align-items: center;
  gap: 6px;
}

/* ── Hero balance card ──────────────────────────────────────────────────── */
.hero {
  background: linear-gradient(180deg, var(--surface) 0%, var(--surface) 100%);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 28px 32px;
  position: relative;
  overflow: hidden;
}
.hero-grid {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 32px;
  align-items: stretch;
}
.hero-side {
  border-left: 1px solid var(--border);
  padding-left: 32px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.hero-eyebrow {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-3);
  display: flex;
  align-items: center;
  gap: 8px;
}
.hero-balance {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: 56px;
  font-weight: 500;
  letter-spacing: -0.025em;
  line-height: 1;
  margin: 12px 0 6px;
}
.hero-sub {
  color: var(--text-2);
  font-size: 14px;
}

/* ── Alert ──────────────────────────────────────────────────────────────── */
.alert {
  display: flex;
  gap: 14px;
  padding: 14px 16px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface);
  align-items: flex-start;
}
.alert-warn { border-color: var(--warning); background: var(--warning-soft); }
.alert-danger { border-color: var(--danger); background: var(--danger-soft); }
.alert-info { border-color: var(--accent); background: var(--accent-soft); }
.alert-icon {
  width: 22px; height: 22px;
  border-radius: 999px;
  display: grid; place-items: center;
  flex-shrink: 0;
  font-weight: 700;
  font-size: 12px;
  color: white;
}
.alert-warn .alert-icon { background: var(--warning); }
.alert-danger .alert-icon { background: var(--danger); }
.alert-info .alert-icon { background: var(--accent); }
.alert-body { font-size: 13.5px; line-height: 1.5; }
.alert-body strong { font-weight: 600; }

/* ── Bar ────────────────────────────────────────────────────────────────── */
.bar {
  height: 6px;
  border-radius: 999px;
  background: var(--surface-2);
  overflow: hidden;
  position: relative;
}
.bar-fill {
  position: absolute;
  inset: 0 auto 0 0;
  background: var(--text);
  border-radius: 999px;
}
.bar.bar-pos .bar-fill { background: var(--positive); }
.bar.bar-warn .bar-fill { background: var(--warning); }
.bar.bar-danger .bar-fill { background: var(--danger); }

/* ── Modal ──────────────────────────────────────────────────────────────── */
.modal-bg {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.4);
  display: grid; place-items: center;
  z-index: 100;
  padding: 24px;
  animation: fade 160ms ease;
}
.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 24px;
  width: 100%;
  max-width: 460px;
  box-shadow: var(--shadow-2);
  animation: pop 200ms cubic-bezier(.3,.8,.4,1);
}
.modal h2 {
  margin: 0 0 18px;
  font-size: 18px;
  font-weight: 600;
  letter-spacing: -0.01em;
}
.modal-form { display: flex; flex-direction: column; gap: 14px; }
.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 6px;
}
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes pop { from { opacity: 0; transform: translateY(8px) scale(0.98); } to { opacity: 1; transform: none; } }

/* ── Calendar / forecast ────────────────────────────────────────────────── */
.timeline {
  display: flex;
  flex-direction: column;
  gap: 0;
}
.timeline-row {
  display: grid;
  grid-template-columns: 96px 14px 1fr auto;
  align-items: center;
  gap: 14px;
  padding: 10px 0;
  border-bottom: 1px dashed var(--border);
}
.timeline-row:last-child { border-bottom: 0; }
.timeline-date {
  font-size: 12px;
  color: var(--text-3);
  font-variant-numeric: tabular-nums;
}
.timeline-bullet {
  width: 10px; height: 10px;
  border-radius: 999px;
  background: var(--text);
  justify-self: center;
}
.timeline-bullet.pos { background: var(--positive); }
.timeline-bullet.neg { background: var(--danger); }

/* ── Chart ──────────────────────────────────────────────────────────────── */
.chart {
  display: block;
  width: 100%;
  height: 200px;
}
.chart text {
  font-family: var(--font-mono);
  font-size: 10px;
  fill: var(--text-3);
}

/* ── Grids for screens ──────────────────────────────────────────────────── */
.cols-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}
.cols-3 {
  display: grid;
  grid-template-columns: 1.2fr 1fr 1fr;
  gap: 20px;
}
.stack { display: flex; flex-direction: column; gap: 20px; }

/* ── Named grid variants (allow media-query override of inline styles) ── */
/* Use these classes instead of style={{ gridTemplateColumns: "..." }}     */
.kpi-5 { grid-template-columns: repeat(5, 1fr); }
.kpi-4 { grid-template-columns: repeat(4, 1fr); }
.kpi-3 { grid-template-columns: repeat(3, 1fr); }
.cols-wide   { grid-template-columns: 1.4fr 1fr; }   /* dashboard/analytics wide ratio */
.cols-budget { grid-template-columns: 1.5fr 1fr; }   /* daily budget stats */
.cols-inv    { grid-template-columns: 1fr 1.5fr; }   /* simulator controls */
.cols-3c     { grid-template-columns: 1fr 1fr 1fr; } /* 3-equal cols */
/* DailyScreen main two-panel layout */
.daily-main-grid {
  display: grid;
  grid-template-columns: 260px 1fr;
  gap: 20px;
  align-items: start;
}

/* ── Section header ─────────────────────────────────────────────────────── */
.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin: 0 0 12px;
  gap: 16px;
}
.section-head h2 {
  margin: 0;
  font-size: 17px;
  font-weight: 600;
  letter-spacing: -0.01em;
}
.section-head .sh-sub {
  color: var(--text-3);
  font-size: 12.5px;
}

/* ── Day strip (daily expense entry) ────────────────────────────────────── */
.daystrip {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 4px;
}
.daystrip-cell {
  flex-shrink: 0;
  width: 52px;
  padding: 8px 0 10px;
  border-radius: 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  text-align: center;
  cursor: pointer;
  transition: background 80ms, border-color 80ms;
}
.daystrip-cell:hover { background: var(--surface-2); }
.daystrip-cell.active {
  background: var(--text);
  color: var(--bg);
  border-color: var(--text);
}
.daystrip-cell .ds-dow {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  opacity: 0.6;
}
.daystrip-cell .ds-day {
  font-family: var(--font-mono);
  font-size: 17px;
  font-weight: 500;
  margin-top: 2px;
}
.daystrip-cell .ds-amt {
  margin-top: 4px;
  font-family: var(--font-mono);
  font-size: 10px;
  opacity: 0.6;
}

/* ── Goal card ──────────────────────────────────────────────────────────── */
.goal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.goal-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
}
.goal-name { font-weight: 600; font-size: 15.5px; }
.goal-target { font-size: 12px; color: var(--text-3); margin-top: 2px; }
.goal-progress {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--text-2);
  display: flex;
  justify-content: space-between;
}

/* ── Empty state ────────────────────────────────────────────────────────── */
.empty {
  text-align: center;
  padding: 32px 16px;
  color: var(--text-3);
  font-size: 13px;
}

/* ── Tabs ───────────────────────────────────────────────────────────────── */
.tabs {
  display: inline-flex;
  gap: 2px;
  background: var(--surface-2);
  padding: 3px;
  border-radius: 10px;
}
.tab {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--text-2);
  padding: 6px 14px;
  border-radius: 7px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
}
.tab.active {
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-1);
}

/* ── Footer info row ────────────────────────────────────────────────────── */
.totals-row {
  display: grid;
  grid-template-columns: 1fr auto;
  padding: 14px 0 0;
  margin-top: 8px;
  border-top: 1px solid var(--border-strong);
  align-items: center;
}
.totals-row .tr-label {
  font-size: 13px;
  color: var(--text-2);
  font-weight: 500;
}
.totals-row .tr-value {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: 18px;
  font-weight: 500;
}

/* ── Date pill ──────────────────────────────────────────────────────────── */
.date-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 13px;
  color: var(--text-2);
  font-variant-numeric: tabular-nums;
}
.date-pill-short { display: none; }

/* Responsive */
@media (max-width: 980px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { height: auto; position: relative; }
  .cols-2, .cols-3 { grid-template-columns: 1fr; }
  .cols-wide, .cols-budget, .cols-inv, .cols-3c { grid-template-columns: 1fr; }
  .kpi-grid { grid-template-columns: 1fr 1fr; }
  .kpi-3, .kpi-4, .kpi-5 { grid-template-columns: repeat(3, 1fr); }
  .hero-grid { grid-template-columns: 1fr; }
  .hero-side { border-left: 0; padding-left: 0; border-top: 1px solid var(--border); padding-top: 24px; }
  .daily-main-grid { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  /* ── Sidebar / Nav ── */
  .sidebar .nav { display: none; }
  .sidebar.nav-open .nav { display: flex; }
  .sidebar { padding: 12px 16px; gap: 12px; }
  .sidebar-footer { display: none; }
  .sidebar-profile { display: none; }
  .sidebar.nav-open .sidebar-profile { display: block; }
  .brand { margin-bottom: 0; }
  .mobile-toggle { display: flex !important; }
  .sidebar.nav-open { position: fixed; inset: 0; z-index: 90; height: 100vh; overflow-y: auto; }
  .nav-section { padding: 12px 8px 4px; }

  /* ── Main content ── */
  .main { padding: 16px 14px 48px; width: 100%; max-width: 100vw; }

  /* ── Prevent overflow on all direct card children ── */
  /* overflow-wrap handles long URLs/strings; word-break: normal avoids mid-word splits */
  .card, .hero, .kpi, .alert { max-width: 100%; overflow-wrap: break-word; word-break: normal; }
  img, video, canvas, svg { max-width: 100%; }

  /* ── Topbar ── */
  .topbar { flex-direction: column; align-items: flex-start; gap: 8px; margin-bottom: 18px; }
  .topbar h1 { font-size: 20px; }
  .topbar .topbar-sub { font-size: 12.5px; }
  .topbar-right { width: 100%; justify-content: space-between; }
  .date-pill { font-size: 12px; padding: 5px 8px; }
  .date-pill-full { display: none; }
  .date-pill-short { display: inline; }
  /* ── iOS: prevent input auto-zoom (font-size must be ≥16px) ── */
  .input, .select { font-size: 16px; }

  /* ── Hero balance ── */
  .hero { padding: 18px 16px; border-radius: 16px; }
  .hero-grid { gap: 20px; }
  .hero-balance { font-size: 32px; margin: 8px 0 4px; }
  .hero-eyebrow { font-size: 11px; }
  .hero-sub { font-size: 13px; }
  .num-xl { font-size: 28px; }
  .num-lg { font-size: 18px; }

  /* ── KPI grid ── */
  .kpi-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .kpi { padding: 14px; }
  .kpi-value { font-size: 20px; margin-top: 6px; }
  .kpi-label { font-size: 10px; }

  /* ── Cards ── */
  .card { padding: 14px; border-radius: 12px; }
  .card-head { margin-bottom: 10px; }
  .card-title-lg { font-size: 15px; }
  .section-head h2 { font-size: 15px; }
  .section-head { margin-bottom: 10px; gap: 8px; flex-wrap: wrap; }

  /* ── Columns ── */
  .cols-2, .cols-3 { grid-template-columns: 1fr; gap: 14px; }
  .cols-wide, .cols-budget, .cols-inv, .cols-3c { grid-template-columns: 1fr; }
  .kpi-3, .kpi-4, .kpi-5 { grid-template-columns: 1fr 1fr; }
  .daily-main-grid { grid-template-columns: 1fr; gap: 14px; }
  .stack { gap: 14px; }

  /* ── List rows ── */
  .list-row { gap: 8px; padding: 10px 0; }
  .list-row .lr-title { font-size: 13.5px; }
  .list-row .lr-meta { font-size: 11px; gap: 6px; }
  .list-row .lr-amt { font-size: 13.5px; }
  .list-row .lr-actions { opacity: 0.6; }
  .lr-actions .icon-btn { width: 30px; height: 30px; }

  /* ── Day strip ── */
  .daystrip { gap: 4px; overflow-x: auto; -webkit-overflow-scrolling: touch; scrollbar-width: none; }
  .daystrip::-webkit-scrollbar { display: none; }
  .daystrip-cell { min-width: 48px; width: 48px; padding: 6px 2px 8px; border-radius: 8px; }
  .daystrip-cell .ds-day { font-size: 15px; }
  .daystrip-cell .ds-dow { font-size: 9px; }
  .daystrip-cell .ds-amt { font-size: 9px; }

  /* ── Modals ── */
  .modal-bg { padding: 12px; }
  .modal { padding: 20px; max-width: 100%; border-radius: 14px; max-height: 88vh; overflow-y: auto; }
  .modal h2 { font-size: 16px; margin-bottom: 14px; }
  .modal-actions { flex-wrap: wrap; }
  .modal-actions .btn { flex: 1; min-width: 0; justify-content: center; }

  /* ── Timeline ── */
  .timeline-row { grid-template-columns: 72px 10px 1fr auto; gap: 8px; padding: 8px 0; }
  .timeline-date { font-size: 11px; }

  /* ── Chart ── */
  .chart { height: 160px; }

  /* ── Ledger ── */
  .ledger { padding: 18px 14px; gap: 20px; border-radius: 14px; }
  .ledger-callout-value { font-size: 24px; }
  .ledger-total-value { font-size: 20px; }
  .ledger-eq { gap: 12px; padding: 14px 0; }
  .ledger-eq-value { font-size: 20px; }
  .ledger-eq-op { font-size: 20px; }

  /* ── Auth ── */
  .auth { padding: 24px 16px; }
  .auth-card { padding: 24px 18px; border-radius: 14px; }
  .auth-title { font-size: 22px; }
  .auth-sub { font-size: 13px; margin-bottom: 18px; }

  /* ── Notifications drawer ── */
  .drawer { width: 100vw; }
  .drawer-head { padding: 14px 16px; }
  .notif { padding: 12px 16px; gap: 10px; }
  .notif-title { font-size: 13px; }
  .notif-text { font-size: 12.5px; }

  /* ── Analytics comparison rows ── */
  .cmp-row { grid-template-columns: 100px 1fr 60px; gap: 10px; padding: 8px 0; }
  .cmp-name { font-size: 12.5px; }
  .cmp-change { font-size: 12.5px; }
  .cmp-amt { font-size: 11.5px; }

  /* ── Simulator ── */
  .sim-stat-grid { grid-template-columns: 1fr; gap: 10px; padding: 10px 12px; }
  .sim-compare { grid-template-columns: 1fr; gap: 10px; }
  .sim-arrow { transform: rotate(90deg); font-size: 20px; }
  .sim-col { padding: 14px; }

  /* ── Reports ── */
  .report-row { grid-template-columns: 1fr; gap: 14px; }

  /* ── Goals ── */
  .goal { padding: 14px; border-radius: 12px; }
  .goal-name { font-size: 14px; }
  .goal-progress { font-size: 12px; }

  /* ── Totals row ── */
  .totals-row .tr-value { font-size: 16px; }

  /* ── Buttons: bigger touch targets on mobile ── */
  .btn { padding: 9px 12px; font-size: 13px; min-height: 36px; }
  .btn-sm { padding: 6px 10px; font-size: 12px; min-height: 32px; }
  .icon-btn { width: 38px; height: 38px; }

  /* ── List rows: allow right column to wrap on very tight layouts ── */
  .list-row .lr-right { flex-wrap: wrap; justify-content: flex-end; gap: 6px; }
  .list-row .lr-actions { opacity: 1; }

  /* ── Tabs ── */
  .tabs { overflow-x: auto; -webkit-overflow-scrolling: touch; white-space: nowrap; max-width: 100%; }
  .tab { padding: 6px 10px; font-size: 12.5px; white-space: nowrap; }

  /* ── Settings ── */
  .user-chip { gap: 8px; }
  .user-email { max-width: 120px; }

  /* ── Alerts ── */
  .alert { padding: 12px 14px; gap: 10px; }
  .alert-body { font-size: 12.5px; }

  /* ── Pill ── */
  .pill { font-size: 11px; padding: 2px 6px; }
}

/* ── Phones 360–640px (incl. iPhone 16 Pro at 393px) ── */
/* kpi-grid stays 2-col (each ~177px on 393px = comfortable) */

/* ── Extra-small phones (≤360px) ── */
@media (max-width: 360px) {
  .main { padding: 12px 10px 40px; }
  .topbar h1 { font-size: 18px; }
  .hero-balance { font-size: 26px; }
  .hero { padding: 14px 12px; }
  .kpi-grid { grid-template-columns: 1fr; gap: 8px; }
  .kpi-3, .kpi-4, .kpi-5 { grid-template-columns: 1fr; }
  .kpi-value { font-size: 18px; }
  .num-xl { font-size: 24px; }
  .card { padding: 12px; }
  .modal { padding: 16px; }
  .modal h2 { font-size: 15px; }
  .daystrip-cell { min-width: 40px; width: 40px; }
  .daystrip-cell .ds-day { font-size: 13px; }
  .cmp-row { grid-template-columns: 80px 1fr 50px; gap: 8px; }
  .auth-card { padding: 20px 14px; }
  .auth-title { font-size: 20px; }
  .ledger-eq-value { font-size: 18px; }
  .ledger-callout-value { font-size: 20px; }
}

/* ── Ledger view (notebook-mirror layout) ──────────────────────────────────
   Single-surface document where two columns face each other, joined by a
   thick rule down the middle — visual nod to the spiral-bound page the
   user works from today, in our digital type system. */
.ledger {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 36px 40px;
  display: flex;
  flex-direction: column;
  gap: 28px;
  position: relative;
}

.ledger-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 56px;
  position: relative;
}
.ledger-row::after {
  /* the spine — separates the two facing columns */
  content: "";
  position: absolute;
  top: 0; bottom: 0;
  left: 50%;
  width: 1px;
  background: var(--border-strong);
}

.ledger-col {
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-width: 0;
}
.ledger-col-title {
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--text);
  padding-bottom: 8px;
  border-bottom: 1px solid var(--text);
  display: inline-block;
  align-self: flex-start;
}
.ledger-col-body { display: flex; flex-direction: column; gap: 4px; }

.ledger-line {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 8px;
  align-items: baseline;
  padding: 4px 0;
  font-size: 14.5px;
}
.ledger-line-label {
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.ledger-line-dots {
  border-bottom: 1.5px dotted var(--border-strong);
  transform: translateY(-3px);
  min-width: 12px;
}
.ledger-line-value {
  font-variant-numeric: tabular-nums;
  font-weight: 500;
  font-size: 14.5px;
  white-space: nowrap;
}

.ledger-divider {
  height: 1px;
  background: var(--border);
  margin: 8px 0 4px;
}

.ledger-callout {
  padding: 12px 0 4px;
}
.ledger-callout-label {
  font-size: 12.5px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-2);
  font-weight: 600;
  margin-bottom: 4px;
}
.ledger-callout-value {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: 32px;
  font-weight: 500;
  letter-spacing: -0.02em;
}

.ledger-subhead {
  font-size: 12.5px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-2);
  font-weight: 600;
  margin: 8px 0 4px;
}
.ledger-upcoming {
  display: grid;
  grid-template-columns: 64px 1fr auto;
  gap: 10px;
  align-items: baseline;
  padding: 4px 0;
  font-size: 13.5px;
}
.ledger-upcoming-date {
  font-family: var(--font-mono);
  font-size: 12.5px;
  color: var(--text-3);
}
.ledger-upcoming-name { color: var(--text); }
.ledger-upcoming-amt { font-size: 13.5px; }

.ledger-total {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-top: 16px;
  padding-top: 12px;
  border-top: 2px solid var(--text);
}
.ledger-total-label {
  font-size: 13.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
}
.ledger-total-value {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: 24px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

/* Equation row — three cells with operator glyphs between */
.ledger-eq {
  display: grid;
  grid-template-columns: 1fr auto 1fr auto 1fr;
  gap: 24px;
  align-items: center;
  padding: 18px 0;
  border-top: 1px solid var(--text);
  border-bottom: 1px solid var(--text);
}
.ledger-eq-cell {
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.ledger-eq-label {
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-weight: 600;
  color: var(--text-2);
}
.ledger-eq-value {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: 26px;
  font-weight: 500;
  letter-spacing: -0.015em;
}
.ledger-eq-op {
  font-family: var(--font-mono);
  font-size: 28px;
  font-weight: 400;
  color: var(--text-3);
}

.ledger-footnote {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-top: 16px;
  margin-top: 4px;
  border-top: 1px dashed var(--border-strong);
  font-size: 13px;
}

@media (max-width: 880px) {
  .ledger { padding: 24px 20px; }
  .ledger-row { grid-template-columns: 1fr; gap: 24px; }
  .ledger-row::after { display: none; }
  .ledger-eq { grid-template-columns: 1fr; gap: 8px; }
  .ledger-eq-op { display: none; }
}

/* ── Auth screen ────────────────────────────────────────────────────────── */
.auth {
  min-height: 100vh;
  background: var(--bg);
  display: grid;
  place-items: center;
  padding: 40px 20px;
}
.auth-stage {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 48px;
  max-width: 920px;
  width: 100%;
  align-items: start;
}
.auth-brand {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 20px;
}
.auth-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 32px;
  box-shadow: var(--shadow-2);
}
.auth-tabs {
  display: inline-flex;
  gap: 4px;
  background: var(--surface-2);
  padding: 3px;
  border-radius: 10px;
  margin-bottom: 24px;
}
.auth-title {
  margin: 0 0 8px;
  font-size: 26px;
  font-weight: 600;
  letter-spacing: -0.02em;
}
.auth-sub {
  color: var(--text-2);
  font-size: 14px;
  margin: 0 0 24px;
}
.auth-form { display: flex; flex-direction: column; gap: 14px; }
.auth-error {
  background: var(--danger-soft);
  color: var(--danger);
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 13px;
}
.auth-submit { width: 100%; padding: 12px 16px; font-size: 14px; justify-content: center; }
.auth-or {
  position: relative;
  text-align: center;
  margin: 4px 0;
}
.auth-or::before {
  content: "";
  position: absolute; left: 0; right: 0; top: 50%;
  border-top: 1px solid var(--border);
}
.auth-or span {
  position: relative;
  background: var(--surface);
  padding: 0 12px;
  font-size: 12px;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.auth-socials { display: flex; flex-direction: column; gap: 8px; }
.auth-social {
  justify-content: center;
  padding: 11px 16px;
  font-size: 13.5px;
}
.sb-glyph {
  width: 16px; height: 16px;
  border-radius: 4px;
  display: inline-block;
  margin-right: 6px;
}
.auth-foot {
  text-align: center;
  font-size: 13px;
  margin-top: 4px;
}
.auth-foot a { color: var(--text-2); text-decoration: none; }
.auth-foot a:hover { color: var(--text); text-decoration: underline; }

.auth-aside {
  align-self: center;
  padding: 24px;
}
.auth-aside-title {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-3);
  margin-bottom: 16px;
}
.auth-features {
  list-style: none;
  padding: 0;
  margin: 0 0 28px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  font-size: 14px;
  color: var(--text);
}
.auth-features li {
  display: flex;
  align-items: center;
  gap: 10px;
}
.auth-features .dot {
  width: 8px; height: 8px;
  background: var(--accent);
  border-radius: 999px;
}
.auth-aside-quote {
  font-size: 14px;
  font-style: italic;
  color: var(--text-2);
  border-left: 2px solid var(--text);
  padding-left: 14px;
  line-height: 1.55;
}

@media (max-width: 760px) {
  .auth-stage { grid-template-columns: 1fr; gap: 24px; }
  .auth-aside { padding: 0; }
}

/* ── Notification drawer ────────────────────────────────────────────────── */
.drawer-bg {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.3);
  z-index: 100;
  animation: fade 160ms ease;
}
.drawer {
  position: fixed;
  top: 0; right: 0; bottom: 0;
  width: 400px;
  max-width: 100vw;
  background: var(--surface);
  border-left: 1px solid var(--border);
  box-shadow: -10px 0 40px rgba(0,0,0,0.15);
  display: flex;
  flex-direction: column;
  animation: slideIn 220ms cubic-bezier(.3,.8,.4,1);
}
@keyframes slideIn { from { transform: translateX(20px); opacity: 0.2; } to { transform: none; opacity: 1; } }

.drawer-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 18px 20px;
  border-bottom: 1px solid var(--border);
}
.drawer-body {
  flex: 1;
  overflow-y: auto;
  padding: 8px 0;
}
.notif-list { display: flex; flex-direction: column; }
.notif {
  display: grid;
  grid-template-columns: 28px 1fr auto;
  gap: 12px;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  align-items: flex-start;
}
.notif:hover { background: var(--surface-2); }
.notif.unread { background: var(--surface-2); }
.notif-icon {
  width: 28px; height: 28px;
  border-radius: 8px;
  display: grid; place-items: center;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-2);
}
.notif-paid .notif-icon { color: var(--positive); }
.notif-payment_due .notif-icon { color: var(--warning); }
.notif-tip .notif-icon { color: var(--accent); }
.notif-title {
  font-weight: 600;
  font-size: 13.5px;
  margin-bottom: 2px;
}
.notif-text {
  font-size: 13px;
  color: var(--text-2);
  line-height: 1.5;
}
.notif-when {
  font-size: 11.5px;
  color: var(--text-3);
  margin-top: 4px;
  font-variant-numeric: tabular-nums;
}
.notif-dot {
  width: 8px; height: 8px;
  border-radius: 999px;
  background: var(--accent);
  margin-top: 8px;
}

/* ── Topbar bell ────────────────────────────────────────────────────────── */
.bell-btn { position: relative; }
.bell-badge {
  position: absolute;
  top: -2px; right: -2px;
  min-width: 16px; height: 16px;
  border-radius: 999px;
  background: var(--danger);
  color: white;
  font-size: 10px;
  font-weight: 600;
  display: grid; place-items: center;
  padding: 0 4px;
}

/* ── Analytics comparison ───────────────────────────────────────────────── */
.cmp-row {
  display: grid;
  grid-template-columns: 140px 1fr 80px;
  gap: 16px;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}
.cmp-row:last-child { border-bottom: 0; }
.cmp-name { font-size: 13.5px; font-weight: 500; }
.cmp-bars { display: flex; flex-direction: column; gap: 4px; }
.cmp-bar-row { display: grid; grid-template-columns: 1fr 70px; gap: 12px; align-items: center; }
.cmp-bar-prev, .cmp-bar-cur {
  display: block;
  height: 6px;
  border-radius: 999px;
  background: var(--surface-2);
  overflow: hidden;
  position: relative;
}
.cmp-bar-prev span, .cmp-bar-cur span {
  display: block; height: 100%; border-radius: 999px;
}
.cmp-bar-prev span { background: var(--text-3); }
.cmp-bar-cur span { background: var(--accent); }
.cmp-amt {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: 12.5px;
  text-align: right;
}
.cmp-change {
  text-align: right;
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: 13.5px;
  font-weight: 600;
}

/* ── Simulator ──────────────────────────────────────────────────────────── */
.sim-stat-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  padding: 12px 14px;
  background: var(--surface-2);
  border-radius: 12px;
  margin-top: 12px;
}
.sim-compare {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 16px;
  align-items: center;
}
.sim-col {
  background: var(--surface-2);
  border-radius: 12px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.sim-col-acc {
  background: var(--positive-soft);
}
.sim-col-eyebrow {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-3);
  font-weight: 600;
  margin-bottom: 4px;
}
.sim-divider {
  height: 1px;
  background: var(--border);
  margin: 10px 0 6px;
}
.sim-arrow {
  font-size: 24px;
  color: var(--text-3);
  text-align: center;
}

/* ── Reports row ────────────────────────────────────────────────────────── */
.report-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 24px;
  align-items: end;
  padding: 12px 0;
}

/* ── Settings ───────────────────────────────────────────────────────────── */
.ch-toggle {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  font-size: 13.5px;
  color: var(--text);
  user-select: none;
}
.ch-toggle input { position: absolute; opacity: 0; pointer-events: none; }
.ch-toggle-track {
  width: 32px; height: 18px;
  background: var(--surface-3);
  border-radius: 999px;
  position: relative;
  transition: background 120ms;
}
.ch-toggle-track > span {
  position: absolute;
  top: 2px; left: 2px;
  width: 14px; height: 14px;
  background: white;
  border-radius: 999px;
  transition: transform 120ms;
  box-shadow: 0 1px 2px rgba(0,0,0,0.2);
}
.ch-toggle input:checked + .ch-toggle-track { background: var(--positive); }
.ch-toggle input:checked + .ch-toggle-track > span { transform: translateX(14px); }
.settings-toggles { display: flex; flex-direction: column; gap: 10px; padding: 4px 0; }

/* ── List row paid state ────────────────────────────────────────────────── */
.list-row.is-paid { opacity: 0.85; }

/* ── User chip in sidebar ───────────────────────────────────────────────── */
.user-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px;
  border-radius: 10px;
  cursor: pointer;
  margin-top: 8px;
  transition: background 80ms;
}
.user-chip:hover { background: var(--surface-2); }
.user-avatar {
  width: 28px; height: 28px;
  border-radius: 999px;
  background: linear-gradient(135deg, var(--accent), #3a6aaa);
  color: white;
  font-weight: 600;
  font-size: 12px;
  display: grid;
  place-items: center;
}
.user-name { font-size: 13px; font-weight: 500; }
.user-email { font-size: 11px; color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 140px; }

/* ── Database viewer ───────────────────────────────────────────────────── */
.db-viewer {
  background: var(--surface);
  border-radius: 18px;
  margin: 24px;
  width: calc(100% - 48px);
  max-width: 1100px;
  max-height: calc(100vh - 48px);
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-2);
  animation: pop 200ms cubic-bezier(.3,.8,.4,1);
  overflow: hidden;
}
.db-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 18px 22px;
  border-bottom: 1px solid var(--border);
  gap: 12px;
  flex-wrap: wrap;
}
.db-tabs {
  display: flex;
  gap: 2px;
  padding: 10px 22px;
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.db-tabs::-webkit-scrollbar { display: none; }
.db-tab {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--text-2);
  padding: 6px 12px;
  border-radius: 8px;
  font-size: 12.5px;
  font-weight: 500;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
  transition: background 80ms;
}
.db-tab:hover { background: var(--surface-2); color: var(--text); }
.db-tab.active {
  background: var(--text);
  color: var(--bg);
}
.db-tab-count {
  font-family: var(--font-mono);
  font-size: 10px;
  opacity: 0.6;
  min-width: 14px;
  text-align: center;
}
.db-body {
  flex: 1;
  overflow: auto;
}
.db-table-wrap {
  min-width: 100%;
  overflow-x: auto;
}
.db-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.db-th {
  position: sticky;
  top: 0;
  background: var(--surface-2);
  text-align: left;
  padding: 8px 14px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-3);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.db-tr { transition: background 60ms; }
.db-tr:hover { background: var(--surface-2); }
.db-td {
  padding: 8px 14px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
}
.db-td-idx {
  font-family: var(--font-mono);
  color: var(--text-3);
  font-size: 11px;
  width: 32px;
  text-align: center;
}
.db-td-id {
  font-family: var(--font-mono);
  color: var(--text-3);
  font-size: 11px;
  max-width: 72px;
}
.db-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 22px;
  border-top: 1px solid var(--border);
  background: var(--surface-2);
}

@media (max-width: 640px) {
  .db-viewer { margin: 0; width: 100%; max-width: 100%; max-height: 100vh; border-radius: 0; }
  .db-header { padding: 14px 16px; }
  .db-header input { width: 120px; }
  .db-tabs { padding: 8px 12px; }
  .db-tab { font-size: 12px; padding: 5px 8px; }
  .db-th { padding: 6px 10px; font-size: 10px; }
  .db-td { padding: 6px 10px; font-size: 12px; max-width: 150px; }
  .db-footer { padding: 8px 12px; }
}

/* ── Strategy method selector ─────────────────────────────────────────── */
.strategy-methods {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}
.strategy-method-btn {
  appearance: none;
  border: 2px solid var(--border);
  background: var(--surface);
  border-radius: 12px;
  padding: 14px 16px;
  text-align: left;
  cursor: pointer;
  transition: border-color 120ms, background 120ms, box-shadow 120ms;
}
.strategy-method-btn:hover {
  border-color: var(--text-3);
}
.strategy-method-btn.active {
  border-color: var(--accent);
  background: var(--accent-soft, #e8ecf5);
  box-shadow: 0 0 0 1px var(--accent);
}
.strategy-method-label {
  font-weight: 600;
  font-size: 14px;
  margin-bottom: 4px;
}
.strategy-method-btn.active .strategy-method-label {
  color: var(--accent);
}
.strategy-method-desc {
  font-size: 12px;
  color: var(--text-3);
  line-height: 1.4;
}

@media (max-width: 640px) {
  .strategy-methods { grid-template-columns: 1fr; }
  .strategy-method-btn { padding: 12px; }
}

/* ── Planned Expenses Calendar ────────────────────────────────────────── */
.planned-cal {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 2px;
  font-size: 12px;
}
.planned-cal-hdr {
  text-align: center;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 6px 0;
}
.planned-cal-cell {
  min-height: 54px;
  border-radius: 6px;
  padding: 3px 4px;
  background: var(--surface-2);
  position: relative;
  overflow: hidden;
  transition: background 80ms;
}
.planned-cal-cell.empty {
  background: transparent;
}
.planned-cal-cell.today {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}
.planned-cal-cell.has-event {
  background: oklch(0.94 0.025 245);
  background: var(--accent-soft, #e8ecf5);
}
[data-theme="dark"] .planned-cal-cell.has-event {
  background: oklch(0.25 0.04 245);
}
.planned-cal-day {
  font-weight: 500;
  font-size: 11px;
  color: var(--text-2);
}
.planned-cal-evt {
  font-size: 9.5px;
  background: var(--accent);
  color: white;
  padding: 1px 4px;
  border-radius: 3px;
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-weight: 500;
}
.pill-inline {
  display: inline;
  font-weight: 500;
}
.pill-inline.neg { color: var(--negative, #c33); }

/* ── Piggy Bank ──────────────────────────────────────────────────────── */
.piggy-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
  padding: 4px 0;
}
.piggy-card {
  background: var(--surface-2);
  border-radius: 14px;
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  transition: box-shadow 120ms;
}
.piggy-card:hover { box-shadow: 0 2px 12px rgba(0,0,0,0.06); }
.piggy-card-head {
  display: flex;
  align-items: flex-start;
  gap: 12px;
}
.piggy-icon {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: var(--accent-soft, #e8ecf5);
  display: grid;
  place-items: center;
  color: var(--accent);
  flex-shrink: 0;
}
.piggy-name {
  font-weight: 600;
  font-size: 15px;
}
.piggy-note {
  font-size: 12px;
  color: var(--text-3);
  margin-top: 2px;
}
.piggy-balance {
  display: flex;
  align-items: baseline;
  gap: 8px;
}
.piggy-progress {
  height: 8px;
  border-radius: 999px;
  background: var(--surface-3);
  position: relative;
  overflow: hidden;
}
.piggy-progress-bar {
  height: 100%;
  border-radius: 999px;
  background: var(--accent);
  transition: width 300ms ease;
  min-width: 2px;
}
.piggy-pct {
  position: absolute;
  right: 0;
  top: -16px;
  font-size: 11px;
  font-weight: 600;
  color: var(--accent);
  font-family: var(--font-mono);
}
.piggy-actions {
  display: flex;
  gap: 8px;
}

@media (max-width: 640px) {
  .planned-cal-cell { min-height: 42px; }
  .planned-cal-evt { font-size: 8px; }
  .piggy-grid { grid-template-columns: 1fr; }
  .piggy-card { padding: 14px; }
}

/* ── Manual button in sidebar ────────────────────────────────────────────── */
.manual-btn {
  appearance: none;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text-2);
  padding: 7px 10px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12.5px;
  font-weight: 500;
  cursor: pointer;
  margin: 4px 8px 2px;
  transition: background 80ms, color 80ms;
  flex-shrink: 0;
}
.manual-btn:hover {
  background: var(--accent-soft);
  color: var(--accent);
  border-color: var(--accent);
}

/* ── Manual modal ─────────────────────────────────────────────────────────── */
.manual-modal {
  position: fixed;
  inset: 20px;
  max-width: 1100px;
  margin: 0 auto;
  background: var(--surface);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  box-shadow: 0 20px 60px rgba(0,0,0,0.2);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: slideIn 220ms cubic-bezier(.3,.8,.4,1);
  z-index: 101;
}

.manual-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  gap: 16px;
  flex-shrink: 0;
  background: var(--surface);
}
.manual-header-left {
  display: flex;
  align-items: center;
  gap: 12px;
}
.manual-logo {
  font-size: 24px;
  line-height: 1;
}
.manual-title {
  font-weight: 700;
  font-size: 17px;
  letter-spacing: -0.02em;
}
.manual-subtitle {
  font-size: 12px;
  color: var(--text-3);
  margin-top: 1px;
}

.manual-search-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 12px;
}
.manual-search {
  border: none;
  background: transparent;
  font-size: 13px;
  color: var(--text);
  width: 180px;
  outline: none;
}
.manual-search::placeholder { color: var(--text-3); }

.manual-body {
  display: flex;
  flex: 1;
  overflow: hidden;
}

/* TOC */
.manual-toc {
  width: 210px;
  flex-shrink: 0;
  border-right: 1px solid var(--border);
  overflow-y: auto;
  padding: 12px 0;
  background: var(--surface-2);
}
.manual-toc-group {
  margin-bottom: 4px;
}
.manual-toc-section {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 7px 14px;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--text-3);
  cursor: pointer;
  transition: color 80ms;
}
.manual-toc-section:hover { color: var(--text-2); }
.manual-toc-section.active { color: var(--accent); }

.manual-toc-item {
  appearance: none;
  border: none;
  background: transparent;
  display: block;
  width: 100%;
  text-align: left;
  padding: 5px 14px 5px 34px;
  font-size: 13px;
  color: var(--text-2);
  cursor: pointer;
  border-radius: 0;
  transition: background 80ms, color 80ms;
}
.manual-toc-item:hover { background: var(--surface-3); color: var(--text); }
.manual-toc-item.active {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 500;
}

/* Article content */
.manual-content {
  flex: 1;
  overflow-y: auto;
  padding: 32px 40px 60px;
}

.manual-article-header {
  margin-bottom: 24px;
}
.manual-article-tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 3px 8px;
  border-radius: 5px;
  margin-bottom: 10px;
}
.manual-article-title {
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin: 0;
  color: var(--text);
}

/* Typography */
.man-h2 {
  font-size: 18px;
  font-weight: 600;
  margin: 28px 0 10px;
  color: var(--text);
  letter-spacing: -0.01em;
}
.man-h3 {
  font-size: 14.5px;
  font-weight: 600;
  margin: 20px 0 8px;
  color: var(--text);
}
.man-p {
  font-size: 14px;
  line-height: 1.65;
  color: var(--text-2);
  margin: 0 0 10px;
}
.man-ul, .man-ol {
  padding-left: 22px;
  margin: 0 0 12px;
}
.man-ul li, .man-ol li {
  font-size: 14px;
  line-height: 1.6;
  color: var(--text-2);
  margin-bottom: 4px;
}
.man-ul li strong, .man-ol li strong,
.man-p strong { color: var(--text); }

.man-code {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 16px;
  font-family: "JetBrains Mono", monospace;
  font-size: 12.5px;
  color: var(--text);
  overflow-x: auto;
  margin: 0 0 12px;
}

.man-table-wrap {
  overflow-x: auto;
  margin: 0 0 16px;
  border-radius: 8px;
  border: 1px solid var(--border);
}
.man-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.man-table th {
  background: var(--surface-2);
  font-weight: 600;
  color: var(--text);
  padding: 8px 12px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}
.man-table td {
  padding: 7px 12px;
  color: var(--text-2);
  border-bottom: 1px solid var(--border);
}
.man-table tr:last-child td { border-bottom: none; }
.man-table tr:nth-child(even) td { background: var(--surface-2); }

/* Nav between articles */
.manual-nav-btns {
  display: flex;
  justify-content: space-between;
  margin-top: 40px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
  gap: 12px;
}

/* Search results */
.manual-empty {
  color: var(--text-3);
  font-size: 14px;
  padding: 40px 0;
  text-align: center;
}
.manual-search-result {
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  margin-bottom: 8px;
  transition: background 80ms;
}
.manual-search-result:hover { background: var(--surface-2); }
.msr-section {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  color: var(--text-3);
  margin-bottom: 4px;
  letter-spacing: 0.04em;
}
.msr-title { font-weight: 600; font-size: 14px; color: var(--text); margin-bottom: 4px; }
.msr-preview { font-size: 13px; color: var(--text-3); line-height: 1.4; }

/* Mobile */
@media (max-width: 760px) {
  .manual-modal { inset: 0; border-radius: 0; }
  .manual-toc { display: none; }
  .manual-content { padding: 20px 18px 48px; }
  .manual-search { width: 120px; }
  .manual-article-title { font-size: 20px; }
}
