* { box-sizing: border-box; }
[hidden] { display: none !important; }

:root {
  --c-bg:        #f4f6fa;
  --c-surface:   #ffffff;
  --c-text:      #0f1e2e;
  --c-text-mute: #5a6a82;
  --c-line:      #e3e8ef;
  --c-line-soft: #eef1f6;

  /* Sidebar background — stays this navy regardless of client theming so the
     white sidebar text is always legible. Client colours only override the
     prominent accents below. */
  --c-nav-bg:    #0a2f55;

  /* Client-themable primary (hero numbers, buttons, accents). Overridden at
     runtime by app.js applyClientTheme() based on dbo.Client.Colour. */
  --c-primary:    #0d3b66;
  --c-primary-d:  #0a2d4f;

  --c-fit:        #1f9d7e;
  --c-restricted: #6cc4a8;
  --c-followup:   #e0a33a;
  --c-unfit:      #d8533f;
  --c-pending:    #c5cbd6;
  --c-grey:       #5a6a82;

  --c-warn:       #e0a33a;
  --c-alert:      #d8533f;
  --c-ok:         #1f9d7e;

  --shadow-card: 0 1px 2px rgba(15,30,46,0.04), 0 0 0 1px rgba(15,30,46,0.05);

  --sidebar-w: 240px;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  background: var(--c-bg);
  color: var(--c-text);
  line-height: 1.4;
  font-size: 14px;
}

button {
  font-family: inherit;
  cursor: pointer;
  background: var(--c-primary);
  color: white;
  border: none;
  padding: 8px 16px;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 500;
}
button:hover { background: var(--c-primary-d); }

/* ---- Full-screen sign-in / error fallback ---------------------------- */
.fullscreen {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 24px;
}
.error-card {
  background: var(--c-surface);
  border-radius: 12px;
  padding: 40px;
  max-width: 460px;
  text-align: center;
  box-shadow: var(--shadow-card);
}
.error-card h2 {
  margin: 0 0 12px 0;
  font-size: 20px;
  color: var(--c-primary);
}
.error-card p {
  margin: 0 0 24px 0;
  color: var(--c-text-mute);
}

/* ====================================================================== */
/* ---- LANDING PAGE (split-screen sign-in) ---------------------------- */
/* ====================================================================== */
.landing {
  position: fixed;
  inset: 0;
  display: grid;
  grid-template-columns: 1.2fr 1fr;
  background: var(--c-bg);
  overflow: hidden;
  z-index: 50;
  animation: landing-fade-in 400ms ease-out;
}
@keyframes landing-fade-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}
@media (max-width: 900px) {
  .landing { grid-template-columns: 1fr; grid-template-rows: auto 1fr; overflow-y: auto; }
}

/* ---- Left panel (brand + value) ------------------------------------- */
.landing-left {
  position: relative;
  background: linear-gradient(135deg, #0a2f55 0%, #0d3b66 50%, #1c5a93 100%);
  color: white;
  padding: 64px 72px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  overflow: hidden;
}
@media (max-width: 1100px) { .landing-left { padding: 48px 40px; } }
@media (max-width: 600px)  { .landing-left { padding: 40px 24px; } }

.landing-bg {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
}
.orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(60px);
  opacity: 0.32;
  animation: orb-drift 14s ease-in-out infinite alternate;
}
.orb-1 {
  width: 360px; height: 360px;
  background: #2ea391;
  top: -80px; left: -80px;
}
.orb-2 {
  width: 280px; height: 280px;
  background: #e0a33a;
  bottom: -60px; right: -40px;
  animation-delay: -5s;
}
.orb-3 {
  width: 220px; height: 220px;
  background: #6cc4a8;
  top: 40%; right: 12%;
  opacity: 0.18;
  animation-delay: -9s;
}
@keyframes orb-drift {
  from { transform: translate(0, 0); }
  to   { transform: translate(40px, -30px); }
}

.brand-stack { position: relative; z-index: 1; }
.brand-mark-xl {
  font-size: 40px;
  font-weight: 800;
  letter-spacing: -1px;
  line-height: 1;
}
.brand-tagline {
  font-size: 13px;
  color: rgba(255,255,255,0.75);
  text-transform: uppercase;
  letter-spacing: 1.5px;
  margin-top: 6px;
  font-weight: 600;
}

