/* ---------------------------------------------------------------------------
   pinbonnetje design system

   Chart colours come from a validated categorical palette (lightness band,
   chroma floor, CVD separation, normal-vision floor, contrast). Light-mode
   aqua and yellow sit below 3:1 on the panel surface, so every chart using
   them ships direct labels — that is the relief rule, not an oversight.
--------------------------------------------------------------------------- */

:root {
  color-scheme: light;

  --app-bg: #f4f6f4;
  --surface: #ffffff;
  --surface-2: #f8faf8;
  --surface-3: #eef1ee;
  --border: #e2e7e2;
  --border-strong: #cfd6cf;

  --text: #14181a;
  --text-secondary: #55605a;
  --text-muted: #828d87;

  --accent: #1f6f4a;
  --accent-hover: #195c3d;
  --accent-soft: #e8f3ed;
  --accent-ink: #14543a;

  --series-1: #2a78d6;
  --series-2: #eb6834;
  --series-3: #1baf7a;
  --series-4: #eda100;

  --good: #0ca30c;
  --warning: #fab219;
  --critical: #d03b3b;

  --grid: #eceeec;

  --radius: 14px;
  --radius-sm: 9px;
  --shadow-sm: 0 1px 2px rgba(16, 24, 20, .05);
  --shadow: 0 1px 3px rgba(16, 24, 20, .07), 0 10px 28px -12px rgba(16, 24, 20, .18);
  --sidebar-w: 236px;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --app-bg: #111211;
    --surface: #1a1a19;
    --surface-2: #202120;
    --surface-3: #282а27;
    --surface-3: #282927;
    --border: #2e302e;
    --border-strong: #3d403d;
    --text: #f0efec;
    --text-secondary: #b6bdb8;
    --text-muted: #868d88;
    --accent: #3fa578;
    --accent-hover: #4cb886;
    --accent-soft: #15291f;
    --accent-ink: #8fd9b6;
    --series-1: #3987e5;
    --series-2: #d95926;
    --series-3: #199e70;
    --series-4: #c98500;
    --grid: #272927;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .4);
    --shadow: 0 1px 3px rgba(0, 0, 0, .5), 0 10px 28px -12px rgba(0, 0, 0, .7);
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --app-bg: #111211;
  --surface: #1a1a19;
  --surface-2: #202120;
  --surface-3: #282927;
  --border: #2e302e;
  --border-strong: #3d403d;
  --text: #f0efec;
  --text-secondary: #b6bdb8;
  --text-muted: #868d88;
  --accent: #3fa578;
  --accent-hover: #4cb886;
  --accent-soft: #15291f;
  --accent-ink: #8fd9b6;
  --series-1: #3987e5;
  --series-2: #d95926;
  --series-3: #199e70;
  --series-4: #c98500;
  --grid: #272927;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .4);
  --shadow: 0 1px 3px rgba(0, 0, 0, .5), 0 10px 28px -12px rgba(0, 0, 0, .7);
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--app-bg);
  color: var(--text);
  font: 14px/1.55 ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { margin: 0; font-weight: 600; letter-spacing: -.01em; }
a { color: inherit; }

/* --- layout --------------------------------------------------------------- */
.layout { display: grid; grid-template-columns: var(--sidebar-w) 1fr; min-height: 100vh; }

.sidebar {
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 18px 12px;
  position: sticky;
  top: 0;
  height: 100vh;
}

