/* Ledgerleaf demo - styles. Dark is the default theme; light lives under [data-theme="light"].
   Breakpoints: phone < 640, tablet 640-1023 (icon rail), desktop >= 1024 (full sidebar). */

/* ---------- tokens ---------- */
:root {
  color-scheme: dark;
  --bg: #0a0f0d;
  --bg-elev: #0d1311;
  --surface: #111816;
  --surface-2: #17201d;
  --surface-3: #1f2a26;
  --raised: #151d1a;
  --border: #222d29;
  --border-strong: #31403a;
  --text: #ecf2ef;
  --text-2: #b3c0ba;
  --muted: #8a9892;
  --accent: #3ee0b0;
  --accent-hover: #6aebc5;
  --on-accent: #03241b;
  --accent-soft: rgba(62, 224, 176, 0.13);
  --accent-line: rgba(62, 224, 176, 0.35);
  --accent-text: #5fe8bf;
  --track: rgba(62, 224, 176, 0.16);
  --focus: #7cf0cd;
  --grid: #1f2a26;
  --axis: #3a4943;
  --c1: #3987e5; --c2: #d95926; --c3: #199e70; --c4: #c98500;
  --c5: #d55181; --c6: #008300; --c7: #9085e9; --c8: #e66767;
  --other: #5f6e68;
  --good: #0ca30c; --warn: #fab219; --serious: #ec835a; --crit: #d03b3b;
  --good-text: #2fbf45; --warn-text: #fab219; --crit-text: #f07a7a;
  --good-ico: #0ca30c; --warn-ico: #fab219; --crit-ico: #e05252;
  --good-soft: rgba(12, 163, 12, 0.16); --warn-soft: rgba(250, 178, 25, 0.14); --crit-soft: rgba(208, 59, 59, 0.2);
  --warn-track: rgba(250, 178, 25, 0.18); --crit-track: rgba(208, 59, 59, 0.24);
  --scrim: rgba(2, 5, 4, 0.66);
  --toast-bg: #e6efeb; --toast-text: #0b1210; --toast-accent: #0a6f70;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.35);
  --shadow-lg: 0 24px 64px rgba(0, 0, 0, 0.55), 0 2px 8px rgba(0, 0, 0, 0.4);
  --hero-glow: radial-gradient(120% 140% at 100% 0%, rgba(62, 224, 176, 0.16) 0%, rgba(62, 224, 176, 0) 55%);
  --radius: 16px;
  --topbar-h: 64px;
  --font: 'Manrope', system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
}
:root[data-theme="light"] {
  color-scheme: light;
  --bg: #f3f6f4;
  --bg-elev: #fbfcfb;
  --surface: #ffffff;
  --surface-2: #f2f5f3;
  --surface-3: #e7ece9;
  --raised: #ffffff;
  --border: #e1e7e4;
  --border-strong: #cbd5d0;
  --text: #0c1512;
  --text-2: #44514b;
  --muted: #637069;
  --accent: #0c7f80;
  --accent-hover: #0a6c6d;
  --on-accent: #ffffff;
  --accent-soft: rgba(12, 127, 128, 0.1);
  --accent-line: rgba(12, 127, 128, 0.3);
  --accent-text: #0a6c6d;
  --track: rgba(12, 127, 128, 0.14);
  --focus: #0c7f80;
  --grid: #e8edea;
  --axis: #c3cdc8;
  --c1: #2a78d6; --c2: #eb6834; --c3: #1baf7a; --c4: #eda100;
  --c5: #e87ba4; --c6: #008300; --c7: #6250d6; --c8: #e34948;
  --other: #a4afaa;
  --good-text: #006300; --warn-text: #7f5200; --crit-text: #b02a2a;
  --good-ico: #0a8f0a; --warn-ico: #b47c00; --crit-ico: #d03b3b;
  --good-soft: rgba(12, 163, 12, 0.11); --warn-soft: rgba(250, 178, 25, 0.2); --crit-soft: rgba(208, 59, 59, 0.11);
  --warn-track: rgba(250, 178, 25, 0.24); --crit-track: rgba(208, 59, 59, 0.16);
  --scrim: rgba(12, 21, 18, 0.42);
  --toast-bg: #13201b; --toast-text: #eef5f1; --toast-accent: #3ee0b0;
  --shadow: 0 1px 2px rgba(16, 24, 20, 0.05), 0 4px 14px rgba(16, 24, 20, 0.05);
  --shadow-lg: 0 24px 64px rgba(16, 24, 20, 0.18), 0 2px 8px rgba(16, 24, 20, 0.08);
  --hero-glow: radial-gradient(120% 140% at 100% 0%, rgba(12, 127, 128, 0.1) 0%, rgba(12, 127, 128, 0) 55%);
}

