:root {
  --green: #108e4f;
  --green-dark: #0b6b3b;
  --red: #d92d20;
  --amber: #dc6803;
  --ink: #14211b;
  --muted: #6b7f74;
  --line: #dfe8e3;
  --bg: #f5f8f6;
  --radius: 16px;
  color-scheme: light;
}

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

/* Tez-tez bosiladigan elementlarda brauzerning "ikki marta bosib kattalashtirish"
   xatti-harakatini o'chiramiz - barmoq bilan ishlashda sahifa sakrab ketmasin.
   Ikki barmoq bilan kattalashtirish (pinch-zoom) ishlayveradi. */
button, a, label, .keypad button, .btn, .result .actions button {
  touch-action: manipulation;
  -webkit-user-select: none;
  user-select: none;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--ink);
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
}

.wrap { max-width: 560px; margin: 0 auto; padding: 16px; }

/* ------------------------------------------------------------- sarlavha */
.topbar {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 16px; background: var(--green); color: #fff;
  position: sticky; top: 0; z-index: 10;
}
.topbar h1 { font-size: 16px; margin: 0; font-weight: 700; letter-spacing: .01em; }
.topbar .spacer { flex: 1; }
.topbar a, .topbar button {
  color: #fff; font-size: 14px; text-decoration: none;
  background: rgba(255,255,255,.16); border: 0; border-radius: 999px;
  padding: 7px 14px; font-weight: 600; cursor: pointer;
}

/* ------------------------------------------------------------- kirish */
.login-card {
  max-width: 360px; margin: 8vh auto; background: #fff; border-radius: 24px;
  padding: 32px 24px; box-shadow: 0 12px 40px rgba(16,142,79,.12); text-align: center;
}
.login-card h1 { font-size: 22px; margin: 0 0 4px; }
.login-card p { color: var(--muted); margin: 0 0 24px; font-size: 14px; }
.pin-display {
  display: flex; align-items: center; justify-content: center; gap: 14px;
  height: 52px; border-bottom: 2px solid var(--line); margin-bottom: 20px;
}
.pin-char {
  font-size: 30px; line-height: 1; min-width: 18px; text-align: center;
  font-variant-numeric: tabular-nums; color: var(--ink);
  animation: pin-in .16s ease-out;
}
/* Raqam nuqtaga aylanganda yumshoq o'tish */
.pin-char.is-masked { animation: pin-mask .24s ease-out; }

