:root {
    --bg: #f5f7fa;
    --surface: #ffffff;
    --text: #2d2d2d;
    --muted: #888;
    --faint: #aaa;
    --line: #f0f0f0;
    --line-strong: #dde3f0;
    --head: #f0f4ff;
    --hover: #fafbff;
    --navy: #1a1a2e;
    --navy-2: #16213e;
    --blue: #4a90d9;
    --blue-text: #3a5ca8;
    --green: #27ae60;
    --red: #e74c3c;
    --orange: #e67e22;
    --purple: #7b2ff7;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
[hidden] { display: none !important; }
body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    color: var(--text);
    background: var(--bg);
    min-height: 100vh;
}

/* ── Top bar ─────────────────────────────────────────────────────────── */
.topbar {
    background: linear-gradient(135deg, var(--navy) 0%, var(--navy-2) 100%);
    color: #fff;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px 24px;
    padding: 12px 24px;
    position: sticky;
    top: 0;
    z-index: 10;
}
.brand { font-weight: 700; font-size: 1.15em; letter-spacing: -0.3px; }
.home-link { color: #aab4c8; text-decoration: none; font-size: 0.9em; padding: 4px 10px; margin-right: -12px; border-radius: 6px; }
.home-link:hover { color: #fff; background: rgba(255,255,255,0.08); }
#nav { display: flex; flex-wrap: wrap; gap: 4px; }
#nav a {
    color: #aab4c8;
    text-decoration: none;
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 0.9em;
}
#nav a:hover { color: #fff; background: rgba(255,255,255,0.08); }
#nav a.active { color: #fff; background: rgba(255,255,255,0.16); }
/* Menu colours (shared/js/navcolors.js): red / yellow while that page has a red / yellow banner */
#nav a.bad { color: #ffd5d0; background: rgba(231,76,60,0.25); }
#nav a.bad:hover { background: rgba(231,76,60,0.35); }
#nav a.warn { color: #ffdf6b; background: rgba(245,197,24,0.22); }
#nav a.warn:hover { background: rgba(245,197,24,0.32); }
/* the page you're on: solid, so the colour still shows (see-through yellow on navy looked olive) */
#nav a.bad.active { color: #fff; background: #d63a2c; }
#nav a.warn.active { color: #2b2200; background: #f5c518; }
.status { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; }
.pill {
    font-size: 0.78em;
    padding: 3px 10px;
    border-radius: 12px;
    background: rgba(255,255,255,0.1);
    color: #ccd3e0;
    white-space: nowrap;
}
.pill.ok { background: rgba(39,174,96,0.25); color: #c8f5d8; }
.pill.bad { background: rgba(231,76,60,0.25); color: #ffd5d0; }

/* ── Layout ──────────────────────────────────────────────────────────── */
main { max-width: 1100px; margin: 28px auto; padding: 0 16px 60px; }
h1.page { font-size: 1.5em; margin-bottom: 6px; }
p.lead { color: var(--muted); margin-bottom: 22px; }
section {
    background: var(--surface);
    border-radius: 10px;
    padding: 22px 26px;
    margin-bottom: 18px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.08);
}
section h2 {
    font-size: 1.0em;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #555;
    margin-bottom: 14px;
    padding-bottom: 10px;
    border-bottom: 2px solid var(--line);
    display: flex;
    align-items: center;
    gap: 10px;
}
section h2 .sub { font-weight: 400; font-size: 0.85em; color: var(--faint); text-transform: none; letter-spacing: 0; }
section p { line-height: 1.55; }
section p + p { margin-top: 8px; }
.note { font-size: 0.84em; color: #999; margin-top: 10px; font-style: italic; }
.muted { color: var(--faint); }
code, .mono { font-family: Consolas, 'SF Mono', monospace; font-size: 0.9em; }
code { background: #f3f5fa; padding: 1px 5px; border-radius: 4px; }
pre.cmd {
    background: #1a1a2e; color: #e6e9f0; padding: 12px 14px; border-radius: 8px;
    font-family: Consolas, 'SF Mono', monospace; font-size: 0.86em; overflow-x: auto; margin: 8px 0;
}
.row { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.spacer { flex: 1; }
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 18px; }
.grid-2 > section { margin-bottom: 0; }
.banner {
    padding: 12px 16px; border-radius: 8px; margin-bottom: 18px; font-size: 0.92em; line-height: 1.5;
    background: #fff8e1; color: #8a5a00; border: 1px solid #f5e1a4;
}
.banner.bad { background: #fdecea; color: #a8322a; border-color: #f5c6c0; }
.banner.ok { background: #e8f8ef; color: #1e7a46; border-color: #bfe8cf; }
.banner.updated-fresh { background: #e8f8ef; color: #1e7a46; border-color: #bfe8cf; }
.banner.updated-aging { background: #fffbe0; color: #7a6400; border-color: #f0e08a; }
.banner.updated-old { background: #fff0e0; color: #a0520a; border-color: #f5c99a; }
.banner.updated-stale { background: #fdecea; color: #a8322a; border-color: #f5c6c0; }

/* ── Controls ────────────────────────────────────────────────────────── */
button, .btn {
    font: inherit; font-size: 0.9em; font-weight: 500;
    padding: 7px 16px; border-radius: 6px; cursor: pointer;
    border: 1px solid var(--line-strong); background: var(--head); color: #444;
}
button:hover { background: #dde8ff; }
button.primary { background: var(--blue); border-color: var(--blue); color: #fff; }
button.primary:hover { background: #3b7fc6; }
button.danger { background: #fff; border-color: #f5c6c0; color: var(--red); }
button.danger:hover { background: #fdecea; }
button:disabled { opacity: 0.5; cursor: not-allowed; }
button.small { padding: 3px 10px; font-size: 0.82em; }
input[type=text], input[type=number], input[type=search], input[type=url], input[type=date], select {
    font: inherit; font-size: 0.9em;
    padding: 6px 10px; border: 1px solid var(--line-strong); border-radius: 6px; background: #f8faff;
}
input:focus, select:focus { outline: 2px solid var(--blue); outline-offset: -1px; background: #fff; }
label.field { display: flex; flex-direction: column; gap: 4px; font-size: 0.85em; color: #555; }
label.check { display: inline-flex; align-items: center; gap: 6px; font-size: 0.9em; cursor: pointer; }

/* ── Tables ──────────────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-size: 0.92em; }
th {
    background: var(--head); color: #444; padding: 9px 13px;
    text-align: left; font-weight: 600; border-bottom: 2px solid var(--line-strong);
    white-space: nowrap;
}
td { padding: 8px 13px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: var(--hover); }
tr.total-row td { background: #f8faff; border-top: 2px solid var(--line-strong); }
th.num, td.num, .amt { text-align: right; font-family: Consolas, 'SF Mono', monospace; }
th.sortable { cursor: pointer; user-select: none; }
th.sortable:hover { background: #dde8ff; }
.positive { color: var(--green); font-weight: 700; }
.negative { color: var(--red); font-weight: 700; }
.income-amt { color: var(--green); font-weight: 600; font-family: Consolas, monospace; text-align: right; }
.expense-amt { color: var(--red); font-family: Consolas, monospace; text-align: right; }
.zero { color: #ccc; }
.cat-badge {
    background: var(--head); color: var(--blue-text); border-radius: 4px;
    padding: 2px 8px; font-size: 0.82em; font-weight: 500; white-space: nowrap;
}
.cat-badge.credit-card { background: #fff0f6; color: #c0392b; }
.cat-badge.income { background: #e8f8ef; color: var(--green); }
.cat-badge.deposit { background: #e8f8ef; color: #1e7a46; } /* Savings → Account activity */
.cat-badge.withdrawal { background: #fdecea; color: #c0392b; }
.note-text { font-size: 0.85em; color: var(--muted); font-style: italic; }
td.edit-cell input, td.edit-cell select { width: 100%; min-width: 120px; }
tr.dirty td { background: #fffbea; }

/* ── Excel-style column filters ──────────────────────────────────────── */
.filter-table th { padding: 6px 8px 6px 13px; }
.th-inner { display: flex; align-items: center; gap: 6px; }
th.num .th-inner { justify-content: flex-end; }
.th-label { cursor: pointer; user-select: none; }
.th-label:hover { color: var(--blue-text); }
.fbtn {
    padding: 0 5px; min-width: 22px; height: 22px; line-height: 1; font-size: 0.8em;
    border-radius: 4px; background: #fff; border: 1px solid var(--line-strong); color: #666;
}
.fbtn:hover { background: #dde8ff; }
th.filtered { background: #e3edff; }
th.filtered .fbtn { background: var(--blue); border-color: var(--blue); color: #fff; }
th.filtered .fbtn::before { content: '⧩ '; font-size: 0.9em; }
.fmenu {
    position: absolute; z-index: 50; background: #fff; border: 1px solid var(--line-strong);
    border-radius: 8px; box-shadow: 0 8px 24px rgba(0,0,0,0.16); padding: 6px; font-size: 0.88em;
    display: flex; flex-direction: column; gap: 4px;
}
.fmenu-item { text-align: left; background: none; border: none; padding: 6px 8px; border-radius: 4px; font-weight: 400; }
.fmenu-item:hover { background: var(--head); }
.fmenu-sep { border-top: 1px solid var(--line); margin: 2px 0; }
.fmenu-search { width: 100%; }
.fmenu-all, .fmenu-row { display: flex; align-items: center; gap: 8px; padding: 3px 6px; cursor: pointer; border-radius: 4px; }
.fmenu-all { border-bottom: 1px solid var(--line); padding-bottom: 6px; }
.fmenu-row:hover { background: var(--hover); }
.fmenu-list { max-height: 260px; overflow-y: auto; }
.fmenu-label { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fmenu-count { color: var(--faint); font-size: 0.85em; font-variant-numeric: tabular-nums; }
.fmenu-more { color: var(--faint); font-style: italic; padding: 6px; }
.fmenu-actions { display: flex; gap: 6px; padding-top: 6px; border-top: 1px solid var(--line); }
.desc-cell { font-size: 0.85em; color: #666; max-width: 280px; }

/* ── Cards / badges ──────────────────────────────────────────────────── */
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 14px; margin-bottom: 18px; }
.card { background: var(--surface); border-radius: 10px; padding: 18px 22px; box-shadow: 0 1px 4px rgba(0,0,0,0.08); }
.card .label { font-size: 0.78em; text-transform: uppercase; letter-spacing: 0.5px; color: var(--muted); }
.card .value { font-size: 1.55em; font-weight: 700; margin-top: 6px; font-variant-numeric: tabular-nums; }
.card .sub { font-size: 0.78em; color: var(--faint); margin-top: 4px; }
.badge { display: inline-block; padding: 2px 9px; border-radius: 12px; font-size: 0.78em; font-weight: 600; }
.badge-ok { background: #e8f8ef; color: var(--green); }
.badge-warn { background: #fff8e1; color: var(--orange); }
.badge-over { background: #fdecea; color: var(--red); }
.badge-neutral { background: #f0f0f0; color: #999; }
.source-tag { font-size: 0.75em; padding: 1px 6px; border-radius: 10px; font-weight: 500; }
.source-edited { background: #f3e8ff; color: var(--purple); font-weight: 600; }
.source-ai { background: #e8f0fe; color: var(--blue-text); }
.source-history { background: #e6f7f7; color: #138d8d; }
.source-cache { background: #e8f8ef; color: var(--green); }
.source-rules { background: #fff8e1; color: var(--orange); }
.progress-bar { height: 10px; background: #eee; border-radius: 10px; overflow: hidden; margin: 6px 0 4px; }
.progress-fill { height: 100%; border-radius: 10px; background: linear-gradient(90deg, #4a90d9, #5ba3e8); }
.progress-label { display: flex; justify-content: space-between; font-size: 0.82em; color: #777; }

.log {
    background: #1a1a2e; color: #d6dbe6; font-family: Consolas, 'SF Mono', monospace; font-size: 0.82em;
    border-radius: 8px; padding: 12px 14px; max-height: 360px; overflow: auto; white-space: pre-wrap;
    line-height: 1.5;
}
.log .err { color: #ff9b8f; }
.log .ok { color: #8fe3ad; }
.log .dim { color: #8590a6; }
.summary-table td, .summary-table th { padding: 5px 10px; }

/* ── Charts ──────────────────────────────────────────────────────────── */
.chart-wrap { margin: 4px 0 22px; }
.chart-wrap canvas { display: block; width: 100%; }
.chart-legend { display: flex; flex-wrap: wrap; gap: 8px 20px; margin-bottom: 10px; font-size: 0.82em; color: #555; }
.chart-legend span { display: flex; align-items: center; gap: 6px; }
.legend-dot { width: 12px; height: 12px; border-radius: 2px; flex-shrink: 0; }
.legend-line { width: 18px; height: 2px; border-top: 2px dashed var(--green); flex-shrink: 0; }
.cat-toggle {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 4px 12px; border-radius: 20px; border: 1px solid var(--line-strong);
    background: var(--head); color: #666; font-size: 0.82em; cursor: pointer; user-select: none;
}
.cat-toggle .legend-dot { background: var(--cat-color); width: 9px; height: 9px; border-radius: 50%; }
.cat-toggle.active { background: var(--cat-color); border-color: var(--cat-color); color: #fff; font-weight: 500; }
.cat-toggle.active .legend-dot { background: rgba(255,255,255,0.7); }
.cat-toggle:not(.active) { opacity: 0.45; }
.ai-box { line-height: 1.7; color: #333; }
.ai-box p { margin-bottom: 12px; }
.ai-box ul { padding-left: 20px; margin-bottom: 12px; }
.ai-box li { margin-bottom: 6px; }

/* ── Config editor ───────────────────────────────────────────────────── */
.kv-row { display: grid; grid-template-columns: 1fr 140px 36px; gap: 8px; margin-bottom: 8px; align-items: center; }
.check-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 8px; }

/* ── Toast ───────────────────────────────────────────────────────────── */
#toast {
    position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%);
    display: flex; flex-direction: column; gap: 8px; z-index: 100; pointer-events: none;
}
#toast div {
    background: #1a1a2e; color: #fff; padding: 10px 18px; border-radius: 8px; font-size: 0.9em;
    box-shadow: 0 4px 14px rgba(0,0,0,0.2);
}
#toast div.bad { background: #a8322a; }
#toast div.ok { background: #1e7a46; }

@media (max-width: 640px) {
    /* On a phone the menu wraps to several rows; pinned, it would cover a fifth of the screen. */
    .topbar { padding: 10px 16px; gap: 6px 14px; position: static; }
    #nav a { padding: 5px 9px; }
    .merge-bar { top: 0; }
    section.loan, .loan .edit-mode .chart-title { scroll-margin-top: 8px; }
    .status { margin-left: 0; }
    section { padding: 16px; }
    section h2 { flex-wrap: wrap; } /* a link next to the heading goes under it */
    .kv-row { grid-template-columns: 1fr 100px 36px; }
}

.nowrap { white-space: nowrap; }
.dt-bar { display: flex; align-items: center; gap: 10px; font-size: 0.85em; color: var(--muted); margin-bottom: 8px; }

/* ── Dashboard ───────────────────────────────────────────────────────── */
.dash-head { margin-bottom: 4px; }
.month-nav { display: flex; align-items: center; gap: 6px; }
.month-nav select { font-weight: 600; min-width: 170px; }
.month-nav button { padding: 6px 12px; }
.kpis .value { font-size: 1.7em; }
.kpis .cmp { font-size: 0.82em; margin-top: 6px; line-height: 1.4; color: var(--muted); }
.delta-good { color: var(--green); font-weight: 600; }
.delta-bad { color: var(--red); font-weight: 600; }
.where-row {
    display: grid; grid-template-columns: minmax(120px, 190px) 1fr 100px minmax(120px, 170px);
    align-items: center; gap: 12px; width: 100%; text-align: left;
    background: none; border: none; border-radius: 6px; padding: 7px 8px; font-weight: 400;
}
.where-row:hover { background: var(--hover); }
.where-row.active { background: #e3edff; }
.where-name { font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.where-name .muted { font-size: 0.8em; font-weight: 400; }
.where-bar { height: 12px; background: #f0f2f7; border-radius: 6px; overflow: hidden; }
.where-bar span { display: block; height: 100%; background: #4a90d9; border-radius: 6px; }
.where-row.active .where-bar span { background: var(--navy-2); }
.where-amt { text-align: right; font-family: Consolas, 'SF Mono', monospace; font-weight: 600; }
.where-delta { font-size: 0.82em; }
.moved { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line); font-size: 0.9em; }
.chip { border-radius: 16px; padding: 4px 12px; font-size: 0.88em; background: var(--head); }
.chip.active { background: var(--navy-2); border-color: var(--navy-2); color: #fff; }
.dash-more { background: var(--surface); border-radius: 10px; padding: 14px 26px; margin-bottom: 18px; box-shadow: 0 1px 4px rgba(0,0,0,0.08); }
.dash-more > summary { cursor: pointer; font-weight: 600; color: #555; text-transform: uppercase; letter-spacing: 0.5px; font-size: 0.9em; }
.dash-more[open] > summary { margin-bottom: 14px; }
.dash-more h3 { font-size: 0.95em; color: #555; margin: 14px 0 8px; }
@media (max-width: 640px) {
    .where-row { grid-template-columns: 1fr 90px; }
    .where-bar { grid-column: 1 / -1; grid-row: 2; }
    .where-delta { grid-column: 1 / -1; }
}
.save-bar { display: flex; align-items: center; gap: 10px; padding: 8px 12px; margin-bottom: 10px; border-radius: 8px; background: #fffbea; border: 1px solid #f5e1a4; font-size: 0.9em; }
.cell-input { width: 100%; min-width: 110px; }
.merge-bar { position: sticky; top: 64px; z-index: 5; background: #eef4ff; border: 1px solid #c9dafc; border-radius: 8px; padding: 10px 14px; margin: 10px 0; font-size: 0.9em; }
.suggest-list { display: flex; flex-direction: column; gap: 4px; }
.suggest-row { display: flex; align-items: center; gap: 10px; padding: 6px 8px; border-radius: 6px; background: #f8faff; font-size: 0.9em; }
.suggest-names { flex: 1; }
.suggest-names small { color: var(--faint); }
tr.selected-row td { background: #eef4ff; }

/* ── Utilities ───────────────────────────────────────────────────────── */
.subnav { display: flex; flex-wrap: wrap; gap: 4px; margin: 6px 0 18px; border-bottom: 2px solid var(--line-strong); }
.subnav a {
    padding: 8px 16px; color: #666; text-decoration: none; font-weight: 500;
    border-bottom: 3px solid transparent; margin-bottom: -2px;
}
.subnav a:hover { color: var(--blue-text); }
.subnav a.active { color: var(--navy-2); border-bottom-color: var(--blue); }
.subnav a.bad { color: #c0392b; }
.subnav a.warn { color: #a07400; }
.subnav a.bad.active { border-bottom-color: #c0392b; }
.subnav a.warn.active { border-bottom-color: #e0b100; }
h2.page-sub { font-size: 1.2em; }
.bill-note { min-width: 240px; }
.ledger td:first-child { width: 100%; }
.ledger td.amt { white-space: nowrap; font-size: 1.05em; }
.ledger-sub { font-size: 0.82em; color: var(--muted); margin-top: 2px; }
.ledger-link { font-size: 0.82em; margin-left: 6px; }
.add-bill { margin-top: 14px; padding: 16px 18px; border: 1px solid var(--line-strong); border-radius: 8px; background: #f8faff; }
.add-bill h3 { font-size: 0.95em; color: #555; margin-bottom: 12px; }
.add-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; margin-bottom: 12px; }
.add-grid input, .add-grid select { width: 100%; }
.add-preview { font-size: 0.9em; color: #555; margin: 4px 0 12px; min-height: 1.2em; }
.ext-link { font-size: 0.85rem; font-weight: 600; text-transform: none; letter-spacing: 0; color: var(--blue-text); text-decoration: none; padding: 3px 10px; border: 1px solid var(--line-strong); border-radius: 14px; background: #fff; white-space: nowrap; }
.ext-link:hover { background: #dde8ff; }
.yr-charts { margin-top: 18px; }
.chart-title { font-size: 0.9em; color: #555; margin-bottom: 8px; }
.banner.row > span:first-child { flex: 1 1 320px; }
.banner.row > .spacer { flex: 0; }
.paid-tag { margin-left: 6px; text-transform: none; letter-spacing: 0; vertical-align: 1px; }
.paid-btn { margin-left: 6px; text-transform: none; letter-spacing: 0; padding: 2px 10px; }
.paid-undo { padding: 1px 8px; font-size: 0.75em; color: #888; background: #fff; }
.unpaid-list .nowrap { display: inline-flex; align-items: center; gap: 6px; margin: 2px 10px 2px 0; }
/* All bills tables: about half their full height, scrolling inside with the header kept in view. */
.short-table .table-wrap { max-height: 450px; overflow: auto; border: 1px solid var(--line); border-radius: 6px; }
.short-table thead th { position: sticky; top: 0; z-index: 1; }
.paid-edit { display: inline-flex; align-items: center; gap: 4px; }
.paid-edit input { padding: 2px 6px; font-size: 0.85em; }
.year-chips { gap: 6px; margin-bottom: 12px; }
/* Chart hover tooltip */
.chart-tip { position: fixed; z-index: 200; pointer-events: none; background: #1a1a2e; color: #fff; border-radius: 6px; padding: 7px 10px; font-size: 0.82em; line-height: 1.5; box-shadow: 0 4px 14px rgba(0,0,0,0.2); white-space: nowrap; }
.chart-tip .tip-head { font-weight: 600; margin-bottom: 2px; color: #cfd6e6; }
.tip-dot { display: inline-block; width: 9px; height: 9px; border-radius: 2px; margin-right: 6px; vertical-align: 0; }
/* Edit mode for the utility sheets */
.table-tools { gap: 8px; margin-bottom: 8px; font-size: 0.9em; }
.sheet-grid .table-wrap { max-height: 450px; overflow: auto; border: 1px solid var(--line-strong); border-radius: 6px; }
.sheet-table th { position: sticky; top: 0; z-index: 1; font-size: 0.85em; }
.sheet-table td { padding: 2px 4px; }
.sheet-table input { font: inherit; font-size: 0.88em; padding: 3px 6px; border: 1px solid transparent; border-radius: 4px; background: transparent; width: auto; }
.sheet-table input:hover { border-color: var(--line-strong); background: #fff; }
.sheet-table input:focus { border-color: var(--blue); background: #fff; }
.sheet-table input.changed { background: #fffbea; border-color: #f5e1a4; }
.sheet-table .rownum { color: var(--faint); font-size: 0.8em; text-align: right; }
/* Loan/CC */
.loan h2 .badge { font-size: 0.7em; text-transform: none; letter-spacing: 0; }
.loan-grid { max-height: 450px; overflow: auto; border: 1px solid var(--line-strong); border-radius: 6px; }
.loan-grid input[type=date] { width: 140px; }
.loan-grid input[type=number] { width: 110px; }
.loan-grid input[data-k=notes] { width: 100%; min-width: 180px; }
td input[data-k=minPayment] { width: 110px; }
.loan-tables > div + div { margin-top: 22px; }
.loan .cards { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
.acct-num { font-size: 0.72em; font-weight: 500; text-transform: none; letter-spacing: 0.5px; color: var(--muted); display: inline-flex; align-items: center; gap: 4px; font-family: Consolas, 'SF Mono', monospace; }
.acct-num button { padding: 0 6px; font-size: 0.9em; font-family: inherit; }
.badge-warn { color: var(--orange); font-weight: 600; }
/* Loan/CC: statuses, insights, planner */
.badge-plan { background: #e8f0fe; color: var(--blue-text); }
tr.planned-row td { font-style: italic; color: #7a8599; }
.insight-list { margin: 0 0 16px 18px; line-height: 1.6; font-size: 0.92em; }
.insight-list li { margin-bottom: 4px; }
details.planner { border: 1px solid var(--line-strong); border-radius: 8px; padding: 10px 16px; margin-bottom: 16px; background: #fbfcff; }
details.planner > summary { cursor: pointer; font-weight: 600; color: #444; }
details.planner[open] > summary { margin-bottom: 12px; }
.planner-controls { align-items: flex-end; gap: 14px; }
.planner-controls input[type=range] { flex: 1; min-width: 160px; margin-bottom: 8px; }
.planner-result { margin: 10px 0 8px; font-size: 0.95em; }
.scen-table td, .scen-table th { padding: 6px 10px; }
.scen-row { cursor: pointer; }
.scen-row:hover td { background: #eef4ff; }
/* Loan/CC: collapsible accounts */
.loan-head { cursor: pointer; user-select: none; }
.loan-chevron { color: var(--muted); width: 14px; display: inline-block; }
.loan-summary { display: flex; flex-wrap: wrap; gap: 6px 22px; font-size: 0.9em; color: #555; margin: -4px 0 4px; }
.loan:not(.collapsed) .loan-summary { display: none; }
section.loan.collapsed { padding-bottom: 14px; }
section.loan.collapsed h2 { margin-bottom: 8px; }
/* Loan/CC totals */
.totals-cards { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }
.totals-table td, .totals-table th { padding: 7px 10px; }
.totals-row { cursor: pointer; }
.totals-row:hover td { background: #eef4ff; }
section.loan, .loan .edit-mode .chart-title { scroll-margin-top: 70px; }
/* Savings */
.sav-cards { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }
.bucket-list { display: flex; flex-direction: column; gap: 2px; }
.bucket-row { display: grid; grid-template-columns: minmax(150px, 230px) 1fr 90px 110px 130px; align-items: center; gap: 12px; padding: 6px 8px; border-radius: 6px; list-style: none; cursor: pointer; font-size: 0.92em; }
.bucket-row::-webkit-details-marker { display: none; }
.bucket-row.static { cursor: default; }
.bucket-row:hover { background: var(--hover); }
details.bucket[open] > .bucket-row { background: #eef4ff; }
.b-name { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.b-amt { text-align: right; font-family: Consolas, 'SF Mono', monospace; font-weight: 600; }
.b-check { text-align: right; font-size: 0.88em; color: var(--green); }
.b-date { font-size: 0.82em; text-align: right; }
.b-notes { margin: 2px 8px 10px; padding: 10px 14px; background: #f8faff; border-left: 3px solid var(--line-strong); border-radius: 4px; font-size: 0.88em; line-height: 1.6; color: #444; }
/* Savings → Where the money is: the Grand total row under the buckets */
.bucket-total { margin-top: 10px; padding-top: 6px; border-top: 2px solid var(--line-strong); }
.bucket-total .bucket-row:hover { background: none; }
.bucket-total .b-name, .bucket-total .b-amt { font-weight: 700; }
.bucket-total .total-note { font-size: 0.82em; }
details.bucket-group { margin-top: 14px; }
details.bucket-group > summary { cursor: pointer; margin-bottom: 8px; }
.upd-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 10px; margin-bottom: 10px; }
.b-grid textarea, .loan-grid textarea { font: inherit; font-size: 0.85em; width: 260px; min-height: 34px; }
@media (max-width: 640px) {
    .bucket-row { grid-template-columns: 1fr 80px; }
    .bucket-row .where-bar, .bucket-row .b-check, .bucket-row .b-date, .bucket-row .total-note { display: none; }
}
.deposit-btn { padding: 2px 8px; font-size: 0.85em; color: var(--green); border-color: #bfe8cf; background: #f2fbf5; font-family: Consolas, 'SF Mono', monospace; }
.deposit-btn:hover { background: #dff5e7; }
.due-tag { color: var(--orange); font-weight: 600; font-size: 0.95em; }
/* Small tabs inside a utility (Electric: Bills / Mini-Splits) */
.pillnav { display: flex; flex-wrap: wrap; gap: 6px; margin: -6px 0 14px; }
.pillnav a { padding: 5px 14px; border-radius: 16px; background: var(--head); color: #555; text-decoration: none; font-size: 0.88em; border: 1px solid var(--line-strong); }
.pillnav a.active { background: var(--navy-2); border-color: var(--navy-2); color: #fff; }
.pillnav a.bad { background: #fdecea; border-color: #f5c6c0; color: #a8322a; }
.pillnav a.warn { background: #fff8e1; border-color: #f0d77a; color: #8a5a00; }
.pillnav a.bad.active { background: #c0392b; border-color: #c0392b; color: #fff; }
.pillnav a.warn.active { background: #f5c518; border-color: #e0b100; color: #3d2e00; }
/* Mini-splits */
.spec-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 10px 18px; font-size: 0.92em; }
.spec-label { display: block; font-size: 0.75em; text-transform: uppercase; letter-spacing: 0.4px; color: var(--muted); margin-bottom: 2px; }
section.unit h2 .badge { text-transform: none; letter-spacing: 0; font-size: 0.72em; }
.log-grid input[data-k=work], .log-grid input[data-k=notes] { width: 100%; min-width: 180px; }

/* Bills */
.late-cell { color: var(--orange); font-weight: 600; }
.missed-cell { color: var(--red); font-weight: 700; }
.bill-grid td, .bill-grid th { white-space: nowrap; font-size: 0.88em; }
.sched-tag { display: inline-block; padding: 1px 8px; border-radius: 10px; font-size: 0.8em; background: #e8f0fe; color: var(--blue-text); white-space: nowrap; }
.sched-tag.unsched { background: #f0f0f0; color: #888; }

/* Loan form */
.form-sub { font-size: 0.85em; text-transform: uppercase; letter-spacing: 0.4px; color: var(--muted); margin: 14px 0 8px; font-weight: 600; }
.form-sub:first-of-type { margin-top: 4px; }
.form-sub .muted { text-transform: none; letter-spacing: 0; font-weight: 400; }

/* ── Setup: Things to update ─────────────────────────────────────────── */
.due-list .banner { margin-bottom: 6px; padding: 8px 12px; }
.due-list .banner.row > span:first-child { flex: 1 1 320px; }
.due-where { display: inline-block; min-width: 110px; font-size: 0.8em; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; opacity: 0.8; }
