/* ════════════════════════════════════════════════════════════
   EVACUATION REGISTER PWA — mobile-first
   Designed for stress conditions: big targets, high contrast,
   no flourishes, predictable layout.
   ════════════════════════════════════════════════════════════ */

* { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  /* Travel Planner — graphite + petrol teal blend.
     Danger / missing kept red so emergency status reads correctly under stress. */
  --bg:          #F7F8FA;
  --card:        #ffffff;
  --border:      #E5E7EB;
  --text:        #14181E;        /* Graphite */
  --muted:       #4B5563;        /* Cool slate */
  --primary:     #0F766E;        /* Petrol teal */
  --danger:      #DC2626;        /* Semantic red — kept for missing/danger */
  --danger-dark: #991B1B;
  --navy:        #14181E;        /* Graphite */
  --present:     #15803D;        /* Success green */
  --present-bg:  #DCFCE7;
  --missing:     #DC2626;
  --missing-bg:  #FEE2E2;
  --safe:        #D97706;        /* Amber accent */
  --safe-bg:     #FEF3C7;
  --unknown:     #4B5563;
  --unknown-bg:  #F3F4F6;
  --shadow:      0 1px 3px rgb(0 0 0 / .08), 0 1px 2px rgb(0 0 0 / .06);
  --shadow-lg:   0 10px 30px rgb(0 0 0 / .15);
  --font-body:    "PT Sans Narrow", -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-display: "Poppins", -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

/* Material Symbols Rounded base */
.material-symbols-rounded {
  font-family: 'Material Symbols Rounded', sans-serif;
  font-weight: normal;
  font-style: normal;
  font-size: 22px;
  line-height: 1;
  letter-spacing: normal;
  text-transform: none;
  display: inline-block;
  white-space: nowrap;
  word-wrap: normal;
  direction: ltr;
  font-feature-settings: 'liga';
  -webkit-font-feature-settings: 'liga';
  -webkit-font-smoothing: antialiased;
  vertical-align: middle;
  font-variation-settings: 'FILL' 0, 'wght' 400, 'GRAD' 0, 'opsz' 24;
}

html, body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  font-size: 16px;
  line-height: 1.5;
  min-height: 100vh;
  overscroll-behavior: contain;
}

h1, h2, h3, h4, .evac-brand, .mark-name, .summary-num {
  font-family: var(--font-display);
}

.hidden { display: none !important; }

/* ── Layout ────────────────────────────────────────────── */
.evac-screen {
  min-height: 100vh;
  padding: 0 1rem 6rem;  /* tail padding so floating buttons don't hide content */
  max-width: 640px;
  margin: 0 auto;
}

.evac-card {
  background: var(--card);
  border-radius: 12px;
  padding: 1.25rem;
  box-shadow: var(--shadow);
  margin-top: 1rem;
}

.evac-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: var(--card);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: .875rem 0;
  margin: 0 -1rem;
  padding-left: 1rem;
  padding-right: 1rem;
  border-bottom: 1px solid var(--border);
}
.evac-header.active-header {
  background: var(--danger);
  color: #fff;
  border-bottom: none;
}
.evac-header-title {
  display: flex;
  align-items: center;
  gap: .5rem;
}
.evac-sub { font-size: .75rem; opacity: .85; }
.evac-header-btn {
  background: rgba(255,255,255,.18);
  color: #fff;
  border: none;
  padding: .5rem .875rem;
  border-radius: 8px;
  font-size: .875rem;
  font-weight: 600;
  cursor: pointer;
}
.evac-header:not(.active-header) .evac-header-btn {
  background: var(--unknown-bg);
  color: var(--text);
}
.evac-header-btn.back { background: transparent; color: inherit; padding-left: 0; }

.evac-icon { font-size: 1.5rem; color: var(--danger); }
.mark-btn .mark-ico {
  font-size: 22px;
  margin-right: .375rem;
  color: currentColor;
  vertical-align: -5px;
}
.evac-icon.pulse { animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%      { opacity: .5; transform: scale(.9); }
}

.evac-brand {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: .5rem;
  margin-bottom: 1.5rem;
}
.evac-logo {
  width: 180px;
  max-width: 100%;
  height: auto;
  display: block;
}
.evac-product {
  font-family: var(--font-display);
  font-size: .75rem;
  color: var(--muted);
  letter-spacing: .04em;
  text-transform: uppercase;
  font-weight: 500;
}
/* Legacy wordmark — harmless if templates still reference it */
.evac-wordmark { display: none; }

