/* ==========================================================================
   Batowa — Toetsingskader Waterkwaliteit
   Styling for the portal and the management screens.

   Hand written, without a build step. The reason: the assessment itself is one
   self-contained HTML file with its own styling, and the shell around it is a
   handful of screens. A bundler would add an install step and a 200 MB
   node_modules without anything getting better — and would have to be run again
   on every server move.

   All colours are declared as custom properties at the top, light and dark.
   Anyone changing the house style only has to be there.

   The palette matches assets/portal.css, which the assessment uses, so that the
   portal and the assessment read as one product rather than two.
   ========================================================================== */

:root {
  --brand: #1e6fb8;
  --brand-dark: #0c447c;
  --brand-light: #45a0e0;
  --brand-surface: #e6f1fb;
  --brand-border: #b5d4f4;

  --bg: #f4f7f9;
  --surface: #ffffff;
  --surface-2: #fafcfd;
  --border: #e2e8ef;
  --border-strong: #cdd7e1;

  --text: #0f1b24;
  --text-muted: #4a5b69;
  --text-subtle: #8595a3;

  --success: #067a52;
  --success-surface: #eafaf3;
  --danger: #b42318;
  --danger-surface: #fdf1f0;
  --warning: #b54708;
  --warning-surface: #fff8ec;

  --shadow-sm: 0 1px 2px rgba(16, 32, 45, .06), 0 1px 3px rgba(16, 32, 45, .04);
  --shadow-md: 0 4px 12px rgba(16, 32, 45, .07), 0 2px 4px rgba(16, 32, 45, .04);
  --shadow-lg: 0 18px 40px rgba(16, 32, 45, .13), 0 4px 10px rgba(16, 32, 45, .05);

  --radius: 10px;
  --radius-lg: 16px;
  --container-width: 1180px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --brand: #4c9fe0;
    --brand-dark: #2b7cc0;
    --brand-light: #7dc4ee;
    --brand-surface: #0d2233;
    --brand-border: #1a4062;

    --bg: #0a1116;
    --surface: #101a21;
    --surface-2: #14212a;
    --border: #1e2d38;
    --border-strong: #2b3d4a;

    --text: #e8eef3;
    --text-muted: #a9bac7;
    --text-subtle: #74889a;

    --success: #37c48b;
    --success-surface: #0c2318;
    --danger: #f97066;
    --danger-surface: #2a1414;
    --warning: #f0a35e;
    --warning-surface: #2a1e10;

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .4);
    --shadow-md: 0 4px 14px rgba(0, 0, 0, .45);
    --shadow-lg: 0 20px 44px rgba(0, 0, 0, .6);
  }
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 { margin: 0 0 .35em; line-height: 1.25; letter-spacing: -.015em; font-weight: 640; }
h1 { font-size: 26px; }
h2 { font-size: 19px; }
h3 { font-size: 16px; }
p { margin: 0 0 1em; }
p:last-child { margin-bottom: 0; }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
small { font-size: 12.5px; }

code, kbd, .mono {
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  font-size: .9em;
}

