* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: #f5f5f5;
  color: #1a1a1a;
}

.auth-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.auth-card {
  width: 100%;
  max-width: 360px;
  background: #fff;
  border-radius: 12px;
  padding: 2rem 1.5rem;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12);
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.auth-card h1 {
  font-size: 1.25rem;
  margin: 0 0 0.5rem;
  text-align: center;
}

.auth-card label {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  font-size: 0.9rem;
}

.auth-card input {
  font-size: 1rem;
  padding: 0.65rem 0.75rem;
  border: 1px solid #ccc;
  border-radius: 8px;
}

.auth-card button {
  font-size: 1rem;
  padding: 0.75rem;
  border: none;
  border-radius: 8px;
  background: #1a56db;
  color: #fff;
  cursor: pointer;
}

.auth-error {
  background: #fde8e8;
  color: #9b1c1c;
  padding: 0.6rem 0.75rem;
  border-radius: 8px;
  font-size: 0.9rem;
  margin: 0;
}

/* ── Admin nav / page shell ────────────────────────────────── */
.admin-nav {
  display: flex;
  gap: 1rem;
  padding: 0.75rem 1rem;
  background: #1a56db;
}
.admin-nav a {
  color: #fff;
  text-decoration: none;
  font-size: 0.95rem;
  padding: 0.35rem 0.1rem; /* bigger tap target — this bar gets heavy mobile use */
}

.breadcrumbs {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem;
  max-width: 900px;
  margin: 0 auto;
  padding: 0.6rem 1rem 0;
  font-size: 0.85rem;
  color: #666;
}
.breadcrumbs a {
  color: #1a56db;
  text-decoration: none;
}
.breadcrumbs a:hover {
  text-decoration: underline;
}
.breadcrumb-sep {
  color: #bbb;
}

.page {
  max-width: 900px;
  margin: 0 auto;
  padding: 1rem;
}

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

.btn-group {
  display: flex;
  gap: 0.5rem;
}

.muted { color: #666; font-size: 0.9rem; }

.empty-state {
  color: #666;
  padding: 2rem 0;
  text-align: center;
}

/* ── Buttons ───────────────────────────────────────────────── */
.btn, .btn-secondary, button[type="submit"] {
  display: inline-block;
  font-size: 0.95rem;
  padding: 0.6rem 1rem;
  border-radius: 8px;
  border: none;
  text-decoration: none;
  cursor: pointer;
}
.btn, button[type="submit"] {
  background: #1a56db;
  color: #fff;
}
.btn-secondary {
  background: #e5e7eb;
  color: #1a1a1a;
}

/* ── Cards / lists ─────────────────────────────────────────── */
.card-list {
  list-style: none;
  margin: 1rem 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.card-list-item {
  background: #fff;
  border-radius: 8px;
  padding: 0.75rem 1rem;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
}
.card-list-item a {
  display: flex;
  justify-content: space-between;
  align-items: center;
  color: inherit;
  text-decoration: none;
}

.quick-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin: 1rem 0;
}
.quick-links a {
  background: #fff;
  border-radius: 8px;
  padding: 0.6rem 0.9rem;
  text-decoration: none;
  color: #1a56db;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
}

/* ── Forms ─────────────────────────────────────────────────── */
.form {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  max-width: 500px;
  margin-top: 1rem;
}
.form-inline {
  flex-direction: row;
  flex-wrap: wrap;
  align-items: center;
  max-width: none;
}
.form fieldset {
  border: 1px solid #ddd;
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}
.form label {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  font-size: 0.9rem;
}
.form input, .form select, .form textarea {
  font-size: 1rem;
  padding: 0.6rem 0.7rem;
  border: 1px solid #ccc;
  border-radius: 8px;
  font-family: inherit;
}
.checkbox-row {
  flex-direction: row;
  align-items: center;
  gap: 0.5rem;
}
.form-error {
  background: #fde8e8;
  color: #9b1c1c;
  padding: 0.6rem 0.75rem;
  border-radius: 8px;
  font-size: 0.9rem;
}
.custom-field-row {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}
.custom-field-row input {
  flex: 1;
  min-width: 0;
}

/* ── Tables ────────────────────────────────────────────────── */
.table-scroll {
  overflow-x: auto;
  margin-top: 1rem;
}
table {
  width: 100%;
  border-collapse: collapse;
  background: #fff;
  border-radius: 8px;
  overflow: hidden;
}
th, td {
  text-align: left;
  padding: 0.6rem 0.8rem;
  border-bottom: 1px solid #eee;
  white-space: nowrap;
}
th {
  background: #f0f2f5;
  font-size: 0.85rem;
  text-transform: uppercase;
  color: #555;
}
.sortable-th {
  cursor: pointer;
  user-select: none;
}
.sortable-th:hover {
  color: #1a1a1a;
}
.sortable-th::after {
  content: " \21C5";
  margin-left: 0.35em;
  opacity: 0.35;
  font-size: 0.85em;
}
.sortable-th[data-sort-dir="asc"]::after {
  content: " \25B2";
  opacity: 1;
}
.sortable-th[data-sort-dir="desc"]::after {
  content: " \25BC";
  opacity: 1;
}

.callout {
  background: #fff8e1;
  border: 1px solid #f0d878;
  border-radius: 8px;
  padding: 1rem;
  margin: 1rem 0;
}
.mono {
  font-family: ui-monospace, monospace;
  font-size: 1.1rem;
  font-weight: bold;
}

/* ── ID card print sheet ───────────────────────────────────── */
.card-sheet {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(3.4in, 1fr));
  gap: 0.25in;
  padding: 0.25in;
}

