:root {
  --bg: #f6f7f5; --card: #ffffff; --ink: #1c2321; --muted: #6b7470; --line: #e3e6e2;
  --brand: #0f766e; --brand-soft: #d9efec; --in: #15803d; --out: #b91c1c; --warn: #b45309;
  --radius: 12px;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #121614; --card: #1b201e; --ink: #e8ece9; --muted: #98a19d; --line: #2c3330;
    --brand: #2dd4bf; --brand-soft: #173c38; --in: #4ade80; --out: #f87171; --warn: #fbbf24; }
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
.top { display: flex; justify-content: space-between; align-items: center; padding: 14px 16px; background: var(--brand); color: #fff; }
@media (prefers-color-scheme: dark) { .top { color: #06201d; } }
.brand { font-weight: 700; font-size: 17px; }
.user { font-size: 13px; opacity: .9; }
.tabs { display: flex; gap: 4px; overflow-x: auto; padding: 8px 12px; background: var(--card); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5; scrollbar-width: none; }
.tabs a { white-space: nowrap; padding: 7px 12px; border-radius: 999px; color: var(--muted); text-decoration: none; font-weight: 500; }
.tabs a.on { background: var(--brand-soft); color: var(--brand); }
main { max-width: 1100px; margin: 0 auto; padding: 16px 16px 96px; }
h2 { font-size: 20px; margin: 4px 0 14px; }
h3 { font-size: 15px; margin: 0 0 10px; }
.muted { color: var(--muted); }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.spread { justify-content: space-between; }
.grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); }
.grid2 { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); margin-top: 12px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; }
.stat .label { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; }
.stat .value { font-size: 22px; font-weight: 700; margin-top: 2px; font-variant-numeric: tabular-nums; }
.stat .sub { font-size: 12px; color: var(--muted); }
.in { color: var(--in); } .out { color: var(--out); } .warn { color: var(--warn); }
.num { font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 8px 6px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
th { font-size: 12px; color: var(--muted); font-weight: 600; }
.table-wrap { overflow-x: auto; }
.list-item { display: flex; justify-content: space-between; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.list-item:last-child { border-bottom: 0; }
.list-item .meta { font-size: 12px; color: var(--muted); }
.pill { display: inline-block; font-size: 11px; padding: 1px 8px; border-radius: 999px; background: var(--line); color: var(--muted); margin-left: 4px; }
.pill.prev { background: #fef3c7; color: #92400e; }
button, .btn { font: inherit; border: 1px solid var(--line); background: var(--card); color: var(--ink); padding: 7px 12px; border-radius: 8px; cursor: pointer; }
button.primary { background: var(--brand); border-color: var(--brand); color: #fff; font-weight: 600; }
@media (prefers-color-scheme: dark) { button.primary { color: #06201d; } }
button.link { border: 0; background: none; color: var(--brand); padding: 2px 4px; }
button.danger { color: var(--out); }
button.small { padding: 3px 8px; font-size: 13px; }
input, select, textarea { font: inherit; width: 100%; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--bg); color: var(--ink); }
label { display: block; font-size: 13px; color: var(--muted); margin: 10px 0 4px; }
.form-grid { display: grid; gap: 0 12px; grid-template-columns: 1fr 1fr; }
.form-grid .full { grid-column: 1 / -1; }
.seg { display: flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.seg button { flex: 1; border: 0; border-radius: 0; }
.seg button.on { background: var(--brand-soft); color: var(--brand); font-weight: 600; }
dialog { border: 0; border-radius: 16px; padding: 0; width: min(560px, calc(100vw - 24px)); background: var(--card); color: var(--ink); }
dialog::backdrop { background: rgba(0,0,0,.45); }
dialog form { padding: 18px; max-height: 85vh; overflow-y: auto; }
.actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }
.fab { position: fixed; right: 18px; bottom: 18px; width: 56px; height: 56px; border-radius: 50%; border: 0; background: var(--brand); color: #fff; font-size: 30px; line-height: 1; box-shadow: 0 6px 18px rgba(0,0,0,.25); }
@media (prefers-color-scheme: dark) { .fab { color: #06201d; } }
#toast { position: fixed; left: 50%; bottom: 90px; transform: translateX(-50%); background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 10px; opacity: 0; transition: opacity .2s; pointer-events: none; z-index: 20; max-width: 90vw; }
#toast.show { opacity: 1; }
.bar { height: 8px; background: var(--line); border-radius: 99px; overflow: hidden; margin-top: 4px; }
.bar > span { display: block; height: 100%; background: var(--brand); }
.bar.out > span { background: var(--out); }
.month-nav { display: flex; align-items: center; gap: 8px; }
.month-nav strong { min-width: 130px; text-align: center; }
.chart { width: 100%; height: 220px; }
.chart text { fill: var(--muted); font-size: 10px; }
.empty { text-align: center; padding: 24px; color: var(--muted); }
.filters { display: grid; gap: 8px; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); margin-bottom: 12px; }
@media (max-width: 560px) {
  .form-grid { grid-template-columns: 1fr; }
  .stat .value { font-size: 19px; }
  .hide-sm { display: none; }
}

.logged-out .tabs, .logged-out .fab { display: none; }
.login { max-width: 380px; margin: 40px auto; }
