/* TicketPulse GateCheck — operational check-in UI
   Purple (#440099) is the brand/action color, used with restraint.
   Green / amber / red are reserved strictly for scan outcomes.
   Machine-read data (codes, counts, times) is set in a monospace face. */

:root {
  /* Brand */
  --brand: #440099;
  --brand-ink: #37007a;
  --brand-100: #f2ecfb;
  --brand-200: #e4d8f8;

  /* Neutrals */
  --ink: #1b1626;
  --ink-2: #48435a;
  --muted: #6f6982;
  --line: #e8e5f0;
  --line-2: #d7d2e4;
  --bg: #f6f5fa;
  --surface: #ffffff;

  /* Outcome semantics (status only, never actions) */
  --ok: #0d7a53;      --ok-soft: #e3f4ec;
  --warn: #8a5900;    --warn-soft: #fbeecb;
  --bad: #c22f3a;     --bad-soft: #fce5e7;

  /* Form */
  --display: "Space Grotesk", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --body: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --mono: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, monospace;
  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 1px 2px rgba(27, 22, 38, .04), 0 10px 30px rgba(27, 22, 38, .06);
  --shadow-lg: 0 24px 60px rgba(27, 22, 38, .14);
  --ring: 0 0 0 3px var(--brand-200);

  /* Theme-dependent values that are not plain surface/ink tokens. Keeping them as variables
     means every component rule below is written once, for both themes. */
  --primary-bg: var(--brand);
  --primary-bg-hover: var(--brand-ink);
  --photo-filter: none;
  color-scheme: light;
}

/* Dark mode is an operational feature, not a preference: gates run after dark, staff hold the
   phone at high brightness for hours, and most shift devices are OLED. #440099 is too dark to
   read against a dark surface, so the brand lifts to a lighter purple while keeping its identity.
   Outcome colors are re-tuned for contrast but keep their green / amber / red meaning.

   Light is the default, so there is deliberately no prefers-color-scheme rule here: dark applies
   only when theme.js has resolved an explicit choice into data-theme. A browser with JavaScript
   disabled therefore stays light, which is the intended default. */
:root[data-theme="dark"] {
  --brand: #b18cff;
  --brand-ink: #c9aeff;
  --brand-100: #221436;
  --brand-200: #33204d;

  --ink: #ece9f4;
  --ink-2: #bab3cc;
  --muted: #8f88a3;
  --line: #2a2438;
  --line-2: #3b3450;
  --bg: #0f0c16;
  --surface: #17131f;

  --ok: #4ad295;      --ok-soft: #10301f;
  --warn: #f0b849;    --warn-soft: #33270a;
  --bad: #ff7b85;     --bad-soft: #3a161b;

  --shadow: 0 1px 2px rgba(0, 0, 0, .5), 0 10px 30px rgba(0, 0, 0, .45);
  --shadow-lg: 0 24px 60px rgba(0, 0, 0, .6);
  --ring: 0 0 0 3px rgba(177, 140, 255, .35);

  /* The primary button keeps white text, so it needs the deeper purple back. */
  --primary-bg: #6d3ecf;
  --primary-bg-hover: #7d51db;
  --photo-filter: brightness(.94);
  color-scheme: dark;
}

img.attendee-photo, img.gate-sheet-photo { filter: var(--photo-filter); }

[hidden] { display: none !important; }
* { box-sizing: border-box; }
html { font-size: 16px; -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--body);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
a { color: inherit; }
button, input, textarea { font: inherit; }
button { cursor: pointer; }
img { max-width: 100%; }

/* ---------- Header ---------- */
.site-header {
  background: var(--surface);
  border-top: 3px solid var(--brand);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 20;
}
.nav-shell {
  max-width: 1320px;
  margin: auto;
  min-height: 64px;
  padding: 0 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}
.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  font-family: var(--display);
  font-weight: 600;
  letter-spacing: -.01em;
}
.brand img { width: 118px; height: 28px; object-fit: contain; object-position: left center; }
.brand span {
  padding-left: 12px;
  border-left: 1px solid var(--line-2);
  color: var(--ink);
  font-size: 1.02rem;
}
.nav-links { display: flex; align-items: center; gap: 6px; font-size: .9rem; }
.nav-links form { margin: 0; }
.nav-links > a {
  text-decoration: none;
  font-family: var(--display);
  font-weight: 500;
  color: var(--ink-2);
  padding: 8px 12px;
  border-radius: 8px;
  transition: background .15s, color .15s;
}
.nav-links > a:hover { background: var(--brand-100); color: var(--brand); }
.current-context {
  min-width: 0;
  max-width: 240px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  column-gap: 8px;
  padding: 7px 11px;
  color: var(--brand);
  background: var(--brand-100);
  border: 1px solid var(--brand-200);
  border-radius: 10px;
  text-decoration: none;
}
.current-context > span { grid-column: 1; color: var(--muted); font-size: .58rem; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; }
.current-context strong { grid-column: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-family: var(--display); font-size: .76rem; }
.current-context svg { grid-column: 2; grid-row: 1 / 3; align-self: center; width: 15px; fill: currentColor; }
a.current-context:hover { background: var(--surface); border-color: var(--brand); }
.profile-menu { position: relative; margin-left: 4px; }
.profile-menu summary { display: flex; align-items: center; gap: 7px; padding: 5px 7px; border-radius: 10px; cursor: pointer; list-style: none; color: var(--ink-2); }
.profile-menu summary::-webkit-details-marker { display: none; }
.profile-menu summary:hover { background: var(--brand-100); }
.profile-menu summary > svg { width: 10px; fill: none; stroke: currentColor; stroke-width: 1.5; }
.profile-avatar { width: 28px; height: 28px; display: grid; place-items: center; border-radius: 50%; background: var(--primary-bg); color: #fff; font-family: var(--display); font-size: .75rem; font-weight: 600; text-transform: uppercase; }
.profile-name { max-width: 110px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .78rem; font-weight: 600; }
.profile-popover { position: absolute; right: 0; top: calc(100% + 8px); z-index: 30; width: 190px; padding: 10px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow-lg); }
.profile-popover > span { display: block; padding: 6px 9px 10px; color: var(--muted); font-size: .7rem; }
.profile-popover form, .profile-popover .link-button { width: 100%; text-align: left; }
.theme-switch {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 2px;
  margin: 0 0 8px;
  padding: 3px;
  border: 1px solid var(--line-2);
  border-radius: 999px;
  background: var(--bg);
}
.theme-switch button {
  min-height: 34px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font-family: var(--display);
  font-size: .76rem;
  font-weight: 600;
  transition: background .15s, color .15s;
}
.theme-switch button:hover { color: var(--ink); }
.theme-switch button.is-active { background: var(--surface); color: var(--brand); box-shadow: var(--shadow); }
.nav-links > .event-switch-link {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  margin-left: 4px;
  padding: 7px 12px;
  color: var(--brand);
  background: linear-gradient(135deg, var(--surface), var(--brand-100));
  border: 1px solid var(--brand-200);
  border-radius: 999px;
  box-shadow: 0 1px 2px rgba(68, 0, 153, .06);
  transition: transform .15s ease, border-color .15s ease, background .15s ease, box-shadow .15s ease;
}
.nav-links > .event-switch-link svg {
  width: 15px;
  height: 15px;
  fill: currentColor;
  flex: none;
}
.nav-links > .event-switch-link:hover {
  color: var(--brand-ink);
  background: var(--surface);
  border-color: var(--brand);
  box-shadow: 0 4px 14px rgba(68, 0, 153, .12);
  transform: translateY(-1px);
}
.role-badge {
  font-family: var(--mono);
  font-size: .68rem;
  font-weight: 500;
  letter-spacing: .02em;
  color: var(--brand);
  background: var(--brand-100);
  border-radius: 999px;
  padding: 5px 11px;
  margin-left: 6px;
}
.link-button {
  border: 0;
  background: transparent;
  color: var(--muted);
  padding: 8px 10px;
  border-radius: 8px;
  font-weight: 500;
  transition: color .15s, background .15s;
}
.link-button:hover { color: var(--ink); background: var(--line); }

