/* Тёмная тема не ради моды: экран смотрят в темноте клуба, и светлый фон
   слепит контролёра между сканами. Кнопки крупные — работают в перчатках и
   не глядя. Цвет решения занимает пол-экрана, чтобы читаться боковым
   зрением, не вчитываясь. */

:root {
  --bg: #101216;
  --panel: rgba(18, 20, 26, 0.92);
  --line: #2a2f3a;
  --text: #f2f4f8;
  --muted: #9aa3b2;
  --ok: #1f9d55;
  --ok-strong: #15b45c;
  --bad: #c62828;
  --warn: #c47f16;
  --accent: #3d7bfd;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  color-scheme: dark;
}

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

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  overscroll-behavior: none;
}

body { overflow: hidden; }

.screen { position: fixed; inset: 0; display: flex; flex-direction: column; }
[hidden] { display: none !important; }

/* --- вход по ПИНу ------------------------------------------------------ */

.screen--login {
  padding: calc(var(--safe-top) + 24px) 20px calc(var(--safe-bottom) + 20px);
  justify-content: center;
  gap: 18px;
  max-width: 460px;
  margin: 0 auto;
}

.login__head { text-align: center; }
.login__title { margin: 0 0 6px; font-size: 24px; font-weight: 650; }
.login__sub { margin: 0; color: var(--muted); font-size: 15px; }

.pin {
  display: flex; justify-content: center; gap: 12px; min-height: 26px;
}
.pin__dot {
  width: 14px; height: 14px; border-radius: 50%;
  background: var(--line); transition: background .12s;
}
.pin__dot.is-filled { background: var(--accent); }

.login__error {
  margin: 0; text-align: center; color: #ff8080; font-size: 15px; min-height: 20px;
}

