/* Attendance Scanner: light, minimal, mobile-first */
:root {
  --accent: #0f766e;
  --accent-hover: #115e59;
  --accent-soft: #f0fdfa;
  --text: #111827;
  --muted: #6b7280;
  --border: #e5e7eb;
  --bg: #ffffff;
  --surface: #f9fafb;

  --present: #15803d;
  --present-bg: #f0fdf4;
  --late: #b45309;
  --late-bg: #fffbeb;
  --absent: #b91c1c;
  --absent-bg: #fef2f2;
  --leave: #1d4ed8;
  --leave-bg: #eff6ff;

  --font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --radius: 8px;
  --radius-sm: 6px;
  --tap: 44px;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  background: var(--bg);
}

body {
  font-family: var(--font);
  color: var(--text);
  font-size: 15px;
  line-height: 1.4;
  height: 100vh;
  height: 100dvh;
  width: 100%;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

button,
input,
select {
  font-family: inherit;
}

button {
  cursor: pointer;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.hidden {
  display: none !important;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ---------- Header ---------- */
.scanner-header {
  flex-shrink: 0;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  padding: 8px 16px;
  padding-top: calc(8px + env(safe-area-inset-top, 0px));
  z-index: 40;
}

.header-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.school-brand {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  flex: 1;
}

.school-logo-img {
  width: 32px;
  height: 32px;
  flex-shrink: 0;
  border-radius: var(--radius-sm);
  background: var(--accent);
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 10px;
  letter-spacing: 0.3px;
}

.school-info {
  min-width: 0;
}

.school-info h1 {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.school-info p {
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.clock-display {
  font-size: 14px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--text);
  white-space: nowrap;
}

.install-pwa-btn {
  min-width: var(--tap);
  height: var(--tap);
  padding: 0 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  background: var(--bg);
  color: var(--accent);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 600;
  transition: background-color 0.15s, border-color 0.15s;
}

.install-pwa-btn:hover {
  background: var(--accent-soft);
  border-color: var(--accent);
}

/* Phone can install directly: make the button stand out */
.install-pwa-btn.ready-pwa {
  background: var(--accent);
  border-color: var(--accent);
  color: #ffffff;
}

.install-pwa-btn.ready-pwa:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
}

/* Very narrow phones: icon only (button keeps its aria-label) */
@media (max-width: 359px) {
  .install-label {
    display: none;
  }
  .install-pwa-btn {
    padding: 0;
    width: var(--tap);
  }
  .school-logo-img {
    display: none;
  }
}

/* ---------- Connection status ---------- */
.status-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: 8px;
}

.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  min-height: 32px;
  padding: 4px 12px;
  border-radius: 999px;
  border: 1px solid transparent;
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.status-badge .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
  background: currentColor;
}

.status-badge.online {
  background: var(--present-bg);
  color: var(--present);
  border-color: #bbf7d0;
}

.status-badge.pending {
  background: var(--late-bg);
  color: var(--late);
  border-color: #fde68a;
}

.status-badge.offline {
  background: var(--absent-bg);
  color: var(--absent);
  border-color: #fecaca;
}

.sync-action-btn {
  flex-shrink: 0;
  min-height: var(--tap);
  padding: 0 16px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--bg);
  color: var(--accent);
  border: 1px solid var(--accent);
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 600;
  transition: background-color 0.15s;
}

.sync-action-btn:hover:not(:disabled) {
  background: var(--accent-soft);
}

.sync-action-btn:disabled {
  color: var(--muted);
  border-color: var(--border);
  background: var(--surface);
  cursor: default;
}

/* Sending in progress */
.sync-action-btn.spinning {
  pointer-events: none;
}

.sync-action-btn.spinning::before {
  content: "";
  width: 14px;
  height: 14px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ---------- Camera viewfinder (stays dark) ---------- */
.scanner-container {
  flex: 1;
  min-height: 0;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #000000;
  overflow: hidden;
}

#qr-reader {
  width: 100% !important;
  height: 100% !important;
  border: none !important;
}

#qr-reader video {
  width: 100% !important;
  height: 100% !important;
  object-fit: cover !important;
  transform: none !important; /* Default: natural, unmirrored view */
  transition: transform 0.2s ease;
}

