/* Koers: zeekaart-look. Koersbalk bovenaan is de held; de rest is rustig en scanbaar.
   Bewust geen Google Fonts of andere externe bronnen (AVG): alles draait op je eigen server. */
:root {
  --bg: #f2f5f4;          /* zeekaartpapier */
  --surface: #ffffff;
  --surface-2: #e8eeec;
  --line: #d5dedb;
  --ink: #0f2230;         /* diepzee-inkt */
  --ink-2: #4a5d68;
  --ink-3: #7b8b93;
  --accent: #0f4c6e;      /* knoppen, focus */
  --accent-ink: #ffffff;
  --flamingo: #e2477c;    /* merkaccent, spaarzaam */
  --s-real: #2a78d6;      /* gerealiseerd */
  --s-certain: #86b6ef;   /* zeker verwacht */
  --s-pipe: #eb6834;      /* gewogen pipeline */
  --s-gap: #c9d2cf;       /* ontbreekt */
  --s-prev: #7b8b93;
  --good: #1f7a4d; --good-bg: #e2f3ea;
  --warn: #9a6200; --warn-bg: #fbf0d9;
  --bad: #b3261e;  --bad-bg: #fbe4e2;
  --radius: 10px;
  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", "Roboto Mono", Menlo, Consolas, monospace;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0c1820; --surface: #122330; --surface-2: #183040; --line: #25404f;
    --ink: #e8f0f2; --ink-2: #a9bcc4; --ink-3: #7d939c;
    --accent: #7cc0e6; --accent-ink: #06202e; --flamingo: #f27aa3;
    --s-real: #3987e5; --s-certain: #6da7ec; --s-pipe: #d95926; --s-gap: #2f4654; --s-prev: #a9bcc4;
    --good: #5fd39a; --good-bg: #133526; --warn: #f0b64b; --warn-bg: #3a2c0c; --bad: #ff8a80; --bad-bg: #3d1614;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0c1820; --surface: #122330; --surface-2: #183040; --line: #25404f;
  --ink: #e8f0f2; --ink-2: #a9bcc4; --ink-3: #7d939c;
  --accent: #7cc0e6; --accent-ink: #06202e; --flamingo: #f27aa3;
  --s-real: #3987e5; --s-certain: #6da7ec; --s-pipe: #d95926; --s-gap: #2f4654; --s-prev: #a9bcc4;
  --good: #5fd39a; --good-bg: #133526; --warn: #f0b64b; --warn-bg: #3a2c0c; --bad: #ff8a80; --bad-bg: #3d1614;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 15px/1.5 var(--font); }
.num, td.n, .kpi b, .money { font-variant-numeric: tabular-nums; }
h1, h2, h3 { margin: 0; line-height: 1.2; text-wrap: balance; }
h2 { font-size: 13px; text-transform: uppercase; letter-spacing: .08em; color: var(--ink-2); font-weight: 650; }
h3 { font-size: 16px; font-weight: 650; }
a { color: var(--accent); }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
.muted { color: var(--ink-3); }
.small { font-size: 13px; }

/* ---------- Kop ---------- */
.top {
  position: sticky; top: env(safe-area-inset-top, 0px); z-index: 20;
  background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.top-in { max-width: 1240px; margin: 0 auto; padding: 10px 16px; display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 10px; margin-right: auto; }
.brand svg { flex: none; }
.brand b { font-size: 19px; letter-spacing: -.01em; }
.brand span { color: var(--ink-3); font-size: 13px; }
.btn {
  border: 1px solid var(--line); background: var(--surface); padding: 7px 12px; border-radius: 8px; cursor: pointer;
  display: inline-flex; align-items: center; gap: 6px; white-space: nowrap;
}
.btn:hover { border-color: var(--ink-3); }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 600; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.ghost { background: transparent; border-color: transparent; }
.btn[disabled] { opacity: .55; cursor: progress; }
select.btn { padding-right: 8px; }

main { max-width: 1240px; margin: 0 auto; padding: 20px 16px 96px; display: grid; gap: 20px; }
.banner { background: var(--warn-bg); color: var(--warn); border-radius: var(--radius); padding: 10px 14px; font-size: 14px; }

.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; min-width: 0; }
.panel-h { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.grid-2 { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); gap: 20px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 20px; }
@media (max-width: 960px) { .grid-2, .grid-3 { grid-template-columns: minmax(0, 1fr); } }

/* ---------- Held: de koersbalk ---------- */
.hero { display: grid; gap: 18px; padding: 22px; }
.hero-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 16px; }
.hero-big { font-size: clamp(30px, 5vw, 44px); font-weight: 750; letter-spacing: -.02em; line-height: 1; }
.hero-big small { font-size: .45em; font-weight: 500; color: var(--ink-2); letter-spacing: 0; }
.hero-sub { color: var(--ink-2); margin-top: 6px; }
.status { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 600; padding: 3px 10px; border-radius: 99px; }
.status.good { background: var(--good-bg); color: var(--good); }
.status.warn { background: var(--warn-bg); color: var(--warn); }
.status.bad { background: var(--bad-bg); color: var(--bad); }

