:root {
  --bg: #0F2F33;
  --bg-2: #15393E;
  --ink: #EEF3F1;
  --muted: #9DB5B2;
  --signal: #F5C518;   /* сигнальный жёлтый, как разметка на складе */
  --ok: #22A06B;
  --out: #3A8DDE;
  --err: #E5484D;
  --font: 'Onest', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--ink); font-family: var(--font); }
body { overflow: hidden; -webkit-user-select: none; user-select: none; -webkit-tap-highlight-color: transparent; }

.kiosk {
  height: 100%;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: auto minmax(0, 1fr) auto;
  padding: max(20px, env(safe-area-inset-top)) 28px max(20px, env(safe-area-inset-bottom));
  gap: 16px;
}

.top { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; min-width: 0; }
.clock { min-width: 0; }
.time {
  font-size: clamp(64px, 13vw, 132px);
  font-weight: 600;
  line-height: .9;
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
}
.date { color: var(--muted); font-size: clamp(16px, 2.4vw, 22px); margin-top: 8px; }
.company { color: var(--muted); font-size: 16px; text-align: right; max-width: 40%; white-space: pre-line; }

.stage { display: flex; align-items: center; justify-content: center; min-height: 0; min-width: 0; }
.frame {
  position: relative;
  /* ширина — по меньшему из: ширина экрана или высота × 3/4; высота считается из пропорции */
  width: min(100%, 62vh * 0.75);
  aspect-ratio: 3 / 4;
  max-height: 100%;
  border-radius: 28px;
  overflow: hidden;
  background: var(--bg-2);
  outline: 3px solid transparent;
  transition: outline-color .2s;
}
video { width: 100%; height: 100%; object-fit: cover; transform: scaleX(-1); display: block; }

.guide { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.guide ellipse {
  fill: none;
  stroke: rgba(238, 243, 241, .8);
  stroke-width: 2;
  stroke-dasharray: 10 8;
  vector-effect: non-scaling-stroke;
  transition: stroke .2s;
}
[data-state="blink"] .guide ellipse, [data-state="turn"] .guide ellipse, [data-state="return"] .guide ellipse,
[data-state="capture"] .guide ellipse { stroke: var(--signal); stroke-dasharray: none; stroke-width: 4; }
[data-state="blink"] .frame, [data-state="turn"] .frame, [data-state="return"] .frame, [data-state="capture"] .frame { outline-color: var(--signal); }

.result {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; justify-content: flex-end;
  padding: 28px;
  background: var(--ok);
  animation: pop .22s ease-out;
}
.result[data-kind="out"] { background: var(--out); }
.result[data-kind="repeat"] { background: #5B6B6D; }
.result[data-kind="unknown"] { background: var(--err); }
.result[data-kind="queued"] { background: #2E5A5F; }
.side-info { display: grid; gap: 6px; justify-items: end; max-width: 40%; min-width: 0; text-align: right; }
.side-info .company { max-width: none; }
.logo { display: block; height: clamp(48px, 11vw, 110px); width: auto; max-width: 100%; }
.net { font-size: 15px; padding: 6px 12px; border-radius: 20px; background: #24484D; color: var(--ink); }
.net.off { background: var(--signal); color: #1B1B12; font-weight: 600; }
.result-kind { font-size: clamp(22px, 3.2vw, 30px); font-weight: 600; opacity: .92; }
.result-name { font-size: clamp(30px, 5.4vw, 52px); font-weight: 700; line-height: 1.05; margin: 8px 0 12px; }
.result-meta { font-size: clamp(18px, 2.6vw, 24px); opacity: .92; }
@keyframes pop { from { transform: scale(.97); opacity: 0; } to { transform: none; opacity: 1; } }

.bottom { text-align: center; min-height: 92px; min-width: 0; }
.status { font-size: clamp(24px, 4vw, 38px); font-weight: 600; margin: 0; }
[data-state="blink"] .status, [data-state="turn"] .status, [data-state="return"] .status { color: var(--signal); }
.turnbar { display: flex; align-items: center; gap: 6px; width: min(460px, 100%); margin: 14px auto 0; }
.turnbar-side { flex: 1; height: 14px; border-radius: 7px; background: #24484D; overflow: hidden; display: flex; }
.turnbar-side.left { justify-content: flex-end; }
.turnbar-side i { display: block; height: 100%; width: 0; background: var(--signal); border-radius: 7px; transition: width .08s linear; }
.turnbar-side i.done { background: var(--ok); }
.turnbar-mid { width: 4px; height: 24px; border-radius: 2px; background: var(--ink); }
.hint { color: var(--muted); font-size: clamp(15px, 2.2vw, 20px); margin: 8px 0 0; }

.activate {
  position: fixed; inset: 0;
  background: var(--bg);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 24px; text-align: center; gap: 12px;
}
.activate h1 { font-size: 32px; margin: 0; }
.activate p { color: var(--muted); font-size: 18px; margin: 0 0 12px; max-width: 420px; }
.activate input {
  font: 600 44px var(--font);
  letter-spacing: .3em;
  text-align: center;
  width: 300px; max-width: 100%;
  padding: 14px 0 14px .3em;
  border-radius: 16px;
  border: 2px solid #2E5A5F;
  background: var(--bg-2);
  color: var(--ink);
}
.activate input:focus { outline: none; border-color: var(--signal); }
.activate button {
  font: 600 20px var(--font);
  padding: 16px 40px;
  border-radius: 14px;
  border: 0;
  background: var(--signal);
  color: #1B1B12;
  cursor: pointer;
}
.activate button:focus-visible { outline: 3px solid var(--ink); outline-offset: 3px; }
.error { color: #FF9A9D !important; min-height: 24px; }

@media (orientation: landscape) and (max-height: 700px) {
  .kiosk { grid-template-columns: 1fr 1.1fr; grid-template-rows: 1fr auto; }
  .top { grid-column: 1; flex-direction: column; align-items: flex-start; justify-content: center; gap: 16px; }
  .company { text-align: left; max-width: none; }
  .side-info { justify-items: start; max-width: none; }
  .stage { grid-column: 2; grid-row: 1 / 3; }
  .frame { width: min(100%, 88vh * 0.75); }
  .bottom { grid-column: 1; grid-row: 2; text-align: left; }
  .turnbar { margin-left: 0; }
}
@media (prefers-reduced-motion: reduce) { .result { animation: none; } }