h2 { font-size: 1.25rem; font-weight: 700; margin-bottom: .5rem; }
h3.section-h {
  font-size: .8125rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--muted);
  margin: 1.5rem 0 .5rem;
  display: flex;
  align-items: center;
  gap: .5rem;
}
.section-count {
  background: var(--unknown-bg);
  color: var(--muted);
  padding: 1px 8px;
  border-radius: 999px;
  font-size: .75rem;
  font-weight: 600;
}

.evac-help { color: var(--muted); font-size: .9375rem; margin-bottom: 1rem; }

/* ── Form fields ──────────────────────────────────────── */
.field-group { margin-bottom: 1rem; }
.field-label {
  display: block;
  font-size: .8125rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: .375rem;
}
.field-input, .field-textarea {
  width: 100%;
  padding: .75rem .875rem;
  font-size: 1rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--card);
  color: var(--text);
  font-family: inherit;
  -webkit-appearance: none;
}
.field-input:focus, .field-textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgb(37 99 235 / .2);
}

/* ── Buttons ──────────────────────────────────────────── */
.btn-primary-big, .btn-danger-big, .btn-secondary-big, .btn-cancel {
  display: block;
  width: 100%;
  padding: 1rem;
  font-size: 1.0625rem;
  font-weight: 700;
  border: none;
  border-radius: 10px;
  cursor: pointer;
  text-align: center;
  font-family: inherit;
  margin-top: .75rem;
}
.btn-primary-big { background: var(--primary); color: #fff; }
.btn-danger-big  { background: var(--danger);  color: #fff; }
.btn-secondary-big {
  background: var(--unknown-bg);
  color: var(--text);
  border: 1px solid var(--border);
}
.btn-cancel {
  background: transparent;
  color: var(--muted);
  font-weight: 500;
}
.btn-primary-big:disabled, .btn-danger-big:disabled { opacity: .6; }

/* ── Status indicator ─────────────────────────────────── */
.evac-status-ok {
  display: flex;
  align-items: center;
  gap: .5rem;
  font-size: 1rem;
  margin-bottom: .75rem;
}
.status-dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  display: inline-block;
}
.status-dot.ok    { background: var(--present); }
.status-dot.alert { background: var(--danger); }

/* ── Summary bar (active evac) ───────────────────────── */
.summary-bar {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: .5rem;
  margin-top: 1rem;
  position: sticky;
  top: 56px;  /* below header */
  background: var(--bg);
  z-index: 40;
  padding: .5rem 0;
}
.summary-item {
  padding: .625rem .5rem;
  border-radius: 8px;
  text-align: center;
  background: var(--card);
  box-shadow: var(--shadow);
}
.summary-num { display: block; font-size: 1.5rem; font-weight: 800; line-height: 1; }
.summary-lbl { display: block; font-size: .6875rem; color: var(--muted); margin-top: .25rem; text-transform: uppercase; letter-spacing: .02em; }
.summary-present .summary-num { color: var(--present); }
.summary-missing .summary-num { color: var(--missing); }
.summary-safe    .summary-num { color: var(--safe); }
.summary-unknown .summary-num { color: var(--unknown); }

/* ── Filter bar ───────────────────────────────────────── */
.filter-bar {
  display: grid;
  grid-template-columns: 1fr 9rem;
  gap: .5rem;
  margin-top: .75rem;
}

/* ── Roster cards ─────────────────────────────────────── */
.roster-section { margin-top: 1rem; }
.section-toggle {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .5rem;
  background: var(--unknown-bg);
  border: none;
  padding: .75rem 1rem;
  border-radius: 8px;
  font-size: .8125rem;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--muted);
  cursor: pointer;
  font-family: inherit;
  letter-spacing: .04em;
  margin-bottom: .5rem;
}
.section-toggle .caret { transition: transform .2s; }
.section-toggle.open .caret { transform: rotate(180deg); }