@keyframes pin-in {
  from { transform: scale(.45); opacity: 0; }
  to   { transform: scale(1);   opacity: 1; }
}
@keyframes pin-mask {
  from { transform: scale(1.35); opacity: .35; }
  to   { transform: scale(1);    opacity: 1; }
}
@media (prefers-reduced-motion: reduce) {
  .pin-char, .pin-char.is-masked { animation: none; }
}
.keypad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.keypad button {
  font-size: 24px; font-weight: 600; padding: 16px 0; border: 1px solid var(--line);
  background: #fff; border-radius: var(--radius); cursor: pointer; color: var(--ink);
}
.keypad button:active { background: #eef5f1; }
.keypad button.wide { grid-column: span 1; font-size: 18px; }
.error { color: var(--red); font-weight: 600; margin-bottom: 12px; font-size: 14px; }

/* ------------------------------------------------------------- skaner */
.camera-box {
  position: relative; background: #000; border-radius: var(--radius);
  overflow: hidden; aspect-ratio: 3 / 4; max-height: 58vh; margin: 0 auto;
}
.camera-box video { width: 100%; height: 100%; object-fit: cover; display: block; }
.camera-box canvas { display: none; }
.reticle {
  position: absolute; inset: 14% 10%; border: 3px solid rgba(255,255,255,.85);
  border-radius: 20px; box-shadow: 0 0 0 100vmax rgba(0,0,0,.28);
}
.camera-hint {
  position: absolute; left: 0; right: 0; bottom: 10px; text-align: center;
  color: #fff; font-size: 13px; text-shadow: 0 1px 4px rgba(0,0,0,.6);
}

.row { display: flex; gap: 10px; margin-top: 14px; }
.btn {
  flex: 1; padding: 15px 12px; border-radius: var(--radius); border: 1px solid var(--line);
  background: #fff; font-size: 15px; font-weight: 600; cursor: pointer; color: var(--ink);
}
.btn-primary { background: var(--green); color: #fff; border-color: var(--green); }
.btn:active { transform: scale(.99); }

.stats {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 14px;
}
.stat {
  background: #fff; border: 1px solid var(--line); border-radius: var(--radius);
  padding: 12px 8px; text-align: center;
}
.stat b { display: block; font-size: 22px; font-variant-numeric: tabular-nums; }
.stat span { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }

/* ------------------------------------------------------------- natija */
.result {
  position: fixed; inset: 0; z-index: 100; display: none;
  flex-direction: column; justify-content: center; align-items: center;
  padding: 24px; text-align: center; color: #fff;
}
.result.show { display: flex; }
.result.ok      { background: var(--green); }
.result.reentry { background: var(--green-dark); }
.result.used    { background: var(--red); }
.result.invalid { background: var(--red); }
.result.manual  { background: var(--amber); }

.result .icon { font-size: 72px; line-height: 1; margin-bottom: 8px; }
.result h2 { font-size: 30px; margin: 0 0 6px; letter-spacing: -.01em; }
.result .num {
  font-size: 46px; font-weight: 800; font-variant-numeric: tabular-nums;
  margin: 4px 0 12px; opacity: .95;
}
.result .name { font-size: 24px; font-weight: 700; margin-bottom: 6px; line-height: 1.25; }
.result .seat {
  font-size: 20px; font-weight: 700; background: rgba(255,255,255,.2);
  padding: 8px 18px; border-radius: 999px; margin-bottom: 10px;
}
.result .meta { font-size: 15px; opacity: .9; line-height: 1.5; max-width: 24em; }
.result .actions { margin-top: 26px; display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; }
.result .actions button {
  padding: 14px 26px; border-radius: 999px; border: 2px solid rgba(255,255,255,.7);
  background: rgba(255,255,255,.16); color: #fff; font-size: 16px; font-weight: 700; cursor: pointer;
}
.result .actions button.solid { background: #fff; color: var(--ink); border-color: #fff; }

/* ------------------------------------------------------------- dialog */
dialog {
  border: 0; border-radius: 20px; padding: 22px; max-width: 380px; width: 92%;
  box-shadow: 0 20px 60px rgba(0,0,0,.25);
}
dialog::backdrop { background: rgba(10,26,18,.5); }
dialog h3 { margin: 0 0 14px; font-size: 18px; }
dialog input[type=text], dialog input[type=search] {
  width: 100%; padding: 14px; font-size: 20px; border: 1px solid var(--line);
  border-radius: 12px; font-variant-numeric: tabular-nums;
}
.search-results { max-height: 46vh; overflow: auto; margin-top: 12px; }
.search-results li {
  list-style: none; padding: 11px 4px; border-bottom: 1px solid var(--line);
  display: flex; gap: 10px; align-items: baseline; font-size: 14px;
}
.search-results li b { font-variant-numeric: tabular-nums; }
.search-results .in { color: var(--green); font-weight: 700; font-size: 12px; }
.search-results ul { margin: 0; padding: 0; }

/* ------------------------------------------------------------- admin */
table { width: 100%; border-collapse: collapse; background: #fff; font-size: 14px; }
th, td { padding: 10px 8px; border-bottom: 1px solid var(--line); text-align: left; }
th { font-size: 12px; text-transform: uppercase; color: var(--muted); letter-spacing: .04em; }
td.num { font-variant-numeric: tabular-nums; font-weight: 700; }
.card {
  background: #fff; border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px; margin-bottom: 16px; overflow-x: auto;
}
.badge { font-size: 11px; padding: 3px 9px; border-radius: 999px; font-weight: 700; }
.badge.entry { background: #e6f4ec; color: var(--green-dark); }
.badge.reentry { background: #fdf0e3; color: var(--amber); }
.badge.reserve { background: #eef1f0; color: var(--muted); }
.muted { color: var(--muted); }
