/* NextGen Traders Summit 2026: one stylesheet for every page. */

:root {
  color-scheme: light dark;
  --bg: #f5f6f8;
  --surface: #ffffff;
  --surface-2: #f8f9fb;
  --surface-3: #eceef2;
  --text: #101418;
  --muted: #667085;
  --placeholder: #98a2b3;
  --border: #e4e7ec;
  --border-strong: #d0d5dd;
  --primary: #101418;
  --primary-hover: #2a3038;
  --on-primary: #ffffff;
  --accent: #ff444f;
  --ring: rgba(16, 20, 24, 0.14);

  --success: #067647;
  --success-bg: #ecfdf3;
  --success-border: #abefc6;
  --warning: #b54708;
  --warning-bg: #fffaeb;
  --warning-border: #fedf89;
  --danger: #b42318;
  --danger-bg: #fef3f2;
  --danger-border: #fecdca;

  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.05);
  --shadow-lg: 0 24px 48px -12px rgba(16, 24, 40, 0.35);
  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, monospace;
  --chevron: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%23667085' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  --search: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2398a2b3' stroke-width='2.2' stroke-linecap='round'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='m20 20-3.5-3.5'/%3E%3C/svg%3E");
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b0d10;
    --surface: #14171c;
    --surface-2: #191d23;
    --surface-3: #262b33;
    --text: #eef0f3;
    --muted: #98a2b3;
    --placeholder: #667085;
    --border: #252a32;
    --border-strong: #363d48;
    --primary: #f2f4f7;
    --primary-hover: #d0d5dd;
    --on-primary: #0b0d10;
    --ring: rgba(242, 244, 247, 0.2);
    --success: #47cd89;
    --success-bg: rgba(71, 205, 137, 0.12);
    --success-border: rgba(71, 205, 137, 0.3);
    --warning: #fdb022;
    --warning-bg: rgba(253, 176, 34, 0.12);
    --warning-border: rgba(253, 176, 34, 0.3);
    --danger: #f97066;
    --danger-bg: rgba(249, 112, 102, 0.12);
    --danger-border: rgba(249, 112, 102, 0.3);
    --shadow: none;
  }
}

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

html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 var(--font);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
/* No 300 ms double-tap-zoom delay on taps */
a, button, input, select, label, summary { touch-action: manipulation; }
h1, h2, h3 { margin: 0; font-weight: 650; line-height: 1.25; letter-spacing: -0.015em; }
h1 { font-size: 22px; }
p { margin: 0; }
a { color: inherit; }
button, input, select { font: inherit; color: inherit; }
.muted { color: var(--muted); }
.mono { font-family: var(--mono); font-size: 0.92em; }

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

.w-narrow { --w: 480px; }
.w-medium { --w: 600px; }
.w-register, .w-scan { --w: 1040px; }
.w-wide { --w: 1240px; }

/* Side gutters that also clear the notch in landscape */
:root {
  --gutter-l: max(16px, env(safe-area-inset-left));
  --gutter-r: max(16px, env(safe-area-inset-right));
  --topbar-h: calc(64px + env(safe-area-inset-top)); /* 60px bar + 3px coral line + 1px border */
}

/* The header (and the staff tab bar inside it) stays light in dark mode too:
   the NextGen logo's navy lettering is designed for a white background. */
.topbar {
  --surface: #ffffff;
  --surface-2: #f8f9fb;
  --surface-3: #eceef2;
  --text: #101418;
  --muted: #667085;
  --border: #e4e7ec;
  --ring: rgba(16, 20, 24, 0.14);
  color-scheme: light;
  position: sticky;
  top: 0;
  z-index: 20;
  padding-top: env(safe-area-inset-top);
  border-top: 3px solid var(--accent); /* Deriv coral */
  background: var(--surface);
  color: var(--text);
  border-bottom: 1px solid var(--border);
}