/* ---------- Shell ---------- */
.main-shell { max-width: 1320px; margin: 0 auto; padding: 48px 24px 96px; }
.guest-main { max-width: none; padding: 0; }

.page-heading { margin-bottom: 32px; }
.page-heading-actions { display: flex; align-items: end; justify-content: space-between; gap: 24px; }
.page-heading-actions > div { min-width: 0; }
.page-heading-actions .button { flex: none; margin-bottom: 2px; }
.eyebrow {
  text-transform: uppercase;
  letter-spacing: .18em;
  font-family: var(--display);
  font-weight: 600;
  font-size: .68rem;
  color: var(--brand);
  margin: 0 0 10px;
}
.page-heading h1, .scan-shell h1, .result-shell h1, .auth-card h1 {
  font-family: var(--display);
  font-weight: 600;
  font-size: clamp(1.7rem, 4vw, 2.35rem);
  line-height: 1.08;
  letter-spacing: -.03em;
  margin: 0 0 10px;
}
.page-heading > p:last-child, .scan-shell > p, .auth-card > p, .result-lead {
  color: var(--muted);
  margin-top: 0;
  font-size: .98rem;
}

/* ---------- Metrics ---------- */
.metrics {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 28px;
}
.metrics article, .metrics .metric-link {
  display: block;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px 20px 22px;
}
.metrics .metric-link {
  text-decoration: none;
  transition: border-color .15s, transform .05s;
}
.metrics .metric-link:hover { border-color: var(--brand); }
.metrics .metric-link:active { transform: translateY(1px); }
.metrics .metric-link strong { text-decoration: underline; text-decoration-color: var(--line-2); text-underline-offset: 4px; }
.metrics span {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: .8rem;
  font-weight: 500;
}
.metrics span::before {
  content: "";
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--muted);
  flex: none;
}
.metrics > *:nth-child(1) span::before { background: var(--ok); }
.metrics > *:nth-child(2) span::before { background: var(--warn); }
.metrics > *:nth-child(3) span::before { background: var(--brand); }
.metrics > *:nth-child(4) span::before { background: var(--bad); }
.metrics strong {
  display: block;
  font-family: var(--mono);
  font-weight: 600;
  font-size: 2.1rem;
  letter-spacing: -.02em;
  margin-top: 10px;
  font-variant-numeric: tabular-nums;
}

/* ---------- Buttons ---------- */
.button {
  appearance: none;
  border: 1px solid var(--line-2);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--ink);
  padding: 12px 18px;
  font-family: var(--display);
  font-weight: 500;
  font-size: .95rem;
  text-align: center;
  text-decoration: none;
  display: inline-block;
  transition: background .15s, border-color .15s, box-shadow .15s, transform .05s;
}
.button:hover { background: var(--bg); border-color: var(--muted); }
.button:active { transform: translateY(1px); }
.button-primary {
  background: var(--primary-bg);
  border-color: var(--primary-bg);
  color: #fff;
}
.button-primary:hover { background: var(--primary-bg-hover); border-color: var(--primary-bg-hover); }
.button-with-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}
.button-with-icon span {
  font-size: 1.15em;
  line-height: 1;
  transition: transform .15s ease;
}
.button-with-icon:hover span { transform: translateX(3px); }
.button-danger { background: var(--bad); border-color: var(--bad); color: #fff; }
.button-danger:hover { filter: brightness(.94); background: var(--bad); }
.button-quiet { border-color: transparent; background: transparent; color: var(--muted); }
.button-quiet:hover { background: var(--line); color: var(--ink); border-color: transparent; }
.button-large {
  display: block;
  width: 100%;
  padding: 16px 18px;
  font-size: 1.02rem;
  margin-bottom: 32px;
  box-shadow: 0 8px 22px rgba(68, 0, 153, .22);
}

/* ---------- Panels & tables ---------- */
.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.panel-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 22px;
  border-bottom: 1px solid var(--line);
}
.panel-heading h2 { font-family: var(--display); font-weight: 600; font-size: 1rem; margin: 0; }
.panel-heading a {
  color: var(--brand);
  font-family: var(--display);
  font-weight: 500;
  font-size: .85rem;
  text-decoration: none;
}
.panel-heading a:hover { text-decoration: underline; }
.panel-count { color: var(--muted); font-size: .8rem; }
.empty-state { padding: 52px 24px; text-align: center; }
.empty-state h3 { margin: 0 0 8px; font-family: var(--display); font-size: 1.05rem; }
.empty-state p { max-width: 480px; margin: 0 auto 20px; color: var(--muted); font-size: .88rem; }

.event-badge {
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--brand);
  font-family: var(--display);
  font-size: .78rem;
  font-weight: 600;
}
.inline-form { display: flex; align-items: center; gap: 8px; }
.inline-form select { min-width: 180px; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .85rem; }
th {
  background: var(--bg);
  color: var(--muted);
  font-family: var(--display);
  font-size: .66rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .09em;
  text-align: left;
}
th, td { padding: 14px 16px; border-bottom: 1px solid var(--line); white-space: nowrap; }
/* Machine-read columns in mono */
tbody td:first-child, tbody td strong { font-family: var(--mono); font-weight: 500; }
tbody tr { transition: background .12s; }
tbody tr:hover { background: var(--brand-100); }
tbody tr:last-child td { border-bottom: 0; }
.empty { padding: 28px 22px; color: var(--muted); }
.table-action {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--brand);
  font-family: var(--display);
  font-size: .78rem;
  font-weight: 600;
  text-decoration: none;
}
.table-action span { transition: transform .15s ease; }
.table-action:hover span { transform: translateX(3px); }
.table-actions { display: flex; align-items: center; gap: 4px; }
.table-actions form { margin: 0; }

/* ---------- Status pills ---------- */
.status {
  display: inline-block;
  border-radius: 999px;
  padding: 4px 10px;
  font-family: var(--mono);
  font-weight: 600;
  font-size: .68rem;
  letter-spacing: .01em;
  text-transform: capitalize;
}
.status-admitted { background: var(--ok-soft); color: var(--ok); }
.status-pending, .status-resumed { background: var(--warn-soft); color: var(--warn); }
.status-duplicate, .status-invalid, .status-revoked { background: var(--bad-soft); color: var(--bad); }
.status-active { background: var(--ok-soft); color: var(--ok); }
.status-draft { background: var(--brand-100); color: var(--brand); }
.status-closed, .status-archived { background: var(--line); color: var(--muted); }