#qr-reader.mirrored video {
  transform: scaleX(-1) !important; /* Mirrored view */
}

.scanner-overlay {
  position: absolute;
  inset: 0;
  pointer-events: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.target-box {
  width: 220px;
  width: min(240px, 70vw, 45vh);
  width: min(240px, 70vw, 45dvh);
  aspect-ratio: 1 / 1;
  border-radius: var(--radius);
  position: relative;
  box-shadow: 0 0 0 4000px rgba(0, 0, 0, 0.45);
}

.target-corner {
  position: absolute;
  width: 24px;
  height: 24px;
  border-color: #ffffff;
  border-style: solid;
}

.top-left { top: 0; left: 0; border-width: 3px 0 0 3px; border-top-left-radius: var(--radius); }
.top-right { top: 0; right: 0; border-width: 3px 3px 0 0; border-top-right-radius: var(--radius); }
.bottom-left { bottom: 0; left: 0; border-width: 0 0 3px 3px; border-bottom-left-radius: var(--radius); }
.bottom-right { bottom: 0; right: 0; border-width: 0 3px 3px 0; border-bottom-right-radius: var(--radius); }

.scanner-laser {
  position: absolute;
  top: 12px;
  left: 12px;
  right: 12px;
  height: 2px;
  border-radius: 2px;
  background: rgba(255, 255, 255, 0.75);
  animation: scanMove 2s ease-in-out infinite alternate;
  transition: background-color 0.15s, height 0.15s;
}

/* Code read: brief highlight */
.scanner-laser.pulse {
  height: 4px;
  background: var(--accent-soft);
}

@keyframes scanMove {
  0% { top: 12px; }
  100% { top: calc(100% - 16px); }
}

.target-instructions {
  position: relative; /* sit above the viewfinder dimming */
  z-index: 1;
  margin-top: 16px;
  max-width: 100%;
  background: var(--bg);
  color: var(--text);
  padding: 8px 16px;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 500;
  text-align: center;
}

/* Tap-to-focus ring (added to <body> at tap position) */
.focus-ring {
  position: fixed;
  width: 56px;
  height: 56px;
  border: 2px solid #ffffff;
  border-radius: 50%;
  transform: translate(-50%, -50%) scale(1.3);
  pointer-events: none;
  opacity: 1;
  transition: transform 0.35s ease-out, opacity 0.35s ease-out;
  z-index: 55;
}

.focus-ring.active {
  transform: translate(-50%, -50%) scale(0.9);
  opacity: 0;
}

/* ---------- Result pop-up ---------- */
.result-card {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0.96);
  width: calc(100% - 32px);
  max-width: 360px;
  max-height: calc(100% - 32px);
  overflow-y: auto;
  background: var(--bg);
  color: var(--text);
  border-radius: var(--radius);
  border: 2px solid var(--present);
  box-shadow: 0 4px 16px rgba(17, 24, 39, 0.12);
  z-index: 100;
  opacity: 0;
  transition: opacity 0.2s ease, transform 0.2s ease;
  pointer-events: auto;
}

.result-card.visible {
  transform: translate(-50%, -50%) scale(1);
  opacity: 1;
}

.result-card.hidden {
  display: none;
}

.result-card.status-present { border-color: var(--present); }
.result-card.status-late    { border-color: var(--late); }
.result-card.status-leave   { border-color: var(--leave); }
.result-card.status-already { border-color: var(--muted); }
.result-card.status-error   { border-color: var(--absent); }

.result-popup-wrapper {
  display: flex;
  flex-direction: column;
}

.status-banner {
  padding: 12px 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  font-size: 17px;
  font-weight: 700;
  letter-spacing: 0.3px;
  text-transform: uppercase;
  border-bottom: 1px solid var(--border);
}

.status-banner.present { background: var(--present-bg); color: var(--present); }
.status-banner.late    { background: var(--late-bg);    color: var(--late); }
.status-banner.leave   { background: var(--leave-bg);   color: var(--leave); }
.status-banner.already { background: var(--surface);    color: var(--text); }
.status-banner.error   { background: var(--absent-bg);  color: var(--absent); }