/* "Powered by deriv": top bar on laptops; footer on phones and on staff pages */
.powered { display: inline-flex; align-items: center; gap: 7px; color: var(--muted); font-size: 12px; white-space: nowrap; }
.powered img { display: block; width: auto; height: 18px; }
.topbar-powered { flex: none; }
.site-foot { display: none; justify-content: center; margin-top: 32px; }
.site-foot-staff { display: flex; }
@media (max-width: 600px) {
  .topbar-powered { display: none; }
  .site-foot { display: flex; }
}
.topbar-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  max-width: var(--w);
  height: 60px;
  margin: 0 auto;
  padding: 0 var(--gutter-r) 0 var(--gutter-l);
}
.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  font-weight: 650;
  text-decoration: none;
}
.brand-logo { display: block; flex: none; width: auto; height: 40px; }
@media (max-width: 560px) {
  .brand-logo { height: 36px; }
}
.brand-tag {
  flex: none;
  padding-left: 10px;
  border-left: 1px solid var(--border);
  color: var(--muted);
  font-weight: 500;
}

.nav { display: flex; align-items: center; gap: 2px; flex: none; }
.nav form { margin: 0; }
.nav-link {
  display: inline-flex;
  align-items: center;
  height: 34px;
  padding: 0 10px;
  border: 0;
  border-radius: var(--radius-sm);
  background: none;
  color: var(--muted);
  font-size: 14px;
  font-weight: 500;
  text-decoration: none;
  cursor: pointer;
}
.nav-link:hover { background: var(--surface-2); color: var(--text); }
.nav-link.active { color: var(--text); background: var(--surface-3); }
.nav-link svg { display: none; }

.container {
  max-width: var(--w);
  margin: 0 auto;
  padding: 24px var(--gutter-r) calc(56px + env(safe-area-inset-bottom)) var(--gutter-l);
}