/* ---------- base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
html.is-locked, html.is-locked body { overflow: hidden; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font-family: var(--font); font-size: 15px; line-height: 1.5;
  -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale;
  min-height: 100vh;
}
h1, h2, h3, p, ul, ol, figure { margin: 0; }
ul, ol { padding: 0; list-style: none; }
a { color: var(--accent-text); }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
img, svg { max-width: 100%; }
.i { flex: none; display: block; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.sr-only { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.muted { color: var(--muted); }
.skip-link { position: absolute; left: 12px; top: -60px; z-index: 300; background: var(--accent); color: var(--on-accent); padding: 10px 14px; border-radius: 10px; font-weight: 700; text-decoration: none; }
.skip-link:focus { top: 12px; }
#main { outline: none; }

/* ---------- shell: sidebar ---------- */
.sidebar {
  position: fixed; top: 0; bottom: 0; left: 0; z-index: 30; width: 248px;
  display: flex; flex-direction: column; padding: 16px 12px 16px;
  background: var(--bg-elev); border-right: 1px solid var(--border); overflow-y: auto;
}
.sb-head { display: flex; align-items: center; justify-content: space-between; padding: 4px 8px 18px; }
.brand { display: inline-flex; align-items: center; gap: 10px; text-decoration: none; color: var(--text); font-weight: 800; font-size: 19px; letter-spacing: -0.02em; min-width: 0; }
.brand-mark { flex: none; display: block; }
.bm-bg { fill: var(--accent); }
.bm-leaf, .bm-vein { fill: none; stroke: var(--on-accent); stroke-linecap: round; stroke-linejoin: round; }
.bm-leaf { stroke-width: 2.4; }
.bm-vein { stroke-width: 2; }
.sidebar .sb-close { display: none; }
.nav-section { font-size: 11.5px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); padding: 14px 12px 6px; }
.sb-nav ul { display: grid; gap: 2px; }
.nav-link {
  position: relative; display: flex; align-items: center; gap: 12px; width: 100%; min-height: 42px; padding: 0 12px;
  border-radius: 10px; color: var(--text-2); text-decoration: none; font-weight: 600; font-size: 14.5px;
  background: none; border: 0; text-align: left;
}
.nav-link:hover { background: var(--surface-2); color: var(--text); }
.nav-link[aria-current="page"] { background: var(--accent-soft); color: var(--accent-text); }
.nav-link[aria-current="page"]::before { content: ''; position: absolute; left: -12px; top: 10px; bottom: 10px; width: 3px; border-radius: 0 3px 3px 0; background: var(--accent); }
.nav-ico { display: inline-grid; place-items: center; flex: none; }
.sb-foot { margin-top: auto; padding-top: 14px; border-top: 1px solid var(--border); display: grid; gap: 2px; }
.sb-user { display: flex; align-items: center; gap: 10px; padding: 8px 12px 10px; min-width: 0; }
.sb-user-text { display: grid; min-width: 0; }
.sb-user-name { font-weight: 700; font-size: 14px; }
.sb-user-role { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sb-back { display: flex; align-items: center; gap: 12px; min-height: 42px; padding: 0 12px; border-radius: 10px; color: var(--text-2); text-decoration: none; font-weight: 600; font-size: 14.5px; position: relative; }
.sb-back:hover { background: var(--surface-2); color: var(--text); }
.sb-credit { font-size: 12px; color: var(--muted); padding: 6px 12px 0; }
.avatar {
  display: inline-grid; place-items: center; flex: none; width: 34px; height: 34px; border-radius: 50%;
  background: var(--accent-soft); color: var(--accent-text); font-weight: 800; font-size: 13px; letter-spacing: 0.02em;
}
.avatar-lg { width: 42px; height: 42px; font-size: 15px; }
.scrim { position: fixed; inset: 0; z-index: 55; background: var(--scrim); opacity: 0; transition: opacity 0.2s ease; }
.scrim.is-open { opacity: 1; }

/* ---------- shell: main column & top bar ---------- */
.main-col { margin-left: 248px; min-width: 0; min-height: 100vh; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 20; height: var(--topbar-h);
  display: flex; align-items: center; gap: 12px; padding: 0 32px;
  background: color-mix(in srgb, var(--bg) 88%, transparent); border-bottom: 1px solid var(--border);
  -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
}
.topbar .nav-toggle, .topbar .brand-top { display: none; }
.topbar-title { font-weight: 700; font-size: 16px; white-space: nowrap; }
.demo-pill {
  display: inline-flex; align-items: center; height: 24px; padding: 0 10px; border-radius: 999px; white-space: nowrap;
  font-size: 12px; font-weight: 700; color: var(--accent-text); background: var(--accent-soft); border: 1px solid var(--accent-line);
}
.topbar-spacer { flex: 1; }
.avatar-btn { background: none; border: 0; padding: 3px; border-radius: 50%; display: inline-grid; }
.avatar-btn:hover .avatar { background: var(--accent-line); }
main { flex: 1; }
.page { max-width: 1320px; margin: 0 auto; padding: 28px 32px 40px; }
.app-foot { max-width: 1320px; width: 100%; margin: 0 auto; padding: 0 32px 28px; display: flex; flex-wrap: wrap; justify-content: space-between; gap: 6px 16px; font-size: 12.5px; color: var(--muted); }
/* Hidden until the app has drawn the page, so it doesn't flash at the bottom and then jump away. */
main:empty + .app-foot { visibility: hidden; }
.app-foot a { color: var(--text-2); text-decoration: none; font-weight: 600; }
.app-foot a:hover { color: var(--accent-text); }
.tabbar, .fab { display: none; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 40px; padding: 0 16px;
  border-radius: 10px; border: 1px solid var(--border-strong); background: var(--surface); color: var(--text);
  font-weight: 650; font-size: 14px; text-decoration: none; white-space: nowrap; transition: background 0.15s, border-color 0.15s;
}
.btn:hover { background: var(--surface-2); }
.btn-primary { background: var(--accent); border-color: transparent; color: var(--on-accent); }
.btn-primary:hover { background: var(--accent-hover); }
.btn-danger { background: var(--crit); border-color: transparent; color: #fff; }
.btn-danger:hover { background: #b83232; }
.btn-ghost { background: transparent; border-color: transparent; color: var(--text-2); }
.btn-ghost:hover { background: var(--surface-2); color: var(--text); }
.btn-ghost-danger { background: transparent; border-color: transparent; color: var(--crit-text); }
.btn-ghost-danger:hover { background: var(--crit-soft); }
.btn-sm { min-height: 34px; padding: 0 12px; font-size: 13px; border-radius: 9px; }
.btn-block { width: 100%; }
.icon-btn {
  display: inline-grid; place-items: center; flex: none; width: 40px; height: 40px; border-radius: 10px;
  background: transparent; border: 0; color: var(--text-2); text-decoration: none;
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.icon-btn.is-disabled { opacity: 0.35; pointer-events: none; }
.chip-btn {
  display: inline-flex; align-items: center; gap: 6px; min-height: 34px; padding: 0 11px; border-radius: 9px; flex: none;
  border: 1px solid var(--border); background: transparent; color: var(--text-2); font-weight: 650; font-size: 13px;
  text-decoration: none; white-space: nowrap;
}
.chip-btn:hover { background: var(--surface-2); color: var(--text); }
.chip-btn[aria-pressed="true"] { background: var(--accent-soft); color: var(--accent-text); border-color: var(--accent-line); }

/* ---------- page head, cards, tiles, grid ---------- */
.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 14px 20px; margin-bottom: 22px; }
.page-titles { min-width: 0; flex: 1 1 320px; }
.eyebrow { font-size: 13px; font-weight: 650; color: var(--muted); margin-bottom: 4px; }
.page-title { font-size: 28px; line-height: 1.2; font-weight: 800; letter-spacing: -0.025em; }
.page-sub { font-size: 14px; color: var(--text-2); margin-top: 6px; max-width: 62ch; }
.page-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; min-width: 0; box-shadow: var(--shadow); }
.card-flush { padding: 0; overflow: clip; }
.card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.card-head.pad { padding: 18px 18px 8px; margin: 0; }
.card-titles { min-width: 0; }
.card-title { font-size: 15.5px; font-weight: 750; letter-spacing: -0.01em; }
.card-sub { font-size: 13px; color: var(--muted); margin-top: 2px; }
.card-actions { display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: 8px; }
.card-link { display: inline-flex; align-items: center; gap: 4px; margin-top: 14px; min-height: 32px; font-weight: 650; font-size: 13.5px; color: var(--accent-text); text-decoration: none; }
.card-link:hover { text-decoration: underline; }
.grid-12 { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 16px; align-items: stretch; }
.span-4 { grid-column: span 4; } .span-5 { grid-column: span 5; } .span-6 { grid-column: span 6; }
.span-7 { grid-column: span 7; } .span-8 { grid-column: span 8; } .span-12 { grid-column: 1 / -1; }
.stack { display: grid; gap: 16px; min-width: 0; }
.tiles { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); margin-bottom: 16px; }
.tiles-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.tile { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px; min-width: 0; box-shadow: var(--shadow); }
.tile-label { display: flex; align-items: center; gap: 7px; font-size: 13px; font-weight: 650; color: var(--text-2); }
.tile-label .i { color: var(--muted); }
.tile-value { font-size: 25px; font-weight: 800; letter-spacing: -0.02em; margin: 6px 0 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tile-sub { font-size: 13px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; }
.tile-alert { border-color: rgba(208, 59, 59, 0.45); }
.tile-alert .tile-label .i { color: var(--crit-ico); }
.back-link { display: inline-flex; align-items: center; gap: 6px; min-height: 40px; margin: -8px 0 6px; color: var(--text-2); text-decoration: none; font-weight: 650; font-size: 14px; }
.back-link:hover { color: var(--accent-text); }

/* ---------- badges, meters, deltas ---------- */
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 3px 9px 3px 7px; border-radius: 999px; font-size: 12.5px; font-weight: 700; white-space: nowrap; line-height: 1.3; }
.st-good { background: var(--good-soft); color: var(--good-text); } .st-good .i { color: var(--good-ico); }
.st-warn { background: var(--warn-soft); color: var(--warn-text); } .st-warn .i { color: var(--warn-ico); }
.st-crit { background: var(--crit-soft); color: var(--crit-text); } .st-crit .i { color: var(--crit-ico); }
.st-ok { background: var(--accent-soft); color: var(--accent-text); }
.st-neutral { background: var(--surface-3); color: var(--text-2); }
.ico-ok { color: var(--accent-text); } .ico-warn { color: var(--warn-ico); } .ico-crit { color: var(--crit-ico); }
.meter { position: relative; height: 8px; border-radius: 999px; background: var(--track); overflow: hidden; }
.meter-fill { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 999px; background: var(--accent); }
.meter-warn { background: var(--warn-track); } .meter-warn .meter-fill { background: var(--warn); }
.meter-over { background: var(--crit-track); } .meter-over .meter-fill { background: var(--crit); }
.delta { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px; font-weight: 700; font-size: 14px; white-space: nowrap; }
.delta-up { background: var(--good-soft); color: var(--good-text); }
.delta-down { background: var(--crit-soft); color: var(--crit-text); }
.amt-pos { color: var(--good-text); }
.amt-xfer { color: var(--text-2); }
.pct-plain { font-size: 13px; font-weight: 650; color: var(--text-2); }
.tag { display: inline-block; padding: 0 6px; border-radius: 6px; background: var(--surface-3); color: var(--text-2); font-size: 12px; font-weight: 600; line-height: 20px; white-space: nowrap; }
.today-chip { display: inline-block; margin-left: 6px; padding: 0 6px; border-radius: 6px; background: var(--accent-soft); color: var(--accent-text); font-size: 11px; font-weight: 800; line-height: 18px; vertical-align: 1px; }
.date-block { display: flex; flex-direction: column; align-items: center; justify-content: center; width: 44px; height: 46px; border-radius: 10px; background: var(--surface-2); flex: none; }
.db-d { font-size: 16px; font-weight: 800; line-height: 1.1; }
.db-m { font-size: 11px; font-weight: 750; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); }
.date-block.is-crit { background: var(--crit-soft); }
.date-block.is-crit .db-m { color: var(--crit-text); }
.cat-ico { display: inline-grid; place-items: center; flex: none; width: 36px; height: 36px; border-radius: 10px; background: var(--surface-3); color: var(--text-2); }
.empty { text-align: center; padding: 28px 16px; color: var(--text-2); }
.empty-ico { margin: 0 auto; color: var(--muted); }
.empty-title { font-weight: 750; font-size: 15px; margin-top: 10px; color: var(--text); }
.empty-text { font-size: 13.5px; color: var(--muted); margin: 4px auto 14px; max-width: 38ch; }