/* -------------------------------------------------------------- topbar --- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--border);
}

.topbar-inner {
  max-width: var(--container-width);
  margin: 0 auto;
  padding: 0 24px;
  height: 60px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 660;
  letter-spacing: -.02em;
  color: var(--text);
  margin-right: 12px;
  white-space: nowrap;
}
.brand:hover { text-decoration: none; }
.brand-mark {
  width: 30px; height: 30px;
  border-radius: 9px;
  background: linear-gradient(145deg, var(--brand-light), var(--brand-dark));
  display: grid; place-items: center;
  color: #fff; font-size: 15px;
  box-shadow: var(--shadow-sm);
}
.brand small {
  display: block;
  font-weight: 480;
  font-size: 11px;
  color: var(--text-subtle);
  letter-spacing: .02em;
  margin-top: -3px;
}

.topbar nav { display: flex; align-items: center; gap: 2px; margin-left: auto; }

.topbar nav a.tab {
  padding: 7px 12px;
  border-radius: 8px;
  color: var(--text-muted);
  font-weight: 520;
  font-size: 14px;
  white-space: nowrap;
}
.topbar nav a.tab:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.topbar nav a.tab.is-active { background: var(--brand-surface); color: var(--brand-dark); }

@media (prefers-color-scheme: dark) {
  .topbar nav a.tab.is-active { color: var(--brand-light); }
}

.identity {
  display: flex; align-items: center; gap: 9px;
  padding-left: 14px; margin-left: 8px;
  border-left: 1px solid var(--border);
}
.identity .who { font-size: 13px; line-height: 1.25; }
.identity .who b { display: block; font-weight: 580; }
.identity .who span { color: var(--text-subtle); font-size: 11.5px; }
.avatar {
  width: 32px; height: 32px; border-radius: 50%;
  background: linear-gradient(145deg, var(--brand-light), var(--brand-dark));
  color: #fff; display: grid; place-items: center;
  font-size: 12px; font-weight: 640; letter-spacing: .02em;
  flex: none;
}

.menu-toggle { display: none; }

@media (max-width: 940px) {
  .topbar-inner { flex-wrap: wrap; height: auto; padding: 10px 16px; }
  .menu-toggle {
    display: grid; place-items: center;
    margin-left: auto; width: 38px; height: 38px;
    border: 1px solid var(--border); border-radius: 9px;
    background: var(--surface); color: var(--text); cursor: pointer;
  }
  .topbar nav {
    order: 3; width: 100%; margin-left: 0;
    flex-wrap: wrap; gap: 4px;
    padding: 8px 0 4px; border-top: 1px solid var(--border); margin-top: 8px;
  }
  .topbar nav[hidden] { display: none; }
  .identity { border-left: 0; padding-left: 0; margin-left: 0; }
}

/* ----------------------------------------------------------- container --- */

.container { max-width: var(--container-width); margin: 0 auto; padding: 28px 24px 72px; }
.container.narrow { max-width: 560px; }
.container.medium { max-width: 840px; }

@media (max-width: 640px) { .container { padding: 20px 16px 56px; } }

.page-header {
  display: flex; align-items: flex-start; gap: 16px;
  flex-wrap: wrap; margin-bottom: 22px;
}
.page-header .page-title { flex: 1; min-width: 240px; }
.page-header .lead { color: var(--text-muted); margin: 2px 0 0; font-size: 14.5px; }
.page-header .page-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------------------------------------------------------------- card --- */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  padding: 22px;
  margin-bottom: 18px;
}
.card.flush { padding: 0; overflow: hidden; }
.card > h2 { display: flex; align-items: center; gap: 8px; }
.card .card-lead { color: var(--text-muted); font-size: 14px; margin: -2px 0 18px; }
.card-header {
  padding: 18px 22px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
}
.card-header h2 { margin: 0; }
.card-header .right { margin-left: auto; display: flex; gap: 8px; align-items: center; }

.grid { display: grid; gap: 18px; }
.grid.cols-2 { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
.grid.cols-3 { grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); }
.grid.cols-4 { grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); }

/* ---------------------------------------------------------------- stat --- */

.stat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px 18px;
  box-shadow: var(--shadow-sm);
}
.stat .label {
  font-size: 12px; text-transform: uppercase; letter-spacing: .05em;
  color: var(--text-subtle); font-weight: 580;
}
.stat .value { font-size: 30px; font-weight: 660; letter-spacing: -.03em; margin-top: 2px; }
.stat .note { font-size: 12.5px; color: var(--text-muted); }
.stat.success .value { color: var(--success); }
.stat.danger .value { color: var(--danger); }

/* -------------------------------------------------------------- button --- */

.button {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  padding: 9px 15px;
  border: 1px solid var(--border-strong);
  border-radius: 9px;
  background: var(--surface);
  color: var(--text);
  font: inherit; font-size: 14px; font-weight: 540;
  cursor: pointer;
  white-space: nowrap;
  transition: background .12s, border-color .12s, transform .06s, box-shadow .12s;
}
.button:hover { background: var(--surface-2); border-color: var(--text-subtle); text-decoration: none; }
.button:active { transform: translateY(1px); }
.button:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }

.button.primary {
  background: linear-gradient(180deg, var(--brand-light), var(--brand));
  border-color: var(--brand-dark);
  color: #fff;
  box-shadow: var(--shadow-sm);
}
.button.primary:hover { background: linear-gradient(180deg, var(--brand), var(--brand-dark)); }

.button.quiet { border-color: transparent; background: transparent; color: var(--text-muted); }
.button.quiet:hover { background: var(--surface-2); border-color: var(--border); color: var(--text); }

.button.danger { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 35%, var(--border)); }
.button.danger:hover { background: var(--danger-surface); border-color: var(--danger); }

.button.small { padding: 6px 11px; font-size: 13px; border-radius: 8px; }
.button.block { width: 100%; }
.button[disabled] { opacity: .5; cursor: not-allowed; }

.button-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-top: 16px; }

/* --------------------------------------------------------------- forms --- */

.field { display: block; margin-bottom: 14px; }
.field > span {
  display: block;
  font-size: 13px; font-weight: 560;
  color: var(--text-muted);
  margin-bottom: 5px;
}
.field .hint { font-weight: 400; color: var(--text-subtle); font-size: 12.5px; display: block; margin-top: 4px; }

input[type=text], input[type=password], input[type=email], input[type=date],
input[type=search], select, textarea {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--border-strong);
  border-radius: 9px;
  background: var(--surface);
  color: var(--text);
  font: inherit; font-size: 14.5px;
  transition: border-color .12s, box-shadow .12s;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 18%, transparent);
}
input::placeholder, textarea::placeholder { color: var(--text-subtle); }
textarea { resize: vertical; min-height: 76px; }
select {
  appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--text-subtle) 50%),
                    linear-gradient(135deg, var(--text-subtle) 50%, transparent 50%);
  background-position: calc(100% - 17px) 52%, calc(100% - 12px) 52%;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  padding-right: 34px;
}

.checkbox { display: flex; align-items: flex-start; gap: 9px; font-size: 14px; color: var(--text-muted); }
.checkbox input { margin-top: 3px; accent-color: var(--brand); width: 16px; height: 16px; flex: none; }

.field-row { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }

fieldset { border: 0; padding: 0; margin: 0 0 4px; }
legend {
  font-size: 12px; text-transform: uppercase; letter-spacing: .05em;
  color: var(--text-subtle); font-weight: 600;
  padding: 14px 0 8px;
}

/* --------------------------------------------------------------- alerts --- */

.alert {
  border-radius: var(--radius);
  padding: 12px 15px;
  margin-bottom: 16px;
  font-size: 14px;
  border: 1px solid;
  display: flex; gap: 10px; align-items: flex-start;
}
.alert.success { background: var(--success-surface); border-color: color-mix(in srgb, var(--success) 35%, transparent); color: var(--success); }
.alert.danger { background: var(--danger-surface); border-color: color-mix(in srgb, var(--danger) 35%, transparent); color: var(--danger); }
.alert.warning { background: var(--warning-surface); border-color: color-mix(in srgb, var(--warning) 35%, transparent); color: var(--warning); }
.alert ul { margin: 6px 0 0; padding-left: 18px; }
.alert b { font-weight: 620; }

/* A password shown once — it has to stand out and be copyable. */
.secret {
  border: 1px dashed var(--brand);
  background: var(--brand-surface);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 16px;
}
.secret .lines { display: flex; gap: 20px; flex-wrap: wrap; margin: 8px 0 10px; }
.secret .lines div { font-size: 12.5px; color: var(--text-muted); }
.secret .lines b { display: block; font-size: 17px; font-family: ui-monospace, Menlo, Consolas, monospace; color: var(--text); letter-spacing: .01em; }

/* --------------------------------------------------------------- table --- */

.table-wrap { overflow-x: auto; }

