/* MoneyBudget styles. System fonts only, light and dark via prefers-color-scheme. */

:root {
  color-scheme: light dark;
  --bg: #f5f6f4;
  --surface: #ffffff;
  --surface-2: #eef0ed;
  --text: #19211e;
  --muted: #56615d;
  --border: #dde1dd;
  --border-strong: #8a9490;
  --accent: #0f6b4f;
  --accent-hover: #0b5640;
  --accent-text: #ffffff;
  --accent-soft: #e2f1ea;
  --link: #0c5f46;
  --focus: #1a73e8;
  --pos-bg: #d8efe3;
  --pos-text: #0a5239;
  --neg-bg: #fbdfdb;
  --neg-text: #9c1f14;
  --warn-bg: #fdebc5;
  --warn-text: #6f4300;
  --info-bg: #e3edf9;
  --info-text: #174a85;
  --zero-bg: #eceeeb;
  --series-1: #257de0;
  --series-2: #f47230;
  --grid: #e3e6e3;
  --shadow: 0 1px 2px rgba(20, 30, 25, 0.06), 0 2px 8px rgba(20, 30, 25, 0.04);
  --radius: 12px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111614;
    --surface: #1b211e;
    --surface-2: #252c29;
    --text: #e9edeb;
    --muted: #a5afab;
    --border: #2f3834;
    --border-strong: #7c8783;
    --accent: #4cc49a;
    --accent-hover: #6bd3ad;
    --accent-text: #05261b;
    --accent-soft: #173529;
    --link: #6fd6b0;
    --focus: #8ab4f8;
    --pos-bg: #153d2e;
    --pos-text: #96e3c2;
    --neg-bg: #4b1d18;
    --neg-text: #ffb8ae;
    --warn-bg: #473408;
    --warn-text: #ffdc93;
    --info-bg: #1a3048;
    --info-text: #b3d3fa;
    --zero-bg: #2a312e;
    --series-1: #338ced;
    --series-2: #e76624;
    --grid: #2c3531;
    --shadow: none;
  }
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

h1, h2, h3 { line-height: 1.25; margin: 0 0 0.5em; letter-spacing: -0.01em; }
h1 { font-size: 1.6rem; }
h2 { font-size: 1.15rem; }
h3 { font-size: 1rem; margin-top: 1.25em; }
p { margin: 0 0 1em; }
ul, ol { margin: 0 0 1em; padding-left: 1.3em; }
a { color: var(--link); text-underline-offset: 2px; }
a:hover { text-decoration-thickness: 2px; }
small, .small { font-size: 0.85rem; }
.muted { color: var(--muted); }
strong { font-weight: 650; }
[hidden] { display: none !important; }

:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 4px; }
main:focus { outline: none; }

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}
.skip-link {
  position: absolute; left: 8px; top: -60px; z-index: 100; padding: 10px 14px;
  background: var(--surface); color: var(--text); border-radius: 8px; box-shadow: var(--shadow);
}
.skip-link:focus { top: 8px; }
.js .js-hide { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0, 0, 0, 0); }

.amt { font-variant-numeric: tabular-nums; white-space: nowrap; }
.amt.neg, .stat-value.neg { color: var(--neg-text); }
.amt.pos { color: var(--pos-text); }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.warn-text { color: var(--warn-text); }

/* ---------- header and navigation ---------- */

