:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-2: #f1f3f6;
  --text: #16191f;
  --muted: #646b78;
  --border: #e2e5ea;
  --accent: #1f5eff;
  --accent-ink: #ffffff;
  --accent-soft: #e8efff;
  --ok: #157f4b;
  --ok-soft: #e6f5ec;
  --err: #c4302b;
  --err-soft: #fdecea;
  --warn: #9a6400;
  --warn-soft: #fff5e0;
  --admin: #6b3fd6;
  --admin-ink: #ffffff;
  --info: #2563eb;
  --info-soft: #eaf1ff;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .05);
  --mono: ui-monospace, "SF Mono", "Cascadia Code", Menlo, Consolas, monospace;
  color-scheme: light;
}
/* Donker: automatisch volgens het apparaat, of geforceerd via het thema (data-theme) */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1115;
    --surface: #171a20;
    --surface-2: #1e222a;
    --text: #e8eaee;
    --muted: #9198a6;
    --border: #2a2f39;
    --accent: #6d9bff;
    --accent-ink: #0b1020;
    --accent-soft: #1b2640;
    --ok: #4cc38a;
    --ok-soft: #13291f;
    --err: #ff7b72;
    --err-soft: #331716;
    --warn: #e3b341;
    --warn-soft: #2d2410;
    --admin: #a98bff;
    --info: #7aa7ff;
    --info-soft: #18233a;
    --shadow: none;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
    --bg: #0f1115;
    --surface: #171a20;
    --surface-2: #1e222a;
    --text: #e8eaee;
    --muted: #9198a6;
    --border: #2a2f39;
    --accent: #6d9bff;
    --accent-ink: #0b1020;
    --accent-soft: #1b2640;
    --ok: #4cc38a;
    --ok-soft: #13291f;
    --err: #ff7b72;
    --err-soft: #331716;
    --warn: #e3b341;
    --warn-soft: #2d2410;
    --admin: #a98bff;
    --info: #7aa7ff;
    --info-soft: #18233a;
    --shadow: none;
    color-scheme: dark;
}
:root[data-theme="light"] { color-scheme: light; }

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.6rem; margin: .2rem 0 .1rem; letter-spacing: -.01em; }
h2 { font-size: 1.05rem; margin: 0 0 .9rem; }
h3 { font-size: .95rem; margin: .4rem 0 .2rem; }
code, .mono { font-family: var(--mono); font-size: .9em; }
.muted { color: var(--muted); }
.block { display: block; }
.nowrap { white-space: nowrap; }
.center { text-align: center; }
.err { color: var(--err); }

/* ---------- topbar ---------- */
.topbar { background: var(--surface); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 10; }
.topbar-inner { max-width: 1040px; margin: 0 auto; padding: .6rem 16px; display: flex; align-items: center; gap: 1.5rem; flex-wrap: wrap; }
.topbar-inner.wide, .container.wide { max-width: 1240px; }
.brand { font-weight: 650; color: var(--text); display: flex; align-items: center; gap: .45rem; }
.brand:hover { text-decoration: none; }
.brand-mark { color: var(--accent); font-size: .8rem; }
.area-admin .brand-mark { color: var(--admin); }
.mainnav { display: flex; gap: .25rem; flex: 1; flex-wrap: wrap; }
.mainnav a { color: var(--muted); padding: .35rem .7rem; border-radius: 7px; font-weight: 500; }
.mainnav a:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.mainnav a.active { background: var(--accent-soft); color: var(--accent); }
.area-admin .mainnav a.active { color: var(--admin); background: color-mix(in srgb, var(--admin) 12%, transparent); }
.userbox { display: flex; align-items: center; gap: .75rem; margin-left: auto; }
.userbox .who { text-align: right; line-height: 1.2; font-size: .9rem; }
.userbox .who small { display: block; color: var(--muted); font-size: .78rem; }
.userbox form { margin: 0; }

.container { max-width: 1040px; margin: 0 auto; padding: 1.5rem 16px 4rem; }

/* ---------- page head ---------- */
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 1rem; margin-bottom: 1.25rem; flex-wrap: wrap; }
.page-head p { margin: 0; }
.head-actions { display: flex; gap: .5rem; flex-wrap: wrap; }
.head-actions form { margin: 0; }
.crumb { font-size: .85rem; color: var(--muted); }