.page-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px 16px;
  margin-bottom: 16px;
}
.page-head p { margin-top: 4px; color: var(--muted); }
.head-actions { display: flex; flex-wrap: wrap; gap: 8px; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
}
.stack { display: grid; gap: 8px; }

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

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 44px;
  padding: 0 18px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  font-size: 15px;
  font-weight: 600;
  white-space: nowrap;
  text-decoration: none;
  cursor: pointer;
  transition: background-color 0.15s, border-color 0.15s, color 0.15s;
  -webkit-tap-highlight-color: transparent;
}
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn:focus-visible, .nav-link:focus-visible, .stat:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--ring); }
.btn svg { flex: none; }
.btn-primary { background: var(--primary); color: var(--on-primary); }
.btn-primary:hover:not(:disabled) { background: var(--primary-hover); }
.btn-secondary { background: var(--surface); border-color: var(--border-strong); color: var(--text); }
.btn-secondary:hover:not(:disabled) { background: var(--surface-2); }
.btn-ghost { background: transparent; color: var(--muted); }
.btn-ghost:hover:not(:disabled) { background: var(--surface-2); color: var(--text); }
.btn-danger { background: transparent; border-color: var(--danger-border); color: var(--danger); }
.btn-danger:hover:not(:disabled) { background: var(--danger-bg); }
.btn-light { background: #fff; color: #101418; }
.btn-light:hover:not(:disabled) { background: #eceef2; }
.btn-sm { height: 36px; padding: 0 12px; font-size: 14px; }
.btn-xs { height: 30px; padding: 0 10px; font-size: 13px; }
.btn-block { width: 100%; }

/* ---------- Forms ---------- */

.form { display: grid; gap: 16px; }
.field { display: grid; gap: 6px; }
.label { font-size: 14px; font-weight: 550; }
.input, .select {
  width: 100%;
  height: 44px;
  padding: 0 12px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background-color: var(--surface);
  font-size: 16px; /* 16px stops iOS zooming into the field */
  transition: border-color 0.15s, box-shadow 0.15s;
}
.input::placeholder { color: var(--placeholder); }
.input:focus, .select:focus { outline: none; border-color: var(--text); box-shadow: 0 0 0 3px var(--ring); }
.mono-input { font-family: var(--mono); letter-spacing: 0.02em; }
.mono-input::placeholder { font-family: var(--font); letter-spacing: 0; }
.select {
  appearance: none;
  -webkit-appearance: none;
  padding-right: 36px;
  background-image: var(--chevron);
  background-repeat: no-repeat;
  background-position: right 12px center;
  cursor: pointer;
}
.select:invalid { color: var(--placeholder); }
.select option { color: var(--text); }
.field.invalid .input, .field.invalid .select { border-color: var(--danger); }
.field.invalid .input:focus, .field.invalid .select:focus { box-shadow: 0 0 0 3px var(--danger-bg); }
.field-error { font-size: 13px; color: var(--danger); }
.field-hint { font-size: 13px; color: var(--muted); }
.field-hint a { color: var(--text); }
.input-row { display: flex; gap: 8px; }
.input-row .input { flex: 1; min-width: 0; }
.fine { font-size: 12.5px; color: var(--muted); text-align: center; }

.alert { padding: 10px 12px; border: 1px solid; border-radius: var(--radius-sm); font-size: 14px; }
.alert-danger { background: var(--danger-bg); border-color: var(--danger-border); color: var(--danger); }
.alert a { color: inherit; font-weight: 600; }

.flash {
  margin-bottom: 16px;
  padding: 10px 14px;
  border: 1px solid;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 500;
}
.flash-success { background: var(--success-bg); border-color: var(--success-border); color: var(--success); }
.flash-warning { background: var(--warning-bg); border-color: var(--warning-border); color: var(--warning); }
.flash-error { background: var(--danger-bg); border-color: var(--danger-border); color: var(--danger); }

.notice {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 20px;
  padding: 12px 14px;
  border: 1px solid var(--success-border);
  border-radius: var(--radius);
  background: var(--success-bg);
  color: var(--success);
  font-size: 14px;
  text-decoration: none;
}

/* ---------- Badges & detail lists ---------- */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 24px;
  padding: 0 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge-success { background: var(--success-bg); color: var(--success); }
.badge-muted { background: var(--surface-3); color: var(--muted); }

.details { margin: 0; border-top: 1px solid var(--border); }
/* Label left, value right; a value too long for the row (client ID, email) drops to its own line */
.details > div {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 2px 16px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}
.details dt { flex: none; color: var(--muted); font-size: 14px; }
.details dd { margin: 0 0 0 auto; min-width: 0; font-weight: 550; text-align: right; overflow-wrap: anywhere; }
.details a { text-decoration: none; }
.details a:hover { text-decoration: underline; }

/* Mentor hand-tag colours. /assets/mentors.css (generated from MENTORS in
   wrangler.jsonc) defines .tag-<mentor> { --tag: <colour> }. */
.tag-chip { display: inline-flex; align-items: center; gap: 7px; white-space: nowrap; }
.tag-dot {
  display: inline-block;
  flex: none;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--tag, var(--muted));
  box-shadow: 0 0 0 1.5px var(--surface), 0 0 0 2.5px var(--tag, var(--muted));
}
/* Mentor logo with a ring in the hand-tag colour */
.mentor-logo {
  flex: none;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  object-fit: cover;
  box-shadow: 0 0 0 1.5px var(--surface), 0 0 0 3px var(--tag, var(--border));
}
.stat-label .tag-dot, .cell-sub .tag-dot { margin: 0 8px 0 2px; vertical-align: 0; }
.stat-label .mentor-logo { margin: 0 8px 0 3px; vertical-align: middle; }
.cell-sub .mentor-logo { width: 16px; height: 16px; margin: 0 7px 0 2px; vertical-align: -3px; }
.via { margin-bottom: 12px; }
.via .mentor-logo { width: 30px; height: 30px; }
.via .tag-chip {
  padding: 5px 14px 5px 5px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  font-size: 14px;
  font-weight: 600;
}

progress.bar {
  appearance: none;
  -webkit-appearance: none;
  display: block;
  width: 100%;
  height: 6px;
  border: 0;
  border-radius: 999px;
  background: var(--surface-3);
  overflow: hidden;
}
progress.bar::-webkit-progress-bar { background: var(--surface-3); border-radius: 999px; }
progress.bar::-webkit-progress-value { background: var(--success); border-radius: 999px; }
progress.bar::-moz-progress-bar { background: var(--success); border-radius: 999px; }

/* ---------- Registration ---------- */

.register { display: grid; gap: 16px; max-width: 480px; margin: 0 auto; }
.register-intro .lead { margin-top: 4px; color: var(--muted); }
.steps { display: none; }

@media (min-width: 900px) {
  .register {
    grid-template-columns: minmax(0, 1fr) 440px;
    gap: 24px 64px;
    align-items: start;
    max-width: none;
    padding-top: 32px;
  }
  .register .notice { grid-column: 1 / -1; margin-bottom: 0; }
  .register-intro { padding-top: 8px; }
  .register-intro h1 { font-size: 36px; letter-spacing: -0.025em; }
  .register-intro .lead { margin-top: 10px; font-size: 17px; }
  .steps {
    display: grid;
    gap: 20px;
    margin: 36px 0 0;
    padding: 0;
    list-style: none;
    counter-reset: step;
  }
  .steps li {
    display: grid;
    grid-template-columns: 32px 1fr;
    column-gap: 14px;
    counter-increment: step;
  }
  .steps li::before {
    content: counter(step);
    grid-row: span 2;
    display: grid;
    place-items: center;
    width: 32px;
    height: 32px;
    border: 1px solid var(--border-strong);
    border-radius: 50%;
    background: var(--surface);
    font-size: 14px;
    font-weight: 650;
  }
  .steps strong { font-weight: 600; }
  .steps span { color: var(--muted); font-size: 14px; }
}

/* ---------- Ticket ---------- */

.ticket { display: grid; gap: 18px; text-align: center; border-top: 6px solid var(--tag, var(--border)); }
.ticket-head { display: grid; justify-items: center; gap: 6px; }
.status-icon {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  margin-bottom: 4px;
  border-radius: 50%;
  background: var(--success-bg);
  color: var(--success);
}
.qr-box {
  width: min(272px, 100%);
  margin: 0 auto;
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #fff; /* QR codes must stay dark-on-light in dark mode */
}
.qr-box img { display: block; width: 100%; height: auto; image-rendering: pixelated; }
.regid { display: grid; gap: 2px; }
.eyebrow { font-size: 12px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); }
.reg-id { font-family: var(--mono); font-size: 26px; font-weight: 700; letter-spacing: 0.06em; }
.ticket .details { text-align: left; }
.hint { margin-top: 14px; font-size: 13px; color: var(--muted); text-align: center; }