.landing-headline {
  position: relative;
  z-index: 1;
  margin: 56px 0 24px 0;
  font-size: 52px;
  line-height: 1.05;
  font-weight: 700;
  letter-spacing: -1.2px;
  color: white;
}
.landing-headline .accent {
  color: #6cc4a8;
  background: linear-gradient(90deg, #6cc4a8 0%, #2ea391 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}
@media (max-width: 1100px) { .landing-headline { font-size: 40px; } }
@media (max-width: 600px)  { .landing-headline { font-size: 32px; margin-top: 32px; } }

.landing-lead {
  position: relative;
  z-index: 1;
  font-size: 17px;
  line-height: 1.55;
  color: rgba(255,255,255,0.82);
  max-width: 560px;
  margin: 0 0 36px 0;
}

.landing-points {
  position: relative;
  z-index: 1;
  list-style: none;
  padding: 0;
  margin: 0 0 40px 0;
  display: flex;
  flex-direction: column;
  gap: 20px;
  max-width: 540px;
}
.landing-points li {
  display: grid;
  grid-template-columns: 12px 1fr;
  gap: 16px;
  align-items: start;
}
.point-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #6cc4a8;
  margin-top: 6px;
  box-shadow: 0 0 0 4px rgba(108,196,168,0.22);
}
.point-body strong {
  display: block;
  font-size: 16px;
  font-weight: 600;
  color: white;
  margin-bottom: 4px;
  letter-spacing: -0.2px;
}
.point-body span {
  display: block;
  font-size: 14px;
  color: rgba(255,255,255,0.7);
  line-height: 1.5;
}

.landing-foot {
  position: relative;
  z-index: 1;
  font-size: 13px;
  color: rgba(255,255,255,0.6);
  padding-top: 24px;
  border-top: 1px solid rgba(255,255,255,0.1);
}
.landing-foot strong { color: rgba(255,255,255,0.85); font-weight: 600; }

/* ---- Right panel (sign-in card) ------------------------------------- */
.landing-right {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px;
  background: linear-gradient(180deg, #f7f9fc 0%, #eef2f8 100%);
}
@media (max-width: 600px) { .landing-right { padding: 32px 24px 48px 24px; } }

.signin-card {
  background: white;
  border-radius: 16px;
  padding: 48px;
  max-width: 420px;
  width: 100%;
  box-shadow:
    0 1px 2px rgba(15,30,46,0.04),
    0 8px 24px rgba(15,30,46,0.06),
    0 0 0 1px rgba(15,30,46,0.04);
}
@media (max-width: 600px) { .signin-card { padding: 32px 28px; } }

.signin-eyebrow {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  color: var(--c-primary);
  margin-bottom: 12px;
}
.signin-card h2 {
  margin: 0 0 10px 0;
  font-size: 30px;
  font-weight: 700;
  letter-spacing: -0.8px;
  color: var(--c-text);
}
.signin-card p {
  margin: 0 0 28px 0;
  font-size: 15px;
  color: var(--c-text-mute);
  line-height: 1.5;
}

.signin-btn {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 14px 20px;
  font-size: 15px;
  font-weight: 600;
  background: var(--c-primary);
  color: white;
  border: none;
  border-radius: 10px;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(13,59,102,0.25);
  transition: transform 120ms ease, box-shadow 120ms ease, background 120ms ease;
}
.signin-btn:hover {
  background: var(--c-primary-d);
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgba(13,59,102,0.32);
}
.signin-btn:active {
  transform: translateY(0);
  box-shadow: 0 2px 8px rgba(13,59,102,0.22);
}
.signin-btn .arrow {
  font-size: 18px;
  transition: transform 120ms ease;
}
.signin-btn:hover .arrow { transform: translateX(3px); }

.signin-help {
  margin-top: 24px;
  padding-top: 20px;
  border-top: 1px solid var(--c-line);
  font-size: 12px;
  line-height: 1.55;
  color: var(--c-text-mute);
}
.signin-help strong { color: var(--c-text); font-weight: 600; }

/* ---- Command-centre landing additions ------------------------------- */
.brand-pipe {
  font-weight: 300;
  opacity: 0.55;
  margin: 0 6px;
}
.brand-stack { position: relative; z-index: 1; }
.brand-bar {
  display: flex;
  align-items: center;
  gap: 14px;
  color: rgba(255,255,255,0.85);
  margin-bottom: 16px;
}
.brand-cross {
  color: #6cc4a8;
  filter: drop-shadow(0 0 8px rgba(108,196,168,0.55));
}
.brand-status {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: rgba(255,255,255,0.85);
  padding: 4px 10px 4px 8px;
  border: 1px solid rgba(108,196,168,0.4);
  border-radius: 999px;
  background: rgba(108,196,168,0.08);
  font-weight: 600;
}
.pulse-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #6cc4a8;
  box-shadow: 0 0 0 0 rgba(108,196,168,0.5);
  animation: pulse-ring 1.8s ease-out infinite;
}
@keyframes pulse-ring {
  0%   { box-shadow: 0 0 0 0 rgba(108,196,168,0.55); }
  70%  { box-shadow: 0 0 0 9px rgba(108,196,168,0); }
  100% { box-shadow: 0 0 0 0 rgba(108,196,168,0); }
}

/* EKG line drifting across the landing background */
.landing-bg .ekg {
  position: absolute;
  inset: auto 0 14% 0;
  width: 200%;
  height: 220px;
  opacity: 0.5;
  animation: ekg-drift 18s linear infinite;
}
@keyframes ekg-drift {
  from { transform: translateX(0); }
  to   { transform: translateX(-50%); }
}
/* Small status dots scattered in the bg */
.landing-bg .dot {
  position: absolute;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #6cc4a8;
  opacity: 0.4;
  box-shadow: 0 0 0 6px rgba(108,196,168,0.06);
}
.landing-bg .dot-1 { top: 18%; left: 12%; }
.landing-bg .dot-2 { top: 64%; left: 38%; background: #e0a33a; box-shadow: 0 0 0 6px rgba(224,163,58,0.08); }
.landing-bg .dot-3 { top: 30%; left: 70%; background: #d8533f; box-shadow: 0 0 0 6px rgba(216,83,63,0.08); }

/* ---- Hero card ribbon (OCH / PHC tags on Overview) ----------------- */
.hero-card { position: relative; overflow: hidden; }
.ribbon {
  position: absolute;
  top: 14px;
  right: 14px;
  background: var(--c-primary);
  color: white;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 1.2px;
  padding: 3px 8px;
  border-radius: 999px;
}
.ribbon-alt { background: var(--c-fit); }

/* ---- Service-area banner (top of OCH / PHC pages) ------------------ */
.service-banner {
  position: relative;
  padding: 24px 28px;
  border-radius: 14px;
  color: white;
  margin-bottom: 24px;
  overflow: hidden;
  box-shadow: var(--shadow-card);
}
.service-banner::after {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 90% 30%, rgba(255,255,255,0.18), transparent 50%);
  pointer-events: none;
}
.service-banner .banner-eyebrow {
  font-size: 11px;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: rgba(255,255,255,0.78);
  font-weight: 600;
  margin-bottom: 6px;
}
.service-banner h2 {
  margin: 0 0 6px 0;
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -0.4px;
  color: white;
}
.service-banner p {
  margin: 0;
  color: rgba(255,255,255,0.86);
  font-size: 14px;
  max-width: 60ch;
}
.och-banner { background: linear-gradient(135deg, #0a2f55 0%, #0d3b66 55%, #1a6f8e 100%); }
.phc-banner { background: linear-gradient(135deg, #0e5947 0%, #1f9d7e 55%, #4ec0a3 100%); }

/* ---- Card-note (small italic helper text under a card) ------------ */
.card-note {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px dashed var(--c-line);
  font-size: 12px;
  color: var(--c-text-mute);
  line-height: 1.5;
}
.card-note em { font-style: italic; }
.card-note code {
  background: var(--c-line-soft);
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 11px;
  color: var(--c-text);
}
.card-pill {
  display: inline-block;
  background: var(--c-primary);
  color: white;
  font-size: 13px;
  font-weight: 700;
  padding: 2px 12px;
  border-radius: 999px;
  margin-left: 8px;
  vertical-align: 2px;
  font-variant-numeric: tabular-nums;
}

/* ---- Kiosk exit floating button ----------------------------------- */
.kiosk-exit {
  position: fixed;
  top: 18px;
  right: 22px;
  display: none;                  /* shown only when body.kiosk */
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  background: rgba(15, 30, 46, 0.85);
  backdrop-filter: blur(6px);
  color: white;
  border: 1px solid rgba(255,255,255,0.18);
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.3px;
  z-index: 250;
  cursor: pointer;
  transition: background 120ms ease, transform 120ms ease;
}
.kiosk-exit:hover {
  background: rgba(15, 30, 46, 0.95);
  transform: translateY(-1px);
}
body.kiosk .kiosk-exit { display: inline-flex; }
body.kiosk::after { display: none; } /* hide the small Esc text — explicit button replaces it */

/* ====================================================================== */
/* ---- TERMS & CONDITIONS MODAL ---------------------------------------- */
/* ====================================================================== */
.terms-overlay {
  position: fixed;
  inset: 0;
  background: rgba(10, 24, 40, 0.55);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 300;
  padding: 24px;
  animation: landing-fade-in 200ms ease-out;
}
.terms-card {
  background: white;
  border-radius: 16px;
  max-width: 720px;
  width: 100%;
  max-height: calc(100vh - 48px);
  display: flex;
  flex-direction: column;
  box-shadow:
    0 1px 2px rgba(15,30,46,0.04),
    0 24px 48px rgba(15,30,46,0.18);
  overflow: hidden;
}
.terms-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: 24px 32px 20px 32px;
  border-bottom: 1px solid var(--c-line);
}
.terms-eyebrow {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  color: var(--c-primary);
  margin-bottom: 6px;
}
.terms-head h2 {
  margin: 0;
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.5px;
  color: var(--c-text);
}
.terms-version {
  font-size: 11px;
  color: var(--c-text-mute);
  font-variant-numeric: tabular-nums;
  text-align: right;
  padding-top: 6px;
}
.terms-body {
  padding: 24px 32px;
  overflow-y: auto;
  font-size: 14px;
  line-height: 1.6;
  color: var(--c-text);
  flex: 1;
}
.terms-body h1, .terms-body h2, .terms-body h3 {
  color: var(--c-primary);
  letter-spacing: -0.3px;
}
.terms-body h1 { display: none; }            /* h1 inside body is redundant with modal title */
.terms-body h2 { font-size: 16px; margin: 24px 0 10px 0; font-weight: 700; }
.terms-body h3 { font-size: 14px; margin: 16px 0 6px 0; font-weight: 600; }
.terms-body p { margin: 8px 0; }
.terms-body ul { padding-left: 22px; margin: 8px 0; }
.terms-body li { margin: 4px 0; }
.terms-body strong { color: var(--c-text); font-weight: 700; }
.terms-body hr {
  border: none;
  border-top: 1px solid var(--c-line);
  margin: 20px 0;
}
.terms-body::-webkit-scrollbar { width: 8px; }
.terms-body::-webkit-scrollbar-track { background: transparent; }
.terms-body::-webkit-scrollbar-thumb { background: var(--c-line); border-radius: 4px; }
.terms-body::-webkit-scrollbar-thumb:hover { background: var(--c-text-mute); }

.terms-foot {
  padding: 20px 32px 24px 32px;
  border-top: 1px solid var(--c-line);
  background: #fafbfd;
}
.terms-check {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
  font-size: 14px;
  color: var(--c-text);
  cursor: pointer;
  user-select: none;
}
.terms-check input[type="checkbox"] {
  width: 18px;
  height: 18px;
  cursor: pointer;
  accent-color: var(--c-primary);
}
#terms-accept[disabled] {
  background: var(--c-line);
  color: var(--c-text-mute);
  cursor: not-allowed;
  box-shadow: none;
  transform: none;
}
#terms-accept[disabled]:hover { background: var(--c-line); }
.terms-error {
  margin-top: 12px;
  padding: 10px 14px;
  background: #fdecea;
  border-left: 3px solid var(--c-alert);
  border-radius: 4px;
  font-size: 13px;
  color: #6e1f12;
}

/* ---- Sidebar + content shell ---------------------------------------- */
#shell {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  min-height: 100vh;
}

#sidebar {
  background: var(--c-nav-bg);
  color: white;
  display: flex;
  flex-direction: column;
  padding: 24px 0;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

#sidebar .brand {
  padding: 0 24px 24px 24px;
  border-bottom: 1px solid rgba(255,255,255,0.1);
  margin-bottom: 16px;
}
#sidebar .brand-mark {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.3px;
}
#sidebar .brand-sub {
  font-size: 11px;
  color: rgba(255,255,255,0.7);
  text-transform: uppercase;
  letter-spacing: 0.7px;
  margin-top: 4px;
}

