/* Businesspoint huisstijl: paars #6A1E5A, magenta #9F1D76, Fira Sans + Jost */
:root {
  color-scheme: light;
  --brand: #6a1e5a;
  --brand-2: #9f1d76;
  --brand-tint: #f4e9f1;
  --bg: #f8f4f7;
  --surface: #ffffff;
  --surface-2: #f3ecf1;
  --text: #2b1027;
  --text-2: #5f4d5a;
  --muted: #8a7a86;
  --border: rgba(106, 30, 90, 0.12);
  --grid: #ebe2e8;
  --axis: #cdbfc8;
  --accent: #6a1e5a;
  --accent-ink: #ffffff;
  --link: #9f1d76;
  --series-1: #6a1e5a;
  --good: #0ca30c;
  --good-ink: #006300;
  --warning: #fab219;
  --critical: #d03b3b;
  --banner: #f4e9f1;
  --logo-filter: none;
  --heading: #6a1e5a;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(106, 30, 90, .06), 0 4px 14px rgba(106, 30, 90, .05);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --brand-tint: #3a1b33;
    --bg: #150d14;
    --surface: #1f141d;
    --surface-2: #2a1c27;
    --text: #fbf3f8;
    --text-2: #cdb9c7;
    --muted: #9c8796;
    --border: rgba(255, 255, 255, 0.10);
    --grid: #2f222c;
    --axis: #45343f;
    --accent: #b9478f;
    --link: #e58cc4;
    --series-1: #c062a0;
    --good-ink: #2fc42f;
    --banner: #3a1b33;
    --logo-filter: brightness(0) invert(1);
    --heading: #fbf3f8;
    --shadow: none;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --brand-tint: #3a1b33; --bg: #150d14; --surface: #1f141d; --surface-2: #2a1c27; --text: #fbf3f8;
  --text-2: #cdb9c7; --muted: #9c8796; --border: rgba(255, 255, 255, 0.10); --grid: #2f222c; --axis: #45343f;
  --accent: #b9478f; --link: #e58cc4; --series-1: #c062a0; --good-ink: #2fc42f; --banner: #3a1b33;
  --logo-filter: brightness(0) invert(1); --heading: #fbf3f8; --shadow: none;
}

* { box-sizing: border-box; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 14px/1.5 "Fira Sans", system-ui, "Segoe UI", Roboto, sans-serif;
  font-variant-numeric: tabular-nums;
}
a { color: var(--link); }
code { background: var(--surface-2); padding: 1px 6px; border-radius: 4px; font-size: 13px; }
h1 { font-size: 26px; margin: 0; font-weight: 700; color: var(--heading); letter-spacing: -0.01em; }
h1::after { content: "*"; color: var(--brand-2); font-size: .8em; vertical-align: super; margin-left: 2px; }
h2 { font-size: 15px; margin: 0 0 2px; font-weight: 600; }
.sub, .meta { color: var(--text-2); font-size: 13px; margin: 0 0 12px; }
.meta { margin: 0; display: flex; gap: 10px; align-items: center; }