/* ---------- Login & messages ---------- */

.login { max-width: 380px; margin: 8vh auto 0; }
.login h1 { margin-bottom: 4px; }
.message { max-width: 440px; margin: 8vh auto 0; display: grid; gap: 12px; text-align: center; justify-items: center; }

/* ---------- Admin: stats ---------- */

.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}
.stat {
  display: grid;
  align-content: start;
  gap: 2px;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
  text-decoration: none;
  transition: border-color 0.15s;
}
.stat:hover { border-color: var(--border-strong); }
.stat.active { border-color: var(--text); box-shadow: inset 0 0 0 1px var(--text); }
.stat-label { font-size: 13px; color: var(--muted); }
.stat-value { font-size: 28px; font-weight: 650; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; line-height: 1.2; }
.stat-sub { font-size: 12.5px; color: var(--muted); }
.stat progress.bar { margin-top: 8px; }

/* ---------- Admin: table ---------- */

/* overflow: clip (not hidden) keeps the sticky toolbar working */
.table-card { padding: 0; overflow: hidden; overflow: clip; }
.toolbar {
  position: sticky;
  top: var(--topbar-h);
  z-index: 5;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 12px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}
.toolbar .search {
  flex: 1 1 280px;
  padding-left: 36px;
  background-image: var(--search);
  background-repeat: no-repeat;
  background-position: 12px center;
}
.toolbar .select { flex: 0 1 180px; }
.js .js-hide { display: none; }
.js-only { display: none !important; }
.js .js-only { display: inline-flex !important; }