/* Sidebar logo. Asset is the cropped 1600×255 wordmark (~6.3:1), so 24px tall
   renders at ~150px wide — fits comfortably within the 280-wide sidebar. */
.brand-logo-side {
  display: block;
  height: 24px;
  width: auto;
  margin-bottom: 4px;
}

/* Landing page logo. Cropped aspect ratio means height=52 renders ~326px wide,
   which balances against the "HealthImpact Command Centre" headline below. */
.brand-logo-landing {
  display: block;
  height: 52px;
  width: auto;
  margin-bottom: 16px;
}
@media (max-width: 600px) { .brand-logo-landing { height: 40px; } }

/* Inversion filter for placing the dark-on-white logo onto navy backgrounds.
   Turns the whole logo into white silhouette — works because the PNG has a
   transparent or near-white background. */
.invert-on-dark { filter: brightness(0) invert(1); }

/* Brand watermark — bottom-right on every dashboard page. Smaller height now
   that the asset is wordmark-width (~6.3:1) — 18px tall ≈ 113px wide. */
.page-watermark {
  position: fixed;
  bottom: 16px;
  right: 18px;
  height: 18px;
  width: auto;
  opacity: 0.35;
  pointer-events: none;
  z-index: 1;
  transition: opacity 200ms ease;
}
.page-watermark:hover { opacity: 0.6; }
body.kiosk .page-watermark { bottom: 22px; right: 26px; height: 24px; opacity: 0.55; }

