/*
   Colors are variables. The light theme is the default.
   The dark theme applies when the system asks for it, unless a choice was made with the switch in the header
   (the data-theme attribute of the html element, set by theme.js). The two dark blocks are the same on purpose.
*/
:root {
    color-scheme: light;
    --bg: #f6f8fa;
    --surface: #ffffff;
    --surface-2: #f0f3f6;
    --ink: #1f2933;
    --muted: #5f6b7a;
    --line: #dde3ea;
    --line-soft: #eef1f4;
    --field-border: #b8c2ce;
    --brand: #1f3a5f;
    --brand-soft: #e9eef5;
    --header-border: #1f3a5f;
    --on-brand: #ffffff;
    --on-brand-link: #cfe0f5;
    --accent: #1f3a5f;
    --primary: #1f3a5f;
    --primary-hover: #2a4d7d;
    --on-primary: #ffffff;
    --link: #1d5fa6;
    --focus: #1d5fa6;
    --tab-off: #a3adb8;
    --ok: #1e7b3a;
    --ok-soft: #e3f4e8;
    --bad: #b3261e;
    --bad-soft: #fbe6e4;
    --warn: #9a5b00;
    --warn-soft: #fdf0d9;
    --info: #1d5fa6;
    --info-soft: #e3eefb;
    --badge-muted-bg: #edf0f3;
    --tile-warn-border: #e7c27d;
    --danger-border: #e0a8a4;
    --track-off: #7f95b3;
    --track-on: #4da3ff;
    --thumb: #ffffff;
}

:root[data-theme="dark"] {
    color-scheme: dark;
    --bg: #06121f;
    --surface: #0d1c2f;
    --surface-2: #13273f;
    --ink: #eaf2ff;
    --muted: #9db0c8;
    --line: #23364d;
    --line-soft: #1a2b41;
    --field-border: #5b7391;
    --brand: #0a1a2d;
    --brand-soft: #14294a;
    --header-border: #23364d;
    --on-brand: #eaf2ff;
    --on-brand-link: #9cc8ff;
    --accent: #6db3ff;
    --primary: #2563c9;
    --primary-hover: #3373dc;
    --on-primary: #ffffff;
    --link: #6db3ff;
    --focus: #6db3ff;
    --tab-off: #5b6b80;
    --ok: #5fd08a;
    --ok-soft: #10301f;
    --bad: #ff9088;
    --bad-soft: #3b1815;
    --warn: #f0b555;
    --warn-soft: #35270c;
    --info: #7db9ff;
    --info-soft: #0f2a4a;
    --badge-muted-bg: #1b2f48;
    --tile-warn-border: #8a6a2a;
    --danger-border: #7d3a36;
    --track-off: #5d7699;
    --track-on: #4da3ff;
    --thumb: #ffffff;
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        color-scheme: dark;
        --bg: #06121f;
        --surface: #0d1c2f;
        --surface-2: #13273f;
        --ink: #eaf2ff;
        --muted: #9db0c8;
        --line: #23364d;
        --line-soft: #1a2b41;
        --field-border: #5b7391;
        --brand: #0a1a2d;
        --brand-soft: #14294a;
        --header-border: #23364d;
        --on-brand: #eaf2ff;
        --on-brand-link: #9cc8ff;
        --accent: #6db3ff;
        --primary: #2563c9;
        --primary-hover: #3373dc;
        --on-primary: #ffffff;
        --link: #6db3ff;
        --focus: #6db3ff;
        --tab-off: #5b6b80;
        --ok: #5fd08a;
        --ok-soft: #10301f;
        --bad: #ff9088;
        --bad-soft: #3b1815;
        --warn: #f0b555;
        --warn-soft: #35270c;
        --info: #7db9ff;
        --info-soft: #0f2a4a;
        --badge-muted-bg: #1b2f48;
        --tile-warn-border: #8a6a2a;
        --danger-border: #7d3a36;
        --track-off: #5d7699;
        --track-on: #4da3ff;
        --thumb: #ffffff;
    }
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: "Segoe UI", system-ui, sans-serif;
    font-size: 14px;
    color: var(--ink);
    background: var(--bg);
}

