/* Blip — kasboek
   Twee kassen, elk met een eigen kleur: SRD = groen, euro = indigo.
   Rustige witte interface; de kleur zit alleen in de saldokaart en de knoppen. */

:root {
  --ink: #13232E;
  --ink-2: #44575F;
  --ink-3: #6E8088;
  --paper: #EEF3F1;
  --card: #FFFFFF;
  --line: #D5E0DC;
  --line-2: #E6EDEA;
  --srd: #126B52;
  --srd-deep: #0C513E;
  --srd-soft: #DDEFE7;
  --eur: #2F45A8;
  --eur-deep: #223489;
  --eur-soft: #E1E6F8;
  --wissel: #E3A72F;
  --wissel-soft: #FBEFD3;
  --in: #126B52;
  --out: #13232E;
  --danger: #A3263A;
  --danger-soft: #FBE9EC;
  --focus: #E3A72F;
  --act-out-bg: #13232E;
  --act-out-fg: #FFFFFF;

  --kas: var(--srd);
  --kas-deep: var(--srd-deep);
  --kas-soft: var(--srd-soft);

  --font: "Atkinson Hyperlegible", system-ui, -apple-system, "Segoe UI", sans-serif;
  --display: "Bricolage Grotesque", "Atkinson Hyperlegible", system-ui, sans-serif;

  --r-lg: 22px;
  --r-md: 14px;
  --r-sm: 10px;
  --nav-h: 64px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  color-scheme: light;
}

body[data-kas="EUR"] { --kas: var(--eur); --kas-deep: var(--eur-deep); --kas-soft: var(--eur-soft); }

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --ink: #E7EEEC;
    --ink-2: #B5C4C0;
    --ink-3: #8B9C98;
    --paper: #0F1A1F;
    --card: #17252B;
    --line: #2A3B42;
    --line-2: #223238;
    --srd: #2E9A78;
    --srd-deep: #1B6E55;
    --srd-soft: #173A30;
    --eur: #5C72D6;
    --eur-deep: #3B50B0;
    --eur-soft: #1E2650;
    --wissel-soft: #3A2F14;
    --in: #4CC199;
    --out: #E7EEEC;
    --danger: #F07A8C;
    --danger-soft: #3B1A21;
    color-scheme: dark;
    --act-out-bg: #E7EEEC;
    --act-out-fg: #0F1A1F;
  }
}
:root[data-theme="dark"] {
  --ink: #E7EEEC;
  --ink-2: #B5C4C0;
  --ink-3: #8B9C98;
  --paper: #0F1A1F;
  --card: #17252B;
  --line: #2A3B42;
  --line-2: #223238;
  --srd: #2E9A78;
  --srd-deep: #1B6E55;
  --srd-soft: #173A30;
  --eur: #5C72D6;
  --eur-deep: #3B50B0;
  --eur-soft: #1E2650;
  --wissel-soft: #3A2F14;
  --in: #4CC199;
  --out: #E7EEEC;
  --danger: #F07A8C;
  --danger-soft: #3B1A21;
  color-scheme: dark;
  --act-out-bg: #E7EEEC;
  --act-out-fg: #0F1A1F;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 17px/1.45 var(--font);
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: inherit; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 6px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.num { font-variant-numeric: tabular-nums; white-space: nowrap; }

/* ---------- Layout ---------- */

.page {
  max-width: 620px;
  margin: 0 auto;
  padding: 16px 16px calc(var(--nav-h) + var(--safe-b) + 28px);
}
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 44px;
  margin-bottom: 12px;
}
.brand {
  font-family: var(--display);
  font-weight: 800;
  font-size: 26px;
  letter-spacing: -0.03em;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
}
.brand-mark { width: 26px; height: 26px; flex: none; }
.topbar .who { color: var(--ink-3); font-size: 15px; }
h1.title {
  font-family: var(--display);
  font-weight: 700;
  font-size: 30px;
  letter-spacing: -0.025em;
  line-height: 1.1;
  margin: 4px 0 16px;
}
h2.section {
  font-family: var(--display);
  font-weight: 700;
  font-size: 20px;
  letter-spacing: -0.015em;
  margin: 28px 0 10px;
}
.back {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: none;
  border: 0;
  padding: 8px 4px;
  margin-left: -4px;
  color: var(--ink-2);
  font-weight: 700;
  text-decoration: none;
}
.back svg { width: 20px; height: 20px; }
.muted { color: var(--ink-3); }
.small { font-size: 15px; }

