/* ============================================================
   Bank-app polish. Loaded last (base.html), on every page.
   The look of ING / bunq / Monzo / Apple Card: flat inset cards on a
   plain ground, one accent, quiet chrome, big numbers, tabular figures,
   cents smaller and lighter, real dark mode. Mostly re-tokens what the
   earlier sheets build, plus a few page-level overrides.
   ============================================================ */

:root {
  --ground: #f2f2f7;
  --ground-2: #e7e7ec;
  --card: #ffffff;
  --card-2: #f4f4f7;           /* something inside a card */
  --pane: var(--card);
  --pane-strong: var(--card-2);
  --pane-solid: var(--card);
  --cell: var(--card);
  --sheet-bg: #f2f2f7;
  --rim: transparent;
  --hairline: rgba(60, 60, 67, .12);
  --hairline-2: rgba(60, 60, 67, .2);
  --gloss: 0 0 0 0 transparent;
  --shadow-1: 0 0 0 0 transparent;
  --shadow-2: 0 1px 2px rgba(0, 0, 0, .03);
  --ink: #111113;
  --ink-2: #5d5d63;
  --ink-3: #8a8a8f;
  --fill: rgba(118, 118, 128, .12);
  --fill-2: rgba(118, 118, 128, .2);
  --seg-on: #ffffff;
  --r: 16px; --r-cell: 14px;
  --press: rgba(118, 118, 128, .14);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --ground: #000000; --ground-2: #2c2c2e;
    --card: #1c1c1e; --card-2: #2c2c2e;
    --sheet-bg: #1c1c1e; --cell: #1c1c1e;
    --hairline: rgba(84, 84, 88, .45); --hairline-2: rgba(84, 84, 88, .65);
    --shadow-2: 0 0 0 0 transparent;
    --ink: #f5f5f7; --ink-2: #a1a1a6; --ink-3: #7c7c82;
    --fill: rgba(118, 118, 128, .24); --fill-2: rgba(118, 118, 128, .36);
    --seg-on: #636366;
    --press: rgba(255, 255, 255, .07);
  }
}
:root[data-theme="dark"] {
  --ground: #000000; --ground-2: #2c2c2e;
  --card: #1c1c1e; --card-2: #2c2c2e;
  --sheet-bg: #1c1c1e; --cell: #1c1c1e;
  --hairline: rgba(84, 84, 88, .45); --hairline-2: rgba(84, 84, 88, .65);
  --shadow-2: 0 0 0 0 transparent;
  --ink: #f5f5f7; --ink-2: #a1a1a6; --ink-3: #7c7c82;
  --fill: rgba(118, 118, 128, .24); --fill-2: rgba(118, 118, 128, .36);
  --seg-on: #636366;
  --press: rgba(255, 255, 255, .07);
}

/* ---------- ground & type ---------- */
body { background: var(--ground); background-image: none; }
.num, .amt, .amt-v, .k-value, .fr-big, b.num, .cell-val, .tx-sum b, .legend-list li span:last-child { font-variant-numeric: tabular-nums; }
.amt-c { font-size: .76em; opacity: .62; letter-spacing: 0; }
.pos .amt-c, .amt.pos .amt-c { opacity: .8; }
h1, h2, h3 { letter-spacing: -.015em; }

/* ---------- flat cards ---------- */
.pane {
  background: var(--card); border-radius: var(--r); box-shadow: var(--shadow-2);
  backdrop-filter: none; -webkit-backdrop-filter: none;
}
.insight, .budget, .rule { background: var(--card-2); box-shadow: none; }
.glist { box-shadow: none; }

/* ---------- controls ---------- */
.btn { box-shadow: none; font-weight: 600; }
.btn.ghost { background: var(--fill); color: var(--ink); box-shadow: none; }
.btn.danger { background: var(--danger); }
.seg { background: var(--fill); }
.seg button.on { background: var(--seg-on); color: var(--ink); box-shadow: 0 1px 3px rgba(0, 0, 0, .12); }
.chip { background: var(--fill); }
input, select, textarea { background: var(--card); border-color: var(--hairline-2); }

