/* Mimmir Data Portal — zelfde ontwerptaal als de CRM (Saga): paarse merkkleur,
   vaste statuskleuren (blauw/amber/groen/rood), mono voor cijfers, licht+donker. */
:root {
  --brand: #5b2d90;
  --brand-bright: #7b45c0;
  --brand-deep: #17102b;
  --brand-soft: #f1ebfa;
  --ink: #1c1830;
  --ink-soft: #6b6580;
  --surface: #ffffff;
  --bg: #f7f5fb;
  --line: #e8e4f0;
  --green: #1e7a5a;
  --green-soft: #e6f4ee;
  --amber: #b06a00;
  --amber-soft: #fdf1de;
  --red: #b3261e;
  --red-soft: #fdeceb;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, monospace;
  /* Categorisch dataviz-palet — overgenomen uit de Saga-CRM, daar met de
     dataviz-skill-validator gecontroleerd voor licht én donker (CVD/contrast). */
  --viz-cat-1: #7C4DBE; --viz-cat-2: #eda100; --viz-cat-3: #2a78d6;
  --viz-cat-4: #eb6834; --viz-cat-5: #1baf7a; --viz-cat-rest: #857D99;
}
@media (prefers-color-scheme: dark) {
  :root {
    --brand-soft: #2a2140;
    --ink: #eee9f7;
    --ink-soft: #a49dbb;
    --surface: #1e1930;
    --bg: #141021;
    --line: #322a4a;
    --green-soft: #16301f;
    --amber-soft: #33260f;
    --red-soft: #3a1a1a;
    --viz-cat-1: #9085e9; --viz-cat-2: #c98500; --viz-cat-3: #3987e5;
    --viz-cat-4: #d95926; --viz-cat-5: #199e70; --viz-cat-rest: #7A7292;
  }
}

* { box-sizing: border-box; }
body {
  margin: 0; font-family: var(--sans); color: var(--ink); background: var(--bg);
  font-size: 15px; line-height: 1.5;
}
a { color: var(--brand-bright); }
h1 { font-size: 24px; margin: 0 0 6px; }
h2 { font-size: 16px; margin: 0 0 10px; }
.muted { color: var(--ink-soft); }
.num { font-family: var(--mono); }
td.num, th.num { text-align: right; }
.pagesub { margin: 0 0 10px; font-size: 13px; }
.field-hint { font-size: 12px; color: var(--ink-soft); }

/* ---- Topbar ---- */
.topbar {
  display: flex; align-items: center; gap: 24px;
  padding: 0 22px; height: 58px;
  background: linear-gradient(120deg, var(--brand-deep), #2a1a4d);
  color: #fff;
}
.brand { display: flex; align-items: center; gap: 9px; text-decoration: none; color: #fff; }
.brand-mark {
  width: 16px; height: 16px; border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #ff7a59, #c8443a);
  box-shadow: 0 0 0 4px rgba(255,255,255,.10);
}
.brand-name { font-weight: 700; letter-spacing: .01em; }
.brand-sub { font-weight: 400; opacity: .72; }
.topbar .nav { display: flex; gap: 4px; margin-left: 10px; flex: 1; }
.topbar .nav a {
  color: rgba(255,255,255,.78); text-decoration: none; font-size: 14px; font-weight: 500;
  padding: 7px 12px; border-radius: 8px;
}
.topbar .nav a:hover { background: rgba(255,255,255,.10); color: #fff; }
.topbar .nav a.active { background: rgba(255,255,255,.16); color: #fff; }
.topbar-right { display: flex; align-items: center; gap: 12px; }
.client-name { font-size: 13px; opacity: .8; }

.page { max-width: 1040px; margin: 0 auto; padding: 26px 22px 60px; }
.foot { text-align: center; color: var(--ink-soft); font-size: 12px; padding: 18px; }

/* ---- Kaarten ---- */
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: 12px;
  padding: 18px; margin-bottom: 18px;
}
.section-title { margin: 26px 0 12px; }

/* ---- Statusstrip ---- */
.status-strip {
  display: flex; align-items: center; gap: 9px; flex-wrap: wrap;
  padding: 11px 14px; border-radius: 10px; margin-bottom: 20px;
  border: 1px solid transparent; font-size: 14px;
}
.status-strip .dot { width: 9px; height: 9px; border-radius: 50%; flex: none; }
.status-strip.ok { background: var(--green-soft); border-color: color-mix(in srgb, var(--green) 25%, transparent); }
.status-strip.ok .dot { background: var(--green); }
.status-strip.warn { background: var(--amber-soft); border-color: color-mix(in srgb, var(--amber) 25%, transparent); }
.status-strip.warn .dot { background: var(--amber); }
.status-strip.danger { background: var(--red-soft); border-color: color-mix(in srgb, var(--red) 25%, transparent); }
.status-strip.danger .dot { background: var(--red); }
.status-link { margin-left: auto; font-size: 13px; white-space: nowrap; }

/* ---- Vraagbalk ---- */
.ask-bar { display: flex; gap: 10px; margin: 14px 0 4px; }
.ask-bar input {
  flex: 1; padding: 12px 14px; font-size: 15px; font-family: inherit;
  border: 1px solid var(--line); border-radius: 10px; background: var(--surface); color: var(--ink);
}
.ask-bar input:focus {
  outline: none; border-color: var(--brand-bright);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand-bright) 18%, transparent);
}

/* ---- Voorbeeldprompts (Vraag je data) ---- */
.chat-suggestions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 4px 0 18px; }
.chat-suggestions-label { font-size: 13px; color: var(--ink-soft); margin-right: 2px; }
.chat-suggestion {
  background: var(--surface); border: 1px solid var(--line); color: var(--brand-bright);
  border-radius: 999px; padding: 6px 13px; font-size: 13px; font-family: inherit; cursor: pointer;
  transition: border-color .12s ease, background .12s ease;
}
.chat-suggestion:hover { border-color: var(--brand-bright); background: var(--brand-soft); }