/* ---------- cards ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.25rem; box-shadow: var(--shadow); margin-bottom: 1.25rem; }
.card-flush { padding: 0; overflow: hidden; }
.empty { padding: 2rem; text-align: center; color: var(--muted); }
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); gap: 1.25rem; align-items: start; }
.grid-2 > .card { margin-bottom: 0; }
.grid-sidebar { display: grid; grid-template-columns: 1fr 320px; gap: 1.25rem; align-items: start; }
@media (max-width: 860px) { .grid-sidebar { grid-template-columns: 1fr; } }
.hint { font-size: .85rem; color: var(--muted); margin: .9rem 0 0; }
.top-gap { margin-top: 1.25rem; padding-top: 1.25rem; border-top: 1px solid var(--border); }

/* ---------- auth ---------- */
.auth-wrap { display: grid; place-items: center; min-height: 60vh; }
.auth-card { width: 100%; max-width: 400px; padding: 2rem; }
.auth-card h1 { margin-bottom: .2rem; }
.auth-card > p.muted { margin-top: 0; margin-bottom: 1.25rem; }

/* ---------- forms ---------- */
.stack { display: flex; flex-direction: column; gap: .9rem; }
.field { display: flex; flex-direction: column; gap: .3rem; min-width: 0; }
.field label { font-size: .82rem; font-weight: 600; color: var(--muted); }
.field small { color: var(--muted); font-size: .78rem; }
input, select, textarea {
  font: inherit; color: var(--text); background: var(--surface);
  border: 1px solid var(--border); border-radius: 8px; padding: .5rem .65rem; width: 100%; min-width: 0;
}
input:focus, select:focus, textarea:focus { outline: 2px solid color-mix(in srgb, var(--accent) 35%, transparent); outline-offset: 0; border-color: var(--accent); }
input[readonly] { background: var(--surface-2); }
input[type=checkbox], input[type=radio] { width: auto; }
.code-input { font-family: var(--mono); font-size: 1.3rem; letter-spacing: .3em; text-align: center; }
.suffix-input { display: flex; align-items: stretch; }
.suffix-input input { border-top-right-radius: 0; border-bottom-right-radius: 0; font-family: var(--mono); }
.suffix { display: flex; align-items: center; padding: 0 .6rem; background: var(--surface-2); border: 1px solid var(--border); border-left: 0;
  border-radius: 0 8px 8px 0; color: var(--muted); font-family: var(--mono); font-size: .85rem; white-space: nowrap; max-width: 45%; overflow: hidden; text-overflow: ellipsis; }

.record-form { display: grid; gap: .75rem; align-items: start;
  grid-template-columns: 110px minmax(160px, 1.2fr) 90px minmax(200px, 2fr) 120px auto;
  grid-template-areas: "type name prio content ttl actions"; }
.record-form .f-type { grid-area: type; } .record-form .f-name { grid-area: name; } .record-form .f-prio { grid-area: prio; }
.record-form .f-content { grid-area: content; } .record-form .f-ttl { grid-area: ttl; } .record-form .f-actions { grid-area: actions; }
.record-form .f-actions { flex-direction: row; gap: .5rem; padding-top: 1.45rem; }
.record-form .f-content input { font-family: var(--mono); }
.record-form [hidden] { display: none; }
@media (max-width: 960px) {
  .record-form { grid-template-columns: 1fr 1fr; grid-template-areas: "type ttl" "name name" "prio prio" "content content" "actions actions"; }
  .record-form .f-actions { padding-top: 0; }
}
.inline-form { display: flex; gap: .6rem; align-items: flex-end; margin-top: 1rem; padding-top: 1rem; border-top: 1px solid var(--border); flex-wrap: wrap; }
.inline-form .grow { flex: 1; min-width: 160px; }
.search input { min-width: 260px; }