.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-align: left;
  text-transform: uppercase;
  white-space: nowrap;
}
.table td { padding: 10px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; white-space: nowrap; }
.table tbody tr { cursor: pointer; }
.table tbody tr:hover { background: var(--surface-2); }
.table tbody tr:last-child td { border-bottom: 0; }
.table form { margin: 0; }
.row-link { font-weight: 600; text-decoration: none; }
.row-link:hover { text-decoration: underline; }
.c-name { max-width: 300px; }
.cell-email, .cell-time { overflow: hidden; color: var(--muted); font-size: 13px; text-overflow: ellipsis; }
.cell-time { margin-top: 3px; }
.reg-inline, .cell-sub { display: none; }
.c-actions { width: 1%; text-align: right; }
.empty { padding: 40px 16px; text-align: center; color: var(--muted); }
.table-foot {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 16px;
  padding: 10px 14px;
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 13px;
}
.table-wrap:has(.empty) + .table-foot { border-top: 0; }
#results { transition: opacity 0.15s; }
#results[aria-busy="true"] { opacity: 0.55; pointer-events: none; }
.select-per { flex: 0 1 150px !important; }

/* Pagination: ‹ Prev 1 … 4 5 [6] 7 8 … 12 Next › */
.pager { display: flex; align-items: center; gap: 4px; }
.pager-nums { display: flex; align-items: center; gap: 2px; }
.pager-num, .pager-step {
  display: inline-grid;
  place-items: center;
  min-width: 34px;
  height: 34px;
  padding: 0 8px;
  border-radius: var(--radius-sm);
  color: var(--text);
  font-weight: 550;
  text-decoration: none;
  font-variant-numeric: tabular-nums;
}
a.pager-num:hover, a.pager-step:hover { background: var(--surface-3); }
.pager-num.current { background: var(--primary); color: var(--on-primary); }
.pager-step.disabled { color: var(--placeholder); }
.pager-gap { padding: 0 4px; color: var(--placeholder); }
.pager-of { display: none; padding: 0 8px; color: var(--text); font-weight: 550; }

/* Smaller laptops: fold the Reg ID column into the line under the name */
@media (max-width: 1100px) {
  .table .c-reg { display: none; }
  .reg-inline { display: inline; font-family: var(--mono); }
  .c-name { max-width: 260px; }
}

/* ---------- Admin: registration links tab ---------- */