/* ---- Tegels ---- */
.tile-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 14px; }
.tile {
  display: flex; flex-direction: column; gap: 5px; position: relative;
  background: var(--surface); border: 1px solid var(--line); border-radius: 12px;
  padding: 16px; text-decoration: none; color: var(--ink);
  transition: transform .12s ease, border-color .12s ease;
}
a.tile:hover { transform: translateY(-2px); border-color: var(--brand-bright); }
.tile-title { font-weight: 600; }
.tile-sub { font-size: 13px; color: var(--ink-soft); }
.tile-remove { margin-top: 8px; }

/* ---- Staafgrafiek (server-side, geen library) ---- */
.bars { display: flex; flex-direction: column; gap: 8px; }
.bar-row { display: grid; grid-template-columns: 150px 1fr 110px; align-items: center; gap: 12px; }
.bar-label { font-size: 13px; color: var(--ink-soft); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-track { background: var(--brand-soft); border-radius: 6px; height: 20px; overflow: hidden; }
.bar-fill { display: block; height: 100%; border-radius: 6px; background: linear-gradient(90deg, var(--brand-bright), var(--brand)); }
.bar-value { font-size: 13px; text-align: right; }

/* ---- Tabellen ---- */
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--line); font-size: 13.5px; }
th { color: var(--ink-soft); font-weight: 600; font-size: 11px; text-transform: uppercase; letter-spacing: .07em; }

/* ---- Badges ---- */
.badge {
  display: inline-block; padding: 2px 9px; border-radius: 999px;
  font-size: 11.5px; font-weight: 600; background: var(--brand-soft); color: var(--brand-bright);
}
.badge.ok { background: var(--green-soft); color: var(--green); }
.badge.danger { background: var(--red-soft); color: var(--red); }
.badge.warn { background: var(--amber-soft); color: var(--amber); }

/* ---- Stappenlijst ---- */
.steps { list-style: none; padding: 0; margin: 0; }
.steps li { padding: 7px 0 7px 24px; position: relative; font-size: 14px; border-bottom: 1px solid var(--line); }
.steps li:last-child { border-bottom: none; }
.steps li::before { position: absolute; left: 0; top: 7px; font-weight: 700; }
.steps li.ok::before { content: "✓"; color: var(--green); }
.steps li.danger::before { content: "✕"; color: var(--red); }

/* ---- Knoppen ---- */
.btn {
  display: inline-block; background: linear-gradient(140deg, var(--brand-bright), var(--brand) 60%);
  color: #fff; padding: 10px 18px; border-radius: 9px; border: none; text-decoration: none;
  cursor: pointer; font-size: 14px; font-weight: 600; font-family: var(--sans);
}
.btn:hover { filter: brightness(1.06); }
.btn:disabled { opacity: .6; cursor: default; filter: none; }
.btn.small { padding: 5px 11px; font-size: 12px; border-radius: 7px; }
.btn.secondary { background: transparent; color: var(--brand-bright); border: 1px solid var(--line); }
.btn.ghost { background: transparent; color: var(--ink-soft); border: 1px solid var(--line); }
.btn.btn-block { display: block; width: 100%; margin-top: 8px; }
.topbar .btn.secondary { color: #fff; border-color: rgba(255,255,255,.35); }
.form-actions { margin-top: 14px; }

/* ---- Formulier ---- */
label { display: block; font-size: 13px; font-weight: 600; margin: 10px 0 4px; }
input[type="text"], input[type="email"], input[type="password"] {
  width: 100%; padding: 9px 11px; border: 1px solid var(--line); border-radius: 9px;
  font-size: 14px; font-family: inherit; background: var(--surface); color: var(--ink);
}
input:focus { outline: none; border-color: var(--brand-bright); box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand-bright) 18%, transparent); }

/* ---- Flash ---- */
.flash { padding: 11px 14px; border-radius: 10px; margin-bottom: 16px; font-size: 14px; border: 1px solid transparent; }
.flash.error { background: var(--red-soft); color: var(--red); border-color: color-mix(in srgb, var(--red) 25%, transparent); }
.flash.success { background: var(--green-soft); color: var(--green); border-color: color-mix(in srgb, var(--green) 25%, transparent); }

