/* ─────────────────────────────────────────────────────────────
   CreatorBoard — design tokens & global styles
   Warm, creator-friendly editorial aesthetic.
   ───────────────────────────────────────────────────────────── */

:root {
  /* Type */
  --font-ui: "Geist", ui-sans-serif, system-ui, sans-serif;
  --font-display: "Instrument Serif", ui-serif, Georgia, serif;
  --font-mono: "Geist Mono", ui-monospace, "SF Mono", monospace;

  /* Default theme: Warm Clay */
  --bg: oklch(0.972 0.012 75);
  --bg-deep: oklch(0.945 0.014 75);
  --surface: oklch(1 0 0);
  --surface-2: oklch(0.985 0.008 75);
  --ink: oklch(0.22 0.018 60);
  --ink-soft: oklch(0.38 0.018 60);
  --muted: oklch(0.55 0.014 65);
  --hairline: oklch(0.9 0.012 70);
  --hairline-strong: oklch(0.82 0.014 70);

  --primary: oklch(0.64 0.16 35);
  --primary-soft: oklch(0.93 0.045 40);
  --primary-ink: oklch(0.36 0.13 35);

  --income: oklch(0.58 0.13 155);
  --income-soft: oklch(0.93 0.045 155);
  --expense: oklch(0.58 0.17 28);
  --expense-soft: oklch(0.94 0.04 30);

  --accent-2: oklch(0.62 0.13 240);
  --accent-2-soft: oklch(0.94 0.035 240);

  /* Density */
  --radius-card: 18px;
  --radius-input: 10px;
  --radius-pill: 999px;
  --pad-card: 22px;
  --row-h: 52px;

  /* Shadows — warm-tinted */
  --shadow-1: 0 1px 0 oklch(0.95 0.01 70 / 0.6), 0 1px 2px oklch(0.4 0.02 60 / 0.04);
  --shadow-2: 0 4px 14px oklch(0.4 0.02 60 / 0.06), 0 1px 2px oklch(0.4 0.02 60 / 0.04);
  --shadow-pop: 0 24px 60px oklch(0.3 0.05 50 / 0.18), 0 4px 14px oklch(0.3 0.05 50 / 0.1);
}

/* Theme: Forest */
.theme-forest {
  --bg: oklch(0.975 0.012 145);
  --bg-deep: oklch(0.948 0.014 145);
  --surface-2: oklch(0.985 0.008 145);
  --hairline: oklch(0.9 0.012 140);
  --hairline-strong: oklch(0.82 0.014 140);
  --primary: oklch(0.55 0.13 155);
  --primary-soft: oklch(0.93 0.05 155);
  --primary-ink: oklch(0.32 0.1 155);
}

/* Theme: Indigo */
.theme-indigo {
  --bg: oklch(0.975 0.01 270);
  --bg-deep: oklch(0.95 0.012 270);
  --surface-2: oklch(0.985 0.006 270);
  --hairline: oklch(0.9 0.012 265);
  --hairline-strong: oklch(0.82 0.014 265);
  --primary: oklch(0.55 0.16 270);
  --primary-soft: oklch(0.93 0.05 270);
  --primary-ink: oklch(0.32 0.13 270);
}

/* Theme: Plum */
.theme-plum {
  --bg: oklch(0.97 0.01 340);
  --bg-deep: oklch(0.94 0.013 340);
  --surface-2: oklch(0.983 0.006 340);
  --hairline: oklch(0.9 0.012 335);
  --hairline-strong: oklch(0.82 0.014 335);
  --primary: oklch(0.55 0.16 340);
  --primary-soft: oklch(0.93 0.05 340);
  --primary-ink: oklch(0.32 0.13 340);
}

/* Theme: Sunshine */
.theme-sunshine {
  --bg: oklch(0.975 0.015 85);
  --bg-deep: oklch(0.945 0.02 85);
  --surface-2: oklch(0.985 0.012 85);
  --hairline: oklch(0.9 0.015 80);
  --hairline-strong: oklch(0.82 0.018 80);
  --primary: oklch(0.7 0.16 70);
  --primary-soft: oklch(0.93 0.06 80);
  --primary-ink: oklch(0.42 0.13 65);
}

