/*
 * Impact Services colours: a deep navy carrying the chrome, a clear blue doing
 * the accent work, cool greys and white for the page. Type is a grotesque
 * system stack - the gate may have no internet, so nothing is downloaded.
 */
:root {
  --brand: #1e5eb8;        /* Impact blue - buttons, links, active states */
  --brand-deep: #14468e;   /* pressed / hover blue */
  --navy: #0f2740;         /* header, primary tile, dark chrome */
  --navy-deep: #08182b;
  --amber: #2f80ed;        /* the bright accent on dark chrome */
  --ink: #16212e;
  --muted: #5b6470;
  --line: #dde3ea;
  --bg: #f2f5f9;           /* cool light grey behind the cards */
  --card: #ffffff;
  --green: #1c7c4a;

  /* Emergency red stays a hue of its own, well away from the blues. */
  --red: #b3261e;

  --radius: 10px;
  --shadow: 0 1px 2px rgba(0, 0, 0, .05), 0 8px 24px rgba(0, 0, 0, .07);
}

* { box-sizing: border-box; }

/* Author `display` rules below beat the UA sheet, so hidden has to be forced. */
[hidden] { display: none !important; }

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

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.5 "Segoe UI", system-ui, -apple-system, Arial, sans-serif;
}

/* ---------- Header / footer ---------- */

.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 20px;
  background: #fff;
  color: var(--ink);
  border-bottom: 3px solid var(--navy);
  padding-top: max(12px, env(safe-area-inset-top));
}

.brand { display: flex; align-items: center; gap: 14px; min-width: 0; }

/* The Impact Services wordmark carries the header; the site is named beside it. */
.brand-logo { display: block; height: 40px; width: auto; flex: none; }
.brand-divider { width: 1px; height: 36px; background: var(--line); flex: none; }

/* ---------- Dashboard sign-in ---------- */

.login-brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  margin-bottom: 22px;
  text-align: center;
}

.login-logo { display: block; width: 220px; max-width: 70vw; height: auto; margin-bottom: 8px; }

.login-brand h1 {
  margin: 0;
  font-size: 30px;
  line-height: 1.03;
  letter-spacing: -.02em;
  text-transform: uppercase;
}
.login-site { margin: 0; color: var(--muted); font-size: 14.5px; }
.login-heading { margin: 0 0 6px; font-size: 19px; }

.brand-text { display: flex; flex-direction: column; line-height: 1.25; min-width: 0; }
.brand-text strong { font-size: 15px; letter-spacing: .08em; text-transform: uppercase; color: var(--navy); }
.brand-text small { font-size: 12px; color: var(--muted); letter-spacing: .04em; }

.header-nav { display: flex; gap: 8px; flex-wrap: wrap; }

.nav-link {
  display: inline-block;
  padding: 9px 18px;
  border: 1px solid var(--navy);
  border-radius: 999px;
  color: var(--navy);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: .06em;
  text-transform: uppercase;
  text-decoration: none;
}

.nav-link:hover { background: var(--bg); }
.nav-link.is-current { background: var(--navy); border-color: var(--navy); color: #fff; }

.site-footer {
  margin-top: auto;
  padding: 18px 20px calc(18px + env(safe-area-inset-bottom));
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 18px;
  flex-wrap: wrap;
  font-size: 12.5px;
  color: var(--muted);
}

.powered-by { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.powered-by img { height: 18px; width: auto; }
.sidebar-powered { margin: 14px 10px 0; font-size: 12px; color: var(--muted); }

/* ---------- Layout ---------- */

.page {
  width: 100%;
  max-width: 760px;
  margin: 0 auto;
  padding: 24px 16px 8px;
}

.page-wide { max-width: 1080px; }

.intro { margin-bottom: 18px; }
.intro h1 {
  margin: 0 0 8px;
  font-size: clamp(28px, 5vw, 38px);
  line-height: 1.02;
  letter-spacing: -.02em;
  text-wrap: balance;
}
.intro p { margin: 0; color: var(--muted); }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 22px;
}

/* ---------- Form ---------- */

.field { margin-bottom: 18px; }

.field > label,
.declaration legend {
  display: block;
  margin-bottom: 7px;
  font-size: 14px;
  font-weight: 600;
  color: var(--ink);
}

.optional { font-weight: 400; color: var(--muted); }

/* Every text-like input, not just the few that happened to exist first - a
   missing type here silently falls back to the browser's own tiny default. */
input[type="text"],
input[type="date"],
input[type="time"],
input[type="password"],
input[type="url"],
input[type="email"],
input[type="tel"],
input[type="number"],
input[type="search"],
select,
textarea {
  width: 100%;
  padding: 13px 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  color: var(--ink);
  font: inherit;
  font-size: 16px; /* keeps iOS from zooming on focus */
}

textarea { resize: vertical; min-height: 62px; }

input:focus-visible,
textarea:focus-visible,
select:focus-visible,
.btn:focus-visible,
canvas:focus-visible {
  outline: 3px solid rgba(30, 94, 184, .45);
  outline-offset: 2px;
  border-color: var(--brand);
}

input.invalid, textarea.invalid { border-color: var(--red); background: #fdf1f0; }

.reg-plate {
  text-transform: uppercase;
  letter-spacing: 2px;
  font-weight: 600;
}

.field-row { display: flex; gap: 14px; }
.field-row .field { flex: 1; margin-bottom: 18px; }

.declaration {
  margin: 0 0 18px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #f4f7fb;
}

.declaration legend { padding: 0 6px; }

.checkbox {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  font-size: 15px;
  cursor: pointer;
}

.checkbox input {
  flex: none;
  width: 24px;
  height: 24px;
  margin: 1px 0 0;
  accent-color: var(--brand);
}

/* ---------- Signature ---------- */

.signature-wrap {
  position: relative;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  overflow: hidden;
}

.signature-wrap canvas {
  display: block;
  width: 100%;
  height: 190px;
  touch-action: none; /* let the canvas own the drag, not the scroller */
  cursor: crosshair;
}

.signature-hint {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: #98a2ae;
  font-size: 15px;
  pointer-events: none;
}

.signature-wrap.has-ink .signature-hint { display: none; }

.signature-baseline {
  position: absolute;
  left: 24px;
  right: 24px;
  bottom: 42px;
  border-bottom: 1px dashed #cbd3dc;
  pointer-events: none;
}

.signature-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 10px;
}

.signature-status { font-size: 13px; color: var(--muted); }

/* ---------- Buttons ---------- */

.btn {
  /* inline-flex, not inline-block: when a row stretches a link-as-button to
     match its neighbours, its label still sits in the middle. Real <button>s
     centre their content anyway; this makes an <a> behave the same. */
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 12px 20px;
  border: 1px solid transparent;
  border-radius: 999px;    /* round, like theirs */
  font: inherit;
  font-weight: 600;
  letter-spacing: .01em;
  cursor: pointer;
  background: #fff;
  color: var(--ink);
  text-decoration: none;   /* links dressed as buttons must not underline */
  text-align: center;
}

.btn-primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--brand-deep); border-color: var(--brand-deep); }
.btn-primary:disabled { opacity: .55; cursor: not-allowed; }