/* Pressed feedback: cards dip, rows tint. */
.dash-kpi.clickable, .insight[role="button"], .insight[data-cat], .insight[data-tx], .insight[data-go],
.dash-avg-link, .dash-allowance, .budget, .dash-budget, .sb-row, .cv-card h3 {
  transition: transform .14s cubic-bezier(.2, .8, .2, 1), opacity .14s;
}
.dash-kpi.clickable:active, .insight[role="button"]:active, .insight[data-go]:active,
.dash-avg-link:active, .dash-allowance:active, .budget:active, .dash-budget:active { transform: scale(.98); opacity: .9; }
.m-row:active, .sub-row:active, .legend-list li:active, .dd-row:active { background: var(--press); }

/* Merchant marks: round, like a bank app's logo column. */
.m-logo { border-radius: 50%; font-weight: 700; letter-spacing: -.02em; }

/* ---------- desktop rail ---------- */
.rail { border-right: .5px solid var(--hairline-2); background: var(--ground); }
.rail a.nav.on { background: var(--card); box-shadow: none; }
@media (hover: hover) { .rail a.nav:hover { background: var(--fill); } }

/* ---------- page headers ---------- */
.page-head h1 { font-weight: 750; letter-spacing: -.025em; }
.pg-sub { color: var(--ink-2); }

/* ---------- period strip (timeline.js): a calm card, not a toolbar ---------- */
.timeline.tl2 { background: var(--card); box-shadow: none; backdrop-filter: none; -webkit-backdrop-filter: none; }

/* ---------- dashboard: free to spend & balances (equal cards, no hero) ---------- */
.fr-big { font-size: 30px; font-weight: 720; letter-spacing: -.025em; }
.fr-sub { color: var(--ink-3); }
.fr-det { margin-top: 10px; border-top: .5px solid var(--hairline-2); }
.fr-det > summary {
  display: flex; align-items: center; justify-content: space-between; gap: 10px; min-height: 44px; padding: 0;
  list-style: none; color: var(--ink); font-size: 15px; font-weight: 500;
}
.fr-det > summary::-webkit-details-marker { display: none; }
.fr-det > summary::after {
  content: ""; flex: none; width: 7px; height: 7px; border-right: 2px solid var(--ink-3); border-bottom: 2px solid var(--ink-3);
  transform: rotate(-45deg); transition: transform .2s; margin-right: 4px;
}
.fr-det[open] > summary::after { transform: rotate(45deg); }
.fr-list .dash-sub { border-top: .5px solid var(--hairline-2); border-radius: 0; }

.bl-sum { display: flex; align-items: baseline; gap: 4px 10px; flex-wrap: wrap; margin: -2px 0 8px; }
.bl-sum > .meta:first-child { flex-basis: 100%; font-size: 13px; }
.bl-total { font-size: 30px; font-weight: 720; letter-spacing: -.025em; line-height: 1.15; }
.bl-total.neg, .bl-row b.neg { color: var(--neg); }
.bl-note:empty { display: none; }
.bl-change { font-size: 13px; font-weight: 600; color: var(--ink-3); }
.bl-change.good { color: var(--pos); }
.bl-change:empty { display: none; }
.bl-list { display: grid; }
.bl-row { color: var(--ink); text-decoration: none !important; border-top: .5px solid var(--hairline-2); border-radius: 0; }
.bl-row b.num { font-size: 16px; font-weight: 650; }

/* KPI tiles: label, number, one quiet line. No "no history" noise. */
.k-delta.none { display: none; }
.dash-kpi .k-label { color: var(--ink-2); font-weight: 500; }
.dash-kpi .k-value { font-weight: 720; }
.dash-kpi .k-sub { color: var(--ink-3); }
.dash-kpi .k-delta.bad { color: var(--ink-2); }   /* more spending than last time isn't an alarm */

/* Section titles in dashboard cards: one size, quiet links. */
.dash-grid .pane-head h2 { font-size: 18px; font-weight: 700; }

/* Bars grow from their baseline. */
.m-bar { transform-origin: left; animation: grow .6s cubic-bezier(.2, .8, .2, 1) both; }
@keyframes grow { from { transform: scaleX(0); } }

