/* =====================================================================
   MoneySavv — app.css (Agent 1)
   Design system + shell + budget + settings styles. Dark only.
   ===================================================================== */

/* =====================================================================
   THEME TOKENS — swap this block to re-theme the whole app.
   Every color, font, radius, shadow and spacing value lives here.
   Component rules below use only these variables.
   ===================================================================== */
:root {
  color-scheme: dark;

  /* Fonts (Figtree loaded from Google Fonts in index.html) */
  --font: "Figtree", "Helvetica Neue", Helvetica, Arial, sans-serif;
  --font-title: var(--font);
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

  /* Type scale (compact: 12–24px) */
  --fs-micro: 10.5px;
  --fs-xs: 12px;
  --fs-sm: 14px;
  --fs-md: 16px;
  --fs-lg: 18px;
  --fs-xl: 24px;
  --fs-display: 32px;      /* hero number only */
  --fw-regular: 400;
  --fw-semi: 600;
  --fw-bold: 700;
  --lh: 1.4;
  --lh-tight: 1.2;
  --btn-tracking: 1.4px;
  --eyebrow-tracking: 1.6px;

  /* Spacing (8px base) */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 24px;
  --space-6: 32px;
  --space-7: 48px;

  /* Shape */
  --radius: 8px;
  --radius-sm: 6px;
  --radius-xs: 4px;
  --radius-pill: 9999px;
  --radius-circle: 50%;
  --page-max: 1120px;
  --page-narrow: 680px;
  --sidebar-w: 232px;
  --topbar-h: 56px;
  --tabbar-h: 64px;
  --control-h: 44px;
  --control-sm: 32px;

  /* Surfaces */
  --bg: #121212;
  --surface: #181818;
  --surface-2: #1f1f1f;
  --surface-3: #252525;
  --surface-hover: #2a2a2a;
  --sidebar-bg: #000000;

  /* Text */
  --text: #ffffff;
  --text-strong: #fdfdfd;
  --muted: #b3b3b3;
  --muted-2: #7c7c7c;

  /* Lines (used sparingly; prefer shade + shadow) */
  --line: #2a2a2a;
  --line-strong: #4d4d4d;
  --line-input: #7c7c7c;

  /* Accent: functional only (CTAs, active nav, winners, on-track) */
  --accent: #1ed760;
  --accent-hover: #3be477;
  --accent-press: #1db954;
  --accent-soft: rgba(30, 215, 96, 0.12);
  --accent-ink: #000000;

  /* Semantic */
  --good: #1ed760;
  --good-soft: rgba(30, 215, 96, 0.12);
  --warn: #ffa42b;
  --warn-soft: rgba(255, 164, 43, 0.14);
  --bad: #f3727f;
  --bad-soft: rgba(243, 114, 127, 0.14);
  --info: #539df5;
  --info-soft: rgba(83, 157, 245, 0.14);
  --focus: #ffffff;
  --track: #2f2f2f;
  --overlay: rgba(0, 0, 0, 0.7);

  /* Toast */
  --toast-bg: #252525;
  --toast-ink: #ffffff;

  /* Hero (achromatic) */
  --hero-from: #2a2a2a;
  --hero-to: #181818;

  /* Sample-price badge (neutral, not green) */
  --sample-bg: rgba(255, 164, 43, 0.12);
  --sample-ink: #ffc56e;

  /* Shadows */
  --shadow: rgba(0, 0, 0, 0.3) 0 8px 8px;
  --shadow-lg: rgba(0, 0, 0, 0.5) 0 8px 24px;
  --shadow-input: #121212 0 1px 0, #7c7c7c 0 0 0 1px inset;
  --shadow-input-hover: #121212 0 1px 0, #b3b3b3 0 0 0 1px inset;
  --shadow-input-focus: #121212 0 1px 0, #ffffff 0 0 0 2px inset;
  --shadow-input-bad: #121212 0 1px 0, #f3727f 0 0 0 2px inset;
  --focus-ring: 0 0 0 2px #121212, 0 0 0 4px #ffffff;

  /* Motion */
  --ease: cubic-bezier(.3, 0, .4, 1);
  --dur: 150ms;
}
/* ===================== END THEME TOKENS ===================== */

