:root {
  --bg: #09090b;
  --card: #18181b;
  --line: #27272a;
  --text: #fafafa;
  --muted: #a1a1aa;
  --accent: #fafafa;
  --green: #16a34a;
  --red: #dc2626;
  --amber: #d97706;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body {
  font: 17px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  min-height: 100dvh;
  -webkit-tap-highlight-color: transparent;
}
main { max-width: 560px; margin: 0 auto; padding: 16px 16px 48px; }
h1 { font-size: 22px; letter-spacing: .08em; margin: 8px 0 20px; }
h2 { font-size: 15px; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; margin: 28px 0 10px; }
.muted { color: var(--muted); }
.hidden { display: none !important; }

nav {
  display: flex; gap: 6px; align-items: center;
  padding: 10px 16px; border-bottom: 1px solid var(--line);
  position: sticky; top: 0; background: var(--bg); z-index: 5;
}
nav .brand { font-weight: 800; letter-spacing: .12em; margin-right: auto; }
nav a, nav button {
  color: var(--muted); text-decoration: none; font: inherit; font-size: 15px;
  background: none; border: 0; padding: 10px 8px; cursor: pointer;
}
nav a.active { color: var(--text); font-weight: 600; }

input[type=text], input[type=email], input[type=password], input[type=search] {
  width: 100%; font: inherit; font-size: 20px; color: var(--text);
  background: var(--card); border: 1px solid var(--line); border-radius: 14px;
  padding: 16px; outline: none;
}
textarea {
  width: 100%; font: inherit; font-size: 18px; color: var(--text); resize: vertical;
  background: var(--bg); border: 1px solid var(--line); border-radius: 12px;
  padding: 12px; outline: none; min-height: 84px;
}
input:focus, textarea:focus { border-color: var(--muted); }
.check { display: flex; align-items: center; gap: 10px; margin-top: 12px; color: var(--muted); }
.check input { width: 22px; height: 22px; }
.backrow { display: grid; gap: 8px; padding-bottom: 14px; margin-bottom: 14px; border-bottom: 1px solid var(--line); }
.backrow input[type=text] { font-size: 16px; padding: 12px; background: var(--bg); }
.backrow textarea { min-height: 64px; font-size: 16px; }

.btn {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%; min-height: 58px; margin-top: 12px; padding: 14px 18px;
  font: inherit; font-size: 18px; font-weight: 700; text-decoration: none;
  color: var(--bg); background: var(--accent); border: 0; border-radius: 14px; cursor: pointer;
}
.btn.secondary { background: var(--card); color: var(--text); border: 1px solid var(--line); font-weight: 600; }
.btn.small { width: auto; min-height: 44px; margin: 0; padding: 8px 14px; font-size: 15px; }
.btn.danger { background: transparent; color: #f87171; border: 1px solid #7f1d1d; }
.btn:disabled { opacity: .5; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: 18px; padding: 18px; }
.error { color: #f87171; margin-top: 12px; min-height: 1.4em; }

.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 14px 10px; text-align: center; }
.stat b { display: block; font-size: 34px; line-height: 1.1; }
.stat span { font-size: 13px; color: var(--muted); }

.list { list-style: none; margin: 12px 0 0; padding: 0; }
.row {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 0; border-bottom: 1px solid var(--line);
}
.row .who { flex: 1; min-width: 0; }
.row .who b { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .who small { color: var(--muted); }
.pill { font-size: 12px; font-weight: 700; padding: 4px 8px; border-radius: 99px; white-space: nowrap; }
.pill.valid { background: #27272a; color: var(--muted); }
.pill.used { background: #14532d; color: #86efac; }
.pill.void { background: #450a0a; color: #fca5a5; }

.live { font-size: 13px; color: var(--muted); display: inline-flex; align-items: center; gap: 6px; }
.live::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--amber); }
.live.on::before { background: #22c55e; }

/* Scanner */
#reader { width: 100%; border-radius: 18px; overflow: hidden; background: #000; min-height: 280px; }
#reader video { object-fit: cover; }
.overlay {
  position: fixed; inset: 0; z-index: 50;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 24px; text-align: center;
}
.overlay.ok { background: var(--green); }
.overlay.bad { background: var(--red); }
.overlay.warn { background: var(--amber); }
.overlay .big { font-size: clamp(44px, 14vw, 88px); font-weight: 900; line-height: 1; }
.overlay .name { font-size: clamp(28px, 9vw, 56px); font-weight: 800; margin-top: 18px; word-break: break-word; }
.overlay .sub { font-size: 22px; margin-top: 14px; opacity: .9; }
