/* v3.7: self-hosted fonts (were Google Fonts — now private, offline-capable, CSP-clean) */
@font-face {
  font-family: 'Space Grotesk'; font-style: normal; font-weight: 400; font-display: swap;
  src: url('vendor/fonts/space-grotesk-latin-400-normal.woff2') format('woff2');
}
@font-face {
  font-family: 'Space Grotesk'; font-style: normal; font-weight: 500; font-display: swap;
  src: url('vendor/fonts/space-grotesk-latin-500-normal.woff2') format('woff2');
}
@font-face {
  font-family: 'Space Grotesk'; font-style: normal; font-weight: 600; font-display: swap;
  src: url('vendor/fonts/space-grotesk-latin-600-normal.woff2') format('woff2');
}
@font-face {
  font-family: 'Space Grotesk'; font-style: normal; font-weight: 700; font-display: swap;
  src: url('vendor/fonts/space-grotesk-latin-700-normal.woff2') format('woff2');
}
@font-face {
  font-family: 'JetBrains Mono'; font-style: normal; font-weight: 400; font-display: swap;
  src: url('vendor/fonts/jetbrains-mono-latin-400-normal.woff2') format('woff2');
}
@font-face {
  font-family: 'JetBrains Mono'; font-style: normal; font-weight: 500; font-display: swap;
  src: url('vendor/fonts/jetbrains-mono-latin-500-normal.woff2') format('woff2');
}
@font-face {
  font-family: 'JetBrains Mono'; font-style: normal; font-weight: 600; font-display: swap;
  src: url('vendor/fonts/jetbrains-mono-latin-600-normal.woff2') format('woff2');
}

/* Family Budget — v1.4 visual system
   Palette: deep pine sidebar, warm paper canvas, ink text, brass accent.
   Type: Fraunces (display) · Libre Franklin (UI) · IBM Plex Mono (figures). */

:root {
  color-scheme: dark;
  --paper: #0D1117;
  --card: #151B23;
  --ink: #E6EDF3;
  --ink-2: #7D8590;
  --ink-3: #545D68;
  --pine: #0A0E13;            /* sidebar (name kept for compatibility) */
  --pine-2: #0D1218;
  --pine-3: #1F8F63;          /* deep mint */
  --pine-mid: #1F8F63;
  --line: #232B36;
  --line-soft: #1B222C;
  --gold: #3DDC97;            /* accent = mint (legacy name kept) */
  --gold-2: #5CE8AB;
  --gold-soft: #11251C;
  --brick: #F97066;
  --brick-soft: #2C1A1C;
  --green: #3DDC97;
  --green-soft: #0F2A1E;
  --mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, monospace;
  --disp: 'Space Grotesk', system-ui, sans-serif;
  --sans: 'Space Grotesk', system-ui, -apple-system, sans-serif;
  --shadow-1: 0 0 0 1px rgba(255,255,255,.02) inset, 0 1px 2px rgba(0,0,0,.3);
  --shadow-2: 0 8px 24px rgba(0,0,0,.35);
  --shadow-3: 0 24px 60px rgba(0,0,0,.55);
  --r-sm: 9px;
  --r-md: 13px;
  --r-lg: 16px;
  --sidebar-w: 218px;
  /* surfaces */
  --input-bg: #0F141B;
  --raised: #10151C;
  --hover: #171E27;
  --modal-bg: #11161D;
  --toast-bg: #1C2530;
  --line-strong: #3B4552;
  --topbar-bg: rgba(13, 17, 23, .8);
  /* chips + banners */
  --chip-bg: #11251C; --chip-fg: #7EE2B8; --chip-line: #1E4433;
  --ok-bg: #0F2A1E; --ok-fg: #9BEBC7; --ok-line: #1E4433;
  --warn-bg: #241E0E; --warn-fg: #E8CE8D; --warn-line: #4A3D1C;
  --danger-bg: #2C1A1C; --danger-fg: #F5A9A3; --danger-line: #4E2A2C;
  --chart-grid: #1B222C;
  --chart-text: #7D8590;
  --accent-contrast: #04170E;
  --btn-off-bg: #232B36;
  --btn-off-fg: #545D68;
  /* v3.6: type scale (inline sizes converted to these) */
  --fs-xs: 11px;
  --fs-sm: 12.5px;
  --fs-md: 13px;
  /* v3.6: accent machinery (accent = "gold" tokens; green/brick stay semantic) */
  --accent-rgb: 61, 220, 151;
  --gold-deep: #1F8F63;
  --accent-hi: #B7F5DA;
}

/* ---------- light theme ---------- */
[data-theme="light"] {
  color-scheme: light;
  --paper: #F5F5EF;
  --card: #FFFFFF;
  --ink: #1B2620;
  --ink-2: #5D6A62;   /* v3.8.1: darkened — small muted text was hard to read on white */
  --ink-3: #737E75;
  --line: #E3E5DB;
  --line-soft: #EEEFE7;
  --gold: #0E9D66;         /* accent: deep mint for light backgrounds */
  --gold-2: #16B377;
  --gold-soft: #E5F5EC;
  --brick: #C74436;
  --brick-soft: #FBE7E4;
  --green: #0E9D66;
  --green-soft: #E5F5EC;
  --shadow-1: 0 1px 2px rgba(20, 30, 24, .06);
  --shadow-2: 0 6px 20px rgba(20, 30, 24, .08);
  --shadow-3: 0 20px 55px rgba(15, 25, 20, .22);
  --input-bg: #FFFFFF;
  --raised: #F7F8F2;
  --hover: #F2F3EC;
  --modal-bg: #FBFBF7;
  --toast-bg: #1B2620;
  --line-strong: #C8CCC0;
  --topbar-bg: rgba(245, 245, 239, .85);
  --chip-bg: #E5F5EC; --chip-fg: #0B7A4E; --chip-line: #C6E9D5;
  --ok-bg: #E5F5EC; --ok-fg: #0F6B44; --ok-line: #C6E9D5;
  --warn-bg: #FCF3DC; --warn-fg: #7A5A12; --warn-line: #EBD9A8;
  --danger-bg: #FBE7E4; --danger-fg: #A33326; --danger-line: #F0C9C2;
  --chart-grid: #E7E8E0;
  --chart-text: #68746C;
  --accent-contrast: #FFFFFF;
  --btn-off-bg: #E3E5DB;
  --btn-off-fg: #9CA69E; /* deliberately paler than --ink-3: disabled ≠ body text */
  --accent-rgb: 14, 157, 102;
  --gold-deep: #0B7A4E;
  --accent-hi: #B7F5DA; /* sidebar stays dark in light theme */
}

/* ---------- base ---------- */
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
button { cursor: pointer; font-family: inherit; color: inherit; }
input, select, textarea { font-family: inherit; font-size: 14px; color: var(--ink); }
input:focus-visible, select:focus-visible, textarea:focus-visible, button:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 1px;
}
::selection { background: rgba(61,220,151,.25); }
.mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.soft { color: var(--ink-2); }
.pos { color: var(--green); }
.neg { color: var(--brick); }

/* ---------- shell ---------- */
.shell { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w);
  flex: 0 0 var(--sidebar-w);
  background: var(--pine);
  border-right: 1px solid var(--line);
  color: #C9D1D9;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 20px 12px 14px;
}
.brand { display: flex; align-items: center; gap: 11px; padding: 2px 8px 20px; }
.brand-mark {
  width: 34px; height: 34px; flex: 0 0 34px;
  border-radius: 9px;
  background: #10251B;
  border: 1px solid rgba(var(--accent-rgb), .4);
  color: var(--gold);
  font-family: var(--disp);
  font-size: 17px; font-weight: 700;
  display: grid; place-items: center;
}
.brand-title {
  font-family: var(--disp);
  font-size: 16.5px;
  font-weight: 600;
  letter-spacing: -0.01em;
  line-height: 1.15;
  color: #F0F6FC;
}
.brand-sub {
  font-family: var(--mono);
  font-size: 9.5px;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: #6E7681;
  margin-top: 3px;
}

