:root {
  --bg: #0f1214; --panel: #181c1f; --panel2: #20262a; --line: #323a40;
  --text: #f2f5f6; --muted: #a9b4ba; --accent: #2dd4bf; --accent-ink: #04201c;
  --good: #4ade80; --bad: #fb7185; --warn: #fbbf24;
  --radius: 14px; --safe-b: env(safe-area-inset-bottom, 0px);
  color-scheme: dark;
}
@media (prefers-color-scheme: light) {
  :root {
    --bg: #f4f6f7; --panel: #ffffff; --panel2: #eef1f3; --line: #c9d1d6;
    --text: #0d1316; --muted: #4a565d; --accent: #0f766e; --accent-ink: #ffffff;
    --good: #15803d; --bad: #be123c; --warn: #a16207;
    color-scheme: light;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body { font: 16px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; -webkit-tap-highlight-color: transparent; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.loading { padding: 40px; text-align: center; color: var(--muted); }

.wrap { max-width: 720px; margin: 0 auto; padding: calc(env(safe-area-inset-top, 0px) + 12px) 16px calc(96px + var(--safe-b)); }
header.top { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
header.top h1 { font-size: 26px; margin: 0; flex: 1; letter-spacing: -0.02em; }
.iconbtn { width: 44px; height: 44px; border-radius: 12px; border: 1px solid var(--line); background: var(--panel); display: grid; place-items: center; }
.iconbtn svg { width: 22px; height: 22px; }

nav.tabs { position: fixed; left: 0; right: 0; bottom: 0; background: var(--panel); border-top: 1px solid var(--line); display: flex; justify-content: center; padding-bottom: var(--safe-b); z-index: 5; }
nav.tabs .in { display: flex; width: 100%; max-width: 720px; }
nav.tabs button { flex: 1; border: 0; background: none; padding: 8px 0 10px; display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: 12px; color: var(--muted); min-height: 56px; }
nav.tabs button svg { width: 24px; height: 24px; }
nav.tabs button[aria-current="page"] { color: var(--text); font-weight: 700; }
nav.tabs button[aria-current="page"] svg { color: var(--accent); }
nav.tabs button[aria-current="page"]::after { content: ""; width: 20px; height: 3px; border-radius: 2px; background: var(--accent); }

.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; margin-bottom: 12px; }
.card h2 { font-size: 15px; margin: 0 0 8px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.row { display: flex; align-items: center; gap: 10px; }
.row.between { justify-content: space-between; }
.muted { color: var(--muted); }
.small { font-size: 14px; }
.big { font-size: 28px; font-weight: 700; letter-spacing: -0.02em; }
.grid3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.stat { background: var(--panel2); border-radius: 10px; padding: 10px; min-width: 0; }
.stat .l { font-size: 13px; color: var(--muted); }
.stat .v { font-size: clamp(14px, 4.1vw, 19px); font-weight: 700; white-space: nowrap; font-variant-numeric: tabular-nums; }
.empty { color: var(--muted); padding: 8px 0; }

.btn { white-space: nowrap; border: 0; border-radius: 12px; padding: 12px 16px; min-height: 44px; background: var(--accent); color: var(--accent-ink); font-weight: 700; }
.btn.sec { background: var(--panel2); color: var(--text); border: 1px solid var(--line); }
.btn.danger { background: none; color: var(--bad); border: 1px solid var(--bad); }
.btn.block { width: 100%; }
.fab { position: fixed; right: max(16px, calc(50% - 344px)); bottom: calc(72px + var(--safe-b)); width: 58px; height: 58px; border-radius: 18px; border: 0; background: var(--accent); color: var(--accent-ink); box-shadow: 0 8px 24px rgba(0,0,0,.35); display: grid; place-items: center; z-index: 6; }
.fab svg { width: 28px; height: 28px; }

.chips { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; margin-bottom: 10px; scrollbar-width: none; }
.chip { border: 1px solid var(--line); background: var(--panel); border-radius: 999px; padding: 8px 14px; white-space: nowrap; min-height: 40px; }
.chip[aria-pressed="true"] { background: var(--text); color: var(--bg); border-color: var(--text); font-weight: 700; }

.item { display: flex; gap: 12px; align-items: flex-start; padding: 10px 0; border-top: 1px solid var(--line); width: 100%; background: none; border-left: 0; border-right: 0; border-bottom: 0; text-align: left; }
.item:first-of-type { border-top: 0; }
.item .t { font-weight: 600; overflow-wrap: anywhere; }
.item .s { font-size: 14px; color: var(--muted); }
.item .main { flex: 1; min-width: 0; }
.time { min-width: 56px; font-variant-numeric: tabular-nums; font-weight: 700; }
.who { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 700; border-radius: 999px; padding: 2px 8px 2px 4px; border: 2px solid var(--c, var(--line)); white-space: nowrap; }
.who .dot { width: 18px; height: 18px; border-radius: 50%; background: var(--c, var(--muted)); color: #0b0f10; font-size: 11px; display: grid; place-items: center; font-weight: 800; }
.amt { font-variant-numeric: tabular-nums; font-weight: 700; white-space: nowrap; }
.amt.in { color: var(--good); }

.check { width: 30px; height: 30px; flex: none; border-radius: 9px; border: 2px solid var(--muted); background: none; display: grid; place-items: center; padding: 0; }
.check svg { width: 20px; height: 20px; }
.check[aria-checked="true"] { background: var(--good); border-color: var(--good); color: #052e16; }
.done .t { text-decoration: line-through; color: var(--muted); }

/* maand */
.mhead { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.mhead h2 { flex: 1; margin: 0; font-size: 18px; text-transform: capitalize; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--text); letter-spacing: 0; min-width: 0; }
.month { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 3px; }
.month .wd { text-align: center; font-size: 12px; color: var(--muted); padding: 4px 0; font-weight: 600; }
.day { aspect-ratio: 1 / 1.05; border: 1px solid transparent; border-radius: 10px; background: var(--panel); display: flex; flex-direction: column; align-items: center; justify-content: flex-start; padding: 4px 0 0; gap: 3px; min-width: 0; }
.day.out { opacity: .4; }
.day .n { font-size: 15px; font-variant-numeric: tabular-nums; width: 28px; height: 28px; display: grid; place-items: center; border-radius: 50%; }
.day.today .n { background: var(--accent); color: var(--accent-ink); font-weight: 800; }
.day[aria-pressed="true"] { border-color: var(--text); border-width: 2px; }
.day .marks { display: flex; gap: 2px; align-items: center; }
.day .mk { width: 8px; height: 8px; border-radius: 50%; background: var(--c); }
.day .cnt { font-size: 11px; color: var(--muted); font-weight: 700; line-height: 1; }

/* budget */
.bar { height: 10px; background: var(--panel2); border-radius: 6px; overflow: hidden; margin-top: 6px; }
.bar > i { display: block; height: 100%; background: var(--accent); border-radius: 6px; }
.bar.over > i { background: var(--bad); }
.over-t { color: var(--bad); font-weight: 700; }
.catrow { padding: 10px 0; border-top: 1px solid var(--line); }
.catrow:first-of-type { border-top: 0; }

/* formulieren */
.sheet { position: fixed; inset: 0; background: rgba(0,0,0,.55); z-index: 20; display: flex; align-items: flex-end; justify-content: center; }
.sheet[hidden] { display: none; }
.sheet .panel { background: var(--panel); width: 100%; max-width: 560px; max-height: 92vh; overflow: auto; border-radius: 20px 20px 0 0; padding: 16px 16px calc(20px + var(--safe-b)); border: 1px solid var(--line); }
.sheet h3 { margin: 0; font-size: 20px; flex: 1; }
label.f { display: block; margin-top: 12px; font-size: 14px; font-weight: 600; color: var(--muted); }
label.f > input, label.f > select, label.f > textarea, .f-in { display: block; width: 100%; margin-top: 4px; padding: 12px; min-height: 46px; border-radius: 10px; border: 1px solid var(--line); background: var(--bg); color: var(--text); font-size: 16px; }
textarea { min-height: 80px; resize: vertical; }
.two { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 10px; }
.two > * { min-width: 0; }
input[type=date], input[type=time], input[type=month] { -webkit-appearance: none; appearance: none; min-width: 0; }
.seg { display: flex; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; margin-top: 4px; }
.seg button { flex: 1; border: 0; background: var(--bg); padding: 10px 4px; min-height: 44px; font-size: 15px; }
.seg button + button { border-left: 1px solid var(--line); }
.seg button[aria-pressed="true"] { background: var(--text); color: var(--bg); font-weight: 700; }
.actions { display: flex; gap: 10px; margin-top: 18px; }
.actions .btn { flex: 1; }
.toggle { display: flex; align-items: center; gap: 10px; margin-top: 12px; font-weight: 600; min-height: 44px; }
.toggle input { width: 22px; height: 22px; }
.err { color: var(--bad); font-weight: 600; margin-top: 10px; }

.toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(140px + var(--safe-b)); background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 12px; font-weight: 600; z-index: 30; max-width: 90vw; }

.auth { max-width: 400px; margin: 0 auto; padding: 48px 20px; }
.auth h1 { font-size: 34px; margin: 12px 0 4px; letter-spacing: -0.02em; }
.logo { width: 64px; height: 64px; }
.codebox { font-family: ui-monospace, Menlo, monospace; background: var(--panel2); padding: 12px; border-radius: 10px; overflow-wrap: anywhere; user-select: all; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }