/* Budget: an iOS-style web app. Light and dark follow the system. Phones get a bottom tab bar, computers a
   sidebar. Class names are shared by every page, so a change here changes all of them.

   Colors: "Harbor haze", pewter #909EAE, harbor blue #5C8DC5, taupe #AD9E90 and olive taupe #736F60, for a
   calm, trustworthy feel. The light three are too pale for text, so they tint backgrounds, the chart and the
   hero card, and text and buttons use deeper shades of the same hues. Every text color reads at 4.5:1 or
   better on its background (icons and lines 3:1). Green, red and orange stay for good, over and warnings. */

:root {
  color-scheme: light;
  --plane: #eef1f4;                      /* page background: a pewter tint */
  --surface: #ffffff;                    /* cards */
  --surface-2: #f5f3f0;                  /* insets inside a card: a taupe tint */
  --fill: rgba(144, 158, 174, 0.18);     /* fields, segmented controls: pewter */
  --fill-2: rgba(144, 158, 174, 0.30);
  --ink: #1d2125;
  --ink-2: #566170;                      /* deep pewter */
  --muted: #6b6758;                      /* olive taupe */
  --grid: #e3e6ea;                       /* separators inside cards */
  --baseline: #c2cad4;
  --border: rgba(86, 97, 112, 0.16);
  --hover: rgba(144, 158, 174, 0.14);
  --bar: rgba(248, 249, 251, 0.88);      /* tab bar, under a blur */
  --seg-on: #ffffff;
  --switch-off: #dfe3e8;
  --switch-on: #5c8dc5;
  --series: #5c8dc5;                     /* harbor blue */
  --series-wash: rgba(92, 141, 197, 0.14);
  --accent: #3a6aa3;                     /* deep harbor blue: links and buttons */
  --accent-ink: #ffffff;
  --accent-wash: rgba(92, 141, 197, 0.16);
  --accent-wash-2: rgba(92, 141, 197, 0.26);
  --in: #2e7a4e;
  --in-wash: rgba(46, 122, 78, 0.12);
  --critical: #b3261e;
  --critical-wash: rgba(179, 38, 30, 0.10);
  --warning: #c98a2b;
  --warning-ink: #87580f;
  --warning-wash: rgba(201, 138, 43, 0.16);
  /* Donut parts, in drawing order: harbor blue, rose, olive, plum, brown. Checked with the dataviz palette
     validator on white and on the dark card, for every ring of 2 to 5 parts (see budget/chart.py). Olive is
     under 3:1 on white, so every donut lists its parts in words beside it. */
  --cat-1: #3a75bf;
  --cat-2: #c1628a;
  --cat-3: #a29c44;
  --cat-4: #793974;
  --cat-5: #a36232;
  --hero-1: #3a6aa3;                     /* the hero card: harbor blue into pewter */
  --hero-2: #5b6878;
  --hero-glow: rgba(58, 106, 163, 0.22);
  --radius: 16px;
  --radius-sm: 12px;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.04), 0 6px 20px rgba(0, 0, 0, 0.04);
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", system-ui, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  --font-display: -apple-system, BlinkMacSystemFont, "SF Pro Display", system-ui, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --plane: #121417;
    --surface: #1c1f23;
    --surface-2: #26292d;
    --fill: rgba(144, 158, 174, 0.20);
    --fill-2: rgba(144, 158, 174, 0.32);
    --ink: #f2f4f6;
    --ink-2: #b3bcc7;                    /* pewter */
    --muted: #a39b8f;                    /* taupe */
    --grid: #30353b;
    --baseline: #4a515a;
    --border: rgba(144, 158, 174, 0.22);
    --hover: rgba(144, 158, 174, 0.16);
    --bar: rgba(24, 27, 31, 0.88);
    --seg-on: #4a525c;
    --switch-off: #3a4048;
    --switch-on: #5c8dc5;
    --series: #6f9fd6;
    --series-wash: rgba(111, 159, 214, 0.18);
    --accent: #86afdd;                   /* light harbor blue, with dark text on buttons */
    --accent-ink: #0f1b2a;
    --accent-wash: rgba(111, 159, 214, 0.20);
    --accent-wash-2: rgba(111, 159, 214, 0.30);
    --in: #6cc590;
    --in-wash: rgba(108, 197, 144, 0.16);
    --critical: #f2867b;
    --critical-wash: rgba(242, 134, 123, 0.16);
    --warning: #d9a24a;
    --warning-ink: #e2b469;
    --warning-wash: rgba(217, 162, 74, 0.16);
    --cat-1: #528ed9;
    --cat-2: #cf6e96;
    --cat-3: #9c963e;
    --cat-4: #985593;
    --cat-5: #b67444;
    --hero-1: #2f5c92;
    --hero-2: #4b5867;
    --hero-glow: rgba(0, 0, 0, 0.3);
    --shadow: none;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

/* touch-action: a tap is a tap right away, with no wait to see if it's the first half of a double-tap zoom. */
html { -webkit-text-size-adjust: 100%; touch-action: manipulation; }
body {
  margin: 0;
  padding-top: env(safe-area-inset-top);  /* under the status bar, opened from the home screen */
  background: var(--plane);
  color: var(--ink);
  font: 16px/1.45 var(--font);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0; line-height: 1.2; font-family: var(--font-display); }
h1 { font-size: 34px; font-weight: 700; letter-spacing: -0.022em; }
h2 { font-size: 20px; font-weight: 650; letter-spacing: -0.012em; }
h3 { font-size: 16px; font-weight: 650; }

.wrap { max-width: 980px; margin: 0 auto; padding: 0 24px; }
main.wrap { padding-bottom: 64px; }

.sr-only {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap;
}

.icon-defs { position: absolute; width: 0; height: 0; overflow: hidden; }
.icon {
  width: 24px; height: 24px; flex: none;
  fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round;
}

/* --- Sidebar (computers) and tab bar (phones) --------------------------------- */

.sidebar { display: none; }
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  display: grid; grid-template-columns: repeat(5, minmax(0, 1fr));
  padding: 6px 4px calc(4px + env(safe-area-inset-bottom));
  background: var(--bar);
  -webkit-backdrop-filter: saturate(180%) blur(20px); backdrop-filter: saturate(180%) blur(20px);
  border-top: 1px solid var(--border);
}
.tabbar a {
  display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 2px 0;
  color: var(--muted); font-size: 11px; font-weight: 500; letter-spacing: 0.01em;
}
.tabbar a:hover { text-decoration: none; }
.tabbar .icon { width: 27px; height: 27px; stroke-width: 1.7; }
.tabbar a[aria-current="page"] { color: var(--accent); }
.tabbar a[aria-current="page"] .icon { stroke-width: 2.1; }
.tabbar a:active { color: var(--accent); }
.tabbar .tab-quick { justify-content: center; }
.tabbar .quick-plus {
  display: grid; place-items: center; width: 46px; height: 46px; border-radius: 50%;
  background: var(--accent); color: var(--accent-ink); box-shadow: 0 2px 8px rgba(0, 0, 0, 0.18);
}
.tabbar .quick-plus .icon { width: 26px; height: 26px; stroke-width: 2.2; }
.tabbar .tab-quick[aria-current="page"] .quick-plus, .tabbar .tab-quick:active .quick-plus { filter: brightness(1.1); }
.sheet {
  border: 0; padding: 0; margin: auto auto 0; width: 100%; max-width: 560px; max-height: 85vh;
  background: transparent; color: var(--ink);
}
.sheet::backdrop { background: rgba(0, 0, 0, 0.4); }
.sheet-body {
  background: var(--plane); border-radius: 18px 18px 0 0;
  padding: 14px 16px calc(16px + env(safe-area-inset-bottom));
}
.sheet-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 10px; }
.sheet-head h2 { margin: 0; font-size: 20px; }
.sheet .list-group { margin: 0; }
.quick-form .swap-btn { align-self: flex-end; min-height: 42px; }
.tick-form { display: inline-flex; align-items: center; gap: 6px; margin: 0 8px 0 0; vertical-align: middle; }

/* A tap shows it took (busy.js): what was pressed dims and can't be pressed twice, and if the next page takes
   more than a moment, a thin bar runs along the top of the tab bar (the top of the window on a computer, or on
   a page without the menu). */