/* ---------- Scan / result shells ---------- */
.scan-shell, .result-shell { max-width: 520px; margin: 0 auto; text-align: center; }

.stepper { display: flex; align-items: center; justify-content: center; margin: 0 0 30px; }
.stepper span {
  width: 28px; height: 28px;
  border-radius: 50%;
  display: grid; place-items: center;
  background: var(--surface);
  border: 1px solid var(--line-2);
  color: var(--muted);
  font-family: var(--mono);
  font-size: .78rem;
  font-weight: 600;
}
.stepper span.active, .stepper.complete span { background: var(--primary-bg); border-color: var(--primary-bg); color: #fff; }
.stepper i { width: 88px; height: 2px; background: var(--line-2); }
.stepper.complete i { background: var(--brand); }

/* Scanner viewfinder — the signature reticle */
.scanner-panel, .camera-card {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--line-2);
  border-radius: var(--radius);
  min-height: 280px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  overflow: hidden;
  margin: 24px 0 16px;
}
.scanner-panel::after, .camera-card::after {
  content: "";
  position: absolute;
  inset: 12px;
  pointer-events: none;
  z-index: 2;
  --l: 24px; --t: 2px; --c: var(--brand);
  background:
    linear-gradient(var(--c), var(--c)) top left / var(--l) var(--t) no-repeat,
    linear-gradient(var(--c), var(--c)) top left / var(--t) var(--l) no-repeat,
    linear-gradient(var(--c), var(--c)) top right / var(--l) var(--t) no-repeat,
    linear-gradient(var(--c), var(--c)) top right / var(--t) var(--l) no-repeat,
    linear-gradient(var(--c), var(--c)) bottom left / var(--l) var(--t) no-repeat,
    linear-gradient(var(--c), var(--c)) bottom left / var(--t) var(--l) no-repeat,
    linear-gradient(var(--c), var(--c)) bottom right / var(--l) var(--t) no-repeat,
    linear-gradient(var(--c), var(--c)) bottom right / var(--t) var(--l) no-repeat;
}
.qr-reader { width: 100%; position: relative; z-index: 1; }
.qr-reader:empty { display: none; }
.scanner-panel [data-start-scanner] { position: relative; z-index: 3; }
.scanner-status, .help, .privacy-note { font-size: .78rem; color: var(--muted); }
.scanner-status { position: relative; z-index: 3; }
.scanner-error { color: var(--bad); font-weight: 700; }

/* ---------- Persistent gate scanner ----------
   The scanner is an appliance, not a page: the viewfinder holds its position for the whole shift
   and outcomes arrive as a sheet over it. Primary actions sit low, within thumb reach, and are
   sized for a rushed or gloved hand (min 52px). */