/* ---------- base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; background: var(--bg); }
body {
  margin: 0;
  font-family: var(--font);
  font-size: var(--fs-md);
  line-height: var(--lh);
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}
h1, h2, h3, h4 { margin: 0; line-height: var(--lh-tight); font-family: var(--font-title); }
h1 { font-size: var(--fs-xl); font-weight: var(--fw-bold); }
h2 { font-size: var(--fs-lg); font-weight: var(--fw-bold); }
h3 { font-size: var(--fs-md); font-weight: var(--fw-bold); }
p { margin: 0; }
a { color: var(--text); }
button, input, select, textarea { font: inherit; color: inherit; }
img, svg { display: block; max-width: 100%; }
[hidden] { display: none !important; }
.num { font-variant-numeric: tabular-nums; }
.small { font-size: var(--fs-sm); }
.muted { color: var(--muted); }
.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;
}

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

.skip-link {
  position: absolute; left: var(--space-3); top: -100px; z-index: 100;
  background: var(--text); color: var(--bg); font-weight: var(--fw-bold);
  padding: var(--space-2) var(--space-4); border-radius: var(--radius-pill); text-decoration: none;
}
.skip-link:focus { top: var(--space-3); }

/* ---------- shell: sidebar (desktop) / top bar + bottom tabs (mobile) ---------- */
.topbar {
  position: fixed; left: 0; top: 0; bottom: 0; z-index: 30;
  width: var(--sidebar-w);
  background: var(--sidebar-bg);
  padding: var(--space-5) var(--space-3);
}
.topbar-inner { display: flex; flex-direction: column; gap: var(--space-6); height: 100%; }
.brand { display: flex; align-items: center; gap: var(--space-2); text-decoration: none; color: var(--accent); padding: 0 var(--space-3); }
.brand-mark { width: 28px; height: 28px; display: grid; place-items: center; color: var(--accent); }
.brand-mark svg { width: 28px; height: 28px; }
.brand-name { font-size: var(--fs-xl); font-weight: var(--fw-regular); letter-spacing: -0.5px; color: var(--accent); }
.brand-name b { font-weight: var(--fw-bold); letter-spacing: -0.3px; }

.tabs { display: flex; flex-direction: column; gap: var(--space-1); }
.tab {
  display: flex; align-items: center; gap: var(--space-4);
  padding: var(--space-3); border-radius: var(--radius-sm);
  color: var(--muted); text-decoration: none; font-size: var(--fs-sm); font-weight: var(--fw-regular);
  transition: color var(--dur) var(--ease), background var(--dur) var(--ease);
}
.tab svg { width: 22px; height: 22px; flex: none; }
.tab:hover { color: var(--text); }
.tab[aria-current="page"] { color: var(--text); font-weight: var(--fw-bold); background: var(--surface-2); }
.tab[aria-current="page"] svg { color: var(--accent); }

.main { margin-left: var(--sidebar-w); padding-bottom: var(--space-7); min-height: 100vh; }