.is-busy { opacity: 0.55; pointer-events: none; }
html.is-loading::before, html.is-loading .tabbar::before {
  content: ""; position: fixed; z-index: 100; left: 0; top: env(safe-area-inset-top); width: 100%; height: 3px;
  background: var(--accent); transform-origin: left center;
  animation: loading-bar 3s cubic-bezier(0.1, 0.7, 0.2, 1) forwards;
}
html.is-loading .tabbar::before { position: absolute; top: -1px; height: 2px; }
@media (max-width: 899px) { html.is-loading:has(.tabbar)::before { content: none; } }
@keyframes loading-bar { from { transform: scaleX(0.04); } to { transform: scaleX(0.92); } }
@media (prefers-reduced-motion: reduce) {
  html.is-loading::before, html.is-loading .tabbar::before { animation: none; transform: scaleX(0.6); }
}
body.with-nav main.wrap { padding-bottom: calc(100px + env(safe-area-inset-bottom)); }

@media (min-width: 900px) {
  body.with-nav { padding-left: 248px; }
  body.with-nav main.wrap { padding-bottom: 64px; }
  .tabbar { display: none; }
  .sidebar {
    display: flex; flex-direction: column; gap: 2px;
    position: fixed; top: 0; bottom: 0; left: 0; width: 248px; padding: 22px 12px;
    background: var(--surface); border-right: 1px solid var(--border); overflow-y: auto;
  }
  .brand {
    display: flex; align-items: center; gap: 10px; padding: 2px 10px 18px;
    font: 700 21px/1 var(--font-display); letter-spacing: -0.02em; color: var(--ink);
  }
  .brand:hover { text-decoration: none; }
  .brand img { border-radius: 7px; }
  .sidebar nav, .sidebar-extra { display: flex; flex-direction: column; gap: 2px; }
  .sidebar-extra { margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--grid); }
  .sidebar nav a, .sidebar-extra a {
    display: flex; align-items: center; gap: 11px; padding: 8px 10px; border-radius: 10px;
    color: var(--ink); font-size: 15px; font-weight: 500;
  }
  .sidebar nav a:hover, .sidebar-extra a:hover { background: var(--hover); text-decoration: none; }
  .sidebar .icon { width: 22px; height: 22px; color: var(--accent); }
  .sidebar a[aria-current="page"] { background: var(--accent); color: var(--accent-ink); }
  .sidebar a[aria-current="page"] .icon { color: var(--accent-ink); }
}

/* --- Page structure -------------------------------------------------------------- */

.page-head {
  display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between;
  gap: 12px 16px; margin: 32px 0 20px;
}
.page-head .sub { font-size: 15px; margin-top: 6px; max-width: 70ch; }
.page-title { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; }
.filters, .actions { display: flex; flex-wrap: wrap; gap: 8px; }

.card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px 20px;
  margin-bottom: 20px;
}
.card-head { margin-bottom: 14px; }
.card-head-split { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 12px; }
.sub { margin: 4px 0 0; color: var(--ink-2); font-size: 14px; }
.hint { margin: 10px 0 0; color: var(--ink-2); font-size: 14px; }
.muted { color: var(--muted); }
.empty { color: var(--ink-2); margin: 6px 0; }

/* iOS segmented control */
.seg { display: inline-flex; padding: 2px; gap: 2px; background: var(--fill); border-radius: 9px; }
.seg a {
  padding: 5px 14px; border-radius: 7px; color: var(--ink); font-size: 14px; font-weight: 500;
}
.seg a:hover { text-decoration: none; background: var(--hover); }
.seg a[aria-current="true"] {
  background: var(--seg-on); font-weight: 600;
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.12), 0 3px 1px rgba(0, 0, 0, 0.04);
}

/* --- Messages ------------------------------------------------------------------- */

.flash, .notice {
  border-radius: var(--radius-sm); padding: 12px 16px; margin: 16px 0; font-size: 15px;
  background: var(--surface); box-shadow: var(--shadow);
}
.flash-ok { display: flex; gap: 10px; }
.flash-ok::before {
  content: ""; flex: none; width: 20px; height: 20px; margin-top: 1px; border-radius: 50%;
  background: var(--in) url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'><path d='M6.5 12.5l3.5 3.5 7.5-8' fill='none' stroke='white' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'/></svg>") center / 14px no-repeat;
}
.flash-error { background: var(--critical-wash); box-shadow: none; }
.flash ul { margin: 0; padding-left: 18px; }
.notice { background: var(--warning-wash); box-shadow: none; }
.notice a { margin-left: 6px; }
.notice-tip { background: var(--accent-wash); }
.notice-tip p { margin: 0; }
.notice-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.notice-actions form { margin: 0; }

.status {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 1px 8px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap;
}
.status-critical { background: var(--critical-wash); color: var(--critical); }
.status-warning { background: var(--warning-wash); color: var(--warning-ink); }
.badge {
  display: inline-block; margin-left: 6px; padding: 1px 8px; border-radius: 999px;
  background: var(--fill); color: var(--ink-2); font-size: 12px; font-weight: 600;
}

/* --- Buttons --------------------------------------------------------------------- */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 40px; padding: 0 16px; border-radius: var(--radius-sm); border: 0;
  background: var(--accent-wash); color: var(--accent); font: inherit; font-size: 15px; font-weight: 600;
  text-decoration: none; cursor: pointer; white-space: nowrap;
  transition: background-color 0.15s, transform 0.1s;
}
.btn:hover { background: var(--accent-wash-2); text-decoration: none; }
.btn:active { transform: scale(0.98); }
.btn-primary { background: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { background: var(--accent); filter: brightness(1.08); }
.btn-ghost { background: transparent; }
.btn-ghost:hover { background: var(--accent-wash); }
.btn-danger { background: var(--critical-wash); color: var(--critical); }
.btn-danger:hover { background: var(--critical-wash); filter: brightness(0.97); }
.btn-small { height: 32px; padding: 0 12px; font-size: 14px; border-radius: 999px; }

/* --- Fields ---------------------------------------------------------------------- */

input, select, textarea {
  font: inherit; font-size: 16px; color: var(--ink); background: var(--fill);
  border: 0; border-radius: 10px; padding: 8px 12px; min-height: 42px;
}
input::placeholder, textarea::placeholder { color: var(--muted); opacity: 1; }
select {
  -webkit-appearance: none; appearance: none; padding-right: 32px; cursor: pointer;
  background: var(--fill) url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'><path d='M7 9.5l5 5 5-5' fill='none' stroke='%238e8e93' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'/></svg>") right 10px center / 16px no-repeat;
}
input:focus-visible, select:focus-visible, textarea:focus-visible, .btn:focus-visible,
.seg a:focus-visible, .chart:focus-visible, a:focus-visible, button:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 2px;
}
input[type="radio"], input[type="checkbox"] { min-height: 0; padding: 0; margin: 0; accent-color: var(--accent); }
input[type="radio"] { width: 20px; height: 20px; }
td > input[type="radio"] { width: 20px; height: 20px; vertical-align: middle; }
label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; font-weight: 500; color: var(--ink-2); }
label.check { flex-direction: row; align-items: center; gap: 10px; font-size: 15px; color: var(--ink); }