/* Client brand chip — shows the client's colour + name in the sidebar */
.client-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 14px;
  padding: 10px 12px;
  background: rgba(255,255,255,0.06);
  border-radius: 8px;
  border: 1px solid rgba(255,255,255,0.08);
}
.client-chip-swatch {
  width: 14px;
  height: 14px;
  border-radius: 4px;
  background: var(--c-brand, var(--c-primary));
  flex-shrink: 0;
  box-shadow: 0 0 0 1px rgba(255,255,255,0.18), 0 0 12px var(--c-brand, var(--c-primary));
}
.client-chip-name {
  font-size: 13px;
  font-weight: 600;
  color: white;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.client-chip[hidden] { display: none !important; }

.nav-group {
  padding: 12px 14px;
}
.nav-label {
  font-size: 10px;
  color: rgba(255,255,255,0.5);
  text-transform: uppercase;
  letter-spacing: 0.8px;
  padding: 4px 10px 8px 10px;
  font-weight: 600;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 9px 10px;
  border-radius: 6px;
  color: rgba(255,255,255,0.85);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  background: transparent;
  border: none;
  cursor: pointer;
  text-align: left;
  margin: 1px 0;
  transition: background 100ms ease;
}
.nav-item:hover {
  background: rgba(255,255,255,0.1);
  color: white;
}
.nav-item.active {
  background: rgba(255,255,255,0.15);
  color: white;
}
.nav-item.active .nav-icon { color: white; }
.nav-item .nav-icon {
  display: inline-block;
  width: 18px;
  text-align: center;
  font-size: 14px;
  color: rgba(255,255,255,0.6);
}

/* Sim dropdown inside sidebar */
.nav-item--static { cursor: default; }
.nav-item--static:hover { background: transparent; }
.nav-select {
  background: rgba(255,255,255,0.08);
  color: white;
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: 6px;
  padding: 6px 8px;
  font-size: 13px;
  font-family: inherit;
  width: 100%;
  cursor: pointer;
  outline: none;
  -webkit-appearance: menulist;
  appearance: menulist;
}
.nav-select:hover { background: rgba(255,255,255,0.12); }
.nav-select option { color: var(--c-text); background: white; }
.nav-select optgroup { color: var(--c-text-mute); background: #f4f6fa; }

/* Simulation banner above page header */
.sim-banner {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  background: linear-gradient(90deg, #fff2d4, #ffe2b3);
  border: 1px solid #e0a33a;
  border-radius: 8px;
  font-size: 13px;
  color: #6b4f17;
  margin-bottom: 16px;
  font-weight: 500;
}
.sim-banner-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #e0a33a;
  box-shadow: 0 0 0 0 rgba(224,163,58,0.5);
  animation: pulse-ring 1.8s ease-out infinite;
}
.sim-banner strong { color: #4a3611; }
.sim-banner-stop {
  margin-left: auto;
  background: transparent;
  color: #6b4f17;
  border: 1px solid #c89a3e;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}
.sim-banner-stop:hover { background: rgba(224,163,58,0.15); }

.sidebar-foot {
  margin-top: auto;
  padding: 16px 14px 0 14px;
  border-top: 1px solid rgba(255,255,255,0.1);
  margin-left: 8px;
  margin-right: 8px;
}
.user-block {
  padding: 10px 10px;
  margin-bottom: 4px;
}
.user-name {
  font-size: 13px;
  color: white;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.user-email {
  font-size: 11px;
  color: rgba(255,255,255,0.55);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ---- Main content area ---------------------------------------------- */
#content {
  padding: 32px 40px;
  max-width: 1600px;
  margin: 0 auto;
  width: 100%;
}

.page-head {
  position: relative;
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  margin-bottom: 24px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--c-line);
}
/* When a client colour is applied, accent the page-head with a short coloured stripe */
.themed .page-head::after {
  content: '';
  position: absolute;
  left: 0;
  bottom: -1px;
  width: 80px;
  height: 3px;
  background: var(--c-brand, var(--c-primary));
  border-radius: 2px;
}
.page-meta {
  font-size: 12px;
  color: var(--c-text-mute);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-weight: 600;
  margin-bottom: 4px;
}
.page-title {
  margin: 0;
  font-size: 28px;
  font-weight: 700;
  color: var(--c-text);
}
.page-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}
.page-updated {
  font-size: 11px;
  color: var(--c-text-mute);
}
.ghost-btn {
  background: transparent;
  color: var(--c-text-mute);
  border: 1px solid var(--c-line);
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 14px;
}
.ghost-btn:hover {
  background: var(--c-line-soft);
  color: var(--c-text);
}
.back-btn { margin-bottom: 16px; }

/* ---- Hero strip ------------------------------------------------------ */
.hero-strip {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}
.hero-card {
  background: var(--c-surface);
  border-radius: 12px;
  padding: 24px;
  box-shadow: var(--shadow-card);
}
.hero-label {
  font-size: 11px;
  color: var(--c-text-mute);
  margin-bottom: 12px;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  font-weight: 600;
}
.hero-value {
  font-size: 40px;
  font-weight: 700;
  color: var(--c-primary);
  font-variant-numeric: tabular-nums;
  margin-bottom: 4px;
  line-height: 1.1;
  letter-spacing: -0.5px;
}
.hero-delta {
  font-size: 13px;
  color: var(--c-text-mute);
}
.hero-delta .pos  { color: var(--c-ok);    font-weight: 600; }
.hero-delta .neg  { color: var(--c-alert); font-weight: 600; }
.hero-delta .flat { color: var(--c-text-mute); }

/* ---- Grid for cards -------------------------------------------------- */
.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 24px;
}
.grid-2 .span-2 { grid-column: 1 / -1; }
@media (max-width: 1100px) {
  .grid-2 { grid-template-columns: 1fr; }
  .grid-2 .span-2 { grid-column: auto; }
}

/* ---- Card surface --------------------------------------------------- */
.card {
  background: var(--c-surface);
  border-radius: 12px;
  padding: 20px 24px;
  box-shadow: var(--shadow-card);
}
.card-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--c-text);
  margin: 0 0 16px 0;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.empty-state {
  color: var(--c-text-mute);
  font-size: 13px;
  text-align: center;
  padding: 32px 16px;
}

/* ---- Charts --------------------------------------------------------- */
.chart-card { position: relative; }
.chart-card canvas { max-height: 260px; }
.donut-wrap {
  position: relative;
  height: 200px;
  margin-bottom: 12px;
}
.donut-wrap canvas { max-height: 200px; }

.chart-legend {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13px;
}
.legend-row {
  display: grid;
  grid-template-columns: 14px 1fr auto;
  align-items: center;
  gap: 8px;
}
.legend-swatch {
  width: 12px;
  height: 12px;
  border-radius: 2px;
}
.legend-label { color: var(--c-text); }
.legend-value {
  color: var(--c-text);
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}
.muted { color: var(--c-text-mute); font-weight: 400; }

/* ---- Quality strip (service-quality KPI card) ----------------------- */
.quality-card { margin-bottom: 24px; }
.card-subtitle {
  font-size: 13px;
  color: var(--c-text-mute);
  margin: -8px 0 16px 0;
  line-height: 1.5;
  max-width: 800px;
}
.quality-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
}
@media (max-width: 900px) {
  .quality-stats { grid-template-columns: repeat(2, 1fr); }
}
.quality-stat {
  padding: 16px;
  background: var(--c-bg);
  border-radius: 10px;
  border: 1px solid var(--c-line-soft);
}
.quality-stat-label {
  font-size: 11px;
  color: var(--c-text-mute);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-weight: 600;
  margin-bottom: 8px;
}
.quality-stat-value {
  font-size: 32px;
  font-weight: 700;
  color: var(--c-primary);
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
  letter-spacing: -0.5px;
  margin-bottom: 4px;
}
.quality-stat-sub {
  font-size: 12px;
  color: var(--c-text-mute);
}