/* ---------- segmented, month switch ---------- */
.segmented { display: inline-flex; padding: 3px; gap: 2px; border-radius: 11px; background: var(--surface-2); border: 1px solid var(--border); max-width: 100%; }
.seg-btn { display: inline-flex; align-items: center; justify-content: center; min-height: 34px; padding: 0 12px; border-radius: 8px; border: 0; background: none; color: var(--text-2); font-weight: 650; font-size: 13px; white-space: nowrap; text-decoration: none; }
.seg-btn:hover { color: var(--text); }
.seg-btn[aria-pressed="true"], .seg-btn[aria-current="true"] { background: var(--surface); color: var(--text); box-shadow: 0 1px 2px rgba(0, 0, 0, 0.25), 0 0 0 1px var(--border); }
.month-switch { display: inline-flex; align-items: center; gap: 2px; padding: 2px; border-radius: 12px; background: var(--surface); border: 1px solid var(--border); }
.month-label { min-width: 132px; text-align: center; font-weight: 700; font-size: 14.5px; white-space: nowrap; }

/* ---------- charts ---------- */
.chart-card { display: flex; flex-direction: column; }
.chart { position: relative; width: 100%; min-width: 0; }
.chart-svg { display: block; overflow: visible; touch-action: pan-y; }
.chart-svg .grid { stroke: var(--grid); stroke-width: 1; }
.chart-svg .axis { stroke: var(--axis); stroke-width: 1; }
.chart-svg .tick { fill: var(--muted); font-size: 11.5px; font-family: var(--font); font-variant-numeric: tabular-nums; }
.chart-svg .hit { fill: transparent; }
.chart-svg .bar { transition: opacity 0.15s, filter 0.15s; }
.chart-svg:hover .mark-group:not(:hover) .bar { opacity: 0.55; }
.chart-svg .mark-group.is-hot .bar, .chart-svg .mark-group:focus .bar { filter: brightness(1.15); opacity: 1; }
.chart-svg .mark-group { outline: none; }
.chart-svg .mark-group:focus-visible .hit { stroke: var(--focus); stroke-width: 2; }
.chart-svg .area { fill-opacity: 0.1; stroke: none; }
.chart-svg .line { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart-svg .dot { stroke: var(--surface); stroke-width: 2; }
.chart-svg .cross-line { stroke: var(--axis); stroke-width: 1; }
.chart-svg .end-label { fill: var(--text); font-size: 12.5px; font-weight: 750; font-family: var(--font); }
.chart-svg:focus { outline: none; }
.chart-svg:focus-visible { outline: 2px solid var(--focus); outline-offset: 4px; border-radius: 6px; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 18px; margin: 0 0 12px; font-size: 13px; color: var(--text-2); }
.legend li { display: inline-flex; align-items: center; gap: 7px; }
.lg-key { display: inline-block; flex: none; }
.lg-box { width: 10px; height: 10px; border-radius: 3px; }
.lg-line { width: 14px; height: 2px; border-radius: 1px; }
.chart-tip {
  position: fixed; left: 0; top: 0; z-index: 200; pointer-events: none; min-width: 168px; max-width: 280px;
  padding: 10px 12px; border-radius: 10px; background: var(--raised); border: 1px solid var(--border-strong);
  box-shadow: var(--shadow-lg); font-size: 13px; line-height: 1.35;
}
.tip-title { font-weight: 700; color: var(--text-2); margin-bottom: 6px; font-size: 12.5px; }
.tip-row { display: flex; align-items: center; gap: 8px; margin-top: 3px; white-space: nowrap; }
.tip-row strong { font-weight: 800; color: var(--text); font-variant-numeric: tabular-nums; }
.tip-label { color: var(--text-2); overflow: hidden; text-overflow: ellipsis; }
.tip-key { width: 12px; height: 2px; border-radius: 1px; flex: none; }
.tip-key-box { width: 9px; height: 9px; border-radius: 2px; }
.tip-key-none { background: transparent; }
.tip-total { margin-top: 7px; padding-top: 7px; border-top: 1px solid var(--border); }
.tip-note { margin-top: 6px; font-size: 12px; color: var(--muted); white-space: normal; }
.spark { position: relative; width: 100%; }
.hbars { display: grid; gap: 6px; }
.hbar-row { display: grid; grid-template-columns: minmax(0, clamp(112px, 34%, 200px)) minmax(0, 1fr); gap: 12px; align-items: center; padding: 5px 6px; margin: 0 -6px; border-radius: 8px; outline: none; }
.hbar-row:hover, .hbar-row.is-hot { background: var(--surface-2); }
.hbar-row:focus-visible { outline: 2px solid var(--focus); outline-offset: 0; }
.hbar-label { display: flex; align-items: center; gap: 8px; min-width: 0; font-size: 13.5px; font-weight: 650; }
.hbar-label span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hbar-ico { color: var(--muted); }
.hbar-track { display: flex; align-items: center; gap: 8px; min-width: 0; }
.hbar-fill { flex: none; height: 12px; min-width: 2px; border-radius: 0 4px 4px 0; background: var(--accent); }
.hbar-row.is-muted .hbar-fill { background: var(--other); }
.hbar-value { font-size: 13px; font-weight: 650; color: var(--text-2); white-space: nowrap; font-variant-numeric: tabular-nums; }
.chart-table { margin-top: 2px; }
.table-wrap { overflow-x: auto; max-width: 100%; -webkit-overflow-scrolling: touch; }
.data-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.data-table th, .data-table td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--border); white-space: nowrap; }
.data-table thead th { font-size: 12px; font-weight: 750; color: var(--muted); }
.data-table tbody th { font-weight: 650; }
.data-table .num { text-align: right; font-variant-numeric: tabular-nums; }
.data-table tbody tr:last-child th, .data-table tbody tr:last-child td { border-bottom: 0; }
.sticky-first th:first-child, .sticky-first td:first-child { position: sticky; left: 0; background: var(--surface); z-index: 1; box-shadow: 1px 0 0 var(--border); }