/* ---------- buttons ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: .35rem; font: inherit; font-weight: 600; font-size: .9rem;
  padding: .5rem .9rem; border-radius: 8px; border: 1px solid transparent; cursor: pointer; white-space: nowrap; background: none; color: var(--text); }
.btn:hover { text-decoration: none; }
.btn-primary { background: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { filter: brightness(1.08); }
.area-admin .btn-primary { background: var(--admin); color: var(--admin-ink, #fff); }
.btn-ghost { border-color: var(--border); background: var(--surface); }
.btn-ghost:hover { background: var(--surface-2); }
.btn-danger-ghost { border-color: var(--border); background: var(--surface); color: var(--err); }
.btn-danger-ghost:hover { background: var(--err-soft); border-color: color-mix(in srgb, var(--err) 30%, transparent); }
.btn-sm { padding: .28rem .6rem; font-size: .8rem; }
.btn-block { width: 100%; }

/* ---------- flash & badges ---------- */
.flash { padding: .7rem .9rem; border-radius: 8px; margin-bottom: 1rem; border: 1px solid transparent; }
.flash-ok { background: var(--ok-soft); color: var(--ok); border-color: color-mix(in srgb, var(--ok) 25%, transparent); }
.flash-error { background: var(--err-soft); color: var(--err); border-color: color-mix(in srgb, var(--err) 25%, transparent); }
.flash-info { background: var(--info-soft); color: var(--text); border-color: color-mix(in srgb, var(--info) 22%, transparent); }
.badge { display: inline-block; font-size: .72rem; font-weight: 600; padding: .1rem .45rem; border-radius: 99px; background: var(--surface-2); color: var(--muted); vertical-align: middle; }
.badge-admin { background: color-mix(in srgb, var(--admin) 15%, transparent); color: var(--admin); }
.badge-ok { background: var(--ok-soft); color: var(--ok); }
.badge-warn { background: var(--warn-soft); color: var(--warn); }
.badge-err { background: var(--err-soft); color: var(--err); }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: .65rem 1rem; border-bottom: 1px solid var(--border); vertical-align: top; }
th { font-size: .75rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; background: var(--surface-2); }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: color-mix(in srgb, var(--surface-2) 50%, transparent); }
td.num, th.num { text-align: right; }
td.actions { text-align: right; white-space: nowrap; }
td.actions form { display: inline; margin: 0; }
td.check, th.check { width: 2.5rem; }
tr.inactive td { opacity: .6; }
tr.failed td { background: color-mix(in srgb, var(--err-soft) 50%, transparent); }
.records td.name { font-weight: 600; max-width: 220px; overflow-wrap: anywhere; }
.records td.content { overflow-wrap: anywhere; max-width: 480px; }
.records .prio { color: var(--muted); }
.type { font-family: var(--mono); font-size: .75rem; font-weight: 700; padding: .12rem .4rem; border-radius: 5px; background: var(--surface-2); }
.type-a, .type-aaaa { color: #1f7a3d; background: color-mix(in srgb, #1f7a3d 12%, transparent); }
.type-cname { color: #9a5b00; background: color-mix(in srgb, #c27c0e 14%, transparent); }
.type-mx { color: #7a3fd0; background: color-mix(in srgb, #7a3fd0 12%, transparent); }
.type-txt { color: #2a6fb0; background: color-mix(in srgb, #2a6fb0 12%, transparent); }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .type-a, :root:not([data-theme="light"]) .type-aaaa { color: #5fd38a; }
  :root:not([data-theme="light"]) .type-cname { color: #f0b24a; }
  :root:not([data-theme="light"]) .type-mx { color: #b79bff; }
  :root:not([data-theme="light"]) .type-txt { color: #7ab8ff; }
}
:root[data-theme="dark"] .type-a, :root[data-theme="dark"] .type-aaaa { color: #5fd38a; }
:root[data-theme="dark"] .type-cname { color: #f0b24a; }
:root[data-theme="dark"] .type-mx { color: #b79bff; }
:root[data-theme="dark"] .type-txt { color: #7ab8ff; }
.diff span { display: block; font-family: var(--mono); font-size: .85em; }
.diff .del { color: var(--err); } .diff .del::before { content: "− "; }
.diff .add { color: var(--ok); } .diff .add::before { content: "+ "; }
.audit td { font-size: .88rem; }

/* ---------- lists ---------- */
.list { list-style: none; padding: 0; margin: 0; }
.list li { display: flex; justify-content: space-between; align-items: center; gap: .75rem; padding: .65rem 0; border-bottom: 1px solid var(--border); }
.list li:last-child { border-bottom: 0; }
.row-actions { display: flex; gap: .35rem; }
.row-actions form { margin: 0; }
details.menu { position: relative; }
details.menu summary { list-style: none; }
details.menu summary::-webkit-details-marker { display: none; }
.menu-items { position: absolute; right: 0; top: calc(100% + 4px); background: var(--surface); border: 1px solid var(--border); border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .12); padding: .3rem; z-index: 5; min-width: 220px; }
.menu-items form { margin: 0; }
.menu-items button { display: block; width: 100%; text-align: left; font: inherit; font-size: .88rem; background: none; border: 0; padding: .45rem .6rem; border-radius: 6px; cursor: pointer; color: var(--text); }
.menu-items button:hover { background: var(--surface-2); }
.menu-items button.danger { color: var(--err); }

/* ---------- zones ---------- */
.zone-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 1rem; }
.zone-tile { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.1rem 1.2rem; display: flex; flex-direction: column; gap: .2rem; box-shadow: var(--shadow); }
.zone-tile:hover { border-color: var(--accent); text-decoration: none; }
.zone-name { font-weight: 650; color: var(--text); font-size: 1.05rem; overflow-wrap: anywhere; }
.zone-tile .muted { font-size: .85rem; }

/* ---------- misc ---------- */
.qr { background: #fff; display: inline-block; padding: .5rem; border-radius: 8px; border: 1px solid var(--border); }
.qr img { display: block; }
.invite-box { border-color: color-mix(in srgb, var(--ok) 40%, var(--border)); }
.copy-row { display: flex; gap: .5rem; }
.import-bar { display: flex; justify-content: space-between; align-items: center; gap: 1rem; padding: 1rem; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.import-bar label { display: flex; align-items: center; gap: .6rem; font-weight: 600; flex-wrap: wrap; }
.import-bar select { width: auto; min-width: 220px; }
.pager { display: flex; justify-content: space-between; }

/* Formulier zonder prioriteitsveld: kolom/rij laten vervallen */
.record-form:has(.f-prio[hidden]) { grid-template-columns: 110px minmax(200px, 1.4fr) minmax(200px, 2fr) 120px auto; grid-template-areas: "type name content ttl actions"; }
@media (max-width: 960px) {
  .record-form:has(.f-prio[hidden]) { grid-template-columns: 1fr 1fr; grid-template-areas: "type ttl" "name name" "content content" "actions actions"; }
}
.records td { vertical-align: middle; }

/* Records als kaartjes op smalle schermen */
@media (max-width: 640px) {
  .records thead { display: none; }
  .records, .records tbody { display: block; }
  .records tr { display: grid; grid-template-columns: auto 1fr auto; grid-template-areas: "type name ttl" "content content content" "actions actions actions";
    gap: .35rem .6rem; padding: .85rem 1rem; border-bottom: 1px solid var(--border); align-items: center; }
  .records tbody tr:last-child { border-bottom: 0; }
  .records td { display: block; padding: 0; border: 0; max-width: none !important; }
  .records td:nth-child(1) { grid-area: name; }
  .records td:nth-child(2) { grid-area: type; }
  .records td:nth-child(3) { grid-area: content; }
  .records td:nth-child(4) { grid-area: ttl; font-size: .85rem; }
  .records td.actions { grid-area: actions; text-align: left; padding-top: .25rem; }
  .topbar-inner { gap: .5rem 1rem; }
  .userbox .who { display: none; }
  .userbox { margin-left: 0; }
}

/* ---------- thema: logo en voettekst ---------- */
.brand-logo { height: 28px; width: auto; max-width: 180px; display: block; object-fit: contain; }
.site-footer { max-width: 1040px; margin: 0 auto; padding: 0 16px 2rem; color: var(--muted); font-size: .85rem; text-align: center; white-space: pre-line; }
.site-footer.wide { max-width: 1240px; }
.auth-logo { display: block; max-height: 56px; max-width: 220px; margin: 0 0 1rem; }

/* ---------- goedkeuringen ---------- */
.nav-count { display: inline-block; min-width: 1.35em; padding: 0 .35em; border-radius: 99px; background: var(--warn); color: #fff;
  font-size: .72rem; font-weight: 700; line-height: 1.35em; text-align: center; margin-left: .15rem; }
.pending-card { border-color: color-mix(in srgb, var(--warn) 45%, var(--border)); background: color-mix(in srgb, var(--warn-soft) 55%, var(--surface)); }
.pending-card h2 { display: flex; align-items: center; gap: .5rem; }
.list li .grow { flex: 1; min-width: 0; }
.badge-kind-create { background: var(--ok-soft); color: var(--ok); }
.badge-kind-update { background: var(--info-soft); color: var(--info); }
.badge-kind-delete { background: var(--err-soft); color: var(--err); }
.diff { margin-top: .25rem; overflow-wrap: anywhere; }
.note { color: var(--text); font-style: italic; }
.check-label { display: flex; gap: .5rem; align-items: center; font-size: .9rem; }
.section-title { margin: 1.75rem 0 .75rem; font-size: 1rem; }
.approvals td { vertical-align: top; }
.decide { min-width: 260px; }
.decide-form { display: flex; flex-direction: column; gap: .45rem; }
.decide-form input { font-size: .85rem; padding: .35rem .55rem; }

/* ---------- thema-instellingen ---------- */
.theme-grid { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 1.25rem; align-items: start; }
@media (max-width: 900px) { .theme-grid { grid-template-columns: 1fr; } }
.color-row { display: flex; gap: .5rem; align-items: center; }
.color-row input[type=color] { width: 3rem; height: 2.4rem; padding: .15rem; cursor: pointer; flex: none; }
.color-row input[type=text] { font-family: var(--mono); max-width: 9rem; }
.logo-current { display: flex; align-items: center; gap: 1rem; padding: .75rem; background: var(--surface-2); border-radius: 8px; flex-wrap: wrap; }
.logo-current img { max-height: 48px; max-width: 200px; }
.preview { border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; position: sticky; top: 5rem; }
.preview-bar { display: flex; align-items: center; gap: .5rem; padding: .6rem .9rem; background: var(--surface); border-bottom: 1px solid var(--border); font-weight: 650; }
.preview-bar img { max-height: 22px; max-width: 120px; }
.preview-body { padding: 1rem .9rem; background: var(--bg); display: flex; flex-direction: column; gap: .6rem; align-items: flex-start; }
.preview-body .pv-admin { background: var(--pv-admin, var(--admin)); color: var(--pv-admin-ink, var(--admin-ink)); }
.preview-body .pv-primary { background: var(--pv-accent, var(--accent)); color: var(--pv-accent-ink, var(--accent-ink)); }
.preview-body .pv-link { color: var(--pv-accent, var(--accent)); font-weight: 600; }
.pv-dot { color: var(--pv-accent, var(--accent)); font-size: .8rem; }
.warn-text { color: var(--warn); font-size: .82rem; }

/* ---------- instellingen ---------- */
.tabs { display: flex; gap: .25rem; border-bottom: 1px solid var(--border); margin: -.25rem 0 1rem; overflow-x: auto; }
.tabs a { padding: .55rem .9rem; color: var(--muted); font-weight: 600; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.tabs a:hover { color: var(--text); text-decoration: none; }
.tabs a.active { color: var(--admin); border-bottom-color: var(--admin); }
.tab-intro { margin: 0 0 1.25rem; }
.card h2 .badge { margin-left: .4rem; font-weight: 600; }
.advanced summary { cursor: pointer; color: var(--muted); font-weight: 600; font-size: .9rem; }
.advanced[open] summary { margin-bottom: .75rem; }
.tips { padding-left: 1.1rem; margin: .25rem 0 1rem; font-size: .9rem; color: var(--muted); }
.tips li { margin-bottom: .35rem; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: .4rem 1rem; margin: 0; }
.kv dt { color: var(--muted); font-size: .88rem; }
.kv dd { margin: 0; }
[data-show-for][hidden] { display: none; }
.divider { display: flex; align-items: center; gap: .75rem; color: var(--muted); font-size: .8rem; margin: .5rem 0 0; }
.divider::before, .divider::after { content: ""; flex: 1; border-top: 1px solid var(--border); }
.local-login { margin-top: .5rem; }

/* ---------- Microsoft-login ---------- */
.btn-ms { background: #fff; color: #3b3b3b; border: 1px solid #8c8c8c; gap: .6rem; }
.btn-ms:hover { background: #f3f3f3; }
.ms-logo { flex: none; }
.badge-ms { background: color-mix(in srgb, #00a4ef 14%, transparent); color: var(--text); font-weight: 500; }
.top-gap-card { margin-top: 1.25rem; }
.inline-form.no-border { border-top: 0; padding-top: 0; margin-top: 0; }
.auth-card > .divider { margin: 1rem 0; }

/* ---------- Inserve ---------- */
.grid-2.tight { gap: .75rem; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
.small-text { font-size: .8rem; line-height: 1.6; overflow-wrap: anywhere; }
.badge-inserve { background: color-mix(in srgb, #f59e0b 16%, transparent); color: var(--text); font-weight: 500; }
.kv-table td { padding: .3rem .6rem; font-size: .82rem; }
.kv-table td:first-child { color: var(--muted); white-space: nowrap; }
pre.small-text { white-space: pre-wrap; background: var(--surface-2); padding: .6rem; border-radius: 6px; }
.app-version { font-size: .8rem; margin: -.5rem 0 1rem; }
.radio-group { border: 0; padding: 0; margin: 0; display: flex; flex-direction: column; gap: .35rem; min-width: 0; }
.radio-group legend { font-size: .82rem; font-weight: 600; color: var(--muted); padding: 0; margin-bottom: .35rem; }
.radio-group small { color: var(--muted); font-size: .78rem; }
code.break { word-break: break-all; }
.check-label.small { font-size: .8rem; font-weight: 400; color: var(--muted); }
