/* NSoE site checklist: admin portal and staff sign-in, in the house style.
   Sits on top of base.css (tokens and components); only admin-specific pieces live here.
   Every colour is a base.css token or one of the tokens below, with dark values. */

:root {
  /* Logo size scales with the screen: 28px on a phone up to 52px on a large desktop. The header grows with it. */
  --logo: clamp(28px, 2.4vw + 18px, 52px);
  --nav-h: max(56px, calc(var(--logo) + 24px));
  --tile-bg: #ffffff;          /* the client's logos always sit on white */
  --tile-line: #ebebf0;
  --seg-empty: #ebebf0;
  --seg-part: #8c8c94;
  --stage: #f2f3f5;            /* behind a photo in the lightbox */
  --backdrop: rgba(15, 20, 26, .6);
  --ctl-line: #8c8c94;         /* form control edges, 3:1 against the page */
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --tile-bg: #ffffff; --tile-line: #424650;
    --seg-empty: #2b313b; --seg-part: #a4a4ad;
    --stage: #0b0f14; --backdrop: rgba(0, 0, 0, .72);
    --muted: #a4a4ad; --ctl-line: #8c8c94;
  }
}
:root[data-theme="dark"] {
  --tile-bg: #ffffff; --tile-line: #424650;
  --seg-empty: #2b313b; --seg-part: #a4a4ad;
  --stage: #0b0f14; --backdrop: rgba(0, 0, 0, .72);
  --muted: #a4a4ad; --ctl-line: #8c8c94;
}
:root { color-scheme: light; }
:root[data-theme="dark"] { color-scheme: dark; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) { color-scheme: dark; } }

[hidden] { display: none !important; }
button { font: inherit; }

/* ---------- Top navigation: the client's own marks in the brand slot ---------- */
.topnav { padding-left: max(12px, env(safe-area-inset-left)); padding-right: max(12px, env(safe-area-inset-right)); }
.logo-tile { display: inline-flex; align-items: center; gap: calc(var(--logo) / 8); padding: 3px calc(var(--logo) / 8); background: var(--tile-bg); border: 1px solid var(--tile-line); border-radius: var(--radius-ctl); flex: none; }
.topnav { height: var(--nav-h); }
.logo-tile img { width: var(--logo); height: calc(var(--logo) * 1.03); object-fit: contain; display: block; }
.topnav .brand { min-width: 0; }
/* Brand centred: true page centre on wide screens; below that, centred in the room left of the controls */
.topnav .brand { flex: 1 1 auto; justify-content: center; }
.topnav > .spacer { display: none; }
.topnav .brand-text { align-items: center; text-align: center; }
@media (min-width: 1200px) {
  .topnav .brand { position: absolute; left: 50%; transform: translateX(-50%); flex: none; max-width: calc(100% - 560px); }
  .topnav > .spacer { display: block; }
}
.brand-text { display: flex; flex-direction: column; min-width: 0; line-height: 16px; }
.brand-name { font-weight: 700; letter-spacing: -0.01em; }
.brand-sub { font-size: 12px; font-weight: 400; color: var(--ink-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topnav .net { font-size: 12px; font-weight: 600; white-space: nowrap; }
.topnav .account { max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- Page ---------- */
.adm { max-width: 1440px; display: flex; flex-direction: column; gap: 20px; outline: none; }
.adm > .page-head { margin: 4px 0 0; }
.adm-summary { margin: 4px 0 0; color: var(--ink-2); }
#body { display: flex; flex-direction: column; gap: 28px; min-width: 0; }
#body:empty { display: none; }
.adm-sec { display: flex; flex-direction: column; gap: 14px; min-width: 0; scroll-margin-top: calc(var(--nav-h) + 16px); }
.adm-sec-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.eyebrow-sm { display: block; font-size: 12px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--link); margin-bottom: 2px; }
.card-head .desc { margin: 2px 0 0; }
.card-head h3 { padding-top: 2px; }

/* Alerts with a title, a sentence and an action */
.alert-text { min-width: 0; }
.alert-actions { margin-top: 10px; display: flex; gap: 8px; flex-wrap: wrap; }

/* Empty state with an icon */
.empty svg.i { display: block; width: 28px; height: 28px; margin: 0 auto 10px; color: var(--ink-3); }
.empty { max-width: 560px; margin: 0 auto; }

/* ---------- School overview cards ---------- */
.acards { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }
.acard { text-align: left; color: var(--ink); cursor: pointer; padding: 16px 20px; gap: 12px; font: inherit; line-height: 20px; }
.acard:hover { border-color: var(--line); }
.acard.is-sel { border-color: var(--link); box-shadow: inset 0 0 0 1px var(--link); background: var(--selected-bg); }
.acard-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.acard-names { display: flex; flex-direction: column; min-width: 0; }
.acard-name { font-size: 16px; line-height: 22px; font-weight: 600; overflow-wrap: anywhere; }
.acard-sub, .acard-meta { color: var(--ink-2); font-size: 12px; line-height: 16px; }
.acard-meta { overflow-wrap: anywhere; }
.acard-top .status { flex: none; font-size: 12px; font-weight: 600; white-space: nowrap; }
.segs { display: flex; gap: 3px; }
.seg { flex: 1; height: 6px; border-radius: 2px; background: var(--seg-empty); }
.seg.is-done { background: var(--ok-bar); }
.seg.is-part { background: var(--seg-part); }
.acard-stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); border-top: 1px solid var(--line-soft); padding-top: 10px; }
.acard-stats > span { display: flex; flex-direction: column; gap: 2px; padding: 0 12px; border-left: 1px solid var(--line-soft); min-width: 0; }
.acard-stats > span:first-child { padding-left: 0; border-left: 0; }
.acard-stats .k { color: var(--ink-2); font-size: 12px; line-height: 16px; }
.acard-stats .v { font-weight: 600; overflow-wrap: anywhere; }
.acard-stats .v .status { font-weight: 600; }