.topbar {
  display: flex; align-items: center; gap: 12px 28px; padding: 16px 28px 12px;
  background: var(--surface); position: sticky; top: 0; z-index: 5; flex-wrap: wrap;
  box-shadow: var(--shadow);
}
.topbar::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 3px;
  background: linear-gradient(90deg, var(--brand) 0%, var(--brand) 70%, var(--brand-2) 100%);
}
.brand { display: flex; align-items: center; gap: 14px; text-decoration: none; }
.brand img { height: 38px; width: auto; display: block; filter: var(--logo-filter); }
.brand .product {
  font-family: "Jost", "Fira Sans", sans-serif; font-size: 15px; color: var(--text-2);
  padding-left: 14px; border-left: 1px solid var(--border); line-height: 1.2;
}
.tabs { display: flex; gap: 2px; order: 3; flex-basis: 100%; overflow-x: auto; scrollbar-width: none; margin: 0 -4px -2px; }
.tabs::-webkit-scrollbar { display: none; }
#conn-pill { margin-left: auto; }
.tabs a {
  padding: 8px 14px; border-radius: 99px; color: var(--text-2); text-decoration: none; white-space: nowrap; font-weight: 500;
}
.tabs a:hover { background: var(--surface-2); color: var(--text); }
.tabs a.active { background: var(--brand); color: #fff; }
.tabs a.active .count { background: #fff; color: var(--brand); }
.pill { font-size: 12px; padding: 4px 12px; border-radius: 99px; border: 1px solid var(--border); color: var(--text-2); white-space: nowrap; }
.pill.ok::before, .pill.warn::before { content: "●"; margin-right: 6px; }
.pill.ok::before { color: var(--good); }
.pill.warn::before { color: var(--warning); }

.banner { background: var(--banner); color: var(--text); padding: 9px 28px; font-size: 13px; border-bottom: 1px solid var(--border); }
main { max-width: 1240px; margin: 0 auto; padding: 28px; }
.section-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; gap: 12px; flex-wrap: wrap; }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px 20px; margin-bottom: 16px; min-width: 0; box-shadow: var(--shadow); }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); gap: 16px; }
.grid2 > .card { margin-bottom: 0; }
.grid2 { margin-bottom: 16px; }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 12px; margin-bottom: 16px; }
.kpi { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow); border-top: 3px solid var(--brand); }
.kpi:nth-child(2) { border-top-color: var(--brand-2); }
.kpi .label { color: var(--text-2); font-size: 12px; }
.kpi .value { font-size: 26px; font-weight: 700; color: var(--heading); letter-spacing: -0.01em; margin-top: 2px; }
.kpi .delta { font-size: 12px; color: var(--text-2); }
.kpi .delta.up { color: var(--good-ink); }
.kpi .delta.down { color: var(--critical); }

.btn {
  font: inherit; font-weight: 500; border: 1px solid var(--border); background: var(--surface); color: var(--text);
  padding: 7px 16px; border-radius: 99px; cursor: pointer; white-space: nowrap;
}
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
.btn.primary:hover { background: var(--brand-2); filter: none; }
.btn.ghost { border-color: transparent; }
.btn.danger { color: var(--critical); }
.btn:disabled { opacity: .55; cursor: wait; }

.list { display: grid; gap: 12px; }
.auto { display: grid; grid-template-columns: 1fr auto; gap: 12px; align-items: center; }
.auto .title { font-weight: 600; font-size: 15px; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.auto .desc { color: var(--text-2); font-size: 13px; }
.auto .facts { display: flex; gap: 16px; flex-wrap: wrap; color: var(--muted); font-size: 12px; margin-top: 6px; }
.auto .actions { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.tag { font-size: 11px; padding: 1px 8px; border-radius: 99px; background: var(--surface-2); color: var(--text-2); font-weight: 500; }
.status { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; }
.status::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--muted); }
.status.success::before { background: var(--good); }
.status.error::before { background: var(--critical); }
.status.running::before { background: var(--warning); }
.empty { color: var(--text-2); text-align: center; padding: 32px; }

table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { text-align: left; font-weight: 500; color: var(--text-2); border-bottom: 1px solid var(--border); padding: 6px 8px; }
td { border-bottom: 1px solid var(--border); padding: 7px 8px; vertical-align: top; }
td.num, th.num { text-align: right; }
tr.click { cursor: pointer; }
tr.click:hover td { background: var(--surface-2); }
.table-wrap { overflow-x: auto; }

.chart { position: relative; width: 100%; }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart text { fill: var(--text-2); font-size: 11px; }
.legend { display: flex; gap: 14px; font-size: 12px; color: var(--text-2); margin: 4px 0 8px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }
.tooltip {
  position: fixed; pointer-events: none; z-index: 20; background: var(--surface); color: var(--text);
  border: 1px solid var(--border); border-radius: 8px; padding: 6px 10px; font-size: 12px;
  box-shadow: 0 4px 16px rgba(0,0,0,.12);
}
.tooltip b { display: block; }