@media (max-width: 699px) {
  .topbar {
    position: sticky; width: auto; bottom: auto; height: var(--topbar-h);
    padding: 0 var(--space-4);
    background: transparent;
  }
  /* Blur lives on a pseudo-layer: backdrop-filter on .topbar itself would make it
     the containing block for the position:fixed .tabs and pin them to the top. */
  .topbar::before {
    content: ""; position: absolute; inset: 0; z-index: -1;
    background: color-mix(in srgb, var(--bg) 92%, transparent);
    backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  }
  .topbar-inner { flex-direction: row; align-items: center; height: 100%; }
  .brand { padding: 0; }
  .brand-name { font-size: var(--fs-lg); }
  .brand-mark, .brand-mark svg { width: 22px; height: 22px; }
  .tabs {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
    display: grid; grid-template-columns: repeat(4, 1fr); gap: 0;
    height: calc(var(--tabbar-h) + env(safe-area-inset-bottom, 0px));
    padding: var(--space-1) var(--space-1) env(safe-area-inset-bottom, 0px);
    background: linear-gradient(to top, var(--sidebar-bg) 70%, color-mix(in srgb, var(--sidebar-bg) 85%, transparent));
    box-shadow: var(--shadow-lg);
  }
  .tab {
    flex-direction: column; justify-content: center; gap: 3px;
    font-size: var(--fs-micro); padding: var(--space-1); text-align: center; line-height: 1.15;
  }
  .tab svg { width: 22px; height: 22px; }
  .tab[aria-current="page"] { background: transparent; }
  .main { margin-left: 0; padding-bottom: calc(var(--tabbar-h) + var(--space-6) + env(safe-area-inset-bottom, 0px)); }
  .toasts { bottom: calc(var(--tabbar-h) + var(--space-3) + env(safe-area-inset-bottom, 0px)) !important; }
}

/* ---------- layout primitives ---------- */
.view { min-height: 100%; }
.page { max-width: var(--page-max); margin: 0 auto; padding: var(--space-6) var(--space-5); display: flex; flex-direction: column; gap: var(--space-5); }
.page-narrow { max-width: var(--page-narrow); margin-left: 0; }
.page-header { display: flex; align-items: flex-end; justify-content: space-between; gap: var(--space-4); flex-wrap: wrap; }
.page-header h1 { margin-top: var(--space-1); font-size: var(--fs-xl); }
.page-header .muted { margin-top: var(--space-1); font-size: var(--fs-sm); }
.eyebrow { font-size: var(--fs-xs); font-weight: var(--fw-bold); letter-spacing: var(--eyebrow-tracking); text-transform: uppercase; color: var(--muted); }

.card {
  background: var(--surface); border: 0;
  border-radius: var(--radius); box-shadow: var(--shadow); padding: var(--space-5);
  min-width: 0;
}
.card-title { font-size: var(--fs-lg); font-weight: var(--fw-bold); }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); margin-bottom: var(--space-4); flex-wrap: wrap; }

.grid { display: grid; gap: var(--space-4); grid-template-columns: repeat(auto-fit, minmax(min(100%, 240px), 1fr)); }
.row { display: flex; align-items: center; gap: var(--space-3); flex-wrap: wrap; }
.stack { display: flex; flex-direction: column; gap: var(--space-4); }

@media (max-width: 699px) {
  .page { padding: var(--space-4) var(--space-4); gap: var(--space-4); }
  .card { padding: var(--space-4); }
}

