:root {
  --bg: #f5f4f0;
  --surface: #ffffff;
  --surface-2: #f9f8f5;
  --text: #1c1b18;
  --muted: #6d6a63;
  --border: #e5e2da;
  --brand: #2f5d50;
  --brand-strong: #234539;
  --brand-soft: #e8efeb;
  --on-brand: #ffffff;
  --pos: #2c7449;
  --neg: #b4443a;
  --warn: #8a5813;
  --line-prev: #98958c;   /* 3:1 on cards, picked with Adobe Leonardo, so last month's dashed line stays visible */
  --bar-inc: #bfd2c8;
  --shadow: 0 1px 2px rgba(28, 27, 24, 0.04);
  --radius: 12px;
  --font: "Source Sans 3", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #131312;
    --surface: #1b1b19;
    --surface-2: #171716;
    --text: #ecebe6;
    --muted: #9b988f;
    --border: #2b2a27;
    --brand: #8fbfa8;
    --brand-strong: #aad3bf;
    --brand-soft: #212c27;
    --on-brand: #13201b;
    --pos: #86c49e;
    --neg: #e08277;
    --warn: #d8a760;
    --line-prev: #69665f;
    --bar-inc: #34463e;
    --shadow: none;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
/* Source Sans runs small, so size the whole app up a touch. */
html { font-size: 106.25%; }
[hidden] { display: none !important; }
body {
  margin: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
svg { display: block; }

/* Layout */
.app { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }
.sidebar {
  position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column; gap: 24px;
  padding: 24px 16px; background: var(--surface); border-right: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 1.25rem; letter-spacing: -0.01em; color: var(--text); padding: 0 8px; }
.brand:hover { text-decoration: none; }
.tabs { display: flex; flex-direction: column; gap: 2px; }
.tabs a { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 10px; color: var(--muted); font-weight: 500; }
.tabs a:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.tabs a.active { background: var(--brand-soft); color: var(--brand); font-weight: 600; }
.tabs svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.sidebar-foot { margin-top: auto; display: flex; flex-direction: column; align-items: flex-start; gap: 6px; padding: 0 8px; }
.link-btn { background: none; border: 0; padding: 0; color: var(--muted); font-size: 0.875rem; cursor: pointer; }
.link-btn:hover { color: var(--text); }
.fine { font-size: 0.75rem; color: var(--muted); margin: 6px 0 0; }

.main { padding: 24px 32px 48px; min-width: 0; }
.topbar { display: flex; align-items: center; gap: 16px; margin-bottom: 24px; flex-wrap: wrap; }
.topbar h1 { font-size: 1.6rem; letter-spacing: -0.01em; margin: 0; margin-right: auto; }
.month-picker { display: flex; align-items: center; gap: 4px; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 4px; font-weight: 600; font-size: 0.9rem; }
.month-picker span { min-width: 130px; text-align: center; }

/* Buttons */
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 10px 18px; border-radius: 8px; border: 1px solid transparent; background: var(--brand); color: var(--on-brand); font-weight: 600; font-size: 0.9rem; cursor: pointer; white-space: nowrap; }
@media (prefers-color-scheme: dark) { .btn { color: #042f2e; } }
.btn:hover { background: var(--brand-strong); text-decoration: none; }
.btn-ghost { background: transparent; color: var(--text); border-color: var(--border); }
.btn-ghost:hover { background: var(--surface-2); }
.btn-sm { padding: 6px 12px; font-size: 0.82rem; }
.btn-danger-ghost { background: transparent; color: var(--neg); border-color: transparent; }
.btn-danger-ghost:hover { background: color-mix(in srgb, var(--neg) 10%, transparent); }
.icon-btn { width: 32px; height: 32px; display: inline-grid; place-items: center; border-radius: 999px; border: 0; background: transparent; color: var(--muted); cursor: pointer; font-size: 1.1rem; flex: none; }
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
/* Icons are from Lucide (ISC licence), copied in inline. */
.icon-btn svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.chip { border: 1px solid var(--border); background: var(--surface); border-radius: 999px; padding: 4px 10px; font-size: 0.75rem; font-weight: 600; cursor: pointer; white-space: nowrap; }
.chip:hover { border-color: var(--brand); color: var(--brand); }
.chip-done { background: var(--brand-soft); border-color: transparent; color: var(--brand); }
.chip-later { cursor: default; color: var(--muted); }
.chip-later:hover { border-color: var(--border); color: var(--muted); }

/* Cards */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); min-width: 0; }
.card + .card { margin-top: 16px; }
.card h3 { margin: 0; font-size: 1rem; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.small-link { font-size: 0.82rem; font-weight: 600; }
.empty { text-align: center; padding: 48px 24px; }
.empty p { color: var(--muted); max-width: 520px; margin: 8px auto 20px; }
.row-actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: inherit; }
.empty .row-actions { justify-content: center; }

.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 16px; }
.stats.three { grid-template-columns: repeat(3, 1fr); }
.stats.two { grid-template-columns: repeat(2, 1fr); }
.stats.five { grid-template-columns: repeat(5, 1fr); }
.stats.five .stat-value { font-size: clamp(1.25rem, 1.7vw, 1.65rem); }
.stats .card + .card { margin-top: 0; }
.stat-label { margin: 0; color: var(--muted); font-size: 0.82rem; font-weight: 500; }
.stat-value { margin: 4px 0 2px; font-size: 1.65rem; font-weight: 700; letter-spacing: -0.01em; font-variant-numeric: tabular-nums; }
.stat-sub { margin: 0; font-size: 0.8rem; color: var(--muted); }

.grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; align-items: stretch; }
.grid .card + .card { margin-top: 0; }
.span-2 { grid-column: span 2; }

.muted { color: var(--muted); }
.small { font-size: 0.82rem; }
.pos { color: var(--pos); }
.neg { color: var(--neg); }
.warn { color: var(--warn); }
p.muted { margin: 0; }
p.small { margin: 0 0 10px; }

/* Charts */
.chart { width: 100%; height: auto; overflow: visible; }
.chart .axis { font-size: var(--axis-fs, 11px); fill: var(--muted); }
.line-prev { fill: none; stroke: var(--line-prev); stroke-width: 2.5; stroke-dasharray: 5 5; }
.line-cur { fill: none; stroke: var(--brand); stroke-width: 3; stroke-linejoin: round; stroke-linecap: round; }
.line-area { fill: var(--brand); opacity: 0.08; }
.line-dot { fill: var(--surface); stroke: var(--brand); stroke-width: 3; }
.budget-line { stroke: var(--muted); stroke-width: 1; stroke-dasharray: 2 4; opacity: 0.7; }
.bar-inc { fill: var(--bar-inc); }
.bar-exp { fill: var(--brand); opacity: 0.55; }
.bar-exp.sel { opacity: 1; }
/* Bars grow up from the axis when their value changes (see animateChanges in app.js). */
.bar-inc, .bar-exp { transform-box: fill-box; transform-origin: bottom; }
.meter-top b, .ss-mile-top b { font-variant-numeric: tabular-nums; }
.legend { display: flex; gap: 14px; font-size: 0.78rem; color: var(--muted); }
.lg::before { content: ""; display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }
.lg-cur::before, .lg-exp::before { background: var(--brand); }
.lg-prev::before { background: var(--line-prev); }
.lg-inc::before { background: var(--bar-inc); }
.ring { width: 40px; height: 40px; flex: none; }
.ring circle { fill: none; stroke-width: 5; }
.ring-bg { stroke: var(--border); }
.ring-fg { stroke-linecap: round; }

/* Lists */
ul { list-style: none; margin: 0; padding: 0; }
.dot { width: 10px; height: 10px; border-radius: 50%; flex: none; }