/* A checkbox in a form row is an iOS switch. */
label.check input[type="checkbox"] {
  -webkit-appearance: none; appearance: none; flex: none; cursor: pointer;
  width: 51px; height: 31px; border-radius: 999px;
  background:
    radial-gradient(circle at 15.5px 50%, #fff 12.5px, transparent 13.5px),
    radial-gradient(circle at 15.5px 56%, rgba(0, 0, 0, 0.14) 13px, transparent 15px),
    var(--switch-off);
  transition: background 0.2s;
}
label.check input[type="checkbox"]:checked {
  background:
    radial-gradient(circle at calc(100% - 15.5px) 50%, #fff 12.5px, transparent 13.5px),
    radial-gradient(circle at calc(100% - 15.5px) 56%, rgba(0, 0, 0, 0.14) 13px, transparent 15px),
    var(--switch-on);
}

/* A checkbox in a list is a round tick, like Reminders. */
.check-col input[type="checkbox"], .change input[type="checkbox"], .due-days input[type="checkbox"],
.check-item input[type="checkbox"] {
  -webkit-appearance: none; appearance: none; cursor: pointer; flex: none;
  width: 22px; height: 22px; border-radius: 50%; border: 1.5px solid var(--baseline); background: transparent;
  vertical-align: middle; transition: background-color 0.15s, border-color 0.15s;
}
.check-col input[type="checkbox"]:checked, .change input[type="checkbox"]:checked,
.due-days input[type="checkbox"]:checked, .check-item input[type="checkbox"]:checked {
  border-color: var(--accent);
  background: var(--accent) url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'><path d='M6.5 12.5l3.5 3.5 7.5-8' fill='none' stroke='white' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'/></svg>") center / 15px no-repeat;
}

.money-input { position: relative; display: flex; }
.money-input > span {
  position: absolute; left: 12px; top: 50%; transform: translateY(-50%);
  color: var(--muted); font-weight: 400; font-size: 16px; pointer-events: none;
}
.money-input input { padding-left: 25px; width: 100%; font-variant-numeric: tabular-nums; }
.pct-input { position: relative; display: flex; width: 110px; }
.pct-input input { width: 100%; padding-right: 28px; font-variant-numeric: tabular-nums; }
.pct-input > span { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.short-input { width: 84px; }

/* --- Forecast -------------------------------------------------------------------- */

.balance-form { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 12px; }
.balance-form .money-input { width: 160px; }
.needs-balance { box-shadow: 0 0 0 2px var(--warning); }

.tiles { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 20px; }
.tiles-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.tiles-two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.tile { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px 16px; min-width: 0; }
.tile-label { color: var(--ink-2); font-size: 13px; font-weight: 500; }
.tile-value {
  font: 700 26px/1.15 var(--font-display); letter-spacing: -0.02em; margin: 4px 0 2px;
  font-variant-numeric: tabular-nums; overflow-wrap: anywhere;
}
.tile-sub { color: var(--muted); font-size: 13px; display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }

.chart-wrap { position: relative; }
.chart { display: block; width: 100%; height: auto; overflow: visible; }
.chart .grid { stroke: var(--grid); stroke-width: 1; }
.chart .baseline { stroke: var(--baseline); stroke-width: 1; }
.chart .tick { fill: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.chart .buffer { stroke: var(--warning); stroke-width: 1.5; stroke-dasharray: 5 4; }
.chart .today { stroke: var(--baseline); stroke-width: 1; }
.chart .ref-label { fill: var(--ink-2); font-size: 12px; }
.chart .area { fill: var(--series-wash); }
.chart .line { fill: none; stroke: var(--series); stroke-width: 2.5; stroke-linejoin: round; stroke-linecap: round; }
.chart .line.negative { stroke: var(--critical); }
.chart .dot { fill: var(--series); stroke: var(--surface); stroke-width: 2; }
.chart .dot.negative { fill: var(--critical); }
.chart .low-label { fill: var(--ink); font-size: 12px; font-weight: 600; paint-order: stroke; stroke: var(--surface); stroke-width: 4px; }
.chart .crosshair { stroke: var(--ink-2); stroke-width: 1; }
.chart .hit { fill: transparent; cursor: crosshair; }
.chart .keep { stroke: var(--ink-2); stroke-width: 1.5; stroke-dasharray: 4 3; }
.chart .keep-dot { fill: var(--surface); stroke: var(--ink-2); stroke-width: 2; }
.chart .keep-dot.short { stroke: var(--critical); }
.chart .keep-dot.under { stroke: var(--warning); }
.chart .keep-label { fill: var(--ink-2); font-size: 12px; paint-order: stroke; stroke: var(--surface); stroke-width: 4px; }
.tip-keep { margin-top: 4px; color: var(--ink-2); font-weight: 600; }
.chart .line.alt { stroke: var(--ink-2); stroke-width: 2; stroke-dasharray: 6 4; opacity: 0.75; }
.chart .hover-dot.alt { fill: var(--ink-2); }

/* Line keys for a chart with two lines: a short stroke like the line itself. */
.chart-keys { display: flex; flex-wrap: wrap; gap: 6px 18px; margin: 0 0 8px; padding: 0; list-style: none;
  color: var(--ink-2); font-size: 13px; }
.chart-keys li { display: flex; align-items: center; gap: 8px; }
.chart-keys .key { width: 18px; height: 0; border-top: 2.5px solid var(--series); border-radius: 2px; }
.chart-keys .key.alt { border-top: 2px dashed var(--ink-2); }
.tip-row { display: flex; align-items: center; gap: 8px; }
.tip-row .key { width: 12px; height: 0; border-top: 2.5px solid var(--series); flex: none; }
.tip-row .key.alt { border-top: 2px dashed var(--ink-2); }
.tip-row .tip-amt { min-width: 0; }

/* Donuts: one whole split into parts, with a legend that lists each part's name, amount and share. */
.donut-figure { display: flex; flex-wrap: wrap; align-items: center; gap: 16px 28px; }
.donut { position: relative; width: min(196px, 100%); aspect-ratio: 1; flex: none; margin: 0 auto; }
.donut svg { display: block; width: 100%; height: 100%; overflow: visible; }
.donut .slice { cursor: pointer; transition: opacity 0.15s; }
.donut-figure.has-active .slice:not(.is-active) { opacity: 0.3; }
.slice.cat-1 { fill: var(--cat-1); } .slice.cat-2 { fill: var(--cat-2); } .slice.cat-3 { fill: var(--cat-3); }
.slice.cat-4 { fill: var(--cat-4); } .slice.cat-5 { fill: var(--cat-5); }
.swatch.cat-1 { background: var(--cat-1); } .swatch.cat-2 { background: var(--cat-2); } .swatch.cat-3 { background: var(--cat-3); }
.swatch.cat-4 { background: var(--cat-4); } .swatch.cat-5 { background: var(--cat-5); }
.donut-center {
  position: absolute; inset: 17%; display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center; pointer-events: none;
}
.donut-value { font: 700 20px/1.15 var(--font-display); letter-spacing: -0.02em; color: var(--ink); }
.donut-value-long { font-size: 16px; }
.donut-label { margin-top: 3px; color: var(--ink-2); font-size: 12px; line-height: 1.25; max-width: 112px;
  overflow-wrap: anywhere; }
.donut-legend { flex: 1 1 240px; min-width: 0; max-width: 460px; margin: 0; padding: 0; list-style: none;
  container-type: inline-size; }
.donut-legend li {
  display: grid; grid-template-columns: 12px minmax(0, 1fr) auto 44px; align-items: center; gap: 10px;
  padding: 8px 6px; border-radius: 8px; cursor: pointer; font-size: 15px;
}
.donut-legend li + li { border-top: 1px solid var(--grid); }
.donut-legend li.is-active { background: var(--hover); }
.donut-legend .swatch { width: 12px; height: 12px; border-radius: 4px; }
.legend-name { overflow-wrap: break-word; }
/* A narrow legend: the name gets the whole first line, its amount and share go under it. */
@container (max-width: 300px) {
  .donut-legend li { grid-template-columns: 12px minmax(0, 1fr) auto; row-gap: 2px; }
  .donut-legend .legend-name { grid-column: 2 / 4; }
  .donut-legend .legend-amount { grid-column: 2; text-align: left; }
  .donut-legend .legend-share { grid-column: 3; }
}
.legend-amount { font-variant-numeric: tabular-nums; font-weight: 600; text-align: right; }
.legend-share { color: var(--ink-2); font-variant-numeric: tabular-nums; text-align: right; }

/* Pie or Bar: each person's choice, switched in place by donut.js and kept for next time. */
.view-switch { display: flex; flex: 1 1 100%; justify-content: flex-end; margin: 0; }
.view-switch button {
  padding: 4px 12px; border: 0; border-radius: 7px; background: var(--fill); color: var(--ink); font: inherit;
  font-size: 13px; font-weight: 500; cursor: pointer;
}
.view-switch button:first-of-type { border-radius: 7px 0 0 7px; }
.view-switch button:last-of-type { border-radius: 0 7px 7px 0; }
.view-switch button[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); font-weight: 600; }
.donut-figure.view-pie .split, .donut-figure.view-bar .donut { display: none; }
.donut-figure.view-bar .donut-legend { flex-basis: 100%; max-width: 560px; }

/* The bar: one whole, each part a block as wide as its share, a 2px gap between, its share inside where it fits. */
.split { flex: 1 1 100%; min-width: 0; }
.split-total { margin: 0 0 8px; color: var(--ink-2); font-size: 14px; }
.split-value { color: var(--ink); font: 700 20px/1.2 var(--font-display); letter-spacing: -0.02em; margin-right: 4px; }
.split-bar { display: flex; gap: 2px; height: 28px; }
.split-bar .block {
  flex: 0 1 0; min-width: 0; border-radius: 4px; cursor: pointer; transition: opacity 0.15s;
  display: flex; align-items: center;
}
.donut-figure.has-active .block:not(.is-active) { opacity: 0.3; }
.block.cat-1 { background: var(--cat-1); } .block.cat-2 { background: var(--cat-2); } .block.cat-3 { background: var(--cat-3); }
.block.cat-4 { background: var(--cat-4); } .block.cat-5 { background: var(--cat-5); }
.block-label { padding-left: 6px; color: #ffffff; font-size: 12px; font-weight: 600; font-variant-numeric: tabular-nums;
  white-space: nowrap; }

.tooltip {
  position: absolute; z-index: 2; pointer-events: none; min-width: 180px; max-width: 270px;
  background: var(--bar); -webkit-backdrop-filter: blur(20px); backdrop-filter: blur(20px);
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.16); padding: 10px 12px; font-size: 13px;
}
.tip-value { font-size: 17px; font-weight: 700; font-variant-numeric: tabular-nums; }
.tip-label { color: var(--ink-2); }
.tip-events { list-style: none; margin: 6px 0 0; padding: 6px 0 0; border-top: 1px solid var(--grid); }
.tip-events li { display: flex; gap: 8px; }
.tip-amt { font-variant-numeric: tabular-nums; font-weight: 600; min-width: 84px; }
.tip-events li.in .tip-amt { color: var(--in); }
.tip-name { color: var(--ink-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.group-head {
  display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-start;
  gap: 12px; margin-bottom: 10px;
}
.group-stats { display: flex; gap: 24px; margin: 0; }
.group-stats div { text-align: right; }
.group-stats dt { color: var(--ink-2); font-size: 12px; font-weight: 500; }
.group-stats dd { margin: 0; font-weight: 650; font-variant-numeric: tabular-nums; }
.group-stats .stat-note { display: block; color: var(--ink-2); font-size: 12px; font-weight: 400; }

/* --- Tables (lists) ---------------------------------------------------------------- */

/* Positioned, so screen-reader-only labels inside a wide table don't widen the page. */
.table-scroll { overflow-x: auto; margin: 0 -20px; padding: 0 20px; position: relative; }
table { width: 100%; border-collapse: collapse; font-size: 15px; }
th {
  text-align: left; font-size: 12px; font-weight: 600; color: var(--muted);
  padding: 6px 10px 8px 0; border-bottom: 1px solid var(--grid);
}
td { padding: 11px 10px 11px 0; border-bottom: 1px solid var(--grid); vertical-align: top; }
tr:last-child td { border-bottom: 0; }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; padding-right: 0; padding-left: 10px; }
td.date { white-space: nowrap; color: var(--ink-2); }
.in { color: var(--in); }
tr.income td { background: var(--series-wash); }
tr.income td:first-child { box-shadow: inset 3px 0 0 var(--series); padding-left: 8px; }
tr.past td { opacity: 0.55; }
tr.paused td { opacity: 0.5; }
.moved { display: block; color: var(--muted); font-size: 12px; }
.check-col { width: 32px; padding-right: 6px; text-align: center; }
.check-col form { display: inline; margin: 0; }
tr.confirmed td:not(.check-col) { color: var(--ink-2); }
.link-btn { display: block; margin-left: auto; padding: 0; border: 0; background: none; color: var(--accent);
  font: inherit; font-size: 13px; font-weight: 500; cursor: pointer; }
.link-btn:hover { text-decoration: underline; }
tr.confirm-editor td { background: var(--surface-2); }
.events.hide-cleared tr.is-cleared, .events.hide-skipped tr.is-skipped { display: none; }
tr.cleared-summary td { padding: 0; }
.cleared-toggle { display: flex; align-items: center; gap: 8px; width: 100%; padding: 10px 0; border: 0;
  background: none; color: var(--ink-2); font: inherit; font-size: 14px; text-align: left; cursor: pointer; }
.cleared-toggle > span:first-child { width: 32px; text-align: center; }
.cleared-action { color: var(--accent); font-weight: 500; }
.cleared-toggle:hover .cleared-action { text-decoration: underline; }
.confirm-form { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.confirm-form .money-input { width: 140px; }
.confirm-form input[type="date"], .confirm-form .money-input input { min-height: 36px; padding-top: 4px; padding-bottom: 4px; }
.confirm-label { font-size: 14px; }
.items td a { font-weight: 600; }
.center { text-align: center; padding-right: 0; padding-left: 12px; }
.due-days td { vertical-align: middle; padding-top: 6px; padding-bottom: 6px; }
.due-days .money-input { width: 120px; margin-left: auto; }
.due-days .money-input input { text-align: right; }
.due-days td.bank { font-size: 13px; min-width: 220px; }
.due-days .bank-col, .due-days td.bank { padding-left: 20px; }
.due-days td.bank .btn-small { margin-top: 4px; }
.good { color: var(--in); font-weight: 600; }
.history-bar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 16px; }
.history-bar p { margin: 0; }
.history-bar .actions form { margin: 0; }
.sync-line { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; }
.steps { margin: 0 0 16px; padding-left: 20px; }
.steps li { padding: 2px 0; }
.connect-form { display: flex; flex-direction: column; gap: 12px; max-width: 640px; }
.connect-form textarea { font-family: ui-monospace, "SF Mono", Consolas, monospace; font-size: 13px; }
.notice ul { margin: 4px 0 0; padding-left: 18px; }

/* --- Month ledger: carried in + paychecks − bills − keep = extra ------------------- */

.ledger { margin: 0; max-width: 640px; font-variant-numeric: tabular-nums; }
.ledger > div { display: flex; justify-content: space-between; align-items: baseline; gap: 16px; padding: 5px 0; }
.ledger dt { color: var(--ink-2); font-size: 15px; }
.ledger dt .muted { font-size: 12px; }
.ledger dd { margin: 0; white-space: nowrap; font-weight: 600; }
.ledger .ledger-subtotal { border-top: 1px solid var(--grid); margin-top: 4px; padding-top: 9px; }
.ledger .ledger-subtotal dt { color: var(--ink); }
.ledger .ledger-total { border-top: 1px solid var(--grid); margin-top: 4px; padding-top: 9px; }
.ledger .ledger-total dt { color: var(--ink); font-weight: 650; }
.ledger .ledger-total dd { font: 700 20px var(--font-display); letter-spacing: -0.01em; }
.ledger-wrap { background: var(--surface-2); border-radius: var(--radius-sm); padding: 10px 14px; margin: 0 0 14px; }
/* This month's ledger beside where its money goes; one above the other when there's no room. */
.ledger-split { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(300px, 100%), 1fr)); gap: 20px 32px; align-items: start; }
.ledger-donut .donut-figure { justify-content: center; }
.chart-title { margin: 18px 0 10px; font-size: 15px; font-weight: 650; }
.ledger-donut .chart-title { margin-top: 0; }
.where-donut { margin: 4px 0 18px; }
.extra-big { font: 650 22px var(--font-display); font-variant-numeric: tabular-nums; }
.carry-bills { margin: 10px 0 0; font-size: 13px; }
/* This month's extra: how it's worked out folds on a phone, under a button that shows only there. */
.how-toggle { margin: 2px 0 0; }
@media (min-width: 601px) { .how-toggle { display: none !important; } }
@media (max-width: 600px) {
  .fold-how:not(.show-how) .extra-how, .fold-how:not(.show-how) .how-more { display: none; }
  .fold-how.show-how .how-toggle { margin-bottom: 12px; }
}

/* To check off: everything waiting for a tick, in one place. */
.check-list { list-style: none; margin: 0; padding: 0; }
.check-list li { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-top: 1px solid var(--grid); }
.check-list li:first-child { border-top: 0; padding-top: 2px; }
.check-item { flex: 1; flex-direction: row; align-items: center; gap: 12px; min-width: 0; font-size: 15px;
  color: var(--ink); cursor: pointer; }
.check-item .muted { font-size: 13px; font-weight: 400; }
.check-list .money-input { flex: none; width: 116px; }
.check-list .num { flex: none; font-variant-numeric: tabular-nums; }
.check-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 16px; margin-top: 14px;
  padding-top: 12px; border-top: 1px solid var(--grid); }