table.data { width: 100%; border-collapse: collapse; font-size: 14px; }
table.data th {
  text-align: left;
  font-size: 11.5px; text-transform: uppercase; letter-spacing: .05em;
  color: var(--text-subtle); font-weight: 620;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-2);
  white-space: nowrap;
}
table.data td { padding: 12px 16px; border-bottom: 1px solid var(--border); vertical-align: middle; }
table.data tbody tr:last-child td { border-bottom: 0; }
table.data tbody tr:hover { background: var(--surface-2); }
table.data td.primary-cell { font-weight: 560; }
table.data td.muted, table.data .muted { color: var(--text-muted); font-size: 13px; }
table.data td.actions { text-align: right; white-space: nowrap; }
table.data td.actions form { display: inline; }
table.data tr.inactive td { opacity: .55; }

/* -------------------------------------------------------------- badges --- */

.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 11.5px; font-weight: 580;
  border: 1px solid var(--border-strong);
  color: var(--text-muted);
  background: var(--surface-2);
  white-space: nowrap;
}
.badge.brand { background: var(--brand-surface); border-color: var(--brand-border); color: var(--brand-dark); }
.badge.success { background: var(--success-surface); border-color: color-mix(in srgb, var(--success) 30%, transparent); color: var(--success); }
.badge.danger { background: var(--danger-surface); border-color: color-mix(in srgb, var(--danger) 30%, transparent); color: var(--danger); }
.badge.warning { background: var(--warning-surface); border-color: color-mix(in srgb, var(--warning) 30%, transparent); color: var(--warning); }
.badge .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

@media (prefers-color-scheme: dark) {
  .badge.brand { color: var(--brand-light); }
}

/* ------------------------------------------------------------ progress --- */

