:root {
  --bg: #eef1f4;
  --surface: #ffffff;
  --ink: #16222e;
  --muted: #5b6b7a;
  --line: #d5dce3;
  --accent: #1d3557;
  --accent-ink: #ffffff;
  --inc: #1f7a6b;
  --exp: #b03a48;
  --focus: #2b6cb0;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1720;
    --surface: #17212c;
    --ink: #e6ecf2;
    --muted: #93a3b3;
    --line: #2a3745;
    --accent: #7fb0e6;
    --accent-ink: #0f1720;
    --inc: #4fc0aa;
    --exp: #ee7b88;
    --focus: #7fb0e6;
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-variant-numeric: tabular-nums;
}
a { color: var(--accent); }
h1 { font: 600 1.6rem/1.2 Georgia, "Iowan Old Style", serif; margin: 0 0 1rem; }
h2 { font-size: 1rem; margin: 0 0 .75rem; }
main { max-width: 72rem; margin: 0 auto; padding: 1.5rem 1rem 4rem; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.num { text-align: right; white-space: nowrap; }
.pos { color: var(--inc); }
.neg { color: var(--exp); }

.top {
  display: flex; align-items: center; gap: 1.5rem; flex-wrap: wrap;
  padding: .75rem 1rem; background: var(--surface); border-bottom: 1px solid var(--line);
}
.brand { font: 700 1.2rem Georgia, "Iowan Old Style", serif; text-decoration: none; color: var(--ink); }
.top nav { display: flex; gap: 1rem; flex: 1; flex-wrap: wrap; }
.top nav a { text-decoration: none; color: var(--muted); padding: .25rem 0; border-bottom: 2px solid transparent; }
.top nav a[aria-current="page"] { color: var(--ink); border-bottom-color: var(--accent); }

.panel { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 1.25rem; margin-bottom: 1rem; }
.panel.narrow { max-width: 32rem; }
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(20rem, 1fr)); gap: 1rem; }
.grid .panel { margin-bottom: 0; }
.grid + .panel { margin-top: 1rem; }

.hero { padding: 1rem 0 1.75rem; }
.saldo-label { margin: 1rem 0 0; color: var(--muted); }
.saldo { font: 600 clamp(2.5rem, 8vw, 4.5rem)/1.1 Georgia, "Iowan Old Style", serif; margin: 0 0 .75rem; }
.split { display: block; width: 100%; max-width: 40rem; height: 10px; border-radius: 5px; overflow: hidden; }
.inc { fill: var(--inc); }
.exp { fill: var(--exp); }
.split-legend { color: var(--muted); font-size: .9rem; margin: .5rem 0 0; }
.dot { display: inline-block; width: .6rem; height: .6rem; border-radius: 50%; margin: 0 .4rem 0 .9rem; background: var(--muted); }
.split-legend .dot:first-child { margin-left: 0; }
.dot.inc { background: var(--inc); }
.dot.exp { background: var(--exp); }

.bars { list-style: none; margin: 0; padding: 0; }
.bars li { display: grid; grid-template-columns: 1fr auto; column-gap: 1rem; margin-bottom: .75rem; }
.bars svg { grid-column: 1 / -1; width: 100%; height: 6px; background: var(--bg); border-radius: 3px; }
.bars .amt { text-align: right; }
.trend { width: 100%; height: auto; }
.trend text { fill: var(--muted); font-size: 11px; }

table { width: 100%; border-collapse: collapse; }
th, td { padding: .6rem .5rem; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
th { color: var(--muted); font-weight: 600; font-size: .85rem; }
th.num, td.num { text-align: right; }
.scroll { overflow-x: auto; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: .5rem 1rem; }

input, select, button, .button {
  font: inherit; color: var(--ink); background: var(--surface);
  border: 1px solid var(--line); border-radius: 6px; padding: .5rem .75rem; min-height: 2.5rem;
}
input[type="file"] { padding: .4rem; width: 100%; }
button, .button { cursor: pointer; text-decoration: none; display: inline-block; }
button.primary, .button.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
button.link { border: 0; background: none; color: var(--accent); padding: 0; min-height: 0; text-decoration: underline; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
input.cat { width: 11rem; padding: .25rem .5rem; min-height: 2rem; }

.stack { display: grid; gap: 1rem; }
.stack label { display: grid; gap: .35rem; font-weight: 600; }
.row, .filters { display: flex; gap: .75rem; flex-wrap: wrap; align-items: center; margin-bottom: .75rem; }
.row input[name="name"] { flex: 2; min-width: 14rem; }
.inline { display: inline-flex; gap: .5rem; align-items: center; }
details summary { cursor: pointer; color: var(--accent); }

.flash { padding: .75rem 1rem; border-radius: 6px; border: 1px solid var(--line); background: var(--surface); }
.flash.ok { border-color: var(--inc); }
.flash.error { border-color: var(--exp); }

.login { max-width: 22rem; margin: 6vh auto 0; }
.empty { max-width: 34rem; margin: 4rem auto; }

@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