/* ---- Ingesloten kwaliteitsrapport ---- */
.report-frame { width: 100%; height: 620px; border: 1px solid var(--line); border-radius: 8px; background: #fff; }

/* ---- Login ---- */
.login-page {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: radial-gradient(1000px 600px at 20% 10%, #3b2566, transparent),
              radial-gradient(800px 500px at 85% 80%, #6d3ba6, transparent), var(--brand-deep);
  color: #fff;
}
.login-shell { width: 100%; max-width: 380px; padding: 20px; }
.login-brand { display: flex; align-items: center; gap: 9px; justify-content: center; margin-bottom: 18px; font-size: 18px; }
.login-card { background: var(--surface); color: var(--ink); border-radius: 14px; padding: 24px; }
.login-card h1 { font-size: 20px; }

/* ---- Filter-pane (dashboards) ---- */
.filter-pane {
  display: flex; flex-wrap: wrap; gap: 14px; align-items: flex-end;
  background: var(--surface); border: 1px solid var(--line); border-radius: 12px;
  padding: 12px 16px; margin-bottom: 18px;
}
.filter-field { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--ink-soft); font-weight: 600; }
.filter-field select {
  padding: 8px 11px; border: 1px solid var(--line); border-radius: 9px; font-size: 14px;
  font-family: inherit; background: var(--surface); color: var(--ink); min-width: 160px;
}
.filter-field select:focus { outline: none; border-color: var(--brand-bright); box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand-bright) 18%, transparent); }

/* ---- KPI-tegels ---- */
.kpi-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; margin-bottom: 18px; }
.kpi {
  background: var(--surface); border: 1px solid var(--line); border-radius: 12px;
  padding: 14px 16px; display: flex; flex-direction: column; gap: 3px;
  border-top: 3px solid var(--brand);
}
.kpi-ok { border-top-color: var(--green); }
.kpi-warn { border-top-color: var(--amber); }
.kpi-danger { border-top-color: var(--red); }
.kpi-muted { border-top-color: var(--line); }
.kpi-label { font-size: 12px; color: var(--ink-soft); font-weight: 600; }
.kpi-value { font-size: 22px; font-weight: 700; }
.kpi-sub { font-size: 12px; color: var(--ink-soft); }

/* ---- Winst- en verliesrekening ---- */
.pl-table { width: 100%; border-collapse: collapse; }
.pl-table td { padding: 7px 10px; border-bottom: 1px solid var(--line); font-size: 14px; }
.pl-table td.num { text-align: right; font-family: var(--mono); }
.pl-table td.neg { color: var(--red); }
.pl-line td { color: var(--ink); }
.pl-subtotal td { font-weight: 600; background: color-mix(in srgb, var(--brand-soft) 40%, transparent); }
.pl-result td { font-weight: 700; border-top: 2px solid var(--brand); border-bottom: 2px solid var(--brand); }
.pl-result td.num:not(.neg) { color: var(--green); }

/* ---- Legenda (gedeeld) ---- */
.chart-legend { display: flex; flex-wrap: wrap; gap: 14px; margin-bottom: 12px; font-size: 13px; color: var(--ink-soft); }
.chart-legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend-swatch { width: 11px; height: 11px; border-radius: 3px; flex: none; }

/* ---- Gegroepeerde kolomgrafiek ---- */
.grouped-chart { display: flex; gap: 14px; align-items: flex-end; height: 200px; padding-top: 6px; overflow-x: auto; }
.grouped-col { display: flex; flex-direction: column; align-items: center; gap: 6px; flex: 1; min-width: 64px; height: 100%; }
.grouped-bars { display: flex; align-items: flex-end; gap: 4px; height: 100%; width: 100%; justify-content: center; }
.grouped-bar { width: 22px; border-radius: 4px 4px 0 0; min-height: 2px; align-self: flex-end; }
.grouped-label { font-size: 11px; color: var(--ink-soft); text-align: center; max-width: 84px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---- Donut ---- */
.donut-wrap { display: flex; gap: 24px; align-items: center; flex-wrap: wrap; }
.donut { width: 150px; height: 150px; border-radius: 50%; flex: none; position: relative; }
.donut-hole {
  position: absolute; inset: 26px; background: var(--surface); border-radius: 50%;
  display: flex; align-items: center; justify-content: center; font-size: 14px; font-weight: 700; text-align: center;
}
.donut-legend { flex: 1; min-width: 220px; display: flex; flex-direction: column; gap: 6px; }
.donut-legend-row { display: grid; grid-template-columns: 16px 1fr auto auto; align-items: center; gap: 8px; font-size: 13px; }
.donut-legend-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.donut-legend-row .num { font-size: 13px; }

/* ---- Badge-varianten voor tabellen ---- */
.badge.warn { background: var(--amber-soft); color: var(--amber); }

@media (max-width: 720px) {
  .topbar { flex-wrap: wrap; height: auto; padding: 10px 14px; gap: 10px; }
  .topbar .nav { order: 3; width: 100%; overflow-x: auto; }
  .bar-row { grid-template-columns: 100px 1fr 90px; gap: 8px; }
  .donut-wrap { justify-content: center; }
}