.scan-timestamp {
  font-size: 14px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  text-transform: none;
}

.popup-body {
  padding: 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 12px;
}

.popup-photo-box {
  width: 128px;
  height: 152px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface);
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.status-present .popup-photo-box { border-color: #bbf7d0; }
.status-late .popup-photo-box    { border-color: #fde68a; }
.status-leave .popup-photo-box   { border-color: #bfdbfe; }
.status-already .popup-photo-box { border-color: var(--border); }

.popup-photo-box img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.popup-avatar-fallback {
  font-size: 48px;
  font-weight: 600;
  color: var(--muted);
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  background: var(--surface);
}

@media (max-height: 600px) {
  .popup-photo-box {
    width: 96px;
    height: 112px;
  }
  .popup-avatar-fallback {
    font-size: 36px;
  }
}

.popup-info {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
}

.popup-name {
  font-size: 20px;
  font-weight: 700;
  color: var(--text);
  line-height: 1.25;
  margin: 0 0 8px 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

.popup-father {
  display: none !important;
}

.popup-meta-pills {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 8px;
}

.meta-pill {
  font-size: 14px;
  font-weight: 600;
  padding: 4px 12px;
  border-radius: 999px;
  line-height: 1.3;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
}

.code-pill {
  display: none !important;
}

.popup-footer {
  padding: 8px 16px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  background: var(--surface);
}

.popup-submsg {
  font-size: 13px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
  min-width: 0;
}

.undo-scan-btn {
  min-height: var(--tap);
  padding: 0 16px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--absent);
  font-size: 14px;
  font-weight: 600;
  border-radius: var(--radius-sm);
  white-space: nowrap;
  flex-shrink: 0;
  transition: background-color 0.15s, border-color 0.15s;
}

.undo-scan-btn:hover {
  background: var(--absent-bg);
  border-color: var(--absent);
}

/* ---------- Full-screen colour flash after a scan ---------- */
.screen-flash {
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.12s ease-out;
  z-index: 60;
}

.screen-flash.flash-green { background: rgba(21, 128, 61, 0.28); opacity: 1; }
.screen-flash.flash-amber { background: rgba(180, 83, 9, 0.28);  opacity: 1; }
.screen-flash.flash-blue  { background: rgba(29, 78, 216, 0.28); opacity: 1; }
.screen-flash.flash-red   { background: rgba(185, 28, 28, 0.28); opacity: 1; }

/* ---------- Bottom bar ---------- */
.bottom-bar {
  flex-shrink: 0;
  background: var(--bg);
  border-top: 1px solid var(--border);
  padding: 12px 16px;
  padding-bottom: calc(12px + env(safe-area-inset-bottom, 0px));
  display: flex;
  flex-direction: column;
  gap: 12px;
  z-index: 40;
}

.footer-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.count-stat {
  display: flex;
  flex-direction: column;
  min-width: 0;
  font-size: 12px;
  color: var(--muted);
  line-height: 1.2;
}

.count-stat strong {
  color: var(--text);
  font-size: 22px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.camera-tools {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}

.icon-btn {
  width: var(--tap);
  height: var(--tap);
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px; /* sound button shows a symbol set by the script */
  line-height: 1;
  transition: background-color 0.15s, border-color 0.15s;
}

.icon-btn:hover {
  background: var(--surface);
}

.icon-btn:active {
  background: var(--accent-soft);
  border-color: var(--accent);
}

.footer-actions {
  display: flex;
  gap: 8px;
}

.manual-entry-btn {
  flex: 1;
  min-height: var(--tap);
  padding: 0 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: var(--accent);
  color: #ffffff;
  border: 1px solid var(--accent);
  border-radius: var(--radius-sm);
  font-size: 15px;
  font-weight: 600;
  white-space: nowrap;
  transition: background-color 0.15s;
}

.manual-entry-btn:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
}

.admin-link-btn {
  min-height: var(--tap);
  padding: 0 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: var(--radius-sm);
  font-size: 15px;
  font-weight: 500;
  text-decoration: none;
}

.admin-link-btn:hover {
  background: var(--surface);
}

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  top: calc(12px + env(safe-area-inset-top, 0px));
  left: 50%;
  transform: translateX(-50%) translateY(-8px);
  width: max-content;
  max-width: calc(100% - 32px);
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 16px;
  font-size: 14px;
  font-weight: 500;
  text-align: center;
  box-shadow: 0 2px 8px rgba(17, 24, 39, 0.08);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
  z-index: 200;
}

.toast.show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

.toast-success { background: var(--present-bg); color: var(--present); border-color: #bbf7d0; }
.toast-warning { background: var(--late-bg);    color: var(--late);    border-color: #fde68a; }
.toast-error   { background: var(--absent-bg);  color: var(--absent);  border-color: #fecaca; }
.toast-info    { background: var(--accent-soft); color: var(--accent); border-color: #99f6e4; }

/* ---------- Modals ---------- */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(17, 24, 39, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 99;
}

.modal-backdrop.hidden {
  display: none !important;
}

.modal-window {
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  width: 100%;
  max-width: 360px;
  max-height: calc(100% - 32px);
  overflow-y: auto;
}

.modal-window h3 {
  font-size: 17px;
  font-weight: 600;
  margin-bottom: 16px;
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 12px;
}

.modal-head h3 {
  margin: 0;
}

.modal-close {
  width: var(--tap);
  height: var(--tap);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  color: var(--muted);
  font-size: 24px;
  line-height: 1;
}

.modal-close:hover {
  background: var(--surface);
  color: var(--text);
}

.modal-text {
  font-size: 14px;
  color: var(--muted);
  margin-bottom: 16px;
}

.form-group {
  margin-bottom: 16px;
}

.form-group label {
  display: block;
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
  margin-bottom: 4px;
}

.form-group input,
.form-group select,
.drawer-tools input {
  width: 100%;
  min-height: var(--tap);
  background: var(--bg);
  border: 1px solid #d1d5db;
  color: var(--text);
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  font-size: 16px;
}

.form-group input:focus,
.form-group select:focus,
.drawer-tools input:focus,
.lock-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-soft), 0 0 0 4px var(--accent);
}

input::placeholder {
  color: var(--muted);
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 16px;
}

.btn-primary,
.btn-secondary {
  min-height: var(--tap);
  padding: 0 16px;
  border-radius: var(--radius-sm);
  font-size: 15px;
  font-weight: 600;
  transition: background-color 0.15s, border-color 0.15s;
}

.btn-primary {
  background: var(--accent);
  color: #ffffff;
  border: 1px solid var(--accent);
}

.btn-primary:hover:not(:disabled) {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
}

.btn-primary:disabled {
  opacity: 0.6;
  cursor: default;
}

.btn-secondary {
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  white-space: nowrap;
}

.btn-secondary:hover {
  background: var(--surface);
}

.btn-block {
  width: 100%;
}

/* ---------- Today's scans list ---------- */
.drawer-window {
  max-width: 440px;
  display: flex;
  flex-direction: column;
}

.drawer-tools {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}

.drawer-tools input {
  flex: 1;
  min-width: 0;
}

.drawer-table-wrap {
  flex: 1;
  overflow-y: auto;
  max-height: 50vh;
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.drawer-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.drawer-table th {
  position: sticky;
  top: 0;
  background: var(--surface);
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  text-align: left;
  padding: 8px;
  border-bottom: 1px solid var(--border);
}

.drawer-empty {
  text-align: center;
  padding: 24px 8px;
  color: var(--muted);
}

/* Rows are written by the script with inline dark-theme colours; re-skin them here */
#drawer-table-body tr {
  border-bottom: 1px solid var(--border) !important;
}

#drawer-table-body td {
  padding: 8px !important;
  color: var(--muted) !important;
  vertical-align: top;
}

#drawer-table-body td:first-child {
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

#drawer-table-body strong {
  color: var(--text) !important;
  font-weight: 600;
}

#drawer-table-body td div {
  font-size: 12px !important;
  color: var(--muted) !important;
}

#drawer-table-body span {
  display: inline-block;
  font-size: 12px !important;
  padding: 2px 8px !important;
  border-radius: 999px !important;
  background: var(--present-bg) !important;
  color: var(--present) !important;
}