/* ─────────────────────────────────────────────────────────────
   Dark mode — overrides base tokens. Theme classes still apply
   their primary hue; the dark variant just shifts everything
   underneath.
   ───────────────────────────────────────────────────────────── */
.dark {
  --bg: oklch(0.18 0.014 60);
  --bg-deep: oklch(0.14 0.014 60);
  --surface: oklch(0.23 0.014 60);
  --surface-2: oklch(0.27 0.014 60);
  --ink: oklch(0.95 0.012 70);
  --ink-soft: oklch(0.78 0.012 70);
  --muted: oklch(0.58 0.012 65);
  --hairline: oklch(0.32 0.014 60);
  --hairline-strong: oklch(0.4 0.014 60);

  --primary: oklch(0.7 0.16 35);
  --primary-soft: oklch(0.32 0.08 40);
  --primary-ink: oklch(0.92 0.13 35);

  --income: oklch(0.74 0.14 155);
  --income-soft: oklch(0.3 0.06 155);
  --expense: oklch(0.72 0.16 28);
  --expense-soft: oklch(0.32 0.07 30);

  --accent-2: oklch(0.72 0.14 240);
  --accent-2-soft: oklch(0.3 0.07 240);

  --shadow-1: 0 1px 0 oklch(0.95 0.01 70 / 0.04), 0 1px 2px oklch(0 0 0 / 0.3);
  --shadow-2: 0 4px 14px oklch(0 0 0 / 0.3), 0 1px 2px oklch(0 0 0 / 0.4);
  --shadow-pop: 0 24px 60px oklch(0 0 0 / 0.55), 0 4px 14px oklch(0 0 0 / 0.4);

  color-scheme: dark;
}

/* Per-theme primary tweaks for dark mode — lift lightness so the
   accent still reads against the deep neutral bg. */
.dark.theme-forest    { --primary: oklch(0.7 0.14 155); --primary-ink: oklch(0.9 0.12 155); --primary-soft: oklch(0.28 0.07 155); }
.dark.theme-indigo    { --primary: oklch(0.72 0.16 270); --primary-ink: oklch(0.92 0.14 270); --primary-soft: oklch(0.3 0.08 270); }
.dark.theme-plum      { --primary: oklch(0.72 0.16 340); --primary-ink: oklch(0.92 0.14 340); --primary-soft: oklch(0.3 0.08 340); }
.dark.theme-sunshine  { --primary: oklch(0.78 0.16 75); --primary-ink: oklch(0.92 0.14 75); --primary-soft: oklch(0.3 0.08 80); }

/* Semantic income/expense text colors — light mode use deeper tones for
   readability on white; dark mode overrides to brighter values via .dark. */
:root {
  --income-text: oklch(0.45 0.13 155);
  --income-text-strong: oklch(0.32 0.1 155);
  --expense-text: oklch(0.5 0.16 28);
  --expense-text-strong: oklch(0.4 0.13 28);
}
.dark {
  --income-text: oklch(0.78 0.14 155);
  --income-text-strong: oklch(0.88 0.13 155);
  --expense-text: oklch(0.76 0.16 28);
  --expense-text-strong: oklch(0.86 0.15 28);
}

/* Pills: re-color text against dark-mode soft backgrounds */
.dark .pill.income { color: var(--income-text-strong); }
.dark .pill.expense { color: var(--expense-text-strong); }
.dark .pill.primary { color: var(--primary-ink); }

/* Hero KPI card stays deep in dark, instead of light-on-light */
.dark .kpi.hero { background: oklch(0.11 0.014 60); }
.dark .kpi.hero .bignum { color: var(--ink); }

/* Inputs need a subtly lifted background to read as fillable */
.dark .input, .dark .search { background: oklch(0.21 0.014 60); }
.dark .input:focus { box-shadow: 0 0 0 3px oklch(0.32 0.08 40); }

/* Segmented control highlight bg */
.dark .segmented button.on { background: oklch(0.3 0.014 60); }

/* Modal veil deeper in dark */
.dark .modal-veil { background: oklch(0 0 0 / 0.6); }

/* PnL table — bright separators stand out too much in dark */
.dark .pnl-tbl tr.total td { border-top-color: var(--ink); border-bottom-color: var(--ink); background: oklch(0.21 0.014 60); }
.dark .pnl-tbl tr.section-head td { background: oklch(0.21 0.014 60); }