.nav { display: flex; flex-direction: column; gap: 2px; flex: 1; overflow-y: auto; scrollbar-width: none; }
.nav::-webkit-scrollbar { display: none; }
.nav-sec { margin-bottom: 6px; }
.nav-sec-head {
  display: flex; align-items: center; justify-content: space-between;
  width: 100%; background: transparent; border: none; cursor: pointer;
  padding: 7px 10px 5px; font-size: 10.5px; font-weight: 700;
  letter-spacing: .09em; text-transform: uppercase; color: #6E7681;
  border-radius: var(--r-sm);
}
.nav-sec-head:hover { color: #8B949E; }
.nav-sec-head .chev { width: 12px; height: 12px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; transition: transform .18s ease; }
.nav-sec.collapsed .nav-sec-head .chev { transform: rotate(-90deg); }
.nav-sec-body { display: flex; flex-direction: column; gap: 2px; overflow: hidden; }
.nav-sec.collapsed .nav-sec-body { display: none; }
.tab {
  display: flex; align-items: center; gap: 11px;
  width: 100%;
  background: transparent;
  border: none;
  border-radius: var(--r-sm);
  padding: 9px 10px;
  font-size: 13.5px;
  font-weight: 500;
  color: #8B949E;
  text-align: left;
  position: relative;
  transition: background .14s ease, color .14s ease;
}
.tab svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; flex: 0 0 17px; }
.tab:hover { background: rgba(255, 255, 255, .05); color: #E6EDF3; }
.tab.active { background: rgba(var(--accent-rgb), .12); color: var(--accent-hi); font-weight: 600; }
.tab.active::before {
  content: "";
  position: absolute; left: -12px; top: 7px; bottom: 7px;
  width: 3px; border-radius: 0 3px 3px 0;
  background: var(--gold);
}
.sidebar-foot {
  font-size: 10.5px;
  color: #545D68;
  padding: 14px 10px 0;
  border-top: 1px solid var(--line);
}

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

.topbar {
  display: flex; align-items: center; gap: 12px;
  background: var(--topbar-bg);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
  padding: 12px 28px;
  position: sticky; top: 0; z-index: 20;
}
.topbar-spacer { flex: 1; }
/* v4.6.1: topbar tools — chat & search as proper labeled buttons, divided from the primary action */
.tb-tool {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 7px 12px; border: 1px solid var(--line); border-radius: var(--r-sm);
  background: var(--card); color: var(--ink-2); font: 500 var(--fs-md)/1 var(--sans);
  cursor: pointer; transition: color .12s ease, border-color .12s ease;
}
.tb-tool:hover { color: var(--ink); border-color: var(--line-strong); }
.tb-tool svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.tb-kbd {
  font: 500 10px/1 var(--mono); color: var(--ink-3);
  border: 1px solid var(--line); border-radius: 4px; padding: 2px 4px;
}
.tb-sep { width: 1px; height: 22px; background: var(--line-strong); margin: 0 4px; }
@media (max-width: 760px) {
  .tb-lbl, .tb-kbd, .tb-sep { display: none; }
  .tb-tool { padding: 8px; }
}
.month-select {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  padding: 8px 12px;
  font-weight: 600;
  font-size: 13.5px;
  box-shadow: var(--shadow-1);
}
.btn-gold {
  display: inline-flex; align-items: center; gap: 7px;
  background: linear-gradient(180deg, var(--gold-2), var(--gold));
  color: var(--accent-contrast, #04170E);
  border: none;
  border-radius: var(--r-sm);
  padding: 9px 15px;
  font-weight: 600;
  font-size: 13.5px;
  box-shadow: 0 4px 18px rgba(var(--accent-rgb), .3);
  transition: filter .14s ease, transform .1s ease;
}
.btn-gold:hover { filter: brightness(1.05); }
.btn-gold:active { transform: translateY(1px); }
.btn-gold:disabled { background: var(--btn-off-bg); color: var(--btn-off-fg); box-shadow: none; cursor: default; }
.btn-icon { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }

.main { max-width: 1060px; width: 100%; margin: 0 auto; padding: 26px 28px 72px; }
.main > * { animation: rise .28s ease backwards; } /* not 'both': forwards-fill made every section a permanent stacking context, trapping popovers behind later siblings */
@keyframes rise { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; transform: none; } }
.loading { color: var(--ink-2); padding: 60px 0; text-align: center; }

/* ---------- headings ---------- */
h2.page-title {
  font-family: var(--disp);
  font-size: 23px;
  font-weight: 600;
  letter-spacing: -0.015em;
  margin: 2px 0 18px;
}
.page-head { display: flex; align-items: baseline; gap: 14px; flex-wrap: wrap; margin-bottom: 16px; }
.page-head .meta { font-family: var(--mono); font-size: 12.5px; color: var(--ink-2); }
.label {
  font-size: 10.5px;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--ink-2);
  font-weight: 700;
}

/* ---------- cards & stats ---------- */
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-1);
}
/* v3.5: shared card padding (was 8 inline variants; classes let compact density reach every card) */
.pad { padding: 18px 20px; }
.pad-sm { padding: 12px 14px; }
/* v3.6: inline empty/hint message — one style for every "nothing here yet" line */
.empty-note { font-size: var(--fs-sm); color: var(--ink-2); }
/* v3.6: tall scrolling tables keep their header in view */
.tw-scroll { max-height: min(68vh, 620px); overflow: auto; }
.tw-scroll thead th { position: sticky; top: 0; background: var(--card); z-index: 2; box-shadow: 0 1px 0 var(--line); }
/* v4.4.1: .tw-pin — first (label) and last (total) columns stay put while months scroll */
.tw-pin th:first-child, .tw-pin td:first-child { position: sticky; left: 0; background: var(--card); z-index: 1; }
.tw-pin th:last-child, .tw-pin td:last-child { position: sticky; right: 0; background: var(--card); z-index: 1; box-shadow: -1px 0 0 var(--line); }
.tw-pin thead th:first-child, .tw-pin thead th:last-child { z-index: 3; }
.tw-pin tbody tr:hover td:first-child, .tw-pin tbody tr:hover td:last-child { background: var(--hover); }
.stat-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(185px, 1fr)); gap: 14px; }
.stat { flex: 1 1 200px; padding: 16px 18px 15px; }
.stat .value {
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  font-size: clamp(17px, 1.6vw + 8px, 25px);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  font-weight: 600;
  letter-spacing: -0.01em;
  margin-top: 7px;
}
.stat .sub { font-size: 12px; color: var(--ink-2); margin-top: 3px; }

/* ---------- bars ---------- */
.bar-grid { display: grid; grid-template-columns: 160px 1fr 110px; align-items: center; gap: 12px; padding: 5px 0; }
.bar-track { height: 14px; background: var(--line-soft); border-radius: 99px; overflow: hidden; }
.bar-fill { height: 100%; background: linear-gradient(90deg, var(--gold-deep), var(--gold)); border-radius: 99px; }
.bar-fill.gold { background: linear-gradient(90deg, var(--gold), var(--gold-2)); }
.bar-amount { font-family: var(--mono); font-variant-numeric: tabular-nums; font-size: 12.5px; text-align: right; }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; border-radius: var(--r-md); }
table { width: 100%; border-collapse: collapse; min-width: 640px; }
thead th {
  font-size: 10.5px;
  letter-spacing: .09em;
  text-transform: uppercase;
  color: var(--ink-2);
  font-weight: 700;
  text-align: left;
  padding: 10px 13px;
  border-bottom: 1px solid var(--line);
  background: var(--raised);
  white-space: nowrap;
  user-select: none;
  position: sticky; top: 0;
}
thead th.sortable { cursor: pointer; }
thead th.sortable:hover { color: var(--ink); }
tbody td {
  padding: 10px 13px;
  border-bottom: 1px solid var(--line-soft);
  font-size: 13.5px;
  vertical-align: top;
}
tbody tr:last-child td { border-bottom: none; }
tbody tr { transition: background .1s ease; }
tbody tr:hover { background: var(--hover); }
td.mono, .dt { font-variant-numeric: tabular-nums; }
.dt { font-family: var(--mono); font-size: 12px; white-space: nowrap; color: var(--ink-2); }
.chip {
  background: var(--chip-bg);
  color: var(--chip-fg);
  border: 1px solid var(--chip-line);
  border-radius: 99px;
  padding: 2px 9px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}
.row-actions button {
  border: none; background: transparent;
  color: var(--ink-3);
  font-size: 14px;
  padding: 2px 6px;
  border-radius: 5px;
  opacity: 0;
  transition: opacity .12s ease, color .12s ease, background .12s ease;
}
tbody tr:hover .row-actions button { opacity: 1; }
.row-actions button:hover { color: var(--ink); background: var(--line-soft); }
.empty { padding: 34px; color: var(--ink-2); text-align: center; }

/* ---------- filters ---------- */
.filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 14px; position: relative; z-index: 5; }
.filters input[type="search"] {
  flex: 1 1 220px;
  padding: 9px 13px;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  background: var(--input-bg);
  color: var(--ink);
  box-shadow: var(--shadow-1);
}
.filters select {
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  background: var(--card);
  box-shadow: var(--shadow-1);
  font-size: 13px;
}
.filters .count { font-family: var(--mono); font-size: 12.5px; color: var(--ink-2); }
.link-btn {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  padding: 8px 13px;
  color: var(--ink);
  font-weight: 500;
  font-size: 13px;
  text-decoration: none;
  box-shadow: var(--shadow-1);
  transition: border-color .12s ease, background .12s ease;
}
.link-btn:hover { border-color: var(--line-strong); background: var(--hover); }

/* ---------- breakdown ---------- */
.cat-block { margin-bottom: 10px; overflow: hidden; }
.cat-head {
  width: 100%;
  display: grid;
  grid-template-columns: 18px 1fr 110px 110px 110px;
  gap: 10px;
  align-items: center;
  background: transparent;
  border: none;
  padding: 13px 16px;
  text-align: left;
  transition: background .12s ease;
}
.cat-head:hover { background: var(--hover); }
.cat-head .name { font-weight: 600; font-size: 14px; }
.mini-track { display: block; height: 4px; background: var(--line-soft); border-radius: 99px; margin-top: 7px; max-width: 260px; }
.mini-fill { display: block; height: 100%; border-radius: 99px; background: var(--pine-3); }
.mini-fill.over { background: var(--brick); }
.cat-detail-head, .cat-detail-row { display: grid; grid-template-columns: 18px 1fr 110px 110px 110px; gap: 10px; padding: 8px 16px; align-items: center; }
.cat-detail-head {
  font-size: 10px;
  letter-spacing: .09em;
  text-transform: uppercase;
  color: var(--ink-2);
  font-weight: 700;
  border-top: 1px solid var(--line);
  background: var(--raised);
}
.cat-detail-row { border-top: 1px solid var(--line-soft); font-size: 13.5px; }
.cat-detail-row:hover { background: var(--hover); }
.r { text-align: right; }
.caret { color: var(--ink-3); font-size: 10px; }
.diff { font-family: var(--mono); font-variant-numeric: tabular-nums; font-size: 12px; padding: 2px 8px; border-radius: 5px; }
.diff.pos { background: var(--green-soft); }
.diff.neg { background: var(--brick-soft); }
.dash { color: var(--ink-3); }