header.top {
    background: var(--brand);
    color: var(--on-brand);
    border-bottom: 1px solid var(--header-border);
    padding: 10px 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.brand { font-size: 18px; font-weight: 600; }
.who { display: flex; gap: 12px; align-items: center; font-size: 13px; }
.who a, .who button.link { color: var(--on-brand-link); text-decoration: none; }
.who a:hover, .who button.link:hover { text-decoration: underline; }
.sep { opacity: 0.5; }

/* the switch for the dark theme; hidden until the script has run, because it does nothing without it */
.theme-toggle { display: inline-flex; align-items: center; gap: 8px; padding: 0; border: 0; background: none; color: var(--on-brand-link); font: inherit; cursor: pointer; }
.theme-toggle:hover { background: none; text-decoration: underline; }
.theme-toggle[hidden] { display: none; }
.theme-toggle .track { position: relative; width: 30px; height: 16px; border-radius: 8px; background: var(--track-off); transition: background 0.15s; }
.theme-toggle .track::after { content: ""; position: absolute; top: 2px; left: 2px; width: 12px; height: 12px; border-radius: 50%; background: var(--thumb); transition: transform 0.15s; }
.theme-toggle[aria-checked="true"] .track { background: var(--track-on); }
.theme-toggle[aria-checked="true"] .track::after { transform: translateX(14px); }
@media (prefers-reduced-motion: reduce) {
    .theme-toggle .track, .theme-toggle .track::after { transition: none; }
}

form.inline { display: inline; margin: 0; }
button.link { background: none; border: 0; padding: 0; font: inherit; color: var(--link); cursor: pointer; }
button.link:hover { background: none; text-decoration: underline; }
button.link.danger-link { color: var(--bad); }

:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

nav.tabs { background: var(--surface); border-bottom: 1px solid var(--line); padding: 0 24px; display: flex; gap: 4px; }
nav.tabs a, nav.tabs span { padding: 12px 16px; color: var(--accent); text-decoration: none; border-bottom: 3px solid transparent; }
nav.tabs a:hover { background: var(--brand-soft); }
nav.tabs a.active { border-bottom-color: var(--accent); font-weight: 600; }
nav.tabs span.off { color: var(--tab-off); cursor: default; }

main { padding: 24px; max-width: 1400px; margin: 0 auto; }
h1 { font-size: 22px; margin: 0 0 16px; }
h2 { font-size: 16px; margin: 24px 0 8px; }
a { color: var(--link); }
.crumbs { color: var(--muted); margin: 0 0 8px; }

table { width: 100%; border-collapse: collapse; background: var(--surface); border: 1px solid var(--line); }
th, td { text-align: left; padding: 8px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { background: var(--brand-soft); font-weight: 600; font-size: 13px; }
tr:last-child td { border-bottom: 0; }
td.empty { text-align: center; color: var(--muted); padding: 24px; }

.badge { display: inline-block; padding: 1px 8px; border-radius: 10px; font-size: 12px; margin-right: 4px; }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.bad { background: var(--bad-soft); color: var(--bad); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.info { background: var(--info-soft); color: var(--info); }
.badge.muted { background: var(--badge-muted-bg); color: var(--muted); }
.muted { color: var(--muted); }
.mono { font-family: Consolas, monospace; word-break: break-all; }

.tiles { display: flex; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.tile { background: var(--surface); border: 1px solid var(--line); border-radius: 6px; padding: 12px 20px; min-width: 130px; text-decoration: none; color: var(--ink); display: flex; flex-direction: column; }
.tile strong { font-size: 24px; }
.tile span { color: var(--muted); font-size: 13px; }
.tile.warn { border-color: var(--tile-warn-border); background: var(--warn-soft); }
.tile:hover { border-color: var(--accent); }

.filters { display: flex; gap: 8px; margin-bottom: 12px; align-items: center; flex-wrap: wrap; }
.filters .check { display: flex; gap: 4px; align-items: center; color: var(--muted); }

input[type=text], input[type=search], input[type=password], input[type=number], textarea, select {
    padding: 7px 10px; border: 1px solid var(--field-border); border-radius: 4px; font: inherit; background: var(--surface); color: var(--ink);
}
::placeholder { color: var(--muted); opacity: 1; }
button { padding: 7px 14px; border: 1px solid var(--field-border); border-radius: 4px; background: var(--surface); color: var(--ink); font: inherit; cursor: pointer; }
button:hover { background: var(--brand-soft); }
button.primary { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }
button.primary:hover { background: var(--primary-hover); }

.pager { display: flex; gap: 16px; justify-content: center; align-items: center; margin: 16px 0; color: var(--muted); }
.pager .pagesize { display: inline-flex; gap: 8px; align-items: center; }
.pager .pagesize strong { color: var(--ink); }

.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 12px; margin-bottom: 8px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 6px; padding: 4px 16px 12px; }
.card h2 { margin-top: 12px; }
dl { display: grid; grid-template-columns: 130px 1fr; gap: 4px 8px; margin: 0; }
dt { color: var(--muted); }
dd { margin: 0; }

details summary { cursor: pointer; color: var(--link); }
pre { background: var(--surface-2); color: var(--ink); padding: 8px; border-radius: 4px; max-height: 260px; overflow: auto; white-space: pre-wrap; margin: 6px 0 0; font-size: 12px; }

.narrow { max-width: 420px; margin: 32px auto; background: var(--surface); border: 1px solid var(--line); border-radius: 6px; padding: 8px 24px 24px; }
.narrow label { display: block; margin: 12px 0 4px; font-weight: 600; }
.narrow input { width: 100%; }
.narrow button { margin-top: 16px; }
.hint { color: var(--muted); font-size: 13px; margin: 4px 0; }
.secret { font-family: Consolas, monospace; font-size: 18px; letter-spacing: 2px; background: var(--surface-2); color: var(--ink); padding: 10px; border-radius: 4px; word-break: break-all; }

.alert { padding: 10px 12px; border-radius: 4px; margin: 8px 0; }
.alert.bad { background: var(--bad-soft); color: var(--bad); }
.alert.ok { background: var(--ok-soft); color: var(--ok); }
.alert.info { background: var(--info-soft); color: var(--info); }
.alert.warn { background: var(--warn-soft); color: var(--warn); }
.alert a { color: inherit; font-weight: 600; }

/* wider search fields, so the placeholder is readable */
input[type=search] { min-width: 300px; }
input[type=text].wide { width: 100%; min-width: 220px; }

a.button, label.button { display: inline-block; padding: 7px 14px; border: 1px solid var(--field-border); border-radius: 4px; text-decoration: none; color: var(--ink); background: var(--surface); }
a.button:hover, label.button:hover { background: var(--brand-soft); }
a.button.primary, label.button.primary { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }
button.danger { color: var(--bad); border-color: var(--danger-border); }
button.danger:hover { background: var(--bad-soft); }

th.num, td.num { text-align: right; }
td.center { text-align: center; }
.small { font-size: 12px; }
ul.plain { list-style: none; margin: 4px 0; padding: 0; }
ul.plain li { padding: 2px 0; }

/* indentation of the group tree; a class per level, because inline styles are not allowed */
td.d0 { padding-left: 12px; }
td.d1 { padding-left: 36px; }
td.d2 { padding-left: 60px; }
td.d3 { padding-left: 84px; }
td.d4 { padding-left: 108px; }
td.d5 { padding-left: 132px; }
td.d6 { padding-left: 156px; }
td.d7 { padding-left: 180px; }

table.editor td { vertical-align: top; }
table.editor .hint { margin: 2px 0 0; }

fieldset.block { background: var(--surface); border: 1px solid var(--line); border-radius: 6px; margin: 8px 0; padding: 8px 16px 12px; }
fieldset.block.on { border-color: var(--accent); }
fieldset.block legend { font-weight: 600; padding: 0 6px; }
.blockhead { display: flex; gap: 12px; align-items: center; margin-bottom: 8px; }
.blockkeys { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 8px 16px; }
.blockkeys label { display: flex; flex-direction: column; gap: 3px; color: var(--muted); font-size: 12px; }
.blockkeys input[type=text] { width: 100%; }
p.actions { margin: 20px 0; display: flex; gap: 16px; align-items: center; }

/* forms with labels above the fields */
form.stack { display: flex; flex-direction: column; gap: 4px; max-width: 640px; }
form.stack label { font-weight: 600; margin-top: 10px; }
form.stack input[type=text], form.stack input[type=number], form.stack select { width: 100%; }
form.stack input[type=file] { padding: 6px 0; }
form.wide-form { max-width: 760px; }
form.stack .check { font-weight: 400; margin-top: 14px; }
form.stack .hint { margin: 2px 0 4px; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin: 12px 0 4px; }
.narrow-input { width: 90px; }
pre.script { max-height: 520px; font-size: 12px; background: var(--surface); border: 1px solid var(--line); padding: 12px; }
table.plain-table { border: 0; background: transparent; }
table.plain-table th { background: transparent; border-bottom: 1px solid var(--line); }
table.plain-table td { border-bottom: 1px solid var(--line-soft); }

/* the file chooser: the browser writes "Bestand kiezen" in its own language, so with scripts the page draws its own button and text */
.file-picker { display: flex; align-items: center; gap: 10px; position: relative; padding: 6px 0; }
.file-picker .file-button, .file-picker .file-name { display: none; }
.file-picker.enhanced input[type=file] { position: absolute; width: 1px; height: 1px; opacity: 0; overflow: hidden; }
.file-picker.enhanced .file-button { display: inline-block; cursor: pointer; }
.file-picker.enhanced .file-name { display: inline; color: var(--muted); }
.file-picker.enhanced input[type=file]:focus + .file-button { outline: 2px solid var(--focus); outline-offset: 2px; }
form.stack .file-picker label.file-button { margin-top: 0; font-weight: 400; }

/* settings */
.subnav { display: flex; gap: 4px; flex-wrap: wrap; border-bottom: 1px solid var(--line); margin: 8px 0 18px; }
.subnav a { padding: 8px 14px; color: var(--muted); text-decoration: none; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.subnav a:hover { color: var(--ink); }
.subnav a.active { color: var(--ink); border-bottom-color: var(--accent); font-weight: 600; }
p.secret { font-family: ui-monospace, Consolas, monospace; font-size: 15px; background: var(--surface); color: var(--ink); border: 1px solid var(--line); padding: 10px 12px; margin: 10px 0; word-break: break-all; user-select: all; }
progress { width: 100%; height: 8px; margin-top: 6px; }
.nowrap { white-space: nowrap; }
