:root {
  --bg: #f7f1e8;
  --surface: #fffcf7;
  --surface-2: #f2e9dd;
  --text: #2b211b;
  --muted: #8a7a6d;
  --line: #ebe0d2;
  --accent: #c4542b;
  --accent-2: #e0893c;
  --accent-ink: #ffffff;
  --accent-soft: #f8e4d7;
  --danger: #b93a26;
  --up: #c2412d;
  --down: #3e8a5b;
  --hero-bg: radial-gradient(120% 90% at 100% 0%, rgb(224 137 60 / 0.35) 0%, transparent 55%), linear-gradient(150deg, #3d2b22 0%, #2a1d17 100%);
  --hero-ink: #fbf3ea;
  --hero-muted: rgb(251 243 234 / 0.62);
  --shadow: 0 1px 2px rgb(60 35 20 / 0.04), 0 8px 24px -8px rgb(60 35 20 / 0.10);
  --radius: 22px;
  --tabbar-h: 66px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #17120f;
    --surface: #221b17;
    --surface-2: #2e2521;
    --text: #f5ece3;
    --muted: #a89a8d;
    --line: #372c26;
    --accent: #e57649;
    --accent-2: #f0a054;
    --accent-ink: #1e110b;
    --accent-soft: #3b2419;
    --danger: #f07a62;
    --up: #f07a62;
    --down: #6cc08d;
    --hero-bg: radial-gradient(120% 90% at 100% 0%, rgb(240 160 84 / 0.30) 0%, transparent 55%), linear-gradient(150deg, #8a3a1f 0%, #4a2216 100%);
    --hero-ink: #fff5ec;
    --hero-muted: rgb(255 245 236 / 0.65);
    --shadow: none;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #17120f;
  --surface: #221b17;
  --surface-2: #2e2521;
  --text: #f5ece3;
  --muted: #a89a8d;
  --line: #372c26;
  --accent: #e57649;
  --accent-2: #f0a054;
  --accent-ink: #1e110b;
  --accent-soft: #3b2419;
  --danger: #f07a62;
  --up: #f07a62;
  --down: #6cc08d;
  --hero-bg: radial-gradient(120% 90% at 100% 0%, rgb(240 160 84 / 0.30) 0%, transparent 55%), linear-gradient(150deg, #8a3a1f 0%, #4a2216 100%);
  --hero-ink: #fff5ec;
  --hero-muted: rgb(255 245 236 / 0.65);
  --shadow: none;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.45 "Plus Jakarta Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: none;
}
button, input, select { font: inherit; color: inherit; }
[hidden] { display: none !important; }
.muted { color: var(--muted); }
.error { color: var(--danger); font-size: 14px; min-height: 1.2em; margin: 8px 0 0; }

main {
  max-width: 560px;
  margin: 0 auto;
  padding: calc(env(safe-area-inset-top) + 10px) 16px calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 28px);
}

/* Kop met maandwisselaar */
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 6px 0 16px;
}
.month-title { flex: 1; text-align: center; }
.month-title.left { text-align: left; }
.month-title small {
  display: block; font-size: 11px; font-weight: 700; letter-spacing: 0.12em; text-transform: uppercase; color: var(--accent);
}
.month-title h2 { margin: 2px 0 0; font-size: 24px; font-weight: 800; letter-spacing: -0.02em; text-transform: capitalize; }
.icon-btn {
  width: 42px; height: 42px; border-radius: 14px; border: 1px solid var(--line);
  background: var(--surface); box-shadow: var(--shadow);
  display: grid; place-items: center; cursor: pointer; color: var(--text);
}
.icon-btn:disabled { opacity: 0.35; }
.icon-btn:active:not(:disabled) { transform: scale(0.94); }

/* Kaarten */
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 20px; margin-bottom: 14px;
}
.card.flush { padding: 4px 0 6px; }
.card h3 {
  margin: 0 0 14px; font-size: 12px; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted);
}