/* ---------- controls ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2);
  min-height: var(--control-h); padding: 0 var(--space-5);
  border-radius: var(--radius-pill); border: 0;
  background: var(--surface-2); color: var(--text);
  box-shadow: var(--line-strong) 0 0 0 1px inset;
  font-size: var(--fs-sm); font-weight: var(--fw-bold); line-height: 1;
  text-transform: uppercase; letter-spacing: var(--btn-tracking);
  text-decoration: none; cursor: pointer; white-space: nowrap;
  transition: background var(--dur) var(--ease), transform var(--dur) var(--ease), box-shadow var(--dur) var(--ease), color var(--dur) var(--ease);
}
.btn:hover { background: var(--surface-hover); box-shadow: var(--muted-2) 0 0 0 1px inset; transform: scale(1.03); }
.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }
.btn.primary { background: var(--accent); color: var(--accent-ink); box-shadow: none; }
.btn.primary:hover { background: var(--accent-hover); }
.btn.primary:active { background: var(--accent-press); }
.btn.ghost { background: transparent; box-shadow: none; color: var(--muted); }
.btn.ghost:hover { color: var(--text); background: transparent; }
.btn.danger { background: var(--bad); color: var(--accent-ink); box-shadow: none; }
.btn.danger-outline { background: transparent; color: var(--bad); box-shadow: var(--bad) 0 0 0 1px inset; }
.btn.danger-outline:hover { background: var(--bad-soft); box-shadow: var(--bad) 0 0 0 1px inset; }
.btn.sm { min-height: var(--control-sm); padding: 0 var(--space-4); font-size: var(--fs-xs); letter-spacing: 1px; }
.btn.icon { width: var(--control-h); padding: 0; border-radius: var(--radius-circle); letter-spacing: 0; }
.btn.icon.sm { width: var(--control-sm); min-height: var(--control-sm); }
.btn.icon svg { width: 16px; height: 16px; }
.btn:focus-visible, .chip:focus-visible { outline: none; box-shadow: var(--focus-ring); }

.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > label, .label { font-size: var(--fs-sm); font-weight: var(--fw-bold); }
.hint { font-size: var(--fs-xs); color: var(--muted); }
.field-error { font-size: var(--fs-xs); color: var(--bad); }

.input, .select {
  width: 100%; min-height: var(--control-h); padding: 0 var(--space-4);
  border-radius: var(--radius-pill); border: 0;
  background: var(--surface-2); color: var(--text); font-size: var(--fs-sm);
  box-shadow: var(--shadow-input);
  transition: box-shadow var(--dur) var(--ease);
}
.input::placeholder { color: var(--muted-2); }
.input:hover, .select:hover { box-shadow: var(--shadow-input-hover); }
.input:focus-visible, .select:focus-visible { outline: none; box-shadow: var(--shadow-input-focus); }
.input[aria-invalid="true"] { box-shadow: var(--shadow-input-bad); }
.select {
  appearance: none; -webkit-appearance: none; padding-right: 40px; cursor: pointer;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 20px) 50%, calc(100% - 15px) 50%;
  background-size: 5px 5px; background-repeat: no-repeat;
}
.select option { background: var(--surface-2); color: var(--text); }
input[type="date"].input { color-scheme: dark; }
input[type="color"].input { padding: 6px; width: var(--control-h); cursor: pointer; border-radius: var(--radius-circle); }
input[type="color"].input::-webkit-color-swatch-wrapper { padding: 0; }
input[type="color"].input::-webkit-color-swatch { border: 0; border-radius: var(--radius-circle); }
input[type="color"].input::-moz-color-swatch { border: 0; border-radius: var(--radius-circle); }

.chip {
  display: inline-flex; align-items: center; gap: 6px;
  min-height: var(--control-sm); padding: 0 var(--space-3); border-radius: var(--radius-pill);
  border: 0; background: var(--surface-2); color: var(--text);
  font-size: var(--fs-sm); font-weight: var(--fw-regular); cursor: pointer; white-space: nowrap;
  transition: background var(--dur) var(--ease);
}
.chip:hover { background: var(--surface-hover); }
.chip[aria-pressed="true"], .chip.active { background: var(--text); color: var(--bg); font-weight: var(--fw-semi); }

.tag {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px var(--space-2); border-radius: var(--radius-xs);
  background: var(--surface-3); color: var(--muted);
  font-size: var(--fs-micro); font-weight: var(--fw-semi); white-space: nowrap; line-height: 1.33;
}
.tag.good { background: var(--good-soft); color: var(--good); }
.tag.warn { background: var(--warn-soft); color: var(--warn); }
.tag.bad { background: var(--bad-soft); color: var(--bad); }

.badge-sample {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 2px var(--space-2); border-radius: var(--radius-pill);
  background: var(--sample-bg); color: var(--sample-ink);
  font-size: var(--fs-micro); font-weight: var(--fw-bold); letter-spacing: 0.4px; text-transform: uppercase;
  white-space: nowrap; vertical-align: middle; line-height: 1.6;
}
.badge-sample::before { content: ""; width: 6px; height: 6px; border-radius: var(--radius-circle); background: currentColor; }

.empty {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: var(--space-2);
  text-align: center; padding: var(--space-6) var(--space-4); color: var(--muted); font-size: var(--fs-sm);
  border-radius: var(--radius); background: var(--surface-2);
}
.empty strong { color: var(--text); font-size: var(--fs-md); }

.table { width: 100%; border-collapse: collapse; font-size: var(--fs-sm); }
.table th, .table td { text-align: left; padding: var(--space-2) var(--space-3); border-bottom: 1px solid var(--line); vertical-align: middle; }
.table th { font-size: var(--fs-xs); color: var(--muted); font-weight: var(--fw-regular); letter-spacing: 0.4px; }
.table tbody tr:hover td { background: var(--surface-2); }
.table tr:last-child td { border-bottom: 0; }
.table .num, .table td.right, .table th.right { text-align: right; }

/* ---------- toasts ---------- */
.toasts {
  position: fixed; left: calc(50% + var(--sidebar-w) / 2); bottom: var(--space-5); transform: translateX(-50%); z-index: 60;
  display: flex; flex-direction: column; gap: var(--space-2); align-items: center;
  width: min(92vw, 420px); pointer-events: none;
}
@media (max-width: 699px) { .toasts { left: 50%; } }
.toast {
  pointer-events: auto; width: 100%;
  display: flex; align-items: center; gap: var(--space-3);
  padding: var(--space-3) var(--space-3) var(--space-3) var(--space-4);
  border-radius: var(--radius); background: var(--toast-bg); color: var(--toast-ink);
  box-shadow: var(--shadow-lg); font-size: var(--fs-sm);
  animation: toast-in 220ms var(--ease);
}
.toast::before { content: ""; width: 8px; height: 8px; border-radius: var(--radius-circle); background: var(--info); flex: none; }
.toast span { flex: 1; }
.toast-success::before { background: var(--good); }
.toast-error::before { background: var(--bad); }
.toast.leaving { opacity: 0; transform: translateY(6px); transition: all 200ms var(--ease); }
.toast-close { background: none; border: 0; color: var(--muted); font-size: var(--fs-lg); cursor: pointer; line-height: 1; width: 28px; height: 28px; border-radius: var(--radius-circle); }
.toast-close:hover { color: var(--text); background: var(--surface-hover); }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ---------- loading + error ---------- */
.loading-card { display: flex; align-items: center; gap: var(--space-3); color: var(--muted); font-size: var(--fs-sm); }
.spinner { width: 18px; height: 18px; border-radius: var(--radius-circle); border: 2px solid var(--surface-3); border-top-color: var(--text); animation: spin 800ms linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.error-card { display: flex; flex-direction: column; gap: var(--space-3); align-items: flex-start; max-width: var(--page-narrow); }
.error-icon { width: 40px; height: 40px; border-radius: var(--radius-circle); display: grid; place-items: center; background: var(--warn-soft); color: var(--warn); font-weight: var(--fw-bold); font-size: var(--fs-lg); }
.error-card p { font-size: var(--fs-sm); }
.error-details { font-size: var(--fs-xs); color: var(--muted); }
.error-details summary { cursor: pointer; }
.error-details code { display: block; margin-top: var(--space-2); font-family: var(--font-mono); word-break: break-word; }

/* ---------- inline confirm (no window.confirm) ---------- */
.confirm-inline {
  display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); flex-wrap: wrap;
  width: 100%; padding: var(--space-3) var(--space-4); border-radius: var(--radius);
  background: var(--surface-3); box-shadow: var(--shadow-lg);
  color: var(--text); font-size: var(--fs-sm); font-weight: var(--fw-bold);
}