#drawer-table-body span[style*="#78350f"] {
  background: var(--late-bg) !important;
  color: var(--late) !important;
}

.drawer-foot {
  margin-top: 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  color: var(--muted);
}

.drawer-foot strong {
  color: var(--text);
}

.btn-danger-link {
  min-height: var(--tap);
  padding: 0 12px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  color: var(--absent);
  font-size: 14px;
  font-weight: 600;
}

.btn-danger-link:hover {
  background: var(--absent-bg);
}

/* ---------- Install guide ---------- */
.install-window {
  max-width: 420px;
}

.guide-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 16px;
  margin-bottom: 12px;
}

.guide-steps {
  margin-left: 16px;
  font-size: 14px;
  line-height: 1.6;
  color: var(--text);
}

.guide-steps li + li {
  margin-top: 4px;
}

.guide-more {
  font-size: 14px;
  color: var(--muted);
}

.guide-more summary {
  min-height: var(--tap);
  display: flex;
  align-items: center;
  cursor: pointer;
  color: var(--accent);
  font-weight: 500;
}

.guide-more .guide-steps {
  margin-top: 8px;
}

.guide-more code {
  display: inline-block;
  font-size: 12px;
  word-break: break-all;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 2px 4px;
  color: var(--text);
}

#install-guide-ip-url {
  color: var(--accent);
  word-break: break-all;
}

