/* Autoballoon – basisstijl
   Tokens bovenaan; donker thema via prefers-color-scheme. */
:root {
  --bg: #f4f5f2;
  --surface: #ffffff;
  --surface-2: #eceee9;
  --ink: #1b1f23;
  --ink-2: #4a525b;
  --muted: #6b737c;
  --line: #d6dad3;
  --accent: #c62828;          /* ballonrood */
  --accent-ink: #ffffff;
  --accent-soft: #fbe9e7;
  --dim: #b0287f;             /* maatkleur (magenta, zoals op de tekeningen) */
  --ok: #2e7d32;
  --warn: #b26a00;
  --error: #c62828;
  --radius: 6px;
  --shadow: 0 1px 2px rgba(0,0,0,.05), 0 4px 16px rgba(0,0,0,.04);
  --font: "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: "Cascadia Mono", Consolas, "SFMono-Regular", Menlo, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #15181b; --surface: #1d2125; --surface-2: #262b30; --ink: #e8eaed; --ink-2: #c3c8ce;
    --muted: #8f979f; --line: #343a40; --accent: #ef5350; --accent-ink: #160707; --accent-soft: #3a1d1d;
    --dim: #e070bd; --ok: #66bb6a; --warn: #ffb74d; --error: #ef5350;
    --shadow: 0 1px 2px rgba(0,0,0,.4);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; min-height: 100vh; display: flex; flex-direction: column;
  background: var(--bg); color: var(--ink); font: 15px/1.55 var(--font);
  /* subtiel tekenpapier-raster */
  background-image: linear-gradient(var(--line) 1px, transparent 1px), linear-gradient(90deg, var(--line) 1px, transparent 1px);
  background-size: 32px 32px; background-position: -1px -1px;
  background-attachment: fixed;
}
body::before { content: ""; position: fixed; inset: 0; background: var(--bg); opacity: .82; z-index: -1; }
a { color: var(--accent); text-underline-offset: 2px; }
h1, h2, h3 { line-height: 1.2; margin: 0 0 .6em; letter-spacing: -.01em; }
h1 { font-size: 1.7rem; } h2 { font-size: 1.15rem; }
code { font-family: var(--mono); font-size: .88em; background: var(--surface-2); padding: .1em .35em; border-radius: 3px; word-break: break-all; }
.muted { color: var(--muted); } .small { font-size: .87rem; } .text-error { color: var(--error); }

/* Kop */
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap;
  padding: 10px max(16px, calc((100vw - 1200px) / 2)); background: var(--surface); border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 10;
}
.brand { display: flex; align-items: center; gap: 10px; color: var(--ink); text-decoration: none; font-weight: 700; font-size: 1.05rem; }
.brand-mark { width: 28px; height: 28px; color: var(--accent); }
.mainnav { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.mainnav a, .linklike { color: var(--ink-2); text-decoration: none; padding: 6px 10px; border-radius: var(--radius); font: inherit; }
.mainnav a:hover, .linklike:hover { background: var(--surface-2); color: var(--ink); }
.mainnav a[aria-current] { color: var(--ink); background: var(--surface-2); }
.mainnav a.btn { color: var(--accent-ink); background: var(--accent); }
.linklike { background: none; border: 0; cursor: pointer; }
form.inline { display: inline; margin: 0; }

.page { flex: 1; width: 100%; max-width: 1200px; margin: 0 auto; padding: 28px 16px 48px; }
.footer { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding: 14px max(16px, calc((100vw - 1200px) / 2)); color: var(--muted); font-size: .85rem; border-top: 1px solid var(--line); background: var(--surface); }

/* Kaarten en layout */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px; box-shadow: var(--shadow); margin-bottom: 20px; }
.card.narrow { max-width: 640px; margin-left: auto; margin-right: auto; }
.card.auth { max-width: 420px; margin-top: 6vh; }
.pagehead { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 18px; }
.pagehead h1 { margin: 0; }
.subnav { display: flex; gap: 4px; flex-wrap: wrap; }
.subnav a { padding: 6px 12px; border-radius: var(--radius); text-decoration: none; color: var(--ink-2); border: 1px solid transparent; }
.subnav a[aria-current] { border-color: var(--line); background: var(--surface); color: var(--ink); font-weight: 600; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 20px; }
.features .card { margin: 0; }
.features { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 20px; }