/* ---------- tab bar (phone) ---------- */
@media (max-width: 900px) {
  body::before { background: var(--ground); }
  .tabbar {
    background: color-mix(in srgb, var(--ground) 82%, transparent);
    backdrop-filter: saturate(180%) blur(20px); -webkit-backdrop-filter: saturate(180%) blur(20px);
    border-top: .5px solid var(--hairline-2);
  }
  .tabbar a { font-size: 10.5px; font-weight: 500; color: var(--ink-3); letter-spacing: 0; }
  .tabbar a svg { width: 26px; height: 26px; }
  .tabbar a.on { color: var(--accent); }
  .tabbar a.on span { font-weight: 600; }

  /* Large title, iOS style. */
  .page-head h1 { font-size: 34px; line-height: 1.1; }
  .page-head .pg-sub { font-size: 15px; color: var(--ink-3); }

  .pane { border-radius: var(--r); }
  .dash-grid { gap: 10px; }
  .dash-grid > .pane { padding: 16px; }

  /* Dashboard header: greeting above the title, data date quiet, import a round button. */
  .dash-head { grid-template-areas: "greet imp" "title imp" "date imp" "acct acct"; margin: 6px 0 14px; }
  .dash-head h1 { font-size: 34px; }
  .dash-greet { font-size: 15px; color: var(--ink-3); margin: 0 0 1px; font-weight: 500; }
  .dash-date { color: var(--ink-3); }
  .dash-import { background: var(--fill); }

  .dash-grid > .dash-kpi, .dash-grid > .dash-kpi.k6 { min-height: 118px; padding: 14px 14px 36px; }
  .dash-kpi .k-label { font-size: 13px; }
  .dash-kpi .k-label .k-dot { display: none; }
  .fr-big, .bl-total { font-size: 28px; }

  /* The averages link is a plain row at the end. */
  .dash-grid > .dash-avg-link { order: 20; }
  .dash-grid > .dash-sankey { order: 21; }

  .dash-grid .pane-head h2 { font-size: 19px; }
  .dash-grid .pane-head .btn.ghost.small { font-weight: 500; font-size: 15px; }
  .m-logo { border-radius: 50%; }
}

/* ---------- transactions (phone): two quiet lines, amount right ---------- */
@media (max-width: 900px) {
  .tx-day { font-size: 13px; font-weight: 600; color: var(--ink-3); }
  .tx-day .num { color: var(--ink-3); font-weight: 500; }
  .tx-day .num.pos { color: var(--pos); }
  .tx-row .m-logo { width: 40px; height: 40px; border-radius: 50%; font-size: 13.5px; }
  .tx-row .who b { font-size: 16px; font-weight: 600; }
  .tx-row .who small { color: var(--ink-3); font-size: 13px; }
  /* Category as plain grey text with its colour dot (still tappable), then the account. */
  .tx-row .mcat { background: none; padding: 0; color: var(--ink-3); font-weight: 400; font-size: 13px; border-radius: 0; max-width: 70%; }
  .tx-row .tx-acc { font-size: 13px; }
  .tx-row .tx-acc .acc-dot { display: none; }
  .tx-row .tx-acc::before { content: "·"; margin-right: 2px; }
  /* Category and account share the line; the account gives way first and
     neither is cut at a fixed width. */
  .tx-row .who small .mcat, .tx-row .who small:has(.tx-acc) .mcat { flex: 0 1 auto; max-width: none; min-width: 0; }
  .tx-row .who small .tx-acc { flex: 0 12 auto; max-width: none; min-width: 3em; }
  .tx-row .who small .tx-acc .tx-acc-n { min-width: 0; }
  /* Raw bank text lives in the details sheet; the balance after stays under the amount. */
  .tx-row .tx-desc, .tx-row .tx-tag { display: none; }
  .tx-row .tx-bal { font-size: 12px; font-weight: 400; margin-top: 1px; }
  .tx-row .amt { font-size: 16.5px; font-weight: 600; }
  .tx-sum { background: var(--card); }
  .tx-row { background: var(--card); }
  .tx-row:hover { background: var(--card); }
  .tx-row:active, .tx-row.pressing { background: color-mix(in srgb, var(--card) 88%, var(--ink)); }
}