.person-card {
  background: var(--card);
  border-radius: 10px;
  padding: .875rem 1rem;
  margin-bottom: .5rem;
  box-shadow: var(--shadow);
  display: flex;
  align-items: center;
  gap: .75rem;
  cursor: pointer;
  border-left: 4px solid transparent;
  transition: background .15s, border-color .15s;
  min-height: 64px;
}
.person-card:active { background: #f3f4f6; }

.person-card.status-present     { border-left-color: var(--present); }
.person-card.status-missing     { border-left-color: var(--missing); background: var(--missing-bg); }
.person-card.status-safe_offsite{ border-left-color: var(--safe); }
.person-card.status-unknown     { border-left-color: var(--border); }

.person-info { flex: 1; min-width: 0; }
.person-name {
  font-weight: 600;
  font-size: 1rem;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.person-meta {
  font-size: .8125rem;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.person-status {
  display: inline-flex;
  align-items: center;
  gap: .25rem;
  font-size: .75rem;
  font-weight: 700;
  padding: 4px 9px;
  border-radius: 999px;
  text-transform: uppercase;
  letter-spacing: .03em;
  white-space: nowrap;
}
.person-status.present     { background: var(--present-bg); color: var(--present); }
.person-status.missing     { background: var(--missing-bg); color: var(--missing); }
.person-status.safe_offsite{ background: var(--safe-bg);    color: var(--safe); }
.person-status.unknown     { background: var(--unknown-bg); color: var(--unknown); }

/* ── Mark modal ────────────────────────────────────────── */
.evac-modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.5);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 100;
  padding: 0;
}
.evac-modal-card {
  background: var(--card);
  border-radius: 16px 16px 0 0;
  width: 100%;
  max-width: 640px;
  padding: 1.25rem;
  max-height: 92vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
}
.mark-name { font-size: 1.25rem; font-weight: 700; }
.mark-meta { color: var(--muted); font-size: .9375rem; margin-top: .125rem; }
.mark-expected {
  font-size: .8125rem;
  color: var(--muted);
  padding: .5rem .75rem;
  background: var(--unknown-bg);
  border-radius: 6px;
  margin-top: .625rem;
}

.mark-buttons {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: .5rem;
  margin-top: 1rem;
}
.mark-btn {
  padding: 1rem .5rem;
  font-size: .9375rem;
  font-weight: 700;
  border: none;
  border-radius: 10px;
  cursor: pointer;
  font-family: inherit;
  text-align: center;
  min-height: 64px;
}
.mark-btn.mark-present { background: var(--present); color: #fff; }
.mark-btn.mark-missing { background: var(--missing); color: #fff; }
.mark-btn.mark-safe    { background: var(--safe);    color: #fff; }
.mark-btn.mark-unknown { background: var(--unknown-bg); color: var(--text); grid-column: span 2; }

/* ── History ──────────────────────────────────────────── */
.history-card {
  background: var(--card);
  border-radius: 10px;
  padding: 1rem;
  margin: .5rem 0;
  box-shadow: var(--shadow);
}
.history-when { font-weight: 700; }
.history-meta { color: var(--muted); font-size: .8125rem; margin-top: .25rem; }
.history-counts {
  display: flex;
  gap: 1rem;
  margin-top: .625rem;
  font-size: .8125rem;
}
.history-counts span { font-weight: 600; }
.history-counts .c-present { color: var(--present); }
.history-counts .c-missing { color: var(--missing); }
.history-counts .c-safe    { color: var(--safe); }

/* ── Offline banner ───────────────────────────────────── */
.offline-banner {
  background: var(--safe-bg);
  color: var(--safe);
  text-align: center;
  padding: .5rem;
  font-size: .8125rem;
  font-weight: 600;
}

/* ── Toast ────────────────────────────────────────────── */
#toast-host {
  position: fixed;
  bottom: 1rem;
  left: 1rem;
  right: 1rem;
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: .5rem;
  pointer-events: none;
}
.toast {
  background: var(--text);
  color: #fff;
  padding: .75rem 1rem;
  border-radius: 8px;
  font-size: .875rem;
  pointer-events: auto;
  opacity: 0;
  transform: translateY(10px);
  transition: opacity .2s, transform .2s;
}
.toast.show { opacity: 1; transform: translateY(0); }
.toast-error   { background: var(--danger-dark); }
.toast-success { background: #166534; }

.evac-err {
  color: var(--danger);
  font-size: .875rem;
  margin-top: .75rem;
}

/* History view — download links */
.history-actions {
  margin: .5rem 0 1rem;
}
.history-actions .btn-secondary-big {
  text-decoration: none;
  display: block;
  text-align: center;
}
.history-download {
  display: inline-block;
  margin-top: .75rem;
  font-size: .8125rem;
  font-weight: 600;
  color: var(--primary);
  text-decoration: none;
  padding: .375rem 0;
}
.history-download:hover { text-decoration: underline; }

/* ══════════════════════════════════════════════════════════════
   Mode tabs (Marshal register / QR scanner) + scanner UI
   ══════════════════════════════════════════════════════════════ */
.mode-tabs {
  display: flex;
  gap: 6px;
  padding: 8px 12px 0;
  background: #fff;
  position: sticky;
  top: 0;
  z-index: 4;
}
.mode-tab {
  flex: 1 1 0;
  appearance: none;
  border: 1px solid #e5e7eb;
  background: #f8fafc;
  border-radius: 8px 8px 0 0;
  padding: 12px 8px;
  font-size: 1rem;
  font-weight: 600;
  color: #475569;
  cursor: pointer;
  border-bottom: 3px solid transparent;
  transition: background .15s, color .15s, border-color .15s;
}
.mode-tab .mode-ico { margin-right: 6px; }
.mode-tab:hover { background: #f1f5f9; }
.mode-tab.active {
  background: #fff;
  color: var(--primary);
  border-color: #e5e7eb #e5e7eb #fff #e5e7eb;
  border-bottom: 3px solid var(--primary);
}

.mode-view { display: none; }
.mode-view.active { display: block; }

/* ── Scanner stage ─────────────────────────────────────── */
.scanner-wrap {
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.scanner-stage {
  position: relative;
  width: 100%;
  aspect-ratio: 4 / 3;
  background: #000;
  border-radius: 12px;
  overflow: hidden;
}
.scanner-stage video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.scan-reticle {
  position: absolute;
  inset: 12% 18%;
  border: 3px solid rgba(255,255,255,.85);
  border-radius: 18px;
  box-shadow: 0 0 0 9999px rgba(0,0,0,.18);
  pointer-events: none;
}
.scanner-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
}
.scan-status {
  flex: 1 1 100%;
  font-size: .9375rem;
  color: #475569;
}
.btn-cancel-inline {
  appearance: none;
  border: 1px solid #cbd5e1;
  background: #fff;
  color: #475569;
  border-radius: 8px;
  padding: .75rem 1.25rem;
  font-weight: 700;
  font-size: 1rem;
  cursor: pointer;
}

/* Big ✓ confirmation overlay */
.scan-flash, .scan-error {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}
.scan-flash-card, .scan-error-card {
  text-align: center;
  background: rgba(0, 33, 71, .92);
  color: #fff;
  border-radius: 18px;
  padding: 26px 32px;
  max-width: 88%;
  box-shadow: 0 12px 40px rgba(0,0,0,.4);
  animation: scanFlashIn .18s ease-out;
}
.scan-error-card { background: rgba(140, 18, 24, .94); }
.scan-flash-tick {
  font-size: 64px;
  line-height: 1;
  color: #4ade80;
  margin-bottom: 6px;
}
.scan-error-x {
  font-size: 64px;
  line-height: 1;
  color: #fecaca;
  margin-bottom: 6px;
}
.scan-flash-name {
  font-size: 1.75rem;
  font-weight: 700;
  margin-bottom: 4px;
}
.scan-flash-meta {
  font-size: 1rem;
  opacity: .85;
  margin-bottom: 10px;
}
.scan-flash-status {
  display: inline-block;
  background: rgba(74, 222, 128, .18);
  color: #d1fae5;
  padding: 4px 12px;
  border-radius: 999px;
  font-size: .8125rem;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
}
.scan-error-msg {
  font-size: 1.25rem;
  font-weight: 700;
}
@keyframes scanFlashIn {
  from { transform: scale(.85); opacity: 0; }
  to   { transform: scale(1);    opacity: 1; }
}

/* Recent scans list */
.recent-scans-card {
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  padding: 12px;
}
.recent-scans-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-weight: 700;
  font-size: .9375rem;
  color: #334155;
  margin-bottom: 8px;
}
.recent-scans-card .badge {
  background: var(--primary);
  color: #fff;
  border-radius: 999px;
  padding: 2px 10px;
  font-size: .8125rem;
}
#recent-scans-list {
  list-style: none;
  margin: 0;
  padding: 0;
  max-height: 260px;
  overflow-y: auto;
}
#recent-scans-list .empty-cell {
  color: #94a3b8;
  font-size: .875rem;
  padding: 16px 4px;
  text-align: center;
}
.recent-scan-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 4px;
  border-top: 1px solid #f1f5f9;
}
.recent-scan-row:first-child { border-top: 0; }
.recent-scan-meta {
  font-size: .8125rem;
  color: #6b7280;
  margin-top: 2px;
}
.recent-scan-time {
  font-size: .8125rem;
  color: #475569;
  font-variant-numeric: tabular-nums;
}

/* ── Multi-org logo strip on /evac login ─────────────── */
.evac-login-orgs {
  margin-top: 1.25rem;
  text-align: center;
}
.evac-login-orgs-label {
  font-size: .625rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: #94a3b8;
  margin-bottom: .5rem;
}
.evac-login-orgs-strip {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: .625rem 1rem;
  padding: .625rem .75rem;
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
}
.evac-login-orgs-strip img {
  height: 24px;
  width: auto;
  max-width: 90px;
  object-fit: contain;
}