/* Knoppen */
.btn {
  display: inline-flex; align-items: center; gap: 6px; padding: 9px 16px; border-radius: var(--radius);
  background: var(--accent); color: var(--accent-ink); border: 1px solid var(--accent); font: 600 .95rem var(--font);
  text-decoration: none; cursor: pointer;
}
.btn:hover { filter: brightness(1.08); }
.btn:disabled { opacity: .45; cursor: not-allowed; filter: none; }
.btn-small { padding: 5px 10px; font-size: .85rem; }
.btn-ghost { background: transparent; color: var(--ink-2); border-color: var(--line); }
.btn-ghost:hover { background: var(--surface-2); color: var(--ink); }

/* Formulieren */
.form { display: grid; gap: 14px; }
.form > .btn { justify-self: start; }
.form label { display: grid; gap: 5px; font-weight: 600; font-size: .9rem; flex: 1; }
.form label small { font-weight: 400; color: var(--muted); }
.form .row { display: flex; gap: 14px; flex-wrap: wrap; }
.form .row > label { min-width: 200px; }
.form .w-small { flex: 0 0 120px; min-width: 120px !important; }
.form label.check { display: flex; align-items: center; gap: 8px; font-weight: 400; }
input, select, textarea {
  font: inherit; color: var(--ink); background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 8px 10px; width: 100%;
}
input[type=checkbox] { width: auto; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: 1px; border-color: var(--accent); }
fieldset { border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px 16px; margin: 0; display: grid; gap: 12px; }
legend { font-weight: 700; padding: 0 6px; }
[hidden] { display: none !important; }

/* Meldingen */
.flash { padding: 10px 14px; border-radius: var(--radius); margin: 0 0 14px; border-left: 4px solid; background: var(--surface); word-break: break-word; }
.flash-ok { border-color: var(--ok); } .flash-error { border-color: var(--error); } .flash-warn { border-color: var(--warn); }

/* Tabellen */
.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: 20px; }
.table { width: 100%; border-collapse: collapse; font-size: .92rem; }
.table tbody tr:last-child td { border-bottom: 0; }
.table th, .table td { text-align: left; padding: 9px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table th { font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); background: var(--surface-2); }
.table.compact td { padding: 6px 10px; font-size: .86rem; }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }
.table tr.inactive td { color: var(--muted); }
.table select { width: auto; padding: 4px 6px; }
.actions-col { white-space: nowrap; text-align: right; }
.badge { display: inline-block; padding: 2px 8px; border-radius: 99px; font-size: .78rem; background: var(--surface-2); }

/* Checklist install */
.checklist { list-style: none; padding: 0; margin: 0 0 20px; border: 1px solid var(--line); border-radius: var(--radius); }
.checklist li { display: flex; justify-content: space-between; padding: 8px 12px; border-bottom: 1px solid var(--line); }
.checklist li:last-child { border-bottom: 0; }
.checklist li span { font-weight: 700; }
.checklist .ok span { color: var(--ok); } .checklist .fail span { color: var(--error); } .checklist .warn span { color: var(--warn); }

/* Statistieken */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 14px; margin-bottom: 20px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; display: grid; }
.stat-n { font-size: 1.8rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.stat-l { color: var(--muted); font-size: .85rem; }
.meta { display: grid; grid-template-columns: max-content 1fr; gap: 6px 18px; margin: 0 0 18px; }
.meta dt { color: var(--muted); } .meta dd { margin: 0; }
.plain { margin: 0; padding-left: 18px; }

/* Lege staat */
.empty { text-align: center; padding: 48px 22px; }
.empty-icon { width: 72px; height: 72px; fill: none; stroke: var(--muted); stroke-width: 1.5; margin-bottom: 8px; }
.empty-icon circle { stroke: var(--accent); fill: var(--surface); }
.empty-icon text { fill: var(--accent); stroke: none; font: 700 9px var(--font); }

/* Startpagina */
.hero { display: grid; grid-template-columns: 1.1fr 1fr; gap: 32px; align-items: center; padding: 24px 0 40px; }
.eyebrow { color: var(--accent); font-weight: 700; text-transform: uppercase; letter-spacing: .08em; font-size: .8rem; margin: 0 0 10px; }
.hero h1 { font-size: clamp(2rem, 4.5vw, 3rem); letter-spacing: -.02em; }
.lead { font-size: 1.1rem; color: var(--ink-2); max-width: 54ch; }
.hero-figure { margin: 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); }
.hero-svg { width: 100%; height: auto; display: block; }
.hero-svg .part { fill: none; stroke: var(--ink); stroke-width: 1.6; }
.hero-svg .center { stroke: var(--muted); stroke-dasharray: 14 4 2 4; stroke-width: 1; }
.hero-svg .dim, .hero-svg .ext { stroke: var(--dim); stroke-width: 1; }
.hero-svg .dimtext { fill: var(--dim); font: 13px var(--font); text-anchor: middle; }
.hero-svg .balloon line { stroke: var(--accent); stroke-width: 1.2; }
.hero-svg .balloon circle { fill: var(--surface); stroke: var(--accent); stroke-width: 1.8; }
.hero-svg .balloon text { fill: var(--accent); font: 700 11px var(--font); text-anchor: middle; }