.brand { display: flex; align-items: center; gap: 11px; padding: 4px 8px 18px; }
.brand-mark {
  width: 34px; height: 34px; border-radius: 10px;
  background: linear-gradient(145deg, var(--accent), #2f9c6a);
  color: #fff; display: grid; place-items: center;
  font-weight: 700; font-size: 17px; flex-shrink: 0;
}
.brand-name { font-size: 15px; font-weight: 650; letter-spacing: -.02em; }
.brand-sub { font-size: 11px; color: var(--text-muted); }

.nav-label {
  font-size: 10.5px; text-transform: uppercase; letter-spacing: .07em;
  color: var(--text-muted); font-weight: 600;
  padding: 14px 10px 6px;
}

.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; border-radius: var(--radius-sm);
  color: var(--text-secondary); font-size: 13.5px; font-weight: 500;
  text-decoration: none; border: 0; background: none; width: 100%;
  cursor: pointer; text-align: left; font-family: inherit;
  transition: background .12s ease, color .12s ease;
}
.nav-item:hover { background: var(--surface-3); color: var(--text); }
.nav-item[aria-current="page"] { background: var(--accent-soft); color: var(--accent-ink); font-weight: 600; }
.nav-item svg { width: 17px; height: 17px; flex-shrink: 0; }
.nav-item .badge {
  margin-left: auto; font-size: 10.5px; font-weight: 600;
  background: var(--surface-3); color: var(--text-secondary);
  padding: 1px 7px; border-radius: 999px;
}

.sidebar-foot { margin-top: auto; display: grid; gap: 8px; padding-top: 14px; }

.content { min-width: 0; display: flex; flex-direction: column; }

.topbar {
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  padding: 14px 26px;
  background: color-mix(in srgb, var(--surface) 86%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 20;
}
.topbar h1 { font-size: 17px; }
.topbar .spacer { margin-left: auto; }

/* minmax(0,1fr): grid items default to min-width:auto, which would let a wide
   table or a nested auto-fit grid push the whole page sideways on a phone. */
.view { padding: 22px 26px 70px; display: grid; grid-template-columns: minmax(0, 1fr); gap: 18px; align-content: start; }
.view > *, .grid > *, .panel, .kpi { min-width: 0; }

/* --- panels --------------------------------------------------------------- */
.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}
.panel-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; flex-wrap: wrap;
  padding: 15px 18px; border-bottom: 1px solid var(--border);
}
.panel-head h2 { font-size: 14px; }
.panel-head .hint { font-size: 12px; color: var(--text-muted); font-weight: 400; }
.panel-body { padding: 18px; }
.panel-body.flush { padding: 0; }

.grid { display: grid; gap: 18px; min-width: 0; }
.grid.cols-2 { grid-template-columns: repeat(auto-fit, minmax(330px, 1fr)); }
.grid.cols-3 { grid-template-columns: repeat(auto-fit, minmax(270px, 1fr)); }

/* --- controls ------------------------------------------------------------- */
.segmented {
  display: inline-flex; gap: 2px; padding: 3px;
  background: var(--surface-3); border-radius: 999px;
}
.segmented button {
  border: 0; background: none; cursor: pointer; font: inherit;
  font-size: 12.5px; font-weight: 550; color: var(--text-secondary);
  padding: 5px 13px; border-radius: 999px;
  transition: background .12s ease, color .12s ease;
}
.segmented button:hover { color: var(--text); }
.segmented button[aria-pressed="true"] {
  background: var(--surface); color: var(--text);
  box-shadow: var(--shadow-sm);
}

.btn {
  display: inline-flex; align-items: center; gap: 7px;
  border: 1px solid var(--border-strong); background: var(--surface);
  color: var(--text); font: inherit; font-size: 13px; font-weight: 550;
  padding: 8px 14px; border-radius: var(--radius-sm); cursor: pointer;
  transition: background .12s ease, border-color .12s ease, transform .06s ease;
}
.btn:hover { background: var(--surface-2); border-color: var(--text-muted); }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn.ghost { border-color: transparent; background: none; }
.btn.ghost:hover { background: var(--surface-3); }
.btn.danger { color: var(--critical); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn svg { width: 15px; height: 15px; }

label.field { display: grid; gap: 5px; font-size: 11.5px; color: var(--text-muted); font-weight: 550; }
input, select, textarea {
  font: inherit; font-size: 13px; color: var(--text);
  background: var(--surface); border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm); padding: 8px 10px;
}
input:focus-visible, select:focus-visible, textarea:focus-visible, .btn:focus-visible, .nav-item:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 1px;
}
input[type="date"] { min-width: 140px; }