/* Onboarding feature rows */
.dark .onb-step { color: var(--ink); }

/* Density: Compact */
.density-compact {
  --pad-card: 16px;
  --row-h: 42px;
}

/* ─── reset ─── */
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font-ui);
  font-size: 14px;
  line-height: 1.4;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
button { font: inherit; color: inherit; }
input, select, textarea { font: inherit; color: inherit; }
a { color: inherit; text-decoration: none; }

/* ─── layout shell ─── */
.app {
  display: grid;
  grid-template-columns: var(--sidebar-w, 248px) 1fr;
  min-height: 100vh;
  background: var(--bg);
}
.app.sidebar-icons { --sidebar-w: 72px; }

.sidebar {
  border-right: 1px solid var(--hairline);
  background: var(--bg);
  padding: 20px 14px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  position: sticky;
  top: 0;
  height: 100vh;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 8px 18px;
  font-family: var(--font-display);
  font-size: 22px;
  letter-spacing: -0.01em;
  color: var(--ink);
}
.brand .mark {
  width: 32px; height: 32px;
  border-radius: 8px;
  display: grid; place-items: center;
  flex-shrink: 0;
  overflow: hidden;
  background: var(--ink);
  box-shadow: 0 1px 2px oklch(0.3 0.05 50 / 0.15);
}
.brand .mark img {
  width: 100%; height: 100%;
  display: block;
}
.brand .label {
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.version-badge {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 500;
  color: var(--ink-soft);
  letter-spacing: 0.02em;
  line-height: 1;
}
.sidebar-icons .brand .label,
.sidebar-icons .nav-item .label,
.sidebar-icons .sidebar-section,
.sidebar-icons .channel-card { display: none; }
.sidebar-icons .nav-item { justify-content: center; padding: 10px 0; }

.nav-section {
  font-size: 11px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  padding: 16px 10px 8px;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 9px 10px;
  border-radius: 10px;
  color: var(--ink-soft);
  cursor: pointer;
  border: 0;
  background: transparent;
  text-align: left;
  width: 100%;
  white-space: nowrap;
}
.nav-item .label { overflow: hidden; text-overflow: ellipsis; }
.nav-item:hover { background: var(--surface-2); color: var(--ink); }
.nav-item.active {
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow-1);
}
.nav-item svg { flex-shrink: 0; }

.channel-card {
  margin-top: auto;
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: 14px;
  padding: 12px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.channel-card .ch-thumb {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--accent-2));
  display: grid; place-items: center;
  color: white;
  font-weight: 600;
  font-size: 14px;
  flex-shrink: 0;
}
.channel-card .ch-name { font-weight: 500; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.channel-card .ch-sub { font-size: 11px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ─── main content area ─── */
.main {
  padding: 28px 36px 60px;
  max-width: 1400px;
  width: 100%;
}
.page-head {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 24px;
  padding-right: 70px; /* reserve room for floating notifications bell */
}
.page-title {
  font-family: var(--font-display);
  font-size: 36px;
  letter-spacing: -0.015em;
  line-height: 1.05;
  font-weight: 400;
  margin: 0;
}
.page-sub { color: var(--muted); font-size: 14px; margin-top: 4px; }
.page-actions { display: flex; gap: 8px; }

/* ─── primitives ─── */
.card {
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-card);
  padding: var(--pad-card);
}
.card-quiet {
  background: var(--surface-2);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-card);
  padding: var(--pad-card);
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: var(--radius-input);
  border: 1px solid var(--hairline-strong);
  background: var(--surface);
  cursor: pointer;
  font-weight: 500;
  font-size: 13px;
  color: var(--ink);
  transition: background 0.15s, transform 0.05s;
}
.btn:hover { background: var(--surface-2); }
.btn:active { transform: scale(0.98); }
.btn-primary {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}
.btn-primary:hover { background: var(--primary-ink); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--ink-soft); }
.btn-ghost:hover { background: var(--surface-2); color: var(--ink); }
.btn-danger { background: var(--expense-soft); color: var(--expense-text-strong); border-color: var(--expense-soft); }
.btn-danger:hover { background: var(--expense); color: white; border-color: var(--expense); }
.btn-sm { padding: 5px 10px; font-size: 12px; }