/* ---- Pipeline rows --------------------------------------------------- */
.pipeline-card { padding: 12px 0; }
.pipeline-card .card-title { padding: 0 24px; }
.pipeline-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 24px;
  border-bottom: 1px solid var(--c-line-soft);
  font-size: 14px;
}
.pipeline-row:last-of-type { border-bottom: none; }
.pipeline-value {
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  font-size: 22px;
  color: var(--c-primary);
}
.pipeline-row.warn  .pipeline-value { color: var(--c-warn); }
.pipeline-row.alert .pipeline-value { color: var(--c-alert); }
.pipeline-row.ok    .pipeline-value { color: var(--c-ok); }

/* ---- Data table ----------------------------------------------------- */
.table-card { padding: 0; overflow: hidden; }
.table-card .card-title { padding: 20px 24px 0 24px; }
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
  margin-top: 12px;
}
.data-table th, .data-table td {
  padding: 12px 24px;
  text-align: left;
  border-bottom: 1px solid var(--c-line-soft);
}
.data-table th {
  background: var(--c-bg);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--c-text-mute);
  font-weight: 600;
}
.data-table td.num, .data-table th.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.data-table tr:last-child td { border-bottom: none; }
.data-table tbody tr.clickable { cursor: pointer; }
.data-table tbody tr.clickable:hover { background: var(--c-line-soft); }