.course { position: relative; padding-top: 26px; }
.course-bar { display: flex; height: 22px; border-radius: 6px; overflow: hidden; background: var(--s-gap); gap: 2px; }
.course-bar > div { height: 100%; min-width: 0; transition: width .6s ease; }
.course-bar .real { background: var(--s-real); }
.course-bar .certain { background: var(--s-certain); }
.course-bar .pipe { background: repeating-linear-gradient(135deg, var(--s-pipe) 0 5px, color-mix(in srgb, var(--s-pipe) 70%, var(--surface)) 5px 8px); }
.course-mark { position: absolute; top: 0; bottom: -6px; width: 0; border-left: 2px dashed var(--ink); }
.course-mark span { position: absolute; top: 0; transform: translateX(-50%); font-size: 12px; white-space: nowrap; color: var(--ink); font-weight: 600; background: var(--surface); padding: 0 4px; }
.course-mark.end span { transform: translateX(-100%); }
.legend { display: flex; flex-wrap: wrap; gap: 6px 18px; margin-top: 12px; font-size: 13px; color: var(--ink-2); }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }
.legend b { color: var(--ink); font-weight: 650; }

.kpis { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 1px; background: var(--line); border-radius: 8px; overflow: hidden; border: 1px solid var(--line); }
.kpi { background: var(--surface); padding: 12px 14px; }
.kpi label { display: block; font-size: 12px; color: var(--ink-3); text-transform: uppercase; letter-spacing: .06em; }
.kpi b { display: block; font-size: 21px; font-weight: 700; margin-top: 2px; }
.kpi em { font-style: normal; font-size: 12.5px; color: var(--ink-2); }
.up { color: var(--good) !important; } .down { color: var(--bad) !important; }
@media (max-width: 900px) { .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); } .kpi:last-child { grid-column: 1 / -1; } }
@media (max-width: 600px) { .fab kbd { display: none; } .fab { padding: 12px 16px; } .top-in { gap: 8px; } .top .muted.small { display: none; } }