.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 9px;
  border-radius: var(--radius-pill);
  font-size: 12px;
  font-weight: 500;
  background: var(--surface-2);
  color: var(--ink-soft);
  border: 1px solid var(--hairline);
}
.pill .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.pill.income { background: var(--income-soft); color: var(--income-text-strong); border-color: transparent; }
.pill.expense { background: var(--expense-soft); color: var(--expense-text-strong); border-color: transparent; }
.pill.primary { background: var(--primary-soft); color: var(--primary-ink); border-color: transparent; }

.kbd {
  font-family: var(--font-mono);
  font-size: 11px;
  padding: 2px 6px;
  background: var(--surface-2);
  border: 1px solid var(--hairline);
  border-radius: 6px;
  color: var(--muted);
}

.input {
  width: 100%;
  padding: 9px 12px;
  border-radius: var(--radius-input);
  border: 1px solid var(--hairline-strong);
  background: var(--surface);
  font-size: 13px;
  color: var(--ink);
  outline: none;
}
.input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.label { font-size: 12px; font-weight: 500; color: var(--ink-soft); margin-bottom: 6px; display: block; }
.nav-item .label, .brand .label, .channel-card .ch-name, .channel-card .ch-sub {
  margin-bottom: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: inherit;
  font-weight: inherit;
  color: inherit;
}

/* search */
.search {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 12px;
  border-radius: var(--radius-input);
  border: 1px solid var(--hairline-strong);
  background: var(--surface);
  width: 280px;
}
.search input { flex: 1; border: 0; outline: 0; background: transparent; font-size: 13px; }

/* tables */
.tbl { width: 100%; border-collapse: collapse; }
.tbl th {
  text-align: left;
  font-size: 11px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  padding: 10px 12px;
  border-bottom: 1px solid var(--hairline);
}
.tbl td {
  padding: 12px;
  border-bottom: 1px solid var(--hairline);
  height: var(--row-h);
  vertical-align: middle;
  font-size: 13.5px;
}
.tbl tr:hover td { background: var(--surface-2); }
.tbl td.num { font-family: var(--font-mono); font-variant-numeric: tabular-nums; text-align: right; font-size: 13px; }
.tbl .amt-income { color: var(--income-text); font-weight: 500; }
.tbl .amt-expense { color: var(--ink); }

/* hero number */
.bignum {
  font-family: var(--font-display);
  font-size: 56px;
  line-height: 1;
  letter-spacing: -0.015em;
  color: var(--ink);
}
.bignum .cents { font-size: 30px; color: var(--muted); }
.bignum-sm {
  font-family: var(--font-display);
  font-size: 32px;
  line-height: 1.05;
  letter-spacing: -0.01em;
}

/* delta */
.delta { font-size: 12px; font-weight: 500; display: inline-flex; gap: 4px; align-items: center; }
.delta.up { color: var(--income-text); }
.delta.down { color: var(--expense-text); }

/* ─── modal ─── */
.modal-veil {
  position: fixed; inset: 0;
  background: oklch(0.22 0.02 60 / 0.4);
  display: grid; place-items: center;
  z-index: 100;
  padding: 40px;
  backdrop-filter: blur(2px);
  animation: veil-in 0.18s ease;
}
.modal {
  background: var(--surface);
  border-radius: 20px;
  width: 100%;
  max-width: 540px;
  max-height: calc(100vh - 80px);
  box-shadow: var(--shadow-pop);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  animation: modal-in 0.22s cubic-bezier(0.2, 0.8, 0.2, 1);
}
.modal-head { flex-shrink: 0; }
.modal-foot { flex-shrink: 0; }
.modal-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
}
.modal-head {
  padding: 22px 24px 16px;
  border-bottom: 1px solid var(--hairline);
}
.modal-title { font-family: var(--font-display); font-size: 26px; letter-spacing: -0.01em; margin: 0; }
.modal-sub { color: var(--muted); margin-top: 4px; font-size: 13px; }
.modal-body { padding: 20px 24px; }
.modal-foot {
  padding: 16px 24px;
  border-top: 1px solid var(--hairline);
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  background: var(--surface-2);
}