/* ---------- grouped lists ---------- */
.glist-title { color: var(--ink-3); font-weight: 500; }
.gcell { min-height: 50px; }
.cell-ic { border-radius: 8px; }

/* ---------- sheets ---------- */
.drawer, .modal, .pop { background: var(--sheet-bg); }
@media (max-width: 900px) {
  .drawer, .modal, .pop.sheet { border-radius: 16px 16px 0 0; }
}

/* ---------- empty states ---------- */
.empty svg { color: var(--ink-3); width: 56px; height: 56px; }

/* ---------- reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  .m-bar { animation: none; }
  .dash-kpi.clickable:active, .insight[role="button"]:active, .dash-avg-link:active, .budget:active { transform: none; }
}

/* ---------- "Waar gaat het heen": category rows with a thin proportional bar ---------- */
.dd-side .legend-list .dd-ic { display: none; }
@media (max-width: 900px) {
  /* A ring with a dozen slices says less than the list: the list is the chart here. */
  .dash-donut .dd-box { display: none; }
  .dash-donut .donut-wrap { display: block; }
  .dd-side .legend-list { gap: 0; }
  .dd-side .legend-list li {
    grid-template-columns: 36px minmax(0, 1fr) auto; grid-template-areas: "ic name amt" "ic bar pct";
    column-gap: 12px; row-gap: 5px; min-height: 56px; padding: 8px 4px; border-radius: 10px; font-size: 15px;
  }
  .dd-side .legend-list li::after {
    content: ""; grid-area: bar; align-self: center; height: 4px; border-radius: 2px; background: var(--c, var(--accent));
    width: calc(var(--w, 0) * 100%); transform-origin: left; animation: grow .6s cubic-bezier(.2, .8, .2, 1) both;
  }
  .dd-side .legend-list .sw { grid-area: ic; justify-self: center; width: 10px; height: 10px; border-radius: 50%; }
  .dd-side .legend-list li:has(.dd-ic) .sw { display: none; }
  .dd-side .legend-list .dd-ic {
    grid-area: ic; display: grid; place-items: center; width: 36px; height: 36px; border-radius: 50%; font-size: 17px;
    background: color-mix(in srgb, var(--c, var(--accent)) 22%, transparent);
  }
  .dd-side .legend-list .dd-name { grid-area: name; font-weight: 500; }
  .dd-side .legend-list .num { grid-area: amt; font-weight: 600; }
  .dd-side .legend-list .pct { grid-area: pct; width: auto; font-size: 12.5px; line-height: 1; }
}
@media (prefers-reduced-motion: reduce) { .dd-side .legend-list li::after { animation: none; } }

/* ---------- Meer ---------- */
.more-list { max-width: 640px; }
.more-list > .glist-wrap + .glist-wrap:not(:has(> .glist-title)) { margin-top: 26px; }
.more-list > .glist-wrap:first-child .st-me { min-height: 72px; }

/* ---------- transaction sheet ---------- */
.txd-logo.m-logo { border-radius: 50%; }
@media (max-width: 900px) { .tx-row .mcat::after { inset: -13px -4px; } } /* 44px tall to tap */

/* Category rows: ▲/▼ against what the category usually costs. */
.dd-vs { margin-left: 6px; font-size: 11.5px; font-weight: 600; white-space: nowrap; color: var(--ink-3); }
.dd-vs.down { color: var(--pos); }

/* ---------- Vrij te besteden + Kijk vooruit ---------- */
.fr-acc { margin: 2px 0 10px; }
.fr-acc[hidden] { display: none; }
.fr-acc button { font-size: 13px; }
.fr-more {
  display: flex; align-items: center; gap: 8px; width: 100%; min-height: 44px; margin-top: 10px; padding: 0;
  border: 0; border-top: .5px solid var(--hairline-2); background: none; color: var(--ink); font: inherit; cursor: pointer; text-align: left;
}
.fr-more-t { font-weight: 600; color: var(--accent-ink); }
.fr-more .meta { margin-left: auto; }
.fr-chev { color: var(--ink-3); font-size: 18px; }