/* ---------- modal ---------- */
.overlay {
  position: fixed; inset: 0;
  background: rgba(4, 8, 12, .6);
  backdrop-filter: blur(2px);
  display: flex; align-items: center; justify-content: center;
  padding: 16px; z-index: 50;
  animation: fade .16s ease both;
}
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.modal {
  background: var(--modal-bg);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  width: 100%; max-width: 440px;
  padding: 22px 24px;
  max-height: 90vh; overflow-y: auto;
  box-shadow: var(--shadow-3);
  animation: pop .2s cubic-bezier(.2, .9, .3, 1.2) both;
}
@keyframes pop { from { opacity: 0; transform: scale(.96) translateY(6px); } to { opacity: 1; transform: none; } }
.modal h3 { font-family: var(--disp); font-size: 19px; font-weight: 600; margin: 0; }
.modal-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }
.modal-close {
  border: none; background: transparent;
  font-size: 19px; color: var(--ink-2);
  width: 30px; height: 30px; border-radius: 7px;
}
.modal-close:hover { background: var(--line-soft); color: var(--ink); }
.seg { display: flex; gap: 6px; margin-bottom: 16px; }
.seg button {
  flex: 1; padding: 8px 0;
  border-radius: var(--r-sm);
  border: 1px solid var(--line);
  background: var(--card);
  font-weight: 600; font-size: 13px;
  text-transform: capitalize;
  transition: all .12s ease;
}
.seg button.on { background: var(--chip-bg); border-color: var(--gold); color: var(--chip-fg); }
.field { display: block; margin-bottom: 12px; }
.field > span {
  display: block;
  font-size: 10.5px; letter-spacing: .09em; text-transform: uppercase;
  color: var(--ink-2); font-weight: 700;
  margin-bottom: 5px;
}
.field input, .field select {
  width: 100%;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  background: var(--input-bg);
}
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
.hint { font-size: 12.5px; color: var(--ink-2); margin: -4px 0 12px; }
.btn-primary {
  width: 100%; margin-top: 6px; padding: 11px 0;
  border-radius: var(--r-sm); border: none;
  background: linear-gradient(180deg, var(--gold-2), var(--gold));
  color: var(--accent-contrast, #04170E);
  font-weight: 600; font-size: 14px;
  box-shadow: 0 4px 18px rgba(var(--accent-rgb), .3);
}
.btn-primary:hover { filter: brightness(1.05); }
.btn-primary:disabled { background: var(--btn-off-bg); color: var(--btn-off-fg); box-shadow: none; }

/* ---------- settings ---------- */
.settings-grid { display: grid; gap: 16px; }
.plan-row { /* kept: baby checklist re-add uses this grid */ display: grid; grid-template-columns: 1fr 130px; gap: 10px; align-items: center; padding: 6px 0; border-top: 1px solid var(--line-soft); }
.plan-row input {
  width: 100%; padding: 7px 10px;
  border: 1px solid var(--line); border-radius: var(--r-sm);
  background: var(--input-bg); color: var(--ink);
  font-family: var(--mono); font-variant-numeric: tabular-nums;
  text-align: right;
}
.settings-cat-title { font-weight: 700; font-size: 13.5px; margin: 14px 0 2px; }
.inline-add { display: flex; gap: 8px; margin-top: 8px; flex-wrap: wrap; }
.inline-add input { padding: 8px 10px; border: 1px solid var(--line); border-radius: var(--r-sm); }
.btn-small {
  background: #1F8F63; color: var(--accent-contrast, #04170E); font-weight: 700;
  border: none; border-radius: var(--r-sm);
  padding: 8px 13px;
  font-weight: 600; font-size: 12.5px;
  transition: filter .12s ease;
}
.btn-small:hover { filter: brightness(1.12); }

/* ---------- toast ---------- */
.toast {
  position: fixed; bottom: 24px; left: 50%;
  transform: translateX(-50%);
  background: var(--toast-bg);
  color: #F2F4EE;
  border: 1px solid var(--line);
  padding: 11px 20px;
  border-radius: 9px;
  font-size: 13px; font-weight: 500;
  z-index: 60;
  box-shadow: var(--shadow-3);
  animation: toast-in .22s ease both;
}
@keyframes toast-in { from { opacity: 0; transform: translate(-50%, 8px); } to { opacity: 1; transform: translate(-50%, 0); } }

/* ---------- responsive ---------- */
@media (max-width: 860px) {
  .shell { flex-direction: column; }
  .sidebar {
    width: 100%; flex: none;
    height: auto; position: static;
    flex-direction: row; align-items: center; flex-wrap: wrap;
    padding: 10px 14px 0;
    gap: 4px 8px;
  }
  /* row 1: brand left, user controls right */
  .brand { order: 1; flex: 1; padding: 0; }
  .brand-sub { display: none; }
  .user-foot { order: 2; display: flex; margin-top: 0; padding: 0; border-top: none; width: auto; }
  /* row 2: full-width scrollable tab strip WITH labels */
  .nav {
    order: 3; flex-basis: 100%; width: 100%;
    flex-direction: row; overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    padding: 6px 0 0;
    margin: 6px -14px 0;
    padding-left: 14px; padding-right: 14px;
    border-top: 1px solid var(--line);
  }
  .nav::-webkit-scrollbar { display: none; }
  .tab { padding: 9px 11px; white-space: nowrap; flex: none; }
  .tab span { display: inline; font-size: 12.5px; }
  .tab svg { width: 17px; height: 17px; flex-basis: 17px; }
  .tab.active::before { left: 8px; right: 8px; top: auto; bottom: 0; width: auto; height: 3px; border-radius: 3px 3px 0 0; }
  .sidebar-foot { display: none; }
  .topbar { padding: 10px 16px; }
  .main { padding-bottom: calc(56px + env(safe-area-inset-bottom, 0px)); }
  .main { padding: 18px 16px 56px; }
  .hide-sm { display: none; }
  .bar-grid { grid-template-columns: 104px 1fr 88px; }
  .cat-head, .cat-detail-head, .cat-detail-row { grid-template-columns: 14px 1fr 78px 78px 82px; gap: 6px; font-size: 12.5px; }
  .stat .value { font-size: 21px; }
  .row-actions button { opacity: 1; }
}
@media (prefers-reduced-motion: reduce) {
  .main > *, .modal, .overlay, .toast, .bar-fill, .hero-fill, .mini-fill { animation: none; }
  .bar-fill, .mini-fill, .tab, .btn-gold { transition: none; }
}
@media (prefers-reduced-motion: no-preference) {
  .bar-fill, .mini-fill { transition: width .45s cubic-bezier(.25, .8, .3, 1); }
}

/* ---------- budget (zero-based) ---------- */
.zb-banner {
  border-radius: var(--r-md);
  padding: 12px 16px;
  font-size: 13.5px;
  margin-bottom: 16px;
  border: 1px solid transparent;
}
.zb-zero { background: var(--ok-bg); border-color: var(--ok-line); color: var(--ok-fg); }
.zb-left { background: var(--warn-bg); border-color: var(--warn-line); color: var(--warn-fg); }
.zb-over { background: var(--danger-bg); border-color: var(--danger-line); color: var(--danger-fg); }
.bud-head, .bud-row {
  display: grid;
  grid-template-columns: 1fr 118px 108px 108px;
  gap: 10px;
  align-items: center;
  padding: 9px 16px;
}
.bud-head { border-bottom: 1px solid var(--line); background: var(--raised); border-radius: var(--r-md) var(--r-md) 0 0; }
.bud-head .name { font-weight: 700; font-size: 13.5px; }
.bud-row { border-top: 1px solid var(--line-soft); }
.bud-row:hover { background: var(--hover); }
.bud-row .mini-track { max-width: 220px; margin-top: 5px; }
.bud-total { background: var(--raised); font-size: 12.5px; border-top: 1px solid var(--line); }
.bud-input {
  width: 100px;
  padding: 6px 9px;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  text-align: right;
  font-variant-numeric: tabular-nums;
  background: var(--input-bg);
}
.bud-input:hover { border-color: var(--line-strong); }
.fund-toggle {
  border: none; background: transparent;
  color: #3B4552;
  font-size: 11px;
  padding: 0 3px;
  vertical-align: 1px;
  transition: color .12s ease;
}
.fund-toggle:hover { color: var(--gold); }
.fund-toggle.on { color: var(--gold); }
.fund-bal {
  font-size: 11px;
  color: var(--chip-fg);
  background: var(--chip-bg);
  border-radius: 99px;
  padding: 1px 8px;
  margin-left: 4px;
}
@media (max-width: 860px) {
  .bud-head, .bud-row { grid-template-columns: 1fr 84px 76px 76px; gap: 6px; font-size: 12.5px; }
  .bud-input { width: 78px; }
}

/* ---------- auth / user ---------- */
.user-foot { display: flex; align-items: center; gap: 8px; }
.whoami { font-size: 12px; color: #8B949E; font-weight: 600; flex: 1; overflow: hidden; text-overflow: ellipsis; }
.logout-btn {
  border: 1px solid rgba(255,255,255,.14); background: transparent;
  color: #6E7681; font-size: 11px; border-radius: 6px; padding: 4px 9px;
}
.logout-btn:hover { color: #E6EDF3; border-color: var(--line-strong); }
@media (max-width: 860px) { .whoami { display: none; } }

/* ---------- charts ---------- */
.chart-controls { display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.chart-controls .field { min-width: 130px; flex: 0 1 auto; }
.chart-controls select { background: var(--input-bg); }
.chart-stage { position: relative; height: 340px; padding: 6px 4px 2px; }
.chart-stage.sm { height: 240px; }
.chart-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: 14px; }
.chart-card { overflow: hidden; }
.chart-card-head { display: flex; justify-content: space-between; align-items: center; padding: 11px 14px 4px; }
.row-del { border: none; background: transparent; color: var(--ink-3); font-size: 15px; border-radius: 6px; padding: 1px 7px; }
.row-del:hover { color: var(--ink); background: var(--line-soft); }
@media (max-width: 860px) {
  .chart-stage { height: 260px; }
  .chart-grid { grid-template-columns: 1fr; }
}

.chart-toggles { display: flex; gap: 18px; flex-wrap: wrap; margin: 2px 0 10px; }
.chart-toggles label { display: flex; align-items: center; gap: 7px; font-size: 12.5px; color: var(--ink-2); cursor: pointer; }
.chart-toggles input { accent-color: var(--gold); }

/* ---------- goals & rules ---------- */
.goal-row { display: grid; grid-template-columns: 1fr 150px 110px 30px; gap: 10px; align-items: center; padding: 9px 0; border-top: 1px solid var(--line-soft); }
.goal-row:first-child { border-top: none; }
.goal-row .row-actions button { opacity: 1; }
@media (max-width: 860px) { .goal-row { grid-template-columns: 1fr 110px 90px 26px; font-size: 12.5px; } }

/* ---------- dashboard widgets ---------- */
.dash-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 14px; margin-top: 16px; }
.dash-card { padding: 14px 16px 10px; }
.dash-head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; margin-bottom: 8px; }
.dash-head > .soft { text-align: right; }
/* v3.8.1: widgets are draggable — reserve a lane so the ⠿ handle never overlaps the corner button */
.dash-block .dash-head { padding-right: 26px; }
.mini-link { border: none; background: transparent; color: var(--gold); font-size: 11.5px; font-weight: 600; padding: 0; }
.mini-link:hover { text-decoration: underline; }
.dash-row { display: grid; grid-template-columns: minmax(0, 1fr) 62px 92px auto; gap: 8px; align-items: center; padding: 7px 0; border-top: 1px solid var(--line-soft); }
.dash-row.recent { grid-template-columns: minmax(0, 1fr) auto; }
.recent-main { min-width: 0; }
.recent-place { display: block; font-size: 13px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.recent-sub { display: block; font-size: 11px; color: var(--ink-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin-top: 1px; }
.dash-row:first-of-type { border-top: none; }
.dash-ok { color: var(--green); font-size: 13px; padding: 10px 0 8px; }

/* ---------- insights ---------- */
.insight-strip { display: flex; gap: 8px; flex-wrap: wrap; margin: -6px 0 16px; }
.insight-chip { background: var(--chip-bg); border: 1px solid var(--chip-line); color: var(--chip-fg); border-radius: 99px; padding: 5px 13px; font-size: 12px; font-weight: 600; }

.mini-icon { border: none; background: transparent; color: var(--ink-2); font-size: 12px; padding: 1px 5px; border-radius: 5px; }
.mini-icon:hover { color: var(--ink); background: var(--line-soft); }
.chip-x { border: none; background: none; color: inherit; opacity: .5; padding: 0 0 0 3px; font-size: 12px; cursor: pointer; }
.chip-x:hover { opacity: 1; }

/* ---------- theme toggle + month arrows ---------- */
.month-arrow {
  border: 1px solid var(--line); background: var(--card); color: var(--ink-2);
  border-radius: var(--r-sm); width: 34px; height: 36px; font-size: 17px; line-height: 1;
  box-shadow: var(--shadow-1);
}
.month-arrow:hover { color: var(--ink); border-color: var(--line-strong); }
#themeBtn { font-size: 13px; }

@media (max-width: 480px) {
  .hide-xs { display: none; }
  .btn-gold { padding: 9px 14px; font-size: 13px; white-space: nowrap; }
  .topbar { gap: 8px; }
}

/* ---------- help ---------- */
.help-search {
  width: 100%; max-width: 480px; padding: 10px 14px; margin-bottom: 4px;
  border: 1px solid var(--line); border-radius: var(--r-sm);
  background: var(--input-bg); color: var(--ink); font-family: var(--sans); font-size: 13.5px;
}
.help-item { margin-bottom: 8px; }
.help-item summary {
  cursor: pointer; padding: 12px 16px; font-size: 13.5px; font-weight: 600;
  list-style: none; display: flex; align-items: center; justify-content: space-between;
}
.help-item summary::-webkit-details-marker { display: none; }
.help-item summary::after { content: "+"; color: var(--ink-3); font-size: 16px; font-weight: 400; }
.help-item[open] summary::after { content: "−"; }
.help-answer { padding: 0 16px 14px; font-size: 13.5px; line-height: 1.65; color: var(--ink-2); }
.help-answer b { color: var(--ink); }
.help-answer code {
  font-family: var(--mono); font-size: 12px; background: var(--raised);
  border: 1px solid var(--line); border-radius: 5px; padding: 1px 6px;
}

.sync-badge {
  border: 1px solid var(--warn-line); background: var(--warn-bg); color: var(--warn-fg);
  border-radius: var(--r-sm); padding: 8px 12px; font-size: 12px; font-weight: 700; white-space: nowrap;
}
.tok-new {
  margin-top: 12px; padding: 12px 14px; border: 1px dashed var(--gold);
  border-radius: var(--r-sm); background: var(--gold-soft); font-size: 12.5px; color: var(--ink);
}

/* ---------- v2.16: undo, split, receipts, review ---------- */
.toast-undo {
  margin-left: 10px; border: 1px solid var(--gold); background: transparent;
  color: var(--gold); border-radius: 6px; padding: 3px 12px; font-size: 12px; font-weight: 700;
}
.split-link { border: none; background: none; color: var(--gold); font-size: 12px; font-weight: 600; padding: 0; cursor: pointer; }
.split-box { border: 1px dashed var(--line-strong); border-radius: var(--r-sm); padding: 12px 14px; margin: 4px 0 12px; }
.split-row { display: grid; grid-template-columns: 1fr 110px 28px; gap: 8px; margin-bottom: 6px; align-items: center; }
.split-row select, .split-row input { padding: 7px 10px; border: 1px solid var(--line); border-radius: 7px; background: var(--input-bg); color: var(--ink); font-size: 13px; }
.split-row .row-x { border: none; background: none; color: var(--ink-3); font-size: 14px; cursor: pointer; }
.receipt-area { margin: 4px 0 12px; }
.rc-list { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 8px; }
.rc-thumb { position: relative; }
.rc-thumb img { width: 64px; height: 64px; object-fit: cover; border-radius: 8px; border: 1px solid var(--line); }
.rc-thumb button {
  position: absolute; top: -6px; right: -6px; width: 20px; height: 20px; border-radius: 50%;
  border: 1px solid var(--line); background: var(--card); color: var(--ink-2); font-size: 11px; line-height: 1;
}
.tappable { cursor: pointer; }
.tappable:hover { background: var(--hover); }

/* ---------- v2.17 ---------- */
.carry-neg { color: var(--brick) !important; border-color: color-mix(in srgb, var(--brick) 40%, transparent) !important; }
.cover-btn {
  border: 1px solid var(--warn-line); background: var(--warn-bg); color: var(--warn-fg);
  border-radius: 6px; padding: 1px 8px; font-size: 10.5px; font-weight: 700; cursor: pointer; margin-left: 4px;
}
.mini-select {
  border: 1px solid var(--line); background: var(--input-bg); color: var(--ink);
  border-radius: 7px; padding: 4px 8px; font-size: 12px; font-family: var(--sans);
}
.tpl-tools { display: flex; gap: 8px; align-items: center; }
.tag-chip {
  display: inline-block; border: 1px solid var(--line-strong); border-radius: 20px;
  padding: 0 7px; font-size: 10px; color: var(--ink-2); vertical-align: 1px;
}
.meta-num { width: 74px; padding: 4px 6px; border: 1px solid var(--line); border-radius: 6px; background: var(--input-bg); color: var(--ink); font-size: 12px; text-align: right; }


/* ---------- skeleton loading (v2.22) ---------- */
.skel {
  position: relative; overflow: hidden;
  background: var(--raised, rgba(140,150,160,.12));
  border-radius: var(--r-sm);
}
.skel::after {
  content: ""; position: absolute; inset: 0;
  transform: translateX(-100%);
  background: linear-gradient(90deg, transparent, rgba(160,175,190,.14), transparent);
  animation: skel-shimmer 1.3s infinite;
}
@keyframes skel-shimmer { 100% { transform: translateX(100%); } }
.skel-page { display: flex; flex-direction: column; gap: 14px; }
.skel-title { height: 26px; width: 240px; max-width: 60%; }
.skel-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }
.skel-stat { height: 86px; border-radius: var(--r-md); }
.skel-card { height: 120px; border-radius: var(--r-md); }
.skel-card.tall { height: 220px; }
.skel-bar { height: 15px; }
.skel-bar.w60 { width: 60%; } .skel-bar.w80 { width: 80%; } .skel-bar.w40 { width: 40%; }
.skel-table { display: flex; flex-direction: column; gap: 11px; padding: 16px; border-radius: var(--r-md); background: var(--card, rgba(140,150,160,.05)); border: 1px solid var(--line); }
@media (prefers-reduced-motion: reduce) { .skel::after { animation: none; } }

/* ---------- mobile bottom nav + FAB + more sheet (v2.22) ---------- */
.bnav { display: none; }
.fab { display: none; }
.more-sheet { position: fixed; inset: 0; z-index: 60; }
.more-backdrop { position: absolute; inset: 0; background: rgba(0,0,0,.45); }
.more-panel {
  position: absolute; left: 0; right: 0; bottom: 0;
  background: var(--pine, #0A0E13); color: inherit;
  border-radius: 16px 16px 0 0; border-top: 1px solid var(--line);
  padding: 8px 12px calc(14px + env(safe-area-inset-bottom, 0px));
  max-height: 70vh; overflow-y: auto;
  animation: sheet-up .22s cubic-bezier(.25,.8,.3,1);
}
@keyframes sheet-up { from { transform: translateY(24px); opacity: .4; } to { transform: none; opacity: 1; } }
.more-grip { width: 38px; height: 4px; border-radius: 2px; background: #3A424B; margin: 6px auto 10px; }
.more-list { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.more-list .tab { padding: 13px 12px; min-height: 48px; font-size: 14px; }

@media (max-width: 860px) {
  .nav { display: none; }              /* section nav is desktop-only; bottom nav takes over */
  /* v4.7: finger-sized hit areas for the tiny controls */
  .mini-icon { padding: 6px 10px; font-size: 12.5px; min-height: 34px; }
  .row-x { width: 34px; height: 34px; font-size: 16px; }
  .sidebar { padding-bottom: 10px; }
  .bnav {
    display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 50;
    background: var(--pine, #0A0E13);
    border-top: 1px solid var(--line);
    padding: 4px 4px calc(4px + env(safe-area-inset-bottom, 0px));
  }
  .bnav-item {
    flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: 3px; min-height: 54px; background: transparent; border: none;
    color: #8B949E; font-size: 10.5px; font-weight: 600; border-radius: var(--r-sm);
    -webkit-tap-highlight-color: transparent;
  }
  .bnav-item svg { width: 21px; height: 21px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
  .bnav-item.active { color: var(--gold); }
  .fab {
    display: flex; align-items: center; justify-content: center;
    position: fixed; right: 16px; bottom: calc(72px + env(safe-area-inset-bottom, 0px)); z-index: 50;
    width: 54px; height: 54px; border-radius: 50%;
    background: var(--gold); color: #06251A; border: none;
    box-shadow: 0 6px 18px rgba(0,0,0,.35);
  }
  .fab svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; }
  .fab:active { transform: scale(.94); }
  .main { padding-bottom: calc(84px + env(safe-area-inset-bottom, 0px)) !important; }
  #addBtn { display: none; }           /* FAB replaces the topbar Add on phones */
  /* bigger touch targets */
  .btn-small, .link-btn { min-height: 40px; }
  .row-actions button { min-width: 38px; min-height: 38px; }
  input:not([type="checkbox"]):not([type="radio"]):not([type="range"]), select { min-height: 40px; }
}


/* ================= v2.23 UI refresh ================= */

/* selection + scrollbars */
::selection { background: rgba(var(--accent-rgb), .28); }
* { scrollbar-width: thin; scrollbar-color: var(--line-strong) transparent; }
*::-webkit-scrollbar { width: 9px; height: 9px; }
*::-webkit-scrollbar-thumb { background: var(--line-strong); border-radius: 8px; border: 2px solid transparent; background-clip: padding-box; }
*::-webkit-scrollbar-track { background: transparent; }

/* focus rings — keyboard users get a clear accent ring, mouse users stay clean */
button:focus-visible, .tab:focus-visible, a:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
  border-radius: var(--r-sm);
}
input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: none;
  border-color: var(--gold) !important;
  box-shadow: 0 0 0 3px rgba(var(--accent-rgb), .18);
}

/* controls: consistent feel + motion */
input, select, textarea {
  transition: border-color .13s ease, box-shadow .13s ease, background .13s ease;
}
input:hover:not(:focus):not([type="checkbox"]):not([type="range"]), select:hover:not(:focus), textarea:hover:not(:focus) {
  border-color: var(--line-strong);
}
button { transition: background .13s ease, color .13s ease, border-color .13s ease, transform .1s ease, box-shadow .13s ease; }
.btn-gold:active, .btn-small:active, .fab:active { transform: scale(.965); }
.btn-gold:hover { box-shadow: 0 3px 12px rgba(var(--accent-rgb), .25); }

/* type hierarchy: slightly stronger titles, calmer metadata */
h2.page-title { font-size: 24px; letter-spacing: -0.02em; }
.page-head { margin-bottom: 18px; }

/* tables: hairline refinement + header always above hovering rows */
thead th { z-index: 2; box-shadow: 0 1px 0 var(--line); border-bottom: none; }
tbody tr:hover td { background: var(--hover); }
tbody tr:hover { background: transparent; }

/* cards: whisper of depth separation on hover ONLY for rows that act like buttons */
.card { transition: border-color .15s ease; }

/* empty states (v2.23) */
.empty-state {
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  padding: 38px 20px; text-align: center;
}
.empty-state .es-icon {
  width: 44px; height: 44px; border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  background: var(--gold-soft); color: var(--gold);
  font-size: 21px; margin-bottom: 4px;
}
.empty-state .es-icon svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.empty-state .es-title { font-weight: 600; font-size: 14.5px; color: var(--ink); }
.empty-state .es-sub { font-size: 12.5px; color: var(--ink-2); max-width: 380px; line-height: 1.55; }
.empty-state .btn-small { margin-top: 10px; }

/* ================= v2.23 density: compact ================= */
[data-density="compact"] tbody td { padding: 6px 11px; font-size: 12.5px; }
[data-density="compact"] thead th { padding: 7px 11px; }
[data-density="compact"] h2.page-title { font-size: 21px; margin-bottom: 12px; }
[data-density="compact"] .page-head { margin-bottom: 12px; }
[data-density="compact"] .stat .value { font-size: clamp(15px, 1.3vw + 7px, 21px); margin-top: 4px; }
[data-density="compact"] .bud-row { padding: 4px 0; }
[data-density="compact"] .cat-block { margin-bottom: 7px; }
[data-density="compact"] .main { padding-top: 14px; }
[data-density="compact"] .tab { padding: 6px 10px; font-size: 13px; }
[data-density="compact"] .nav-sec { margin-bottom: 2px; }
[data-density="compact"] .filters { margin-bottom: 10px; }
[data-density="compact"] .bar-grid { padding: 3px 0; }
[data-density="compact"] .empty-state { padding: 24px 16px; }

/* ================= v2.24 snapshot redesign ================= */
.hero { display: flex; gap: 22px; padding: 20px 22px; margin-top: 14px; align-items: stretch; flex-wrap: wrap; }
.hero-main { flex: 1 1 260px; min-width: 240px; }
.hero-value {
  font-variant-numeric: tabular-nums;
  font-size: clamp(30px, 4vw, 44px);
  font-weight: 650; letter-spacing: -0.025em; line-height: 1.05;
  margin: 6px 0 2px;
}
.hero-sub { font-size: 12.5px; }
.hero-track { height: 9px; background: var(--line-soft); border-radius: 99px; overflow: hidden; margin: 12px 0 6px; max-width: 420px; }
.hero-fill { height: 100%; background: linear-gradient(90deg, var(--gold-deep), var(--gold)); border-radius: 99px; }
.hero-fill.over { background: linear-gradient(90deg, #C2564E, var(--brick)); }
.hero-side {
  display: grid; grid-template-columns: 1fr 1fr; gap: 6px 20px;
  align-content: center; padding-left: 22px; border-left: 1px solid var(--line-soft);
  min-width: 220px;
}
.stat-sm .value { font-size: 16.5px; font-weight: 600; margin-top: 2px; font-variant-numeric: tabular-nums; }
@media (max-width: 640px) {
  .hero { gap: 14px; padding: 16px; }
  .hero-side { border-left: none; padding-left: 0; border-top: 1px solid var(--line-soft); padding-top: 12px; width: 100%; }
}

/* v4.8: chart headline tiles (range totals above the live chart) */
.ch-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin: 4px 0 12px; }
.ch-stats:empty { display: none; }
.ch-stat { border: 1px solid var(--line); border-radius: var(--r-sm); padding: 10px 12px; background: var(--line-soft); display: flex; flex-direction: column; gap: 2px; }
.ch-stat .v { font-size: 16.5px; font-weight: 600; font-variant-numeric: tabular-nums; }
.ch-stat .k { font-size: var(--fs-xs); color: var(--ink-3); text-transform: uppercase; letter-spacing: .06em; }
@media (max-width: 640px) { .ch-stats { grid-template-columns: 1fr 1fr; } }

/* v4.17.1: maximize any table/chart card */
.maxi-btn { position: absolute; top: 6px; right: 6px; z-index: 6; border: 1px solid var(--line); background: var(--card); color: var(--ink-2); cursor: pointer; font-size: 13px; padding: 3px 8px; border-radius: 7px; opacity: .55; transition: opacity .15s, color .15s; box-shadow: 0 1px 3px rgba(0,0,0,.25); }
.card:hover > .maxi-btn, .maxi > .maxi-btn { opacity: 1; }
.maxi-btn:hover { color: var(--ink); border-color: var(--line-strong); }
.card.table-wrap > .maxi-btn { right: 44px; }   /* dodge the select-all checkbox / scrollbar lane */
.card.table-wrap, .card { position: relative; }
.card.maxi { position: fixed; inset: 10px; z-index: 450; margin: 0 !important; overflow: auto; box-shadow: var(--shadow-3); }
.card.maxi .tw-scroll, .card.maxi.tw-scroll { max-height: none !important; }
.card.maxi .chart-stage, .card.maxi .chart-stage.sm { height: calc(100vh - 130px); }
html.maxi-open { overflow: hidden; }
@media (max-width: 640px) { .maxi-btn { display: none; } }  /* phones: already full width, gesture space is precious */

/* v4.12: account drill-down two-up */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 900px) { .grid-2 { grid-template-columns: 1fr; } }

/* v4.9: sparklines, MoM chips, heatmap, cat dots, budget rings */
.spark { vertical-align: -4px; margin-left: 6px; }
.spark:empty { display: none; }
.mom { font-size: 10.5px; font-weight: 700; margin-left: 4px; letter-spacing: .02em; }
.mom .up { color: var(--brick); }      /* spending going up is the bad direction */
.mom .dn { color: var(--green); }
.mom .flat { color: var(--ink-3); }
#heroMom { font-size: 11px; vertical-align: 2px; }
.heat-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 3px; margin-top: 4px; }
.heat-wd { font-size: 9.5px; color: var(--ink-3); text-align: center; text-transform: uppercase; letter-spacing: .04em; }
.heat-day { aspect-ratio: 1; display: grid; place-items: center; font-size: 10.5px; color: var(--ink-2); border-radius: 5px; background: var(--line-soft); font-variant-numeric: tabular-nums; }
.cdot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; margin-right: 5px; vertical-align: 0; }
.mdiv td { font-size: var(--fs-xs); font-weight: 700; color: var(--ink-3); text-transform: uppercase; letter-spacing: .08em; padding: 12px 10px 4px !important; border-bottom: none !important; background: transparent !important; }
.bud-ring { vertical-align: -3px; margin-right: 7px; }

/* v4.10.1: version stamp */
.ver-foot { padding: 4px 18px 2px; }
#appVer { font-family: var(--mono); font-size: 9.5px; letter-spacing: .1em; color: var(--ink-3); opacity: .65; cursor: pointer; }
#appVer:hover { opacity: 1; }
.more-ver { text-align: center; font-family: var(--mono); font-size: 9.5px; letter-spacing: .1em; color: var(--ink-3); opacity: .65; padding: 8px 0 2px; }

/* v4.11: tips card, wide toggle, avatars, receipt peek, kbd sheet, cat icon input */
.tips-card { border-color: var(--gold-deep, var(--gold)); margin-bottom: 12px; }
.tip-line { font-size: var(--fs-sm); color: var(--ink-2); padding: 3px 0; }
.wtoggle { position: absolute; top: 6px; right: 8px; border: none; background: transparent; color: var(--ink-3); cursor: pointer; font-size: 13px; padding: 4px 6px; border-radius: 6px; opacity: 0; transition: opacity .15s; z-index: 2; }
.dash-block { position: relative; }
.dash-block:hover .wtoggle, .wtoggle:focus-visible { opacity: .8; }
.wtoggle:hover { background: var(--line-soft); color: var(--ink); }
@media (max-width: 860px) { .wtoggle { display: none; } }   /* single column on phones — nothing to toggle */
.avx { display: inline-grid; place-items: center; width: 16px; height: 16px; border-radius: 50%; color: #0D1117; font-size: 9.5px; font-weight: 700; margin-right: 6px; vertical-align: -3px; }
.rcpt-peek { cursor: pointer; }
.rcpt-pop { position: fixed; z-index: 300; background: var(--modal-bg); border: 1px solid var(--line-strong); border-radius: var(--r-sm); padding: 6px; box-shadow: var(--shadow-3); display: flex; gap: 6px; }
.rcpt-pop img { max-height: 240px; max-width: 220px; border-radius: 6px; display: block; }
.kbd-sheet { position: fixed; inset: 0; z-index: 400; background: rgba(0,0,0,.45); display: grid; place-items: center; }
.kbd-card { width: min(440px, calc(100vw - 32px)); }
.kbd-row { display: flex; gap: 12px; align-items: baseline; padding: 5px 0; font-size: var(--fs-md); color: var(--ink-2); }
.kbd-row kbd { font-family: var(--mono); font-size: 11.5px; background: var(--line-soft); border: 1px solid var(--line); border-radius: 5px; padding: 2px 7px; white-space: nowrap; }
.cat-icon-in { width: 40px; text-align: center; padding: 3px 4px; font-size: 15px; margin-right: 6px; }
.cat-icon-in::placeholder { opacity: .3; }   /* a guess, not a choice — keep it ghosted */
.emoji-pop { position: fixed; z-index: 350; width: 240px; display: grid; grid-template-columns: repeat(8, 1fr); gap: 2px; padding: 8px; background: var(--modal-bg); border: 1px solid var(--line-strong); border-radius: var(--r-sm); box-shadow: var(--shadow-3); }
.emoji-pop button { border: none; background: transparent; font-size: 17px; padding: 4px 0; border-radius: 6px; cursor: pointer; line-height: 1.2; }
.emoji-pop button:hover { background: var(--line-soft); }
.emoji-pop .emoji-none { color: var(--ink-3); font-size: 14px; }

/* quick add bar */
.qa-card { display: flex; align-items: center; gap: 10px; padding: 6px 14px; margin-bottom: 12px; flex-wrap: wrap; }
.qa-icon { width: 16px; height: 16px; fill: none; stroke: var(--gold); stroke-width: 2; stroke-linecap: round; flex: none; }
.qa-card input {
  flex: 1 1 240px; border: none !important; background: transparent !important;
  box-shadow: none !important; font-size: 13.5px; padding: 10px 0; min-height: 0 !important;
}
.qa-preview { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; flex-basis: 100%; padding-bottom: 8px; }
.qa-preview:empty { display: none; }
.qa-chip {
  font-size: 11.5px; font-weight: 600; padding: 3px 9px; border-radius: 99px;
  background: var(--gold-soft); color: var(--chip-fg); border: 1px solid var(--chip-line);
}
.qa-chip.miss { background: var(--warn-bg); color: var(--warn-fg); border-color: var(--warn-line); font-weight: 500; }
.qa-chip.go { background: transparent; color: var(--ink-2); border-style: dashed; }

/* widget blocks + drag */
.dash-block { position: relative; margin-top: 16px; }
.dash-grid .dash-block { margin-top: 0; }
.dash-grid { gap: 12px; }
.drag-handle {
  position: absolute; top: 9px; right: 10px; z-index: 3;
  color: var(--ink-3); font-size: 13px; line-height: 1;
  padding: 4px 6px; border-radius: 6px; cursor: grab;
  opacity: 0; transition: opacity .15s ease, color .15s ease;
  user-select: none; -webkit-user-drag: element;
}
.dash-block:hover .drag-handle { opacity: 1; }
.drag-handle:hover { color: var(--ink); background: var(--hover); }
.dash-block.dragging { opacity: .45; }
.dash-block.drop-hint > .card, .dash-block.drop-hint > div.card { border-color: var(--gold); }
.dash-block.drop-hint { outline: 2px dashed var(--gold); outline-offset: 3px; border-radius: var(--r-md); }
@media (pointer: coarse) { .drag-handle { opacity: .55; } }

/* customize panel order list */
.order-list { display: flex; flex-direction: column; gap: 2px; max-width: 420px; }
.order-row {
  display: flex; justify-content: space-between; align-items: center;
  font-size: 13px; padding: 4px 8px; border-radius: var(--r-sm);
}
.order-row:hover { background: var(--hover); }
.order-row .link-btn { padding: 4px 10px; font-size: 13px; min-height: 0; }
.order-row .link-btn[disabled] { opacity: .3; }

/* swipe pill (mobile) */
.swipe-pill {
  position: fixed; right: 10px; z-index: 55;
  display: flex; gap: 6px;
  background: var(--toast-bg); border: 1px solid var(--line-strong);
  border-radius: 12px; padding: 5px;
  box-shadow: var(--shadow-2);
  animation: sheet-up .16s ease;
}
.swipe-pill button {
  border: none; border-radius: 8px; padding: 10px 14px;
  font-size: 13px; font-weight: 600; background: var(--raised); color: var(--ink);
  min-height: 40px;
}
.swipe-pill [data-sp="del"] { color: var(--brick); }
tr.swipe-hl td { background: var(--hover) !important; }

/* ================= v2.25 ================= */
/* reconciliation */
tr.recon-done td { opacity: .55; }
tr.recon-done td:first-child { opacity: 1; }

/* comments */
.cmt-badge { font-size: 10.5px; color: var(--ink-2); }
.cmt-list { display: flex; flex-direction: column; gap: 8px; max-height: 220px; overflow-y: auto; }
.cmt { background: var(--raised); border: 1px solid var(--line-soft); border-radius: var(--r-sm); padding: 8px 11px; }
.cmt-meta { font-size: 11.5px; display: flex; gap: 8px; align-items: baseline; }
.cmt-meta .row-x { margin-left: auto; }
.cmt-body { font-size: 13px; margin-top: 3px; white-space: pre-wrap; }

/* cash-flow calendar */
.cf-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.cf-head { margin-bottom: 4px; }
.cf-head div { font-size: 10px; letter-spacing: .08em; color: var(--ink-3); text-align: center; font-weight: 700; }
.cf-cell {
  min-height: 58px; border: 1px solid var(--line-soft); border-radius: 7px;
  padding: 4px 5px; font-size: 11px; overflow: hidden;
  display: flex; flex-direction: column; gap: 2px;
}
.cf-cell.blank { border: none; }
.cf-cell.today { border-color: var(--gold); box-shadow: 0 0 0 1px var(--gold) inset; }
.cf-day { font-weight: 700; color: var(--ink-2); font-size: 10.5px; }
.cf-cell.today .cf-day { color: var(--gold); }
.cf-bill { font-size: 10px; font-weight: 600; border-radius: 4px; padding: 1px 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; background: var(--danger-bg); color: var(--danger-fg); }
.cf-bill.income { background: var(--ok-bg); color: var(--ok-fg); }
.cf-proj { margin-top: auto; font-size: 10px; color: var(--ink-2); }
.cf-proj.neg { color: var(--brick); font-weight: 700; }
@media (max-width: 640px) { .cf-cell { min-height: 46px; } .cf-bill { display: none; } .cf-cell.today .cf-bill { display: block; } }

/* global search */
/* the hidden attribute must always win, even against class display rules
   (this bit us: .gs-overlay { display:flex } beat [hidden] and the search overlay
   sat over the whole app from page load) */
[hidden] { display: none !important; }
.gs-overlay {
  position: fixed; inset: 0; z-index: 70;
  background: rgba(0,0,0,.5);
  display: flex; align-items: flex-start; justify-content: center;
  padding: 12vh 16px 0;
}
.gs-box {
  width: 100%; max-width: 560px;
  background: var(--modal-bg); border: 1px solid var(--line-strong);
  border-radius: var(--r-lg); box-shadow: var(--shadow-3);
  overflow: hidden; animation: sheet-up .16s ease;
}
.gs-box input {
  width: 100%; border: none !important; background: transparent !important; box-shadow: none !important;
  padding: 15px 18px; font-size: 15px;
  border-bottom: 1px solid var(--line) !important; border-radius: 0;
}
.gs-results { max-height: 46vh; overflow-y: auto; padding: 6px; }
.gs-item {
  display: flex; gap: 10px; align-items: baseline;
  padding: 9px 12px; border-radius: var(--r-sm); font-size: 13.5px; cursor: pointer;
}
.gs-item.sel { background: var(--hover); }
.gs-kind {
  flex: 0 0 44px; font-size: 10px; font-weight: 700; letter-spacing: .07em;
  text-transform: uppercase; color: var(--ink-3);
}
.gs-main { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.gs-hint { padding: 8px 14px; font-size: 11px; border-top: 1px solid var(--line-soft); }

/* ================= v2.28 ================= */
.wr-stat .value { font-size: clamp(20px, 2.4vw, 30px); }
.rpt-head { margin-bottom: 12px; }
@media print {
  .sidebar, .topbar, .bnav, .fab, .toast, .no-print, #rptCard > .label, #rptCard > .soft, #rptCard details, #rptList { display: none !important; }
  .main { padding: 0 !important; }
  .shell { display: block; }
  .rpt-page { border: none; box-shadow: none; }
  body { background: white; color: black; }
}
.tx-pick { margin-left: 6px; }

/* ================= v2.29 multi-account filter ================= */
.acct-multi { position: relative; display: inline-block; }
.acct-multi-btn {
  background: var(--input-bg); border: 1px solid var(--line);
  color: var(--ink); border-radius: var(--r-sm);
  padding: 8px 12px; font-size: 13px; min-height: 37px;
  cursor: pointer; white-space: nowrap;
}
.acct-multi-btn:hover { border-color: var(--line-strong); }
.acct-multi-btn.on { border-color: var(--gold); color: var(--gold-2); font-weight: 600; }
.acct-pop {
  position: absolute; top: calc(100% + 6px); left: 0; z-index: 30;
  min-width: 210px; max-height: 300px; overflow-y: auto;
  background: var(--modal-bg); border: 1px solid var(--line-strong);
  border-radius: var(--r-md); box-shadow: var(--shadow-2);
  padding: 6px;
}
.acct-opt {
  display: flex; gap: 9px; align-items: center;
  padding: 8px 10px; min-height: 36px; border-radius: var(--r-sm);
  font-size: 13px; cursor: pointer;
}
.acct-opt:hover { background: var(--hover); }

/* ================= v2.30 year grid ================= */
table.yg th.yg-name { position: sticky; left: 0; background: var(--card); text-align: left; font-size: 12px; min-width: 150px; z-index: 1; }
table.yg .yg-cat { cursor: pointer; }
table.yg .yg-cat:hover th, table.yg .yg-cat:hover td { background: var(--hover); }
table.yg .yg-cat th { font-weight: 700; font-size: 12.5px; }
table.yg td.yg-cell, table.yg td { font-size: 11.5px; padding: 6px 8px; white-space: nowrap; }
table.yg .yg-total th, table.yg .yg-total td { border-top: 2px solid var(--line-strong); }

/* ---- v2.31: guardrails ---- */
.rail-warn {
  font-size: 12.5px; padding: 8px 12px; border-radius: 8px; margin: 0 0 12px;
  border: 1px solid var(--line); background: var(--line-soft); color: var(--ink-2);
}
.rail-warn.hot { border-color: var(--warn-line); background: var(--warn-bg); color: var(--warn-fg); font-weight: 600; }
/* v4.6.5: overnight review is the highest-signal widget — full-width block, readable findings */
#aireviewBox .rail-warn { font-size: var(--fs-md); line-height: 1.6; padding: 12px 16px; }
.rail-chip { color: var(--warn-fg) !important; }

/* ---- v2.31: paycheck planner ---- */
.pc-card { padding: 14px 16px; margin-bottom: 12px; }
.pc-track { height: 5px; border-radius: 3px; background: var(--line-soft); margin-top: 10px; overflow: hidden; }
.pc-fill { height: 100%; border-radius: 3px; background: var(--gold); }
.pc-fill.over { background: var(--brick); }
.pc-foot { display: flex; justify-content: space-between; align-items: center; margin-top: 6px; }

/* ================= v2.32 UI polish ================= */

/* Toggle glyphs (◆ ↻ 🔒): real square hit targets that can't collide or clip.
   The old 11px text buttons sat flush against the label and each other. */
.fund-toggle {
  display: inline-grid; place-items: center;
  width: 22px; height: 22px; padding: 0;
  font-size: 11px; line-height: 1;
  border-radius: 6px; border: 1px solid transparent;
  vertical-align: middle;
}
.fund-toggle:hover { background: var(--line-soft); }
.fund-toggle.on { color: var(--gold); background: var(--gold-soft); border-color: var(--chip-line); }
@media (pointer: coarse) { .fund-toggle { width: 28px; height: 28px; font-size: 12.5px; } }

/* Budget rows: name+toggles on one line (name ellipsizes), chips wrap on their own
   line, progress track below — nothing collides no matter how many chips show. */
[data-blabel] { display: block; min-width: 0; }
.bud-name { display: flex; align-items: center; gap: 7px; min-width: 0; font-size: 13.5px; }
.bud-name-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bud-toggles { display: inline-flex; gap: 3px; flex: none; }
.bud-chips { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
.bud-chips .fund-bal { margin-left: 0; }
.bud-row .mini-track { margin-top: 6px; }
@media (max-width: 860px) {
  .bud-chips .fund-bal { font-size: 10px; padding: 1px 6px; }
  .bud-row .mini-track { max-width: 100%; }
}

/* Budget setup: labeled 4-column grid (Detail · Plan · Rail · 🔒) with the rename/delete
   icons folded into the name cell — replaces the cramped unlabeled 5-column row. */
.setup-row {
  display: grid; grid-template-columns: minmax(0, 1fr) 96px 88px 34px;
  gap: 8px; align-items: center; padding: 6px 0; border-top: 1px solid var(--line-soft);
}
.setup-row-head { border-top: none; padding: 4px 0 2px; }
.setup-row input {
  width: 100%; padding: 7px 9px;
  border: 1px solid var(--line); border-radius: var(--r-sm);
  background: var(--input-bg); color: var(--ink);
  font-family: var(--mono); font-variant-numeric: tabular-nums; text-align: right;
}
.setup-row input::placeholder { color: var(--ink-3); font-family: var(--sans); font-size: 11.5px; }
.setup-name { display: flex; align-items: center; gap: 2px; min-width: 0; font-size: 13.5px; }
.setup-name-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.setup-actions { display: inline-flex; flex: none; }
.setup-row .fund-toggle { margin: 0 auto; }
@media (max-width: 700px) {
  .setup-row { grid-template-columns: minmax(0, 1fr) 78px 70px 32px; gap: 6px; }
  .setup-row input { padding: 6px 7px; font-size: 12.5px; }
  .setup-row-head .label { font-size: 9.5px; letter-spacing: .05em; }
}

/* Small × row buttons (baby checklist, monthly costs) — were unstyled outside splits/comments */
.row-x {
  border: none; background: transparent; color: var(--ink-3);
  font-size: 14px; width: 26px; height: 26px; border-radius: 6px;
  display: inline-grid; place-items: center; padding: 0;
}
.row-x:hover { color: var(--brick); background: var(--line-soft); }

/* page-head controls share one vertical center instead of a ragged baseline */
.page-head { align-items: center; }
.page-head .mini-select { min-height: 32px; }
.page-head .link-btn { padding: 6px 12px; font-size: 12.5px; }

/* checkboxes take the accent everywhere (baby checklist, bulk select, chart toggles) */
input[type="checkbox"] { accent-color: var(--gold); width: 15px; height: 15px; }

/* money inputs: hide the number spinners — right-aligned figures read cleaner and the
   spinners collided with typed values in the narrow setup/budget cells */
.setup-row input::-webkit-outer-spin-button, .setup-row input::-webkit-inner-spin-button,
.plan-row input::-webkit-outer-spin-button, .plan-row input::-webkit-inner-spin-button,
.bud-input::-webkit-outer-spin-button, .bud-input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.setup-row input[type="number"], .plan-row input[type="number"], .bud-input { -moz-appearance: textfield; appearance: textfield; }

/* hero text (Baby: "🎉 Peanut is here!") wraps instead of colliding with side stats */
.hero-main { min-width: 0; }
.hero-value { overflow-wrap: anywhere; }
.hero-side { min-width: 0; }

/* topbar month select can shrink on small phones instead of pushing the + button off-screen */
.month-select { min-width: 0; max-width: 46vw; text-overflow: ellipsis; }

/* paycheck cards: header vertically centered, bill rows never overflow */
.pc-card .dash-head { align-items: center; }
.pc-card .dash-row > span:first-child { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* baby checklist rows reuse the plan-row grid — give the checkbox column breathing room */
.plan-row input[type="checkbox"] { width: 16px; height: 16px; justify-self: start; padding: 0; border: none; background: transparent; }

/* ---- v2.34: ask-your-budget chat ---- */
.chat-panel {
  position: fixed; right: 18px; bottom: 18px; z-index: 60;
  width: min(400px, calc(100vw - 24px)); height: min(540px, calc(100vh - 90px));
  display: flex; flex-direction: column;
  background: var(--card); border: 1px solid var(--line-strong); border-radius: var(--r);
  box-shadow: 0 18px 50px rgba(0, 0, 0, .35);
}
.chat-head { display: flex; align-items: center; gap: 8px; padding: 12px 14px; border-bottom: 1px solid var(--line); }
.chat-log { flex: 1; overflow-y: auto; padding: 14px; display: flex; flex-direction: column; gap: 10px; }
.chat-msg { max-width: 88%; padding: 9px 12px; border-radius: 12px; font-size: 13.5px; line-height: 1.45; white-space: pre-wrap; overflow-wrap: anywhere; }
.chat-msg.me { align-self: flex-end; background: var(--gold-soft); border: 1px solid var(--chip-line); border-bottom-right-radius: 4px; }
.chat-msg.bot { align-self: flex-start; background: var(--line-soft); border: 1px solid var(--line); border-bottom-left-radius: 4px; }
.chat-tools { margin-top: 6px; font-size: 10.5px; color: var(--ink-3); font-family: var(--mono); }
.chat-input { display: flex; gap: 8px; padding: 12px; border-top: 1px solid var(--line); }
/* v4.7: iOS autofill accessory bar overlaps the input — breathing room on phones only */
@media (max-width: 640px) { .chat-input { padding-bottom: 22px; } }
.chat-input input { flex: 1; padding: 9px 12px; border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--input-bg); color: var(--ink); font-size: 13.5px; }
.chat-busy .d1, .chat-busy .d2, .chat-busy .d3 { animation: chatDots 1.2s infinite; }
.chat-busy .d2 { animation-delay: .2s; } .chat-busy .d3 { animation-delay: .4s; }
@keyframes chatDots { 0%, 60%, 100% { opacity: .25; } 30% { opacity: 1; } }
@media (max-width: 640px) {
  .chat-panel { right: 0; bottom: 0; left: 0; width: 100%; height: min(78vh, 620px); border-radius: var(--r) var(--r) 0 0; border-left: none; border-right: none; border-bottom: none; }
}

/* ---- v2.36: in-app dialog (replaces window.prompt) ---- */
.dlg-overlay {
  position: fixed; inset: 0; z-index: 80;
  background: rgba(8, 12, 10, .55); backdrop-filter: blur(2px);
  display: grid; place-items: center; padding: 16px;
}
.dlg { width: min(420px, 100%); padding: 18px 20px; box-shadow: 0 24px 60px rgba(0, 0, 0, .4); }
.dlg .field input, .dlg .field select { width: 100%; }

/* ---- v2.37 ---- */
/* sidebar footer: the signed-in name gets its own full-width line instead of being
   crushed (and ellipsized to nothing) between three buttons */
.user-foot { flex-wrap: wrap; row-gap: 4px; }
.whoami { flex: 1 1 100%; overflow-wrap: anywhere; white-space: normal; line-height: 1.3; }

/* subscription 6-month history dots */
.sub-dot {
  display: inline-block; width: 9px; height: 9px; border-radius: 3px;
  background: var(--line-soft); margin-right: 3px; vertical-align: middle;
}
.sub-dot.on { background: var(--gold); }

/* ---- v2.39.1: danger button for destructive dialog confirms ---- */
.btn-danger {
  background: var(--brick); color: #fff; border: none;
  border-radius: var(--r-sm); font-weight: 600; font-size: 13px; cursor: pointer;
}
.btn-danger:hover { filter: brightness(1.1); }

/* ================= v2.40 UX pass ================= */
/* More sheet: section labels + settings footer (theme/density/sign-out had no mobile home) */
.more-sec-label {
  font-size: 10px; text-transform: uppercase; letter-spacing: .09em; color: var(--ink-3);
  padding: 12px 14px 4px; grid-column: 1 / -1;
}
.more-sec-label:first-child { padding-top: 4px; }
.more-foot {
  grid-column: 1 / -1; display: flex; gap: 8px; align-items: center;
  border-top: 1px solid var(--line); margin-top: 10px; padding: 10px 10px 2px;
}

/* stacked toasts */
.toast-stack {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(18px + env(safe-area-inset-bottom, 0px));
  display: flex; flex-direction: column; gap: 8px; align-items: center; z-index: 90;
  pointer-events: none;
}
.toast-stack .toast { position: static; transform: none; pointer-events: auto; }
@media (max-width: 860px) { .toast-stack { bottom: calc(76px + env(safe-area-inset-bottom, 0px)); } }

/* compact density: cover everything built since v2.23 */
[data-density="compact"] .card.stat { padding: 12px 14px; }
[data-density="compact"] .card.stat .value { font-size: 19px; }
[data-density="compact"] .stat-row { gap: 10px; margin-bottom: 12px; }
[data-density="compact"] .dash-card { padding: 12px 14px; }
[data-density="compact"] .dash-row { padding: 5px 0; }
[data-density="compact"] .pc-card { padding: 12px 14px; }
[data-density="compact"] .setup-row { padding: 4px 0; }
[data-density="compact"] .chat-msg { padding: 6px 10px; font-size: 12.5px; }
[data-density="compact"] .chat-log { padding: 10px; gap: 7px; }
[data-density="compact"] .dlg { padding: 14px 16px; }
[data-density="compact"] .help-item summary { padding: 9px 12px; font-size: 12.5px; }
[data-density="compact"] .pad { padding: 13px 15px; }
[data-density="compact"] .pad-sm { padding: 9px 12px; }
[data-density="compact"] { --fs-xs: 10.5px; --fs-sm: 11.5px; --fs-md: 12.5px; }

/* ---- v3.1: receipt gallery ---- */
.rcpt-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.rcpt-item { position: relative; margin: 0; border: 1px solid var(--line); border-radius: var(--r-sm); overflow: hidden; background: var(--line-soft); }
.rcpt-item img { width: 100%; height: 120px; object-fit: cover; display: block; }
.rcpt-item figcaption { padding: 7px 9px; font-size: 11.5px; }
.rcpt-item .row-x { position: absolute; top: 4px; right: 4px; background: var(--card); border-radius: 6px; }
.rcpt-missing { height: 120px; display: grid; place-items: center; color: var(--ink-3); font-size: 11px; }
.rcpt-item.missing { opacity: .6; }
[data-density="compact"] .rcpt-grid { grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 8px; }

/* ---- v3.4 ---- */
.hero-ai { cursor: pointer; }
.hero-ai .value.warn { color: var(--warn-fg); }
/* v4.7: the AI tile is clickable — make it look like it */
.hero-ai { cursor: pointer; border-radius: var(--r-sm); padding: 4px 8px; margin: -4px -8px; transition: background .12s; }
.hero-ai:hover, .hero-ai:focus-visible { background: var(--line-soft); outline: none; }


/* ---------- v3.6: accent variants (default = mint; sidebar active text via --accent-hi) ---------- */
[data-accent="sky"] {
  --gold: #58A6FF; --gold-2: #79B8FF; --gold-deep: #1F6FEB; --gold-soft: #0D1D33;
  --chip-bg: #0D1D33; --chip-fg: #A5CFFF; --chip-line: #1B3A63;
  --accent-rgb: 88, 166, 255; --accent-contrast: #03101F; --accent-hi: #B9D8FF;
}
[data-theme="light"][data-accent="sky"] {
  --gold: #0969DA; --gold-2: #218BFF; --gold-deep: #0550AE; --gold-soft: #E1EEFB;
  --chip-bg: #E1EEFB; --chip-fg: #0550AE; --chip-line: #BBD8F5;
  --accent-rgb: 9, 105, 218; --accent-contrast: #FFFFFF;
}
[data-accent="amber"] {
  --gold: #E8B44F; --gold-2: #F2C86E; --gold-deep: #B87E1F; --gold-soft: #2A2110;
  --chip-bg: #2A2110; --chip-fg: #F0D394; --chip-line: #57431A;
  --accent-rgb: 232, 180, 79; --accent-contrast: #1F1503; --accent-hi: #F3D9A0;
}
[data-theme="light"][data-accent="amber"] {
  --gold: #B57F14; --gold-2: #D19A25; --gold-deep: #8A6110; --gold-soft: #F8EFD9;
  --chip-bg: #F8EFD9; --chip-fg: #7A5A12; --chip-line: #EBD9A8;
  --accent-rgb: 181, 127, 20; --accent-contrast: #FFFFFF;
}
[data-accent="rose"] {
  --gold: #F778BA; --gold-2: #FF9CCE; --gold-deep: #BF4B8A; --gold-soft: #2B1622;
  --chip-bg: #2B1622; --chip-fg: #FBB1D8; --chip-line: #5C2B45;
  --accent-rgb: 247, 120, 186; --accent-contrast: #230A18; --accent-hi: #FFC2E0;
}
[data-theme="light"][data-accent="rose"] {
  --gold: #BF4B8A; --gold-2: #D65D9E; --gold-deep: #99306D; --gold-soft: #FBE7F1;
  --chip-bg: #FBE7F1; --chip-fg: #99306D; --chip-line: #F2C4DC;
  --accent-rgb: 191, 75, 138; --accent-contrast: #FFFFFF;
}

/* v3.6: bars grow in on render */
.bar-fill, .hero-fill, .mini-fill { transform-origin: left; animation: fill-in .5s ease backwards; }
@keyframes fill-in { from { transform: scaleX(0); } }


/* ---------- v4.4.1: print — Year grid and reports on paper, no chrome ---------- */
@media print {
  .sidebar, .topbar, .bnav, .more-sheet, .toast-stack, #fab, #chatBtn, #chatPanel,
  .filters select, .filters .btn-small, .btn, .btn-small, .btn-gold, .link-btn, .mini-icon,
  .row-x, .api-try, .drag-handle, .inline-add { display: none !important; }
  html, body, .main, .card { background: #fff !important; color: #000 !important; }
  .main { max-width: none; padding: 0; margin: 0; }
  .card { border: 1px solid #bbb !important; box-shadow: none !important; break-inside: avoid; }
  .tw-scroll { max-height: none !important; overflow: visible !important; }
  .tw-pin th, .tw-pin td { position: static !important; }
  table { font-size: 10px; }
  th, td { color: #000 !important; }
  .soft, .empty-note, .label, .dash { color: #444 !important; }
  .pos { color: #0a6b3d !important; } .neg { color: #a1242c !important; }
  .bar-fill, .hero-fill, .mini-fill { animation: none !important; }
  a { text-decoration: none; color: #000; }
  /* v4.7: broader print coverage — snapshot & transactions come out clean */
  .qa-card, .acct-multi, .tb-tool, .tb-sep, .hero-ai, .more-panel { display: none !important; }
  .dash-grid { display: block !important; }
  .dash-block { margin: 0 0 10px !important; break-inside: avoid; }
  .bar-track, .hero-track, .mini-track { background: #eee !important; border: 1px solid #ccc; }
  .bar-fill, .hero-fill, .mini-fill { background: #888 !important; }
  .rail-warn, .rail-warn.hot { background: #f5f5f5 !important; border: 1px solid #bbb !important; color: #000 !important; }
}

/* v4.6.2: Firefox paints option lists from these directly; Chromium uses color-scheme above */
select option, select optgroup { background: var(--card); color: var(--ink); }
select optgroup { font-weight: 600; color: var(--ink-2); }