dialog { border: 1px solid var(--border); border-radius: 12px; background: var(--surface); color: var(--text); padding: 20px; width: min(560px, calc(100vw - 32px)); }
dialog.wide { width: min(860px, calc(100vw - 32px)); }
dialog::backdrop { background: rgba(0,0,0,.35); }
.field { display: grid; gap: 4px; margin-bottom: 12px; }
.field label { font-size: 12px; color: var(--text-2); font-weight: 500; }
.field input, .field select, .field textarea {
  font: inherit; padding: 7px 9px; border-radius: 8px; border: 1px solid var(--border);
  background: var(--bg); color: var(--text); width: 100%;
}
.field textarea { min-height: 80px; resize: vertical; }
.row { display: flex; gap: 10px; }
.row > * { flex: 1; }
.form-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 8px; }
.hint { font-size: 12px; color: var(--muted); }
.output { white-space: pre-wrap; background: var(--bg); border: 1px solid var(--border); border-radius: 8px; padding: 12px 14px; max-height: 50vh; overflow: auto; }
.output h3 { margin: 12px 0 4px; font-size: 14px; }
.logs { font-family: ui-monospace, Consolas, monospace; font-size: 12px; color: var(--text-2); margin: 8px 0; }
.steps li { margin-bottom: 6px; }
.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--text); color: var(--bg); padding: 8px 16px; border-radius: 8px; z-index: 30; max-width: calc(100vw - 32px); }

@media (max-width: 640px) {
  main { padding: 16px; }
  .topbar { padding: 10px 16px; gap: 10px; }
  .banner { padding: 8px 16px; }
  .auto { grid-template-columns: 1fr; }
  .auto .actions { justify-content: flex-start; }
  .grid2 { grid-template-columns: 1fr; }
}