.link-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 16px; }
.link-card { display: grid; align-content: start; gap: 14px; border-top: 4px solid var(--tag, var(--border)); }
.link-card-head { display: flex; align-items: center; gap: 12px; }
.link-card-head .mentor-logo { width: 44px; height: 44px; }
.link-card h2 { font-size: 17px; }
.link-card p { margin-top: 2px; font-size: 13.5px; }
.link-card .input { font-size: 14px; }
.link-qr { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.link-qr img {
  width: 148px;
  height: 148px;
  padding: 6px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fff; /* QR codes stay dark-on-light */
  image-rendering: pixelated;
}
@media (max-width: 560px) {
  .link-grid { grid-template-columns: 1fr; }
  .link-card .input { font-size: 16px; } /* below 16px, iOS zooms in on tap */
}

/* ---------- Admin: participant ---------- */

.back-link { display: inline-block; margin-bottom: 12px; color: var(--muted); font-size: 14px; text-decoration: none; }
.back-link:hover { color: var(--text); }
.detail { display: grid; gap: 18px; }
.detail-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.detail-head .mono { margin-top: 2px; color: var(--muted); }
.detail-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.detail-actions form { margin: 0; }
.danger-zone { padding-top: 16px; border-top: 1px solid var(--border); }
.danger-zone form { margin: 0; }

/* ---------- Scanner ---------- */

.scan { display: grid; gap: 12px; max-width: 560px; margin: 0 auto; }
.scan-count { display: grid; gap: 10px; padding: 14px 16px; }
.scan-count-row { display: flex; align-items: baseline; justify-content: space-between; }
.count { color: var(--muted); font-variant-numeric: tabular-nums; }
.count strong { color: var(--text); font-size: 22px; font-weight: 650; }

.scanner { padding: 0; overflow: hidden; }
.viewfinder { position: relative; aspect-ratio: 1 / 1; background: #0b0d10; overflow: hidden; }
.viewfinder video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
/* Always a square in the middle: that is the area the decoder reads */
.frame {
  position: absolute;
  top: 50%;
  left: 50%;
  height: 70%;
  aspect-ratio: 1 / 1;
  transform: translate(-50%, -50%);
  border: 2px solid rgba(255, 255, 255, 0.9);
  border-radius: 20px;
  box-shadow: 0 0 0 100vmax rgba(0, 0, 0, 0.32);
  pointer-events: none;
}
.scanner-idle {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 14px;
  padding: 24px;
  background: #0b0d10;
  color: #d0d5dd;
  text-align: center;
}
.scanner-idle p { max-width: 300px; font-size: 14px; }
.scanner-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 52px;
  padding: 8px 8px 8px 16px;
  color: var(--muted);
  font-size: 13px;
}
.manual { display: grid; gap: 8px; padding: 16px; }

/* Laptops: camera on the left, counter and manual entry on the right */
@media (min-width: 900px) {
  .scan {
    grid-template-columns: minmax(0, 1fr) 340px;
    grid-template-areas: "camera count" "camera manual" "camera rest";
    grid-template-rows: auto auto 1fr;
    align-items: start;
    gap: 16px;
    max-width: none;
  }
  .scan-count { grid-area: count; }
  .scanner { grid-area: camera; }
  .manual { grid-area: manual; }
  .viewfinder { aspect-ratio: 4 / 3; max-height: calc(100dvh - var(--topbar-h) - 140px); width: 100%; }
}

.result {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: max(16px, env(safe-area-inset-top)) var(--gutter-r) max(16px, env(safe-area-inset-bottom)) var(--gutter-l);
  animation: fade-in 0.15s ease-out;
}
.result.success { background: rgba(7, 148, 85, 0.95); }
.result.warning { background: rgba(220, 104, 3, 0.95); }
.result.danger { background: rgba(217, 45, 32, 0.95); }
.result-card {
  width: min(440px, 100%);
  overflow: hidden;
  border-radius: 16px;
  background: var(--surface);
  box-shadow: var(--shadow-lg);
  animation: pop-in 0.18s ease-out;
}
.result-head { padding: 24px 20px 14px; text-align: center; }
.result-title { font-size: 21px; font-weight: 750; letter-spacing: 0.01em; }
.success .result-title { color: var(--success); }
.warning .result-title { color: var(--warning); }
.danger .result-title { color: var(--danger); }
.result-name { margin-top: 8px; font-size: 20px; font-weight: 600; overflow-wrap: anywhere; }
.result-body { display: grid; gap: 16px; padding: 0 20px 20px; }
.result-body .btn { height: 52px; font-size: 16px; }
.result-message { color: var(--muted); text-align: center; }
.result-note {
  padding: 10px 12px;
  border: 1px solid var(--warning-border);
  border-radius: var(--radius-sm);
  background: var(--warning-bg);
  color: var(--warning);
  font-weight: 600;
  text-align: center;
}
.result-tag {
  display: grid;
  justify-items: center;
  gap: 2px;
  padding: 14px 16px;
  border-radius: 12px;
  background: var(--tag, #344054);
  color: #fff;
  text-align: center;
}
.result-tag-logo {
  width: 52px;
  height: 52px;
  margin-bottom: 8px;
  border-radius: 50%;
  object-fit: cover;
  background: #fff;
  box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.9);
}
.result-tag-label { font-size: 12px; font-weight: 600; letter-spacing: 0.1em; text-transform: uppercase; opacity: 0.85; }
.result-tag-color { font-size: 28px; font-weight: 800; letter-spacing: 0.02em; line-height: 1.15; text-transform: uppercase; }
.result-tag-mentor { font-size: 14px; font-weight: 500; opacity: 0.9; }
.result-timer { height: 4px; background: var(--success); transform-origin: left; animation: shrink 2.5s linear forwards; }

@keyframes fade-in { from { opacity: 0; } }
@keyframes pop-in { from { opacity: 0; transform: scale(0.96); } }
@keyframes shrink { to { transform: scaleX(0); } }
@media (prefers-reduced-motion: reduce) {
  .result, .result-card { animation: none; }
}

/* ---------- Phones & small tablets ---------- */

@media (max-width: 760px) {
  /* Staff navigation becomes a bottom tab bar, like a native app */
  .staff .nav {
    position: fixed;
    right: 0;
    bottom: 0;
    left: 0;
    z-index: 30;
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0;
    padding: 0 env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
    border-top: 1px solid var(--border);
    background: var(--surface);
  }
  .staff .nav form, .staff .nav form .nav-link { width: 100%; }
  .staff .nav-link {
    flex-direction: column;
    justify-content: center;
    gap: 3px;
    height: 58px;
    border-radius: 0;
    font-size: 11px;
    font-weight: 550;
  }
  .staff .nav-link svg { display: block; }
  .staff .nav-link:hover { background: none; }
  .staff .nav-link.active { background: none; color: var(--text); }
  .staff .container { padding-bottom: calc(88px + env(safe-area-inset-bottom)); }
  .hide-phone { display: none !important; }

  /* Participant rows become compact cards */
  .table thead { display: none; }
  .table, .table tbody { display: block; }
  .table tr {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas: "name status" "name actions";
    align-items: center;
    gap: 6px 12px;
    padding: 12px 14px;
    border-bottom: 1px solid var(--border);
  }
  .table tbody tr:last-child { border-bottom: 0; }
  .table td { display: none; padding: 0; border: 0; white-space: normal; }
  .table td.c-name { display: block; grid-area: name; max-width: none; }
  .table td.c-status { display: block; grid-area: status; justify-self: end; }
  .table td.c-actions { display: block; grid-area: actions; justify-self: end; width: auto; }
  .table .btn-xs { height: 34px; padding: 0 12px; }
  .cell-email, .cell-time { display: none; }
  .cell-sub { display: block; margin-top: 2px; color: var(--muted); font-size: 13px; }
  .toolbar .select { flex: 1 1 140px; }
}

@media (max-width: 560px) {
  .container { padding-top: 16px; }
  .card { padding: 16px; }
  .table-card, .scanner { padding: 0; }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .stats .stat:first-child { grid-column: 1 / -1; }
  .stat { padding: 12px 14px; }
  .stat-value { font-size: 24px; }
  .brand-tag { display: none; }
  .page-head .head-actions { display: grid; grid-template-columns: 1fr 1fr; width: 100%; }
  .table-foot { flex-direction: column; align-items: stretch; gap: 6px; text-align: center; }
  .select-per { display: none; } /* phones page with Prev / Next at the default size */
  .pager { justify-content: space-between; order: -1; }
  .pager-nums { display: none; }
  .pager-of { display: inline; }
  .pager-step { min-width: 88px; border: 1px solid var(--border-strong); }
  .pager-step.disabled { border-color: var(--border); }
  .detail-actions form, .detail-actions .btn { width: 100%; }

  /* Edge-to-edge camera, like a native scanner */
  .scanner {
    margin: 0 calc(-1 * var(--gutter-r)) 0 calc(-1 * var(--gutter-l));
    border-right: 0;
    border-left: 0;
    border-radius: 0;
  }
}