/* ---------- Compare table (scrolls inside .table-wrap, never the page) ---------- */
.table-wrap { -webkit-overflow-scrolling: touch; }
.table-wrap:focus-visible { outline-offset: -2px; }
table.cmp { table-layout: fixed; }
table.cmp th, table.cmp td { white-space: normal; vertical-align: top; overflow-wrap: anywhere; }
table.cmp thead th { vertical-align: bottom; padding-top: 6px; padding-bottom: 6px; }
table.cmp .cmp-corner { width: 200px; padding-bottom: 12px; }
table.cmp .cmp-label { font-weight: 600; color: var(--ink-2); }
table.cmp tbody th { border-bottom: 1px solid var(--line-soft); }
table.cmp tbody tr:last-child th { border-bottom: 0; }
table.cmp tbody tr:hover th { background: var(--bg-subtle); }
table.cmp tbody th::before { content: none; }
table.cmp .is-sel { background: var(--selected-bg); }
tbody tr:hover td.is-sel { background: var(--selected-bg); }
.cmp-hcell { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; width: 100%; padding: 6px 0; border: 0; background: none; color: var(--ink); text-align: left; cursor: pointer; }
.cmp-hcell .cmp-name { font-weight: 600; text-decoration: underline; text-underline-offset: 3px; text-decoration-color: var(--ink-3); }
.cmp-hcell:hover .cmp-name { color: var(--link); text-decoration-color: currentColor; }
.cmp-hcell .status { font-size: 12px; font-weight: 400; }
.status.is-flag { align-items: flex-start; font-weight: 600; }
.status.is-flag svg.i { margin-top: 2px; vertical-align: 0; }

/* ---------- Full checklist ---------- */
.dgrid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; align-items: start; }
.dkv { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); margin: 0; }
.dkv > div { padding: 0 16px 12px; border-left: 1px solid var(--line-soft); min-width: 0; }
.dkv > div:nth-child(2n+1) { border-left: 0; padding-left: 0; }
.dkv dt { color: var(--ink-2); font-size: 12px; line-height: 16px; margin-bottom: 2px; }
.dkv dd { margin: 0; overflow-wrap: anywhere; white-space: pre-line; }
.kv dd .status { vertical-align: top; }
.linkbtn { border: 0; background: none; padding: 0; color: var(--ink); font-weight: 600; cursor: pointer; text-decoration: underline; text-underline-offset: 3px; text-decoration-color: var(--ink-3); }
.linkbtn:hover { color: var(--link); text-decoration-color: currentColor; }
.badge { color: var(--ink); }