.gate {
  max-width: 560px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.gate-context {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.gate-context-event { display: flex; flex-direction: column; min-width: 0; }
.gate-context-event strong {
  font-family: var(--display);
  font-size: 1.05rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.gate-chip {
  flex: none;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 1px;
  min-height: 48px;
  padding: 7px 14px;
  border: 1px solid var(--line-2);
  border-radius: 999px;
  background: var(--surface);
  color: var(--ink);
}
.gate-chip span { font-size: .68rem; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.gate-chip strong { font-family: var(--display); font-size: .92rem; }

.gate-stage {
  position: relative;
  aspect-ratio: 3 / 4;
  max-height: 58vh;
  border-radius: var(--radius);
  overflow: hidden;
  background: #0b0810;
  display: grid;
  place-items: center;
}
.gate-reader, .gate-reader video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.gate-reader { grid-area: 1 / 1; }
.gate-reader img { display: none; }
.gate-preview {
  grid-area: 1 / 1;
  width: 100%; height: 100%;
  object-fit: cover;
  z-index: 2;
}
/* The signature reticle, carried over from the original viewfinder. */
.gate-reticle {
  grid-area: 1 / 1;
  position: relative;
  width: min(72%, 260px);
  aspect-ratio: 1;
  z-index: 3;
  pointer-events: none;
  --l: 30px; --t: 3px; --c: #fff;
  background:
    linear-gradient(var(--c), var(--c)) top left / var(--l) var(--t) no-repeat,
    linear-gradient(var(--c), var(--c)) top left / var(--t) var(--l) no-repeat,
    linear-gradient(var(--c), var(--c)) top right / var(--l) var(--t) no-repeat,
    linear-gradient(var(--c), var(--c)) top right / var(--t) var(--l) no-repeat,
    linear-gradient(var(--c), var(--c)) bottom left / var(--l) var(--t) no-repeat,
    linear-gradient(var(--c), var(--c)) bottom left / var(--t) var(--l) no-repeat,
    linear-gradient(var(--c), var(--c)) bottom right / var(--l) var(--t) no-repeat,
    linear-gradient(var(--c), var(--c)) bottom right / var(--t) var(--l) no-repeat;
  transition: width .25s ease, opacity .25s ease, transform .2s ease;
}
.gate-stage-reading .gate-reticle { --c: #37d391; transform: scale(.94); }
.gate-stage[data-state="drowsy"] .gate-reticle { opacity: .35; }
.gate-stage[data-state="asleep"] .gate-reticle,
.gate-stage[data-state="error"] .gate-reticle,
.gate-stage[data-state="idle"] .gate-reticle { opacity: 0; }
/* Photo mode reframes the reticle from a code target to a portrait guide. */
.gate-stage-photo .gate-reticle {
  width: min(58%, 200px);
  aspect-ratio: 3 / 4;
  --c: #fff;
  transform: translateY(-8%);
}
.gate-photo-open { overflow: hidden; }
.gate[data-phase="photo"] .gate-stage {
  position: fixed;
  inset: 0;
  z-index: 200;
  width: 100%;
  max-height: none;
  aspect-ratio: auto;
  border-radius: 0;
}
.gate-stage-photo .gate-stage-status { display: none; }
.gate-photo-mode {
  position: absolute;
  inset: 0;
  z-index: 9;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  pointer-events: none;
}
.gate-photo-mode[hidden] { display: none; }
.gate-photo-mode-heading {
  align-self: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  margin-top: max(18px, env(safe-area-inset-top));
  padding: 9px 18px;
  border: 1px solid rgba(255, 255, 255, .28);
  border-radius: 999px;
  background: rgba(11, 8, 16, .76);
  color: #fff;
  backdrop-filter: blur(12px);
}
.gate-photo-mode-heading span {
  font-size: .68rem;
  font-weight: 700;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, .72);
}
.gate-photo-mode-heading strong { font-family: var(--mono); font-size: .92rem; }
.gate-photo-mode-actions {
  pointer-events: auto;
  display: grid;
  gap: 9px;
  width: min(100%, 520px);
  margin: 0 auto;
  padding: 72px 18px max(18px, env(safe-area-inset-bottom));
  background: linear-gradient(transparent, rgba(11, 8, 16, .94) 42%);
}
.gate-photo-mode-actions p {
  margin: 0 0 3px;
  color: #fff;
  font-size: .88rem;
  font-weight: 600;
  text-align: center;
  text-shadow: 0 1px 8px rgba(0, 0, 0, .6);
}
.gate-photo-mode-actions .button-primary {
  min-height: 58px;
  box-shadow: 0 8px 30px rgba(0, 0, 0, .28);
}
.gate-photo-mode-actions .button-quiet { color: #fff; }

.gate-read-feedback {
  grid-area: 1 / 1;
  z-index: 6;
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: calc(100% - 32px);
  padding: 11px 16px 11px 11px;
  border: 1px solid rgba(255, 255, 255, .3);
  border-radius: 999px;
  background: rgba(8, 44, 31, .92);
  color: #fff;
  box-shadow: 0 12px 30px rgba(0, 0, 0, .25);
  pointer-events: none;
  animation: gate-read-in .14s ease-out;
}
.gate-read-feedback[hidden] { display: none; }
.gate-read-feedback > span:last-child { display: flex; flex-direction: column; min-width: 0; text-align: left; }
.gate-read-feedback strong { font-family: var(--display); font-size: .95rem; }
.gate-read-feedback small {
  max-width: 28ch;
  overflow: hidden;
  color: rgba(255, 255, 255, .78);
  font-size: .72rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.gate-read-mark {
  flex: none;
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: #37d391;
  color: #062c1d;
  font-size: 1.1rem;
  font-weight: 800;
}
@keyframes gate-read-in {
  from { opacity: 0; transform: scale(.92); }
}

/* The whole viewfinder is the wake target — one thumb tap anywhere. */
.gate-wake {
  grid-area: 1 / 1;
  z-index: 4;
  width: 100%; height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 0;
  background: rgba(11, 8, 16, .82);
  color: #fff;
  padding: 24px;
  text-align: center;
}
.gate-wake-icon { font-size: 2.6rem; line-height: 1; color: var(--brand); }
.gate-wake strong { font-family: var(--display); font-size: 1.3rem; }
.gate-wake small { font-size: .82rem; color: rgba(255, 255, 255, .72); max-width: 30ch; }

.gate-stage-status {
  grid-area: 1 / 1;
  align-self: end;
  z-index: 5;
  margin: 0 0 12px;
  padding: 7px 14px;
  border-radius: 999px;
  background: rgba(11, 8, 16, .66);
  color: #fff;
  font-size: .8rem;
  text-align: center;
}
.gate-stage-status:empty { display: none; }
.gate-status-error { background: var(--bad); font-weight: 600; }

/* ---------- Outcome sheet ---------- */
.gate-sheet {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
  padding: 20px;
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 10px;
  animation: gate-sheet-in .16s ease-out;
}
@keyframes gate-sheet-in { from { opacity: 0; transform: translateY(10px); } }
@media (prefers-reduced-motion: reduce) { .gate-sheet { animation: none; } }
.gate-sheet-admitted { border-top: 4px solid var(--ok); }
.gate-sheet-duplicate { border-top: 4px solid var(--bad); }
.gate-sheet-invalid { border-top: 4px solid var(--warn); }
.gate-sheet.gate-sheet-photo-ready { border-top: 4px solid var(--brand); }
.gate-sheet-mark {
  width: 46px; height: 46px;
  margin: 0 auto;
  border-radius: 50%;
  display: grid; place-items: center;
  font-size: 1.5rem; font-weight: 700;
}
.gate-sheet-admitted .gate-sheet-mark { background: var(--ok-soft); color: var(--ok); }
.gate-sheet-invalid .gate-sheet-mark { background: var(--warn-soft); color: var(--warn); }
.gate-sheet-eyebrow {
  margin: 0;
  font-size: .72rem;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--muted);
}
.gate-sheet-code {
  margin: 0;
  font-family: var(--mono);
  font-size: 1.7rem;
  letter-spacing: -.02em;
}
.gate-sheet-lead { margin: 0; color: var(--ink-2); font-size: .95rem; }
.gate-sheet-note { margin: 0; font-size: .76rem; color: var(--muted); }
.gate-sheet-captured {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  text-align: left;
}
.gate-sheet-captured-mark {
  flex: none;
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--ok-soft);
  color: var(--ok);
  font-size: 1.2rem;
  font-weight: 800;
}
/* At a duplicate the face is the decision, so it leads and it is large. */
img.gate-sheet-photo {
  display: block;
  width: min(100%, 320px);
  aspect-ratio: 3 / 4;
  object-fit: cover;
  margin: 0 auto;
  border-radius: var(--radius-sm);
  border: 3px solid var(--bad);
}
.gate-sheet-photo-missing {
  display: grid;
  place-items: center;
  width: min(100%, 320px);
  aspect-ratio: 3 / 4;
  margin: 0 auto;
  border-radius: var(--radius-sm);
  border: 2px dashed var(--line-2);
  color: var(--muted);
  font-size: .85rem;
  padding: 16px;
  text-align: center;
}
.button-jumbo {
  width: 100%;
  min-height: 56px;
  font-size: 1.05rem;
  font-weight: 600;
}
.gate-sheet .button { width: 100%; min-height: 52px; }

/* ---------- Undo pill ---------- */
.gate-undo {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 10px 10px 16px;
  margin-bottom: 12px;
  border: 1px solid var(--line-2);
  border-radius: 999px;
  background: var(--surface);
  font-size: .88rem;
}
.gate-undo strong { font-family: var(--mono); }
.gate-undo-button {
  flex: none;
  min-height: 40px;
  padding: 0 16px;
  border: 1px solid var(--line-2);
  border-radius: 999px;
  background: var(--bg);
  color: var(--ink);
  font-weight: 600;
}
.gate-undo-button i { font-style: normal; color: var(--muted); font-family: var(--mono); }

/* ---------- Manual entry ---------- */
.gate-manual > summary {
  list-style: none;
  cursor: pointer;
  min-height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--brand);
  font-family: var(--display);
  font-weight: 600;
  font-size: .9rem;
}
.gate-manual > summary::-webkit-details-marker { display: none; }
.gate-manual-form { display: flex; flex-direction: column; gap: 10px; padding: 6px 0 4px; }
.gate-manual-form label { font-family: var(--display); font-size: .8rem; font-weight: 600; color: var(--ink-2); }
.gate-manual-row {
  display: flex;
  align-items: stretch;
  border: 1px solid var(--line-2);
  border-radius: var(--radius-sm);
  background: var(--surface);
  overflow: hidden;
}
.gate-manual-row:focus-within { border-color: var(--brand); box-shadow: var(--ring); }
.gate-manual-prefix {
  display: grid;
  place-items: center;
  padding: 0 14px;
  background: var(--bg);
  border-right: 1px solid var(--line-2);
  color: var(--muted);
  font-family: var(--mono);
  font-size: .95rem;
}
.gate-manual-row input {
  flex: 1;
  min-width: 0;
  border: 0;
  outline: none;
  background: transparent;
  color: var(--ink);
  padding: 15px 14px;
  font-family: var(--mono);
  font-size: 1.15rem;
}
.gate-manual-form .button { min-height: 52px; }

.gate-offline {
  margin: 0;
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  background: var(--bad-soft);
  color: var(--bad);
  font-size: .88rem;
  text-align: center;
}

/* ---------- Gate picker ---------- */
.gate-dialog {
  border: 0;
  border-radius: var(--radius);
  padding: 0;
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow-lg);
  max-width: 400px;
  width: calc(100% - 32px);
}
.gate-dialog::backdrop { background: rgba(11, 8, 16, .6); }
.gate-dialog-form { padding: 22px; }
.gate-dialog h2 { margin: 0 0 6px; font-family: var(--display); font-size: 1.2rem; }
.gate-dialog p { margin: 0 0 16px; color: var(--muted); font-size: .87rem; }
.gate-options { display: flex; flex-direction: column; gap: 8px; }
.gate-option {
  min-height: 54px;
  border: 1px solid var(--line-2);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--ink);
  font-family: var(--display);
  font-size: 1rem;
  font-weight: 600;
}
.gate-option:hover { border-color: var(--brand); background: var(--brand-100); }
.gate-noscript { margin-top: 16px; }

/* ---------- Audit filters ---------- */
.audit-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 0 20px 16px;
  border-bottom: 1px solid var(--line);
}
.audit-filter {
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  padding: 0 14px;
  border: 1px solid var(--line-2);
  border-radius: 999px;
  background: var(--surface);
  color: var(--ink-2);
  font-size: .82rem;
  font-weight: 500;
  text-decoration: none;
}
.audit-filter:hover { border-color: var(--brand); color: var(--brand); }
.audit-filter.is-active { background: var(--primary-bg); border-color: var(--primary-bg); color: #fff; }

/* ---------- Forms ---------- */
.form-stack { display: flex; flex-direction: column; gap: 10px; text-align: left; }
.form-stack label {
  font-family: var(--display);
  font-size: .8rem;
  font-weight: 600;
  color: var(--ink-2);
}
.form-stack input:not([type=checkbox]), .form-stack textarea, .form-stack select {
  width: 100%;
  border: 1px solid var(--line-2);
  border-radius: var(--radius-sm);
  background: var(--surface);
  padding: 13px 14px;
  color: var(--ink);
  transition: border-color .15s, box-shadow .15s;
}
.form-stack input[data-code] { font-family: var(--mono); letter-spacing: .01em; }
.form-stack input:focus, .form-stack textarea:focus, .form-stack select:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: var(--ring);
}
.panel-form {
  padding: 24px;
  gap: 7px;
}
.panel-form label:not(:first-child) { margin-top: 8px; }
.panel-form .button { width: 100%; margin-top: 12px; padding-block: 13px; }
.form-actions { display: flex; align-items: center; justify-content: flex-end; gap: 10px; margin-top: 16px; }
.panel-form .form-actions .button { width: auto; margin-top: 0; }
.form-grid-two { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-grid-two > div { min-width: 0; }
.form-grid-two label { display: block; margin: 8px 0 7px; }
.form-section { display: flex; flex-direction: column; gap: 7px; padding-top: 20px; margin-top: 8px; border-top: 1px solid var(--line); }
.form-section h2 { margin: 0 0 5px; font-family: var(--display); font-size: .95rem; }
.policy-note { display: flex; gap: 12px; padding: 14px; margin-top: 10px; background: var(--brand-100); border: 1px solid var(--brand-200); border-radius: 10px; }
.policy-note strong { flex: none; color: var(--brand); font-size: .78rem; }
.policy-note span { color: var(--ink-2); font-size: .78rem; }
.focused-page { width: min(720px, 100%); margin: 0 auto; }
.focused-card { box-shadow: 0 18px 50px rgba(27, 22, 38, .08); }
.focused-card-wide { width: min(720px, 100%); }
.back-link { display: inline-flex; margin-bottom: 24px; color: var(--muted); font-size: .8rem; font-weight: 600; text-decoration: none; }
.back-link:hover { color: var(--brand); }
.account-result { display: grid; grid-template-columns: 1fr auto; gap: 3px 12px; padding: 15px; margin-bottom: 8px; background: var(--bg); border: 1px solid var(--line); border-radius: 11px; }
.account-result > span { color: var(--brand); font-size: .66rem; font-weight: 700; letter-spacing: .07em; text-transform: uppercase; }
.account-result strong { grid-column: 1; font-size: .88rem; overflow-wrap: anywhere; }
.account-result small { grid-column: 1; color: var(--muted); }
.account-result .text-button { grid-column: 2; grid-row: 1 / 4; align-self: center; }
.text-button { border: 0; padding: 7px 9px; background: transparent; color: var(--brand); font: inherit; font-size: .76rem; font-weight: 600; }
.text-button:hover { text-decoration: underline; }
.validation { color: var(--bad); font-size: .82rem; }
.validation ul { margin: 0; padding-left: 20px; }
.checkbox {
  display: flex; align-items: center; gap: 9px;
  font-family: var(--body) !important;
  font-weight: 500 !important;
  margin: 4px 0;
  color: var(--ink-2);
}
.checkbox input { accent-color: var(--brand); width: 16px; height: 16px; }

/* ---------- Camera capture ---------- */
.camera-card video, .camera-card canvas, .camera-card img {
  width: 100%; height: 100%;
  min-height: 280px; max-height: 460px;
  object-fit: cover;
  position: relative; z-index: 1;
}
.camera-placeholder { display: flex; flex-direction: column; align-items: center; gap: 10px; z-index: 1; }
.camera-placeholder strong { font-family: var(--display); font-weight: 600; }
.camera-placeholder small { color: var(--muted); }
.camera-icon {
  width: 52px; height: 52px;
  border-radius: 50%;
  background: var(--brand-100);
  color: var(--brand);
  display: grid; place-items: center;
  font-size: 1.6rem;
}
.camera-message { padding: 15px; color: var(--bad); position: relative; z-index: 3; }
.camera-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

/* ---------- Meta grids ---------- */
.admission-meta, .detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin: 6px 0;
}
.admission-meta div, .detail-grid div {
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  text-align: left;
}
.admission-meta strong, .admission-meta span, .detail-grid span, .detail-grid strong { display: block; }
.admission-meta strong, .detail-grid span {
  font-family: var(--display);
  font-size: .66rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--muted);
}
.admission-meta span, .detail-grid strong {
  font-family: var(--mono);
  font-size: .85rem;
  font-weight: 500;
  margin-top: 5px;
  color: var(--ink);
}

