:root {
  --bg: #f4f6f7;
  --surface: #ffffff;
  --ink: #1b2328;
  --muted: #5a6b74;
  --line: #d9e0e4;
  --accent: #3c6bb4;   /* ExtraCo logo blue */
  --accent-ink: #ffffff;
  --good-bg: #e5f5ec; --good-ink: #14663b;
  --active-bg: #e3effc; --active-ink: #1d5ca8;
  --pending-bg: #fdf3e3; --pending-ink: #92500a;
  --bad-bg: #fbe9e7; --bad-ink: #a33224;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.55 "Segoe UI", -apple-system, system-ui, sans-serif;
}

.topbar {
  display: flex; align-items: center; justify-content: space-between;
  background: var(--surface); border-bottom: 1px solid var(--line);
  padding: 10px 16px; position: sticky; top: 0; z-index: 10;
}
.brand { display: flex; align-items: center; gap: 8px; text-decoration: none; }
.brand-logo { height: 30px; display: block; }
.brand-label {
  font-weight: 700; font-size: 13px; color: var(--accent-ink);
  background: var(--accent); border-radius: 5px; padding: 1px 7px;
  letter-spacing: 0.04em;
}
.login-logo { display: block; height: 64px; margin: 4px auto 18px; }
.nav-links { display: flex; align-items: center; gap: 16px; }
.nav-links a { color: var(--muted); text-decoration: none; font-weight: 600; font-size: 14px; }
.nav-links a:hover { color: var(--accent); }
.nav-links form { margin: 0; }

.page { max-width: 720px; margin: 0 auto; padding: 20px 16px 90px; }

.card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 12px; padding: 20px; margin-bottom: 16px;
}
.card.narrow { max-width: 400px; margin: 8vh auto 0; }
h1 { font-size: 24px; margin: 0 0 10px; letter-spacing: -0.01em; }
h2 { font-size: 15px; margin: 0 0 10px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.08em; }
.hint { color: var(--muted); font-size: 14px; margin: 0 0 14px; }
.hint.dev { color: var(--pending-ink); }
.error { background: var(--bad-bg); color: var(--bad-ink); border-radius: 8px; padding: 10px 14px; font-size: 14px; }
.error ul { margin: 6px 0 0; padding-left: 20px; }

label { display: block; font-weight: 600; font-size: 14px; margin: 12px 0 6px; }
input[type="email"], input[type="text"], textarea {
  width: 100%; padding: 12px; font-size: 16px;
  border: 1px solid var(--line); border-radius: 8px;
  background: var(--bg); color: var(--ink);
}
input:focus, textarea:focus, button:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.check { display: flex; align-items: center; gap: 8px; font-weight: 400; font-size: 14px; margin: 14px 0; }
.check input { width: auto; }

button.primary, .btn.primary {
  display: inline-block; width: auto;
  background: var(--accent); color: var(--accent-ink);
  border: 0; border-radius: 8px; padding: 12px 22px;
  font-size: 16px; font-weight: 600; cursor: pointer;
  text-decoration: none; margin-top: 6px;
}
button.primary:hover { filter: brightness(1.08); }
form button.primary { width: 100%; }
.card .hint + form button.primary { margin-top: 14px; }
button.linklike {
  background: none; border: 0; color: var(--accent); font: inherit;
  font-weight: 600; font-size: 14px; cursor: pointer; padding: 0;
}
.resend { margin-top: 14px; text-align: center; }

/* Scanner */
.scan-wrap { display: flex; flex-direction: column; gap: 16px; }
#scanner {
  position: relative; border-radius: 12px; overflow: hidden;
  background: #10161a; aspect-ratio: 3 / 4; max-height: 60vh;
}
#video { width: 100%; height: 100%; object-fit: cover; }
.reticle {
  position: absolute; inset: 0; margin: auto;
  width: min(62%, 280px); aspect-ratio: 1;
  border: 3px solid rgba(255, 255, 255, 0.85); border-radius: 16px;
  box-shadow: 0 0 0 2000px rgba(0, 0, 0, 0.25);
  pointer-events: none;
}
#scan-status {
  position: absolute; left: 0; right: 0; bottom: 8px; margin: 0;
  text-align: center; color: #fff; font-size: 14px;
  text-shadow: 0 1px 3px rgba(0,0,0,0.7);
}
.manual h2 { margin-bottom: 8px; }
.manual form { display: flex; gap: 8px; }
.manual input { flex: 1; }
.manual button.primary { width: auto; margin-top: 0; }