/* Photo thumbnails */
.thumbs { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 16px; }
.thumb { display: flex; flex-direction: column; gap: 6px; min-width: 0; padding: 0; border: 0; background: none; color: var(--ink); text-align: left; cursor: zoom-in; }
.thumb-img { display: block; aspect-ratio: 4 / 3; border-radius: 8px; overflow: hidden; border: 1px solid var(--line-soft); background: var(--bg-subtle); }
.thumb-img img { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb:hover .thumb-img { border-color: var(--link); box-shadow: 0 0 0 1px var(--link); }
.thumb-name { font: 12px/16px var(--mono); color: var(--ink-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- Photo lightbox as a house-style modal (a native <dialog>) ---------- */
.lb { border: 0; padding: 0; margin: auto; width: min(1100px, calc(100vw - 32px)); max-height: calc(100vh - 32px); background: var(--surface); color: var(--ink); border-radius: var(--radius-card); box-shadow: 0 8px 32px rgba(0, 0, 0, .25); overflow: hidden; }
.lb::backdrop { background: var(--backdrop); }
.lb[open] { display: flex; flex-direction: column; }
.lb-head { display: flex; align-items: center; gap: 8px; padding: 12px 12px 12px 20px; border-bottom: 1px solid var(--line-soft); }
.lb-name { flex: 1; min-width: 0; font: 600 14px/20px var(--mono); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lb-stage { flex: 1; min-height: 0; display: flex; align-items: center; justify-content: center; background: var(--stage); }
.lb-stage img { display: block; max-width: 100%; max-height: calc(100vh - 160px); object-fit: contain; }
.lb-foot { display: flex; align-items: center; gap: 8px; padding: 10px 20px; border-top: 1px solid var(--line-soft); }
.lb-count { color: var(--ink-2); white-space: nowrap; }
/* PDF export: the browser's own PDF viewer inside the same modal. */
.pdfv { height: calc(100vh - 32px); }
.pdfv-frame { flex: 1; min-height: 0; width: 100%; border: 0; background: var(--stage); }
.pdfv-warn { margin: 16px 20px; }

/* Send a checklist back to its assessor. */
.sbv { width: min(560px, calc(100vw - 32px)); }
.sbv-body { display: grid; gap: 16px; padding: 16px 20px 20px; overflow: auto; }
.sbv-lead { margin: 0; color: var(--ink-2); }
.sbv-modes { border: 0; margin: 0; padding: 0; min-width: 0; }
.sbv-modes legend { padding: 0; margin-bottom: 4px; }
.sbv .choice .muted { display: block; }
.sent-back .alert-text { display: grid; gap: 4px; }
.sent-back .sb-note { white-space: pre-line; overflow-wrap: anywhere; }

/* ---------- Staff sign-in ---------- */
/* Pinned near the top, not centred: an error message then makes the card longer downwards
   instead of moving the whole card up, which read as a shake. */
.center-page { position: relative; align-items: start; padding-top: clamp(32px, 10vh, 112px); }
.corner-theme { position: absolute; top: 12px; right: 12px; }
.auth > .brand { gap: 10px; }
.auth .card-body h1 { font-size: 24px; line-height: 30px; }
.auth .lead { margin: 4px 0 0; color: var(--ink-2); }
.auth .stack { display: grid; gap: 16px; }
.auth .input { height: 40px; width: 100%; }
.input, .select { border-color: var(--ctl-line); }
.f.invalid .input, .f.invalid .select { border-color: var(--err); }
.pw { position: relative; }
.pw .input { padding-right: 72px; }
.pw .show { position: absolute; right: 4px; top: 4px; height: 32px; }
.code-inp { font: 600 22px var(--mono); letter-spacing: .3em; text-align: center; }
.auth .card-foot { text-align: center; color: var(--ink-2); }
.auth-foot { margin: 16px 0 0; text-align: center; color: var(--ink-3); font-size: 12px; }
.alert.small { padding: 10px 12px; font-size: 13px; }

/* ---------- Phones: 44px tap targets, 16px inputs so iOS does not zoom ---------- */
@media (max-width: 720px) {
  .topnav { gap: 8px; }
  .topnav .btn, .topnav .icon-btn { min-height: 44px; }
  .topnav .brand-name { white-space: normal; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden; }
  .topnav .icon-btn { width: 44px; }
  .topnav .net.ok .net-label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  .crumbs { padding: 8px 16px; font-size: 12px; }
  .btn, .icon-btn, .btn.icon { min-height: 44px; }
  .btn.icon, .icon-btn { min-width: 44px; }
  .input, .select, textarea, .auth .input { font-size: 16px; min-height: 44px; }
  .pw .show { top: 0; right: 0; height: 44px; }
  .linkbtn { min-height: 44px; min-width: 44px; }
  .adm > .page-head .actions { width: 100%; }
  .adm > .page-head .actions .btn { flex: 1; justify-content: center; }
  .acards { grid-template-columns: minmax(0, 1fr); }
  .dgrid { grid-template-columns: minmax(0, 1fr); }
  .dkv { grid-template-columns: minmax(0, 1fr); }
  .dkv > div { border-left: 0; padding-left: 0; padding-right: 0; }
  .thumbs { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
  .card-head, .card-body { padding-left: 16px; padding-right: 16px; }
  .cmp-hcell { min-height: 44px; }
  .lb { width: 100vw; max-width: 100vw; max-height: 100dvh; height: 100dvh; border-radius: 0; }
  .lb-stage img { max-height: calc(100dvh - 130px); }
  .lb-foot { padding: 8px 12px; }
  .lb-head { padding-left: 16px; }
  .lb-head #lb-open { padding: 0 10px; min-width: 44px; justify-content: center; }
}
@media (max-width: 480px) {
  .topnav .brand-name { font-size: 13px; line-height: 15px; -webkit-line-clamp: 3; }
  .topnav .brand-sub { display: none; }
  .auth > .brand { padding-right: 40px; }
}
@media (max-width: 400px) {
  .lb-head #lb-open .lb-open-text { display: none; }
  .lb-head #pdf-download { padding: 0 10px; min-width: 44px; justify-content: center; }
  .lb-head #pdf-download .pdfv-dl-text { display: none; }
}
.auth > .brand .logo-tile { padding: 4px 6px; border-radius: 8px; }
.auth > .brand .logo-tile img { width: 40px; height: 41px; }
.auth > .brand { white-space: normal; }
.auth > .brand .brand-name { font-size: 18px; line-height: 22px; }

/* Compare table: keep the question column in view while the schools scroll sideways */
table.cmp th:first-child { position: sticky; left: 0; z-index: 1; background: var(--surface); box-shadow: 1px 0 0 var(--line-soft); }
table.cmp tbody tr:hover th:first-child { background: var(--bg-subtle); }
@media (max-width: 720px) {
  table.cmp .cmp-corner { width: 132px; }
  table.cmp th, table.cmp td { padding-left: 10px; padding-right: 10px; }
  .kv dd { margin-bottom: 8px; }
  .kv > div { padding-bottom: 6px; }
}

/* ---------- QR code for assessors: dialog, then the A4 sheet that only shows when printing ---------- */
.qrv { width: min(760px, calc(100vw - 32px)); }
.qrv-body { display: grid; grid-template-columns: minmax(0, 300px) minmax(0, 1fr); gap: 24px; padding: 20px; overflow: auto; }
/* A QR code is always dark on white, in dark mode too, or phone cameras struggle. */
.qrv-code { background: #fff; border: 1px solid var(--tile-line); border-radius: var(--radius-ctl); padding: 8px; align-self: start; }
.qrv-code svg { display: block; width: 100%; height: auto; }
.qrv-side { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.qrv-label { font-size: 11px; font-weight: 600; }
.qrv-link { display: flex; align-items: center; gap: 4px; border: 1px solid var(--ctl-line); border-radius: var(--radius-ctl); padding: 2px 2px 2px 10px; }
.qrv-link code { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.qrv-copied { font-size: 12px; color: var(--ink-2); min-height: 16px; }
.qrv-note { margin: 0; color: var(--ink-2); }
.qrv-actions { display: flex; gap: 8px; flex-wrap: wrap; }
@media (max-width: 720px) {
  .qrv { width: 100vw; }
  .qrv-body { grid-template-columns: minmax(0, 1fr); padding: 16px; }
  .qrv-code { width: min(100%, 320px); justify-self: center; }
  .qrv-actions .btn { flex: 1; justify-content: center; min-height: 44px; }
}

.qr-sheet { display: none; }
@media print {
  @page { size: A4 portrait; margin: 18mm; }
  body.print-qr { background: #fff; }
  body.print-qr > *:not(.qr-sheet) { display: none !important; }
  body.print-qr .qr-sheet { display: flex; flex-direction: column; align-items: center; text-align: center; color: #000; }
  .qr-sheet-logos { display: flex; gap: 8mm; }
  .qr-sheet-logos img { width: 22mm; height: auto; }
  .qr-sheet-kicker { margin: 8mm 0 0; font-size: 12pt; }
  .qr-sheet-title { margin: 2mm 0 0; font-size: 24pt; line-height: 1.2; }
  .qr-sheet-school { margin: 3mm 0 0; font-size: 18pt; font-weight: 600; }
  .qr-sheet-school:empty { display: none; }
  .qr-sheet-code { width: 120mm; margin-top: 8mm; }
  .qr-sheet-code svg { display: block; width: 100%; height: auto; }
  .qr-sheet-scan { margin: 6mm 0 0; font-size: 16pt; font-weight: 600; }
  .qr-sheet-url { margin: 2mm 0 0; font: 11pt/1.4 var(--mono); overflow-wrap: anywhere; }
  .qr-sheet-tip { margin: 8mm 0 0; max-width: 140mm; font-size: 11pt; color: #333; }
}

/* ---------- Dashboard, audit log and users (admin-dash.js) ---------- */
.tabs { margin-top: 4px; }
.tabpanel { display: grid; gap: 16px; }
.tabpanel[hidden] { display: none; }
/* Read out by screen readers only: the Users results and the Actions column heading. */
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.tiles { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.tile { display: grid; gap: 2px; padding: 14px 16px; background: var(--surface); border: 1px solid var(--line-soft); border-radius: var(--radius-card); }
.tile-k { color: var(--ink-2); font-size: 12px; }
.tile-v { font-size: 24px; line-height: 30px; font-weight: 600; }
.tile-sub { color: var(--ink-3); font-size: 12px; }
.cell-sub { display: block; color: var(--ink-3); font-size: 12px; overflow-wrap: anywhere; }
table.live td, table.users td, table.audit td { vertical-align: top; white-space: normal; }
.live-items { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.live-item { display: grid; gap: 2px; }
.live-school { font-weight: 600; }
.live-prog { display: flex; align-items: center; flex-wrap: wrap; }
.nowrap { white-space: nowrap; }
.pad { padding: 0 20px 16px; }
.audit-tools { display: flex; gap: 12px; flex-wrap: wrap; align-items: end; }
.audit-tools .f:first-child { flex: 1 1 260px; }
.invite-form { display: flex; gap: 12px; flex-wrap: wrap; align-items: end; }
.invite-form .f { flex: 1 1 220px; }
.invite-form .alert { flex-basis: 100%; }
.temp-kv { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 4px 12px; margin: 8px 0 0; }
.temp-kv dt { color: var(--ink-2); }
.temp-kv dd { margin: 0; overflow-wrap: anywhere; }
.uacts { display: flex; gap: 6px; flex-wrap: wrap; }
details.archived > summary { cursor: pointer; list-style: none; }
details.archived > summary::-webkit-details-marker { display: none; }
details.archived > summary h2::before { content: "▸ "; color: var(--ink-3); }
details.archived[open] > summary h2::before { content: "▾ "; }
.tabpanel > .alert, section.card > .alert, #dash-devices > .alert { margin: 0 20px 16px; }
@media (max-width: 900px) { .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 560px) {
  .tiles { grid-template-columns: minmax(0, 1fr); }
  table.live thead, table.users thead { display: none; }
  table.live tr, table.users tr { display: grid; gap: 6px; padding: 12px 0; border-bottom: 1px solid var(--line-soft); }
  table.live td, table.users td { border: 0; padding: 0 16px; }
}