@media (max-width: 760px) {
  .hero { grid-template-columns: 1fr; padding-top: 4px; }
  .page { padding-top: 18px; }
  .actions-col { white-space: normal; }
}

/* Upload-zone (tekeningen) */
.dropzone {
  display: grid; justify-items: center; gap: 4px; text-align: center; padding: 22px 16px; margin-bottom: 20px;
  border: 2px dashed var(--line); border-radius: var(--radius); background: var(--surface); transition: border-color .15s, background .15s;
}
.dropzone p { margin: 0; }
.dropzone.over { border-color: var(--accent); background: var(--accent-soft); }
.dropzone.busy { border-style: solid; }
.dz-icon { width: 36px; height: 36px; fill: none; stroke: var(--accent); stroke-width: 2.5; stroke-linecap: round; stroke-linejoin: round; }
.filepick { color: var(--accent); text-decoration: underline; cursor: pointer; font-weight: 600; }
.filepick input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.filepick:focus-within { outline: 2px solid var(--accent); outline-offset: 2px; }
.uploadlist { list-style: none; padding: 0; margin: 8px 0 0; width: 100%; max-width: 640px; display: grid; gap: 6px; }
.uploadlist:empty { display: none; }
.uploadlist li { display: grid; grid-template-columns: 1fr 120px auto; gap: 10px; align-items: center; font-size: .88rem; text-align: left; }
.ul-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ul-bar { height: 6px; background: var(--surface-2); border-radius: 3px; overflow: hidden; }
.ul-bar span { display: block; height: 100%; width: 0; background: var(--accent); transition: width .2s; }
.uploadlist li.ok .ul-bar span { background: var(--ok); }
.uploadlist li.ok .ul-status { color: var(--ok); }
.uploadlist li.err .ul-status { color: var(--error); }

/* Tekeningenlijst */
.drawing-link { font-weight: 600; color: var(--ink); text-decoration: none; }
.drawing-link:hover { color: var(--accent); text-decoration: underline; }
.badge-nieuw { background: var(--surface-2); }
.badge-gedetecteerd { background: #fff3e0; color: #8a4b00; }
.badge-gecontroleerd { background: #e3f2fd; color: #0d47a1; }
.badge-afgerond { background: #e8f5e9; color: #1b5e20; }
@media (prefers-color-scheme: dark) {
  .badge-gedetecteerd { background: #3a2a12; color: #ffcc80; }
  .badge-gecontroleerd { background: #12263a; color: #90caf9; }
  .badge-afgerond { background: #16301a; color: #a5d6a7; }
}
.rowmenu { position: relative; display: inline-block; text-align: left; }
.rowmenu summary { list-style: none; }
.rowmenu summary::-webkit-details-marker { display: none; }
.rowmenu-panel {
  position: absolute; right: 0; top: calc(100% + 4px); z-index: 5; min-width: 240px; display: grid; gap: 2px; padding: 6px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: 0 8px 24px rgba(0,0,0,.12);
}
.rowmenu-panel > a, .rowmenu-panel .linklike { display: block; padding: 6px 10px; border-radius: 4px; color: var(--ink); text-decoration: none; text-align: left; width: 100%; }
.rowmenu-panel > a:hover, .rowmenu-panel .linklike:hover { background: var(--surface-2); }
.rowmenu-panel .rename { display: flex; gap: 6px; padding: 6px 4px; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); margin: 4px 0; }
.rowmenu-panel .rename input { padding: 4px 8px; }
.linklike.danger { color: var(--error); }