/* ---------- settings ---------- */
.status-line { font-size: var(--fs-sm); padding: var(--space-3) var(--space-4); border-radius: var(--radius); background: var(--surface-2); }
.status-good { background: var(--good-soft); color: var(--good); }
.status-bad { background: var(--bad-soft); color: var(--bad); }
.status-info { color: var(--muted); }

/* =====================================================================
   BUDGET (bud-*)
   ===================================================================== */
.bud-monthbar { display: flex; align-items: center; gap: var(--space-1); }
.bud-month-label { min-width: 132px; text-align: center; font-weight: var(--fw-bold); font-size: var(--fs-sm); }

.bud-hero {
  background: linear-gradient(160deg, var(--hero-from), var(--hero-to) 70%);
  box-shadow: var(--shadow-lg);
  display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 2fr); gap: var(--space-5); align-items: center;
}
.bud-hero-label { font-size: var(--fs-xs); color: var(--muted); font-weight: var(--fw-bold); letter-spacing: var(--eyebrow-tracking); text-transform: uppercase; }
.bud-hero-value { font-size: var(--fs-display); font-weight: var(--fw-bold); letter-spacing: -1px; line-height: 1.1; margin: var(--space-2) 0 var(--space-1); font-variant-numeric: tabular-nums; }
.bud-hero-value.good { color: var(--good); }
.bud-hero-value.bad { color: var(--bad); }
.bud-hero-sub { font-size: var(--fs-sm); color: var(--muted); }
.bud-hero-bar { height: 4px; border-radius: var(--radius-pill); background: var(--track); overflow: hidden; margin-top: var(--space-3); }
.bud-hero-bar > span { display: block; height: 100%; background: var(--text); border-radius: inherit; transition: width 400ms var(--ease); }
.bud-hero-bar.over > span { background: var(--bad); }