/* Hoofdkaart */
.hero {
  position: relative; overflow: hidden;
  background: var(--hero-bg); color: var(--hero-ink);
  border-radius: 26px; padding: 22px 22px 18px; margin-bottom: 14px;
  box-shadow: 0 18px 40px -18px rgb(60 30 15 / 0.55);
}
.hero::after {
  content: ""; position: absolute; right: -40px; bottom: -60px; width: 180px; height: 180px; border-radius: 50%;
  border: 28px solid rgb(255 255 255 / 0.04); pointer-events: none;
}
.hero-top { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.eyebrow { margin: 0; color: var(--hero-muted); font-size: 13px; font-weight: 500; }
.hero-total {
  margin: 6px 0 18px; font-size: 46px; font-weight: 800; letter-spacing: -0.035em; line-height: 1.05;
  font-variant-numeric: tabular-nums;
}
.hero-stats {
  display: grid; grid-template-columns: repeat(3, 1fr);
  border-top: 1px solid rgb(255 255 255 / 0.12); padding-top: 14px;
}
.hero-stats div + div { border-left: 1px solid rgb(255 255 255 / 0.12); padding-left: 14px; }
.hero-stats small { display: block; font-size: 11.5px; color: var(--hero-muted); font-weight: 500; }
.hero-stats strong { font-size: 16px; font-weight: 700; font-variant-numeric: tabular-nums; }
/* Budget in de hoofdkaart */
.budget { margin: -4px 0 16px; }
.budget-bar { position: relative; height: 8px; border-radius: 4px; background: rgb(255 255 255 / 0.14); }
.budget-bar i {
  display: block; height: 100%; border-radius: 4px; max-width: 100%;
  background: linear-gradient(90deg, #f3b56a, #e8894a); transition: width 0.4s ease;
}
.budget-bar i.over { background: linear-gradient(90deg, #f08a6a, #e0503a); }
.budget-pace {
  position: absolute; top: -4px; width: 2px; height: 16px; margin-left: -1px; border-radius: 1px;
  background: var(--hero-ink); opacity: 0.8;
}
.budget-row { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-top: 9px; font-size: 13.5px; color: var(--hero-muted); }
.budget-row strong { color: var(--hero-ink); font-weight: 700; font-variant-numeric: tabular-nums; }
.budget-row strong.over { color: #ffb4a0; }
.budget-edit, .budget-set {
  border: 0; cursor: pointer; font-weight: 700; font-size: 12.5px; color: var(--hero-ink);
  background: rgb(255 255 255 / 0.12); padding: 5px 11px; border-radius: 999px;
}
.budget-set { display: block; margin: -6px 0 16px; padding: 8px 14px; font-size: 13px; }
.budget-forecast { margin: 6px 0 0; font-size: 12.5px; color: var(--hero-muted); }
.budget-forecast.over { color: #ffb4a0; }
.legend .legend-dash { width: 14px; height: 0; border-radius: 0; border-top: 2px dashed var(--text); }
.month-list .m-amt.over { color: var(--up); }
.sheet-sub { margin: -4px 0 14px; font-size: 14px; }

.pill {
  padding: 4px 10px; border-radius: 999px; font-weight: 700; font-size: 12.5px; white-space: nowrap;
  background: rgb(255 255 255 / 0.12); color: var(--hero-ink);
}
.pill.up { background: rgb(255 120 90 / 0.22); color: #ffd3c6; }
.pill.down { background: rgb(120 210 150 / 0.20); color: #cdf1d9; }
.pill:empty { display: none; }

/* Donut */
.donut-wrap { position: relative; width: 210px; height: 210px; margin: 0 auto 18px; }
.donut-center {
  position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center;
  pointer-events: none; text-align: center;
}
.donut-center small { color: var(--muted); font-size: 11px; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase; }
.donut-center span { font-weight: 800; font-size: 18px; letter-spacing: -0.01em; margin-top: 2px; }

.store-list, .receipt-list, .month-list { list-style: none; margin: 0; padding: 0; }
.store-list li { display: grid; grid-template-columns: 12px 1fr auto; gap: 6px 10px; align-items: center; padding: 10px 0; }
.store-list li + li { border-top: 1px solid var(--line); }
.store-list li > span:nth-child(2) { font-weight: 600; }
.dot { width: 12px; height: 12px; border-radius: 4px; }
.store-list .amt { font-weight: 700; font-variant-numeric: tabular-nums; }
.store-list .bar { grid-column: 2 / 4; height: 6px; background: var(--surface-2); border-radius: 3px; overflow: hidden; }
.store-list .bar i { display: block; height: 100%; border-radius: 3px; }
.store-list .pct { color: var(--muted); font-size: 12.5px; font-weight: 500; margin-left: 8px; }

.empty { text-align: center; color: var(--muted); padding: 28px 12px; }

/* Maanden */
.chart-wrap { position: relative; height: 240px; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 14px; margin-top: 14px; font-size: 12.5px; color: var(--muted); font-weight: 500; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 10px; height: 10px; border-radius: 3px; }

.compare-pick { display: flex; align-items: center; gap: 8px; margin-bottom: 14px; }
.compare-pick select {
  flex: 1; min-width: 0; padding: 11px 10px; border-radius: 14px; border: 1px solid var(--line);
  background: var(--surface-2); text-transform: capitalize; font-size: 15px; font-weight: 600;
}
.cmp-table { width: 100%; border-collapse: collapse; font-size: 13.5px; font-variant-numeric: tabular-nums; }
.cmp-table th, .cmp-table td { white-space: nowrap; }
.cmp-table th {
  text-align: right; color: var(--muted); font-weight: 700; font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase; padding: 6px 4px;
}
.cmp-table th:first-child, .cmp-table td:first-child { text-align: left; }
.cmp-table td { text-align: right; padding: 9px 4px; border-top: 1px solid var(--line); }
.cmp-table td:first-child { display: flex; align-items: center; gap: 6px; font-weight: 600; }
.cmp-table .dot { width: 10px; height: 10px; flex: none; }
.cmp-table tr.total td { font-weight: 800; border-top: 2px solid var(--line); }
.cmp-table .up { color: var(--up); font-weight: 600; }
.cmp-table .down { color: var(--down); font-weight: 600; }

.month-list li button {
  width: 100%; display: flex; justify-content: space-between; align-items: center;
  padding: 13px 0; background: none; border: 0; border-top: 1px solid var(--line); cursor: pointer; text-align: left;
}
.month-list li:first-child button { border-top: 0; }
.month-list .m-name { text-transform: capitalize; font-weight: 600; }
.month-list .m-amt { font-weight: 700; font-variant-numeric: tabular-nums; }

/* Bonnetjes */
.card-head { display: flex; justify-content: space-between; align-items: center; padding: 16px 18px 6px; }
.card-head h3 { margin: 0; }
.link-btn {
  border: 0; background: var(--accent-soft); color: var(--accent); font-weight: 700; font-size: 13px;
  cursor: pointer; padding: 6px 12px; border-radius: 999px;
}
.btn.wide { width: 100%; }
.receipt-list li button {
  width: 100%; display: grid; grid-template-columns: 42px 1fr auto; align-items: center; gap: 12px;
  padding: 11px 18px; background: none; border: 0; text-align: left; cursor: pointer;
}
.receipt-list li + li button { border-top: 1px solid var(--line); }
.receipt-list li button:active { background: var(--surface-2); }
.badge {
  width: 42px; height: 42px; border-radius: 13px; display: grid; place-items: center;
  font-weight: 800; font-size: 13px; letter-spacing: -0.02em;
}
.receipt-list .r-store { font-weight: 700; }
.receipt-list .r-sub { font-size: 13px; color: var(--muted); }
.receipt-list .r-amt { font-weight: 700; font-variant-numeric: tabular-nums; }

/* Back-ups */
.card-head.inline { padding: 0 0 8px; }
.backup-info { margin: 0 0 8px; font-size: 13.5px; color: var(--muted); }
.backup-list { list-style: none; margin: 0; padding: 0; }
.backup-list li { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 11px 0; border-top: 1px solid var(--line); }
.backup-list .b-date { font-weight: 600; font-size: 14.5px; }
.backup-list .b-date::first-letter { text-transform: uppercase; }
.device-list .b-date::first-letter { text-transform: none; }
.backup-list .b-sub { font-size: 12.5px; color: var(--muted); }
.b-actions { display: flex; gap: 6px; flex: none; }
.icon-btn.small { width: 36px; height: 36px; border-radius: 11px; box-shadow: none; }
.link-plain { border: 0; background: none; color: var(--accent); font-weight: 700; font-size: 13.5px; padding: 10px 0 0; cursor: pointer; }

.tag {
  display: inline-block; margin-left: 6px; padding: 2px 8px; border-radius: 999px; vertical-align: 1px;
  background: var(--accent-soft); color: var(--accent); font-size: 11px; font-weight: 700;
}
.link-btn.danger { color: var(--danger); background: color-mix(in srgb, var(--danger) 12%, transparent); }
.btn.subtle { margin-top: 10px; color: var(--muted); background: none; box-shadow: none; }
.lock .lock-name { font-size: 15px; letter-spacing: 0; }

/* Knoppen */
.btn {
  padding: 13px 16px; border-radius: 16px; border: 1px solid var(--line); background: var(--surface); box-shadow: var(--shadow);
  font-weight: 700; cursor: pointer;
}
.btn.primary {
  border: 0; color: var(--accent-ink);
  background: linear-gradient(135deg, var(--accent-2), var(--accent));
  box-shadow: 0 8px 20px -8px color-mix(in srgb, var(--accent) 70%, transparent);
}
.btn.danger { color: var(--danger); }
.btn:disabled { opacity: 0.5; }
.btn:active:not(:disabled) { transform: scale(0.98); }

/* Tabbalk */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  display: grid; grid-template-columns: 1fr 100px 1fr; align-items: end;
  height: calc(var(--tabbar-h) + env(safe-area-inset-bottom));
  padding: 0 12px env(safe-area-inset-bottom);
  background: color-mix(in srgb, var(--surface) 86%, transparent);
  backdrop-filter: blur(18px) saturate(1.4); -webkit-backdrop-filter: blur(18px) saturate(1.4);
  border-top: 1px solid var(--line);
}
.tab {
  height: var(--tabbar-h); border: 0; background: none; color: var(--muted);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  font-size: 11px; font-weight: 700; cursor: pointer;
}
.tab svg { width: 24px; height: 24px; }
.tab.active { color: var(--accent); }
.scan-btn {
  display: flex; flex-direction: column; align-items: center; gap: 4px; padding-bottom: 8px;
  font-size: 11px; font-weight: 800; color: var(--accent); cursor: pointer;
}
.scan-ico {
  width: 62px; height: 62px; border-radius: 22px; margin-top: -28px;
  display: grid; place-items: center; color: #fff;
  background: linear-gradient(140deg, var(--accent-2), var(--accent));
  box-shadow: 0 10px 24px -6px color-mix(in srgb, var(--accent) 60%, transparent), inset 0 1px 0 rgb(255 255 255 / 0.25);
  border: 4px solid var(--bg);
}
.scan-btn:active .scan-ico { transform: scale(0.94); }

/* Pincode */
.lock {
  position: fixed; inset: 0; z-index: 50;
  background: radial-gradient(90% 60% at 50% 0%, var(--accent-soft) 0%, transparent 70%), var(--bg);
  display: grid; place-items: center; padding: 24px;
}
.lock-card { width: 100%; max-width: 340px; text-align: center; }
.lock-icon { width: 84px; height: 84px; border-radius: 22px; box-shadow: 0 14px 30px -12px rgb(120 50 20 / 0.5); }
.lock h1 { margin: 16px 0 4px; font-size: 30px; font-weight: 800; letter-spacing: -0.02em; }
.lock form { display: grid; gap: 10px; margin-top: 24px; }
.lock input {
  padding: 15px; border-radius: 16px; border: 1px solid var(--line); background: var(--surface);
  text-align: center; font-size: 18px; letter-spacing: 0.12em;
}

/* Bezig */
.busy {
  position: fixed; inset: 0; z-index: 40; background: color-mix(in srgb, var(--bg) 85%, transparent);
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 16px; font-weight: 700;
}
.spinner {
  width: 46px; height: 46px; border-radius: 50%;
  border: 4px solid var(--surface-2); border-top-color: var(--accent);
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Onderblad */
.sheet-backdrop {
  position: fixed; inset: 0; z-index: 30; background: rgb(30 18 10 / 0.45);
  display: flex; align-items: flex-end; justify-content: center;
}
.sheet {
  width: 100%; max-width: 560px; max-height: 92vh; overflow-y: auto;
  background: var(--bg); border-radius: 26px 26px 0 0;
  padding: 8px 16px calc(16px + env(safe-area-inset-bottom));
  animation: up 0.22s ease-out;
}
@keyframes up { from { transform: translateY(40px); opacity: 0; } }
.sheet-grip { width: 40px; height: 5px; border-radius: 3px; background: var(--line); margin: 4px auto 12px; }
.sheet h3 { margin: 0 0 12px; font-size: 21px; font-weight: 800; letter-spacing: -0.01em; }
.hint { background: var(--accent-soft); color: var(--text); padding: 11px 13px; border-radius: 14px; font-size: 14px; margin: 0 0 12px; }
.sheet-photo { width: 100%; max-height: 160px; object-fit: cover; object-position: top; border-radius: 16px; margin-bottom: 12px; }
fieldset { border: 0; padding: 0; margin: 0 0 14px; }
legend, .field > span {
  font-size: 11.5px; color: var(--muted); font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; margin-bottom: 7px; display: block;
}
.store-picker { display: grid; grid-template-columns: repeat(3, 1fr); gap: 7px; }
.store-picker button {
  padding: 10px 4px; border-radius: 14px; border: 1.5px solid var(--line); background: var(--surface);
  font-size: 13px; font-weight: 700; cursor: pointer; display: flex; flex-direction: column; align-items: center; gap: 5px;
}
.store-picker button .dot { width: 14px; height: 14px; border-radius: 50%; }
.store-picker button[aria-pressed="true"] { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.field { display: block; margin-bottom: 12px; }
.field input, .money {
  width: 100%; padding: 12px; border-radius: 14px; border: 1px solid var(--line); background: var(--surface);
  font-size: 17px; min-height: 50px;
}
.field input:focus, .money:focus-within, .lock input:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
.money { display: flex; align-items: center; gap: 6px; padding: 0 12px; }
.money span { color: var(--muted); font-weight: 700; }
.money input { border: 0; padding: 12px 0; background: none; outline: none !important; font-weight: 800; font-size: 20px; min-width: 0; }
.sheet-actions { display: flex; gap: 8px; margin-top: 8px; }
.sheet-actions .primary { flex: 1; }

/* Melding */
.toast {
  position: fixed; left: 50%; bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 18px); z-index: 60;
  transform: translateX(-50%); background: var(--text); color: var(--bg);
  padding: 11px 18px; border-radius: 999px; font-size: 14px; font-weight: 700; max-width: calc(100% - 32px);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  box-shadow: 0 10px 30px -10px rgb(0 0 0 / 0.4);
}