.drawer.la-drawer { display: flex; flex-direction: column; overflow: hidden; height: 100%; padding-bottom: 0; }
.la { display: flex; flex-direction: column; flex: 1 1 auto; min-height: 0; }
.la-head { display: flex; align-items: baseline; gap: 10px; padding: 4px 48px 10px 0; }
.la-head h2 { margin: 0; font-size: 20px; }
.la-scroll { flex: 1 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; margin: 0 -4px; padding: 0 4px; }
.la-day { display: flex; align-items: center; gap: 8px; padding: 16px 4px 6px; font-size: 13px; font-weight: 600; color: var(--ink-3); }
.la-day:first-letter { text-transform: uppercase; }
.la-tag { font-size: 11px; font-weight: 700; padding: 2px 7px; border-radius: 999px; background: color-mix(in srgb, var(--pos) 20%, transparent); color: var(--pos); }
.la-row { display: flex; align-items: center; gap: 12px; min-height: 60px; padding: 8px 12px; margin-bottom: 6px; border-radius: 12px; background: color-mix(in srgb, var(--ink) 7%, var(--sheet-bg)); transition: opacity .25s, transform .25s; }
.la-row .m-logo { width: 36px; height: 36px; border-radius: 50%; flex: none; }
.la-mid { display: flex; flex-direction: column; min-width: 0; flex: 1 1 auto; }
.la-mid .m-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.la-amt { flex: none; font-size: 16px; }
.la-amt.pos { color: var(--pos); }
.la-row.booked { opacity: .42; transform: scale(.985); }
.la-empty { padding: 24px 4px; }
.la-foot {
  flex: none; display: flex; align-items: center; justify-content: space-between; gap: 12px;
  margin: 0 -16px; padding: 14px 20px calc(14px + var(--safe-bottom, 0px));
  background: var(--sheet-bg); border-top: .5px solid var(--hairline-2); box-shadow: 0 -10px 24px -12px rgba(0,0,0,.45);
}
.la-l { display: flex; flex-direction: column; gap: 2px; }
.la-lbl { font-weight: 700; color: var(--accent-ink); }
.la-when { font-size: 13px; }
.la-val { display: inline-flex; align-items: flex-end; font-size: 24px; font-weight: 720; line-height: 1; letter-spacing: -.02em; }
.la-val.neg { color: var(--warn); }
.rl { display: inline-block; height: 1em; overflow: hidden; }
.rl-strip { display: flex; flex-direction: column; transition: transform .55s cubic-bezier(.2, 1.25, .35, 1); will-change: transform; }
.rl-strip > span, .rl-c { display: block; height: 1em; line-height: 1em; }
@media (max-width: 900px) {
  .drawer.la-drawer { height: min(92vh, calc(var(--vvh, 100vh) - var(--safe-top) - 10px)); }
}
@media (prefers-reduced-motion: reduce) {
  .rl-strip, .la-row { transition: none; }
}

/* Kijk vooruit: balance curve, lowest point, "Kan ik dit betalen?" */
.la-top { padding: 0 0 8px; border-bottom: .5px solid var(--hairline); margin-bottom: 4px; }
.la-curve { width: 100%; height: 86px; display: block; }
.la-low { margin: 4px 0 6px; }
.la-what summary { cursor: pointer; font-weight: 600; color: var(--accent-ink); padding: 4px 0; list-style: none; }
.la-what summary::-webkit-details-marker { display: none; }
.la-what summary::after { content: " ›"; }
.la-what[open] summary::after { content: " ⌄"; }
.la-what-row { display: flex; gap: 8px; align-items: center; margin: 6px 0; }
.la-what-row input[type="text"], .la-what-row input[type="date"] { flex: 1; min-width: 0; }
.la-what-monthly { justify-content: space-between; }
.la-verdict { margin: 6px 0 2px; font-size: 14px; }
.la-verdict.ok b { color: var(--pos); }
.la-verdict.no b { color: var(--neg); }