.bud-stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--space-2); margin: 0; }
.bud-stat { background: var(--surface-3); border-radius: var(--radius); padding: var(--space-3) var(--space-4); min-width: 0; }
.bud-stat dt { font-size: var(--fs-xs); color: var(--muted); }
.bud-stat dd { margin: 2px 0 0; font-size: var(--fs-lg); font-weight: var(--fw-bold); font-variant-numeric: tabular-nums; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bud-stat dd.good { color: var(--good); }
.bud-stat dd.bad { color: var(--bad); }

.bud-layout { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); gap: var(--space-5); align-items: start; }
.bud-col { display: flex; flex-direction: column; gap: var(--space-5); min-width: 0; }

.bud-cats { display: flex; flex-direction: column; gap: var(--space-4); list-style: none; margin: 0; padding: 0; }
.bud-cat-top { display: flex; align-items: baseline; justify-content: space-between; gap: var(--space-3); margin-bottom: 6px; }
.bud-cat-name { display: flex; align-items: center; gap: var(--space-2); font-weight: var(--fw-bold); font-size: var(--fs-sm); min-width: 0; }
.bud-cat-name span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bud-dot { width: 10px; height: 10px; border-radius: var(--radius-circle); flex: none; }
.bud-cat-amt { font-size: var(--fs-xs); color: var(--muted); white-space: nowrap; font-variant-numeric: tabular-nums; }
.bud-cat-amt b { color: var(--text); font-size: var(--fs-sm); }
.bud-bar { height: 6px; border-radius: var(--radius-pill); background: var(--track); overflow: hidden; }
.bud-bar > span { display: block; height: 100%; border-radius: inherit; transition: width 400ms var(--ease); }
.bud-cat-foot { display: flex; justify-content: space-between; gap: var(--space-2); margin-top: 6px; font-size: var(--fs-xs); color: var(--muted); }
.bud-cat.is-warn .bud-cat-foot .left { color: var(--warn); font-weight: var(--fw-bold); }
.bud-cat.is-over .bud-cat-foot .left { color: var(--bad); font-weight: var(--fw-bold); }
.bud-cat.is-over .bud-bar > span { background: var(--bad) !important; }
.bud-cat.is-warn .bud-bar > span { background: var(--warn) !important; }