.check-actions .btn { margin-left: auto; }
.cushion-note { margin: 0 0 12px; color: var(--warning-ink); font-size: 14px; }
.month-end-line { margin: 0 0 14px; padding: 10px 14px; background: var(--surface-2); border-radius: var(--radius-sm); font-size: 14px; }
.month-end-line a { margin-left: 6px; }
.closed-note { margin: 0 0 16px; padding: 10px 14px; background: var(--surface); border-radius: var(--radius-sm);
  font-size: 14px; color: var(--ink-2); box-shadow: var(--shadow); }
.closed-note a { margin-left: 6px; }

/* --- Spending, deposits, savings --------------------------------------------------- */

.quick-form { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 12px; }
.quick-form .money-input { width: 150px; }
.quick-form > label.grow { flex: 1; min-width: 200px; }
.quick-form > label.pending-check { min-height: 42px; font-weight: 500; }
.week-stats { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 8px 16px; margin-bottom: 10px; }
.meter { height: 8px; background: var(--fill); border-radius: 999px; overflow: hidden; margin-bottom: 14px; }
.meter > span { display: block; height: 100%; background: var(--series); border-radius: 999px; }
.meter.over > span { background: var(--critical); }
.purchases td { vertical-align: middle; }
.spend-cards { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; align-items: start; }
.spend-cards > .card { margin-bottom: 0; }
.spend-cards + .card { margin-top: 20px; }
.save-form { margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--grid); }
.save-form .hint { margin: 0 0 8px; }