.keypad {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px;
}
.keypad button {
  padding: 18px 0; font-size: 26px; font-weight: 600;
  color: var(--text); background: #1b1f27;
  border: 1px solid var(--line); border-radius: 14px;
}
.keypad button:active { background: #262c38; }
.keypad__aux { font-size: 17px !important; color: var(--muted) !important; }

.login__go { margin-top: 4px; }

/* Возврат в смену: одна большая кнопка вместо клавиатуры. */
.login__resume { padding: 22px; font-size: 19px; }

/* --- камера ------------------------------------------------------------ */

.camera {
  position: absolute; inset: 0; width: 100%; height: 100%;
  object-fit: cover; background: #000;
}
.camera__frame { position: absolute; opacity: 0; pointer-events: none; }

/* Рамка не украшение: распознаётся ровно то, что в неё попало. Затемнение
   вокруг — подсказка, куда целиться, чтобы не поймать соседний билет. */
.reticle {
  position: absolute; left: 50%; top: 44%;
  width: min(64vw, 280px); aspect-ratio: 1; transform: translate(-50%, -50%);
  border: 3px solid rgba(255, 255, 255, .55); border-radius: 22px;
  box-shadow: 0 0 0 100vmax rgba(0, 0, 0, .42);
}
.reticle__hint {
  position: absolute; left: 0; right: 0; top: calc(44% + min(32vw, 140px) + 14px);
  margin: 0; text-align: center; font-size: 14px;
  color: rgba(255, 255, 255, .8); text-shadow: 0 1px 4px rgba(0, 0, 0, .8);
  pointer-events: none;
}

/* --- верхняя и нижняя панели ------------------------------------------ */

.topbar {
  position: relative; z-index: 2;
  display: flex; align-items: center; gap: 12px;
  padding: calc(var(--safe-top) + 8px) 12px 8px;
  background: linear-gradient(to bottom, rgba(0, 0, 0, .75), transparent);
}
.topbar__btn {
  width: 42px; height: 42px; font-size: 20px; color: var(--text);
  background: rgba(0, 0, 0, .45); border: none; border-radius: 12px;
}
.topbar__info { flex: 1; min-width: 0; }
.topbar__post { display: block; font-weight: 650; font-size: 15px; }
.topbar__operator { display: block; font-size: 13px; color: var(--muted); }

.status { display: flex; align-items: center; gap: 6px; font-size: 13px; }
.status__dot {
  width: 11px; height: 11px; border-radius: 50%; background: var(--muted);
}
.status__dot.is-live { background: var(--ok-strong); }
.status__dot.is-offline { background: var(--bad); }
.status__dot.is-pending { background: var(--warn); }
.status__queue { color: var(--muted); min-width: 20px; }

.bottombar {
  margin-top: auto; position: relative; z-index: 2;
  padding: 10px 12px calc(var(--safe-bottom) + 10px);
  background: linear-gradient(to top, rgba(0, 0, 0, .82), transparent);
  display: flex; flex-direction: column; gap: 10px;
}

.direction { display: flex; gap: 8px; }
.direction__btn {
  flex: 1; padding: 16px 0; font-size: 18px; font-weight: 700;
  letter-spacing: .04em; text-transform: uppercase;
  color: var(--muted); background: rgba(20, 24, 31, .85);
  border: 2px solid var(--line); border-radius: 14px;
}
.direction__btn.is-active { color: #fff; background: var(--accent); border-color: var(--accent); }
#dir-out.is-active { background: #6b4ea8; border-color: #6b4ea8; }

.counters { display: flex; gap: 8px; }
.counter {
  flex: 1; text-align: center; padding: 8px 4px;
  background: rgba(20, 24, 31, .8); border-radius: 12px;
}
.counter b { display: block; font-size: 20px; }
.counter span { font-size: 11px; color: var(--muted); text-transform: uppercase; }

.quick { display: flex; gap: 8px; }
.quick .btn { flex: 1; }

/* --- решение ----------------------------------------------------------- */

.verdict {
  position: absolute; inset: 0; z-index: 5;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 10px; padding: 24px; text-align: center;
  background: rgba(16, 18, 22, .94);
}
.verdict.is-ok { background: rgba(21, 122, 68, .96); }
.verdict.is-bad { background: rgba(160, 30, 30, .96); }
.verdict.is-warn { background: rgba(150, 100, 16, .96); }

.verdict__result { font-size: 30px; font-weight: 800; letter-spacing: .01em; }
.verdict__holder { font-size: 22px; font-weight: 600; }
.verdict__tier {
  font-size: 34px; font-weight: 800; text-transform: uppercase; letter-spacing: .06em;
  padding: 6px 18px; border: 3px solid rgba(255, 255, 255, .8); border-radius: 14px;
}
.verdict__tier:empty { display: none; }
.verdict__meta { font-size: 15px; opacity: .9; word-break: break-all; }
.verdict__actions { margin-top: 14px; display: flex; flex-direction: column; gap: 8px; width: min(100%, 340px); }
.verdict__tap { margin: 10px 0 0; font-size: 13px; opacity: .75; }

/* --- листы ------------------------------------------------------------- */

.screen--sheet {
  z-index: 10; background: var(--bg);
  padding: calc(var(--safe-top) + 12px) 16px calc(var(--safe-bottom) + 16px);
  gap: 12px; overflow-y: auto;
}
.sheet__head { display: flex; align-items: center; justify-content: space-between; }
.sheet__head h2 { margin: 0; font-size: 20px; }
.sheet__close {
  padding: 10px 14px; color: var(--text); background: #1b1f27;
  border: 1px solid var(--line); border-radius: 12px; font-size: 15px;
}
.sheet__error { color: #ff8080; margin: 0; }

.input {
  width: 100%; padding: 14px; font-size: 17px;
  color: var(--text); background: #161a21;
  border: 1px solid var(--line); border-radius: 12px;
}
.field { display: flex; flex-direction: column; gap: 6px; font-size: 14px; color: var(--muted); }

.hint { margin: 0; font-size: 13px; color: var(--muted); }

.results { display: flex; flex-direction: column; gap: 8px; }
.result {
  display: flex; align-items: center; gap: 10px; width: 100%; text-align: left;
  padding: 12px; color: var(--text); background: #161a21;
  border: 1px solid var(--line); border-radius: 12px;
}
.result__main { flex: 1; min-width: 0; }
.result__name { font-weight: 600; }
.result__sub { font-size: 13px; color: var(--muted); }
.result__badge {
  font-size: 12px; padding: 4px 8px; border-radius: 8px;
  background: #22272f; color: var(--muted); white-space: nowrap;
}
.result__badge.is-inside { background: var(--ok); color: #fff; }
.result__badge.is-dead { background: var(--bad); color: #fff; }

.facts { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; margin: 0; font-size: 15px; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; text-align: right; }

.switch { display: flex; align-items: center; gap: 10px; font-size: 16px; }
.switch input { width: 22px; height: 22px; }

/* --- кнопки ------------------------------------------------------------ */

.btn {
  padding: 16px; font-size: 17px; font-weight: 600;
  color: var(--text); background: #1b1f27;
  border: 1px solid var(--line); border-radius: 14px;
}
.btn:active { opacity: .85; }
.btn--primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn--ghost { background: rgba(20, 24, 31, .85); }
.btn--force { background: #fff; color: #111; border-color: #fff; }
/* «Дальше» — самая частая кнопка на плашке: её ищут вслепую. */
.btn--next {
  padding: 20px; font-size: 19px;
  background: rgba(0, 0, 0, .35); border-color: rgba(255, 255, 255, .55);
}
.btn--danger { background: var(--bad); border-color: var(--bad); color: #fff; }

.toast {
  position: fixed; left: 50%; bottom: calc(var(--safe-bottom) + 90px);
  z-index: 50; transform: translateX(-50%);
  max-width: 90vw; padding: 12px 18px; border-radius: 12px;
  background: rgba(0, 0, 0, .88); font-size: 15px; text-align: center;
}

@media (prefers-reduced-motion: no-preference) {
  .verdict { animation: pop .12s ease-out; }
  @keyframes pop { from { opacity: .4; } to { opacity: 1; } }
}
