/* Budget app styles, shared by the web app and (later) the mobile app.
   All colors are variables on :root so a theme option can swap them in one place later. */

:root {
    --bg: #f4f6f8;
    --panel: #ffffff;
    --panel-alt: #f8fafc;
    --text: #18202b;
    --muted: #64707f;
    --line: #e3e7ec;
    --line-strong: #cfd5dc;
    --primary: #1f5fd6;
    --primary-soft: #e8f0fd;
    --danger: #d23b32;
    --warning: #e08a0b;
    --info: #1593b3;
    --success: #23935a;
    --money-in: #1b7f4b;
    --money-out: #c2382f;
    --radius: 10px;
    --radius-sm: 6px;
    --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .08);
    --tap: 44px;
    --tabbar-h: 60px;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    -webkit-font-smoothing: antialiased;
}

main { padding: 14px 18px 56px; max-width: 1180px; margin: 0 auto; }

h1 { font-size: 1.45rem; margin: 6px 0 12px; letter-spacing: -.01em; }
h2 { font-size: 1.1rem; margin: 18px 0 8px; }
h3 { font-size: .95rem; margin: 14px 0 6px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
.muted, .hint { color: var(--muted); }
.hint { font-size: .85rem; }
.spacer { flex: 1; }

/* ---------- money ---------- */
.num, .amt, .bc-amount, .stat .value { font-variant-numeric: tabular-nums; }
.amt.neg { color: var(--money-out); }
.amt.pos { color: var(--money-in); }

/* ---------- navigation ---------- */
.topnav {
    display: flex; flex-wrap: wrap; gap: 4px 16px; align-items: center;
    padding: 10px 18px; background: var(--panel); border-bottom: 1px solid var(--line);
    position: sticky; top: 0; z-index: 20;
}
.topnav .brand { font-weight: 700; letter-spacing: -.01em; margin-right: 6px; }
.topnav a { color: var(--text); padding: 4px 2px; border-bottom: 2px solid transparent; }
.topnav a:hover { text-decoration: none; color: var(--primary); }
.topnav a.active { color: var(--primary); font-weight: 600; border-bottom-color: var(--primary); }
.topnav .who { color: var(--muted); font-size: .85rem; }

.tabbar { display: none; }
.sheet, .sheet-backdrop { display: none; }

/* ---------- buttons ---------- */
.btn, button {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    font: inherit; cursor: pointer; min-height: 36px;
    padding: 6px 14px; border: 1px solid var(--line-strong); border-radius: var(--radius-sm);
    background: var(--panel); color: var(--text);
}
.btn:hover, button:hover { text-decoration: none; background: var(--panel-alt); }
.btn.primary, button.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.primary:hover, button.primary:hover { filter: brightness(1.05); background: var(--primary); }
.btn.small { min-height: 28px; padding: 2px 10px; font-size: .85rem; }
button:disabled, .btn:disabled { opacity: .55; cursor: default; }
button.link { border: 0; background: none; padding: 0; min-height: 0; color: var(--primary); }
button.link:hover { text-decoration: underline; background: none; }

/* ---------- bucket cards ---------- */
.bucket-buttons {
    display: grid; gap: 10px; margin: 10px 0;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
}
.bucket {
    display: grid; gap: 4px; align-content: start; justify-items: start; text-align: left;
    min-height: 0; padding: 12px 12px 10px; border: 1px solid var(--line); border-radius: var(--radius);
    background: var(--panel); box-shadow: var(--shadow); color: var(--text);
    --level: var(--success);
}
.bucket:hover { background: var(--panel); border-color: var(--line-strong); }
.bucket.danger { --level: var(--danger); }
.bucket.warning { --level: var(--warning); }
.bucket.info { --level: var(--info); }
.bucket.success { --level: var(--success); }
.bucket.overdrawn { border-color: var(--danger); box-shadow: 0 0 0 1px var(--danger) inset; }
.bucket.selected { border-color: var(--primary); box-shadow: 0 0 0 2px var(--primary-soft), 0 0 0 1px var(--primary) inset; }
.bucket.overall { background: var(--panel-alt); }
.bc-name { font-size: .85rem; color: var(--muted); max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bc-amount { font-size: 1.2rem; font-weight: 650; }
.bc-bar { width: 100%; height: 6px; border-radius: 3px; background: var(--line); overflow: hidden; }
.bc-bar span { display: block; height: 100%; background: var(--level); border-radius: 3px; }
.bc-meta { font-size: .75rem; color: var(--muted); }
.bucket-actions { display: flex; flex-wrap: wrap; gap: 8px; margin: 4px 0 12px; }

/* ---------- account summary strip ---------- */
.summary-strip {
    display: flex; flex-wrap: wrap; gap: 10px; margin: 10px 0 14px;
}
.stat {
    flex: 1 1 130px; display: grid; gap: 2px; padding: 10px 14px;
    background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow);
}
.stat .label { font-size: .78rem; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.stat .value { font-size: 1.15rem; font-weight: 600; }
.stat.main { flex-basis: 170px; }
.stat.main .value { font-size: 1.5rem; }
.stat.main.ok { border-color: #bfe3cf; background: #f2fbf6; }
.stat.main.ok .value { color: var(--money-in); }
.stat.main.short { border-color: #f1c4c0; background: #fdf3f2; }
.stat.main.short .value { color: var(--money-out); }

/* ---------- account list ---------- */
.account-list { list-style: none; margin: 8px 0; padding: 0; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.account-list li { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px; padding: 10px 14px; border-bottom: 1px solid var(--line); }
.account-list li:last-child { border-bottom: 0; }
.account-list .account-name { display: grid; flex: 1; color: var(--text); }
.account-list .account-name:hover { text-decoration: none; color: var(--primary); }
.account-list .account-balance { font-weight: 600; }

/* ---------- tables ---------- */
.grid {
    width: 100%; border-collapse: separate; border-spacing: 0; margin: 8px 0;
    background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden;
}
.grid.narrow { width: auto; min-width: 320px; }
.grid th, .grid td { padding: 8px 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
.grid tbody tr:last-child td { border-bottom: 0; }
.grid th { font-size: .78rem; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; background: var(--panel-alt); }
.grid tfoot td, .grid tr.total td { font-weight: 650; background: var(--panel-alt); border-top: 1px solid var(--line); }
.num { text-align: right !important; white-space: nowrap; }
tr.clickable { cursor: pointer; }
tr.clickable:hover td { background: var(--primary-soft); }
tr.section td, tr.section th { background: #eef1f4; font-weight: 600; font-size: .85rem; }
tr.hold td { color: #4b5563; font-style: italic; }
tr.bucket-row td { color: var(--muted); font-size: .92rem; }
tr.single td { font-weight: 700; }
tr.single td { background: var(--primary-soft); }
tr.muted td { color: var(--muted); }
.reconcile-cell { display: flex; gap: 10px; align-items: center; }
.tick { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; }
.tick input { width: 20px; height: 20px; }

/* ---------- forms ---------- */
.form { display: grid; gap: 14px; max-width: 560px; }
.form label { display: grid; gap: 4px; font-size: .88rem; color: var(--muted); }
.form label.check { display: flex; gap: 8px; align-items: center; color: var(--text); }
input, select, textarea {
    font: inherit; padding: 7px 10px; min-height: 36px;
    border: 1px solid var(--line-strong); border-radius: var(--radius-sm); background: #fff; color: var(--text);
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--primary-soft); border-color: var(--primary); }
input[type=checkbox] { min-height: 0; width: 18px; height: 18px; accent-color: var(--primary); }
textarea { min-height: 76px; }
input.short { width: 7em; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; }
.filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 10px 0; }
.toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.toolbar h1 { margin: 0 8px 0 0; }
.split { display: flex; gap: 8px; margin: 4px 0; }
fieldset { border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 14px; background: var(--panel); }
.suggestions { background: #fffbeb; border: 1px solid #f5e1a4; border-radius: var(--radius); padding: 10px 12px; }

/* ---------- layout ---------- */
.columns { display: grid; gap: 18px; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); align-items: start; }
/* Grid items default to min-width:auto, which lets a wide table spill into the next column.
   Keep each column to its share; wide tables scroll inside .table-wrap instead. */
.columns > * { min-width: 0; }
.table-wrap { overflow-x: auto; }
.table-wrap > .grid { margin-top: 0; }
/* Main content + narrow side column (Reconcile). Side column drops below on narrower screens. */
.columns.side-layout { grid-template-columns: minmax(0, 1fr) minmax(260px, 320px); }
.columns.side-layout aside h2 { margin-top: 4px; }
.row-actions { display: inline-flex; gap: 6px; }
.totals-by-account { list-style: none; padding: 0; margin: 8px 0; max-width: 360px; }
.totals-by-account li { display: flex; justify-content: space-between; padding: 4px 0; border-bottom: 1px dashed var(--line); }
@media (max-width: 1000px) {
    .columns.side-layout { grid-template-columns: minmax(0, 1fr); }
}
.account-links { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: .9rem; margin: 6px 0; }
.account-link { display: inline-flex; gap: 4px; align-items: center; }
.pager { display: flex; gap: 10px; align-items: center; margin: 10px 0; }

/* ---------- tip calculator ---------- */
.tip-box { margin: 8px 0; }
.tip-box ul { margin: 6px 0; padding-left: 18px; }

/* ---------- monthly tasks ---------- */
.monthly-tasks { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0 14px; }
.task { border: 1px solid var(--line-strong); border-radius: 999px; background: var(--panel); padding: 4px 12px; min-height: 32px; }
.task.done { background: #e7f5ec; border-color: #bfe3cf; color: var(--money-in); }

/* ---------- calendar ---------- */
.month { width: 100%; table-layout: fixed; border-collapse: collapse; background: var(--panel); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
.month th { font-size: .78rem; color: var(--muted); padding: 6px; background: var(--panel-alt); }
.month td { height: 96px; vertical-align: top; border: 1px solid var(--line); padding: 4px; overflow: hidden; }
.month td.other { background: #f6f7f9; color: var(--muted); }
.month td.today { background: var(--primary-soft); }
.daynum { font-size: .8rem; color: var(--muted); }
.event {
    display: block; font-size: .8rem; background: var(--primary); color: #fff; border-radius: 4px;
    padding: 1px 5px; margin-top: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.event:hover { text-decoration: none; filter: brightness(1.1); }

/* ---------- summary bars ---------- */
.summary { margin-top: 18px; }
.bars { list-style: none; padding: 0; margin: 0; display: grid; gap: 6px; max-width: 680px; }
.bars li { display: grid; grid-template-columns: 150px 1fr 110px; gap: 10px; align-items: center; }
.bar { background: var(--line); height: 10px; border-radius: 5px; overflow: hidden; }
.bar span { display: block; height: 100%; background: var(--primary); border-radius: 5px; }

/* ---------- messages ---------- */
.error-banner {
    display: flex; justify-content: space-between; gap: 8px;
    background: #fdf0ef; color: #8a1c1c; border: 1px solid #f3c6c2; border-radius: var(--radius);
    padding: 10px 14px; margin: 10px 0;
}
.ok { color: var(--success); }
.loading { color: var(--muted); }
.error { color: var(--danger); }
code { color: #a3215f; }
.new-code { font-size: 1.25rem; }
.new-code strong { letter-spacing: .1em; font-variant-numeric: tabular-nums; }
input.code { text-transform: uppercase; letter-spacing: .08em; width: 12em; }
.center { text-align: center; }
.signin.mfa { max-width: 460px; }
.qr { margin: 10px 0; }
.qr img { display: block; width: 200px; height: 200px; background: #fff; padding: 8px; border: 1px solid var(--line); border-radius: var(--radius-sm); }
code.secret { letter-spacing: .06em; word-break: break-all; }
.help-small { margin-top: 14px; font-size: .88rem; }
.help-small summary { cursor: pointer; color: var(--primary); }

/* ---------- auth ---------- */
.signin { max-width: 380px; margin: 10vh auto 16px; background: var(--panel); padding: 22px 26px; border-radius: 14px; border: 1px solid var(--line); box-shadow: var(--shadow); }
.signin form { display: grid; gap: 12px; }
.app-footer { margin-top: 36px; padding-top: 12px; border-top: 1px solid var(--line); text-align: center; color: var(--muted); font-size: .85rem; }
.app-footer .tagline { font-style: italic; }
.app-footer-brand { font-weight: 600; }
.signin .tagline-line { margin: -6px 0 14px; color: var(--muted); font-style: italic; }
.signin label { display: grid; gap: 4px; font-size: .88rem; color: var(--muted); }
.overlay { position: fixed; inset: 0; background: rgba(15, 23, 42, .45); display: grid; place-items: center; z-index: 50; }
.overlay-box { background: var(--panel); border-radius: 14px; padding: 8px 8px 0; max-width: 420px; }
.overlay-box .signin { margin: 0; border: 0; box-shadow: none; }
.overlay-box .note { margin: 12px 20px 0; }
.gate-error { max-width: 580px; margin: 8vh auto; background: var(--panel); padding: 22px 26px; border-radius: 14px; border: 1px solid var(--line); box-shadow: var(--shadow); }

/* ---------- charts ----------
   Palette: the dataviz skill's validated reference instance (light), used unchanged and on
   the surface it was validated against (#fcfcfb). Slots in fixed order; status colors reserved. */
:root {
    --chart-surface: #fcfcfb;
    --chart-ink: #0b0b0b;
    --chart-ink-2: #52514e;
    --chart-muted: #898781;
    --chart-grid: #e1e0d9;
    --chart-axis: #c3c2b7;
    --series-1: #2a78d6;
    --series-2: #eb6834;
    --series-3: #1baf7a;
    --series-4: #eda100;
    --series-5: #e87ba4;
    --series-6: #008300;
    --seq-250: #86b6ef;
    --div-pos: #2a78d6;
    --div-neg: #e34948;
    --status-good: #0ca30c;
    --status-warning: #fab219;
    --status-critical: #d03b3b;
}

.chart-card {
    background: var(--chart-surface); color: var(--chart-ink);
    border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow);
    padding: 14px 16px 10px; margin: 0 0 14px; min-width: 0;
}
.chart-head h3 { margin: 0; font-size: 1rem; color: var(--chart-ink); text-transform: none; letter-spacing: 0; }
.chart-sub { margin: 2px 0 0; font-size: .82rem; color: var(--chart-ink-2); }
.chart-empty { color: var(--chart-ink-2); margin: 12px 0 6px; }
.chart-legend { display: flex; flex-wrap: wrap; gap: 4px 14px; margin: 10px 0 2px; font-size: .82rem; color: var(--chart-ink-2); }
.chart-legend .key { display: inline-flex; align-items: center; gap: 6px; }
.swatch-rect { width: 10px; height: 10px; border-radius: 2px; display: inline-block; }
.chart-readout { min-height: 46px; margin: 8px 0 6px; font-size: .85rem; color: var(--chart-ink-2); }
.ro-head strong { font-size: 1.05rem; color: var(--chart-ink); margin-right: 6px; }
.ro-rows { display: flex; flex-wrap: wrap; gap: 2px 14px; margin-top: 2px; }
.ro-row { display: inline-flex; align-items: center; gap: 6px; }
.ro-row strong { color: var(--chart-ink); font-variant-numeric: tabular-nums; }
.line-key { width: 12px; height: 2px; border-radius: 1px; display: inline-block; }
.chart-table { margin-top: 6px; font-size: .85rem; }
.chart-table summary { cursor: pointer; color: var(--primary); padding: 4px 0; font-weight: 500; }
.chart-table .grid { margin: 6px 0; }
.refreshing { opacity: .55; transition: opacity .15s; }

/* shared column/line plot frame: y labels | plot ; x labels under the plot */
.vchart, .lchart {
    display: grid; grid-template-columns: auto 1fr; grid-template-rows: var(--plot-h) auto;
    column-gap: 8px; margin-top: 6px;
}
.chart-card .y-axis { position: relative; min-width: 38px; font-size: .72rem; color: var(--chart-muted); font-variant-numeric: tabular-nums; }
.chart-card .y-axis span { position: absolute; right: 0; transform: translateY(50%); white-space: nowrap; }
.chart-card .plot { position: relative; }
.chart-card .grid-line { position: absolute; left: 0; right: 0; height: 1px; background: var(--chart-grid); }
.chart-card .grid-line.base { background: var(--chart-axis); }
.chart-card .x-axis { grid-column: 2; display: flex; font-size: .72rem; color: var(--chart-muted); padding-top: 4px; }
.chart-card .x-axis span { flex: 1; text-align: center; white-space: nowrap; overflow: visible; }
.chart-card .x-axis.spread { justify-content: space-between; }
.chart-card .x-axis.spread span { flex: 0 0 auto; }

/* columns. Chart classes all start with v/l and are scoped to the chart, so they can't
   collide with page classes (".stack" once matched the stacking tables and squeezed them). */
.vchart .vcols { position: absolute; inset: 0; display: flex; align-items: flex-end; }
.vchart .vcol {
    flex: 1; height: 100%; display: flex; align-items: flex-end; justify-content: center;
    background: none; border: 0; border-radius: 0; padding: 0; min-height: 0; cursor: default;
}
.vchart .vcol:hover, .vchart .vcol.on, .vchart .vcol:focus-visible { background: rgba(42, 120, 214, .06); }
.vchart .vcol:focus-visible { outline: 2px solid var(--series-1); outline-offset: -2px; }
.vchart .vstack {
    width: min(24px, 70%); display: flex; flex-direction: column-reverse; gap: 2px;
    border-radius: 4px 4px 0 0; overflow: hidden; background: var(--chart-surface);
}
.vchart .vseg { flex-basis: 0; min-height: 0; }

/* diverging (money in up / out down) */
.vchart .vcol.flow-col { flex-direction: column; align-items: center; justify-content: stretch; }
.vchart .flow-col .half { flex: 1; width: min(24px, 70%); display: flex; }
.vchart .flow-col .half.up { align-items: flex-end; }
.vchart .flow-col .half.down { align-items: flex-start; }
.vchart .flow-col .bar { width: 100%; }
.vchart .flow-col .half.up .bar { background: var(--div-pos); border-radius: 4px 4px 0 0; }
.vchart .flow-col .half.down .bar { background: var(--div-neg); border-radius: 0 0 4px 4px; }

/* line */
.lchart svg { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }
.lchart .line { fill: none; stroke: var(--series-1); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; vector-effect: non-scaling-stroke; }
.lchart .area { fill: var(--series-1); opacity: .1; }
.lchart .projection { fill: none; stroke: var(--series-1); stroke-width: 2; stroke-dasharray: 2 5; stroke-linecap: round; vector-effect: non-scaling-stroke; }
.lchart .crosshair { position: absolute; top: 0; bottom: 0; width: 1px; background: var(--chart-axis); transform: translateX(-.5px); pointer-events: none; }
.lchart .ldot {
    position: absolute; width: 8px; height: 8px; border-radius: 50%; background: var(--series-1);
    box-shadow: 0 0 0 2px var(--chart-surface); transform: translate(-50%, -50%); pointer-events: none;
}
.lchart .ldot.hollow { background: var(--chart-surface); box-shadow: 0 0 0 2px var(--series-1); }
.lchart .zones { position: absolute; inset: 0; }
.lchart .zones span { position: absolute; top: 0; bottom: 0; }

/* horizontal bars (paired + ranked) */
.hbars { display: grid; gap: 4px; margin-top: 6px; }
.hrow {
    display: grid; grid-template-columns: minmax(80px, 150px) 1fr 84px; gap: 10px; align-items: center;
    width: 100%; text-align: left; background: none; border: 0; border-radius: var(--radius-sm);
    padding: 4px 6px; min-height: 0; font: inherit; color: var(--chart-ink); cursor: default;
}
.hrow:hover, .hrow.on, .hrow:focus-visible { background: rgba(42, 120, 214, .06); }
.hrow:focus-visible { outline: 2px solid var(--series-1); outline-offset: -2px; }
.hlabel { font-size: .85rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.htrack { display: grid; gap: 2px; }
.hbar { display: block; height: 10px; border-radius: 0 4px 4px 0; min-width: 0; }
.hbars:not(.paired) .hbar { height: 14px; }
.hvalue { font-size: .85rem; text-align: right; font-variant-numeric: tabular-nums; color: var(--chart-ink); }

/* ---------- dashboard ---------- */
.dashboard {
    display: grid; gap: 16px; align-items: start;
    grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr);
    grid-template-areas:
        "pace    accounts"
        "pace    safe"
        "compare recent"
        "compare coming";
}
.d-safe { grid-area: safe; } .d-pace { grid-area: pace; } .d-coming { grid-area: coming; }
.d-compare { grid-area: compare; } .d-recent { grid-area: recent; } .d-accounts { grid-area: accounts; }
.dashboard > * { min-width: 0; }

.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px 16px; }
.panel-head { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.panel-head h2 { margin: 0; font-size: 1.05rem; }

.hero-card {
    background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow);
    padding: 18px 20px; display: grid; gap: 4px;
}
.hero-card.short { border-color: #f1c4c0; background: #fdf6f5; }
.hero-label { font-size: .8rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 600; }
.hero-value { font-size: 3.25rem; line-height: 1.05; font-weight: 650; letter-spacing: -.02em; color: var(--text); }
.hero-card.short .hero-value { color: var(--money-out); }
.hero-sub { color: var(--muted); font-size: .9rem; }
.tiles { display: flex; flex-wrap: wrap; gap: 8px 22px; margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--line); }
.tile { display: grid; }
.tile .label { font-size: .75rem; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.tile .value { font-weight: 600; }

.status-icon {
    display: inline-grid; place-items: center; width: 16px; height: 16px; border-radius: 50%;
    font-size: .68rem; font-weight: 800; color: #fff; margin-right: 6px; vertical-align: -2px;
}
.status-icon.good { background: var(--status-good); }
.status-icon.warning { background: var(--status-warning); color: #0b0b0b; }
.status-icon.critical { background: var(--status-critical); }
.status-icon.none { background: var(--line-strong); color: var(--text); }

.pace-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.pace-row {
    display: grid; grid-template-columns: minmax(90px, 1fr) auto; grid-template-areas: "name amount" "meter meter" "status status";
    gap: 4px 10px; padding: 8px 6px; border-radius: var(--radius-sm); color: var(--text);
}
.pace-row:hover { background: var(--panel-alt); text-decoration: none; }
.pace-name { grid-area: name; font-weight: 600; }
.pace-amount { grid-area: amount; text-align: right; font-variant-numeric: tabular-nums; }
.pace-amount .muted { font-size: .82rem; }
.meter { grid-area: meter; position: relative; height: 8px; border-radius: 4px; background: #ecebe6; }
.meter .fill { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 4px; }
.pace-row.good .fill { background: var(--status-good); }
.pace-row.warning .fill { background: var(--status-warning); }
.pace-row.critical .meter { background: #f6d9d9; }
.pace-row.none .fill { background: var(--line-strong); }
.meter .target { position: absolute; top: -3px; bottom: -3px; width: 2px; margin-left: -1px; background: var(--text); border-radius: 1px; }
.pace-status { grid-area: status; font-size: .8rem; color: var(--muted); }

.feed { list-style: none; margin: 0; padding: 0; }
.feed li { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.feed li:last-child { border-bottom: 0; }
.feed-icon {
    flex: 0 0 28px; height: 28px; border-radius: 50%; display: grid; place-items: center;
    background: var(--panel-alt); color: var(--muted); font-weight: 700; font-size: .85rem;
}
.feed-icon.hold { background: #fff4dc; color: #8a5a00; }
.feed-icon.event { background: var(--primary-soft); color: var(--primary); }
.feed-icon.spend { background: #fdecea; color: var(--money-out); }
.feed-icon.fund { background: #e7f5ec; color: var(--money-in); }
.feed-main { flex: 1; display: grid; min-width: 0; color: var(--text); }
.feed-main:hover { text-decoration: none; color: var(--primary); }
.feed-title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.feed-detail { font-size: .8rem; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.feed-amount { font-weight: 600; white-space: nowrap; }
.account-list.flat { border: 0; box-shadow: none; margin: 0; }
.account-list.flat li { padding: 8px 0; }

.collapsible { margin: 0 0 12px; }
.collapsible-head {
    display: flex; align-items: center; gap: 8px; width: 100%; justify-content: flex-start;
    background: none; border: 0; padding: 4px 0; min-height: 32px; font-weight: 600; color: var(--text);
}
.collapsible-head:hover { background: none; color: var(--primary); }
.collapsible-head .hint { font-weight: 400; }
.collapsible-head .chevron { width: 1em; color: var(--muted); }
.collapsible-body { margin-top: 6px; }
.charts-row { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); margin-bottom: 4px; }
.charts-row > * { min-width: 0; }
.filters.period { gap: 6px; }

/* ---------- public pages (About, Help) ---------- */
.public-header {
    display: flex; align-items: center; gap: 16px; padding: 12px 18px;
    background: var(--panel); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 20;
}
.public-header .brand { font-weight: 700; font-size: 1.1rem; color: var(--text); }
.public-header nav { display: flex; gap: 14px; }
.public-header nav a { color: var(--text); }
.public-header nav a.active { color: var(--primary); font-weight: 600; }
main.public { max-width: 920px; }
main.public section { margin: 28px 0; scroll-margin-top: 70px; }
.public-footer { display: flex; gap: 14px; max-width: 920px; margin: 0 auto; padding: 18px; color: var(--muted); font-size: .85rem; border-top: 1px solid var(--line); }
.lead { font-size: 1.1rem; color: #3a4554; max-width: 720px; }
.hero { padding: 22px 0 8px; }
.hero h1 { font-size: 2.1rem; line-height: 1.15; margin-bottom: 14px; letter-spacing: -.02em; }
.demo .bucket { cursor: default; }
.feature-grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); }
.feature { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow); }
.feature h3 { text-transform: none; letter-spacing: 0; color: var(--text); font-size: 1.02rem; margin: 0 0 6px; }
.feature p { margin: 0; color: #3a4554; }
.steps { padding-left: 22px; }
.steps li { margin: 8px 0; }
.checklist { list-style: none; padding: 0; }
.checklist li { padding: 4px 0 4px 26px; position: relative; }
.checklist li::before { content: "✓"; position: absolute; left: 4px; color: var(--success); font-weight: 700; }
.cta { background: var(--primary-soft); border-radius: var(--radius); padding: 18px 22px; }
.cta h2 { margin-top: 0; }
.toc { display: flex; flex-wrap: wrap; gap: 6px 14px; padding: 10px 14px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); }
.callout { background: #fff8e6; border: 1px solid #f3dfa6; border-radius: var(--radius); padding: 12px 16px; }
.formula { background: var(--panel-alt); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 8px 12px; font-weight: 600; display: inline-block; }
.swatch { display: inline-block; width: 12px; height: 12px; border-radius: 3px; vertical-align: -1px; }
.swatch.danger { background: var(--danger); }
.swatch.warning { background: var(--warning); }
.swatch.info { background: var(--info); }
.swatch.success { background: var(--success); }
details { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius-sm); margin: 8px 0; }
details summary { cursor: pointer; padding: 10px 14px; font-weight: 600; list-style-position: inside; }
details[open] summary { border-bottom: 1px solid var(--line); }
details p { margin: 0; padding: 10px 14px 12px; color: #3a4554; }

/* ======================================================================
   Phones
   ====================================================================== */
@media (max-width: 640px) {
    body { font-size: 16px; } /* 16px+ keeps iOS from zooming into inputs */
    main { padding: 10px 12px calc(var(--tabbar-h) + 24px + env(safe-area-inset-bottom, 0px)); }
    h1 { font-size: 1.3rem; }

    /* bottom tab bar instead of the top bar */
    .topnav { display: none; }
    .tabbar {
        display: grid; grid-template-columns: repeat(5, 1fr);
        position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
        height: calc(var(--tabbar-h) + env(safe-area-inset-bottom, 0px));
        padding-bottom: env(safe-area-inset-bottom, 0px);
        background: var(--panel); border-top: 1px solid var(--line);
    }
    .tabbar a, .tabbar button {
        display: grid; justify-items: center; align-content: center; gap: 2px;
        border: 0; border-radius: 0; background: none; min-height: var(--tabbar-h);
        font-size: .72rem; color: var(--muted); padding: 4px 0;
    }
    .tabbar a:hover { text-decoration: none; }
    .tabbar a.active, .tabbar button.active { color: var(--primary); font-weight: 600; }
    .tabbar svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
    .sheet-backdrop { display: block; position: fixed; inset: 0; background: rgba(15, 23, 42, .35); z-index: 31; }
    .sheet {
        display: grid; position: fixed; left: 0; right: 0; z-index: 32;
        bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom, 0px));
        background: var(--panel); border-radius: 14px 14px 0 0; padding: 8px 0 12px; box-shadow: 0 -4px 16px rgba(0,0,0,.12);
    }
    .sheet a, .sheet button.link { display: flex; align-items: center; min-height: var(--tap); padding: 0 20px; color: var(--text); font-size: 1rem; }
    .sheet button.link { color: var(--danger); }
    .sheet-who { padding: 8px 20px 0; color: var(--muted); font-size: .85rem; border-top: 1px solid var(--line); margin-top: 6px; }

    /* bigger tap targets */
    .btn, button, input, select { min-height: var(--tap); }
    .btn.small { min-height: 34px; }
    button.link { min-height: 0; }

    .bucket-buttons { grid-template-columns: repeat(2, 1fr); gap: 8px; }
    .bucket { padding: 10px; }
    .bc-amount { font-size: 1.1rem; }

    .stat { flex-basis: calc(50% - 5px); }
    .stat.main { flex-basis: 100%; }

    /* tables become stacked rows: each cell shows its column name */
    table.stack, table.stack tbody, table.stack tfoot, table.stack tr, table.stack td { display: block; width: 100%; }
    table.stack thead { display: none; }
    table.stack tr { padding: 8px 12px; border-bottom: 1px solid var(--line); }
    table.stack tbody tr:last-child { border-bottom: 0; }
    table.stack td {
        display: flex; justify-content: space-between; align-items: center; gap: 12px;
        border: 0; padding: 2px 0; text-align: right;
    }
    table.stack td::before { content: attr(data-label); color: var(--muted); font-size: .8rem; text-align: left; }
    table.stack td:empty, table.stack td[data-label=""]::before { display: none; }
    table.stack td.title { font-weight: 600; font-size: 1rem; justify-content: flex-start; text-align: left; }
    table.stack td.title::before { display: none; }
    table.stack tr.section td, table.stack tr.total td { justify-content: space-between; }
    table.stack .reconcile-cell { flex-wrap: wrap; justify-content: flex-end; }
    table.stack .reconcile-cell select { flex: 1; min-width: 0; }

    .grid.narrow { width: 100%; min-width: 0; }
    .columns { grid-template-columns: 1fr; }
    .month td { height: 64px; font-size: .75rem; }
    .event { font-size: .7rem; padding: 0 3px; }
    .bars li { grid-template-columns: 90px 1fr 84px; }
    .signin, .gate-error { margin: 4vh 12px; padding: 18px; }

    /* dashboard: one column, in the agreed order */
    .dashboard {
        grid-template-columns: minmax(0, 1fr);
        grid-template-areas: "accounts" "pace" "safe" "compare" "recent" "coming";
        gap: 12px;
    }
    .hero-value { font-size: 2.75rem; }
    .hrow { grid-template-columns: minmax(70px, 110px) 1fr 74px; gap: 8px; }
    .chart-card .x-axis span { font-size: .65rem; }
    .chart-card .x-axis:not(.spread) span:nth-child(even) { visibility: hidden; } /* every other month label on small screens */
    .vchart .y-axis, .lchart .y-axis { min-width: 32px; }

    .public-header { flex-wrap: wrap; gap: 8px 14px; }
    main.public { padding-bottom: 32px; }
    .hero h1 { font-size: 1.6rem; }
    .lead { font-size: 1rem; }
}