/* What's safe to move today: the hero card on the Forecast and Savings pages. */
.save-now {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 16px 28px;
  padding: 22px 24px; color: #fff;
  background: linear-gradient(135deg, var(--hero-1), var(--hero-2));
  box-shadow: 0 12px 32px var(--hero-glow);
}
.save-now-text { flex: 1 1 320px; min-width: 0; }
.save-now-label { font-size: 15px; font-weight: 600; color: rgba(255, 255, 255, 0.88); font-family: var(--font); letter-spacing: 0; }
.save-now-value {
  font: 700 46px/1.05 var(--font-display); letter-spacing: -0.03em; margin: 6px 0 10px;
  font-variant-numeric: tabular-nums;
}
.save-now-why, .save-now-goal { margin: 0; font-size: 15px; color: rgba(255, 255, 255, 0.9); max-width: 64ch; }
.save-now-goal { margin-top: 8px; }
.save-now a { color: #fff; text-decoration: underline; text-underline-offset: 2px; }
.save-now-actions { display: flex; flex-direction: column; gap: 8px; align-items: stretch; }
.save-now-form .btn { height: 48px; padding: 0 20px; font-size: 16px; width: 100%; }
.save-now-into { margin-bottom: 8px; color: rgba(255, 255, 255, 0.88); }  /* which savings account, if several */
.save-now-into select { width: 100%; }
.save-now .btn { background: rgba(255, 255, 255, 0.2); color: #fff; }
.save-now .btn:hover { background: rgba(255, 255, 255, 0.28); }
.save-now .btn-primary { background: #fff; color: var(--hero-1); }
.save-now .btn-primary:hover { background: #fff; filter: brightness(0.96); }
.save-now ~ .this-month .extra-big .good { color: var(--ink-2); }  /* the safe amount is the one to go by */

.savings-set summary { cursor: pointer; color: var(--accent); font-size: 15px; font-weight: 500; }
.savings-set form { margin-top: 10px; }
form.inline { display: inline; margin: 0; }
.phone-only { display: none; }
@media (max-width: 600px) { .phone-only { display: inline; } }
.row-actions { white-space: nowrap; }
a.link-btn { text-decoration: none; }
code { font-size: 13px; background: var(--fill); padding: 1px 6px; border-radius: 6px; overflow-wrap: anywhere; }

/* --- Forms: paychecks and bills, debts ---------------------------------------------- */

.form-layout { display: grid; grid-template-columns: minmax(0, 1fr) 280px; gap: 20px; align-items: start; }
.item-form, .debt-form { display: flex; flex-direction: column; gap: 16px; margin: 0; }
.debt-form .money-input { width: 160px; }
.field-row { display: flex; flex-wrap: wrap; gap: 12px; }
.field-row > label { min-width: 140px; }
.field-row > label.grow { flex: 1; min-width: 220px; }
fieldset {
  border: 0; border-radius: var(--radius-sm); background: var(--surface-2);
  padding: 14px 16px 16px; margin: 0; display: flex; flex-direction: column; gap: 12px;
}
legend { font-weight: 600; padding: 0; float: left; width: 100%; margin-bottom: 4px; }
legend + * { clear: left; }
.form-actions { display: flex; gap: 8px; }
.preview { margin: 0; position: sticky; top: 16px; }
.preview ol { margin: 10px 0 0; padding-left: 20px; font-variant-numeric: tabular-nums; }
.preview li { padding: 3px 0; }
.delete-form { margin-top: 24px; }
.sign-in { max-width: 420px; margin: 48px auto; display: flex; flex-direction: column; gap: 10px; }
.sign-in-form { display: flex; flex-direction: column; gap: 14px; margin-top: 8px; }

/* --- Advisor ---------------------------------------------------------------------- */

.advisor-source { margin: 0 0 20px; color: var(--ink-2); font-size: 15px; max-width: 80ch; }
.changes { list-style: none; margin: 0; padding: 0; }
.changes li + li { border-top: 1px solid var(--grid); }
.change { display: grid; grid-template-columns: 24px minmax(0, 1fr) auto; gap: 4px 12px; align-items: start;
  padding: 14px 0; cursor: pointer; font-size: 15px; font-weight: 400; color: var(--ink); }
.change input[type="checkbox"] { margin: 1px 0 0; }
.change-text { display: flex; flex-direction: column; gap: 3px; }
.change-detail { color: var(--ink-2); font-size: 14px; }
.change-note { color: var(--ink-2); font-size: 13px; font-style: italic; }
.change-saves { text-align: right; font-size: 12px; color: var(--muted); line-height: 1.35; white-space: nowrap; }
.change-saves strong { font: 700 17px var(--font-display); font-variant-numeric: tabular-nums; }
.plan-ahead { margin: 0 0 12px; font-weight: 600; }
.plan-head { margin: 18px 0 6px; font-size: 16px; }
.plan-steps { margin: 0; padding-left: 20px; font-size: 15px; }
.plan-steps li { padding: 3px 0; }
.plan-save { margin-top: 16px; display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: center; }
.where .where-group th, .where .where-group td { padding-top: 16px; font-size: 15px; font-weight: 650; color: var(--ink); }
.where tbody tr:not(.where-group) td:first-child { padding-left: 14px; }
.share { display: block; height: 6px; margin-top: 7px; max-width: 240px; background: var(--fill); border-radius: 999px; overflow: hidden; }
.share > span { display: block; height: 100%; background: var(--series); border-radius: 999px; }
.advisor-notes { margin: 14px 0 0; padding-left: 18px; color: var(--ink-2); font-size: 14px; }
.advisor-notes li { padding: 3px 0; }
.advisor-fine { margin: 0 0 24px; }

/* --- Debt, goal, Can I afford it? ---------------------------------------------------- */

.method-pick {
  border: 0; margin: 0 0 14px; padding: 0; background: none;
  display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 10px;
}
.method-pick legend { grid-column: 1 / -1; font-size: 13px; font-weight: 500; color: var(--ink-2); margin-bottom: 0; }
.radio-card {
  flex-direction: row; align-items: flex-start; gap: 12px; padding: 12px 14px; cursor: pointer;
  border-radius: var(--radius-sm); background: var(--surface-2); box-shadow: inset 0 0 0 1.5px transparent;
  font-weight: 400; color: var(--ink); font-size: 15px; transition: box-shadow 0.15s, background-color 0.15s;
}
.radio-card:has(input:checked) { background: var(--accent-wash); box-shadow: inset 0 0 0 1.5px var(--accent); }
.radio-card input { margin-top: 2px; }
.radio-card > span { display: flex; flex-direction: column; gap: 2px; }
.radio-card .muted { font-size: 13px; color: var(--ink-2); }
.debt-plan-form .quick-form, .goal-form .quick-form { margin-top: 4px; }
.compare { margin: 0 0 16px; padding-left: 18px; color: var(--ink-2); font-size: 15px; }
.compare li { padding: 2px 0; }
.payoff .share { max-width: 160px; }
.payoff td.date, .payoff th:nth-child(6) { padding-left: 16px; }
.debt-paid-by { font-size: 13px; margin-top: 3px; display: flex; flex-wrap: wrap; gap: 4px 8px; align-items: center; font-weight: 400; }
.debt-paid-by .link-btn { display: inline; margin: 0; font-size: 13px; }
.suggestions { list-style: none; margin: 0; padding: 0; }
.suggestions li { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 10px 0; }
.suggestions li + li { border-top: 1px solid var(--grid); }
.afford-form { display: flex; flex-direction: column; gap: 14px; }
.afford-form .method-pick { margin: 0; }
.need-pick { background: none; padding: 0; border: 0; margin: 0; min-width: 0; display: block; }
.need-pick legend { font-size: 13px; font-weight: 500; color: var(--ink-2); margin-bottom: 8px; }
.need-pick label.check { display: inline-flex; margin-right: 20px; }
.afford-form > .btn { align-self: flex-start; }
.afford-form .hint { margin: 0; }
.verdict { background-color: var(--surface); }
.verdict-yes { background-image: linear-gradient(var(--in-wash), var(--in-wash)); }
.verdict-wait, .verdict-tight { background-image: linear-gradient(var(--warning-wash), var(--warning-wash)); }
.verdict-no { background-image: linear-gradient(var(--critical-wash), var(--critical-wash)); }
.verdict-for { margin: 0 0 4px; color: var(--ink-2); font-size: 15px; }
.verdict-head { font: 750 30px/1.15 var(--font-display); letter-spacing: -0.02em; margin: 0 0 10px; }
.verdict-yes .verdict-head { color: var(--in); }
.verdict-wait .verdict-head, .verdict-tight .verdict-head { color: var(--warning-ink); }
.verdict-no .verdict-head { color: var(--critical); }
.verdict-reasons { margin: 0; padding-left: 18px; font-size: 16px; }
.verdict-effects { margin: 10px 0 0; padding-left: 18px; color: var(--ink-2); font-size: 15px; }
.verdict li { padding: 2px 0; }

/* --- More (phones): an inset grouped list ---------------------------------------------- */

.list-group {
  list-style: none; margin: 0 0 20px; padding: 0; overflow: hidden;
  background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow);
}
.list-group a { position: relative; display: flex; align-items: center; gap: 14px; min-height: 60px; padding: 10px 16px; color: var(--ink); }
.list-group a:hover { text-decoration: none; background: var(--hover); }
.list-group li + li a::before { content: ""; position: absolute; top: 0; left: 60px; right: 0; border-top: 1px solid var(--grid); }
.list-icon { display: grid; place-items: center; width: 30px; height: 30px; border-radius: 8px; background: var(--accent); flex: none; }
.list-icon .icon { width: 19px; height: 19px; color: #fff; stroke-width: 2; }
.list-icon-afford { background: #8a7a6b; }
.list-icon-advisor { background: #5b6878; }
.list-icon-debt { background: #7d6a74; }
.list-icon-deposits { background: #4c7cb4; }
.list-icon-savings { background: #66778b; }
.list-icon-recurring { background: #736f60; }
.list-icon-settings { background: #566170; }
.list-icon-bank { background: #3a6aa3; }
.list-icon-history { background: #4c7cb4; }
.list-icon-accounts { background: #5c6f86; }
.list-icon-move { background: #4f7a6a; }
.list-icon-iou { background: #7a6a4f; }
.list-icon-networth { background: #5d7a63; }
.list-icon-taxes { background: #6b6f86; }
.list-icon-ahead { background: #5f7487; }
.list-icon-spending { background: #6a7f5b; }
.list-icon-mortgage { background: #4c7cb4; }
.list-icon-car { background: #736f60; }
.list-amount { display: flex; flex-direction: column; align-items: flex-end; text-align: right; font-variant-numeric: tabular-nums; }
.list-amount strong { font-weight: 600; font-size: 16px; }
.list-amount span { color: var(--ink-2); font-size: 13px; }
.list-text { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.list-text strong { font-weight: 500; font-size: 16px; }
.list-text span { color: var(--ink-2); font-size: 13px; }
.chevron { width: 18px; height: 18px; color: var(--baseline); stroke-width: 2.4; }

/* --- Narrower screens ------------------------------------------------------------------ */

@media (max-width: 899px) {
  .wrap { padding: 0 16px; }
  .page-head { margin: 14px 0 16px; }
  h1 { font-size: 32px; }
  .tiles, .tiles-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .form-layout { grid-template-columns: 1fr; }
  .preview { position: static; }
  .group-stats { gap: 16px; }
  .group-stats div { text-align: left; }
  .card { padding: 16px; margin-bottom: 16px; }
  .table-scroll { margin: 0 -16px; padding: 0 16px; }
  .due-days .money-input { width: 92px; }
  .spend-cards { grid-template-columns: minmax(0, 1fr); gap: 16px; }
  .spend-cards + .card { margin-top: 16px; }
  .btn { height: 44px; }
  .btn-small { height: 34px; }
  input, select, textarea { min-height: 44px; }
  .link-btn { padding: 6px 0; font-size: 13px; }
  .save-now { padding: 20px; }
  .save-now-value { font-size: 42px; }
}

/* Phones: the forecast table as stacked rows (the name and its amount, then the date and the balance after it,
   then the category), full-width actions, and a chart that swipes sideways. */
@media (max-width: 600px) {
  .tile-value { font-size: 22px; }
  .save-now-actions, .save-now-form, .save-now-form .btn { width: 100%; }
  .events thead { display: none; }
  .events, .events tbody { display: block; }
  .events tr {
    display: grid; grid-template-columns: 32px minmax(0, 1fr) auto; column-gap: 8px; padding: 11px 0;
    grid-template-areas: "check item amount" "check date balance" "check cat balance";
    border-bottom: 1px solid var(--grid);
  }
  .events tr[hidden] { display: none; }
  .events td { padding: 0; border: 0; }
  .events .check-col { grid-area: check; width: auto; padding-top: 1px; }
  .events .cell-item { grid-area: item; color: var(--ink); font-weight: 600; overflow-wrap: anywhere; }
  .events td.date { grid-area: date; white-space: normal; color: var(--ink-2); font-size: 13px; }
  .events .cell-cat { grid-area: cat; font-size: 13px; }
  .events .cell-cat:empty { display: none; }
  .events .cell-amount { grid-area: amount; font-weight: 600; }
  .events .cell-amount .link-btn { display: inline; margin-left: 10px; padding: 0; font-weight: 500; }
  .events .cell-balance { grid-area: balance; font-size: 13px; color: var(--ink-2); }
  .events .cell-balance::before { content: "Balance "; color: var(--muted); }
  .events tr.confirm-editor { display: block; padding: 10px; }
  .events tr.confirm-editor td { display: block; }
  /* "Has it cleared?" under a row: the question on its own line, then two buttons big enough to tap on purpose. */
  .events tr[data-ask] .confirm-label { flex: 1 1 100%; }
  .events tr[data-ask] .btn { flex: 1 1 0; height: 44px; }
  .view-switch button { min-height: 34px; padding: 6px 16px; font-size: 14px; }
  .events tr.cleared-summary { display: block; padding: 0; }
  .events tr.cleared-summary td { display: block; }
  .cleared-toggle { padding: 12px 0; }
  .cleared-toggle > span:first-child { width: 32px; }
  tr.income { background: var(--series-wash); box-shadow: inset 3px 0 0 var(--series); }
  tr.income td, tr.income td:first-child { background: none; box-shadow: none; padding-left: 0; }
  .group-stats { gap: 12px; flex-wrap: wrap; }
  .chart-wrap { overflow-x: auto; margin: 0 -16px; padding: 0 16px; }
  .chart { min-width: 640px; }
  .change { grid-template-columns: 24px minmax(0, 1fr); }
  .change-saves { grid-column: 2; text-align: left; }
  .change-saves br { display: none; }
  /* The button fills the row. (In a column, flex: 1 would squash it to the height of its text.) */
  .afford-form > .btn { align-self: stretch; }
  .form-actions .btn { flex: 1; }

  /* Logged purchases, deposits and transfers: two lines each (what and its amount, then the day and Edit /
     Remove), so nothing runs off the side. */
  .purchases, .purchases tbody { display: block; }
  .purchases tr {
    display: grid; grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "what amount" "date actions";
    align-items: start; column-gap: 12px; padding: 10px 0 4px; border-bottom: 1px solid var(--grid);
  }
  .purchases tr:last-child { border-bottom: 0; }
  .purchases td { padding: 0; border: 0; }
  .purchases td.what { grid-area: what; font-weight: 600; overflow-wrap: anywhere; }
  .purchases td.date { grid-area: date; align-self: center; font-size: 13px; white-space: normal; }
  .purchases td.num { grid-area: amount; font-weight: 600; }
  .purchases td.row-actions { grid-area: actions; align-self: center; margin-right: -12px; }

  /* Recurring paychecks and bills: the name and its amount, when it repeats, then the next date, its account
     and what it comes to a month. */
  .recurring thead { display: none; }
  .recurring, .recurring tbody { display: block; }
  .recurring tr {
    display: grid; grid-template-columns: auto minmax(0, 1fr) auto; column-gap: 8px; row-gap: 2px; padding: 12px 0;
    grid-template-areas: "name name amount" "when when when" "next account monthly";
    border-bottom: 1px solid var(--grid);
  }
  .recurring tr:last-child { border-bottom: 0; }
  .recurring td { padding: 0; border: 0; font-size: 13px; }
  .recurring .cell-name { grid-area: name; font-size: 15px; overflow-wrap: anywhere; }
  .recurring .cell-amount { grid-area: amount; font-size: 15px; font-weight: 600; }
  .recurring .cell-when { grid-area: when; }
  .recurring .cell-next { grid-area: next; white-space: normal; }
  .recurring .cell-account { grid-area: account; }
  .recurring .cell-account:not(:empty)::before { content: "· "; }
  .recurring .cell-monthly { grid-area: monthly; }
  .recurring td.empty { grid-column: 1 / -1; font-size: 15px; }

  /* Bill due days: each bill's name, then its due day and weekend rule side by side, its amount and the
     Confirmed tick, and what the bank shows under them. */
  .due-days thead { display: none; }
  .due-days, .due-days tbody { display: block; }
  .due-days tr {
    display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 3fr); gap: 8px 10px; padding: 14px 0;
    grid-template-areas: "name name" "day adjust" "amount ok" "bank bank";
    border-bottom: 1px solid var(--grid);
  }
  .due-days tr:last-child { border-bottom: 0; }
  .due-days td, .due-days td.bank { padding: 0; border: 0; min-width: 0; text-align: left; }
  .due-days .cell-name { grid-area: name; font-size: 16px; }
  .due-days .cell-day { grid-area: day; }
  .due-days .cell-adjust { grid-area: adjust; }
  .due-days .cell-amount { grid-area: amount; }
  .due-days .cell-ok { grid-area: ok; display: flex; align-items: center; gap: 8px; }
  .due-days .cell-ok label { font-size: 15px; color: var(--ink); }
  .due-days td.bank { grid-area: bank; }
  .due-days td.bank::before { content: "Your bank"; display: block; color: var(--muted); font-size: 12px; }
  .due-days select, .due-days .money-input { width: 100%; margin: 0; }
  .due-days .money-input input { text-align: left; }
  .due-days td.empty { grid-column: 1 / -1; }

  /* A table whose rows stack: the first cell is the row's name, and each cell after it says what it is
     (data-label), with its value on the right. */
  .stack thead { display: none; }
  .stack, .stack tbody, .stack tr { display: block; }
  .stack tr { padding: 12px 0; border-bottom: 1px solid var(--grid); }
  .stack tr:last-child { border-bottom: 0; }
  .stack td { display: flex; justify-content: space-between; gap: 16px; padding: 2px 0; border: 0;
    text-align: right; white-space: normal; }
  .stack td:first-child, .stack td.stack-name { display: block; text-align: left; font-weight: 600; padding-bottom: 4px; }
  .stack td:first-child .muted, .stack td.stack-name .muted { font-weight: 400; }
  .stack td.wide-only { display: none; }
  .payoff.stack td.date { padding-left: 0; }
  .loan-extras.stack tr.tried { margin: 0 -8px; padding-left: 8px; padding-right: 8px; border-radius: 8px; background: var(--fill); }
  .loan-extras.stack tr.tried td { background: none; }
  .stack td[data-label]::before { content: attr(data-label); flex: none; color: var(--muted); font-size: 13px;
    font-weight: 400; text-align: left; }
  .stack td:not([data-label]):not(:first-child) { justify-content: flex-end; padding-top: 6px; }
}

/* --- Account and household ------------------------------------------------------- */

.account-actions { margin-top: 10px; display: flex; flex-wrap: wrap; gap: 8px; }
.account-head { margin: 22px 0 6px; padding-top: 16px; border-top: 1px solid var(--grid); font-size: 16px; }
.badge-on { background: var(--in-wash); color: var(--in); }
p > .badge-on:first-child { margin-left: 0; }
.two-step-more { margin-top: 8px; }
.two-step-more summary { cursor: pointer; color: var(--accent); font-weight: 500; }
.two-step-more form { margin-top: 12px; }
.devices { list-style: none; margin: 0; padding: 0; }
.devices li { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 6px 12px;
  padding: 10px 0; }
.devices li + li { border-top: 1px solid var(--grid); }

/* Two-step sign-in: setting it up, and the recovery codes shown once. */
.two-step-setup .steps { margin: 0; padding-left: 22px; display: flex; flex-direction: column; gap: 20px; }
.two-step-setup .steps li > * { display: block; margin-top: 6px; }
.two-step-setup .steps form { margin-top: 10px; }
.qr-box { width: 200px; max-width: 100%; padding: 10px; background: #ffffff; border-radius: var(--radius-sm); }
.qr-box svg { display: block; width: 100%; height: auto; }
.setup-key, .recovery-codes code { font: 600 16px/1.5 ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  letter-spacing: 0.04em; overflow-wrap: anywhere; }
.recovery-codes { columns: 2; column-gap: 32px; margin: 12px 0 16px; padding-left: 28px; }
.recovery-codes li { padding: 3px 0; }
.recovery-codes + .copy-row { margin-bottom: 4px; }
.nowrap { white-space: nowrap; }
.page-back { margin: 0 0 6px; font-size: 14px; }  /* "‹ Accounts" above an account's own page */
.members { list-style: none; margin: 0 0 14px; padding: 0; }
.members li { padding: 10px 0; }
.members li + li { border-top: 1px solid var(--grid); }
.invite-link { margin: 0 0 14px; padding: 12px 14px; border-radius: var(--radius-sm); background: var(--accent-wash); }
.invite-link p { margin: 0 0 8px; font-size: 15px; }
.invite-link input { width: 100%; background: var(--surface); font-size: 14px; }
.copy-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.copy-row input { flex: 1 1 220px; width: auto; min-width: 0; }
.copy-row .btn { flex: none; }
.copy-status { margin: 8px 0 0; font-size: 14px; color: var(--ink-2); }
.copy-status:empty { display: none; }
.copy-status.copy-failed { color: var(--critical); }
@media (max-width: 600px) { .copy-row .btn { flex: 1 1 100%; } }  /* a full-width tap target under the link */
.signout-form { margin: 0; }
.signout-form .btn { width: 100%; justify-content: flex-start; }

/* --- Setup wizard -------------------------------------------------------------------- */

.setup { max-width: 680px; margin: 0 auto; padding-top: 24px; }
.setup h1 { margin: 4px 0 6px; }
.setup > .sub { margin: 0 0 18px; font-size: 16px; }
.setup-count { margin: 0; font-size: 13px; font-weight: 600; color: var(--ink-2); }
.setup-progress { height: 6px; background: var(--fill); border-radius: 999px; overflow: hidden; margin: 8px 0 12px; }
.setup-progress span { display: block; height: 100%; background: var(--accent); border-radius: 999px; }
.setup-steps { list-style: none; display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 22px; padding: 0; }
.setup-steps a { display: block; padding: 4px 11px; border-radius: 999px; font-size: 13px; font-weight: 500;
  color: var(--ink-2); background: var(--fill); }
.setup-steps a:hover { text-decoration: none; background: var(--fill-2); }
.setup-steps li.done a { color: var(--accent); background: var(--accent-wash); }
.setup-steps li[aria-current] a { color: var(--accent-ink); background: var(--accent); }
.setup-form { display: flex; flex-direction: column; gap: 16px; }
.setup-form .money-input { width: 180px; }
.setup-form .method-pick { margin: 0; }
.setup-actions { display: flex; flex-wrap: wrap; gap: 10px; justify-content: flex-end; }
.setup-sample {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px 16px;
  padding: 14px 16px; border-radius: var(--radius); background: var(--accent-wash); margin-bottom: 20px;
}
.setup-sample p { margin: 0; font-size: 15px; flex: 1 1 300px; }
.setup-list { list-style: none; padding: 4px 16px; }
.setup-list li { display: flex; align-items: center; gap: 12px; padding: 10px 0; }
.setup-list li + li { border-top: 1px solid var(--grid); }
.setup-list li > span:first-child { flex: 1; min-width: 0; }
.setup-list form { margin: 0; }
.setup-list .link-btn { margin: 0; }
.bill-rows { display: flex; flex-direction: column; gap: 8px; }
.bill-row { display: grid; grid-template-columns: minmax(0, 1fr) 140px 76px; gap: 8px; align-items: center; }
.bill-row .money-input { width: auto; }
.bill-row input { min-width: 0; width: 100%; }
.bill-head { font-size: 13px; font-weight: 500; color: var(--ink-2); }
.setup-back { margin: 4px 0 24px; font-size: 15px; }
.setup-card {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 14px 20px;
  background-image: linear-gradient(var(--accent-wash), var(--accent-wash));
}
.setup-card h2 { margin-bottom: 4px; }
@media (max-width: 600px) {
  .setup { padding-top: 8px; }
  .bill-row { grid-template-columns: minmax(0, 1fr) 104px 52px; gap: 6px; }
  .bill-row > input:first-child { padding-left: 10px; padding-right: 6px; }  /* room for "Rent or mortgage" */
  .setup-actions .btn { flex: 1; }
}

/* --- This month and months ahead ---------------------------------------------------- */

.next-months { display: flex; align-items: center; gap: 14px; color: var(--ink); }
.next-months:hover { text-decoration: none; background: var(--surface-2); }
.next-months > span { flex: 1; display: flex; flex-direction: column; gap: 2px; }
.next-months .muted { font-size: 14px; }
.month-summary td a { font-weight: 600; }
@media (max-width: 600px) { .month-summary .wide-only { display: none; } }  /* each month's card has them */
.zone-form { margin-bottom: 4px; }
.zone-form label { min-width: 0; max-width: 100%; }  /* long zone names shrink to the screen, not past it */
.zone-form select { max-width: 100%; }

/* --- Bank history and CSV import ------------------------------------------------------ */

.upload-form { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 12px; }
.upload-form > label.grow { flex: 1 1 260px; }
.upload-form input[type="file"] { padding: 8px; font-size: 15px; }
.upload-form input[name="account"] { width: 140px; }
.how-to { margin-top: 14px; font-size: 14px; color: var(--ink-2); }
.how-to summary { cursor: pointer; color: var(--accent); font-weight: 500; }
.how-to ol { margin: 8px 0 0; padding-left: 20px; }
.how-to li { padding: 2px 0; }
.found-head { margin: 4px 0 0; font-size: 15px; color: var(--ink-2); }
.found-form > .btn { margin-top: 12px; }

/* --- Accounts ------------------------------------------------------------------------- */

.tile-accounts { list-style: none; margin: 8px 0 0; padding: 8px 0 0; border-top: 1px solid var(--grid); font-size: 13px; }
.tile-accounts li { display: flex; justify-content: space-between; gap: 8px; color: var(--ink-2); padding: 1px 0; }
.account-rows { list-style: none; margin: 0; padding: 0; }
.account-rows li { padding: 12px 0; }
.account-rows li + li { border-top: 1px solid var(--grid); }
.account-rows .hint { margin: 6px 0 0; }
.account-rows .badge { align-self: center; margin-left: 0; }
.goals { list-style: none; margin: 0 0 6px; padding: 0; }
.goals li { padding: 12px 0; }
.goals li + li { border-top: 1px solid var(--grid); }
.goal-line { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 2px 12px; align-items: baseline; margin-bottom: 8px; }
.goal-meter { margin-bottom: 6px; }
.goal-meter.done > span { background: var(--in); }
.goal-note { margin: 0; font-size: 13px; }
.goal-edit { margin-top: 6px; }
.goal-edit summary { cursor: pointer; color: var(--accent); font-size: 14px; font-weight: 500; }
.goal-edit form { margin-top: 10px; }
.hint.over { color: var(--critical); }
.account-actions-row { display: flex; flex-wrap: wrap; gap: 8px 24px; margin-top: 10px; }
.account-actions-row details { flex: 1 1 260px; }
details.settled { margin-top: 8px; }

/* --- Suggestions as you type (pickers.js): What, and a long category list ------------------- */

.has-suggest { position: relative; }
.suggest-list {
  position: absolute; z-index: 30; left: 0; right: 0; top: 100%; margin: 4px 0 0; padding: 4px;
  min-width: 220px; max-height: 264px; overflow-y: auto; list-style: none;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm);
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.14);
}
.suggest-list li {
  display: flex; justify-content: space-between; align-items: baseline; gap: 12px; padding: 10px 12px;
  border-radius: 8px; font-size: 16px; font-weight: 400; color: var(--ink); cursor: pointer;
}
.suggest-list li[aria-selected="true"], .suggest-list li:hover { background: var(--hover); }
.suggest-note { color: var(--ink-2); font-size: 14px; white-space: nowrap; }
.category-search { min-width: 180px; }
.filter-box { display: block; max-width: 360px; margin-bottom: 8px; }
.suggestion-rows { list-style: none; margin: 0; padding: 0; }
.suggestion-rows li { padding: 12px 0; }
.suggestion-rows li + li { border-top: 1px solid var(--grid); }
.suggestion-rows summary { cursor: pointer; }
.suggestion-rows form { margin-top: 10px; }
.by-category tfoot th, .by-category tfoot td, .sources tfoot td { font-weight: 600; font-size: inherit; color: var(--ink); text-transform: none; letter-spacing: 0; border-top: 1px solid var(--grid); }
.by-category tfoot td.muted { color: var(--ink-2); }
details.settled summary { cursor: pointer; color: var(--ink-2); font-size: 15px; }
.goal-line .inline-form, li > .inline-form { display: inline; }

/* --- Mortgage and car loans ---------------------------------------------------------- */

.card .loan-list { margin: 0 -20px -8px; background: none; box-shadow: none; border-radius: 0; }
.card .loan-list a { padding: 10px 20px; }
.card .loan-list li + li a::before { left: 64px; }
.loan-plan { margin: -8px 0 12px; }
.loan-recurring { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 0 0 16px; }
.loan-split { max-width: 420px; }
.loan-split .total td { font-weight: 600; border-top: 1px solid var(--grid); }
.loan-extras .tried td { font-weight: 600; background: var(--fill); }
.loan-try { margin-top: 12px; }
@media (max-width: 899px) {
  .card .loan-list { margin: 0 -16px -8px; }
  .card .loan-list a { padding: 10px 16px; }
  .card .loan-list li + li a::before { left: 60px; }
}

/* --- Invites with an email --------------------------------------------------------------- */

.invite-form { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; }
.invite-form label.grow { flex: 1 1 240px; }

/* --- Your data ---------------------------------------------------------------------------- */

.delete-account { margin-top: 16px; padding-top: 12px; border-top: 1px solid var(--grid); }
.delete-account summary { cursor: pointer; color: var(--critical); font-size: 14px; font-weight: 500; }
.delete-account .hint { margin: 8px 0 12px; }