/* ---------- Result shell ---------- */
.result-shell {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 36px 32px;
  box-shadow: var(--shadow);
}
.result-shell.success { border-top: 3px solid var(--ok); }
.result-shell.duplicate { border-top: 3px solid var(--bad); }
.result-mark {
  width: 58px; height: 58px;
  border-radius: 50%;
  display: grid; place-items: center;
  margin: 0 auto 18px;
  background: var(--ok-soft);
  color: var(--ok);
  font-size: 1.8rem;
  font-weight: 900;
}
.duplicate .result-mark { background: var(--bad-soft); color: var(--bad); }
.attendee-photo, .photo-missing {
  width: 100%;
  max-height: 420px;
  border-radius: var(--radius);
  object-fit: cover;
  margin: 18px 0;
}
.photo-missing {
  display: grid; place-items: center;
  background: var(--bg);
  border: 1px dashed var(--line-2);
  color: var(--muted);
  padding: 60px 20px;
  font-size: .9rem;
}
.result-shell > .button { width: 100%; margin-top: 10px; }
.result-shell .detail-grid { margin: 18px 0; }

/* On a duplicate the face is the decision, so it comes first, framed in the alert color, and the
   wristband code drops to supporting detail. */
.attendee-photo-lead {
  margin: 4px auto 16px;
  max-width: 340px;
  aspect-ratio: 3 / 4;
  max-height: none;
  border: 3px solid var(--bad);
}
.photo-missing-lead { margin: 4px auto 16px; max-width: 340px; aspect-ratio: 3 / 4; padding: 24px; }
.result-shell h1.result-code {
  font-family: var(--mono);
  font-size: 1.5rem;
  margin: 10px 0 4px;
  color: var(--ink-2);
}
.result-check { margin: 0; font-size: .82rem; color: var(--muted); }
.duplicate .result-lead { font-size: 1.02rem; }

