:root {
  --bg: #f4f1ea;
  --bg-card: #fffdf8;
  --text: #1c1a16;
  --muted: #6b6458;
  --line: #e4ddd2;
  --accent: #2f6fed;
  --danger: #c0392b;
  --ok: #2a7a4b;
  --today: #f3e2b8;
  --radius: 14px;
  --font: "Golos Text", "Segoe UI", sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #16181c;
    --bg-card: #22252b;
    --text: #f3f1ec;
    --muted: #a39b8f;
    --line: #33383f;
    --accent: #6ea2ff;
    --danger: #ff7b72;
    --ok: #7dcea0;
    --today: #3a3118;
  }
}
html[data-theme="dark"] {
  --bg: #16181c;
  --bg-card: #22252b;
  --text: #f3f1ec;
  --muted: #a39b8f;
  --line: #33383f;
  --accent: #6ea2ff;
  --danger: #ff7b72;
  --ok: #7dcea0;
  --today: #3a3118;
}
html[data-theme="light"] {
  --bg: #f4f1ea;
  --bg-card: #fffdf8;
  --text: #1c1a16;
  --muted: #6b6458;
  --line: #e4ddd2;
  --accent: #2f6fed;
  --danger: #c0392b;
  --ok: #2a7a4b;
  --today: #f3e2b8;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font-family: var(--font); }
body { min-height: 100dvh; }
a { color: var(--accent); text-decoration: none; }
.top {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px; border-bottom: 1px solid var(--line);
  position: sticky; top: 0; background: var(--bg); z-index: 5;
}
.brand { font-weight: 700; color: var(--text); }
.top nav { display: flex; gap: 14px; align-items: center; font-size: 15px; }
.who { color: var(--muted); }
main { padding: 16px; max-width: 1100px; margin: 0 auto; }
h1 { font-size: 1.4rem; font-weight: 600; margin: 0 0 16px; }
.card { background: var(--bg-card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
label { display: block; color: var(--muted); font-size: 13px; margin: 12px 0 6px; }
input[type=text], input[type=password], input[type=number], input[type=date], textarea, select {
  width: 100%; padding: 12px 14px; border-radius: 12px;
  border: 1px solid var(--line); background: var(--bg); color: var(--text);
  font: inherit; font-variant-numeric: tabular-nums;
}
.amount { font-size: 2rem; font-weight: 600; letter-spacing: -0.02em; }
.cats { display: grid; grid-template-columns: repeat(auto-fill, minmax(108px, 1fr)); gap: 8px; }
.cat {
  border: 1px solid var(--line); background: var(--bg); border-radius: 12px;
  padding: 10px 8px; text-align: center; cursor: pointer; font-size: 13px;
}
.cat input { display: none; }
.cat.on { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 16%, var(--bg-card)); }
.cat .i { font-size: 22px; display: block; margin-bottom: 4px; }
.row { display: flex; gap: 8px; margin-top: 16px; }
.btn {
  flex: 1; border: 0; border-radius: 12px; padding: 14px;
  font: inherit; font-weight: 600; cursor: pointer;
}
.btn.primary { background: var(--accent); color: #fff; }
.btn.ghost { background: transparent; color: var(--muted); border: 1px solid var(--line); }
.flash { padding: 10px 12px; border-radius: 10px; margin-bottom: 12px; }
.flash.ok { background: color-mix(in srgb, var(--ok) 18%, var(--bg-card)); }
.flash.err { background: color-mix(in srgb, var(--danger) 18%, var(--bg-card)); }
.grid-wrap { overflow: auto; border: 1px solid var(--line); border-radius: var(--radius); }
table.month { border-collapse: collapse; min-width: 900px; width: 100%; font-variant-numeric: tabular-nums; font-size: 13px; }
table.month th, table.month td { border-bottom: 1px solid var(--line); padding: 6px 8px; text-align: right; white-space: nowrap; }
table.month th:first-child, table.month td:first-child { text-align: left; position: sticky; left: 0; background: var(--bg-card); }
table.month .today { background: var(--today); }
table.month td a { color: inherit; display: block; min-width: 2.2em; }
table.month td a:hover { color: var(--accent); }
.neg { color: var(--danger); }
.pos { color: var(--ok); }
.login { max-width: 380px; margin: 12vh auto; }
@media (max-width: 700px) {
  .top nav a:nth-last-child(2) { display: none; }
}
