:root {
  --bg: #f6f7f9; --surface: #ffffff; --text: #14171c; --muted: #5d6673; --line: #e3e6eb;
  --accent: #0b6e4f; --accent-text: #ffffff; --danger: #b42318; --ok: #067647; --warn: #b54708;
  --bar: #dfe5ec; --radius: 12px; color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1216; --surface: #181c22; --text: #e8ebf0; --muted: #9aa4b2; --line: #2a3038;
    --accent: #2fbf8a; --accent-text: #05160f; --danger: #f97066; --ok: #47cd89; --warn: #fdb022;
    --bar: #2a3038; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0f1216; --surface: #181c22; --text: #e8ebf0; --muted: #9aa4b2; --line: #2a3038;
  --accent: #2fbf8a; --accent-text: #05160f; --danger: #f97066; --ok: #47cd89; --warn: #fdb022;
  --bar: #2a3038; color-scheme: dark;
}
* { box-sizing: border-box; }
body { margin: 0; font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; background: var(--bg); color: var(--text); }
button, input, select { font: inherit; color: inherit; }
h1, h2, h3 { margin: 0 0 .5rem; line-height: 1.2; }
h2 { font-size: 1.15rem; } h3 { font-size: 1rem; }
.muted { color: var(--muted); font-size: .9rem; }
.wrap { max-width: 980px; margin: 0 auto; padding: 16px; padding-bottom: 48px; }
header.top { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 16px; border-bottom: 1px solid var(--line); background: var(--surface); position: sticky; top: 0; z-index: 2; }
.brand { font-weight: 700; letter-spacing: .02em; font-size: 1.05rem; }
nav.tabs { display: flex; gap: 6px; flex-wrap: wrap; margin: 16px 0; }
nav.tabs button { background: transparent; border: 1px solid var(--line); padding: 7px 14px; border-radius: 999px; cursor: pointer; color: var(--muted); }
nav.tabs button[aria-current="page"] { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin-bottom: 16px; }
.grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }
.stat .value { font-size: 1.4rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.pos { color: var(--ok); } .neg { color: var(--danger); }
form.row { display: flex; flex-wrap: wrap; gap: 8px; align-items: end; }
form.row label { display: flex; flex-direction: column; gap: 4px; font-size: .85rem; color: var(--muted); flex: 1 1 140px; }
input, select { padding: 9px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--bg); min-width: 0; width: 100%; }
button.primary, button.ghost, button.danger { padding: 9px 14px; border-radius: 8px; cursor: pointer; border: 1px solid transparent; }
button.primary { background: var(--accent); color: var(--accent-text); font-weight: 600; }
button.ghost { background: transparent; border-color: var(--line); }
button.danger { background: transparent; color: var(--danger); border-color: var(--line); }
button:disabled { opacity: .55; cursor: wait; }
button:focus-visible, input:focus-visible, select:focus-visible, nav.tabs button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
ul.list { list-style: none; padding: 0; margin: 0; }
ul.list li { display: grid; grid-template-columns: 1fr auto; gap: 8px; padding: 10px 0; border-bottom: 1px solid var(--line); align-items: center; }
ul.list li:last-child { border-bottom: 0; }
.amount { font-variant-numeric: tabular-nums; font-weight: 600; white-space: nowrap; }
.bar { height: 8px; background: var(--bar); border-radius: 999px; overflow: hidden; margin-top: 6px; }
.bar > span { display: block; height: 100%; background: var(--accent); border-radius: 999px; max-width: 100%; }
.bar.over > span { background: var(--danger); }
.month { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.month strong { min-width: 150px; text-align: center; }
.auth { max-width: 380px; margin: 10vh auto; }
.error { color: var(--danger); font-size: .9rem; min-height: 1.2em; margin: 6px 0 0; }
.actions { display: flex; gap: 6px; }
#toast { position: fixed; bottom: 16px; left: 50%; transform: translateX(-50%); background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 8px; max-width: 90vw; }
#toast[hidden] { display: none; }
.empty { color: var(--muted); padding: 12px 0; }
.spacer { flex: 1; }