/* ---------- Lock screen ---------- */
#scanner-lock-overlay {
  z-index: 99999;
  background: var(--bg);
  align-items: center;
  justify-content: center;
}

.lock-card {
  width: 100%;
  max-width: 360px;
  text-align: center;
  padding: 24px 16px;
}

.lock-icon {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 16px;
}

.lock-title {
  font-size: 20px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 8px;
}

.lock-text {
  font-size: 15px;
  color: var(--muted);
  margin-bottom: 24px;
}

.lock-input {
  width: 100%;
  min-height: 56px;
  text-align: center;
  font-size: 24px;
  letter-spacing: 8px;
  padding: 8px 12px;
  background: var(--bg);
  border: 1px solid #d1d5db;
  color: var(--text);
  border-radius: var(--radius-sm);
  margin-bottom: 12px;
}

.lock-input::placeholder {
  font-size: 16px;
  letter-spacing: normal;
}

.lock-error {
  color: var(--absent);
  background: var(--absent-bg);
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 500;
  padding: 8px 12px;
  margin-bottom: 12px;
}

#lock-submit-btn {
  min-height: 48px;
  font-size: 16px;
}

.lock-foot {
  margin-top: 24px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

.lock-link {
  display: inline-flex;
  align-items: center;
  min-height: var(--tap);
  padding: 0 8px;
  color: var(--accent);
  font-size: 15px;
  font-weight: 500;
  text-decoration: none;
}

.lock-link:hover {
  text-decoration: underline;
}

/* ---------- Reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  .scanner-laser {
    animation: none;
    top: 50%;
  }
  .result-card,
  .toast,
  .focus-ring,
  .screen-flash {
    transition: none;
  }
  .sync-action-btn.spinning::before {
    animation-duration: 2s;
  }
}

/* "Scanned today" opens the list of this phone's scans */
button.count-stat {
  background: none;
  border: none;
  padding: 0;
  font: inherit;
  color: inherit;
  text-align: left;
  cursor: pointer;
  min-height: 44px;
}

/* ===== Face attendance (scanner-face.js) ===== */
.face-toggle-btn.is-on {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent);
}

.face-toggle-btn[hidden] { display: none; }

.face-status {
  /* Top of the camera view, above the viewfinder dimming; never pushed off short screens */
  position: absolute;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 1;
  max-width: calc(100% - 32px);
  padding: 4px 12px;
  border-radius: 999px;
  background: rgba(15, 42, 36, 0.72);
  color: #e6f4ef;
  font-size: 12px;
  font-weight: 600;
  text-align: center;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.face-status[hidden] { display: none; }
.face-status.ok { background: rgba(15, 118, 110, 0.85); color: #fff; }
.face-status.warn { background: rgba(180, 83, 9, 0.88); color: #fff; }