@keyframes veil-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes modal-in {
  from { opacity: 0; transform: translateY(8px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

/* ─── KPI grid ─── */
.kpi-grid {
  display: grid;
  grid-template-columns: 1.4fr 1fr 1fr 1fr;
  gap: 16px;
  margin-bottom: 24px;
}
.layout-equal .kpi-grid { grid-template-columns: repeat(4, 1fr); }

.kpi {
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-card);
  padding: var(--pad-card);
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.kpi.hero {
  background: var(--ink);
  color: oklch(0.95 0.01 70);
  border-color: transparent;
}
.kpi.hero .kpi-label { color: oklch(0.7 0.01 70); }
.kpi.hero .bignum { color: white; }
.kpi.hero .bignum .cents { color: oklch(0.7 0.01 70); }

.kpi-label {
  font-size: 12px;
  font-weight: 500;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* ─── dashboard grid ─── */
.dash-grid {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 16px;
}
.layout-equal .dash-grid { grid-template-columns: 1fr 1fr; }

/* ─── chart styles ─── */
.chart-wrap {
  height: 260px;
  position: relative;
  margin-top: 8px;
}
.chart-legend {
  display: flex;
  gap: 16px;
  font-size: 12px;
  color: var(--ink-soft);
  margin-top: 12px;
}
.chart-legend .swatch {
  display: inline-block;
  width: 10px; height: 10px;
  border-radius: 3px;
  margin-right: 6px;
  vertical-align: middle;
}

/* ─── category bars ─── */
.cat-row {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--hairline);
}
.cat-row:last-child { border-bottom: 0; }
.cat-name {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13.5px;
}
.cat-swatch { width: 10px; height: 10px; border-radius: 3px; }
.cat-bar {
  height: 6px;
  background: var(--surface-2);
  border-radius: 3px;
  overflow: hidden;
  margin-top: 4px;
}
.cat-bar > div { height: 100%; border-radius: 3px; }
.cat-amount {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: 13px;
  font-weight: 500;
}

/* ─── segmented ─── */
.segmented {
  display: inline-flex;
  background: var(--surface-2);
  border: 1px solid var(--hairline);
  border-radius: 10px;
  padding: 3px;
}
.segmented button {
  border: 0;
  background: transparent;
  padding: 6px 12px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--muted);
}
.segmented button.on {
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow-1);
}

/* ─── filters bar ─── */
.filters {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-bottom: 18px;
}
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 11px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--hairline-strong);
  background: var(--surface);
  font-size: 12.5px;
  cursor: pointer;
  color: var(--ink-soft);
}
.chip:hover { background: var(--surface-2); }
.chip.on { background: var(--ink); color: var(--bg); border-color: var(--ink); }

/* ─── settings ─── */
.account-row {
  display: grid;
  grid-template-columns: 48px 1fr auto auto;
  align-items: center;
  gap: 14px;
  padding: 16px 4px;
  border-bottom: 1px solid var(--hairline);
}
.account-row:last-child { border-bottom: 0; }
.account-logo {
  width: 44px; height: 44px;
  border-radius: 12px;
  display: grid; place-items: center;
  font-weight: 700;
  color: white;
  font-size: 14px;
}

/* ─── animations ─── */
@keyframes fade-in {
  from { opacity: 0.6; transform: translateY(2px); }
  to { opacity: 1; transform: translateY(0); }
}
.page-fade { animation: fade-in 0.25s ease-out; }

/* ─── P&L table ─── */
.pnl-tbl {
  width: 100%;
  border-collapse: collapse;
  font-variant-numeric: tabular-nums;
}
.pnl-tbl th {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  font-weight: 500;
  padding: 12px 10px;
  text-align: right;
  border-bottom: 1px solid var(--hairline-strong);
}
.pnl-tbl th:first-child { text-align: left; }
.pnl-tbl td {
  padding: 9px 10px;
  font-size: 13.5px;
  border-bottom: 1px solid var(--hairline);
}
.pnl-tbl td.num { text-align: right; font-family: var(--font-mono); font-size: 13px; }
.pnl-tbl tr.section-head td {
  font-weight: 600;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--ink-soft);
  background: var(--surface-2);
  padding-top: 14px;
  padding-bottom: 14px;
}
.pnl-tbl tr.subtotal td {
  font-weight: 600;
  border-top: 1px solid var(--hairline-strong);
}
.pnl-tbl tr.total td {
  font-weight: 600;
  font-size: 15px;
  border-top: 2px solid var(--ink);
  border-bottom: 2px solid var(--ink);
  background: var(--surface-2);
}
.pnl-tbl .indent { padding-left: 24px; color: var(--ink-soft); }