.status-chip {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 6px 12px; border-radius: 999px;
  border: 1px solid var(--border); background: var(--surface-2);
  font-size: 12.5px; color: var(--text-secondary);
}
.status-chip .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--warning); flex-shrink: 0; }
.status-chip.live .dot { background: var(--good); }
.status-chip.error .dot { background: var(--critical); }

.pill {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 2px 9px; border-radius: 999px;
  font-size: 11px; font-weight: 600;
  background: var(--surface-3); color: var(--text-secondary);
}
.pill.betaald, .pill.ok { background: var(--accent-soft); color: var(--accent-ink); }
.pill.open { background: #fdf2e3; color: #92540f; }
.pill.late { background: #fbe9e9; color: #8f2626; }
:root[data-theme="dark"] .pill.open { background: #30230f; color: #e8b273; }
:root[data-theme="dark"] .pill.late { background: #331a1a; color: #e89393; }

/* --- KPI tiles ------------------------------------------------------------ */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(168px, 1fr)); gap: 14px; }
.kpi {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 15px 17px; box-shadow: var(--shadow-sm);
}
.kpi .label {
  font-size: 11px; text-transform: uppercase; letter-spacing: .05em;
  color: var(--text-muted); font-weight: 650;
}
.kpi .value {
  font-size: 23px; font-weight: 660; letter-spacing: -.025em;
  margin-top: 7px; font-variant-numeric: tabular-nums;
}
.kpi .sub { font-size: 12px; color: var(--text-muted); margin-top: 3px; }
.kpi.positive .value { color: var(--accent); }
.kpi.negative .value { color: var(--critical); }

/* --- charts --------------------------------------------------------------- */
.chart { position: relative; }
.chart svg { width: 100%; height: auto; display: block; overflow: visible; }
.grid-line { stroke: var(--grid); stroke-width: 1; }
.axis-label { fill: var(--text-muted); font-size: 10.5px; }
.series-1-fill { fill: var(--series-1); }
.series-2-fill { fill: var(--series-2); }
.series-1-stroke { fill: none; stroke: var(--series-1); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.series-2-stroke { fill: none; stroke: var(--series-2); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.crosshair { stroke: var(--border-strong); stroke-width: 1; stroke-dasharray: 3 3; }
.hit { fill: transparent; cursor: crosshair; }

.legend { display: flex; flex-wrap: wrap; gap: 14px; font-size: 12px; color: var(--text-secondary); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.swatch { width: 10px; height: 10px; border-radius: 3px; display: inline-block; flex-shrink: 0; }

.tooltip {
  position: absolute; pointer-events: none; z-index: 5;
  background: var(--surface); border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm); box-shadow: var(--shadow);
  padding: 9px 11px; font-size: 12px; min-width: 150px;
  opacity: 0; transition: opacity .1s ease;
}
.tooltip.visible { opacity: 1; }
.tooltip .tt-title { font-weight: 650; margin-bottom: 5px; }
.tooltip .tt-row { display: flex; align-items: center; gap: 7px; justify-content: space-between; }
.tooltip .tt-row span:last-child { font-variant-numeric: tabular-nums; font-weight: 550; }

/* Segmented share bar — direct labels satisfy the contrast relief rule. */
.share-bar { display: flex; width: 100%; height: 28px; border-radius: 7px; overflow: hidden; gap: 2px; }
.share-bar div { min-width: 3px; transition: opacity .12s ease; }
.share-bar div:hover { opacity: .82; }
.share-list { display: grid; gap: 9px; margin-top: 15px; }
.share-row { display: grid; grid-template-columns: auto 1fr auto auto; gap: 10px; align-items: center; font-size: 13px; }
.share-row .share-name { color: var(--text); }
.share-row .share-amount { font-variant-numeric: tabular-nums; color: var(--text-secondary); }
.share-row .share-pct { font-variant-numeric: tabular-nums; color: var(--text-muted); font-size: 12px; min-width: 42px; text-align: right; }

.bars { display: grid; gap: 11px; }
.bar-row { display: grid; grid-template-columns: 1fr auto; gap: 4px 10px; font-size: 13px; }
.bar-row .name { color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-row .amount { color: var(--text-secondary); font-variant-numeric: tabular-nums; }
.bar-row .track { grid-column: 1 / -1; display: block; height: 7px; border-radius: 4px; background: var(--surface-3); overflow: hidden; }
.bar-row .fill { display: block; height: 100%; border-radius: 4px; background: var(--accent); }

/* --- tables --------------------------------------------------------------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th {
  text-align: left; font-size: 10.5px; font-weight: 650;
  text-transform: uppercase; letter-spacing: .05em; color: var(--text-muted);
  padding: 11px 14px; border-bottom: 1px solid var(--border);
  background: var(--surface-2); position: sticky; top: 0;
  white-space: nowrap;
}
td { padding: 11px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: var(--surface-2); }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.strong { font-weight: 600; }
.empty { text-align: center; color: var(--text-muted); padding: 44px 20px; }

/* --- misc ----------------------------------------------------------------- */
.notice {
  display: flex; gap: 12px; align-items: flex-start;
  padding: 13px 16px; border-radius: var(--radius);
  border: 1px solid #f0dcb8; background: #fdf8ef; color: #7a5a22;
  font-size: 13px;
}
.notice.info { border-color: var(--border); background: var(--surface-2); color: var(--text-secondary); }
:root[data-theme="dark"] .notice { border-color: #4a3c20; background: #241d10; color: #e0c18a; }
.notice svg { width: 17px; height: 17px; flex-shrink: 0; margin-top: 1px; }
.link-button {
  border: 0; background: none; padding: 0; font: inherit; font-weight: 600;
  color: var(--accent); text-decoration: underline; cursor: pointer;
}

.skeleton {
  background: linear-gradient(90deg, var(--surface-3) 25%, var(--surface-2) 37%, var(--surface-3) 63%);
  background-size: 400% 100%; animation: shimmer 1.3s ease-in-out infinite;
  border-radius: var(--radius-sm);
}
@keyframes shimmer { from { background-position: 100% 0; } to { background-position: -100% 0; } }

.toasts { position: fixed; right: 20px; bottom: 20px; display: grid; gap: 9px; z-index: 100; }
.toast {
  background: var(--surface); border: 1px solid var(--border-strong);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius-sm); box-shadow: var(--shadow);
  padding: 11px 15px; font-size: 13px; min-width: 230px;
  animation: slide-in .18s ease;
}
.toast.error { border-left-color: var(--critical); }
@keyframes slide-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 13px; }
.form-actions { grid-column: 1 / -1; display: flex; justify-content: flex-end; gap: 10px; align-items: center; }
.form-error { color: var(--critical); font-size: 12.5px; margin-right: auto; }

.entry {
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  margin-bottom: 11px; overflow: hidden;
}
.entry-head {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 11px 14px; background: var(--surface-2); font-size: 13px;
}
.entry-head .strong { margin-right: auto; }
.entry table { font-size: 12.5px; }
.entry td, .entry th { padding: 7px 14px; }

.muted { color: var(--text-muted); }
.small { font-size: 12px; }
.stack { display: grid; gap: 13px; }
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

.sidebar-toggle { display: none; }

@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed; inset: 0 auto 0 0; width: var(--sidebar-w); z-index: 50;
    transform: translateX(-100%); transition: transform .2s ease;
  }
  .sidebar.open { transform: none; box-shadow: var(--shadow); }
  .sidebar-toggle { display: inline-flex; }
  .view { padding: 16px; }
  .topbar { padding: 12px 16px; }
}