.danger-zone {
  text-align: left;
  border-top: 1px solid var(--line);
  margin-top: 26px;
  padding-top: 22px;
}
.danger-zone summary {
  font-family: var(--display);
  font-weight: 600;
  color: var(--bad);
  cursor: pointer;
}
.danger-zone p { font-size: .84rem; color: var(--muted); }
.danger-zone .form-stack { margin-top: 12px; }

/* ---------- Auth ---------- */
.auth-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(120% 80% at 50% -10%, var(--brand-100) 0, rgba(242, 236, 251, 0) 60%),
    var(--bg);
}
.auth-card {
  width: min(420px, 100%);
  background: var(--surface);
  border: 1px solid var(--line);
  border-top: 3px solid var(--brand);
  border-radius: 18px;
  padding: 40px 36px;
  box-shadow: var(--shadow-lg);
}
.auth-logo { width: 170px; margin-bottom: 26px; }
.auth-card .eyebrow { margin-bottom: 8px; }
.auth-card .button { margin-top: 10px; }

/* ---------- Flash ---------- */
.flash {
  max-width: 720px;
  margin: 0 auto 22px;
  padding: 14px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  font-weight: 500;
  font-size: .88rem;
}
.flash-notice { background: var(--ok-soft); border-color: rgba(13, 122, 83, .2); color: var(--ok); }
.flash-alert { background: var(--bad-soft); border-color: rgba(194, 47, 58, .2); color: var(--bad); }