/* ─── empty state ─── */
.empty {
  padding: 40px;
  text-align: center;
  color: var(--muted);
}

/* ─────────────────────────────────────────────────────────────
   Mobile / responsive layer
   Below 860px the sidebar collapses into a slide-out drawer,
   the page-head stacks, KPI rows wrap to 2x2, two-column grids
   become one column, and modals go full-screen.
   ───────────────────────────────────────────────────────────── */

/* Mobile header — shown only when sidebar is hidden */
.mobile-header { display: none; }

@media (max-width: 860px) {
  .alerts-floating { display: none !important; }
  .page-head { padding-right: 0; }
  .app {
    grid-template-columns: 1fr;
    min-width: 0;
  }

  /* Drawer sidebar */
  .sidebar {
    position: fixed;
    top: 0; bottom: 0; left: 0;
    width: 280px;
    z-index: 1100;
    transform: translateX(-100%);
    transition: transform 0.25s cubic-bezier(0.2, 0.8, 0.2, 1);
    box-shadow: var(--shadow-pop);
    background: var(--bg);
    overflow-y: auto;
  }
  .sidebar.open { transform: translateX(0); }
  .sidebar-veil {
    position: fixed; inset: 0;
    background: oklch(0 0 0 / 0.4);
    z-index: 1090;
    animation: veil-in 0.18s ease;
  }

  /* Top mobile header */
  .mobile-header {
    display: flex;
    align-items: center;
    gap: 10px;
    position: sticky;
    top: 0;
    z-index: 40;
    padding: 12px 16px;
    background: var(--bg);
    border-bottom: 1px solid var(--hairline);
  }
  .mobile-header .icon-btn {
    display: grid; place-items: center;
    width: 38px; height: 38px;
    border-radius: 10px;
    border: 1px solid var(--hairline-strong);
    background: var(--surface);
    cursor: pointer;
    color: var(--ink);
  }
  .mobile-header .brand-mini {
    display: flex; align-items: center; gap: 8px;
    font-family: var(--font-display);
    font-size: 18px;
  }
  .mobile-header .brand-mini img { width: 28px; height: 28px; border-radius: 7px; }

  /* Main content padding */
  .main { padding: 16px 16px 90px; }

  /* Page head stacks */
  .page-title { font-size: 30px; }
  .page-head {
    flex-direction: column;
    align-items: stretch;
    gap: 14px;
    margin-bottom: 18px;
  }
  .page-actions {
    width: 100%;
    flex-wrap: wrap;
  }
  .page-actions .btn { flex: 1 1 auto; justify-content: center; }

  /* Grids collapse */
  .kpi-grid,
  .kpi-grid[style*="grid-template-columns"],
  .kpi-grid[style*="gridTemplateColumns"] {
    grid-template-columns: 1fr 1fr !important;
    gap: 10px;
  }
  .dash-grid,
  .dash-grid[style*="grid-template-columns"] {
    grid-template-columns: 1fr !important;
  }
  /* Subscription, receipts, settings inner grids — anything that
     spans more than 2 columns should fold to 1 or 2 on mobile. */
  [style*="grid-template-columns: repeat(3"],
  [style*="grid-template-columns: repeat(4"],
  [style*="grid-template-columns: repeat(5"],
  [style*="grid-template-columns: 1fr 1fr"],
  [style*="grid-template-columns: 1.4fr 1fr"],
  [style*="grid-template-columns: 2fr 1fr"],
  [style*="grid-template-columns: 200px 1fr"],
  [style*="grid-template-columns: 280px 1fr"],
  [style*="grid-template-columns: 120px 1fr"],
  [style*="grid-template-columns: 100px 1fr"] {
    grid-template-columns: 1fr !important;
  }
  /* Receipts grid: 2 cols on mobile so cards aren't huge */
  [style*="grid-template-columns: repeat(3, 1fr)"][style*="gap: 12"] {
    grid-template-columns: 1fr 1fr !important;
  }

  /* KPI text sizes — shrink slightly on mobile */
  .bignum { font-size: 40px; }
  .bignum .cents { font-size: 22px; }
  .bignum-sm { font-size: 26px; }
  .kpi { padding: 16px; gap: 6px; }
  .kpi .kpi-label { font-size: 10.5px; }

  /* Settings two-column → stack */
  .settings-cols { grid-template-columns: 1fr !important; gap: 14px !important; }
  /* Settings side nav becomes horizontal scroll chips */
  .settings-cols > div:first-child {
    flex-direction: row !important;
    overflow-x: auto;
    padding-bottom: 6px;
    margin: 0 -16px;
    padding-left: 16px; padding-right: 16px;
  }
  .settings-cols > div:first-child .nav-item {
    flex-shrink: 0;
    padding: 8px 14px;
    background: var(--surface);
    border: 1px solid var(--hairline);
  }
  .settings-cols > div:first-child .nav-item.active {
    background: var(--ink); color: var(--bg);
  }
  .settings-cols > div:first-child .nav-item.active svg { color: var(--bg); }

  /* Cards containing wide tables: horizontal scroll */
  .card { overflow-x: auto; }
  .tbl { min-width: 580px; }
  .pnl-tbl { min-width: 600px; }

  /* Filters wrap */
  .filters {
    align-items: stretch;
  }
  .search {
    width: 100% !important;
    box-sizing: border-box;
  }
  .segmented {
    overflow-x: auto;
    max-width: 100%;
  }

  /* Modals — full screen, but with a small inset on iOS for safe areas */
  .modal-veil { padding: 0; }
  .modal {
    width: 100vw;
    max-width: 100vw !important;
    height: 100vh;
    border-radius: 0;
    display: flex;
    flex-direction: column;
    animation: modal-mobile-in 0.22s cubic-bezier(0.2, 0.8, 0.2, 1);
  }
  .modal-body { flex: 1; overflow-y: auto; }
  .modal-foot { flex-wrap: wrap; }

  /* Onboarding step body padding */
  .onb-step h1, .onb-step h2 { font-size: 32px !important; }

  /* Chart heights — slightly shorter on mobile */
  .chart-wrap { height: 220px; }

  /* Tweaks panel — keep it visible but slimmer */
  .twk-panel { right: 12px; left: 12px; width: auto !important; }

  /* Login screen — ensure it fills mobile properly */
  .login-screen { padding: 16px !important; }

  /* Modal footer buttons — wrap nicely on narrow screens */
  .modal-foot .btn { font-size: 12px; padding: 7px 10px; }

  /* Receipt scan two-column → stack */
  [style*="gridTemplateColumns: \"1fr 1fr\""],
  [style*="grid-template-columns: 1fr 1fr"] {
    grid-template-columns: 1fr !important;
  }

  /* Account settings grid */
  .account-row {
    grid-template-columns: 40px 1fr auto !important;
    gap: 10px;
  }
  .account-row > :nth-child(3) { display: none; }
}