/* ---- Data notes ----------------------------------------------------- */
.data-notes {
  padding: 12px 20px;
  background: #fff8e1;
  border-left: 4px solid var(--c-warn);
  border-radius: 4px;
  font-size: 13px;
  color: #5d4a1a;
  margin-bottom: 24px;
}
.data-notes .note { margin: 4px 0; }

/* ---- Site detail ---------------------------------------------------- */
.detail-title {
  font-size: 32px;
  font-weight: 700;
  margin: 0 0 4px 0;
  color: var(--c-text);
}

/* ---- Kiosk mode ----------------------------------------------------- */
body.kiosk #sidebar { display: none; }
body.kiosk #shell   { grid-template-columns: 1fr; }
body.kiosk #content { padding: 24px 32px; max-width: none; }
body.kiosk .page-head { padding-bottom: 8px; margin-bottom: 16px; }
body.kiosk .page-title { font-size: 24px; }
body.kiosk .hero-value { font-size: 64px; line-height: 1; }
body.kiosk .hero-card  { padding: 32px; }
body.kiosk .hero-label { font-size: 13px; }
body.kiosk .card-title { font-size: 14px; }
body.kiosk .pipeline-value { font-size: 32px; }
body.kiosk .chart-card canvas { max-height: 320px; }
body.kiosk .page-actions { display: none; }