/* ---------- Misc ---------- */
.centered { text-align: center; padding: 48px 32px; max-width: 520px; margin: 60px auto; }
.centered.panel { box-shadow: var(--shadow); }
.audit-panel { max-width: none; }
.live-feed-status {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: var(--ok);
  font-family: var(--mono);
  font-size: .72rem;
  font-weight: 600;
}
.live-feed-status i {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: currentColor;
  box-shadow: 0 0 0 4px var(--ok-soft);
  animation: live-pulse 1.8s ease-out infinite;
}
.live-feed-error { color: var(--warn); }
.live-feed-error i { box-shadow: 0 0 0 4px var(--warn-soft); }
@keyframes live-pulse {
  0% { box-shadow: 0 0 0 0 rgba(13, 122, 83, .35); }
  70%, 100% { box-shadow: 0 0 0 7px rgba(13, 122, 83, 0); }
}
.admin-heading { max-width: 720px; }
.admin-grid, .user-admin-grid {
  display: grid;
  grid-template-columns: minmax(300px, 370px) minmax(0, 1fr);
  gap: 24px;
  align-items: start;
}
.admin-grid > *, .user-admin-grid > * { min-width: 0; }
.user-create-panel { position: sticky; top: 92px; }
.user-create-form { padding: 24px; }
.user-create-form .button { margin-top: 8px; }
.user-list-panel .panel-heading > span { color: var(--muted); font-size: .8rem; }
.users-admin-grid { grid-template-columns: minmax(300px, 340px) minmax(0, 1fr); }
.members-table { table-layout: fixed; }
.members-table .member-name { width: 18%; }
.members-table .member-email { width: 24%; }
.members-table .member-role { width: 18%; }
.members-table .member-event { width: 18%; }
.members-table .member-action { width: 22%; }
.members-table th, .members-table td { padding-left: 12px; padding-right: 12px; }
.members-table td { overflow: hidden; text-overflow: ellipsis; }
.members-table .inline-form { gap: 6px; min-width: 0; }
.members-table .inline-form select { width: 100%; min-width: 0; padding-left: 10px; padding-right: 28px; }
.members-table .inline-form .link-button { flex: none; }
.member-event-cell span, .member-event-cell small { display: block; overflow: hidden; text-overflow: ellipsis; }
.member-event-cell small { margin-top: 4px; color: var(--muted); font-size: .68rem; }
.table-action-primary { color: var(--brand); font-weight: 600; }
.muted-text { color: var(--muted); font-size: .76rem; }
.focused-form-panel { width: min(720px, 100%); }
.panel-subtitle { margin: 3px 0 0; color: var(--muted); font-size: .76rem; }
.member-security-panel, .member-access-panel { margin-top: 18px; }
.member-status {
  display: inline-flex;
  align-items: center;
  width: max-content;
  padding: 4px 9px;
  border-radius: 999px;
  font-size: .68rem;
  font-weight: 700;
}
.member-status-active { color: var(--ok); background: var(--ok-soft); }
.member-status-inactive { color: var(--bad); background: var(--bad-soft); }
.members-table td:first-child .member-status { margin: 5px 0 0 7px; vertical-align: middle; }
.member-row-inactive td { color: var(--muted); background: var(--bg); }
.member-inactive-callout, .member-security-note, .member-access-action {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 22px 24px;
}
.member-inactive-callout { background: var(--bad-soft); }
.member-inactive-callout p, .member-security-note p, .member-access-action p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: .78rem;
}
.member-inactive-callout form, .member-access-action form { flex: none; }
.password-reset-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.password-reset-grid > div { display: grid; gap: 7px; }
.member-security-note { display: block; }
.member-access-action { padding: 0; }
.member-access-action > div { max-width: 460px; }
.member-access-action .button { margin: 0; width: auto; }
.event-access-fieldset { padding: 18px 0 4px; margin: 12px 0 0; border: 0; border-top: 1px solid var(--line); }
.event-access-fieldset legend { padding: 18px 0 0; color: var(--ink); font-family: var(--display); font-size: .86rem; font-weight: 600; }
.form-help { margin: 0 0 8px; color: var(--muted); font-size: .76rem; }
.checkbox-list { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.panel-form .checkbox-card {
  display: flex;
  align-items: center;
  gap: 11px;
  min-width: 0;
  padding: 12px;
  margin: 0;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 10px;
  cursor: pointer;
}
.checkbox-card:has(input:checked) { background: var(--brand-100); border-color: var(--brand-200); }
.checkbox-card input { flex: none; accent-color: var(--brand); }
.checkbox-card span { min-width: 0; }
.checkbox-card strong, .checkbox-card small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.checkbox-card strong { color: var(--ink); font-size: .8rem; }
.checkbox-card small { margin-top: 2px; color: var(--muted); font-size: .68rem; font-weight: 500; }

.workspace-nav { display: flex; gap: 4px; margin: -12px 0 28px; padding: 5px; overflow-x: auto; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 1px 2px rgba(27, 22, 38, .03); scrollbar-width: none; }
.workspace-nav::-webkit-scrollbar { display: none; }
.workspace-nav a { flex: none; padding: 9px 14px; border-radius: 8px; color: var(--ink-2); font-family: var(--display); font-size: .82rem; font-weight: 600; text-decoration: none; }
.workspace-nav a:hover { color: var(--brand); background: var(--brand-100); }
.workspace-nav a.active { color: #fff; background: var(--primary-bg); }
.workspace-summary { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; margin-bottom: 22px; }
.summary-card { padding: 20px; }
.summary-card > span { color: var(--muted); font-size: .74rem; font-weight: 600; }
.summary-card > strong { display: block; margin: 8px 0 14px; font-family: var(--display); font-size: 1.65rem; }
.summary-card > a { color: var(--brand); font-size: .76rem; font-weight: 600; text-decoration: none; }
.setup-panel .panel-heading > div .eyebrow { margin-bottom: 4px; }
.setup-list { padding: 8px 20px 18px; }
.setup-item { display: grid; grid-template-columns: 36px 1fr auto; gap: 14px; align-items: center; padding: 15px 6px; color: var(--ink); border-bottom: 1px solid var(--line); text-decoration: none; }
.setup-item:last-child { border-bottom: 0; }
.setup-item:hover strong, .setup-item > b { color: var(--brand); }
.setup-item small { display: block; margin-top: 3px; color: var(--muted); }
.setup-check { width: 32px; height: 32px; display: grid; place-items: center; border-radius: 50%; background: var(--brand-100); color: var(--brand); font-family: var(--mono); font-size: .75rem; font-weight: 700; }
.setup-item.is-complete .setup-check { background: var(--ok-soft); color: var(--ok); }
.setup-item.is-disabled { pointer-events: none; opacity: .52; }
.operations-panel { overflow: hidden; }
.operation-list { padding: 4px 22px; }
.operation-item { display: flex; align-items: center; justify-content: space-between; gap: 24px; padding: 18px 0; border-bottom: 1px solid var(--line); }
.operation-item:last-child { border-bottom: 0; }
.operation-item strong { display: block; font-family: var(--display); }
.operation-item small { display: block; margin-top: 4px; color: var(--muted); }
.operation-item form { flex: none; margin: 0; }
.operation-item .button { padding: 10px 14px; }
.operations-footer { display: flex; align-items: center; gap: 18px; padding: 14px 22px; background: var(--bg); border-top: 1px solid var(--line); color: var(--muted); font-size: .76rem; }
.operations-footer a { color: var(--brand); font-weight: 600; text-decoration: none; }
.operations-footer a:hover { text-decoration: underline; }
.settings-card { max-width: 820px; }
.settings-row { display: flex; align-items: center; justify-content: space-between; gap: 24px; padding: 24px; }
.settings-row strong { font-family: var(--display); }
.settings-row p { max-width: 620px; margin: 7px 0 0; color: var(--muted); font-size: .84rem; }
.locked-policy { flex: none; padding: 6px 10px; color: var(--muted); background: var(--bg); border: 1px solid var(--line); border-radius: 999px; font-size: .68rem; font-weight: 600; }

.scope-page { width: min(720px, 100%); margin: 0 auto; }
.scope-heading {
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}
.scope-heading .page-icon {
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  color: var(--brand);
  background: linear-gradient(145deg, var(--surface), var(--brand-100));
  border: 1px solid var(--brand-200);
  border-radius: 14px;
  box-shadow: 0 6px 18px rgba(68, 0, 153, .09);
}
.scope-heading .page-icon svg { width: 23px; height: 23px; fill: currentColor; }
.scope-heading h1 { margin-bottom: 8px; }
.scope-heading p:last-child { margin-bottom: 0; }
.scope-card {
  border-color: var(--brand-200);
  box-shadow: 0 18px 45px rgba(32, 18, 54, .08);
}
.scope-card .panel-form { padding: 26px; }
.scope-card select { min-height: 50px; background-color: var(--surface); }
.pagination {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 16px;
  padding: 16px 18px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: .8rem;
  text-align: center;
}
.pagination strong { color: var(--ink); font-family: var(--mono); }
.pagination .button { padding: 8px 13px; font-size: .8rem; }
.pagination .disabled { opacity: .45; cursor: default; }
.text-danger { color: var(--bad); }

/* ---------- Analytics ---------- */
.analytics-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 24px;
}
.period-switcher {
  display: inline-flex;
  padding: 4px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: 0 1px 2px rgba(27, 22, 38, .04);
}
.period-switcher a {
  padding: 7px 12px;
  border-radius: 8px;
  color: var(--muted);
  font-family: var(--display);
  font-size: .78rem;
  font-weight: 600;
  text-decoration: none;
}
.period-switcher a:hover { color: var(--brand); }
.period-switcher a.active { color: #fff; background: var(--primary-bg); box-shadow: 0 3px 10px rgba(68, 0, 153, .18); }
.analytics-metrics article { min-height: 138px; }
.analytics-metrics small { display: block; margin-top: 7px; color: var(--muted); font-size: .72rem; }
.analytics-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 20px;
}
.analytics-chart .panel-heading > div span { display: block; margin-top: 3px; color: var(--muted); font-size: .72rem; }
.activity-chart { grid-column: 1 / -1; }
.activity-bars {
  min-height: 260px;
  padding: 28px 24px 18px;
  display: flex;
  align-items: end;
  gap: clamp(5px, 1.2vw, 14px);
  overflow-x: auto;
  background: linear-gradient(to bottom, rgba(232, 229, 240, .55) 1px, transparent 1px);
  background-size: 100% 25%;
}
.activity-column {
  min-width: 26px;
  flex: 1 0 26px;
  height: 205px;
  display: flex;
  flex-direction: column;
  justify-content: end;
  align-items: center;
  gap: 7px;
}
.activity-column i {
  width: min(30px, 75%);
  max-height: 155px;
  min-height: 4px;
  display: block;
  border-radius: 6px 6px 2px 2px;
  background: linear-gradient(180deg, #7440b7, var(--brand));
  box-shadow: 0 4px 10px rgba(68, 0, 153, .16);
}
.activity-column small { color: var(--muted); font-family: var(--mono); font-size: .58rem; white-space: nowrap; }
.activity-value { color: var(--ink-2); font-family: var(--mono); font-size: .62rem; }
.breakdown-list { padding: 8px 22px 20px; }
.breakdown-row { padding: 12px 0; }
.breakdown-row > div:first-child { display: flex; justify-content: space-between; gap: 12px; font-size: .8rem; }
.breakdown-row span { color: var(--muted); font-family: var(--mono); }
.breakdown-track { height: 7px; margin-top: 8px; overflow: hidden; background: var(--brand-100); border-radius: 999px; }
.breakdown-track i { height: 100%; display: block; background: var(--brand); border-radius: inherit; }
.analytics-table { padding: 6px 22px 18px; }
.analytics-table > div {
  min-width: 440px;
  display: grid;
  grid-template-columns: minmax(160px, 1fr) repeat(3, 72px);
  gap: 12px;
  align-items: center;
  padding: 11px 0;
  border-bottom: 1px solid var(--line);
  font-size: .78rem;
}
.analytics-table > div:last-child { border-bottom: 0; }
.analytics-table > div span:not(:first-child) { font-family: var(--mono); text-align: right; }
.analytics-table-head { color: var(--muted); font-family: var(--display); font-size: .64rem !important; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; }

:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; border-radius: 4px; }

/* ---------- Responsive ---------- */
@media (max-width: 1050px) {
  .nav-shell {
    flex-wrap: wrap;
    gap: 8px;
    padding-top: 10px;
    padding-bottom: 8px;
  }
  .nav-links {
    order: 2;
    width: 100%;
    padding-top: 7px;
    border-top: 1px solid var(--line);
    overflow-x: auto;
    scrollbar-width: none;
  }
  .nav-links::-webkit-scrollbar { display: none; }
  .role-badge { margin-left: auto; }
  .current-context { margin-left: auto; }
}
@media (max-width: 1180px) and (min-width: 901px) {
  .users-admin-grid { grid-template-columns: 300px minmax(0, 1fr); }
  .members-table th, .members-table td { padding-left: 9px; padding-right: 9px; }
  .members-table .inline-form { align-items: stretch; flex-direction: column; }
  .members-table .inline-form .link-button { align-self: flex-start; }
}
@media (max-width: 900px) {
  .admin-grid, .user-admin-grid { grid-template-columns: 1fr; }
  .user-create-panel { position: static; }
}
@media (max-width: 760px) {
  .main-shell { padding: 28px 16px 72px; }
  .nav-shell { padding: 0 14px; }
  .brand img { width: 100px; }
  .brand span, .role-badge, .event-badge { display: none; }
  .current-context { max-width: 185px; }
  .current-context > span { display: none; }
  .current-context strong { align-self: center; }
  .profile-name { display: none; }
  .profile-popover { position: fixed; top: 112px; right: 14px; }
  .page-heading-actions { align-items: stretch; flex-direction: column; }
  .page-heading-actions .button { align-self: flex-start; }
  .workspace-nav { margin-top: -14px; }
  .workspace-summary { grid-template-columns: 1fr; }
  .operation-item { align-items: stretch; flex-direction: column; gap: 14px; }
  .operation-item .button { width: 100%; }
  .operations-footer { align-items: flex-start; flex-direction: column; gap: 8px; }
  .form-grid-two { grid-template-columns: 1fr; gap: 0; }
  .form-actions { align-items: stretch; flex-direction: column-reverse; }
  .panel-form .form-actions .button { width: 100%; }
  .policy-note, .settings-row { align-items: flex-start; flex-direction: column; }
  .account-result { grid-template-columns: 1fr; }
  .account-result .text-button { grid-column: 1; grid-row: auto; justify-self: start; padding-left: 0; }
  .nav-links { gap: 2px; }
  .nav-links > .event-switch-link { padding: 8px; margin-left: 0; }
  .event-switch-link span { display: none; }
  .metrics { grid-template-columns: 1fr 1fr; gap: 12px; }
  .metrics article { padding: 16px; }
  .metrics strong { font-size: 1.7rem; }
  .camera-actions { grid-template-columns: 1fr; }
  .admin-grid, .user-admin-grid { grid-template-columns: 1fr; gap: 16px; }
  .panel-form { padding: 20px; }
  .password-reset-grid { grid-template-columns: 1fr; }
  .member-inactive-callout, .member-access-action { align-items: stretch; flex-direction: column; }
  .member-inactive-callout .button, .member-access-action .button { width: 100%; }
  .scope-heading { grid-template-columns: 40px minmax(0, 1fr); gap: 12px; }
  .scope-heading .page-icon { width: 40px; height: 40px; border-radius: 12px; }
  .pagination { grid-template-columns: 1fr 1fr; }
  .pagination > span:not(.button) { grid-column: 1 / -1; grid-row: 1; }
  .result-shell { padding: 28px 20px; }
  .auth-card { padding: 30px 24px; }
  .analytics-heading { align-items: stretch; flex-direction: column; }
  .period-switcher { align-self: flex-start; }
  .analytics-grid { grid-template-columns: 1fr; }
  .activity-chart { grid-column: auto; }
  .analytics-table { overflow-x: auto; }
  .members-table-wrap { overflow: visible; padding: 12px; }
  .members-table, .members-table tbody, .members-table tr, .members-table td { display: block; width: 100%; }
  .members-table colgroup, .members-table thead { display: none; }
  .members-table tr {
    margin-bottom: 12px;
    padding: 6px 14px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 12px;
    box-shadow: 0 4px 14px rgba(27, 22, 38, .04);
  }
  .members-table tr:last-child { margin-bottom: 0; }
  .members-table td {
    display: grid;
    grid-template-columns: 112px minmax(0, 1fr);
    gap: 12px;
    align-items: center;
    padding: 10px 0;
    border-bottom: 1px solid var(--line);
    white-space: normal;
    overflow: visible;
  }
  .members-table td:last-child { border-bottom: 0; }
  .members-table td::before {
    content: attr(data-label);
    color: var(--muted);
    font-family: var(--display);
    font-size: .66rem;
    font-weight: 600;
    letter-spacing: .06em;
    text-transform: uppercase;
  }
  .members-table .member-email-cell, .members-table .member-event-cell { overflow-wrap: anywhere; }
  .checkbox-list { grid-template-columns: 1fr; }
  /* Gate outcomes are controls, not page content. Keep them in the visual viewport so staff
     receive immediate confirmation and never have to scroll to find the photo button. */
  .gate-sheet {
    position: fixed;
    z-index: 100;
    right: 12px;
    bottom: max(12px, env(safe-area-inset-bottom));
    left: 12px;
    width: auto;
    max-width: 536px;
    max-height: min(76dvh, 680px);
    margin: 0 auto;
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: 16px;
    border-radius: 20px;
    box-shadow: 0 24px 70px rgba(20, 12, 35, .3);
  }
  .gate-sheet.gate-sheet-photo-ready { gap: 8px; }
  .gate-sheet.gate-sheet-photo-ready .gate-sheet-note { display: none; }
  .gate-sheet.gate-sheet-photo-ready .button-jumbo { min-height: 60px; }
  .gate-sheet.gate-sheet-photo-ready .button-quiet { min-height: 44px; }
}
@media (max-width: 400px) {
  .metrics { grid-template-columns: 1fr; }
  .nav-links { font-size: .82rem; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}

/* Keep the empty mount point measurable so html5-qrcode does not create a 0px-wide video. */
.qr-reader:empty { display: block; }
.qr-reader video { display: block !important; width: 100% !important; max-height: 460px; object-fit: cover; }