.bills li { display: grid; grid-template-columns: 40px minmax(0, 1fr) auto; align-items: center; gap: 10px; padding: 9px 0; border-top: 1px solid var(--border); }
.bills li:first-child { border-top: 0; }
.bill-date { display: flex; flex-direction: column; align-items: center; font-size: 0.66rem; color: var(--muted); text-transform: uppercase; line-height: 1.1; background: var(--surface-2); border-radius: 8px; padding: 4px 0; }
.bill-date b { font-size: 1rem; color: var(--text); }
.bill-name { font-weight: 400; font-size: 0.9rem; display: flex; flex-direction: column; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bill-name small { overflow: hidden; text-overflow: ellipsis; }
.bill-name small { font-weight: 400; color: var(--muted); font-size: 0.75rem; }
.bill-amt { font-weight: 600; font-variant-numeric: tabular-nums; font-size: 0.9rem; }
.bill.paid .bill-name b { color: var(--muted); }
.bill.paid .bill-name b { text-decoration: line-through; }

.catbars { display: grid; gap: 12px; }
.catbars li { display: grid; grid-template-columns: 10px 110px 1fr 130px; align-items: center; gap: 10px; font-size: 0.88rem; }
.cb-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cb-bar { height: 8px; border-radius: 99px; background: var(--surface-2); border: 1px solid var(--border); overflow: hidden; }
.cb-bar i { display: block; height: 100%; border-radius: 99px; }
.cb-amt { text-align: right; font-weight: 600; font-variant-numeric: tabular-nums; }
.cb-amt small { color: var(--muted); font-weight: 400; }

.goals { display: grid; gap: 14px; }
.goals li { display: flex; gap: 12px; align-items: center; }
.goal-text { display: flex; flex-direction: column; font-size: 0.82rem; min-width: 0; }
.goal-text b { font-size: 0.9rem; }
.goal-text span:nth-child(2) { color: var(--muted); }

.txns li { border-top: 1px solid var(--border); }
.txns li:first-child { border-top: 0; }
.txn { width: 100%; display: flex; align-items: center; gap: 12px; padding: 10px 6px; background: none; border: 0; text-align: left; cursor: pointer; border-radius: 10px; }
.txn:hover { background: var(--surface-2); }
.txn-main { display: flex; flex-direction: column; flex: 1; min-width: 0; }
.txn-main b { font-weight: 600; font-size: 0.92rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.txn-main small { color: var(--muted); font-size: 0.78rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.txn-amt { font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
.badge { font-size: 0.7rem; font-weight: 600; background: var(--surface-2); border: 1px solid var(--border); color: var(--muted); padding: 2px 8px; border-radius: 99px; white-space: nowrap; }
.items { margin: -4px 6px 10px 28px; padding: 8px 12px; background: var(--surface-2); border-radius: 10px; font-size: 0.8rem; color: var(--muted); }
.items li { display: flex; justify-content: space-between; border: 0; padding: 2px 0; }
.txns.compact .txn { padding: 8px 2px; }

.toolbar { display: flex; gap: 10px; margin-bottom: 12px; flex-wrap: wrap; }
.toolbar input { flex: 1; min-width: 200px; }
input, select { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 9px 12px; width: 100%; min-width: 0; }
.toolbar select { width: auto; }
input:focus, select:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }

.budget-rows li { display: flex; align-items: center; gap: 14px; padding: 10px 0; border-top: 1px solid var(--border); }
.budget-rows li:first-child { border-top: 0; }
.br-name { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.br-name small { font-size: 0.78rem; padding-left: 8px; }
input.inline { border-color: transparent; background: transparent; font-weight: 600; padding: 4px 8px; }
input.inline:hover { border-color: var(--border); }
.money-input { display: flex; align-items: center; gap: 4px; width: 130px; flex: none; }
.money-input span { color: var(--muted); }
.money-input input { text-align: right; font-variant-numeric: tabular-nums; }

.liabs li { border-top: 1px solid var(--border); }
.liabs li:first-child { border-top: 0; }
.liab { width: 100%; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 6px; background: none; border: 0; text-align: left; cursor: pointer; border-radius: 10px; }
.liab:hover { background: var(--surface-2); }
.liab-main, .liab-right { display: flex; flex-direction: column; min-width: 0; }
.liab-right { text-align: right; flex: none; }
.liab small { font-size: 0.78rem; color: var(--muted); }
.liab-right small.neg { color: var(--neg); }
.liab b { font-variant-numeric: tabular-nums; }

.goal-cards { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(min(260px, 100%), 1fr)); gap: 14px; }
.goal-card { border: 1px solid var(--border); border-radius: 14px; padding: 16px; display: flex; flex-direction: column; gap: 8px; }
.gc-top { display: flex; gap: 12px; align-items: center; justify-content: space-between; }
.gc-top b { font-size: 1rem; }
.gc-amt { color: var(--muted); font-size: 0.9rem; }
.gc-amt b { font-size: 1.6rem; font-weight: 700; color: var(--text); font-variant-numeric: tabular-nums; letter-spacing: -0.01em; }
.goal-card small { font-size: 0.78rem; }
.goal-card .row-actions { margin-top: 6px; }
.goal-card p { margin: 0; }

/* Modal */
dialog { border: 1px solid var(--border); border-radius: 20px; padding: 0; width: min(520px, calc(100% - 32px)); background: var(--surface); color: var(--text); box-shadow: 0 30px 80px -20px rgba(0, 0, 0, 0.35); }
dialog::backdrop { background: rgba(15, 23, 42, 0.45); }
dialog form { padding: 20px; max-height: calc(100vh - 48px); overflow-y: auto; }
.modal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.modal-head h2 { font-size: 1.15rem; margin: 0; }
.modal-foot { display: flex; align-items: center; gap: 8px; margin-top: 18px; }
.spacer { flex: 1; }
.form-error { color: var(--neg); font-size: 0.85rem; margin: 10px 0 0; min-height: 1em; }
.form-error:empty { display: none; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.field { display: flex; flex-direction: column; gap: 4px; font-size: 0.8rem; color: var(--muted); font-weight: 500; }
.field input, .field select { color: var(--text); font-size: 0.95rem; }
.field.full { grid-column: 1 / -1; }
.seg { display: inline-flex; background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; padding: 3px; margin-bottom: 14px; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg span { display: block; padding: 6px 16px; border-radius: 7px; font-weight: 600; font-size: 0.85rem; color: var(--muted); cursor: pointer; }
.seg input:checked + span { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.seg input:focus-visible + span { outline: 2px solid var(--brand); }
.receipt { margin-top: 14px; border: 1px dashed var(--border); border-radius: 12px; padding: 10px 14px; }
.receipt summary { cursor: pointer; font-weight: 600; font-size: 0.9rem; }
.receipt[open] summary { margin-bottom: 10px; }
.item-rows { display: grid; gap: 8px; margin-bottom: 10px; }
.item-row { display: grid; grid-template-columns: 1fr 110px 32px; gap: 8px; align-items: center; }
.item-row .it-amt { text-align: right; }

/* Responsive */
@media (max-width: 1100px) {
  .stats, .stats.five { grid-template-columns: repeat(2, 1fr); }
  .stats.five .card:first-child { grid-column: 1 / -1; }
  .grid { grid-template-columns: 1fr 1fr; }
  .span-2 { grid-column: 1 / -1; }
}
@media (max-width: 760px) {
  .app { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed; bottom: 0; top: auto; left: 0; right: 0; height: auto; z-index: 20;
    flex-direction: row; padding: 6px 8px calc(6px + env(safe-area-inset-bottom)); border-right: 0; border-top: 1px solid var(--border);
  }
  .sidebar .brand, .sidebar-foot { display: none; }
  .tabs { flex-direction: row; width: 100%; justify-content: space-around; }
  .tabs a { flex-direction: column; gap: 2px; padding: 6px 4px; font-size: 0.68rem; flex: 1; text-align: center; }
  .main { padding: 16px 16px 96px; }
  .topbar { gap: 10px; }
  .topbar h1 { font-size: 1.35rem; }
  .month-picker { order: 3; width: 100%; justify-content: space-between; }
  .stats, .stats.three, .stats.five { grid-template-columns: 1fr 1fr; gap: 10px; }
  .stats.three .card:first-child { grid-column: 1 / -1; }
  .grid { grid-template-columns: 1fr; }
  .stat-value { font-size: 1.3rem; }
  .card { padding: 16px; }
  .catbars li { grid-template-columns: 10px 1fr 110px; }
  .catbars .cb-bar { grid-column: 2 / -1; grid-row: 2; }
  .form-grid { grid-template-columns: 1fr; }
  .money-input { width: 110px; }
  .item-row { grid-template-columns: 1fr 90px 32px; }
}

/* Calculator flyout */
.calc-toggle svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.calc-toggle[aria-expanded="true"] { background: var(--brand-soft); color: var(--brand); border-color: transparent; }
.calc {
  position: fixed; top: 16px; right: 16px; z-index: 50; max-height: calc(100vh - 32px);
  width: 320px; display: flex; flex-direction: column; gap: 12px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 20px; padding: 16px;
  box-shadow: 0 30px 80px -20px rgba(0, 0, 0, 0.35);
  animation: calc-in 0.18s ease-out;
}
@keyframes calc-in { from { transform: translateX(24px); opacity: 0; } to { transform: none; opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .calc { animation: none; } }
.calc-head { display: flex; align-items: center; justify-content: space-between; }
.calc-head h2 { margin: 0; font-size: 1rem; }
.calc-tape { list-style: none; margin: 0; padding: 0; max-height: 220px; min-height: 24px; overflow-y: auto; display: flex; flex-direction: column; justify-content: flex-end; gap: 4px; }
.calc-tape li { display: flex; justify-content: space-between; gap: 12px; font-size: 0.8rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.calc-tape li button { background: none; border: 0; padding: 0; cursor: pointer; color: inherit; text-align: left; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.calc-tape li .tape-res { flex: none; color: var(--text); font-weight: 600; text-align: right; }
.calc-tape li button:hover { color: var(--brand); }
.calc-tape .tape-empty { justify-content: center; font-style: italic; }
.calc-display { background: var(--surface-2); border: 1px solid var(--border); border-radius: 14px; padding: 10px 14px; text-align: right; }
.calc-display input { border: 0; background: transparent; padding: 0; text-align: right; font-size: 1.05rem; color: var(--muted); font-variant-numeric: tabular-nums; box-shadow: none; }
.calc-display input:focus { box-shadow: none; }
.calc-display output { display: block; font-size: 2rem; font-weight: 700; letter-spacing: -0.01em; min-height: 2.4rem; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.calc-display output.err { color: var(--neg); font-size: 1rem; font-weight: 600; padding-top: 10px; }
.calc-keys { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.calc-keys button { height: 48px; border-radius: 12px; border: 1px solid var(--border); background: var(--surface); font-size: 1.1rem; font-weight: 600; cursor: pointer; }
.calc-keys button:hover { background: var(--surface-2); }
.calc-keys button:active { transform: scale(0.97); }
.calc-keys .k-fn { color: var(--muted); }
.calc-keys .k-op { color: var(--brand); background: var(--brand-soft); border-color: transparent; }
.calc-keys .k-eq { background: var(--brand); color: var(--on-brand); border-color: transparent; }
@media (prefers-color-scheme: dark) { .calc-keys .k-eq { color: #042f2e; } }
.calc-head-tools { display: flex; align-items: center; gap: 8px; }
.calc-insert { width: 100%; justify-content: center; white-space: normal; text-align: center; line-height: 1.3; }
.calc-insert:disabled { background: var(--surface-2); color: var(--muted); cursor: default; }
input.calc-target { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
@media (min-width: 761px) { body.calc-open .main { padding-right: 368px; } }
@media (max-width: 760px) {
  .calc-toggle span { display: none; }
  .calc-toggle { padding: 9px; }
  .calc { top: auto; left: 0; right: 0; bottom: 0; width: auto; max-height: 82vh; border-radius: 20px 20px 0 0; padding-bottom: calc(16px + env(safe-area-inset-bottom)); animation-name: calc-up; }
  .calc-tape { max-height: 22vh; }
  .calc-keys button { height: 52px; }
  @keyframes calc-up { from { transform: translateY(24px); opacity: 0; } to { transform: none; opacity: 1; } }
}
.modal-tools { display: flex; gap: 2px; }
.calc-open svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.form-note { color: var(--brand); font-size: 0.82rem; margin: 10px 0 0; }
.form-note:empty { display: none; }
.save-status { color: var(--pos); }
.save-status::before { content: "✓ "; }
.save-status.neg::before { content: "! "; }

/* Top spending and tips */
.topcats { list-style: none; margin: 0; padding: 0; display: grid; gap: 14px; }
.topcats li { display: flex; gap: 12px; align-items: flex-start; }
.tc-rank { width: 24px; height: 24px; flex: none; display: grid; place-items: center; border-radius: 50%; background: var(--surface-2); border: 1px solid var(--border); font-size: 0.75rem; font-weight: 700; color: var(--muted); }
.tc-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.tc-line { display: flex; align-items: center; gap: 8px; }
.tc-name { font-weight: 600; font-size: 0.9rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tc-amt { margin-left: auto; font-variant-numeric: tabular-nums; }
.tc-bar { height: 6px; border-radius: 99px; background: var(--surface-2); overflow: hidden; }
.tc-bar i { display: block; height: 100%; border-radius: 99px; }
.topcats small { font-size: 0.75rem; }
.tag { font-size: 0.68rem; font-weight: 600; padding: 2px 8px; border-radius: 99px; background: var(--surface-2); color: var(--muted); border: 1px solid var(--border); white-space: nowrap; flex: none; }
.tag-flex { background: color-mix(in srgb, var(--warn) 12%, transparent); color: var(--warn); border-color: transparent; }
.tag-btn { cursor: pointer; font-family: inherit; }
.tag-btn:hover { border-color: var(--brand); }
.head-stat { margin-left: auto; font-size: 0.85rem; color: var(--muted); white-space: nowrap; }
.head-stat b { font-variant-numeric: tabular-nums; }
.tips { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; }
.tip { border: 1px solid var(--border); border-radius: 12px; padding: 14px 16px; display: flex; flex-direction: column; gap: 2px; }
.tip-head { display: flex; align-items: center; gap: 8px; font-size: 0.9rem; margin-bottom: 6px; }
.tip-name { background: none; border: 0; padding: 0; font-weight: 600; cursor: pointer; }
.tip-name.spent-link { text-decoration: none; }
.tip-name.spent-link:hover { text-decoration: underline; }
.card-fill > .tips { flex: 1; }
.tip-head .tag { margin-left: auto; }
.tip-save { margin: 0; font-size: 0.85rem; color: var(--muted); }
.tip-save b { font-size: 1.6rem; font-weight: 700; color: var(--pos); font-variant-numeric: tabular-nums; letter-spacing: -0.01em; }
.tip-move { margin: 0 0 10px; font-size: 0.85rem; }
.tip-bar { margin-top: auto; display: flex; height: 6px; border-radius: 99px; overflow: hidden; background: var(--surface-2); gap: 2px; }
.tip-bar i { display: block; height: 100%; background: var(--line-prev); }
.tip-bar i.cut { background: var(--pos); }
.tip-foot { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; margin-top: 8px; font-size: 0.78rem; color: var(--muted); }
.tip-foot > span { font-variant-numeric: tabular-nums; }
.tip-more { text-align: right; }
.tip-more summary { cursor: pointer; color: var(--brand); font-weight: 600; list-style: none; }
.tip-more summary::-webkit-details-marker { display: none; }
.tip-more summary::after { content: " ›"; }
.tip-more[open] summary::after { content: " ‹"; }
.tip-more[open] { flex-basis: 100%; text-align: left; }
.tip-foot:has(.tip-more[open]) { flex-wrap: wrap; }
.tip-ideas { list-style: none; padding: 0; margin: 6px 0 0; display: grid; gap: 4px; }
.tip-ideas li { font-size: 0.8rem; color: var(--muted); padding-left: 14px; position: relative; }
.tip-ideas li::before { content: "•"; position: absolute; left: 2px; color: var(--brand); }
/* Phones: swipe through tips side by side instead of stacking three tall cards. */
@media (max-width: 760px) {
  .tips { display: flex; overflow-x: auto; scroll-snap-type: x mandatory; margin: 0 -16px; padding: 0 16px 4px; scroll-padding: 0 16px; scrollbar-width: none; }
  .tips::-webkit-scrollbar { display: none; }
  .tip { flex: 0 0 78%; scroll-snap-align: start; }
}
.tc-meta { display: flex; gap: 10px; font-variant-numeric: tabular-nums; }
/* A labelled progress bar: label and value on top, thin track below. */
.meter { margin-bottom: 6px; }
.meter-top { display: flex; justify-content: space-between; font-size: 0.82rem; color: var(--muted); margin-bottom: 6px; }
.meter-top b { color: var(--text); font-variant-numeric: tabular-nums; }
.meter-top small { color: var(--muted); font-weight: 400; font-size: inherit; }
.meter-track { height: 6px; border-radius: 99px; background: var(--surface-2); overflow: hidden; }
.meter-track i { display: block; height: 100%; background: var(--brand); border-radius: 99px; }
/* Short status label; the full sentence is in its title. Color only when it means something. */
.status { font-size: 0.72rem; font-weight: 600; padding: 2px 8px; border-radius: 99px; white-space: nowrap; flex: none; background: var(--surface-2); color: var(--muted); }
.status-pos { background: color-mix(in srgb, var(--pos) 12%, transparent); color: var(--pos); }
.status-warn { background: color-mix(in srgb, var(--warn) 12%, transparent); color: var(--warn); }
.status-neg { background: color-mix(in srgb, var(--neg) 12%, transparent); color: var(--neg); }
.goals .goal-text { flex: 1; }
.goals .status { margin-left: auto; }
.facts { display: flex; flex-wrap: wrap; gap: 8px 28px; margin: 10px 0 6px; }
.facts div { display: flex; flex-direction: column-reverse; }
.facts dt { font-size: 0.75rem; color: var(--muted); }
.facts dd { margin: 0; font-size: 1.1rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.pt-amt small { font-weight: 400; color: var(--muted); font-size: 0.8rem; }
.sb-facts { display: flex; flex-wrap: wrap; gap: 4px 16px; }
.sb-facts b { color: var(--text); font-variant-numeric: tabular-nums; }

/* Spending chart: fills its card */
.card-fill { align-self: stretch; display: flex; flex-direction: column; }
.chart-fill { flex: 1; display: flex; align-items: flex-end; min-height: 0; }
.chart-fill .chart { width: 100%; }
.grid-line { stroke: var(--border); stroke-width: 1; }
.line-proj { fill: none; stroke: var(--brand); stroke-width: 2; stroke-dasharray: 3 5; opacity: 0.7; }
.chart .proj-label { fill: var(--brand); font-weight: 600; }
.lg-proj::before { background: none; border: 2px dotted var(--brand); width: 6px; height: 6px; }
.chart-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-bottom: 14px; }
.chart-stats div { background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; padding: 8px 12px; display: flex; flex-direction: column; min-width: 0; }
.chart-stats span { font-size: 0.72rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chart-stats b { font-size: 1.05rem; font-variant-numeric: tabular-nums; }
@media (max-width: 760px) { .chart-stats { grid-template-columns: 1fr 1fr; } }

/* Totals for the transactions on screen */
.view-totals { position: sticky; top: 0; z-index: 2; display: flex; align-items: center; gap: 20px; flex-wrap: wrap; background: var(--surface-2); border: 1px solid var(--border); border-radius: 12px; padding: 10px 14px; margin-bottom: 10px; }
.vt-count { flex: 1; min-width: 160px; font-size: 0.82rem; color: var(--muted); }
.vt-count .link-btn { color: var(--brand); font-size: inherit; font-weight: 600; }
.vt-cell { display: flex; flex-direction: column; align-items: flex-end; }
.vt-cell span { font-size: 0.7rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }
.vt-cell b { font-variant-numeric: tabular-nums; font-size: 0.95rem; }
.vt-net b { font-size: 1.25rem; }
@media (max-width: 760px) { .view-totals { gap: 14px; } .vt-count { flex-basis: 100%; } }

/* Autocomplete */
.ac-wrap { position: relative; }
.ac-list { position: absolute; left: 0; right: 0; top: 100%; margin-top: 4px; z-index: 30; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: 0 12px 30px -10px rgba(0, 0, 0, 0.35); padding: 4px; max-height: 260px; overflow-y: auto; }
.ac-list li { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 8px 10px; border-radius: 8px; cursor: pointer; color: var(--text); font-size: 0.9rem; }
.ac-list li small { color: var(--muted); font-size: 0.75rem; white-space: nowrap; }
.ac-list li.on, .ac-list li:hover { background: var(--brand-soft); }
.item-row .ac-list { min-width: 220px; }

/* Category totals link to their transactions */
.spent-link { background: none; border: 0; padding: 0; font: inherit; color: inherit; cursor: pointer; text-align: left; text-decoration: underline; text-decoration-color: color-mix(in srgb, currentColor 35%, transparent); text-underline-offset: 3px; }
.spent-link:hover { color: var(--brand); text-decoration-color: currentColor; }
.tc-name.spent-link, .cb-name.spent-link { text-decoration: none; }
.tc-name.spent-link:hover, .cb-name.spent-link:hover { text-decoration: underline; }

/* Income, budget sub-menu */
.income-card { display: flex; align-items: center; gap: 20px; flex-wrap: wrap; margin-bottom: 16px; }
.income-card p { margin: 0; flex: 1; min-width: 200px; }
.income-field { display: flex; flex-direction: column; gap: 4px; font-size: 0.8rem; color: var(--muted); font-weight: 500; }
.money-input.big { width: 200px; }
.money-input.big input { font-size: 1.25rem; font-weight: 700; color: var(--text); text-align: left; }
.subtabs { display: flex; gap: 4px; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 4px; margin-bottom: 16px; width: fit-content; max-width: 100%; overflow-x: auto; }
.subtabs a { padding: 8px 16px; border-radius: 7px; color: var(--muted); font-weight: 600; font-size: 0.88rem; white-space: nowrap; display: inline-flex; align-items: center; gap: 6px; }
.subtabs a:hover { text-decoration: none; color: var(--text); }
.subtabs a.on { background: var(--brand-soft); color: var(--brand); }
.subtabs .count { background: var(--neg); color: #fff; border-radius: 99px; font-size: 0.7rem; padding: 1px 7px; }

/* Plans */
.plans-layout { display: grid; grid-template-columns: 280px minmax(0, 1fr); gap: 16px; align-items: start; }
.plan-list { display: grid; gap: 8px; position: sticky; top: 16px; }
.plan-item { width: 100%; text-align: left; background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 12px 14px; cursor: pointer; display: flex; flex-direction: column; gap: 3px; }
.plan-item:hover { border-color: var(--brand); }
.plan-item.sel { border: 2px solid var(--brand); padding: 11px 13px; background: var(--brand-soft); }
.pi-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.plan-item small { color: var(--muted); font-size: 0.78rem; }
.pi-save { font-size: 0.78rem; font-weight: 600; color: var(--pos); }
.tag-rec { background: var(--brand); color: var(--on-brand); border-color: transparent; }
.tag-on { background: var(--pos); color: #fff; border-color: transparent; }
.tag-high { background: color-mix(in srgb, var(--neg) 14%, transparent); color: var(--neg); border-color: transparent; }
.plan-detail .card + .card { margin-top: 16px; }
.plan-about { margin: 0 0 4px; font-size: 0.92rem; }
.split-bar { display: flex; height: 14px; border-radius: 99px; overflow: hidden; background: var(--surface-2); margin: 14px 0 8px; }
.split-bar i, .split-legend i { display: block; height: 100%; }
.split-legend { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 0.8rem; color: var(--muted); }
.split-legend span { display: inline-flex; align-items: center; gap: 6px; }
.split-legend i { width: 10px; height: 10px; border-radius: 3px; }
.sb-needs { background: #64748b; } .sb-wants { background: #d97706; } .sb-save { background: var(--pos); } .sb-debt { background: #2563eb; }
.plan-notes { margin: 12px 0 0; padding: 10px 14px; background: var(--surface-2); border-radius: 10px; display: grid; gap: 4px; }
.plan-notes li { font-size: 0.82rem; color: var(--muted); }
.plan-table { width: 100%; border-collapse: collapse; margin-top: 14px; font-size: 0.88rem; }
.plan-table th { text-align: left; font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); font-weight: 600; padding: 6px 4px; border-bottom: 1px solid var(--border); }
.plan-table th:not(:first-child), .plan-table td:not(:first-child) { text-align: right; white-space: nowrap; }
.plan-table td { padding: 8px 4px; border-bottom: 1px solid var(--border); font-variant-numeric: tabular-nums; }
.plan-table tr.locked td { color: var(--muted); }
.plan-table tr.save-row td { font-weight: 700; color: var(--pos); }
.plan-table .tag { margin-left: 6px; }
.plan-actions { margin-top: 16px; align-items: center; }
.zero-line { stroke: var(--muted); opacity: 0.6; }
.outlook-facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(118px, 1fr)); gap: 10px; margin-top: 12px; }
.outlook-facts div { background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; display: flex; flex-direction: column; }
.outlook-facts span { font-size: 0.72rem; color: var(--muted); }
.outlook-facts b { font-size: 1.1rem; font-variant-numeric: tabular-nums; }
.outlook-facts small { font-size: 0.72rem; color: var(--muted); }

/* Patterns */
.pattern { border: 1px solid var(--border); border-left: 4px solid var(--warn); border-radius: 12px; padding: 14px 16px; margin-top: 12px; }
.pattern-high { border-left-color: var(--neg); }
.pt-head { display: flex; align-items: center; gap: 10px; }
.pt-amt { margin-left: auto; font-weight: 700; font-variant-numeric: tabular-nums; }
.pattern p { margin: 8px 0 0; font-size: 0.9rem; }
.pattern .link-btn { margin-top: 6px; color: var(--brand); font-weight: 600; }
.minor-head { margin: 20px 0 8px; font-size: 0.85rem; color: var(--muted); }
.minor-list li { display: flex; justify-content: space-between; gap: 12px; padding: 6px 0; border-top: 1px solid var(--border); font-size: 0.88rem; }
.strain-banner { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; background: color-mix(in srgb, var(--neg) 9%, var(--surface)); border: 1px solid color-mix(in srgb, var(--neg) 35%, transparent); border-radius: var(--radius); padding: 14px 18px; margin-bottom: 16px; }
.strain-banner > div:nth-child(2) { flex: 1; min-width: 220px; }
.strain-banner p { margin: 2px 0 0; font-size: 0.85rem; color: var(--muted); }
.sb-icon { width: 30px; height: 30px; border-radius: 50%; background: var(--neg); color: #fff; display: grid; place-items: center; font-weight: 800; flex: none; }
@media (max-width: 900px) {
  .plans-layout { grid-template-columns: 1fr; }
  .plan-list { position: static; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); }
}
@media (max-width: 760px) {
  .plan-table { font-size: 0.8rem; }
  .plan-table .tag { display: none; }
  .money-input.big { width: 100%; }
}
.pi-cut { font-size: 0.74rem; color: var(--warn); } .pi-cut.neg { color: var(--neg); }

/* ---------- plan guide ---------- */
.plan-table tr.sub-row td { font-size: 0.8rem; color: var(--muted); padding-top: 4px; padding-bottom: 4px; }
.plan-table tr.sub-row td:first-child { padding-left: 18px; }
.guide { margin-top: 16px; }
.guide summary { cursor: pointer; list-style: none; display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; font-weight: 600; }
.guide summary::-webkit-details-marker { display: none; }
.guide summary::before { content: '›'; display: inline-block; width: 12px; color: var(--muted); transition: transform .15s; }
.guide[open] summary::before { transform: rotate(90deg); }
.guide summary small { font-weight: 400; font-size: 0.8rem; }
.guide-body { margin-top: 12px; font-size: 0.88rem; }
.guide-body h4 { margin: 0 0 8px; font-size: 0.9rem; }
.guide-body ol, .guide-body ul { margin: 0; padding-left: 20px; list-style: revert; display: grid; gap: 6px; color: var(--muted); }
.guide-body a { color: var(--brand); font-weight: 600; }
.guide-cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(260px, 100%), 1fr)); gap: 20px; margin-top: 18px; }
.table-wrap { overflow-x: auto; }
.guide-table { margin-top: 0; }
.guide-table th:not(:first-child), .guide-table td:not(:first-child) { text-align: left; white-space: normal; }
.guide-table td { vertical-align: top; }
.guide-table td:first-child { white-space: nowrap; }
.guide-inline { margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--border); }
.guide-inline summary { font-size: 0.85rem; color: var(--muted); }
@media (max-width: 720px) { .guide-table { min-width: 560px; } }

@media (max-width: 1100px) { .grid { grid-auto-flow: row dense; } }

/* ---------- budget bubbles ---------- */
.bubbles { flex: 1; display: grid; grid-template-columns: minmax(0, 1fr) 240px; gap: 20px; min-height: 340px; }
.bubble-stage { position: relative; min-height: 320px; border-radius: 10px; background: var(--surface-2); border: 1px solid var(--border); overflow: hidden; touch-action: none; }
.bubble-stage svg { position: absolute; inset: 0; width: 100%; height: 100%; }
.bubble-stage > p { padding: 20px; margin: 0; }
.bubble { cursor: grab; outline: none; transition: opacity .15s; }
.bubble.grab { cursor: grabbing; }
.bubble.dim { opacity: 0.35; }
.bubble .b-fill { fill: color-mix(in srgb, var(--c) 78%, var(--surface)); stroke: color-mix(in srgb, var(--c) 60%, var(--text) 10%); stroke-width: 1; transition: r .2s; }
.bubble:hover .b-fill, .bubble:focus-visible .b-fill { stroke: var(--text); stroke-width: 2; }
.bubble.over .b-fill { stroke: var(--neg); stroke-width: 2.5; }
.bubble .b-ring { fill: none; stroke: var(--muted); stroke-width: 1.2; stroke-dasharray: 4 4; opacity: 0.7; }
.bubble text { text-anchor: middle; pointer-events: none; fill: #fff; font-weight: 700; paint-order: stroke; stroke: rgba(0,0,0,0.18); stroke-width: 2px; }
.bubble .b-amt { font-weight: 600; opacity: 0.92; }
.bubble-tip { position: absolute; left: 0; top: 0; pointer-events: none; background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; font-size: 0.8rem; display: flex; flex-direction: column; min-width: 150px; box-shadow: 0 6px 20px -8px rgba(0,0,0,0.35); z-index: 2; }
.bubble-side { display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.bubble-rank { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.bubble-rank button { width: 100%; display: grid; grid-template-columns: 10px minmax(0, 1fr) auto; align-items: center; gap: 10px; padding: 6px 8px; border: 0; background: none; border-radius: 8px; cursor: pointer; text-align: left; font-size: 0.86rem; }
.bubble-rank li.hot button, .bubble-rank button:hover { background: var(--surface-2); }
.bubble-rank .dot { width: 10px; height: 10px; border-radius: 50%; }
.br-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.br-amt { font-weight: 700; font-variant-numeric: tabular-nums; }
.br-amt small { font-weight: 400; color: var(--muted); }
.bubble-idle, .bubble-key { margin: 0; }
.bubble-key { margin-top: auto; display: flex; gap: 8px; align-items: flex-start; }
.key-ring { flex: none; width: 14px; height: 14px; border-radius: 50%; border: 1.5px dashed var(--muted); margin-top: 2px; }
@media (max-width: 900px) { .bubbles { grid-template-columns: 1fr; } .bubble-stage { min-height: 300px; } }

/* ---------- savings snapshot ---------- */
.savings-snap { margin-top: auto; padding-top: 16px; border-top: 1px solid var(--border); display: grid; gap: 14px; }
.ss-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.ss-stats div { display: flex; flex-direction: column; }
.ss-stats span, .ss-stats small { font-size: 0.75rem; color: var(--muted); }
.ss-stats b { font-size: 1.25rem; font-variant-numeric: tabular-nums; }
.ss-chart { display: grid; grid-template-columns: repeat(6, 1fr); gap: 8px; height: 110px; }
.ss-col { display: grid; grid-template-rows: 1fr 1fr auto; min-width: 0; }
.ss-half { display: flex; justify-content: center; }
.ss-half.up { align-items: flex-end; border-bottom: 1px solid var(--border); }
.ss-half.down { align-items: flex-start; }
.ss-half i { width: 60%; max-width: 28px; border-radius: 3px; }
.ss-half.up i { background: var(--pos); opacity: .8; border-radius: 3px 3px 0 0; }
.ss-half.down i { background: var(--neg); opacity: .8; border-radius: 0 0 3px 3px; }
.ss-col span { font-size: 0.7rem; color: var(--muted); text-align: center; margin-top: 4px; }
.ss-mile { display: grid; gap: 6px; }
.ss-mile-top { display: flex; justify-content: space-between; gap: 8px; font-size: 0.82rem; }
.ss-mile-top b { font-variant-numeric: tabular-nums; white-space: nowrap; }
.ss-track { height: 6px; border-radius: 3px; background: var(--surface-2); border: 1px solid var(--border); overflow: hidden; }
.ss-track i { display: block; height: 100%; background: var(--brand); }

/* ---------- info tooltips ---------- */
.card-head h3, .stat-label { display: flex; align-items: center; gap: 6px; }
.info { position: relative; flex: none; display: inline-grid; place-items: center; width: 16px; height: 16px; border-radius: 50%; border: 1px solid var(--border); color: var(--muted); font: italic 600 10px/1 Georgia, "Times New Roman", serif; cursor: help; user-select: none; }
.info:hover, .info:focus-visible { color: var(--text); border-color: var(--muted); outline: none; }
.info::after { content: attr(data-tip); position: absolute; top: calc(100% + 8px); left: -8px; z-index: 20; width: max-content; max-width: 260px; padding: 8px 10px; border-radius: 8px; background: var(--text); color: var(--bg); font: 400 0.78rem/1.45 var(--font); letter-spacing: 0; text-transform: none; white-space: normal; display: none; pointer-events: none; box-shadow: 0 8px 24px -10px rgba(0,0,0,.4); }
.info:hover::after, .info:focus::after { display: block; }
@media (max-width: 760px) { .info::after { max-width: min(260px, 70vw); } }
.plan-actions { align-items: center; }
.savings-snap.no-neg .ss-col { grid-template-rows: 1fr 0 auto; }
.savings-snap.no-neg .ss-chart { height: 90px; }

/* ---------- spending vs income lines ---------- */
.line-spend { stroke: var(--text); }
.line-spend-dot { stroke: var(--text); }
.line-income { fill: none; stroke: var(--pos); stroke-width: 2.5; stroke-linejoin: round; stroke-linecap: round; }
.gap-neg { fill: var(--neg); opacity: 0.32; }
.gap-pos { fill: var(--text); opacity: 0.08; }   /* a light grey on light and dark themes alike */
@media (prefers-color-scheme: dark) { .gap-pos { opacity: 0.1; } }
.net-label { font-weight: 700; fill: var(--text); }
.net-label.neg { fill: var(--neg); }
.lg-spend::before { background: var(--text); }
.lg-incline::before { background: var(--pos); }
.line-proj { stroke: var(--text); opacity: 0.45; }
.chart .proj-label { fill: var(--muted); }
.lg-proj::before { border-color: var(--muted); }
.line-spend, .line-income, .line-prev, .line-proj, .line-spend-dot { vector-effect: non-scaling-stroke; }

/* ---------- mobile app layout ---------- */
.fab, .lbl-short, #monthLabelShort { display: none; }
@media (max-width: 760px) {
  /* Add transaction floats bottom right, where a thumb already is. */
  #addTxnBtn { display: none; }
  .fab { display: grid; place-items: center; position: fixed; right: 16px; bottom: calc(80px + env(safe-area-inset-bottom)); z-index: 21; width: 56px; height: 56px; padding: 0; border: 0; border-radius: 50%; background: var(--brand); color: var(--on-brand); cursor: pointer; box-shadow: 0 8px 20px -6px rgba(0, 0, 0, 0.35); }
  .fab svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; }
  .fab:active { transform: scale(0.94); }
  .fab:focus-visible { outline: 3px solid var(--brand-soft); outline-offset: 2px; }
  .lbl-long, #monthLabel { display: none; }
  .lbl-short, #monthLabelShort { display: inline; }
  .tabs { align-items: center; }
  .tabs a { min-height: 50px; justify-content: center; font-size: 0.66rem; }
  .tabs a svg { width: 22px; height: 22px; }
  .sidebar { background: color-mix(in srgb, var(--surface) 92%, transparent); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); }

  /* Compact sticky header: title, month and calculator on one row. */
  .main { padding: 0 16px calc(156px + env(safe-area-inset-bottom)); }
  .topbar { position: sticky; top: 0; z-index: 15; flex-wrap: nowrap; gap: 8px; margin: 0 -16px 14px; padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
    background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); border-bottom: 1px solid transparent; }
  .topbar h1 { font-size: 1.2rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
  .month-picker { order: 0; width: auto; flex: none; font-size: 0.85rem; padding: 2px; }
  .month-picker .icon-btn { width: 34px; height: 34px; }
  .month-picker span { min-width: 72px; }
  .month-picker { justify-content: center; }
  .card-head { flex-wrap: wrap; row-gap: 6px; }
  .legend { gap: 10px; font-size: 0.72rem; flex-wrap: wrap; }
  .strain-banner .sb-icon { display: none; }
  .calc-toggle { width: 40px; height: 40px; padding: 0; justify-content: center; flex: none; }

  /* Forms open as bottom sheets. */
  dialog { width: 100%; max-width: 100%; margin: auto 0 0; border-radius: 20px 20px 0 0; border-bottom: 0; animation: sheet-up .22s ease-out; }
  dialog form { max-height: 88vh; padding: 8px 18px calc(18px + env(safe-area-inset-bottom)); }
  dialog form::before { content: ''; display: block; width: 36px; height: 4px; border-radius: 2px; background: var(--border); margin: 0 auto 12px; }
  .modal-foot { position: sticky; bottom: calc(-18px - env(safe-area-inset-bottom)); background: var(--surface); padding: 12px 0 4px; margin-bottom: -4px; }
  .modal-foot .btn { flex: 1; justify-content: center; padding: 12px; }
  .modal-foot .spacer { display: none; }

  /* iOS zooms into inputs under 16px. */
  input, select, textarea { font-size: 16px !important; }

  /* Tighter dashboard rhythm. */
  .grid, .stats { gap: 12px; }
  .stat { padding: 14px; }
  .stat-sub { font-size: 0.72rem; }
  .strain-banner { flex-wrap: wrap; }
  .strain-banner .row-actions { width: 100%; }
  .strain-banner .row-actions .btn { flex: 1; justify-content: center; }
}
@keyframes sheet-up { from { transform: translateY(40px); opacity: 0; } to { transform: none; opacity: 1; } }
@media (prefers-reduced-motion: reduce) { dialog { animation: none; } }
@media (max-width: 760px) {
  /* Five equal slots so labels never crowd each other. */
  .tabs { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 2px; justify-content: stretch; }
  .tabs a { padding: 6px 0; gap: 3px; white-space: nowrap; min-width: 0; }
  .tabs a span { overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
}

/* ---------- receipt scanning ---------- */
.scan-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; }
.scan-btn { cursor: pointer; }
.scan-btn svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linejoin: round; }
.scan-status { font-size: 0.8rem; color: var(--muted); }
.scan-status.pos { color: var(--pos); } .scan-status.neg { color: var(--neg); }
@media (max-width: 760px) { .scan-btn { width: 100%; justify-content: center; padding: 12px; } .scan-status { width: 100%; text-align: center; } }
/* On phones the icon can sit anywhere in a row, so show the tip as a strip above the tab bar instead of beside it. */
@media (max-width: 760px) {
  .info::after { position: fixed; top: auto; left: 16px; right: 16px; bottom: calc(84px + env(safe-area-inset-bottom)); width: auto; max-width: none; }
}
@media (max-width: 900px) {
  .plans-layout { grid-template-columns: minmax(0, 1fr); }
  .plan-list { grid-template-columns: repeat(auto-fill, minmax(min(200px, 100%), 1fr)); }
}
/* Narrow phones: name on the first line, type, limit and delete on the second. */
@media (max-width: 420px) {
  .budget-rows li { flex-wrap: wrap; gap: 8px 10px; }
  .budget-rows .br-name { flex-basis: calc(100% - 60px); }
  .budget-rows .tag-btn { margin-left: 46px; }
  .budget-rows .money-input { flex: 1; width: auto; min-width: 0; }
}
@media (max-width: 420px) {
  .plan-table th { white-space: normal; }
  .plan-table td small { display: block; }
}
@media (max-width: 360px) { .plan-table { font-size: 0.74rem; } .plan-table th, .plan-table td { padding-left: 2px; padding-right: 2px; } }
/* The header is already sticky on phones; a second sticky bar would slide under it. */
@media (max-width: 760px) { .view-totals { position: static; } }

.phone-backup { display: none; text-align: center; margin: 20px 0 8px; line-height: 1.8; }
@media (max-width: 760px) { .phone-backup { display: block; } }
/* ---------- spending chart guide ---------- */
.guide-link { font-size: 0.78rem; font-weight: 500; margin-left: 4px; }
.guide-link:hover { text-decoration: underline; text-underline-offset: 3px; }
dialog.guide { width: min(560px, calc(100% - 32px)); }
.guide h3 { margin: 22px 0 8px; font-size: 0.78rem; font-weight: 600; color: var(--muted); letter-spacing: 0.02em; }
.guide-intro { margin: 0; font-size: 0.92rem; line-height: 1.55; }
.guide-note { margin: 10px 0 0; font-size: 0.86rem; line-height: 1.5; color: var(--muted); }
.guide-note b { color: var(--text); font-weight: 600; }
.guide dl { margin: 0; border-top: 1px solid var(--border); }
.guide dl > div { display: grid; grid-template-columns: 132px 1fr; gap: 12px; padding: 9px 0; border-bottom: 1px solid var(--border); font-size: 0.86rem; line-height: 1.45; }
.guide dt { display: flex; align-items: center; gap: 8px; font-weight: 600; }
.guide dd { margin: 0; color: var(--muted); }
.guide dt svg { width: 28px; height: 12px; flex: none; overflow: visible; }
.guide-steps { margin: 0; padding-left: 20px; font-size: 0.86rem; line-height: 1.5; color: var(--muted); }
.guide-steps li + li { margin-top: 8px; }
.guide-steps li::marker { color: var(--muted); font-variant-numeric: tabular-nums; }
.guide-steps b { color: var(--text); font-weight: 600; }
@media (max-width: 760px) {
  .guide-link { font-size: 0.72rem; }
  dialog.guide { width: 100%; top: auto; } /* long sheet: pin to the bottom edge */
  .guide dl > div { grid-template-columns: 1fr; gap: 2px; }
}
/* Small phones (320–360px): keep the page title whole next to the month picker. */
@media (max-width: 360px) {
  .topbar { gap: 6px; }
  .topbar h1 { font-size: 1rem; }
  .month-picker span { min-width: 60px; }
  .month-picker .icon-btn { width: 30px; }
}

/* ---------- spending chart flyout ---------- */
.chart-fill { position: relative; }
.chart.has-hover { cursor: crosshair; -webkit-tap-highlight-color: transparent; }
.hover-line { stroke: var(--muted); stroke-width: 1; stroke-dasharray: 2 3; vector-effect: non-scaling-stroke; }
.hover-dot { fill: var(--surface); stroke-width: 2; vector-effect: non-scaling-stroke; }
.hd-spend { stroke: var(--text); }
.hd-inc { stroke: var(--pos); }
.chart-tip { position: absolute; z-index: 5; transform: translateY(-50%); min-width: 150px; padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); box-shadow: 0 8px 24px -12px rgba(0, 0, 0, 0.35); font-size: 0.8rem; line-height: 1.5; pointer-events: none; }
.chart-tip b { display: block; margin-bottom: 2px; font-weight: 600; }
.chart-tip span { display: flex; align-items: center; gap: 6px; color: var(--muted); }
.chart-tip em { margin-left: auto; padding-left: 12px; font-style: normal; color: var(--text); font-variant-numeric: tabular-nums; }
.chart-tip .tip-net { margin-top: 4px; padding-top: 4px; border-top: 1px solid var(--border); color: var(--text); font-weight: 600; }
.chart-tip .tip-net.neg, .chart-tip .tip-net.neg em { color: var(--neg); }
.tip-key { width: 10px; height: 2px; border-radius: 1px; flex: none; }
.tip-inc { background: var(--pos); }
.tip-spend { background: var(--text); }

/* ---------- Cleaner surfaces: one level of boxes. Cards hold content directly; inside a card,
   groups are separated by thin rules or space, not by more bordered boxes. ---------- */
.chart-stats { gap: 0; }
.chart-stats div { background: none; border: 0; border-left: 1px solid var(--border); border-radius: 0; padding: 0 14px; }
.chart-stats div:first-child { border-left: 0; padding-left: 0; }
@media (max-width: 760px) {
  .chart-stats { row-gap: 12px; }
  .chart-stats div:nth-child(odd) { border-left: 0; padding-left: 0; }
}
.tips { gap: 0; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
.tip { border: 0; border-left: 1px solid var(--border); border-radius: 0; padding: 0 20px; }
.tip:first-child { border-left: 0; padding-left: 0; }
.bill-date { background: none; padding: 0; }
.tc-rank { display: none; }
.bubble-stage { background: none; border: 0; }
.strain-banner { background: var(--surface); border: 1px solid var(--border); border-left: 3px solid var(--neg); }
.strain-banner .sb-icon { display: none; }
.calc-toggle { padding: 9px; }
.calc-toggle span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* Bank CSV import */
.csv-btn { margin-left: auto; }
.csv-hint { margin: 0 0 10px; }
.csv-sum { margin: 0 0 10px; font-size: 0.9rem; color: var(--muted); }
.csv-sum b { color: var(--text); font-variant-numeric: tabular-nums; }
.csv-map { margin-bottom: 12px; border: 1px solid var(--border); border-radius: 10px; padding: 8px 12px; }
.csv-map summary { cursor: pointer; font-size: 0.85rem; font-weight: 600; color: var(--muted); }
.csv-map[open] summary { margin-bottom: 10px; }
.csv-rows { list-style: none; margin: 0; padding: 0; }
.csv-row { display: grid; grid-template-columns: auto minmax(0, 1fr) auto minmax(0, 130px); align-items: center; gap: 10px; padding: 8px 0; border-top: 1px solid var(--border); }
.csv-row input[type=checkbox] { width: 18px; height: 18px; accent-color: var(--brand); }
.csv-row.off .csv-main, .csv-row.off .csv-amt { opacity: 0.5; }
.csv-main { display: flex; flex-direction: column; min-width: 0; }
.csv-main b { font-size: 0.9rem; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.csv-main small { font-size: 0.75rem; color: var(--muted); }
.csv-amt { font-weight: 600; font-variant-numeric: tabular-nums; font-size: 0.9rem; }
select.csv-cat { padding: 6px 8px; font-size: 0.82rem; }
@media (max-width: 760px) {
  .csv-row { grid-template-columns: auto minmax(0, 1fr) auto; }
  .csv-row .csv-cat { grid-column: 2 / -1; }
  .csv-btn { margin-left: 0; width: 100%; justify-content: center; }
}

/* Yearly costs */
.funds li { padding-bottom: 10px; }
.fund-bar { display: flex; align-items: center; gap: 10px; padding: 0 6px; }
.fund-bar .meter-track { flex: 1; min-width: 60px; }
.fund-bar small { font-size: 0.78rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.fund-note { display: flex; justify-content: space-between; gap: 10px; margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--border); font-size: 0.82rem; color: var(--muted); }
.fund-note b { color: var(--text); font-variant-numeric: tabular-nums; }
.fund-note:hover { text-decoration: none; color: var(--text); }

/* Leftover sweep */
.sweep-banner { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; background: color-mix(in srgb, var(--pos) 8%, var(--surface)); border: 1px solid color-mix(in srgb, var(--pos) 30%, transparent); border-radius: var(--radius); padding: 14px 18px; margin-bottom: 16px; }
.sweep-banner > div:nth-child(2) { flex: 1; min-width: 200px; }
.sweep-banner p { margin: 2px 0 0; font-size: 0.85rem; color: var(--muted); }
.sweep-banner .sb-icon { background: var(--pos); color: var(--surface); }
.sweep-banner .row-actions { align-items: center; }
.sweep-banner select { width: auto; max-width: 180px; padding: 6px 10px; font-size: 0.85rem; }
.sweep-amt { width: 110px; }
.sweep-amt input { padding: 6px 10px; font-size: 0.85rem; }
@media (max-width: 760px) {
  .sweep-banner .sb-icon { display: none; }
  .sweep-banner .row-actions { width: 100%; }
  .sweep-banner select { flex: 1 1 140px; max-width: none; min-width: 0; }
  .sweep-banner .btn { flex: 1 1 calc(50% - 4px); justify-content: center; }
}
/* Same quiet treatment as the strain banner and one level of boxes. */
.sweep-banner { background: var(--surface); border: 1px solid var(--border); border-left: 3px solid var(--pos); }
.sweep-banner .sb-icon { display: none; }
.csv-map { border: 0; border-top: 1px solid var(--border); border-radius: 0; padding: 10px 0 0; }

/* Catch up after time away */
.catchup-banner { border-left-color: var(--brand); }
.cu-facts { display: flex; gap: 8px 28px; flex-wrap: wrap; margin: 4px 0 10px; }
.cu-facts div { display: flex; flex-direction: column; }
.cu-facts b { font-size: 1.15rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.cu-facts small { font-size: 0.75rem; color: var(--muted); }
.cu-log { display: flex; align-items: center; gap: 8px; font-size: 0.85rem; color: var(--muted); margin-bottom: 12px; }
.cu-log input { width: 18px; height: 18px; accent-color: var(--brand); }
.cu-head { margin: 6px 0 4px; font-size: 0.75rem; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }
#cuSum + .cu-head + .csv-rows .csv-row { grid-template-columns: auto minmax(0, 1fr) auto; }

/* ---------- Phone polish ---------- */
@media (max-width: 760px) {
  /* Leftover banner: amount and goal share a row, the two buttons share the next. */
  .sweep-banner { padding: 14px 16px; }
  .sweep-amt { flex: 0 0 92px; width: 92px; }
  .sweep-banner select { flex: 1 1 calc(100% - 100px); }

  /* Activity: search on its own row, category filter and import side by side. */
  .toolbar { gap: 8px; }
  .toolbar input { flex-basis: 100%; min-width: 0; }
  .toolbar select { flex: 1 1 0; min-width: 0; }
  .csv-btn { width: auto; flex: none; padding: 9px 14px; }
  /* Totals read left to right instead of drifting to the right edge as they wrap. */
  .view-totals { gap: 6px 24px; }
  .vt-cell { align-items: flex-start; }

  /* Budget sections: three equal tabs that always fit. */
  .subtabs { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); width: 100%; }
  .subtabs a { justify-content: center; padding: 8px 4px; }

  /* Income and balance fields use the card's full width. */
  .income-card { gap: 14px; }
  .income-field { width: 100%; }

  /* Pattern cards: name, strain and amount on one line, the store underneath. */
  .pt-head { flex-wrap: wrap; row-gap: 2px; }
  .pt-head > .muted { order: 5; flex-basis: 100%; }

  /* Goals: one level of boxes on a phone too. Goals sit in the card, split by thin rules. */
  .goal-cards { gap: 0; }
  .goal-card { border: 0; border-top: 1px solid var(--border); border-radius: 0; padding: 16px 0; }
  .goal-card:first-child { border-top: 0; padding-top: 4px; }
  .goal-card:last-child { padding-bottom: 0; }

  /* Expense or income: a full-width switch that's easy to hit. */
  .seg { display: flex; }
  .seg label { flex: 1; }
  .seg span { text-align: center; padding: 8px 16px; }
}
/* Short pairs (amount and date, payment and due day) sit side by side once there's room. */
@media (min-width: 360px) and (max-width: 760px) {
  .form-grid { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); align-items: end; }
}
/* Touch screens: a vertical swipe over the bubbles scrolls the page; sideways drags still move them, and a tap still opens one. */
@media (hover: none) {
  .bubble-stage, .bubble { touch-action: pan-y; }
}
.chart.has-hover:focus:not(:focus-visible) { outline: none; }
/* The plan guide table turns into stacked rows on a phone instead of scrolling sideways. */
@media (max-width: 600px) {
  .plan-table.guide-table { min-width: 0; font-size: 0.86rem; }
  .guide-table thead { display: none; }
  .guide-table, .guide-table tbody, .guide-table tr, .guide-table td { display: block; }
  .guide-table tr { padding: 10px 0; border-bottom: 1px solid var(--border); }
  .guide-table td { border: 0; padding: 1px 0; white-space: normal !important; }
  .guide-table td:first-child { padding-bottom: 3px; }
  .guide-table td:nth-child(n+3) { color: var(--muted); }
}

/* Budgeting by paycheck */
.pp-bills { background: color-mix(in srgb, var(--text) 55%, var(--surface)); }
.pp-save { background: var(--brand); }
.pp-hold { background: var(--warn); }
.lg-bills::before { background: color-mix(in srgb, var(--text) 55%, var(--surface)); }
.lg-save::before { background: var(--brand); }
.lg-hold::before { background: var(--warn); }
.lg-free::before { background: var(--surface-2); box-shadow: inset 0 0 0 1px var(--border); }
.pay-periods { list-style: none; margin: 0; padding: 0; }
.pp { padding: 14px 0; border-top: 1px solid var(--border); }
.pp:first-child { border-top: 0; padding-top: 0; }
.pp:last-child { padding-bottom: 0; }
.pp-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.pp-when { display: flex; flex-direction: column; min-width: 0; }
.pp-when b { font-weight: 600; }
.pp-when small { font-size: 0.78rem; color: var(--muted); }
.pp-in { font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.pp-in small { font-weight: 600; font-size: 0.82rem; color: var(--pos); }
.pp-now .pp-when b { color: var(--brand); }
.pp-bar { display: flex; height: 8px; margin: 10px 0 8px; border-radius: 99px; overflow: hidden; background: var(--surface-2); box-shadow: inset 0 0 0 1px var(--border); }
.pp-bar i { display: block; height: 100%; }
.pp-facts { display: flex; flex-wrap: wrap; gap: 4px 20px; font-size: 0.82rem; color: var(--muted); }
.pp-facts b { color: var(--text); font-variant-numeric: tabular-nums; }
.pp-facts b.pos { color: var(--pos); }
.pp-facts b.neg { color: var(--neg); }
.pp-facts span:last-child { margin-left: auto; }
.pp-bills-list { margin-top: 8px; }
.pp-bills-list li { display: grid; grid-template-columns: 52px minmax(0, 1fr) auto 56px; align-items: center; gap: 10px; padding: 5px 0; font-size: 0.86rem; }
.pp-bills-list .pp-d { color: var(--muted); font-size: 0.78rem; font-variant-numeric: tabular-nums; }
.pp-bills-list .pp-n { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pp-bills-list b { font-weight: 600; font-variant-numeric: tabular-nums; text-align: right; }
.pp-bills-list .chip { justify-self: end; }
.pp-bills-list li.late .pp-d { color: var(--neg); }

.pay-strip { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr); align-items: center; gap: 12px 32px; margin-bottom: 16px; }
.ps-now { display: flex; flex-direction: column; color: var(--text); }
.ps-now:hover { text-decoration: none; }
.ps-now:hover .stat-label { color: var(--brand); }
.ps-next { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.ps-next li { display: grid; grid-template-columns: 52px minmax(0, 1fr) 64px; align-items: center; gap: 10px; font-size: 0.84rem; }
.ps-d { color: var(--muted); font-variant-numeric: tabular-nums; }
.ps-next b { text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; }
.ps-bar { display: flex; height: 6px; border-radius: 99px; overflow: hidden; background: var(--surface-2); box-shadow: inset 0 0 0 1px var(--border); }
.ps-bar i { display: block; height: 100%; }
.pay-empty { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.pay-empty span { display: flex; flex-direction: column; }
.pay-empty small { color: var(--muted); font-size: 0.82rem; }
@media (max-width: 760px) {
  .pay-strip { grid-template-columns: 1fr; margin-bottom: 12px; }
  .subtabs { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .pp-bills-list li { grid-template-columns: 50px minmax(0, 1fr) auto auto; gap: 8px; }
  .pp-bills-list .pp-d { white-space: nowrap; }
  .ps-d { white-space: nowrap; }
  .pay-empty .btn { width: 100%; justify-content: center; }
}
@media (max-width: 440px) { .subtabs { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 440px) { .pay-sched .head-stat { display: none; } }
/* Bill priority and the starter buffer on the paycheck plan */
.pp-bills-list .pp-n { display: flex; flex-direction: column; min-width: 0; }
.pp-bills-list .pp-n small { font-size: 0.72rem; }
.pp-tip { margin: 8px 0 0; font-size: 0.82rem; }
.pp-buffer { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 0 0 14px; margin-bottom: 14px; border-bottom: 1px solid var(--border); }
.pp-buffer span { display: flex; flex-direction: column; }
.pp-buffer small { font-size: 0.8rem; color: var(--muted); }
.pp-bills-list .pp-n small { white-space: normal; }
.pp-facts b.warn { color: var(--warn); }
/* Paychecks, easier to read: each period opens like a receipt */
.pay-periods > li { border-top: 1px solid var(--border); }
.pay-periods > li:first-child { border-top: 0; }
details.pp { padding: 0; border: 0; }
.pp-head { list-style: none; display: grid; grid-template-columns: minmax(0, 1fr) auto 18px; align-items: center; gap: 12px; padding: 12px 0 8px; cursor: pointer; }
.pp-head::-webkit-details-marker { display: none; }
.pp-head:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; border-radius: 6px; }
.pay-periods > li:first-child .pp-head { padding-top: 0; }
.pp-amt { display: flex; flex-direction: column; align-items: flex-end; }
.pp-amt b { font-size: 1.2rem; font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1.2; }
.pp-amt small { font-size: 0.75rem; color: var(--muted); }
.pp-amt b.warn { color: var(--warn); }
.pp-amt b.neg { color: var(--neg); }
.pp-chev { width: 18px; height: 18px; fill: none; stroke: var(--muted); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; transition: transform .15s; }
details.pp[open] .pp-chev { transform: rotate(180deg); }
details.pp .pp-bar { margin: 0 0 12px; }
.pp-body { padding: 0 0 14px; }
.pp-math { margin: 0 0 6px; display: grid; gap: 4px; font-size: 0.88rem; }
.pp-math div { display: flex; justify-content: space-between; gap: 12px; }
.pp-math dt { color: var(--muted); display: flex; align-items: center; gap: 8px; min-width: 0; }
.pp-math dt i { width: 10px; height: 10px; border-radius: 3px; flex: none; }
.pp-math dd { margin: 0; font-variant-numeric: tabular-nums; font-weight: 600; white-space: nowrap; }
.pp-math .pp-total { border-top: 1px solid var(--border); padding-top: 6px; margin-top: 2px; }
.pp-math .pp-total dt { color: var(--text); font-weight: 600; }
.pp-math .pp-total dd { font-weight: 700; }
.pp-math .pp-total dd small { font-weight: 500; color: var(--muted); font-size: 0.78rem; margin-left: 4px; }
.pp-math dd.warn { color: var(--warn); }
.pp-math dd.neg { color: var(--neg); }
.pp-note { margin: 6px 0 0; font-size: 0.8rem; color: var(--muted); }
.pp-note.warn { color: var(--warn); }
.pp-note.neg { color: var(--neg); }
details.pp .pp-bills-list { margin-top: 10px; padding-top: 4px; border-top: 1px dashed var(--border); }
.pp-bills-list li { grid-template-columns: 52px minmax(0, 1fr) auto auto; }
.pay-start h3 { font-size: 1.15rem; }
.ps-side { display: flex; flex-direction: column; gap: 8px; }
.ps-cap { font-size: 0.75rem; color: var(--muted); }
@media (max-width: 760px) {
  .pp-amt b { font-size: 1.1rem; }
  .pp-bills-list li { grid-template-columns: 48px minmax(0, 1fr) auto auto; }
}

/* CSV import: fill in what isn't in Budgt yet */
.csv-fill { border: 1px solid var(--border); border-left: 3px solid var(--pos); border-radius: var(--radius); padding: 12px 14px; margin: 0 0 12px; }
.csv-fill p { margin: 0 0 8px; }
.csv-fill b { font-variant-numeric: tabular-nums; }
.csv-fill-bal { display: flex; justify-content: space-between; gap: 12px; font-size: 0.9rem; color: var(--muted); }
.csv-fill-bal b { color: var(--text); }
.csv-fill-bank { display: flex; align-items: baseline; gap: 8px; font-size: 0.9rem; margin: 0 0 10px; }
.csv-fill-bank input { flex: none; width: 18px; height: 18px; accent-color: var(--brand); margin: 0; align-self: center; }
.csv-fill .row-actions { gap: 8px; }
@media (max-width: 480px) { .csv-fill .btn { flex: 1 1 calc(50% - 4px); justify-content: center; } .csv-fill .row-actions { width: 100%; } }

/* Paychecks: next month's bills that land before its first payday */
.pp-spend { background: var(--border); }
.pp-ahead .pp-math dt small { font-size: 0.8rem; }

@media (max-width: 640px) { .csv-row select.csv-cat { width: auto; max-width: 100%; justify-self: start; padding: 2px 26px 2px 10px; border-color: transparent; border-radius: 999px; background-color: color-mix(in srgb, var(--muted) 10%, var(--surface)); color: var(--muted); } }