/* Kiosk exit hint */
body.kiosk::after {
  content: "Esc to exit kiosk";
  position: fixed;
  bottom: 12px;
  right: 14px;
  font-size: 11px;
  color: var(--c-text-mute);
  background: rgba(255,255,255,0.6);
  padding: 4px 10px;
  border-radius: 4px;
  font-weight: 500;
  letter-spacing: 0.5px;
}

/* ---- Admin page (kept compatible) ----------------------------------- */
.admin-toolbar {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-bottom: 16px;
}
.admin-toolbar select, .admin-toolbar input {
  padding: 8px 12px;
  font-size: 14px;
  border: 1px solid var(--c-line);
  border-radius: 6px;
  background: var(--c-surface);
  min-width: 220px;
}
.admin-toolbar .grow { flex: 1; }
button.secondary {
  background: transparent;
  color: var(--c-text-mute);
  border: 1px solid var(--c-line);
}
button.secondary:hover { background: var(--c-line-soft); color: var(--c-text); }
.users-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}
.users-table th, .users-table td {
  padding: 10px 16px;
  text-align: left;
  border-bottom: 1px solid var(--c-line-soft);
}
.users-table th {
  background: var(--c-bg);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--c-text-mute);
  font-weight: 600;
}
.users-table tbody tr:hover { background: var(--c-line-soft); cursor: pointer; }
.users-table td.muted-cell { color: var(--c-text-mute); font-size: 12px; }
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.badge.active   { background: #d4f1e8; color: #226a5b; }
.badge.inactive { background: var(--c-line-soft); color: var(--c-text-mute); }
.badge.manager  { background: #fff2d4; color: #6b5117; }
.badge.viewall  { background: #e4d9f7; color: #4a2f7f; }

.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(15,30,46,0.5);
  display: flex; align-items: center; justify-content: center;
  z-index: 100;
}
.modal {
  background: var(--c-surface);
  border-radius: 12px;
  width: min(560px, calc(100vw - 32px));
  max-height: calc(100vh - 64px);
  overflow-y: auto;
}
.modal-header {
  padding: 16px 24px;
  border-bottom: 1px solid var(--c-line);
  display: flex; justify-content: space-between; align-items: center;
}
.modal-header h2 { margin: 0; font-size: 16px; color: var(--c-primary); }
.modal-body { padding: 20px 24px; }
.modal-footer {
  padding: 12px 24px;
  border-top: 1px solid var(--c-line);
  display: flex; justify-content: flex-end; gap: 8px;
}
.field { margin-bottom: 14px; }
.field label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--c-text-mute);
  margin-bottom: 4px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.field input[type="text"], .field input[type="email"], .field input[type="date"], .field select {
  width: 100%;
  padding: 8px 12px;
  font-size: 14px;
  border: 1px solid var(--c-line);
  border-radius: 6px;
  background: var(--c-surface);
}
.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.checkbox-row {
  display: flex; align-items: center; gap: 8px;
  margin: 8px 0; font-size: 14px;
}
.sites-list {
  max-height: 240px; overflow-y: auto;
  border: 1px solid var(--c-line); border-radius: 6px;
  padding: 8px; background: var(--c-bg);
}
.sites-list label {
  display: flex; align-items: center; gap: 8px;
  padding: 4px 8px; font-size: 13px; cursor: pointer;
}
.sites-list label:hover { background: var(--c-line-soft); border-radius: 4px; }
.toast {
  position: fixed;
  bottom: 24px; right: 24px;
  padding: 12px 20px;
  background: var(--c-text);
  color: white; border-radius: 6px; font-size: 14px;
  z-index: 200;
  box-shadow: 0 4px 12px rgba(0,0,0,0.2);
}
.toast.error { background: var(--c-alert); }
.toast.ok    { background: var(--c-ok); }
.header-link {
  color: var(--c-primary);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  padding: 6px 12px;
  border-radius: 6px;
}
.header-link:hover { background: var(--c-line-soft); }