.btn-lg { width: 100%; padding: 17px; font-size: 18px; }

.btn-ghost { border-color: var(--line); color: var(--ink); }
.btn-ghost:hover { background: #e9edf3; }

.btn-link {
  width: 100%;
  margin-top: 10px;
  padding: 10px;
  border: 0;
  background: none;
  color: var(--muted);
  font-size: 13.5px;
  text-decoration: underline;
}

.btn-danger { background: #fff; border-color: var(--line); color: var(--red); }
.btn-danger:hover { background: #fdf1f0; }

.btn-sm { padding: 9px 14px; font-size: 14px; }

.privacy {
  margin: 4px 0 16px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
  font-size: 12.5px;
  line-height: 1.55;
  color: var(--muted);
}

.form-error {
  margin: 0 0 14px;
  padding: 12px 14px;
  border: 1px solid #f0c4c0;
  border-radius: 10px;
  background: #fdf1f0;
  color: var(--red);
  font-size: 14.5px;
  font-weight: 600;
}

/* ---------- Confirmation ---------- */

.confirm-overlay {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(0, 0, 0, .55);
  z-index: 20;
  overflow-y: auto;            /* a tall card (express lane in landscape) scrolls rather than clips */
  -webkit-overflow-scrolling: touch;
}

.confirm-overlay .confirm-card { margin: auto; }

.confirm-card {
  width: 100%;
  max-width: 400px;
  padding: 32px 26px 26px;
  border-radius: 16px;
  background: #fff;
  box-shadow: 0 20px 60px rgba(0, 0, 0, .3);
  text-align: center;
}

.confirm-card .tick { color: var(--green); }
.confirm-card h2 { margin: 8px 0 6px; font-size: 24px; }
.confirm-card p { margin: 0 0 6px; color: var(--muted); }
.confirm-note { font-size: 13.5px; }
.confirm-card .btn { margin-top: 18px; min-width: 140px; }

/* ---------- On-site table ---------- */

.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.count-pill {
  display: inline-flex;
  align-items: baseline;
  gap: 8px;
  padding: 8px 16px;
  border-radius: 999px;
  background: var(--navy);
  color: #fff;
  font-weight: 600;
}

.count-pill strong { font-size: 22px; }

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

table { width: 100%; border-collapse: collapse; font-size: 15px; }

th, td {
  padding: 13px 12px;
  text-align: left;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}

th {
  font-size: 12.5px;
  text-transform: uppercase;
  letter-spacing: .6px;
  color: var(--muted);
  white-space: nowrap;
}

tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: #f4f7fb; }

td .sub { display: block; font-size: 13px; color: var(--muted); }
td.actions { text-align: right; white-space: nowrap; }

.tag {
  display: inline-block;
  white-space: nowrap;
  padding: 3px 9px;
  border-radius: 999px;
  background: #eef2f6;
  font-size: 12.5px;
  font-weight: 600;
  letter-spacing: 1px;
}

.empty {
  padding: 46px 20px;
  text-align: center;
  color: var(--muted);
}

.empty strong { display: block; margin-bottom: 6px; font-size: 17px; color: var(--ink); }

/* ---------- Pairing a gate tablet ---------- */

.pairing-card { border-left: 4px solid var(--amber); }

/* Read aloud across a site cabin, so it has to be big and unambiguous. */
.pairing-code {
  margin: 14px 0 18px;
  font-family: "Cascadia Mono", Consolas, ui-monospace, monospace;
  font-size: clamp(30px, 7vw, 46px);
  font-weight: 700;
  letter-spacing: 6px;
  color: var(--navy);
}

.pair-code-input {
  font-family: "Cascadia Mono", Consolas, ui-monospace, monospace;
  font-size: 26px;
  font-weight: 700;
  letter-spacing: 6px;
  text-align: center;
  text-transform: uppercase;
}

.paired-state { display: flex; flex-direction: column; align-items: flex-start; gap: 10px; }
.paired-state .card-title { margin: 0; }
.paired-state .express-details { width: 100%; margin: 0; }
.paired-state .confirm-buttons { justify-content: flex-start; margin-top: 6px; }

/* ---------- Express lane for regulars ---------- */

.express {
  padding: 20px 22px;
  margin-bottom: 18px;
  border: 1px solid var(--line);
  border-left: 4px solid var(--brand);
  border-radius: var(--radius);
  background: var(--card);
  box-shadow: var(--shadow);
}

.express-head h2 { margin: 0 0 4px; font-size: 19px; }
.express-head p { margin: 0 0 14px; font-size: 14px; color: var(--muted); }

.express-form { display: flex; gap: 10px; flex-wrap: wrap; }

.express-form input {
  flex: 0 0 170px;
  padding: 14px 18px;
  font-family: "Segoe UI", system-ui, sans-serif;
  font-size: 26px;
  font-weight: 700;
  letter-spacing: 8px;
  text-align: center;
  text-indent: 8px;        /* balances the trailing letter-spacing */
  border: 1px solid var(--line);
  border-radius: 999px;    /* matches the pills beside it */
}

.express-form .btn { flex: 0 0 auto; padding-left: 22px; padding-right: 22px; }

.express .form-error { margin: 14px 0 0; }

.or-rule {
  display: flex;
  align-items: center;
  gap: 14px;
  margin: 0 0 18px;
  font-size: 13px;
  color: var(--muted);
}

.or-rule::before, .or-rule::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--line);
}

.express-card { max-width: min(480px, 100%); text-align: left; }
.express-card h2 { margin: 6px 0 2px; text-align: left; }
.express-company { margin: 0 0 16px; color: var(--muted); font-size: 14px; }

.eyebrow-tag {
  display: inline-block;
  padding: 4px 12px;
  border-radius: 999px;
  background: var(--brand);
  color: #fff;
  font-size: 12.5px;
  letter-spacing: .04em;
}

.eyebrow-tag b { letter-spacing: 2px; }

.express-details {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 6px 16px;
  margin: 0 0 16px;
  padding: 14px 16px;
  border-radius: 10px;
  background: #f4f7fb;
  font-size: 14px;
}

.express-details dt { color: var(--muted); }
.express-details dd { margin: 0; font-weight: 600; }

.express-hs { margin-bottom: 16px; font-size: 14px; }
.express-card .signature-wrap { background: #fff; }
.express-card .signature-wrap canvas { height: 150px; }

.save-regular {
  margin: 0 0 18px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #f4f7fb;
  font-size: 14px;
}

.save-regular strong { display: block; }
.save-regular small { color: var(--muted); }

.pass-issued {
  padding: 12px 14px;
  border-radius: 10px;
  background: #eaf1fb;
  color: var(--navy);
  font-size: 14px;
}

.pass-issued b { font-size: 20px; letter-spacing: 3px; }

.pass-tag { letter-spacing: 2px; font-weight: 700; }

.list-filter {
  width: auto;
  min-width: 230px;
  padding: 9px 12px;
  font-size: 14px;
}

tr.row-muted { opacity: .55; }

/* ---------- Visitor / operative choice ---------- */

.type-choice { margin: 0 0 18px; padding: 0; border: 0; }
.type-choice legend { padding: 0; }

.segmented { display: flex; gap: 12px; }

.segment { flex: 1; cursor: pointer; }
.segment input { position: absolute; opacity: 0; pointer-events: none; }

.segment span {
  display: block;
  height: 100%;
  padding: 14px;
  border: 2px solid var(--line);
  border-radius: 10px;
  background: #fff;
}

.segment strong { display: block; font-size: 15px; }
.segment small { color: var(--muted); font-size: 12.5px; line-height: 1.4; }

.segment input:checked + span { border-color: var(--brand); background: #eaf1fb; }
.segment input:focus-visible + span { outline: 3px solid rgba(30, 94, 184, .45); outline-offset: 2px; }

/* ---------- CSCS / induction block ---------- */

.card-block {
  margin: 0 0 18px;
  padding: 16px;
  border: 1px solid var(--line);
  border-left: 4px solid var(--amber);
  border-radius: 10px;
  background: #fbfcfe;
}

.card-block legend { padding: 0 6px; }
.card-block .field:last-of-type { margin-bottom: 0; }
/* A hint under a form control needs air, not the negative margin the
   dashboard uses to tuck one under a heading. Applies to every field. */
.field .hint { margin: 8px 0 0; line-height: 1.45; }

.prefill-note {
  margin: 0 0 14px;
  padding: 10px 12px;
  border-radius: 8px;
  background: #eaf1fb;
  font-size: 13px;
  color: var(--navy);
}

.input-with-action { display: flex; gap: 10px; }
.input-with-action input { flex: 1; }
.input-with-action .btn { flex: none; white-space: nowrap; }

.check-panel {
  margin: 14px 0 0;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
}

.check-panel-ok { border-color: #bfe3ce; background: #f4fbf7; }
.check-panel-warn { border-color: #f0dcb0; background: #fbfcfe; }
.check-panel-bad { border-color: #f0c4c0; background: #fdf1f0; }

.check-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.check-badge {
  display: inline-block;
  padding: 4px 12px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 700;
}

.check-badge-ok { background: #e3f3ea; color: var(--green); }
.check-badge-warn { background: #fdf4e3; color: #8a5b06; }
.check-badge-bad { background: #fdeceb; color: var(--red); }

.check-source { font-size: 12px; color: var(--muted); }
.check-message { margin: 10px 0 0; font-size: 13.5px; }

.check-details {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 4px 14px;
  margin: 12px 0 0;
  font-size: 13.5px;
}

.check-details dt { color: var(--muted); }
.check-details dd { margin: 0; font-weight: 600; }

.detail-inline { display: grid; grid-template-columns: auto 1fr; gap: 6px 18px; }
.detail-inline dt { font-size: 12.5px; align-self: center; }
.detail-inline dd { margin: 0; font-size: 14px; }

.check-result {
  margin: 14px 0 0;
  padding: 11px 13px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
}

.check-ok { background: #e9f6ef; color: var(--green); }
.check-warn { background: #fdf4e3; color: #8a5b06; }
.check-bad { background: #fdeceb; color: var(--red); }

.override-card { max-width: min(460px, 100%); text-align: left; }
.override-card h2 { text-align: center; color: var(--red); }
.override-lead { font-size: 13.5px; }

.block-list {
  margin: 0 0 16px;
  padding: 12px 14px 12px 32px;
  border-radius: 8px;
  background: #fdeceb;
  color: var(--red);
  font-size: 14px;
  font-weight: 600;
}

.block-list li + li { margin-top: 6px; }

.confirm-warning {
  padding: 10px 12px;
  border-radius: 8px;
  background: #fdf4e3;
  color: #8a5b06;
  font-size: 13.5px;
  font-weight: 600;
}

/* ---------- Live badge ---------- */

.live-badge {
  display: inline-block;
  margin-left: 6px;
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  vertical-align: 1px;
}

.live-live { background: #e3f3ea; color: var(--green); }
.live-reconnecting { background: #fdf2e0; color: #8a5b06; }
.live-polling { background: #eef2f6; color: var(--muted); }

.toolbar-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- Fire register ---------- */

.evac-banner {
  display: flex;
  align-items: baseline;
  gap: 14px;
  flex-wrap: wrap;
  padding: 14px 20px;
  background: var(--red);
  color: #fff;
  font-size: 15px;
}

.evac-banner strong {
  font-size: 19px;
  letter-spacing: .4px;
  text-transform: uppercase;
}

body.evacuating { background: #fdf0ef; }

.btn-evac { background: var(--red); border-color: var(--red); color: #fff; }
.btn-evac:hover { background: #8f1e17; border-color: #8f1e17; }
.btn-evac:disabled { opacity: .5; cursor: not-allowed; }

.btn-allclear { background: var(--green); border-color: var(--green); color: #fff; }
.btn-allclear:hover { background: #155f38; border-color: #155f38; }

.roll-summary {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-bottom: 16px;
}

.roll-stat {
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--card);
  text-align: center;
  box-shadow: var(--shadow);
}

.roll-num { display: block; font-size: 34px; font-weight: 700; line-height: 1.1; }
.roll-label { font-size: 13px; color: var(--muted); }

.roll-ok .roll-num { color: var(--green); }
.roll-missing .roll-num { color: var(--red); }
.roll-missing.is-clear .roll-num { color: var(--green); }

.marshal-line { font-size: 13.5px; color: var(--muted); }

.roll-list { display: flex; flex-direction: column; }

.roll-row {
  display: grid;
  grid-template-columns: 40px 1fr auto;
  align-items: center;
  gap: 14px;
  width: 100%;
  padding: 16px 8px;
  border: 0;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
  background: none;
  font: inherit;
  text-align: left;
}

/* Rows with no roll-call tick (the sign-out list) drop that first track,
   otherwise the name is squeezed into the 40px column meant for the circle. */
.roll-row-plain { grid-template-columns: 1fr auto; }

button.roll-row { cursor: pointer; }
button.roll-row:hover { background: #f4f7fb; }
button.roll-row:disabled { opacity: .5; }
.roll-list .roll-row:last-child { border-bottom: 0; }

.roll-row.is-accounted { background: #f3faf6; }
.roll-row.is-accounted .roll-who strong { color: var(--green); }

.roll-tick {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border: 2px solid var(--line);
  border-radius: 50%;
  color: #fff;
  font-size: 18px;
  font-weight: 700;
}

.is-accounted .roll-tick { background: var(--green); border-color: var(--green); }

.roll-who { display: flex; flex-direction: column; }
.roll-who strong { font-size: 17px; }
.roll-who .sub { font-size: 13px; color: var(--muted); }
.roll-who strong { overflow-wrap: anywhere; }
.roll-status { font-size: 13px; color: var(--muted); text-align: right; }

.confirm-buttons { display: flex; gap: 10px; justify-content: center; margin-top: 6px; }
.confirm-card .field { text-align: left; }

.print-only { display: none; }

/* ---------- Dashboard ---------- */

.dash-intro { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }

.tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 18px;
  border-bottom: 1px solid var(--line);
  overflow-x: auto;
}

.tab {
  padding: 11px 16px;
  border: 0;
  border-bottom: 3px solid transparent;
  background: none;
  color: var(--muted);
  font: inherit;
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
}

.tab:hover { color: var(--ink); }
.tab.is-active { color: var(--navy); border-bottom-color: var(--amber); }

.tab-panel { display: flex; flex-direction: column; gap: 16px; }

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

.stat-card {
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--card);
  box-shadow: var(--shadow);
}

.stat-primary { background: var(--navy); border-color: var(--navy); color: #fff; }
.stat-primary .stat-label { color: rgba(255, 255, 255, .65); }

.stat-num { display: block; font-size: 30px; font-weight: 700; line-height: 1.15; }
.stat-label { font-size: 13px; color: var(--muted); }

.warn-strip {
  display: flex;
  align-items: baseline;
  gap: 10px;
  padding: 14px 16px;
  border: 1px solid #f0dcb0;
  border-radius: var(--radius);
  background: #fdf7ea;
  font-size: 14px;
}

.warn-strip strong { font-size: 20px; color: #8a5b06; }

.split { display: grid; grid-template-columns: 1.4fr 1fr; gap: 16px; }

.card-title { margin: 0 0 14px; font-size: 16px; }

.hint { margin: -6px 0 16px; font-size: 13.5px; color: var(--muted); }

code {
  padding: 1px 5px;
  border-radius: 4px;
  background: #eef2f6;
  font-size: 12.5px;
}

.bar-chart {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  gap: 10px;
  align-items: end;
  height: 190px;
}

.bar-col { display: grid; grid-template-rows: auto 1fr auto; gap: 6px; height: 100%; }
.bar-value { font-size: 13px; font-weight: 600; text-align: center; }

.bar {
  align-self: end;
  width: 100%;
  min-height: 3px;
  border-radius: 6px 6px 0 0;
  background: linear-gradient(180deg, var(--brand), var(--brand-deep));
}

.bar-label { font-size: 12px; color: var(--muted); text-align: center; }

.filters { display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-end; }
.filters .field { margin-bottom: 0; }
.filters .grow { flex: 1; min-width: 200px; }
.filters .checkbox-field { padding-bottom: 8px; }
.filter-actions { display: flex; gap: 8px; margin-left: auto; }

.result-line { margin: 0 0 12px; font-size: 13.5px; color: var(--muted); }

th.num, td.num { text-align: right; }

.pill {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 12.5px;
  font-weight: 600;
}

.pill-ok { background: #e3f3ea; color: var(--green); }
.pill-bad { background: #fdeceb; color: var(--red); }
.pill-warn { background: #fdf4e3; color: #8a5b06; }
.pill + .pill { margin-left: 5px; }
td .pill { margin-top: 3px; }

.stat-alert { border-color: #e7b7b2; background: #fdf1f0; }
.stat-alert .stat-num { color: var(--red); }

tr.row-attention { background: #fffaf3; }
tr.row-attention:hover { background: #fdf4e3; }

.inline-check { font-size: 13.5px; white-space: nowrap; }
.inline-check input { width: 20px; height: 20px; }

.form-ok {
  margin: 0 0 14px;
  padding: 12px 14px;
  border: 1px solid #bfe3ce;
  border-radius: 10px;
  background: #f1faf5;
  color: var(--green);
  font-size: 14.5px;
  font-weight: 600;
}

td.actions .btn + .btn { margin-left: 6px; }

/* ---------- Detail drawer ---------- */

.drawer-overlay {
  position: fixed;
  inset: 0;
  display: flex;
  justify-content: flex-end;
  background: rgba(0, 0, 0, .45);
  z-index: 30;
}

.drawer {
  width: min(460px, 100%);
  height: 100%;
  padding: 22px;
  background: #fff;
  overflow-y: auto;
  box-shadow: -12px 0 40px rgba(0, 0, 0, .25);
}

.drawer-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.drawer-head h2 { margin: 0; font-size: 21px; }

.detail-list { display: grid; grid-template-columns: 1fr; gap: 0; margin: 0; }
.detail-list dt { font-size: 12.5px; text-transform: uppercase; letter-spacing: .5px; color: var(--muted); }
.detail-list dd { margin: 2px 0 14px; font-size: 15px; }

.detail-signature h3 { margin: 6px 0 8px; font-size: 14px; }

.detail-signature img {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
}

@media (max-width: 860px) {
  .split { grid-template-columns: 1fr; }
}

@media (max-width: 560px) {
  .roll-summary { grid-template-columns: 1fr; }
  .roll-row:not(.roll-row-plain) { grid-template-columns: 34px 1fr; }
  .roll-row:not(.roll-row-plain) .roll-status { grid-column: 2; text-align: left; }
  .filter-actions { margin-left: 0; }
}

@media (max-width: 560px) {
  .field-row { flex-direction: column; gap: 0; }
  .site-header { flex-wrap: wrap; }
}

@media print {
  .site-header, .site-footer, .toolbar .btn, .toolbar-actions, .header-nav,
  .live-badge, .tabs, .drawer-overlay, .confirm-overlay, td.actions, th.actions,
  .btn-link { display: none !important; }

  body, body.evacuating { background: #fff; }
  .card { border: 0; box-shadow: none; padding: 0; }
  .print-only { display: block; }
  .print-sign-off { margin-top: 26px; font-size: 13px; }

  /* A printed roll-call is ticked by hand, so the marker must be an empty box. */
  .roll-row { break-inside: avoid; padding: 10px 0; }
  .roll-tick { border-radius: 4px; border-color: #000; background: #fff !important; color: #000; }
  .roll-summary { break-inside: avoid; }
  .roll-stat, .stat-card { box-shadow: none; }
  .stat-primary { background: #fff; color: #000; border-color: #000; }
  .stat-primary .stat-label { color: #000; }
  .evac-banner { background: #fff; color: #000; border-bottom: 2px solid #000; }
}

/* ---------- Contact numbers (security / evacuation) ---------- */

.phone-link,
.roll-phone {
  display: inline-block;
  font-weight: 600;
  color: var(--navy);
  text-decoration: none;
  white-space: nowrap;
}

.phone-link:hover, .roll-phone:hover { text-decoration: underline; }

/* On the roll-call the number sits under the name, big enough to tap. */
.roll-phone { margin-top: 4px; font-size: 15px; }

/* ---------- Site induction ---------- */

.ind-person { margin-bottom: 18px; }
.ind-person .field-row { align-items: flex-start; }
.ind-person .hint { margin: 0; }
.ind-type { margin-bottom: 18px; }
.ind-type legend {
  display: block;
  margin-bottom: 7px;
  font-size: 14px;
  font-weight: 600;
}

.ind-progress {
  display: flex;
  align-items: center;
  gap: 14px;
  margin: 0 0 14px;
  font-size: 14px;
  font-weight: 600;
  color: var(--muted);
}
.ind-progress-bar {
  flex: 1;
  height: 8px;
  border-radius: 4px;
  background: var(--line);
  overflow: hidden;
}
.ind-progress-bar span {
  display: block;
  height: 100%;
  width: 0;
  background: var(--brand);
  transition: width .3s ease;
}

.ind-doc { padding: 0; overflow: hidden; margin-bottom: 14px; }
.ind-doc.is-read { border-color: #bfe0cd; }

.ind-doc-head {
  display: flex;
  gap: 14px;
  align-items: center;
  padding: 16px 18px;
  cursor: pointer;
}
.ind-doc-num {
  flex: none;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--navy);
  color: #fff;
  font-weight: 700;
}
.ind-doc.is-read .ind-doc-num { background: var(--green); }
.ind-doc-text { flex: 1; min-width: 0; }
.ind-doc-text h2 { margin: 0 0 3px; font-size: 18px; }
.ind-doc-text p { margin: 0; font-size: 14px; color: var(--muted); }
.ind-doc-status {
  flex: none;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .04em;
  padding: 5px 9px;
  border-radius: 999px;
  background: #e9edf3;
  color: var(--muted);
}
.ind-doc-status.is-read { background: #e9f6ef; color: var(--green); }
.ind-doc-open { flex: none; }

.ind-doc-body { border-top: 1px solid var(--line); padding: 18px; }
.ind-loading { color: var(--muted); }

.ind-content { font-size: 16px; line-height: 1.55; }
.ind-content h3 { margin: 24px 0 8px; font-size: 17px; }
.ind-content h3:first-child { margin-top: 0; }
.ind-content p { margin: 0 0 10px; }
.ind-content ul { margin: 0 0 12px; padding-left: 22px; }
.ind-content li { margin: 6px 0; }
.ind-content a { color: var(--brand-deep); }

.ind-key {
  margin: 0 0 18px;
  padding: 14px 16px;
  border-left: 4px solid var(--brand);
  border-radius: 8px;
  background: #f4f7fb;
}
.ind-key h3 { margin: 0 0 8px; }
.ind-key ul { margin-bottom: 0; }
.ind-big li { font-size: 17px; margin: 8px 0; }

.ind-callout {
  margin: 0 0 12px;
  padding: 12px 16px;
  border-radius: 8px;
  background: #fdf4e3;
}
.ind-callout p:last-child { margin-bottom: 0; }
.ind-warn { background: #fdeceb; color: var(--red); }
.ind-todo { background: #eef2f7; border: 1px dashed #9aa6b5; }

.ind-figure { margin: 14px 0 18px; }
.ind-figure img {
  display: block;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
}
.ind-figure figcaption { margin-top: 6px; font-size: 13px; color: var(--muted); }
.ind-img-missing { min-height: 60px; background: #e9edf3; }

.ind-table { width: 100%; border-collapse: collapse; font-size: 15px; margin: 0 0 14px; }
.ind-table th, .ind-table td { padding: 8px 10px 8px 0; vertical-align: top; border-bottom: 1px solid var(--line); }
.ind-table th { text-align: left; width: 34%; }

.ind-note { font-size: 14px; color: var(--muted); }
.ind-source { margin: 18px 0 14px; font-size: 13px; color: var(--muted); }
.ind-source a { color: var(--brand-deep); }

.ind-declare .checkbox { margin-bottom: 18px; }
.ind-declare .form-error { margin-bottom: 12px; }

@media (max-width: 560px) {
  .ind-doc-head { flex-wrap: wrap; }
  .ind-doc-text { flex-basis: calc(100% - 48px); }
  .ind-doc-status { margin-left: 48px; }
}

/* Sign-in form: the induction box */
.induction-block { border-left: 4px solid var(--brand); }
.induction-block.is-done { border-left-color: var(--green); }
.induction-status { margin: 0 0 12px; font-size: 14.5px; line-height: 1.45; color: var(--muted); }
.induction-block.is-done .induction-status { color: var(--green); font-weight: 600; }
.induction-actions { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.induction-actions .btn-link { padding: 0; }
.express-induct, .override-induct { width: 100%; margin: 0 0 14px; }

/* Dashboard: induction pack and records */
.pack-docs { margin: 0 0 12px; padding-left: 20px; font-size: 14.5px; }
.pack-docs li { margin: 4px 0; }
.pack-docs a { color: var(--brand-deep); }
.detail-induction .pack-docs { margin-top: 8px; }
.detail-declaration {
  margin: 10px 0;
  padding: 10px 12px;
  border-left: 3px solid var(--line);
  font-size: 13.5px;
  font-style: italic;
  color: var(--muted);
}

/* Dashboard: tablet connections */
.stat-link {
  font: inherit;
  text-align: left;
  cursor: pointer;
  color: inherit;
}
.stat-link:hover { border-color: var(--brand); }
.stat-num small { font-size: 16px; font-weight: 600; color: var(--muted); }

.conn-strip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
  margin: 0 0 16px;
  padding: 12px 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--card);
}
.conn-count { display: flex; align-items: center; gap: 10px; font-size: 15px; }
.conn-count strong { font-size: 22px; }
.conn-detail { font-size: 13px; color: var(--muted); }
.conn-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #c3cbd5;
  box-shadow: 0 0 0 3px rgba(0, 0, 0, .04);
}
.conn-all { background: var(--green); box-shadow: 0 0 0 3px rgba(28, 124, 74, .18); }
.conn-some { background: #d9a012; box-shadow: 0 0 0 3px rgba(217, 160, 18, .2); }
.conn-zero { background: var(--red); box-shadow: 0 0 0 3px rgba(164, 35, 27, .18); }
.pill-muted { background: #e9edf3; color: var(--muted); }

/* ---------- Dashboard shell: sidebar navigation ---------- */

.dash {
  display: grid;
  grid-template-columns: 236px minmax(0, 1fr);
  min-height: calc(100vh - 70px);
}

.sidebar {
  position: sticky;
  top: 0;
  align-self: start;
  height: 100vh;
  display: flex;
  flex-direction: column;
  padding: 18px 14px;
  background: var(--card);
  border-right: 1px solid var(--line);
  overflow-y: auto;
}

.sidebar-user { padding: 4px 10px 14px; display: flex; flex-direction: column; gap: 8px; }
.sidebar-who { font-size: 13px; color: var(--muted); }
.sidebar-who strong { color: var(--ink); }
.sidebar .live-badge { align-self: flex-start; }
.sidebar-logout { margin: auto 0 0; align-self: stretch; }

.dash .tabs {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin: 0 0 18px;
  border: 0;
  overflow: visible;
}
.nav-group {
  margin: 12px 10px 4px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--muted);
}
.dash .tab {
  text-align: left;
  padding: 10px 12px;
  border: 0;
  border-left: 3px solid transparent;
  border-radius: 0 8px 8px 0;
  color: var(--muted);
  white-space: normal;
}
.dash .tab:hover { background: var(--bg); color: var(--ink); }
.dash .tab.is-active { background: #e6effb; color: var(--brand-deep); border-left-color: var(--brand); }

.dash-main {
  min-width: 0;
  padding: 22px 28px 40px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.dash-top { display: flex; align-items: center; gap: 14px; margin-bottom: 4px; }
.dash-top h1 { margin: 0; font-size: clamp(24px, 3vw, 30px); letter-spacing: -.02em; }

.sidebar-toggle {
  display: none;
  width: 42px;
  height: 42px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--card);
  cursor: pointer;
  flex-direction: column;
  justify-content: space-between;
}
.sidebar-toggle span { display: block; height: 3px; border-radius: 2px; background: var(--ink); }

.changes-strip {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  padding: 10px 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--card);
  font-size: 14px;
  color: var(--muted);
}
.changes-strip strong { font-size: 20px; color: var(--ink); }
.changes-strip .btn-link { padding: 0; margin-left: auto; }

@media (max-width: 860px) {
  .dash { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: min(280px, 85vw);
    z-index: 40;
    transform: translateX(-100%);
    transition: transform .2s ease;
    box-shadow: 0 0 40px rgba(0, 0, 0, .25);
  }
  body.sidebar-open .sidebar { transform: none; }
  .sidebar-toggle { display: flex; }
  .dash-main { padding: 16px 14px 32px; }
}

/* Express lane: one box for a pass number, name, mobile or email */
.express-identify input {
  flex: 1 1 260px;
  font-size: 18px;
  font-weight: 600;
  letter-spacing: 0;
  text-align: left;
  text-indent: 0;
}
.express-identify input#identify-company { flex-basis: 100%; font-weight: 500; }

.express-welcome {
  margin: -8px 0 14px;
  padding: 10px 14px;
  border-radius: 10px;
  background: #e8f1fd;
  color: var(--brand-deep);
  font-size: 14px;
}

.express-declaration { margin: 0 0 10px; font-size: 13px; color: var(--muted); line-height: 1.45; }
.express-card .signature-field label b { color: var(--navy); }
.optional { font-weight: 400; color: var(--muted); font-size: 12.5px; }

/* Simple type buttons: no subtitle, just the choice */
.segmented-simple .segment span { justify-content: center; text-align: center; padding: 16px 12px; }
.segmented-simple .segment strong { font-size: 17px; }

/* Induction: the document's own pages */
.ind-pages { display: flex; flex-direction: column; gap: 14px; margin: 0 0 18px; }
.ind-page {
  margin: 0;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  min-height: 200px;
}
.ind-page img { display: block; width: 100%; height: auto; min-height: 200px; background: #fff; }
.ind-page:not(.is-loaded) img { opacity: 0; min-height: 60vw; }
.ind-page-num { padding: 6px 10px; font-size: 12px; color: var(--muted); text-align: right; }
.ind-page.is-failed { border-color: var(--red); }
.ind-page.is-failed .ind-page-num { color: var(--red); text-align: left; }
.ind-page-num .btn { margin-left: 8px; vertical-align: middle; }
.ind-confirm:disabled { opacity: .6; cursor: wait; }

/* Site manager PIN gate: who's on site and the fire register on a tablet */
.pin-gate {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: center;
  padding: 20px;
  background: var(--bg);        /* opaque: nothing behind it is readable */
  overflow-y: auto;
}

.pin-card {
  width: 100%;
  max-width: 420px;
  padding: 32px 28px 26px;
  border-radius: 16px;
  background: #fff;
  border: 1px solid var(--line);
  box-shadow: 0 20px 60px rgba(15, 39, 64, .12);
  text-align: center;
}

.pin-card h2 { margin: 12px 0 6px; }
.pin-lead { margin: 0 0 18px; color: var(--muted); font-size: 14px; }

#pin-input {
  width: 100%;
  padding: 14px 18px;
  margin-bottom: 14px;
  font-size: 30px;
  font-weight: 700;
  letter-spacing: 12px;
  text-align: center;
  text-indent: 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
}

.pin-card .confirm-buttons { justify-content: center; }
@media print { .pin-gate { display: none; } }

/* Records taken while the tablet was offline, waiting to upload */
.queue-bar {
  position: sticky;
  top: 0;
  z-index: 15;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 16px;
  background: #fff6e5;
  border-bottom: 1px solid #f0d9a8;
  color: #6b4b12;
  font-size: 14px;
}

.queue-bar-bad { background: #fdf1f0; border-bottom-color: #f0c4c0; color: var(--red); }
.queue-text { font-weight: 600; }

.queue-card { max-width: min(460px, 100%); text-align: left; }
.queue-card h2 { text-align: left; margin: 0 0 6px; }
.queue-lead { margin: 0 0 14px; font-size: 14px; color: var(--muted); }

.queue-list { list-style: none; margin: 0 0 18px; padding: 0; display: grid; gap: 8px; }

.queue-item {
  display: grid;
  gap: 2px;
  padding: 10px 12px;
  border-radius: 10px;
  background: #f4f7fb;
  font-size: 14px;
}

.queue-item span { color: var(--muted); font-size: 13px; }
.queue-item-bad { background: #fdf1f0; }
.queue-item-bad span { color: var(--red); }
.queue-item .btn { justify-self: start; margin-top: 4px; }

@media print { .queue-bar { display: none; } }

/* Android 15 and later draw the status and navigation bars over the app, so
   the fixed furniture keeps itself clear of them. Zero everywhere else. */
.site-header { padding-top: calc(12px + env(safe-area-inset-top, 0px)); }
.site-footer { padding-bottom: calc(14px + env(safe-area-inset-bottom, 0px)); }
.queue-bar { top: env(safe-area-inset-top, 0px); }
.page, .dash-main { padding-bottom: calc(32px + env(safe-area-inset-bottom, 0px)); }