/* PID page */
.pid-head { margin: 4px 0 16px; }
.eyebrow { font-size: 12px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--accent); font-weight: 600; margin: 0 0 2px; }
.pid-head h1 { font-size: 28px; }
.pills { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.pill {
  font-size: 13px; padding: 5px 12px; border-radius: 999px;
  background: var(--pending-bg); color: var(--pending-ink);
}
.pill b { font-weight: 600; opacity: 0.75; margin-right: 4px; }
.pill.good { background: var(--good-bg); color: var(--good-ink); }
.pill.active { background: var(--active-bg); color: var(--active-ink); }
.pill.bad { background: var(--bad-bg); color: var(--bad-ink); }

.group dl { margin: 0; }
.kv {
  display: flex; gap: 16px; justify-content: space-between;
  padding: 8px 0; border-bottom: 1px solid var(--line);
}
.kv:last-child { border-bottom: 0; }
.kv dt { color: var(--muted); font-size: 14px; flex: 0 0 40%; }
.kv dd { margin: 0; font-weight: 500; text-align: right; overflow-wrap: anywhere; font-variant-numeric: tabular-nums; }

.fab {
  position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%);
  background: var(--accent); color: var(--accent-ink);
  padding: 13px 26px; border-radius: 999px; text-decoration: none;
  font-weight: 600; box-shadow: 0 4px 14px rgba(0, 0, 0, 0.25);
}

/* Admin */
.saved { background: var(--good-bg); color: var(--good-ink); border-radius: 8px; padding: 8px 14px; font-size: 14px; }
.table-wrap { overflow-x: auto; }
table.users { border-collapse: collapse; width: 100%; font-size: 14px; }
table.users th {
  text-align: left; font-size: 12px; letter-spacing: 0.07em; text-transform: uppercase;
  color: var(--muted); padding: 8px 12px 8px 0; border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
table.users td { padding: 9px 12px 9px 0; border-bottom: 1px solid var(--line); vertical-align: middle; white-space: nowrap; }
table.users .email-cell { font-weight: 600; }
table.users .num { font-variant-numeric: tabular-nums; }
table.users input[type="checkbox"] { width: 18px; height: 18px; }
.badge {
  font-size: 11px; font-weight: 600; letter-spacing: 0.04em;
  background: var(--accent); color: var(--accent-ink);
  border-radius: 999px; padding: 1px 8px; margin-left: 6px; vertical-align: middle;
}
.badge.you { background: var(--active-bg); color: var(--active-ink); }
button.primary.small { padding: 6px 14px; font-size: 13px; width: auto; margin: 0; }

/* Labels */
textarea { font-family: Consolas, monospace; }
.label-sheet {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 12px;
}
.label {
  background: #fff; color: #000; border: 1px dashed #bbb; border-radius: 8px;
  padding: 12px; text-align: center;
  break-inside: avoid; page-break-inside: avoid;
}
.label img { width: 100%; max-width: 170px; image-rendering: pixelated; }
.label-code { font-family: Consolas, monospace; font-weight: 700; font-size: 15px; margin: 6px 0 0; }
.label-item { font-size: 12px; color: #333; margin: 3px 0 0; }

@media print {
  body { background: #fff; }
  .topbar, .no-print, .fab { display: none !important; }
  .page { max-width: none; padding: 0; }
  .label-sheet { grid-template-columns: repeat(4, 1fr); gap: 6mm; }
  .label { border: 1px dashed #999; border-radius: 0; }
}

@media (max-width: 480px) {
  .kv { flex-direction: column; gap: 0; }
  .kv dd { text-align: left; }
}