.progress {
  width: 108px; height: 7px;
  background: var(--border);
  border-radius: 999px;
  overflow: hidden;
}
.progress > i {
  display: block; height: 100%;
  background: linear-gradient(90deg, var(--brand-light), var(--brand));
  border-radius: 999px;
}
.progress.complete > i { background: linear-gradient(90deg, #34d399, var(--success)); }
.progress-value { font-size: 12px; color: var(--text-muted); margin-top: 3px; }

/* --------------------------------------------------------------- empty --- */

.empty {
  text-align: center;
  padding: 46px 24px;
  color: var(--text-muted);
}
.empty .empty-icon {
  width: 52px; height: 52px; margin: 0 auto 14px;
  border-radius: 15px;
  background: var(--brand-surface);
  border: 1px solid var(--brand-border);
  display: grid; place-items: center;
  font-size: 22px;
}
.empty h3 { color: var(--text); }

/* ---------------------------------------------------------------- tabs --- */

.tabs { display: flex; gap: 4px; margin-bottom: 16px; flex-wrap: wrap; }
.tabs a {
  padding: 7px 14px; border-radius: 999px;
  font-size: 13.5px; font-weight: 540;
  color: var(--text-muted);
  border: 1px solid transparent;
}
.tabs a:hover { background: var(--surface); border-color: var(--border); text-decoration: none; }
.tabs a.is-active { background: var(--surface); border-color: var(--border-strong); color: var(--text); box-shadow: var(--shadow-sm); }
.tabs a .count { color: var(--text-subtle); font-weight: 460; }

/* -------------------------------------------------------------- dialog --- */

dialog {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  color: var(--text);
  padding: 0;
  max-width: 460px; width: calc(100% - 32px);
  box-shadow: var(--shadow-lg);
}
dialog::backdrop { background: rgba(10, 20, 28, .55); backdrop-filter: blur(2px); }
dialog .dialog-body { padding: 22px; }
dialog h3 { margin-bottom: 8px; }
dialog p { color: var(--text-muted); font-size: 14px; }

/* --------------------------------------------------------------- login --- */

.login-screen {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1.05fr .95fr;
}
.login-aside {
  background:
    radial-gradient(1000px 500px at 15% 10%, rgba(255,255,255,.16), transparent 60%),
    linear-gradient(155deg, var(--brand-dark), #072a52 62%, #041c38);
  color: #fff;
  padding: 52px 56px;
  display: flex; flex-direction: column; justify-content: space-between;
  position: relative; overflow: hidden;
}
.login-aside::after {
  content: ""; position: absolute; inset: auto -10% -32% -10%; height: 46%;
  background: radial-gradient(60% 100% at 50% 100%, rgba(41, 182, 224, .3), transparent 70%);
  pointer-events: none;
}
.login-aside .brand { color: #fff; }
.login-aside .brand small { color: rgba(255,255,255,.65); }
.login-aside h1 { font-size: 34px; max-width: 15ch; margin-top: 40px; }
.login-aside .aside-lead { color: rgba(255,255,255,.82); font-size: 15.5px; max-width: 46ch; }
.login-aside ul { list-style: none; padding: 0; margin: 26px 0 0; display: grid; gap: 11px; }
.login-aside li { display: flex; gap: 11px; align-items: flex-start; color: rgba(255,255,255,.9); font-size: 14.5px; }
.login-aside li .check {
  flex: none; width: 21px; height: 21px; border-radius: 7px; margin-top: 1px;
  background: rgba(255,255,255,.14); display: grid; place-items: center; font-size: 11px;
}
.login-aside .footnote { font-size: 12.5px; color: rgba(255,255,255,.6); position: relative; z-index: 1; }

.login-panel { display: grid; place-items: center; padding: 40px 24px; background: var(--bg); }
.login-panel .inner { width: 100%; max-width: 380px; }
.login-panel h2 { font-size: 23px; }
.login-panel .below { margin-top: 22px; font-size: 13px; color: var(--text-subtle); text-align: center; }

@media (max-width: 900px) {
  .login-screen { grid-template-columns: 1fr; }
  .login-aside { padding: 28px 24px; }
  .login-aside h1 { font-size: 25px; margin-top: 18px; }
  .login-aside ul, .login-aside .footnote { display: none; }
}

/* ---------------------------------------------------------------- misc --- */

.divider { height: 1px; background: var(--border); border: 0; margin: 20px 0; }
.muted { color: var(--text-muted); }
.subtle { color: var(--text-subtle); }
.right { text-align: right; }
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.push { margin-left: auto; }
.stack { display: grid; gap: 4px; }
.nowrap { white-space: nowrap; }

.filter-bar {
  display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end;
  padding: 16px 22px; border-bottom: 1px solid var(--border); background: var(--surface-2);
}
.filter-bar .field { margin-bottom: 0; }
.filter-bar .field.grow { flex: 1; min-width: 180px; }

.pagination { display: flex; gap: 6px; justify-content: center; padding: 16px; flex-wrap: wrap; }
.pagination a, .pagination span {
  padding: 6px 11px; border-radius: 8px; font-size: 13.5px;
  border: 1px solid var(--border); color: var(--text-muted); background: var(--surface);
}
.pagination .is-active { background: var(--brand); border-color: var(--brand-dark); color: #fff; }
.pagination .disabled { opacity: .45; }

.timeline { display: grid; gap: 0; }
.timeline .entry {
  display: flex; gap: 12px; align-items: flex-start;
  padding: 11px 0; border-bottom: 1px solid var(--border); font-size: 13.5px;
}
.timeline .entry:last-child { border-bottom: 0; }
.timeline .dot {
  width: 8px; height: 8px; border-radius: 50%; margin-top: 7px; flex: none;
  background: var(--text-subtle);
}
.timeline .entry.success .dot { background: var(--success); }
.timeline .entry.danger .dot { background: var(--danger); }
.timeline .when { margin-left: auto; color: var(--text-subtle); font-size: 12.5px; white-space: nowrap; }

.code-block {
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 14px;
  overflow-x: auto; font-size: 12.5px;
}

@media print {
  .topbar, .button-row, .filter-bar, .pagination { display: none; }
  body { background: #fff; }
  .card { box-shadow: none; border-color: #ccc; }
}
