:root {
  --green: #1a7f37;
  --green-bg: #eafaf0;
  --amber: #8a5a00;
  --amber-bg: #fff4de;
  --red: #b42318;
  --red-bg: #fdeceb;
  --ink: #111;
  --paper: #fff;
  --muted: #666;
  --border: #ddd;
  font-size: 20px;
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
  padding: 0;
  overflow: hidden;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  background: var(--paper);
  color: var(--ink);
  -webkit-tap-highlight-color: transparent;
}

.hidden { display: none !important; }

.screen {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
}

.btn {
  font: inherit;
  font-weight: 700;
  border: none;
  border-radius: 14px;
  padding: 1em 1.2em;
  cursor: pointer;
  color: var(--paper);
}
.btn:active { filter: brightness(0.9); }

.btn-big { font-size: 1.3rem; padding: 0.9em 1em; width: 100%; }
.btn-primary { background: #1155cc; }
.btn-green { background: var(--green); }
.btn-amber { background: var(--amber); }
.btn-red { background: var(--red); }
.btn-neutral { background: #333; }

.btn-icon {
  font: inherit;
  font-size: 1.6rem;
  background: none;
  border: none;
  padding: 0.4em 0.6em;
  color: var(--ink);
  cursor: pointer;
}

/* ---------- PIN screen ---------- */
#screen-pin {
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  background: var(--paper);
}
.pin-form {
  width: 100%;
  max-width: 420px;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  text-align: center;
}
.pin-form h1 {
  font-size: 1.6rem;
  margin: 0 0 0.5rem;
}
.pin-input {
  font-size: 2rem;
  letter-spacing: 0.3em;
  text-align: center;
  padding: 0.5em;
  border: 2px solid var(--border);
  border-radius: 14px;
  width: 100%;
}
.pin-input:focus { outline: 3px solid #1155cc; border-color: #1155cc; }

.error {
  color: var(--red);
  font-weight: 700;
  font-size: 1.1rem;
  margin: 0;
}

/* ---------- Scanner screen ---------- */
#screen-scanner {
  background: #000;
}
#qr-reader {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
}
#qr-reader video {
  width: 100% !important;
  height: 100% !important;
  object-fit: cover !important;
}
/* hide the library's default border/canvas chrome we don't need */
#qr-reader img { display: none; }

.fab {
  position: fixed;
  right: 1rem;
  bottom: 1rem;
  z-index: 20;
  font-size: 1.2rem;
  font-weight: 700;
  padding: 0.9em 1.3em;
  border-radius: 999px;
  border: none;
  background: var(--paper);
  color: var(--ink);
  box-shadow: 0 2px 10px rgba(0,0,0,0.4);
}

/* ---------- Search screen ---------- */
#screen-search {
  background: var(--paper);
}
.search-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem;
  border-bottom: 2px solid var(--border);
}
.search-input {
  flex: 1;
  font-size: 1.3rem;
  padding: 0.6em 0.7em;
  border: 2px solid var(--border);
  border-radius: 12px;
}
.search-input:focus { outline: 3px solid #1155cc; border-color: #1155cc; }

.search-status {
  padding: 0.5rem 1rem;
  color: var(--muted);
  font-size: 1.1rem;
}

.search-results {
  list-style: none;
  margin: 0;
  padding: 0;
  overflow-y: auto;
  flex: 1;
}
.search-result {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  width: 100%;
  text-align: left;
  border: none;
  border-bottom: 1px solid var(--border);
  background: var(--paper);
  padding: 1rem;
  font: inherit;
  cursor: pointer;
}
.search-result:active { background: #f0f0f0; }
.search-result .dot {
  flex-shrink: 0;
  width: 0.9em;
  height: 0.9em;
  border-radius: 50%;
  background: var(--border);
}
.search-result.checked-in .dot { background: var(--green); }
.search-result .info { display: flex; flex-direction: column; min-width: 0; }
.search-result .name { font-weight: 700; font-size: 1.15rem; }
.search-result .email {
  color: var(--muted);
  font-size: 0.95rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ---------- Result overlay ---------- */
.overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1.2rem;
  padding: 2rem 1.5rem;
  text-align: center;
  color: var(--ink);
}
.overlay.status-green { background: var(--green-bg); }
.overlay.status-amber { background: var(--amber-bg); }
.overlay.status-red { background: var(--red-bg); }
.overlay.status-error { background: #f2f2f2; }

.overlay-close {
  position: absolute;
  top: 0.75rem;
  right: 0.75rem;
  font: inherit;
  font-size: 1.4rem;
  width: 2.2em;
  height: 2.2em;
  border-radius: 50%;
  border: none;
  background: rgba(0,0,0,0.12);
  color: var(--ink);
  cursor: pointer;
}

.overlay .status-icon { font-size: 4rem; line-height: 1; }
.overlay .status-name { font-size: 2rem; font-weight: 800; word-break: break-word; }
.overlay .status-line { font-size: 1.4rem; font-weight: 700; }
.overlay.status-green .status-line { color: var(--green); }
.overlay.status-amber .status-line { color: var(--amber); }
.overlay.status-red .status-line { color: var(--red); }

.consent-banner {
  width: 100%;
  max-width: 480px;
  background: var(--red);
  color: var(--paper);
  font-weight: 800;
  font-size: 1.3rem;
  padding: 0.9em 1em;
  border-radius: 14px;
}
.consent-quiet {
  color: var(--muted);
  font-size: 1rem;
}
.consent-ask {
  width: 100%;
  max-width: 480px;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}
.consent-ask .consent-prompt {
  font-weight: 700;
  font-size: 1.1rem;
}
.consent-buttons {
  display: flex;
  gap: 0.75rem;
}
.consent-buttons .btn { flex: 1; font-size: 1.05rem; }

.overlay-actions {
  width: 100%;
  max-width: 480px;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-top: 0.5rem;
}

.qr-box {
  background: var(--paper);
  border-radius: 14px;
  padding: 1rem;
}
.qr-box img { display: block; width: 220px; height: 220px; }
.qr-link {
  display: block;
  margin-top: 0.5rem;
  font-size: 1rem;
  color: #1155cc;
  word-break: break-all;
}