/* ---------- Orders, voorraad, bevestigingen ---------- */
.grid3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 16px; margin-bottom: 16px; }
.grid3 > .card { margin-bottom: 0; }
.card.flush { padding: 0; overflow: hidden; }
.card.flush table th:first-child, .card.flush table td:first-child { padding-left: 16px; }
.card.flush table th:last-child, .card.flush table td:last-child { padding-right: 16px; }
.card.flush .empty { padding: 40px; }
.toolbar { display: flex; justify-content: space-between; gap: 12px; align-items: center; margin-bottom: 12px; flex-wrap: wrap; }
.toolbar-right { display: flex; gap: 8px; flex-wrap: wrap; }
.toolbar input[type=search] { font: inherit; padding: 6px 10px; border-radius: 8px; border: 1px solid var(--border); background: var(--surface); color: var(--text); min-width: 220px; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { font: inherit; font-size: 13px; padding: 5px 12px; border-radius: 99px; border: 1px solid var(--border); background: var(--surface); color: var(--text-2); cursor: pointer; }
.chip:hover { background: var(--surface-2); }
.chip.active { background: var(--brand); color: #fff; border-color: transparent; }
.chip .n { opacity: .7; margin-left: 4px; }
.count { display: inline-block; min-width: 18px; padding: 0 5px; margin-left: 4px; border-radius: 99px; background: var(--critical); color: #fff; font-size: 11px; line-height: 18px; text-align: center; }

.badge { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; padding: 2px 9px; border-radius: 99px; white-space: nowrap; font-weight: 500; background: var(--surface-2); color: var(--text-2); }
.badge::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.badge.good { color: var(--good-ink); background: color-mix(in srgb, var(--good) 14%, transparent); }
.badge.warn { color: var(--text); background: color-mix(in srgb, var(--warning) 22%, transparent); }
.badge.warn::before { background: var(--warning); }
.badge.bad { color: var(--critical); background: color-mix(in srgb, var(--critical) 12%, transparent); }
.badge.muted { color: var(--muted); }

tr.order-row { cursor: pointer; }
tr.order-row:hover td { background: var(--surface-2); }
tr.order-row td:first-child::before { content: "▸"; display: inline-block; width: 14px; color: var(--muted); transition: transform .15s; }
tr.order-row.open td:first-child::before { transform: rotate(90deg); }
tr.lines-row > td { background: var(--bg); padding: 10px 16px 14px; }
tr.lines-row table { background: var(--surface); border: 1px solid var(--border); border-radius: 8px; }
tr.lines-row th { font-size: 12px; }
.late { color: var(--critical); font-weight: 500; }
.neg { color: var(--critical); font-weight: 600; }
.pos { color: var(--good-ink); }
.small { font-size: 12px; color: var(--muted); }
.row-actions { display: flex; gap: 6px; justify-content: flex-end; }
.btn.sm { padding: 3px 10px; font-size: 12px; }
.logic summary { cursor: pointer; }
.logic ol { margin: 10px 0 0; padding-left: 20px; color: var(--text-2); }
.logic li { margin-bottom: 6px; }
.issues { margin: 0; padding-left: 16px; color: var(--critical); font-size: 12px; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 4px 16px; font-size: 13px; margin: 8px 0 14px; }
.kv dt { color: var(--text-2); }
.kv dd { margin: 0; }
.callout { border-left: 3px solid var(--warning); background: color-mix(in srgb, var(--warning) 10%, transparent); padding: 8px 12px; border-radius: 0 8px 8px 0; margin: 10px 0; font-size: 13px; }
.callout.info { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 8%, transparent); }
.check-field { display: flex; gap: 8px; align-items: center; margin-bottom: 12px; font-size: 13px; }
.check-field input { width: 16px; height: 16px; }
@media (max-width: 640px) {
  .toolbar input[type=search] { min-width: 0; width: 100%; }
  .toolbar-right { width: 100%; }
}
[hidden] { display: none !important; }

/* ---------- Gebruikersmenu & rechten ---------- */
.user-menu { position: relative; }
.user-btn { display: flex; align-items: center; gap: 10px; background: none; border: 1px solid transparent; border-radius: 99px; padding: 3px 12px 3px 3px; cursor: pointer; font: inherit; color: var(--text); }
.user-btn:hover { background: var(--surface-2); }
.avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--brand); color: #fff; display: grid; place-items: center; font-weight: 600; font-size: 13px; }
.user-text { display: grid; text-align: left; line-height: 1.2; }
.user-text b { font-size: 13px; font-weight: 600; }
.user-text span { font-size: 11px; color: var(--muted); }
.menu { position: absolute; right: 0; top: calc(100% + 6px); background: var(--surface); border: 1px solid var(--border); border-radius: 10px; box-shadow: 0 8px 24px rgba(0,0,0,.12); padding: 6px; min-width: 190px; z-index: 10; }
.menu button { display: block; width: 100%; text-align: left; background: none; border: 0; padding: 8px 10px; border-radius: 6px; font: inherit; color: var(--text); cursor: pointer; }
.menu button:hover { background: var(--surface-2); }
.matrix th.role { text-align: center; min-width: 110px; vertical-align: bottom; }
.matrix th.role .small { display: block; font-weight: 400; }
.matrix td.cell { text-align: center; }
.matrix td.cell input { width: 17px; height: 17px; accent-color: var(--brand); cursor: pointer; }
.matrix tr.group td { background: var(--surface-2); font-weight: 600; font-size: 12px; color: var(--text-2); text-transform: uppercase; letter-spacing: .04em; }
.matrix .role-actions { display: flex; gap: 4px; justify-content: center; margin-top: 4px; }
.link-btn { background: none; border: 0; padding: 0; color: var(--link); cursor: pointer; font: inherit; font-size: 12px; }
@media (max-width: 760px) { .user-text { display: none; } .user-btn { padding: 3px; } }