/* ---------- transaction rows (adapt to their container width) ---------- */
.txn-list { container-type: inline-size; }
.day-group + .day-group { border-top: 1px solid var(--border); }
.day-head {
  position: sticky; top: var(--topbar-h); z-index: 2; display: flex; justify-content: space-between; align-items: center; gap: 12px;
  padding: 12px 18px 6px; background: var(--surface); font-size: 13px; font-weight: 750; color: var(--text-2);
}
.day-total { font-variant-numeric: tabular-nums; font-weight: 700; color: var(--text-2); white-space: nowrap; }
.day-total.amt-pos { color: var(--good-text); }
.txn-row {
  display: grid; grid-template-columns: 38px minmax(0, 1fr) auto; gap: 12px; align-items: center; width: 100%;
  min-height: 58px; padding: 9px 18px; background: none; border: 0; text-align: left; color: inherit;
}
.txn-row:hover { background: var(--surface-2); }
.txn-row:focus-visible { outline-offset: -2px; }
.txn-ico { display: grid; place-items: center; width: 38px; height: 38px; border-radius: 11px; background: var(--surface-3); color: var(--text-2); }
.txn-ico.is-inc { background: var(--accent-soft); color: var(--accent-text); }
.txn-main { display: grid; min-width: 0; }
.txn-payee { font-weight: 650; font-size: 14.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.txn-meta { font-size: 12.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.txn-extra { display: flex; gap: 6px; align-items: center; min-width: 0; overflow: hidden; white-space: nowrap; margin-top: 3px; font-size: 12.5px; }
.txn-note { color: var(--text-2); overflow: hidden; text-overflow: ellipsis; min-width: 0; flex: 0 1 auto; }
.txn-date { display: none; font-size: 12.5px; color: var(--muted); }
.txn-col { display: none; min-width: 0; font-size: 13.5px; color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.txn-notes { gap: 6px; align-items: center; }
.txn-amt { font-weight: 700; font-size: 15px; white-space: nowrap; text-align: right; font-variant-numeric: tabular-nums; }
@container (min-width: 820px) {
  .txn-row { grid-template-columns: 38px minmax(0, 1.6fr) minmax(0, 0.9fr) minmax(0, 1.25fr) minmax(0, 1.4fr) minmax(104px, auto); gap: 16px; min-height: 54px; }
  .txn-col { display: block; }
  .txn-notes { display: flex; }
  .txn-meta, .txn-extra { display: none; }
  .txn-date { display: block; }
}

/* ---------- overview ---------- */
.ov-top { display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 7fr); gap: 16px; margin-bottom: 16px; }
.ov-top .tiles { margin: 0; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.hero-card { background-image: var(--hero-glow); padding: 22px 24px; display: flex; flex-direction: column; }
.hero-label { font-size: 14px; font-weight: 650; color: var(--text-2); }
.hero-value { font-size: clamp(44px, 4.6vw, 58px); line-height: 1.06; font-weight: 800; letter-spacing: -0.035em; margin: 10px 0 10px; white-space: nowrap; }
.hero-delta { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; font-size: 13.5px; }
.hero-split { display: grid; grid-template-columns: auto auto minmax(0, 1fr); gap: 16px 26px; margin-top: auto; padding-top: 18px; border-top: 1px solid var(--border); align-items: end; }
.hero-card .hero-split { margin-top: 20px; }
.hero-split .k { display: block; font-size: 12px; font-weight: 650; color: var(--muted); }
.hero-split .v { display: block; font-size: 16px; font-weight: 750; white-space: nowrap; }
.hero-trend { min-width: 0; }
.acc-strip { margin-bottom: 16px; }
.acc-strip-list { display: grid; gap: 12px; grid-template-columns: repeat(3, minmax(0, 1fr)); }
.acc-chip {
  display: grid; grid-template-columns: 36px minmax(0, 1fr); gap: 2px 10px; align-items: center; height: 100%;
  padding: 12px 14px; border-radius: 14px; background: var(--surface); border: 1px solid var(--border); color: var(--text); text-decoration: none; box-shadow: var(--shadow);
}
.acc-chip:hover { border-color: var(--accent-line); }
.acc-chip-ico { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 10px; background: var(--surface-3); color: var(--text-2); }
.acc-chip-text { display: grid; min-width: 0; }
.acc-chip-name { font-weight: 700; font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.acc-chip-meta { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.acc-chip-bal { grid-column: 1 / -1; margin-top: 8px; font-size: 18px; font-weight: 800; letter-spacing: -0.01em; white-space: nowrap; }
.acc-chip-bal.is-owed { color: var(--text-2); }
.bud-mini { display: grid; gap: 4px; }
.bud-mini-row { display: grid; gap: 7px; padding: 9px 10px; margin: 0 -10px; border-radius: 10px; color: inherit; text-decoration: none; }
.bud-mini-row:hover { background: var(--surface-2); }
.bud-mini-top { display: flex; justify-content: space-between; align-items: center; gap: 10px; font-size: 14px; }
.bud-mini-name { display: inline-flex; align-items: center; gap: 8px; font-weight: 650; min-width: 0; }
.bud-mini-name .i { color: var(--muted); }
.bud-mini-amt { font-weight: 700; white-space: nowrap; }
.bud-mini-foot { display: flex; justify-content: space-between; align-items: center; gap: 8px; font-size: 12.5px; min-height: 24px; }
.bill-mini { display: grid; gap: 2px; }
.bill-mini-row { display: grid; grid-template-columns: 44px minmax(0, 1fr) auto; gap: 12px; align-items: center; padding: 8px 10px; margin: 0 -10px; border-radius: 10px; color: inherit; text-decoration: none; }
.bill-mini-row:hover { background: var(--surface-2); }
.bill-mini-main { display: grid; min-width: 0; }
.bill-mini-name { font-weight: 650; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bill-mini-meta { font-size: 12.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bill-mini-end { display: grid; justify-items: end; gap: 4px; }
.bill-mini-amt { font-weight: 750; font-size: 14px; white-space: nowrap; }

/* ---------- transactions page ---------- */
.toolbar { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 12px; padding: 14px; margin-bottom: 14px; }
.tb-search { position: relative; flex: 1 1 260px; min-width: 0; }
.toolbar .tb-search input { padding-left: 40px; }
.search-ico { position: absolute; left: 13px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.tb-filters { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 10px; min-width: 0; }
.tb-item { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.tb-label { font-size: 12px; font-weight: 700; color: var(--muted); }
.tb-item select { min-width: 150px; }
.toolbar .tb-item select { font-size: 14px; font-weight: 650; }
.select-btn {
  display: inline-flex; align-items: center; gap: 8px; height: 42px; min-width: 176px; padding: 0 12px; border-radius: 10px;
  border: 1px solid var(--border-strong); background: var(--surface-2); color: var(--text); font-weight: 650; font-size: 14px; text-align: left;
}
.select-btn .sb-text { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.select-btn .i { color: var(--muted); }
.select-btn[aria-expanded="true"] { border-color: var(--accent); }
.totals-bar { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 10px 32px; padding: 14px 18px; margin-bottom: 14px; border-radius: 14px; background: var(--surface); border: 1px solid var(--border); }
.tot { display: grid; min-width: 0; }
.tot .k { font-size: 12px; font-weight: 700; color: var(--muted); white-space: nowrap; }
.tot .v { font-size: 19px; font-weight: 800; letter-spacing: -0.01em; white-space: nowrap; }
.tot-count { margin-left: auto; text-align: right; }
.tot-count .v { font-size: 15px; font-weight: 700; color: var(--text-2); }
.tot-note { flex-basis: 100%; display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); }
.load-more { display: flex; flex-direction: column; align-items: center; gap: 8px; margin: 18px 0 4px; font-size: 13px; }
.load-more.in-card { margin: 0; padding: 16px; border-top: 1px solid var(--border); }
.list-end { text-align: center; font-size: 13px; margin: 14px 0 0; }

/* popovers */
.popover { position: fixed; z-index: 120; overflow-y: auto; overscroll-behavior: contain; min-width: 240px; max-width: calc(100vw - 16px); padding: 8px; border-radius: 14px; background: var(--raised); border: 1px solid var(--border-strong); box-shadow: var(--shadow-lg); }
.pop-range { width: 330px; }
.pop-title { font-size: 12px; font-weight: 750; color: var(--muted); padding: 6px 10px 4px; }
.dr-list { display: grid; gap: 1px; }
.dr-opt { display: grid; grid-template-columns: 18px minmax(0, 1fr) auto; gap: 10px; align-items: center; width: 100%; min-height: 42px; padding: 0 10px; border-radius: 9px; border: 0; background: none; text-align: left; font-size: 14px; font-weight: 550; color: var(--text); }
.dr-opt:hover { background: var(--surface-2); }
.dr-opt[aria-pressed="true"] { font-weight: 750; }
.dr-check { display: grid; place-items: center; color: var(--accent-text); }
.dr-check .i { stroke-width: 3; }
.dr-sub { font-size: 12.5px; color: var(--muted); white-space: nowrap; }
.dr-custom { margin-top: 6px; padding: 12px 10px 6px; border-top: 1px solid var(--border); display: grid; gap: 10px; }
.dr-custom-title { display: flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 750; }
.dr-custom-title .i { color: var(--accent-text); }
.dr-dates { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.dr-dates label { display: grid; gap: 4px; font-size: 12px; font-weight: 700; color: var(--muted); min-width: 0; }
.pop-user { width: 290px; padding: 6px; }
.um-head { display: flex; align-items: center; gap: 12px; padding: 10px 10px 12px; border-bottom: 1px solid var(--border); }
.um-name { font-weight: 750; font-size: 15px; }
.um-mail { font-size: 12.5px; color: var(--muted); }
.um-items { padding: 6px 0; display: grid; gap: 2px; }
.um-credit { font-size: 12px; color: var(--muted); padding: 10px 12px 6px; border-top: 1px solid var(--border); }
.menu-item { display: flex; align-items: center; gap: 12px; width: 100%; min-height: 44px; padding: 0 12px; border-radius: 10px; border: 0; background: none; color: var(--text); font-weight: 650; font-size: 14.5px; text-align: left; text-decoration: none; }
.menu-item:hover { background: var(--surface-2); }
.menu-item .i { color: var(--text-2); }

/* ---------- budgets ---------- */
.bud-overall { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 18px 40px; align-items: center; padding: 22px 24px; margin-bottom: 16px; background-image: var(--hero-glow); }
.bo-main { display: grid; gap: 10px; min-width: 0; }
.bo-label { font-size: 14px; font-weight: 650; color: var(--text-2); }
.bo-value { font-size: 32px; font-weight: 800; letter-spacing: -0.025em; line-height: 1.1; }
.bo-value .muted { font-size: 18px; font-weight: 650; letter-spacing: 0; }
.bo-main .meter { height: 10px; }
.bo-foot { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; font-size: 13.5px; }
.bo-line { color: var(--text-2); }
.bo-stats { display: flex; gap: 28px; }
.bo-stats li { display: grid; gap: 2px; }
.bo-num { font-size: 26px; font-weight: 800; line-height: 1.1; }
.bo-k { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 650; color: var(--text-2); white-space: nowrap; }
.bud-grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 268px), 1fr)); }
.bud-card { position: relative; display: flex; flex-direction: column; gap: 10px; padding: 16px; }
.bud-card:hover { border-color: var(--border-strong); }
.bud-card.is-over { border-color: rgba(208, 59, 59, 0.45); }
.bud-head { display: flex; align-items: center; gap: 12px; }
.bud-titles { flex: 1; min-width: 0; }
.bud-name { font-size: 15px; font-weight: 750; }
.bud-sub { font-size: 12.5px; color: var(--muted); }
.bud-edit { position: relative; z-index: 2; margin: -6px -6px -6px 0; }
.bud-amt { font-size: 21px; font-weight: 800; letter-spacing: -0.015em; }
.bud-amt .muted { font-size: 13px; font-weight: 650; letter-spacing: 0; }
.bud-foot { display: flex; align-items: center; gap: 8px; min-height: 24px; }
.bud-line { font-size: 13px; color: var(--text-2); }
.bud-open { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 2px; padding: 10px 0 0; border: 0; border-top: 1px solid var(--border); background: none; color: var(--accent-text); font-weight: 700; font-size: 13.5px; text-align: left; min-height: 40px; }
.bud-open::after { content: ''; position: absolute; inset: 0; border-radius: inherit; }
.bud-open:focus-visible { outline: none; }
.bud-open:focus-visible::after { outline: 2px solid var(--focus); outline-offset: 2px; }
.unbudgeted { margin-top: 16px; }
.ub-list li { display: flex; align-items: center; gap: 12px; padding: 4px 0; }
.ub-row { flex: 1; min-width: 0; display: flex; align-items: center; gap: 12px; min-height: 44px; padding: 0; border: 0; background: none; color: var(--text); text-align: left; }
.ub-name { flex: 1; font-weight: 650; }
.ub-amt { font-weight: 750; white-space: nowrap; }
.drawer-summary { display: grid; gap: 10px; padding: 14px; border-radius: 12px; background: var(--surface-2); margin-bottom: 8px; }
.ds-amt { font-size: 22px; font-weight: 800; }
.ds-amt .muted { font-size: 13.5px; font-weight: 650; }
.ds-foot { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px; font-size: 13px; }
.ds-note { display: flex; align-items: flex-start; gap: 8px; font-size: 13px; color: var(--text-2); }
.ds-note .i { color: var(--muted); margin-top: 1px; }
.drawer-list { margin: 0 -20px; }
.dlg-body .day-head { top: -4px; background: var(--raised); }
.drawer-actions { padding: 16px 0 4px; }

/* ---------- accounts ---------- */
.acc-grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr)); }
.acc-card { position: relative; display: flex; flex-direction: column; gap: 4px; padding: 18px; }
.acc-card:hover { border-color: var(--accent-line); }
.acc-card-head { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.acc-ico { display: grid; place-items: center; flex: none; width: 42px; height: 42px; border-radius: 12px; background: var(--surface-3); color: var(--text-2); }
.acc-card-titles { flex: 1; min-width: 0; }
.acc-name { font-size: 15.5px; font-weight: 750; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.acc-name a { color: var(--text); text-decoration: none; }
.stretched::after { content: ''; position: absolute; inset: 0; border-radius: var(--radius); }
.stretched:focus-visible { outline: none; }
.stretched:focus-visible::after { outline: 2px solid var(--focus); outline-offset: 2px; }
.acc-meta { font-size: 12.5px; color: var(--muted); }
.acc-chev { color: var(--muted); }
.acc-bal-label { font-size: 12.5px; font-weight: 650; color: var(--muted); }
.acc-bal { font-size: 26px; font-weight: 800; letter-spacing: -0.02em; line-height: 1.15; }
.acc-spark { margin: 8px 0 4px; z-index: 1; }
.acc-util { display: grid; gap: 6px; margin: 4px 0; font-size: 12.5px; }
.acc-foot { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 13px; font-weight: 650; padding-top: 10px; margin-top: 4px; border-top: 1px solid var(--border); }
.acc-foot .muted { margin-left: auto; font-weight: 600; }
.acc-summary { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 18px 36px; align-items: center; padding: 22px 24px; margin-bottom: 16px; background-image: var(--hero-glow); }
.as-label { font-size: 14px; font-weight: 650; color: var(--text-2); }
.as-value { font-size: 44px; font-weight: 800; letter-spacing: -0.03em; line-height: 1.1; margin: 6px 0 10px; white-space: nowrap; }
.as-delta { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; font-size: 13.5px; }
.as-stats { display: grid; grid-template-columns: repeat(3, auto); gap: 14px 30px; }
.as-stats .k { display: block; font-size: 12px; font-weight: 650; color: var(--muted); white-space: nowrap; }
.as-stats .v { display: block; font-size: 18px; font-weight: 800; white-space: nowrap; }
#acc-history-card { margin-bottom: 16px; }

/* ---------- goals ---------- */
.goal-grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 420px), 1fr)); }
.goal-card { display: flex; flex-direction: column; gap: 12px; padding: 20px; }
.goal-card.is-behind { border-color: rgba(250, 178, 25, 0.35); }
.goal-head { display: flex; align-items: flex-start; gap: 12px; }
.goal-ico { display: grid; place-items: center; flex: none; width: 44px; height: 44px; border-radius: 12px; background: var(--accent-soft); color: var(--accent-text); }
.goal-titles { flex: 1; min-width: 0; }
.goal-name { font-size: 17px; font-weight: 800; letter-spacing: -0.01em; }
.goal-sub { font-size: 13px; color: var(--muted); }
.goal-amt { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 8px; font-size: 14px; }
.goal-amt strong { font-size: 26px; font-weight: 800; letter-spacing: -0.02em; }
.goal-pct { margin-left: auto; font-weight: 750; color: var(--text-2); }
.goal-card .meter { height: 10px; }
.goal-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(128px, 1fr)); gap: 12px; padding: 12px 0; border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); }
.goal-stats > div { display: grid; min-width: 0; }
.goal-stats .k { font-size: 12px; font-weight: 650; color: var(--muted); }
.goal-stats .v { font-size: 15px; font-weight: 800; white-space: nowrap; }
.goal-stats .s { font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.goal-hint { display: flex; align-items: flex-start; gap: 8px; font-size: 13.5px; color: var(--text-2); }
.goal-hint .i { margin-top: 2px; color: var(--muted); }
.goal-card.is-behind .goal-hint .i { color: var(--warn-ico); }
.goal-acc { display: flex; align-items: center; gap: 6px; font-size: 12.5px; }
.goal-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: auto; padding-top: 4px; }
.goal-mini { display: grid; gap: 8px; margin-bottom: 16px; padding: 12px 14px; border-radius: 12px; background: var(--surface-2); }
.goal-mini p { font-size: 13.5px; color: var(--text-2); }