.id-card {
  width: 3.4in;
  height: 2.15in; /* standard ID/credit-card proportions */
  border: 1px solid #ccc;
  border-radius: 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.1in;
  padding: 0.15in;
  page-break-inside: avoid;
  break-inside: avoid;
}

.id-card-qr {
  width: 1.3in;
  height: 1.3in;
}

.id-card-name {
  font-weight: bold;
  font-size: 1rem;
  text-align: center;
}

.id-card-wiki {
  font-size: 0.85rem;
  color: #555;
  text-align: center;
}

@media print {
  .no-print { display: none !important; }
  .id-card { border: 1px dashed #999; }
  body { background: #fff; }
}

/* ── Badges ────────────────────────────────────────────────── */
.badge {
  display: inline-block;
  font-size: 0.75rem;
  text-transform: uppercase;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  font-weight: 600;
}
.badge-open { background: #def7ec; color: #03543f; }
.badge-closed { background: #f0f2f5; color: #555; }
.badge-entry-valid { background: #def7ec; color: #03543f; }
.badge-entry-duplicate_flagged { background: #fdf6b2; color: #723b13; }
.badge-entry-voided { background: #fde8e8; color: #9b1c1c; }
.badge-active { background: #def7ec; color: #03543f; }
.badge-inactive { background: #fde8e8; color: #9b1c1c; }
.badge-entry-none { background: #f0f2f5; color: #555; }

.grant-forms {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-top: 1rem;
}

.card-list-item-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}

/* ── Dashboard ─────────────────────────────────────────────── */
.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 1rem;
  margin: 1rem 0;
}
.stat-tile {
  background: #fff;
  border-radius: 8px;
  padding: 1rem;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
}
.stat-tile-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}
.stat-tile-count {
  font-size: 2rem;
  font-weight: 700;
  line-height: 1.1;
}
.stat-tile-label {
  color: #666;
  font-size: 0.85rem;
}
.stat-tile-sub {
  margin-top: 0.5rem;
  font-size: 0.85rem;
  color: #723b13;
}

/* ── Scanner ───────────────────────────────────────────────── */
.scanner-frame {
  position: relative;
  max-width: 480px;
  /* Fixed rather than following the camera's native 16:9 (~270px at this
     width) — shorter preview, video crops via object-fit:cover below rather
     than squishing. Purely cosmetic: decodeCurrentFrame() in scanner.js
     reads from the camera's native buffer, not this CSS box, so cropping
     the preview doesn't change what jsQR actually sees. */
  height: 220px;
  margin: 1rem auto;
  background: #000;
}
.scan-guide {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 40%;
  aspect-ratio: 1 / 1;
  transform: translate(-50%, -50%);
  pointer-events: none;
}
.scan-guide-corner {
  position: absolute;
  width: 20px;
  height: 20px;
  border: 3px solid rgba(255, 255, 255, 0.85);
}
.scan-guide-corner-tl { top: 0; left: 0; border-right: none; border-bottom: none; border-radius: 8px 0 0 0; }
.scan-guide-corner-tr { top: 0; right: 0; border-left: none; border-bottom: none; border-radius: 0 8px 0 0; }
.scan-guide-corner-bl { bottom: 0; left: 0; border-right: none; border-top: none; border-radius: 0 0 0 8px; }
.scan-guide-corner-br { bottom: 0; right: 0; border-left: none; border-top: none; border-radius: 0 0 8px 0; }
.scan-guide-line {
  position: absolute;
  top: 50%;
  left: 0;
  right: 0;
  height: 1px;
  background: rgba(96, 165, 250, 0.9);
  box-shadow: 0 0 4px rgba(0, 0, 0, 0.5);
  pointer-events: none;
}
.scan-cooldown-bar {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: rgba(255, 255, 255, 0.2);
  z-index: 1;
}
.scan-cooldown-bar-fill {
  height: 100%;
  width: 0%;
  background: rgba(96, 165, 250, 0.9);
}
#scanner-video {
  /* Rounding lives on the video itself, not a clipping parent — a
     border-radius + overflow:hidden ancestor can make some Android/Chromium
     GPU drivers fail to composite a live <video> at all (renders solid
     black even though the stream is genuinely flowing). */
  width: 100%;
  height: 100%;
  display: block;
  border-radius: 12px;
  object-fit: cover;
}
.scan-button {
  display: block;
  width: 100%;
  max-width: 480px;
  margin: 0 auto;
  padding: 1rem;
  font-size: 1.1rem;
  font-weight: 600;
}
.scan-button:disabled {
  background: #a9b6d9;
  cursor: not-allowed;
}

.scan-banner {
  /* Overlaid on the frame (not a flowed sibling) so it appearing/disappearing
     never shifts the camera preview's position on the page. */
  position: absolute;
  left: 0.5rem;
  right: 0.5rem;
  bottom: 0.5rem;
  z-index: 2;
  padding: 0.75rem 1rem;
  border-radius: 8px;
  font-size: 1.05rem;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}
.scan-banner-valid { background: #def7ec; color: #03543f; }
.scan-banner-duplicate { background: #fdf6b2; color: #723b13; }
.scan-banner-error { background: #fde8e8; color: #9b1c1c; }

/* ── Entry corrections ─────────────────────────────────────── */
.corrected-flag {
  font-size: 0.8rem;
}
.correction-menu summary {
  cursor: pointer;
  color: #1a56db;
  font-size: 0.9rem;
}
.correction-forms {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-top: 0.5rem;
  min-width: 260px;
}
.correction-forms .form {
  gap: 0.5rem;
  margin-top: 0;
  max-width: none;
}
.correction-forms input, .correction-forms select {
  padding: 0.4rem 0.5rem;
  font-size: 0.85rem;
}

/* ── Check-in search ───────────────────────────────────────── */
#checkin-search {
  width: 100%;
  max-width: 500px;
  font-size: 1rem;
  padding: 0.65rem 0.75rem;
  border: 1px solid #ccc;
  border-radius: 8px;
  margin-top: 1rem;
}

/* ── Fuzzy table filter ────────────────────────────────────── */
.fuzzy-filter {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin: 1rem 0;
}
.fuzzy-filter input {
  flex: 1 1 280px;
  max-width: 500px;
  font-size: 1rem;
  padding: 0.65rem 0.75rem;
  border: 1px solid #ccc;
  border-radius: 8px;
}