.bud-chart { display: flex; align-items: center; gap: var(--space-5); flex-wrap: wrap; justify-content: center; }
.bud-donut { width: 176px; height: 176px; flex: none; }
.bud-donut-center-v { font-size: 17px; font-weight: var(--fw-bold); fill: var(--text); font-family: var(--font); }
.bud-donut-center-l { font-size: 9px; fill: var(--muted); font-family: var(--font); letter-spacing: 1.2px; text-transform: uppercase; font-weight: var(--fw-bold); }
.bud-donut-track { stroke: var(--track); }
.bud-legend { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: var(--space-2); font-size: var(--fs-sm); flex: 1; min-width: 160px; }
.bud-legend li { display: flex; align-items: center; gap: var(--space-2); }
.bud-legend .name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bud-legend .val { font-variant-numeric: tabular-nums; color: var(--muted); font-size: var(--fs-xs); }
.bud-legend li.left-row .name, .bud-legend li.left-row .val { color: var(--good); font-weight: var(--fw-bold); }

.bud-form { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-3); }
.bud-form .span-2 { grid-column: 1 / -1; }
.bud-seg { display: grid; grid-template-columns: 1fr 1fr; background: var(--surface-2); border-radius: var(--radius-pill); padding: 4px; gap: 4px; }
.bud-seg label { position: relative; }
.bud-seg input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.bud-seg span { display: flex; align-items: center; justify-content: center; min-height: 36px; border-radius: var(--radius-pill); font-size: var(--fs-xs); font-weight: var(--fw-bold); letter-spacing: var(--btn-tracking); text-transform: uppercase; color: var(--muted); }
.bud-seg input:checked + span { background: var(--text); color: var(--bg); }
.bud-seg input:focus-visible + span { box-shadow: var(--focus-ring); }
.bud-amount { position: relative; }
.bud-amount::before { content: "$"; position: absolute; left: var(--space-4); top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; font-size: var(--fs-sm); }
.bud-amount .input { padding-left: 28px; font-variant-numeric: tabular-nums; }

.bud-filters { display: flex; gap: var(--space-2); overflow-x: auto; padding: 2px 2px var(--space-2); margin-bottom: var(--space-2); scrollbar-width: none; }
.bud-filters::-webkit-scrollbar { display: none; }
.bud-txns { list-style: none; margin: 0; padding: 0; }
.bud-txn { display: grid; grid-template-columns: auto minmax(0, 1fr) auto auto; align-items: center; gap: var(--space-3); padding: var(--space-2); margin: 0 calc(var(--space-2) * -1); border-radius: var(--radius-sm); transition: background var(--dur) var(--ease); }
.bud-txn:hover { background: var(--surface-2); }
.bud-txn-icon { width: 40px; height: 40px; border-radius: var(--radius-xs); display: grid; place-items: center; font-weight: var(--fw-bold); font-size: var(--fs-sm); color: var(--bg); }
.bud-txn-main { min-width: 0; }
.bud-txn-title { font-weight: var(--fw-regular); font-size: var(--fs-md); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bud-txn-meta { font-size: var(--fs-xs); color: var(--muted); display: flex; gap: var(--space-2); align-items: center; flex-wrap: wrap; }
.bud-txn-amt { font-weight: var(--fw-bold); font-size: var(--fs-sm); font-variant-numeric: tabular-nums; white-space: nowrap; }
.bud-txn-amt.income { color: var(--good); }
.bud-txn .btn.icon { opacity: 0.55; }
.bud-txn:hover .btn.icon, .bud-txn .btn.icon:focus-visible { opacity: 1; }
.bud-txn .confirm-inline { grid-column: 1 / -1; }

.bud-edit-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: var(--space-2); }
.bud-edit-row { display: grid; grid-template-columns: var(--control-h) minmax(0, 1fr) 120px var(--control-h); gap: var(--space-2); align-items: center; }
.bud-income-row { display: grid; grid-template-columns: minmax(0, 1fr) 180px; gap: var(--space-3); align-items: end; padding-bottom: var(--space-4); margin-bottom: var(--space-4); border-bottom: 1px solid var(--line); }
.bud-example-note { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); flex-wrap: wrap; padding: var(--space-3) var(--space-4); border-radius: var(--radius); background: var(--surface-2); color: var(--muted); font-size: var(--fs-sm); }