/* ---------- bills ---------- */
.cal-card { container-type: inline-size; }
.cal-legend { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 6px; }
.cal-table { width: 100%; table-layout: fixed; border-collapse: separate; border-spacing: 4px; margin: -4px; width: calc(100% + 8px); }
.cal-table th { font-size: 12px; font-weight: 750; color: var(--muted); padding: 2px 0 4px; text-align: left; padding-left: 6px; }
.wd-short { display: none; }
.cal-day { vertical-align: top; height: 92px; padding: 6px; border-radius: 10px; background: var(--surface-2); overflow: hidden; }
.cal-day.is-pad { background: transparent; }
.cal-day.is-today { box-shadow: inset 0 0 0 2px var(--accent); }
.cal-num { display: block; font-size: 12.5px; font-weight: 750; color: var(--text-2); }
.cal-day.is-today .cal-num { color: var(--accent-text); }
.cal-marks { display: grid; gap: 3px; margin-top: 4px; }
.cal-mark { display: flex; align-items: center; gap: 4px; min-width: 0; padding: 2px 5px; border-radius: 6px; font-size: 11.5px; font-weight: 700; line-height: 1.35; }
.cal-mark-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
@container (max-width: 560px) {
  .cal-day { height: 56px; padding: 5px 4px; }
  .cal-marks { display: flex; flex-wrap: wrap; gap: 2px; }
  .cal-mark { padding: 2px; }
  .cal-mark-text { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .cal-table th { text-align: center; padding-left: 0; }
  .cal-legend { justify-content: flex-start; }
}
.agenda-row {
  display: grid; grid-template-columns: 44px minmax(0, 1fr) auto; grid-template-areas: 'date main end' 'date action end';
  gap: 6px 12px; align-items: center; padding: 11px 18px; border-top: 1px solid var(--border);
}
.agenda-row.is-paid { grid-template-areas: 'date main end'; }
.ag-end { grid-area: end; display: grid; justify-items: end; gap: 5px; align-self: start; }
.badge-btn { border: 0; font: inherit; font-size: 12.5px; font-weight: 700; cursor: pointer; }
.badge-btn:hover { text-decoration: underline; }
.agenda-row .date-block { grid-area: date; align-self: start; }
.ag-ico { display: none; }
.ag-main { grid-area: main; display: grid; min-width: 0; }
.ag-name { font-weight: 700; font-size: 14.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ag-meta { font-size: 12.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ag-amt { font-weight: 800; font-size: 15px; white-space: nowrap; text-align: right; }
.ag-action { grid-area: action; justify-self: start; }
.agenda-row.is-paid .ag-name { color: var(--text-2); }

/* ---------- reports ---------- */
.multiples { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 214px), 1fr)); }
.mult { padding: 12px 12px 6px; border-radius: 12px; background: var(--surface-2); min-width: 0; }
.mult-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.mult-name { display: inline-flex; align-items: center; gap: 7px; font-size: 13.5px; font-weight: 750; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mult-name .i { color: var(--muted); }
.mult-label { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mult-total { font-weight: 800; font-size: 14px; white-space: nowrap; }
.mult-sub { font-size: 12px; color: var(--muted); margin: 2px 0 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mult .chart-svg .dot { stroke: var(--surface-2); }
.payee-cell { display: flex; align-items: center; gap: 10px; min-width: 0; }
.rank { display: inline-grid; place-items: center; flex: none; width: 24px; height: 24px; border-radius: 7px; background: var(--surface-3); font-size: 12px; font-weight: 800; color: var(--text-2); }
.payee-text { display: grid; min-width: 0; }
.payee-name { font-weight: 700; }
.payee-cat { font-size: 12px; color: var(--muted); font-weight: 600; }
.payee-table th, .payee-table td { padding: 9px 18px; }
.src-mix { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; margin-top: auto; padding-top: 16px; }
.src-mix li { display: grid; gap: 2px; padding: 10px 12px; border-radius: 12px; background: var(--surface-2); min-width: 0; }
.src-mix .k { font-size: 12px; font-weight: 650; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.src-mix .v { font-size: 16px; font-weight: 800; white-space: nowrap; }
.src-mix .s { font-size: 12px; color: var(--muted); }
.chart-card .chart-view { display: flex; flex-direction: column; flex: 1; }

/* ---------- dialogs: centred modal, bottom sheet on phone, right drawer ---------- */
.overlay { position: fixed; inset: 0; z-index: 100; display: flex; align-items: center; justify-content: center; padding: 24px; background: var(--scrim); opacity: 0; transition: opacity 0.18s ease; }
.overlay.is-open { opacity: 1; }
.dialog {
  position: relative; display: flex; flex-direction: column; width: 100%; max-height: calc(100vh - 48px);
  background: var(--raised); border: 1px solid var(--border-strong); border-radius: 18px; box-shadow: var(--shadow-lg); outline: none;
  transform: translateY(10px) scale(0.985); transition: transform 0.2s ease;
}
.overlay.is-open .dialog { transform: none; }
.dlg-sm { max-width: 460px; } .dlg-md { max-width: 620px; } .dlg-lg { max-width: 820px; }
.dlg-head { display: flex; align-items: flex-start; gap: 12px; padding: 20px 20px 14px; }
.sheet-grip { display: none; }
.dlg-titles { flex: 1; min-width: 0; }
.dlg-title { font-size: 18px; font-weight: 800; letter-spacing: -0.015em; }
.dlg-sub { font-size: 13.5px; color: var(--muted); margin-top: 2px; }
.dlg-close { margin: -6px -8px 0 0; }
.dlg-body { flex: 1 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 4px 20px 20px; }
.dlg-foot { display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: 8px; padding: 14px 20px; border-top: 1px solid var(--border); }
.foot-left { margin-right: auto; }
.confirm-msg { font-size: 14.5px; color: var(--text-2); }
.ov-drawer { justify-content: flex-end; align-items: stretch; padding: 0; }
.dlg-drawer { max-width: 480px; height: 100%; max-height: none; border-radius: 0; border-width: 0 0 0 1px; transform: translateX(28px); }
.ov-sheet { align-items: flex-end; padding: 0; }
.dlg-sheet { border-radius: 20px 20px 0 0; transform: translateY(28px); }

/* ---------- forms ---------- */
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 16px; }
.field { display: grid; gap: 6px; min-width: 0; align-content: start; }
.field-wide { grid-column: 1 / -1; }
.field label, .field-label { font-size: 13px; font-weight: 700; color: var(--text-2); }
.opt { font-weight: 550; color: var(--muted); }
.field input, .field select, .field textarea, .tb-search input, .tb-item select, .dr-dates input {
  width: 100%; min-height: 42px; padding: 0 12px; border-radius: 10px; border: 1px solid var(--border-strong);
  background: var(--surface-2); color: var(--text); font-size: 15px; outline: none; transition: border-color 0.15s, box-shadow 0.15s;
}
.field textarea { padding: 10px 12px; min-height: 64px; resize: vertical; line-height: 1.4; }
.field input:focus, .field select:focus, .field textarea:focus, .tb-search input:focus, .tb-item select:focus, .dr-dates input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.field input::placeholder, .field textarea::placeholder, .tb-search input::placeholder { color: var(--muted); opacity: 1; }
.field [aria-invalid="true"] { border-color: var(--crit); }
.field-err { font-size: 13px; font-weight: 600; color: var(--crit-text); }
.field-hint { font-size: 12.5px; color: var(--muted); }
.input-prefix { position: relative; }
.input-prefix > span { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); font-weight: 700; pointer-events: none; }
.input-prefix input { padding-left: 28px; }
.field-amount input { min-height: 50px; font-size: 20px; font-weight: 750; letter-spacing: -0.01em; }
.field-amount .input-prefix > span { font-size: 18px; }
.type-switch { border: 0; padding: 0; margin: 0 0 16px; min-width: 0; }
.type-switch legend { padding: 0; margin-bottom: 6px; }
.seg-radio { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 4px; padding: 4px; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--border); }
.seg-opt { position: relative; }
.seg-opt input { position: absolute; opacity: 0; inset: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.seg-opt span { display: flex; align-items: center; justify-content: center; gap: 6px; min-height: 40px; border-radius: 9px; font-weight: 700; font-size: 14px; color: var(--text-2); }
.seg-opt input:checked + span { background: var(--surface); color: var(--text); box-shadow: 0 1px 2px rgba(0, 0, 0, 0.25), 0 0 0 1px var(--border-strong); }
.seg-opt input:focus-visible + span { outline: 2px solid var(--focus); outline-offset: 1px; }
.form-note { display: flex; align-items: flex-start; gap: 8px; margin: 0 0 12px; padding: 10px 12px; border-radius: 10px; background: var(--surface-2); font-size: 13px; color: var(--text-2); }
.form-note .i { margin-top: 1px; color: var(--muted); }
.form .form-grid + .form-note { margin: 14px 0 0; }
.form-note + .form-note { margin-top: 8px; }
.xfer-preview { display: grid; gap: 6px; margin-top: 14px; }
.xp-row { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 4px 12px; padding: 9px 12px; border-radius: 10px; background: var(--surface-2); font-size: 13.5px; }
.xp-name { font-weight: 650; }
.xp-vals { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; color: var(--text-2); font-variant-numeric: tabular-nums; }
.xp-vals strong { color: var(--text); }

/* more sheet */
.more-list { display: grid; }
.more-link { display: grid; grid-template-columns: 42px minmax(0, 1fr) 18px; gap: 12px; align-items: center; padding: 10px 2px; color: var(--text); text-decoration: none; border-bottom: 1px solid var(--border); }
.more-ico { display: grid; place-items: center; width: 42px; height: 42px; border-radius: 12px; background: var(--surface-2); color: var(--text-2); }
.more-link[aria-current="page"] .more-ico { background: var(--accent-soft); color: var(--accent-text); }
.more-text { display: grid; min-width: 0; }
.more-label { font-weight: 750; font-size: 15px; }
.more-sub { font-size: 13px; color: var(--muted); }
.more-chev { color: var(--muted); }
.more-tools { display: grid; gap: 2px; margin: 12px -12px 0; }
.more-credit { display: flex; align-items: center; gap: 10px; margin-top: 12px; padding-top: 14px; border-top: 1px solid var(--border); font-size: 12.5px; color: var(--muted); }

/* toasts */
.toasts { position: fixed; left: 50%; bottom: 24px; z-index: 150; transform: translateX(-50%); display: grid; gap: 8px; justify-items: center; width: max-content; max-width: calc(100vw - 32px); pointer-events: none; }
.toast {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px 10px 14px; border-radius: 12px; max-width: 100%;
  background: var(--toast-bg); color: var(--toast-text); box-shadow: var(--shadow-lg); font-size: 14px; font-weight: 650; pointer-events: auto;
  animation: toast-in 0.2s ease; transition: opacity 0.2s, transform 0.2s;
}
.toast.is-leaving { opacity: 0; transform: translateY(6px); }
.toast-ico { color: var(--toast-accent); }
.toast-msg { min-width: 0; }
.toast-btn { flex: none; min-height: 32px; padding: 0 10px; border: 0; border-radius: 8px; background: transparent; color: var(--toast-accent); font-weight: 800; font-size: 14px; }
.toast-btn:hover { background: rgba(127, 127, 127, 0.16); }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ---------- desktop-only tweaks ---------- */
@media (min-width: 1024px) and (max-width: 1279px) {
  .bills-grid > [class*="span-"] { grid-column: 1 / -1; }
  .ov-top { grid-template-columns: minmax(0, 1fr); }
  .ov-top .tiles { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .page { padding: 24px 28px 36px; }
  .topbar { padding: 0 28px; }
}

/* ---------- tablet: icon rail ---------- */
@media (max-width: 1023px) {
  .sidebar { width: 72px; padding: 14px 10px; overflow: visible; }
  .main-col { margin-left: 72px; }
  .sb-head { justify-content: center; padding: 2px 0 14px; }
  .sidebar .brand-word, .sb-user-text, .sb-credit { display: none; }
  .nav-section { font-size: 0; height: 1px; padding: 0; margin: 10px 8px; background: var(--border); }
  .nav-link, .sb-back { justify-content: center; width: 52px; padding: 0; margin: 0 auto; min-height: 44px; }
  .nav-link[aria-current="page"]::before { left: -10px; }
  .nav-label {
    position: absolute; left: calc(100% + 14px); top: 50%; transform: translateY(-50%); z-index: 50;
    padding: 6px 10px; border-radius: 8px; background: var(--raised); border: 1px solid var(--border-strong); box-shadow: var(--shadow-lg);
    color: var(--text); font-size: 13px; font-weight: 650; white-space: nowrap; opacity: 0; pointer-events: none; transition: opacity 0.12s;
  }
  .nav-link:hover .nav-label, .nav-link:focus-visible .nav-label, .sb-back:hover .nav-label, .sb-back:focus-visible .nav-label { opacity: 1; }
  .sb-user { justify-content: center; padding: 8px 0; }
  .page { padding: 24px 24px 36px; }
  .topbar { padding: 0 24px; }
  .app-foot { padding: 0 24px 24px; }
  .grid-12 > [class*="span-"] { grid-column: 1 / -1; }
  .tiles-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .tb-search { flex-basis: 100%; }
  .tb-filters { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); width: 100%; }
  .tb-item select, .select-btn { min-width: 0; width: 100%; }
  .tb-clear { grid-column: 1 / -1; }
  .select-btn > .i:first-child { display: none; }
  .ov-top { grid-template-columns: minmax(0, 1fr); }
  .ov-top .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .bud-overall, .acc-summary { grid-template-columns: minmax(0, 1fr); }
}
@media (min-width: 640px) and (max-width: 1023px) {
  .sidebar .sidebar .sb-close { display: none; }
}

/* ---------- phone ---------- */
@media (max-width: 639px) {
  :root { --topbar-h: 56px; }
  body { font-size: 15px; }
  .sidebar {
    width: min(300px, 86vw); padding: 14px 12px; z-index: 60; overflow-y: auto; box-shadow: var(--shadow-lg);
    transform: translateX(-100%); visibility: hidden; transition: transform 0.22s ease, visibility 0s linear 0.22s;
  }
  .sidebar.is-open { transform: none; visibility: visible; transition: transform 0.22s ease; }
  .sidebar .brand-word, .sb-user-text, .sb-credit { display: initial; }
  .sb-user-text { display: grid; }
  .sb-credit { display: block; }
  .sb-head { justify-content: space-between; padding: 2px 4px 14px 8px; }
  .sidebar .sb-close { display: inline-grid; }
  .nav-section { font-size: 11.5px; height: auto; padding: 14px 12px 6px; margin: 0; background: none; }
  .nav-link, .sb-back { justify-content: flex-start; width: 100%; padding: 0 12px; min-height: 44px; }
  .nav-link[aria-current="page"]::before { left: -12px; }
  .nav-label { position: static; transform: none; opacity: 1; padding: 0; border: 0; background: none; box-shadow: none; font-size: 14.5px; color: inherit; pointer-events: auto; }
  .sb-user { justify-content: flex-start; padding: 8px 12px 10px; }
  .main-col { margin-left: 0; }
  .topbar { height: 56px; padding: 0 8px 0 4px; gap: 4px; }
  .topbar .nav-toggle { display: inline-grid; }
  .topbar .brand-top { display: inline-flex; gap: 7px; font-size: 16.5px; margin-right: 4px; }
  .topbar-title, .topbar-add, .avatar-btn { display: none; }
  .demo-pill { height: 22px; padding: 0 8px; font-size: 10.5px; }
  .page { padding: 16px 16px 24px; }
  .app-foot { padding: 0 16px calc(152px + env(safe-area-inset-bottom)); font-size: 12px; }
  .tabbar {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 40; display: grid; grid-template-columns: repeat(5, minmax(0, 1fr));
    padding: 6px 4px calc(6px + env(safe-area-inset-bottom)); background: var(--bg-elev); border-top: 1px solid var(--border);
  }
  .tab { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; min-height: 52px; padding: 0; border: 0; background: none; color: var(--muted); text-decoration: none; font-size: 11px; font-weight: 700; }
  .tab > span:first-child { display: grid; place-items: center; width: 52px; height: 28px; border-radius: 999px; transition: background 0.15s; }
  .tab[aria-current="page"], .tab.is-active { color: var(--accent-text); }
  .tab[aria-current="page"] > span:first-child, .tab.is-active > span:first-child { background: var(--accent-soft); }
  .tab-label { white-space: nowrap; }
  .fab {
    position: fixed; right: 16px; bottom: calc(76px + env(safe-area-inset-bottom)); z-index: 41; display: grid; place-items: center;
    width: 56px; height: 56px; border-radius: 18px; border: 0; background: var(--accent); color: var(--on-accent); box-shadow: 0 10px 24px rgba(0, 0, 0, 0.35);
  }
  .fab .i { width: 26px; height: 26px; }
  html.is-locked .fab { visibility: hidden; }
  .toasts { bottom: calc(144px + env(safe-area-inset-bottom)); }

  .page-head { margin-bottom: 16px; }
  .page-title { font-size: 24px; }
  .page-titles { flex-basis: 100%; }
  .hide-phone { display: none !important; }
  .card:not(.card-flush) { padding: 16px; }
  .card-head.pad { padding: 16px 16px 6px; }
  .chart-card .card-head { flex-wrap: wrap; }
  .chart-card .card-titles { flex: 1 1 180px; }
  .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .ov-top .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .tile { padding: 13px 14px; }
  .tile-value { font-size: 19px; }
  .tile-sub { font-size: 12px; white-space: nowrap; }
  .tiles-3 .tile:first-child { grid-column: 1 / -1; }
  .hero-card { padding: 18px; }
  .hero-value { font-size: 44px; }
  .hero-split { grid-template-columns: auto auto; }
  .hero-trend { grid-column: 1 / -1; }
  .acc-strip-list { display: flex; overflow-x: auto; scroll-snap-type: x mandatory; gap: 10px; margin: 0 -16px; padding: 0 16px 4px; scrollbar-width: none; }
  .acc-strip-list::-webkit-scrollbar { display: none; }
  .acc-strip-list li { flex: 0 0 196px; scroll-snap-align: start; }
  .hbar-row { grid-template-columns: minmax(0, clamp(104px, 36%, 150px)) minmax(0, 1fr); gap: 10px; }
  .txn-row { padding: 9px 16px; gap: 10px; grid-template-columns: 36px minmax(0, 1fr) auto; }
  .txn-ico { width: 36px; height: 36px; }
  .day-head { padding: 12px 16px 6px; }
  .chip-btn { min-height: 40px; }
  .btn { min-height: 42px; }
  .btn-sm { min-height: 40px; }

  .toolbar { padding: 12px; gap: 10px; }
  .tb-search { flex-basis: 100%; }
  .tb-filters { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); width: 100%; }
  .tb-item select, .select-btn { min-width: 0; width: 100%; }
  .select-btn { height: 44px; }
  .tb-clear { grid-column: 1 / -1; }
  .tb-clear .btn { width: 100%; }
  .totals-bar { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px 12px; padding: 12px 14px; }
  .tot .v { font-size: 16px; overflow: hidden; text-overflow: ellipsis; }
  .tot-count { grid-column: 1 / -1; margin: 0; text-align: left; display: flex; justify-content: space-between; gap: 8px; padding-top: 8px; border-top: 1px solid var(--border); }
  .tot-count .v { font-size: 13.5px; }
  .tot-note { grid-column: 1 / -1; align-items: flex-start; }

  .field input, .field select, .field textarea, .tb-search input, .tb-item select, .dr-dates input, .toolbar .tb-item select { font-size: 16px; min-height: 44px; }
  .field-amount input { font-size: 20px; }
  .form-grid { grid-template-columns: minmax(0, 1fr); gap: 12px; }

  .ov-modal, .ov-sheet { align-items: flex-end; padding: 0; }
  .dlg-modal, .dlg-sheet { max-width: none; max-height: 92vh; max-height: 92dvh; border-radius: 20px 20px 0 0; border-width: 1px 0 0; transform: translateY(32px); }
  .dlg-modal .sheet-grip, .dlg-sheet .sheet-grip { display: block; position: absolute; left: 50%; top: 8px; width: 38px; height: 4px; margin-left: -19px; border-radius: 2px; background: var(--border-strong); }
  .dlg-head { padding: 22px 16px 12px; }
  .dlg-body { padding: 2px 16px 16px; }
  .dlg-foot { padding: 12px 16px calc(12px + env(safe-area-inset-bottom)); }
  .dlg-foot .btn { flex: 1 1 auto; }
  .dlg-foot .foot-left { flex: 0 0 auto; }
  .dlg-drawer { max-width: none; border-width: 0; transform: translateY(24px); }
  .drawer-list { margin: 0 -16px; }
  .dlg-sm.dlg-modal .dlg-foot .btn { flex: 1 1 0; }

  .bo-value { font-size: 26px; }
  .bo-stats { justify-content: space-between; gap: 12px; }
  .bo-num { font-size: 22px; }
  .bo-k { font-size: 12px; }
  .month-label { min-width: 116px; font-size: 14px; }
  .page-budgets .page-actions, .page-bills .page-actions { width: 100%; justify-content: space-between; }
  .as-value { font-size: 34px; }
  .as-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .as-stats li:last-child { grid-column: 1 / -1; }
  .acc-summary { padding: 18px; }
  .goal-card { padding: 16px; }
  .goal-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .goal-stats > div:last-child { grid-column: 1 / -1; }
  .goal-actions .btn { flex: 1 1 0; }
  .wd-long { display: none; }
  .wd-short { display: inline; }
  .agenda-row { padding: 12px 16px; }
  .seg-period { width: 100%; }
  .seg-period .seg-btn { flex: 1 1 0; padding: 0 6px; font-size: 12.5px; }
  .page-reports .page-actions { width: 100%; }
  .payee-table th, .payee-table td { padding: 9px 12px; }
  .payee-table th:first-child, .payee-table td:first-child { padding-left: 16px; }
  .payee-table th:nth-child(4), .payee-table td:nth-child(4) { display: none; }
  .payee-table tbody th { white-space: normal; }
  .multiples { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .mult { padding: 10px 10px 4px; }
  .mult-sub { white-space: normal; }
  .src-mix { grid-template-columns: minmax(0, 1fr); gap: 6px; }
  .src-mix li { grid-template-columns: minmax(0, 1fr) auto; column-gap: 12px; padding: 8px 12px; }
  .src-mix .v { grid-column: 2; grid-row: 1 / span 2; align-self: center; }
  .cal-legend { display: none; }
  .pop-range { width: min(330px, calc(100vw - 16px)); }
}
@media (max-width: 380px) {
  .multiples { grid-template-columns: minmax(0, 1fr); }
  .demo-pill { font-size: 10px; padding: 0 7px; }
  .brand-top { font-size: 16px; }
}

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