/* ---------- Acties ---------- */
.actions { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.action { display: grid; grid-template-columns: 22px minmax(0, 1fr) auto; gap: 10px; padding: 10px 8px; border-radius: 8px; align-items: start; }
.action:hover { background: var(--surface-2); }
.action input { width: 18px; height: 18px; margin: 2px 0 0; accent-color: var(--accent); cursor: pointer; }
.action .t { font-weight: 600; }
.action .d { color: var(--ink-2); font-size: 13.5px; }
.action.done .t, .action.done .d { text-decoration: line-through; color: var(--ink-3); }
.tag { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; padding: 2px 7px; border-radius: 99px; white-space: nowrap; }
.tag.geld { background: var(--good-bg); color: var(--good); }
.tag.sales { background: color-mix(in srgb, var(--s-real) 16%, var(--surface)); color: var(--s-real); }
.tag.groei { background: color-mix(in srgb, var(--s-pipe) 16%, var(--surface)); color: var(--s-pipe); }
.tag.risico, .tag.ai { background: var(--warn-bg); color: var(--warn); }
.tag.ai { background: color-mix(in srgb, var(--flamingo) 15%, var(--surface)); color: var(--flamingo); }
.progress-line { height: 4px; background: var(--surface-2); border-radius: 4px; overflow: hidden; margin: -6px 0 10px; }
.progress-line div { height: 100%; background: var(--good); }

/* ---------- Gat & AI ---------- */
.gap-big { font-size: 28px; font-weight: 750; letter-spacing: -.01em; }
.steps { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin: 14px 0; }
.step { background: var(--surface-2); border-radius: 8px; padding: 10px 12px; }
.step b { display: block; font-size: 22px; }
.step span { font-size: 12.5px; color: var(--ink-2); }
.ai-card { border-top: 1px solid var(--line); margin-top: 16px; padding-top: 16px; display: grid; gap: 10px; }
.ai-card p { margin: 0; }
.ai-kop { font-weight: 650; font-size: 16px; }
.ai-ins { display: grid; gap: 8px; }
.ai-ins div { padding-left: 12px; border-left: 3px solid var(--line); }
.ai-q { background: var(--surface-2); padding: 10px 12px; border-radius: 8px; font-style: italic; }

/* ---------- Grafiek ---------- */
.chart-box { position: relative; height: 320px; }
@media (max-width: 600px) { .chart-box { height: 260px; } }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.seg button { border: 0; background: transparent; padding: 5px 10px; cursor: pointer; color: var(--ink-2); }
.seg button[aria-pressed="true"] { background: var(--surface-2); color: var(--ink); font-weight: 600; }

/* ---------- Tabellen ---------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--ink-3); font-weight: 600; padding: 8px; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 9px 8px; border-bottom: 1px solid var(--line); vertical-align: middle; }
td.n, th.n { text-align: right; white-space: nowrap; }
tr:last-child td { border-bottom: 0; }
tfoot td { font-weight: 700; border-top: 1px solid var(--line); }

/* ---------- Doelen ---------- */
.goals { display: grid; gap: 16px; }
.goal-top { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 6px; }
.goal-top b { font-weight: 650; }
.meter { position: relative; height: 10px; background: var(--surface-2); border-radius: 5px; overflow: visible; }
.meter .fill { height: 100%; border-radius: 5px; background: var(--s-real); }
.meter .fc { position: absolute; top: 0; height: 100%; border-radius: 5px; background: repeating-linear-gradient(135deg, var(--s-certain) 0 4px, transparent 4px 7px); }
.meter .exp { position: absolute; top: -4px; bottom: -4px; border-left: 2px solid var(--ink); }
.goal-foot { font-size: 13px; color: var(--ink-2); margin-top: 6px; }
.dots { display: flex; gap: 6px; flex-wrap: wrap; }
.dots span { width: 22px; height: 22px; border-radius: 50%; border: 2px solid var(--s-real); display: grid; place-items: center; font-size: 11px; font-weight: 700; }
.dots span.on { background: var(--s-real); color: #fff; }
.dots span.maybe { border-style: dashed; border-color: var(--s-pipe); }

/* ---------- Pipeline ---------- */
.stages { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 8px; margin-bottom: 14px; }
.stage { background: var(--surface-2); border-radius: 8px; padding: 10px 12px; }
.stage span { font-size: 12px; color: var(--ink-3); text-transform: uppercase; letter-spacing: .06em; }
.stage b { display: block; font-size: 18px; }
.stage em { font-style: normal; font-size: 12.5px; color: var(--ink-2); }
@media (max-width: 700px) { .stages { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.pot { display: flex; flex-wrap: wrap; gap: 8px 24px; margin-bottom: 12px; font-size: 14px; color: var(--ink-2); }
.pot b { color: var(--ink); }
.deal-title { font-weight: 600; }
.deal-sub { font-size: 12.5px; color: var(--ink-3); }
td select, td input { border: 1px solid transparent; background: transparent; padding: 4px 6px; border-radius: 6px; max-width: 100%; }
td select:hover, td input:hover { border-color: var(--line); }
td input[type="number"] { width: 64px; text-align: right; }
.pill { font-size: 12px; padding: 2px 8px; border-radius: 99px; background: var(--surface-2); color: var(--ink-2); white-space: nowrap; }
.pill.late { background: var(--bad-bg); color: var(--bad); }
.pill.today { background: var(--warn-bg); color: var(--warn); }
.pill.mb { background: color-mix(in srgb, var(--s-real) 14%, var(--surface)); color: var(--s-real); }
.filter-row { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- Horizontale balken ---------- */
.hbars { display: grid; gap: 10px; }
.hbar-top { display: flex; justify-content: space-between; font-size: 14px; gap: 8px; }
.hbar-track { position: relative; height: 12px; margin-top: 4px; }
.hbar-track .cur { height: 12px; background: var(--s-real); border-radius: 0 4px 4px 0; }
.hbar-track .prev { position: absolute; top: -3px; bottom: -3px; border-left: 2px solid var(--s-prev); }

/* ---------- Vraag ---------- */
.ask { display: flex; gap: 8px; }
.ask input { flex: 1; min-width: 0; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); }
.answer { margin-top: 12px; white-space: pre-wrap; background: var(--surface-2); padding: 12px 14px; border-radius: 8px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.chips button { border: 1px solid var(--line); background: transparent; border-radius: 99px; padding: 4px 10px; font-size: 13px; cursor: pointer; color: var(--ink-2); }
.chips button:hover { border-color: var(--ink-3); color: var(--ink); }

/* ---------- Snel toevoegen ---------- */
.fab {
  position: fixed; right: 20px; bottom: calc(20px + env(safe-area-inset-bottom, 0px)); z-index: 30;
  background: var(--flamingo); color: #fff; border: 0; border-radius: 99px; padding: 14px 20px; font-weight: 700;
  box-shadow: 0 6px 20px color-mix(in srgb, var(--flamingo) 40%, transparent); cursor: pointer; display: flex; gap: 8px; align-items: center;
}
.fab kbd { font: 12px var(--mono); background: rgba(255,255,255,.2); padding: 1px 6px; border-radius: 4px; }
dialog { border: 1px solid var(--line); border-radius: 14px; padding: 0; background: var(--surface); color: var(--ink); width: min(560px, calc(100vw - 32px)); max-height: calc(100vh - 48px); }
dialog::backdrop { background: rgba(6, 20, 28, .45); }
.dlg { padding: 20px; display: grid; gap: 14px; }
.dlg-h { display: flex; justify-content: space-between; align-items: center; }
.field { display: grid; gap: 4px; }
.field label { font-size: 13px; color: var(--ink-2); font-weight: 600; }
.field input, .field select, .field textarea { border: 1px solid var(--line); border-radius: 8px; padding: 9px 11px; background: var(--bg); width: 100%; }
.row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.row-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
@media (max-width: 520px) { .row, .row-3 { grid-template-columns: minmax(0, 1fr); } }
.stage-pick { display: flex; flex-wrap: wrap; gap: 6px; }
.stage-pick label { cursor: pointer; }
.stage-pick input { position: absolute; opacity: 0; }
.stage-pick span { display: inline-block; padding: 6px 12px; border: 1px solid var(--line); border-radius: 99px; font-size: 14px; }
.stage-pick input:checked + span { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.stage-pick input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }
.dlg-foot { display: flex; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.goal-edit { display: grid; grid-template-columns: 120px minmax(0, 1fr) 110px 120px 110px 32px; gap: 6px; align-items: center; }
.goal-edit input, .goal-edit select { border: 1px solid var(--line); border-radius: 6px; padding: 6px 8px; background: var(--bg); min-width: 0; }
@media (max-width: 720px) { .goal-edit { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); } }
.weights { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 4px; }
.weights label { font-size: 11px; color: var(--ink-3); text-align: center; display: grid; gap: 2px; }
.weights input { width: 100%; border: 1px solid var(--line); border-radius: 6px; padding: 4px 2px; text-align: center; background: var(--bg); }
@media (max-width: 600px) { .weights { grid-template-columns: repeat(6, minmax(0, 1fr)); } }

.toast { position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%); background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 8px; z-index: 50; font-size: 14px; }

/* ---------- Login ---------- */
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login form { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 28px; width: min(380px, 100%); display: grid; gap: 14px; }
.login input { border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; background: var(--bg); }
.err { color: var(--bad); font-size: 14px; }

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