@media (max-width: 1060px) {
  .bud-hero { grid-template-columns: 1fr; }
  .bud-layout { grid-template-columns: 1fr; }
}
@media (max-width: 699px) {
  .bud-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .bud-hero-value { font-size: var(--fs-xl); }
  .bud-form { grid-template-columns: 1fr; }
  .bud-edit-row { grid-template-columns: var(--control-h) minmax(0, 1fr) 100px var(--control-h); }
  .bud-income-row { grid-template-columns: 1fr; }
  .bud-month-label { min-width: 96px; }
  .bud-donut { width: 148px; height: 148px; }
  .page-header .bud-monthbar { width: 100%; justify-content: space-between; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 1ms !important; transition-duration: 1ms !important; }
}

/* settings: detected region under ZIP */
.region-line { font-size: var(--fs-xs); color: var(--muted); display: flex; align-items: center; gap: 6px; min-height: 18px; }
.region-line:empty { display: none; }
.region-line::before { content: ""; width: 8px; height: 8px; border-radius: var(--radius-circle); background: var(--muted-2); flex: none; }
.region-line.in { color: var(--text); font-weight: var(--fw-bold); }
.region-line.in::before { background: var(--good); }
.region-line.out { color: var(--warn); }
.region-line.out::before { background: var(--warn); }

/* =====================================================================
   CATEGORY ART (art-*, cat-art) — placeholder illustrations from js/art.js
   ===================================================================== */
.cat-art { display: block; width: 100%; height: 100%; }
.cat-art .art-bg { fill: var(--surface-3); }
.cat-art .art-a { fill: #3e3e3e; }
.cat-art .art-b { fill: #555555; }
.cat-art .art-c { fill: var(--surface); }
.cat-art .art-d { fill: var(--muted-2); }
.cat-art .art-g { fill: var(--accent); }
.cat-art .art-sa { stroke: #3e3e3e; }
.cat-art .art-sd { stroke: var(--muted-2); }
.art-frame {
  position: relative; display: block; width: 100%; aspect-ratio: 4 / 3;
  border-radius: var(--radius); overflow: hidden; background: var(--surface-3);
}
.art-frame.art-square { aspect-ratio: 1 / 1; }
.art-frame > img { display: block; width: 100%; height: 100%; object-fit: contain; background: var(--surface-3); }
.art-thumb {
  flex: none; display: inline-block; width: 40px; height: 40px;
  border-radius: var(--radius); overflow: hidden; background: var(--surface-3);
}
.art-thumb .cat-art { width: 100%; height: 100%; }

/* settings: Advanced (developers) disclosure */
.adv { border-radius: var(--radius); background: var(--surface-2); }
.adv-summary {
  list-style: none; cursor: pointer; padding: var(--space-3) var(--space-4);
  font-size: var(--fs-sm); font-weight: var(--fw-bold); color: var(--muted);
  display: flex; align-items: center; gap: var(--space-2); border-radius: var(--radius);
}
.adv-summary::-webkit-details-marker { display: none; }
.adv-summary::before {
  content: ""; width: 7px; height: 7px; flex: none; margin-left: 2px;
  border: solid currentColor; border-width: 0 2px 2px 0; transform: rotate(-45deg);
  transition: transform var(--dur) var(--ease);
}
.adv[open] > .adv-summary::before { transform: rotate(45deg); }
.adv-summary:hover { color: var(--text); }
.adv-summary:focus-visible { outline: none; box-shadow: var(--focus-ring); }
.adv-body { padding: 0 var(--space-4) var(--space-4); }