.site-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 20;
}
.header-inner {
  max-width: 1000px; margin: 0 auto; padding: 0 16px; height: 56px;
  display: flex; align-items: center; gap: 20px;
}
.logo {
  display: inline-flex; align-items: center; gap: 8px; font-weight: 700; font-size: 1.05rem;
  color: var(--text); text-decoration: none; letter-spacing: -0.02em;
}
.logo-mark {
  width: 22px; height: 22px; border-radius: 7px; background: var(--accent);
  box-shadow: inset 0 0 0 5px var(--accent), inset 0 0 0 8px var(--surface);
}
.icon { flex: none; }
.main-nav { display: flex; align-items: center; gap: 4px; flex: 1; }
.main-nav a, .header-link {
  display: inline-flex; align-items: center; gap: 6px; padding: 8px 12px; border-radius: 8px;
  color: var(--muted); text-decoration: none; font-weight: 550; font-size: 0.95rem;
}
.main-nav a .icon, .header-link .icon { width: 18px; height: 18px; }
.main-nav a:hover, .header-link:hover { background: var(--surface-2); color: var(--text); }
.main-nav a[aria-current], .header-link[aria-current] { background: var(--accent-soft); color: var(--pos-text); }
.main-nav .nav-add { margin-left: auto; background: var(--accent); color: var(--accent-text); }
.main-nav .nav-add:hover, .main-nav .nav-add[aria-current] { background: var(--accent-hover); color: var(--accent-text); }
.header-actions { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.in-app .header-actions { margin-left: 0; }

@media (max-width: 760px) {
  .in-app { padding-bottom: 68px; }
  .in-app .header-actions { margin-left: auto; }
  .main-nav {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; gap: 0;
    background: var(--surface); border-top: 1px solid var(--border);
    padding: 4px 4px calc(4px + env(safe-area-inset-bottom));
    justify-content: space-around;
  }
  .main-nav a {
    flex: 1; flex-direction: column; gap: 2px; padding: 6px 2px; font-size: 0.7rem; min-height: 52px;
    justify-content: center; border-radius: 10px;
  }
  .main-nav a .icon { width: 22px; height: 22px; }
  .main-nav a:nth-child(1) { order: 1; }
  .main-nav a:nth-child(2) { order: 2; }
  .main-nav .nav-add { order: 3; margin: 0 4px; flex: 0 0 64px; }
  .main-nav a:nth-child(3) { order: 4; }
  .main-nav a:nth-child(4) { order: 5; }
  .header-link span { display: none; }
  .public .header-link { font-size: 0.9rem; }
}
.narrow-only { display: none; }
@media (max-width: 480px) {
  .header-inner { gap: 8px; }
  .wide-only { display: none; }
  .narrow-only { display: inline; }
}

.banner {
  background: var(--info-bg); color: var(--info-text); text-align: center; padding: 8px 16px; font-size: 0.9rem;
}
.banner a { color: inherit; font-weight: 650; }
.banner-warn { background: var(--warn-bg); color: var(--warn-text); }

main { width: 100%; max-width: 1000px; margin: 0 auto; padding: 24px 16px 48px; flex: 1; }
main.narrow { max-width: 640px; }

.site-footer { border-top: 1px solid var(--border); padding: 16px; font-size: 0.85rem; }
.site-footer nav { max-width: 1000px; margin: 0 auto; display: flex; flex-wrap: wrap; gap: 6px 20px; justify-content: center; }
.site-footer a { color: var(--muted); padding: 4px 0; }
.site-footer .cancel-link { font-weight: 650; color: var(--text); }

/* ---------- building blocks ---------- */

.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 20px; margin: 0 0 16px; box-shadow: var(--shadow);
}
.card > :last-child { margin-bottom: 0; }
.stack { display: grid; gap: 16px; }
.stack-large { display: grid; gap: 20px; }
.stack-large > .card { margin: 0; }
.actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin: 0; }
p.actions { margin-bottom: 1em; }
.actions-center { justify-content: center; }
.page-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 16px; }
.page-head h1 { margin: 0; }
.page-head p { margin: 4px 0 0; }
.back { margin: 0 0 8px; font-size: 0.9rem; }
.back a { text-decoration: none; }
.lead { font-size: 1.1rem; color: var(--muted); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 40px; padding: 8px 16px; border-radius: 9px;
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--text);
  font: inherit; font-weight: 600; font-size: 0.95rem; text-decoration: none; cursor: pointer; white-space: nowrap;
}
.btn:hover { background: var(--surface-2); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn-ghost { border-color: transparent; background: transparent; color: var(--link); }
.btn-danger { background: var(--neg-text); border-color: var(--neg-text); color: var(--surface); }
.btn-danger:hover { background: var(--neg-text); filter: brightness(0.9); }
.btn-danger-ghost { border-color: transparent; background: transparent; color: var(--neg-text); }
.btn-small { min-height: 32px; padding: 4px 10px; font-size: 0.85rem; }
.btn-large { min-height: 48px; padding: 12px 22px; font-size: 1.05rem; }
.btn-block { width: 100%; }
.btn-icon { width: 40px; padding: 0; font-size: 1.2rem; }
.btn-icon.btn-small { width: 32px; font-size: 1rem; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.link-button { background: none; border: 0; padding: 4px; font: inherit; color: var(--link); text-decoration: underline; cursor: pointer; }

.field { display: grid; gap: 6px; align-content: start; margin: 0; padding: 0; border: 0; min-width: 0; }
.field > span, .field > legend { font-weight: 600; font-size: 0.92rem; padding: 0; }
.field small { color: var(--muted); font-weight: 400; }
input[type="text"], input[type="email"], input[type="password"], input[type="date"], input[type="month"],
input[type="number"], input[type="search"], input[type="file"], select, textarea {
  width: 100%; min-height: 42px; padding: 8px 12px; border-radius: 9px;
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--text); font: inherit;
}
input[readonly] { background: var(--surface-2); color: var(--muted); }
textarea { min-height: 84px; resize: vertical; }
input[type="checkbox"], input[type="radio"] { width: 18px; height: 18px; accent-color: var(--accent); flex: none; margin: 3px 0 0; }
.input-money { position: relative; display: block; }
.input-money input { padding-right: 34px; text-align: right; font-variant-numeric: tabular-nums; }
.input-money > span { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.input-money-large input { font-size: 1.5rem; font-weight: 650; min-height: 56px; }
.input-narrow { width: 72px !important; display: inline-block; min-height: 34px !important; padding: 4px 8px !important; }
.choice { display: flex; gap: 10px; align-items: flex-start; padding: 6px 0; cursor: pointer; }
.choice span { display: grid; }
.choice small { color: var(--muted); }
.inline-form { display: flex; gap: 8px; align-items: center; flex: 1; min-width: 0; }
.inline-form input[type="text"] { flex: 1; min-width: 0; }
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; margin-bottom: 16px; }
.delete-form { margin: 8px 0 24px; text-align: right; }

.segmented { display: flex; border: 1px solid var(--border-strong); border-radius: 10px; padding: 3px; gap: 3px; background: var(--surface-2); }
.segmented label { flex: 1; position: relative; }
.segmented input { position: absolute; opacity: 0; inset: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.segmented span { display: block; text-align: center; padding: 8px 6px; border-radius: 7px; font-weight: 600; font-size: 0.95rem; color: var(--muted); }
.segmented input:checked + span { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.segmented input:focus-visible + span { outline: 3px solid var(--focus); outline-offset: 1px; }

.notice { padding: 12px 14px; border-radius: 10px; margin: 0 0 16px; font-size: 0.95rem; background: var(--info-bg); color: var(--info-text); }
.notice a { color: inherit; font-weight: 650; }
.notice ul { margin: 0; }
.notice-ok { background: var(--pos-bg); color: var(--pos-text); }
.notice-error { background: var(--neg-bg); color: var(--neg-text); }
.notice-warn { background: var(--warn-bg); color: var(--warn-text); }

.empty { text-align: center; padding: 32px 16px; color: var(--muted); }
.empty h1, .empty h2 { color: var(--text); }
.empty > :last-child { margin-bottom: 0; }

.tag { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 0.75rem; font-weight: 600; background: var(--zero-bg); color: var(--muted); }
.tag-warn { background: var(--warn-bg); color: var(--warn-text); }
.tag-goal { background: var(--accent-soft); color: var(--pos-text); }

.facts { display: grid; grid-template-columns: minmax(120px, auto) 1fr; gap: 8px 16px; margin: 0 0 16px; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; }
@media (max-width: 480px) { .facts { grid-template-columns: 1fr; gap: 0; } .facts dd { margin-bottom: 10px; } }

.status { display: inline-block; padding: 3px 12px; border-radius: 999px; font-weight: 650; font-size: 0.9rem; margin-bottom: 12px; }
.status-ok { background: var(--pos-bg); color: var(--pos-text); }
.status-info { background: var(--info-bg); color: var(--info-text); }
.status-warn { background: var(--warn-bg); color: var(--warn-text); }
.status-error { background: var(--neg-bg); color: var(--neg-text); }
.danger-zone { border-color: var(--neg-text); }

.table-scroll { overflow-x: auto; margin-bottom: 12px; border-radius: 8px; }
.data-table, .raw-table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
.data-table th, .data-table td, .raw-table td { padding: 8px 10px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: top; }
.data-table th.num, .data-table td.num { text-align: right; }
.data-table thead th { color: var(--muted); font-weight: 600; font-size: 0.82rem; }
.raw-table td { white-space: nowrap; max-width: 220px; overflow: hidden; text-overflow: ellipsis; color: var(--muted); }
.raw-table .is-header td { font-weight: 650; color: var(--text); background: var(--surface-2); }
.sticky-actions { position: sticky; bottom: 0; padding: 12px 0; background: linear-gradient(transparent, var(--bg) 30%); z-index: 5; }
@media (max-width: 760px) { .sticky-actions { bottom: 68px; } }

dialog {
  border: 1px solid var(--border); border-radius: 16px; padding: 0; width: min(480px, calc(100vw - 24px));
  background: var(--surface); color: var(--text); box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}
dialog::backdrop { background: rgba(10, 15, 12, 0.5); }
dialog .card { border: 0; margin: 0; box-shadow: none; }
dialog h1 { font-size: 1.25rem; }

/* ---------- public pages ---------- */

.hero { text-align: center; padding: 40px 0 32px; }
.hero h1 { font-size: clamp(2rem, 6vw, 3rem); letter-spacing: -0.03em; margin-bottom: 16px; }
.hero .lead { max-width: 560px; margin: 0 auto 24px; }
.features { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 16px; margin-bottom: 16px; }
.features .card { margin: 0; }
.steps ol { margin-bottom: 0; display: grid; gap: 8px; }
.pricing { text-align: center; }
.price strong { font-size: 2.2rem; letter-spacing: -0.02em; }
.price span { color: var(--muted); }
.checks { list-style: none; padding: 0; display: inline-grid; gap: 6px; text-align: left; }
.checks li::before { content: "✓"; color: var(--accent); font-weight: 700; margin-right: 8px; }

.prose h2 { margin-top: 1.6em; }
.prose h3 { margin-top: 1.2em; }
.placeholder { background: #ffe58a; color: #3b2c00; padding: 1px 5px; border-radius: 4px; font-weight: 600; }

.auth-card { margin-top: 24px; padding: 28px 24px; }
.auth-card form + form, .auth-alt { margin-top: 16px; }
.auth-alt { text-align: center; font-size: 0.92rem; margin-bottom: 0; }

.cancel-kind .reason-field { display: none; margin-top: 8px; }
.cancel-kind:has(#kind-extraordinary:checked) .reason-field { display: grid; }

/* ---------- onboarding and accounts ---------- */

.step-no {
  display: inline-grid; place-items: center; width: 26px; height: 26px; border-radius: 50%;
  background: var(--accent); color: var(--accent-text); font-size: 0.9rem; margin-right: 6px;
}
.starter-group { border: 0; padding: 0; margin: 0 0 16px; }
.starter-group legend { font-weight: 650; padding: 0; margin-bottom: 6px; }
.starter-row { display: flex; align-items: center; gap: 10px; margin-bottom: 6px; }
.starter-row input[type="checkbox"] { margin: 0; width: 20px; height: 20px; }
.starter-row input[type="text"] { min-height: 38px; }
.starter-row:has(input[type="checkbox"]:not(:checked)) input[type="text"] { opacity: 0.5; text-decoration: line-through; }

.when-credit { display: none; }
.account-form:has(.account-type option[value="credit"]:checked) .when-credit { display: inline; }
.account-form:has(.account-type option[value="credit"]:checked) .when-not-credit { display: none; }

.account-list { list-style: none; padding: 0; display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
.account-card { margin: 0; padding: 0; overflow: hidden; }
.account-main {
  display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 16px 18px;
  color: var(--text); text-decoration: none; font-size: 1.05rem;
}
.account-main:hover { background: var(--surface-2); }
.account-main span:first-child { display: grid; }
.account-main small { color: var(--muted); }
.account-actions { display: flex; flex-wrap: wrap; gap: 4px 16px; margin: 0; padding: 10px 18px; border-top: 1px solid var(--border); font-size: 0.88rem; }
.closed-accounts { margin-top: 24px; }
.closed-accounts summary { cursor: pointer; color: var(--muted); margin-bottom: 12px; }

/* ---------- budget ---------- */

.month-nav { display: flex; align-items: center; gap: 8px; margin-bottom: 16px; }
.month-nav h1 { margin: 0; min-width: 9.5em; text-align: center; font-size: 1.35rem; }

.rta {
  display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 12px 24px;
  border-radius: var(--radius); padding: 16px 20px; margin-bottom: 16px;
  background: var(--zero-bg); color: var(--text);
}
.rta-pos { background: var(--pos-bg); color: var(--pos-text); }
.rta-neg { background: var(--neg-bg); color: var(--neg-text); }
.rta p { margin: 0; }
.rta-label { font-weight: 650; font-size: 0.9rem; }
.rta-amount { font-size: 2rem; font-weight: 700; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; line-height: 1.2; }
.rta-hint { font-size: 0.9rem; }
.rta-action { display: grid; gap: 4px; justify-items: start; }

.budget { width: 100%; border-collapse: collapse; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
.budget th, .budget td { padding: 8px 12px; text-align: left; vertical-align: middle; }
.budget thead th { font-size: 0.78rem; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; border-bottom: 1px solid var(--border); }
.budget .num { text-align: right; }
.budget .group-row th, .budget .group-row td { background: var(--surface-2); font-weight: 650; font-size: 0.9rem; border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); }
.budget .group-row td { color: var(--muted); font-weight: 600; }
.cat-row th { font-weight: 500; }
.cat-row + .cat-row th, .cat-row + .cat-row td { border-top: 1px solid var(--border); }
.cat-name { color: var(--text); text-decoration: none; font-weight: 550; }
.cat-name:hover { text-decoration: underline; }
.cat-meta { display: block; font-size: 0.8rem; color: var(--muted); font-weight: 400; }
.goal { display: flex; align-items: center; gap: 8px; margin-top: 3px; flex-wrap: wrap; }
.goal progress { width: 64px; height: 6px; flex: none; border: 0; border-radius: 3px; background: var(--zero-bg); overflow: hidden; appearance: none; -webkit-appearance: none; }
.goal progress::-webkit-progress-bar { background: var(--zero-bg); }
.goal progress::-webkit-progress-value { background: var(--accent); }
.goal progress::-moz-progress-bar { background: var(--accent); }
.goal progress.is-open::-webkit-progress-value { background: #c98a00; }
.goal progress.is-open::-moz-progress-bar { background: #c98a00; }
.goal-text { font-size: 0.8rem; color: var(--muted); font-weight: 400; text-align: left; }
button.goal-fund {
  background: var(--warn-bg); color: var(--warn-text); border: 0; border-radius: 6px; padding: 2px 8px;
  font: inherit; font-size: 0.8rem; cursor: pointer; white-space: normal;
}
button.goal-fund:hover { filter: brightness(0.96); text-decoration: underline; }
.assign-input {
  width: 108px !important; min-height: 36px !important; padding: 4px 8px !important; text-align: right;
  font-variant-numeric: tabular-nums; border-color: transparent !important; background: transparent !important;
}
.assign-input:hover { border-color: var(--border-strong) !important; }
.assign-input:focus { border-color: var(--border-strong) !important; background: var(--surface) !important; }
.assign-input.is-saving { opacity: 0.6; }
.col-activity a { color: var(--text); text-decoration: none; }
.col-activity a:hover { text-decoration: underline; }
.pill {
  display: inline-block; padding: 3px 10px; border-radius: 999px; font-weight: 650; font-size: 0.92rem;
  font-variant-numeric: tabular-nums; text-decoration: none; background: var(--zero-bg); color: var(--muted);
}
.pill:hover { filter: brightness(0.96); text-decoration: underline; }
.pill-pos { background: var(--pos-bg); color: var(--pos-text); }
.pill-neg { background: var(--neg-bg); color: var(--neg-text); }
.pill-credit { background: var(--warn-bg); color: var(--warn-text); }
.pill-note { display: block; font-size: 0.72rem; color: var(--muted); margin-top: 2px; white-space: normal; }
.table-footer { margin: 12px 0 0; font-size: 0.9rem; text-align: right; }
#budget-form > .btn { margin-top: 12px; }

@media (max-width: 620px) {
  .budget .col-activity { display: none; }
  .budget th, .budget td { padding: 8px 6px; }
  .budget th:first-child { padding-left: 12px; overflow-wrap: anywhere; hyphens: auto; }
  .budget td:last-child, .budget th:last-child { padding-right: 12px; }
  .assign-input { width: 84px !important; font-size: 0.95rem; }
  .pill { padding: 3px 8px; font-size: 0.88rem; }
  .rta-amount { font-size: 1.7rem; }
  .month-nav h1 { min-width: 0; flex: 1; font-size: 1.15rem; }
}

/* ---------- categories and goals ---------- */

.manage-group.is-hidden { opacity: 0.75; }
.manage-group-head { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 12px; }
.manage-tools { display: flex; gap: 6px; align-items: center; }
.sort-buttons { display: inline-flex; gap: 4px; }
.manage-list { list-style: none; padding: 0; margin: 0 0 12px; }
.manage-list li { display: flex; align-items: center; gap: 8px; padding: 6px 0; border-bottom: 1px solid var(--border); }
.manage-list li > a { flex: 1; color: var(--text); font-weight: 550; text-decoration: none; padding: 4px 0; }
.manage-list li > a:hover { text-decoration: underline; }
.manage-list li.is-hidden > a { color: var(--muted); text-decoration: line-through; }
.add-form input { min-height: 36px; }

.goal-form .goal-amount, .goal-form .goal-date, .goal-form .goal-repeat, .when-recurring { display: none; }
.goal-form:has([value="monthly"]:checked, [value="by_date"]:checked, [value="recurring"]:checked, [value="debt_monthly"]:checked) .goal-amount { display: grid; }
.goal-form:has([value="by_date"]:checked, [value="recurring"]:checked, [value="debt_by_date"]:checked) .goal-date { display: grid; }
.goal-form:has([name="type"][value="recurring"]:checked) .goal-repeat { display: grid; }
.goal-form:has([name="type"][value="recurring"]:checked) .when-recurring { display: inline; }
.goal-form:has([name="type"][value="recurring"]:checked) .when-not-recurring { display: none; }
.repeat-row { display: flex; flex-wrap: wrap; gap: 4px 24px; }
.repeat-row .choice { align-items: center; }

/* ---------- transactions ---------- */

.filters { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; align-items: center; }
.filters input, .filters select { width: auto; flex: 1 1 150px; min-height: 40px; }
.filters label { display: inline-flex; align-items: center; gap: 6px; font-size: 0.9rem; color: var(--muted); }

.tx-list { list-style: none; padding: 0; }
.tx { display: grid; grid-template-columns: 92px 1fr auto; gap: 4px 12px; align-items: baseline; padding: 10px 16px; border-bottom: 1px solid var(--border); }
.tx:last-child { border-bottom: 0; }
.tx-date { color: var(--muted); font-size: 0.88rem; font-variant-numeric: tabular-nums; }
.tx-main { min-width: 0; display: grid; gap: 2px; }
.tx-main a { color: var(--text); font-weight: 550; text-decoration: none; overflow-wrap: anywhere; }
.tx-main a:hover { text-decoration: underline; }
.tx-main small { color: var(--muted); overflow-wrap: anywhere; }
.tx-main select { margin-top: 6px; max-width: 360px; }
.tx-amount { font-weight: 600; }
@media (max-width: 560px) {
  .tx { grid-template-columns: 1fr auto; padding: 10px 12px; }
  .tx-date { grid-column: 1 / -1; font-size: 0.78rem; }
}
.pager { display: flex; justify-content: space-between; margin-top: 16px; }

.tx-form .only-transfer, .tx-form .only-transfer-inline { display: none; }
.tx-form:has([name="type"][value="transfer"]:checked, [type="hidden"][name="type"][value="transfer"]) .only-transfer { display: block; }
.tx-form:has([name="type"][value="transfer"]:checked, [type="hidden"][name="type"][value="transfer"]) .only-transfer-inline { display: inline; }
.tx-form:has([name="type"][value="transfer"]:checked, [type="hidden"][name="type"][value="transfer"]) .only-normal,
.tx-form:has([name="type"][value="transfer"]:checked, [type="hidden"][name="type"][value="transfer"]) .only-normal-inline { display: none; }

/* ---------- import ---------- */

.review-list { list-style: none; padding: 0; }
.review-row {
  display: grid; grid-template-columns: 24px 88px 1fr 110px; gap: 6px 12px; align-items: center;
  padding: 10px 16px; border-bottom: 1px solid var(--border);
}
.review-row:last-child { border-bottom: 0; }
.review-row > input[type="checkbox"] { margin: 0; }
.review-row.is-duplicate { background: var(--surface-2); }
.review-date { color: var(--muted); font-size: 0.88rem; font-variant-numeric: tabular-nums; }
.review-amount { grid-column: 4; grid-row: 1; text-align: right; font-weight: 600; }
.review-fields { grid-column: 3; grid-row: 1; display: grid; grid-template-columns: 1fr 1fr; gap: 8px; min-width: 0; }
.review-fields input, .review-fields select { min-height: 36px; padding: 4px 8px; font-size: 0.92rem; min-width: 0; }
.review-memo { grid-column: 3 / -1; font-size: 0.82rem; color: var(--muted); overflow-wrap: anywhere; }
.review-row:has(> input[type="checkbox"]:not(:checked)) .review-fields,
.review-row:has(> input[type="checkbox"]:not(:checked)) .review-amount { opacity: 0.45; }
@media (max-width: 700px) {
  .review-row { grid-template-columns: 24px 1fr auto; padding: 10px 12px; }
  .review-date { grid-column: 2; }
  .review-amount { grid-column: 3; }
  .review-fields { grid-column: 2 / -1; grid-row: 2; grid-template-columns: 1fr; }
  .review-memo { grid-column: 2 / -1; }
}
.skipped { margin: 12px 0; font-size: 0.9rem; color: var(--muted); }

/* ---------- reports ---------- */

.report-filters { display: flex; flex-wrap: wrap; gap: 8px 16px; align-items: center; margin-bottom: 16px; }
.report-filters .filters { margin: 0; }
.report-filters .filters input { flex: 0 1 auto; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { padding: 6px 12px; border-radius: 999px; border: 1px solid var(--border-strong); color: var(--text); text-decoration: none; font-size: 0.88rem; background: var(--surface); }
.chip:hover { background: var(--surface-2); }
.chip[aria-current] { background: var(--text); color: var(--surface); border-color: var(--text); }

.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-bottom: 16px; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; display: grid; gap: 2px; box-shadow: var(--shadow); min-width: 0; }
.stat-label { font-size: 0.85rem; color: var(--muted); }
.stat-value { font-size: 1.35rem; font-weight: 700; font-variant-numeric: tabular-nums; letter-spacing: -0.01em; overflow-wrap: anywhere; }
@media (max-width: 560px) { .stats { grid-template-columns: 1fr; gap: 8px; } .stat { grid-template-columns: 1fr auto; align-items: baseline; } .stat-value { font-size: 1.15rem; } }

.s1 { fill: var(--series-1); background: var(--series-1); }
.s2 { fill: var(--series-2); background: var(--series-2); }

.spend-list, .spend-sub { list-style: none; padding: 0; margin: 0; }
.spend-list > li { border-bottom: 1px solid var(--border); }
.spend-list > li:last-child { border-bottom: 0; }
.spend-list summary, .spend-sub li {
  display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; padding: 10px 0; align-items: baseline;
}
.spend-list summary { cursor: pointer; list-style: none; }
.spend-list summary::-webkit-details-marker { display: none; }
.spend-list summary .spend-name::before { content: "▸"; display: inline-block; width: 1.1em; color: var(--muted); }
.spend-list details[open] > summary .spend-name::before { content: "▾"; }
.spend-name { font-weight: 600; }
.spend-sub .spend-name { font-weight: 500; color: var(--text); }
.spend-value { font-variant-numeric: tabular-nums; font-weight: 600; }
.spend-bar { grid-column: 1 / -1; }
.spend-share { grid-column: 1 / -1; font-size: 0.8rem; color: var(--muted); }
.spend-sub { padding: 0 0 8px 1.1em; }
.spend-sub li { padding: 6px 0; }
.spend-sub .hbar { height: 6px; }
.hbar { display: block; width: 100%; height: 10px; }
.spend-sub .hbar rect { height: 6px; }

.chart { margin: 0; position: relative; }
.legend { list-style: none; padding: 0; margin: 0 0 8px; display: flex; gap: 16px; font-size: 0.88rem; color: var(--muted); }
.legend li { display: inline-flex; align-items: center; gap: 6px; }
.swatch { width: 12px; height: 12px; border-radius: 3px; display: inline-block; }
.chart-scroll { overflow-x: auto; }
.trend { display: block; min-width: 300px; }
.trend.chart-lg { min-width: 720px; }
.trend.chart-xl { min-width: 1080px; }
.trend .grid { stroke: var(--grid); stroke-width: 1; }
.trend .grid.axis { stroke: var(--border-strong); }
.trend .tick, .trend .xlabel { fill: var(--muted); font-size: 11px; font-family: var(--font); }
.trend .xyear { font-size: 10px; }
.trend .hit { fill: transparent; cursor: default; outline-offset: -2px; }
.trend .month:hover .hit, .trend .hit:focus-visible { fill: var(--text); fill-opacity: 0.05; }
.trend .month { overflow: visible; }
.chart-table { margin-top: 8px; font-size: 0.9rem; }
.chart-table summary { cursor: pointer; color: var(--link); margin-bottom: 8px; }
.chart-tip {
  position: absolute; z-index: 10; pointer-events: none; background: var(--surface); color: var(--text);
  border: 1px solid var(--border); border-radius: 10px; padding: 8px 12px; box-shadow: 0 6px 24px rgba(0, 0, 0, 0.16);
  font-size: 0.85rem; min-width: 150px;
}
.chart-tip-title { color: var(--muted); margin-bottom: 4px; }
.chart-tip-row { display: flex; align-items: center; gap: 8px; }
.chart-tip-row strong { font-variant-numeric: tabular-nums; }
.chart-tip-row span:last-child { color: var(--muted); }
.chart-tip-key { width: 12px; height: 3px; border-radius: 2px; flex: none; }

@media (prefers-reduced-motion: no-preference) {
  .btn, .main-nav a, .pill { transition: background-color 0.12s ease, filter 0.12s ease; }
}

@media print {
  .site-header, .site-footer, .banner, .main-nav { display: none; }
  body { background: #fff; }
}