/* Extra-small screens — phones in portrait */
@media (max-width: 480px) {
  .kpi-grid,
  .kpi-grid[style*="grid-template-columns"],
  .kpi-grid[style*="gridTemplateColumns"] {
    grid-template-columns: 1fr !important;
  }
  .page-title { font-size: 26px; }
  .bignum { font-size: 34px; }
  .bignum-sm { font-size: 22px; }
  .page-actions .btn { font-size: 12px; padding: 7px 10px; }
  /* Receipt vault cards — single column on very small screens */
  [style*="grid-template-columns: repeat(3, 1fr)"][style*="gap: 12"] {
    grid-template-columns: 1fr !important;
  }
  .segmented button { padding: 5px 8px; font-size: 11.5px; }
  .modal-head { padding: 16px 16px 12px; }
  .modal-body { padding: 14px 16px; }
  .modal-foot { padding: 12px 16px; }
  .modal-title { font-size: 22px; }
}

@keyframes modal-mobile-in {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Hide mobile header on desktop */
@media (min-width: 861px) {
  .mobile-header { display: none !important; }
}

/* selectable row */
.row-clickable { cursor: pointer; }

/* sparkline */
.spark { width: 100%; height: 40px; }

/* tag list in modal */
.tag-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}
.tag-grid .chip { justify-content: center; padding: 9px; }