/* ---------- Saldokaart: het enige luide element ---------- */

.kascard {
  background: var(--kas);
  color: #fff;
  border-radius: var(--r-lg);
  padding: 14px 14px 22px;
  transition: background-color .35s ease;
  position: relative;
  overflow: hidden;
}
.kascard::after {
  /* de 'blip': een rustige stip rechtsboven die de kas markeert */
  content: "";
  position: absolute;
  right: 22px;
  top: 64px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--wissel);
  box-shadow: 0 0 0 7px rgba(255,255,255,.12), 0 0 0 16px rgba(255,255,255,.06);
}
.kasswitch {
  display: inline-grid;
  grid-auto-flow: column;
  gap: 4px;
  padding: 4px;
  background: rgba(0,0,0,.18);
  border-radius: 999px;
}
.kasswitch button {
  border: 0;
  background: transparent;
  color: rgba(255,255,255,.82);
  padding: 8px 16px;
  border-radius: 999px;
  font-weight: 700;
  font-size: 15px;
  min-height: 38px;
}
.kasswitch button[aria-pressed="true"] { background: #fff; color: var(--kas-deep); }
.kascard .label { margin: 22px 4px 2px; font-size: 16px; opacity: .85; }
.kascard .balance {
  font-family: var(--display);
  font-weight: 800;
  font-size: clamp(40px, 12.5vw, 60px);
  line-height: 1;
  letter-spacing: -0.035em;
  margin: 0 4px;
  font-variant-numeric: tabular-nums;
}
.kascard .balance .cur { font-size: .45em; font-weight: 700; letter-spacing: 0; margin-right: .18em; vertical-align: .55em; opacity: .9; }
.kascard .balance .dec { font-size: .5em; letter-spacing: -0.01em; }
.kascard .meta { margin: 12px 4px 0; font-size: 15px; opacity: .85; }
.kascard .empty-cta {
  margin: 14px 4px 0;
  display: inline-block;
  background: #fff;
  color: var(--kas-deep);
  border: 0;
  border-radius: 999px;
  padding: 10px 16px;
  font-weight: 700;
}

/* ---------- Actieknoppen ---------- */

.actions {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 10px;
  margin: 14px 0 6px;
}
.act {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 58px;
  border-radius: var(--r-md);
  border: 0;
  font-weight: 700;
  font-size: 18px;
  padding: 0 14px;
}
.act svg { width: 22px; height: 22px; flex: none; }
.act-in { background: var(--card); color: var(--in); box-shadow: inset 0 0 0 2px var(--kas-soft); }
.act-out { background: var(--act-out-bg); color: var(--act-out-fg); }
.act-wissel { background: var(--wissel-soft); color: var(--ink); padding: 0 16px; }

/* ---------- Lijsten ---------- */

.list {
  background: var(--card);
  border-radius: var(--r-md);
  border: 1px solid var(--line-2);
  overflow: hidden;
}
.row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 4px 12px;
  align-items: center;
  padding: 13px 14px;
  border-top: 1px solid var(--line-2);
  text-decoration: none;
  color: inherit;
  background: none;
  width: 100%;
  text-align: left;
  border-left: 0; border-right: 0; border-bottom: 0;
}
.row:first-child { border-top: 0; }
.row:hover { background: color-mix(in srgb, var(--paper) 55%, transparent); }
.row .desc { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .sub { color: var(--ink-3); font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .amt { font-weight: 700; text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.row .bal { color: var(--ink-3); font-size: 14px; text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.amt.in { color: var(--in); }
.amt.out { color: var(--out); }
.amt.wissel { color: var(--in); }
.row.deleted .desc, .row.deleted .amt { text-decoration: line-through; color: var(--ink-3); }
.tag {
  display: inline-block;
  font-size: 12px;
  font-weight: 700;
  padding: 1px 7px;
  border-radius: 999px;
  vertical-align: 2px;
  margin-left: 6px;
  background: var(--line-2);
  color: var(--ink-2);
}
.tag.w { background: var(--wissel-soft); color: var(--ink); }
.tag.d { background: var(--danger-soft); color: var(--danger); }
.clip { width: 14px; height: 14px; vertical-align: -2px; margin-left: 4px; color: var(--ink-3); }

.month-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  margin: 22px 2px 8px;
}
.month-head h3 { font-family: var(--display); font-size: 18px; font-weight: 700; margin: 0; letter-spacing: -0.01em; }
.month-head .tot { font-size: 14px; color: var(--ink-3); text-align: right; }

.linkrow {
  display: block;
  text-align: center;
  padding: 14px;
  font-weight: 700;
  color: var(--kas);
  text-decoration: none;
}

.empty {
  background: var(--card);
  border: 1px dashed var(--line);
  border-radius: var(--r-md);
  padding: 24px 18px;
  text-align: center;
  color: var(--ink-2);
}

/* ---------- Filters ---------- */

.seg {
  display: inline-grid;
  grid-auto-flow: column;
  gap: 4px;
  padding: 4px;
  background: var(--line-2);
  border-radius: 999px;
}
.seg button {
  border: 0;
  background: transparent;
  padding: 8px 14px;
  border-radius: 999px;
  font-weight: 700;
  font-size: 15px;
  color: var(--ink-2);
  min-height: 38px;
}
.seg button[aria-pressed="true"] { background: var(--card); color: var(--ink); box-shadow: 0 1px 2px rgba(19,35,46,.12); }
.seg.kas button[aria-pressed="true"] { background: var(--kas); color: #fff; }
.filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 8px; }
.filters .grow { flex: 1 1 180px; }

/* ---------- Formulieren ---------- */

.field { margin: 16px 0 0; }
.field > label, .field > .lbl { display: block; font-weight: 700; font-size: 15px; margin-bottom: 6px; }
.input, select.input, textarea.input {
  width: 100%;
  min-height: 48px;
  padding: 11px 13px;
  border: 1.5px solid var(--line);
  border-radius: var(--r-sm);
  background: var(--card);
  font-size: 17px;
}
.input:focus { outline: none; border-color: var(--kas); box-shadow: 0 0 0 3px var(--kas-soft); }
.money {
  display: flex;
  align-items: baseline;
  gap: 10px;
  border-bottom: 2px solid var(--line);
  padding: 4px 2px 8px;
}
.money:focus-within { border-color: var(--kas); }
.money .cur { font-family: var(--display); font-weight: 700; font-size: 24px; color: var(--ink-3); }
.money input {
  border: 0;
  outline: none;
  background: none;
  width: 100%;
  font-family: var(--display);
  font-weight: 800;
  font-size: 42px;
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
  padding: 0;
  min-width: 0;
}
.money input::placeholder { color: var(--line); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  border: 1.5px solid var(--line);
  background: var(--card);
  border-radius: 999px;
  padding: 8px 14px;
  font-weight: 700;
  font-size: 15px;
  min-height: 40px;
}
.chip[aria-pressed="true"] { background: var(--kas); border-color: var(--kas); color: #fff; }
.help { color: var(--ink-3); font-size: 14px; margin-top: 6px; }
.error-msg {
  background: var(--danger-soft);
  color: var(--danger);
  border-radius: var(--r-sm);
  padding: 10px 12px;
  margin-top: 14px;
  font-weight: 700;
  font-size: 15px;
}
.note {
  background: var(--wissel-soft);
  border-radius: var(--r-sm);
  padding: 12px 14px;
  margin-top: 14px;
  font-size: 15px;
}
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 52px;
  padding: 0 20px;
  border-radius: var(--r-md);
  border: 0;
  font-weight: 700;
  font-size: 17px;
  text-decoration: none;
}
.btn-primary { background: var(--kas); color: #fff; }
.btn-primary:disabled { opacity: .55; }
.btn-ghost { background: var(--card); color: var(--ink); box-shadow: inset 0 0 0 1.5px var(--line); }
.btn-danger { background: var(--danger-soft); color: var(--danger); }
.btn-block { width: 100%; }
.btn-row { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 20px; }
.btn-row .btn { flex: 1 1 140px; }

.filepick {
  display: flex;
  align-items: center;
  gap: 12px;
  border: 1.5px dashed var(--line);
  border-radius: var(--r-sm);
  padding: 12px;
  background: var(--card);
}
.filepick img { width: 56px; height: 56px; object-fit: cover; border-radius: 8px; flex: none; }
.filepick .fp-text { flex: 1; min-width: 0; font-size: 15px; }
.filepick .fp-text strong { display: block; }
.filepick button { border: 0; background: none; color: var(--kas); font-weight: 700; padding: 8px; }

.switch { display: flex; align-items: center; gap: 12px; font-weight: 700; }
.switch input { width: 22px; height: 22px; accent-color: var(--kas); }

/* ---------- Sheet (invoerscherm) ---------- */

.sheet-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(10, 20, 26, .45);
  z-index: 40;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  animation: fade .18s ease;
}
.sheet {
  background: var(--paper);
  width: 100%;
  max-width: 620px;
  max-height: 94vh;
  overflow: auto;
  border-radius: var(--r-lg) var(--r-lg) 0 0;
  padding: 10px 18px calc(22px + var(--safe-b));
  animation: rise .22s cubic-bezier(.2,.8,.2,1);
  overscroll-behavior: contain;
}
.sheet-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  position: sticky;
  top: -10px;
  background: var(--paper);
  padding: 10px 0 8px;
  z-index: 1;
}
.sheet-head h2 { font-family: var(--display); font-size: 22px; font-weight: 700; letter-spacing: -0.02em; margin: 0; }
.sheet-head .kaslbl { display: block; font-family: var(--font); font-size: 14px; font-weight: 700; color: var(--kas); letter-spacing: 0; }
.icon-btn {
  border: 0;
  background: var(--card);
  width: 42px;
  height: 42px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  flex: none;
}
.icon-btn svg { width: 20px; height: 20px; }
@media (min-width: 700px) {
  .sheet-backdrop { align-items: center; }
  .sheet { border-radius: var(--r-lg); }
}
@keyframes rise { from { transform: translateY(40px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

.effect {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 16px;
}
.effect > div { background: var(--card); border-radius: var(--r-sm); padding: 10px 12px; }
.effect .k { font-size: 14px; color: var(--ink-3); font-weight: 700; }
.effect .v { font-weight: 700; font-size: 18px; font-variant-numeric: tabular-nums; }
.effect .eur .k { color: var(--eur); }
.effect .srd .k { color: var(--srd); }

/* ---------- Detail ---------- */

.detail-amt {
  font-family: var(--display);
  font-weight: 800;
  font-size: 44px;
  letter-spacing: -0.035em;
  line-height: 1.05;
  font-variant-numeric: tabular-nums;
  margin: 6px 0 4px;
}
.facts {
  background: var(--card);
  border-radius: var(--r-md);
  border: 1px solid var(--line-2);
  margin-top: 16px;
}
.facts > div { display: grid; grid-template-columns: 120px 1fr; gap: 12px; padding: 12px 14px; border-top: 1px solid var(--line-2); }
.facts > div:first-child { border-top: 0; }
.facts dt { color: var(--ink-3); font-size: 15px; }
.facts dd { margin: 0; font-weight: 700; overflow-wrap: anywhere; }
.receipt-view { margin-top: 16px; }
.receipt-view img { width: 100%; border-radius: var(--r-md); border: 1px solid var(--line); display: block; background: var(--card); }
.history { list-style: none; padding: 0; margin: 0; }
.history li { padding: 10px 2px; border-top: 1px solid var(--line); font-size: 15px; }
.history li:first-child { border-top: 0; }
.history .when { color: var(--ink-3); font-size: 14px; }
.change { color: var(--ink-2); }

/* ---------- Overzicht ---------- */

.statement {
  background: var(--card);
  border-radius: var(--r-md);
  border: 1px solid var(--line-2);
  padding: 4px 16px;
}
.statement > div { display: flex; justify-content: space-between; gap: 12px; padding: 11px 0; border-top: 1px solid var(--line-2); }
.statement > div:first-child { border-top: 0; }
.statement .end { font-weight: 700; font-size: 19px; border-top: 2px solid var(--ink); }
.bars { display: grid; gap: 12px; }
.bar .bar-top { display: flex; justify-content: space-between; gap: 12px; font-size: 15px; margin-bottom: 5px; }
.bar .bar-top strong { font-weight: 700; }
.bar .track { height: 10px; background: var(--line-2); border-radius: 999px; overflow: hidden; }
.bar .fill { height: 100%; background: var(--kas); border-radius: 999px; }
.bar.in .fill { background: var(--in); opacity: .55; }
.months { display: grid; gap: 14px; }
.month-bars { display: grid; grid-template-columns: 88px 1fr; gap: 10px; align-items: center; font-size: 15px; }
.month-bars .pair { display: grid; gap: 4px; }
.month-bars .pb { display: flex; align-items: center; gap: 8px; }
.month-bars .pb span { height: 10px; border-radius: 999px; min-width: 2px; }
.month-bars .pb .i { background: var(--in); opacity: .55; }
.month-bars .pb .o { background: var(--kas); }
.month-bars .pb em { font-style: normal; color: var(--ink-3); font-size: 13px; white-space: nowrap; font-variant-numeric: tabular-nums; }
.legend { display: flex; gap: 16px; font-size: 14px; color: var(--ink-3); margin: 4px 0 12px; }
.legend i { display: inline-block; width: 12px; height: 12px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }

/* ---------- Meer ---------- */

.menu { background: var(--card); border-radius: var(--r-md); border: 1px solid var(--line-2); overflow: hidden; }
.menu a, .menu button {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  padding: 16px;
  border: 0;
  border-top: 1px solid var(--line-2);
  background: none;
  text-decoration: none;
  font-weight: 700;
  text-align: left;
}
.menu > :first-child { border-top: 0; }
.menu .sub { display: block; font-weight: 400; color: var(--ink-3); font-size: 14px; }
.menu svg { width: 18px; height: 18px; color: var(--ink-3); flex: none; }

/* ---------- Navigatie ---------- */

.nav {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 30;
  background: color-mix(in srgb, var(--card) 94%, transparent);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-top: 1px solid var(--line);
  padding-bottom: var(--safe-b);
}
.nav-inner { max-width: 620px; margin: 0 auto; display: grid; grid-template-columns: repeat(4, 1fr); }
.nav a {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  height: var(--nav-h);
  text-decoration: none;
  color: var(--ink-3);
  font-size: 13px;
  font-weight: 700;
}
.nav a svg { width: 24px; height: 24px; }
.nav a[aria-current="page"] { color: var(--kas); }

/* ---------- Login ---------- */

.login {
  max-width: 400px;
  margin: 0 auto;
  padding: 12vh 20px 40px;
}
.login .brand { font-size: 44px; }
.login .brand-mark { width: 42px; height: 42px; }
.login p.lead { color: var(--ink-2); margin: 8px 0 24px; }

/* ---------- Toast ---------- */

#toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--nav-h) + var(--safe-b) + 16px);
  transform: translate(-50%, 20px);
  background: var(--ink);
  color: var(--paper);
  padding: 12px 18px;
  border-radius: 16px;
  font-weight: 700;
  font-size: 15px;
  width: max-content;
  max-width: min(420px, calc(100% - 32px));
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s, transform .2s;
  z-index: 60;
  text-align: center;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }

.loading { padding: 40px 0; text-align: center; color: var(--ink-3); }

/* ---------- Rapport (ook om te printen) ---------- */

.report { background: var(--card); border-radius: var(--r-md); border: 1px solid var(--line-2); padding: 22px 18px; }
.report h1 { font-family: var(--display); font-size: 26px; letter-spacing: -0.02em; margin: 0 0 2px; }
.report h2 { font-family: var(--display); font-size: 18px; margin: 24px 0 8px; }
.report table { width: 100%; border-collapse: collapse; font-size: 14px; }
.report th, .report td { text-align: left; padding: 7px 6px; border-bottom: 1px solid var(--line-2); vertical-align: top; }
.report th { font-size: 13px; color: var(--ink-3); font-weight: 700; }
.report td.r, .report th.r { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.report td:nth-child(2) { overflow-wrap: anywhere; }
@media (max-width: 520px) {
  .report { padding: 18px 12px; }
  .report table { font-size: 12.5px; }
  .report th, .report td { padding: 6px 3px; }
  .report th:first-child, .report td:first-child { white-space: nowrap; }
}
.report td .cat { display: block; color: var(--ink-3); font-size: 13px; }
.report tr.total td { font-weight: 700; border-top: 2px solid var(--ink); border-bottom: 0; }
.report .final { margin-top: 20px; font-size: 18px; font-weight: 700; }
.table-wrap { overflow-x: auto; }

@media print {
  @page { margin: 14mm; }
  body { background: #fff; color: #000; font-size: 11pt; }
  .nav, .no-print, #toast, .topbar { display: none !important; }
  .page { padding: 0; max-width: none; }
  .report { border: 0; padding: 0; }
  .report th, .report td { border-color: #ccc; }
  .report tr { break-inside: avoid; }
}

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