/* ═══════════════════════════════════════════════════════════
   Отчёт по стенду — client-facing statistics for an offline run.
   Builds on style.css tokens; nothing here redefines them.
   ═══════════════════════════════════════════════════════════ */

.run-select {
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  font: 500 12px/1 var(--sans);
  padding: 7px 10px;
  border-radius: var(--r-sm);
  max-width: 320px;
}
.run-select:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

.report {
  padding: 24px clamp(16px, 4vw, 40px) 72px;
  max-width: 1240px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* ── First-load screen ──────────────────────────────────── */
/* The page needs a run list, a rescore and two context images before any
   number on it is true. Showing empty panels in the meantime reads as "no
   visitors" rather than "not loaded yet". */

.boot {
  position: fixed; inset: 0; z-index: 120; background: var(--bg);
  display: flex; align-items: center; justify-content: center; padding: 24px;
  transition: opacity 260ms var(--ease);
}
.boot.gone { opacity: 0; pointer-events: none; }
.boot-card { display: flex; flex-direction: column; align-items: center;
  gap: 12px; text-align: center; max-width: 34ch; }
.boot-spin {
  width: 30px; height: 30px; border-radius: 50%;
  border: 2px solid var(--surface-3); border-top-color: var(--accent);
  animation: boot-spin 780ms linear infinite;
}
@keyframes boot-spin { to { transform: rotate(360deg); } }
.boot-title { font-size: 15px; font-weight: 600; letter-spacing: -.01em; }
.boot-step { font: 500 12px/1.5 var(--mono); color: var(--text-3);
  min-height: 18px; }
.boot-step.err { color: var(--red); }
.boot-track { width: 190px; height: 3px; border-radius: 2px;
  background: var(--surface-3); overflow: hidden; }
.boot-track i { display: block; height: 100%; width: 0;
  background: var(--accent); border-radius: 2px;
  transition: width 420ms var(--ease); }

/* Re-scoring only replaces numbers already on screen, so it gets a hairline
   at the top instead of hiding the page behind an overlay. */
.busy {
  position: fixed; top: 0; left: 0; right: 0; height: 2px; z-index: 110;
  background: linear-gradient(90deg, transparent, var(--accent), transparent);
  background-size: 42% 100%; background-repeat: no-repeat;
  animation: busy-slide 1100ms var(--ease) infinite;
}
.busy[hidden] { display: none; }
@keyframes busy-slide {
  from { background-position: -45% 0; } to { background-position: 145% 0; }
}
@media (prefers-reduced-motion: reduce) {
  .boot-spin { animation: none; border-top-color: var(--accent); }
  .busy { animation: none; background-size: 100% 100%; opacity: .5; }
}

/* ── Header ─────────────────────────────────────────────── */

.rp-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 20px;
  flex-wrap: wrap;
  padding-bottom: 4px;
}
.eyebrow {
  font: 500 11px/1.4 var(--mono);
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--text-3);
  margin-bottom: 8px;
}
.rp-title {
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -.02em;
  line-height: 1.1;
}
.rp-sub { color: var(--text-2); font-size: 13px; margin-top: 5px; }
.rp-zonechip {
  font: 500 11px/1 var(--mono);
  color: var(--accent);
  background: var(--accent-soft);
  border: 1px solid var(--accent-border);
  border-radius: 100px;
  padding: 6px 12px;
  white-space: nowrap;
}

/* ── KPI row ────────────────────────────────────────────── */

.kpis {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(auto-fit, minmax(158px, 1fr));
}
.kpi {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 14px 16px;
}
.kpi .k {
  display: block;
  font-size: 11px;
  letter-spacing: .05em;
  text-transform: uppercase;
  color: var(--text-3);
  margin-bottom: 8px;
}
.kpi .n {
  font: 600 27px/1 var(--mono);
  letter-spacing: -.02em;
  font-variant-numeric: tabular-nums;
}
.kpi .n small { font-size: 14px; color: var(--text-2); font-weight: 500; }
.kpi .sub { display: block; font-size: 11px; color: var(--text-3); margin-top: 6px; }

/* ── Panels ─────────────────────────────────────────────── */

.panel {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 16px 18px 18px;
}
.panel-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}
.panel-head h3 { font-size: 14px; font-weight: 600; letter-spacing: -.01em; }
.panel-note { font-size: 11.5px; color: var(--text-3); }
.hint { font-size: 12.5px; color: var(--text-2); line-height: 1.55; max-width: 62ch; }

.two-col {
  display: grid;
  gap: 20px;
  grid-template-columns: repeat(auto-fit, minmax(340px, 1fr));
}

.chart-wrap { height: 210px; position: relative; }
.heatmap { width: 100%; border-radius: var(--r-sm); display: block; border: 1px solid var(--border); }

/* ── Duration distribution ──────────────────────────────── */

.dist { display: flex; flex-direction: column; gap: 11px; }
.dist-row { display: grid; grid-template-columns: 74px 1fr 46px; gap: 10px; align-items: center; }
.dist-row .lab { font: 500 12px/1 var(--mono); color: var(--text-2); }
.dist-row .track { height: 10px; background: var(--surface-3); border-radius: 5px; overflow: hidden; }
.dist-row .track i { display: block; height: 100%; background: var(--accent); border-radius: 5px;
  transition: width var(--dur) var(--ease); }
.dist-row .val { font: 600 13px/1 var(--mono); text-align: right; font-variant-numeric: tabular-nums; }

/* ── Funnel ─────────────────────────────────────────────── */

.funnel { display: flex; flex-direction: column; gap: 9px; }
.fn-row { display: grid; grid-template-columns: 1fr 74px; gap: 12px; align-items: center; }
.fn-bar { position: relative; height: 30px; background: var(--surface-3);
  border-radius: var(--r-sm); overflow: hidden; }
.fn-bar i { position: absolute; inset: 0 auto 0 0; background: var(--accent);
  border-radius: var(--r-sm); transition: width var(--dur) var(--ease); }
.fn-bar span { position: absolute; left: 10px; top: 50%; transform: translateY(-50%);
  font-size: 12px; font-weight: 500; color: var(--text); z-index: 1; }
.fn-n { text-align: right; font: 600 15px/1 var(--mono); font-variant-numeric: tabular-nums; }
.fn-n small { display: block; font: 500 10.5px/1.4 var(--mono); color: var(--text-3); }

/* ── Load share ─────────────────────────────────────────── */

.loadbar { display: flex; height: 30px; border-radius: var(--r-sm); overflow: hidden;
  background: var(--surface-3); }
.loadbar i { display: block; height: 100%; transition: width var(--dur) var(--ease); }
.load-legend { display: flex; flex-wrap: wrap; gap: 14px; margin-top: 12px; }
.load-legend span { display: flex; align-items: center; gap: 6px; font-size: 12px;
  color: var(--text-2); font-variant-numeric: tabular-nums; }
.load-legend b { width: 9px; height: 9px; border-radius: 2px; flex: 0 0 auto; }

.chart-sm { height: 150px; }

/* ── Entry map ──────────────────────────────────────────── */

.entry-wrap { position: relative; line-height: 0; border-radius: var(--r-sm);
  overflow: hidden; border: 1px solid var(--border); }
.entry-wrap img { width: 100%; display: block; }
#entry-canvas { position: absolute; inset: 0; width: 100%; height: 100%; }

/* ── Zone editor ────────────────────────────────────────── */

.zone-editor { display: grid; gap: 18px; grid-template-columns: minmax(0, 1.7fr) minmax(230px, 1fr); }
@media (max-width: 860px) { .zone-editor { grid-template-columns: 1fr; } }

.zone-canvas-wrap { position: relative; line-height: 0; border-radius: var(--r-sm); overflow: hidden;
  border: 1px solid var(--border); }
.zone-canvas-wrap img { width: 100%; display: block; }
#zone-canvas { position: absolute; inset: 0; width: 100%; height: 100%; cursor: crosshair; }

.zone-side { display: flex; flex-direction: column; gap: 14px; }
.zone-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.grace { display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--text-2); }
.grace input {
  width: 58px; background: var(--surface-2); border: 1px solid var(--border);
  color: var(--text); font: 500 12px/1 var(--mono); padding: 6px 8px; border-radius: var(--r-sm);
}
.zone-status { font: 500 12px/1.5 var(--mono); color: var(--green); min-height: 18px; }
.zone-status.err { color: var(--red); }

/* ── People ─────────────────────────────────────────────── */

.people-controls { display: flex; gap: 14px; align-items: center; flex-wrap: wrap; }
.people-controls select {
  background: var(--surface-2); border: 1px solid var(--border); color: var(--text);
  font: 500 12px/1 var(--sans); padding: 6px 9px; border-radius: var(--r-sm);
}
.chk { display: flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--text-2); }

.people {
  display: grid; gap: 10px; margin-top: 14px;
  grid-template-columns: repeat(auto-fill, minmax(168px, 1fr));
}
.card {
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--r); overflow: hidden; cursor: zoom-in;
  transition: border-color var(--dur) var(--ease), transform var(--dur) var(--ease);
}
.card:hover { border-color: var(--border-hover); transform: translateY(-1px); }
.card:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.shot-wrap { position: relative; display: block; background: var(--surface-3); }
.card .shot {
  width: 100%; aspect-ratio: 3 / 5; object-fit: cover; object-position: top center;
  display: block;
}
.noshot {
  display: none; position: absolute; inset: 0; align-items: center; justify-content: center;
  font: 500 10.5px/1 var(--mono); color: var(--text-3); text-align: center;
}
.card.no-crops { cursor: default; }
.card.no-crops:hover { transform: none; border-color: var(--border); }
.card.no-crops .shot { visibility: hidden; }
.card.no-crops .noshot { display: flex; }
.card .body { padding: 9px 11px 11px; display: flex; flex-direction: column; gap: 5px; }
.card .who { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.card .id { font: 600 11px/1 var(--mono); color: var(--text-3); }
.card .tag {
  font: 500 9.5px/1 var(--mono); letter-spacing: .06em; text-transform: uppercase;
  padding: 3px 6px; border-radius: 3px; white-space: nowrap;
  background: var(--orange-soft); color: var(--orange); border: 1px solid var(--orange-border);
}
.card .time { font: 600 17px/1 var(--mono); font-variant-numeric: tabular-nums; }
.card .meta { font-size: 11px; color: var(--text-3); font-variant-numeric: tabular-nums; }
.card .meta b { color: var(--text-2); font-weight: 600; }

/* ── Repeat visitors ────────────────────────────────────── */

.repeats { display: flex; flex-direction: column; gap: 9px; }
.rep {
  display: grid; grid-template-columns: 74px 1fr; gap: 14px; align-items: center;
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--r); padding: 9px 12px 9px 9px; cursor: zoom-in;
  transition: border-color var(--dur) var(--ease);
}
.rep:hover { border-color: var(--border-hover); }
.rep:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.rep-shot {
  width: 74px; aspect-ratio: 3 / 4; object-fit: cover; object-position: top center;
  border-radius: var(--r-sm); background: var(--surface-3); display: block;
}
.rep-body { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.rep-top { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.rep-id { font: 600 12px/1 var(--mono); color: var(--text-2); }
.rep-count {
  font: 500 10px/1 var(--mono); letter-spacing: .06em; text-transform: uppercase;
  background: var(--accent-soft); color: var(--accent);
  border: 1px solid var(--accent-border); border-radius: 3px; padding: 3px 7px;
}
.rep-total { font: 600 13px/1 var(--mono); font-variant-numeric: tabular-nums; }
.rep-line { position: relative; height: 20px; }
.rep-track {
  position: absolute; inset: 8px 0 auto 0; height: 3px;
  background: var(--surface-3); border-radius: 2px;
}
.rep-visit {
  position: absolute; top: 5px; height: 9px; min-width: 4px;
  background: var(--accent); border-radius: 2px;
}
.rep-times { font: 500 11px/1.5 var(--mono); color: var(--text-3); }

/* ── Possible duplicates ────────────────────────────────── */

.dupes { display: grid; gap: 10px;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
.dupe { display: flex; align-items: center; gap: 8px;
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--r); padding: 8px 10px; }
.dupe img { width: 56px; aspect-ratio: 3/4; object-fit: cover;
  object-position: top center; border-radius: var(--r-sm);
  background: var(--surface-3); cursor: zoom-in; display: block; }
.dupe-mid { display: flex; flex-direction: column; align-items: center;
  gap: 3px; flex: 1 1 auto; min-width: 0; }
.dupe-sim { font: 600 13px/1 var(--mono); color: var(--amber); }
.dupe-lab { font: 500 10px/1.4 var(--mono); color: var(--text-3);
  text-align: center; word-break: break-all; }

/* ── Frame viewer ───────────────────────────────────────── */

.viewer { display: flex; flex-direction: column; gap: 12px; }
.viewer-stage {
  position: relative; line-height: 0; border-radius: var(--r-sm);
  overflow: hidden; border: 1px solid var(--border); background: var(--surface-3);
  aspect-ratio: 16 / 9;
}
.viewer-stage img { width: 100%; height: 100%; object-fit: contain; display: block; }
.viewer-time {
  position: absolute; left: 10px; top: 10px;
  background: rgba(6, 9, 14, .78); color: var(--text);
  font: 600 12px/1 var(--mono); padding: 6px 10px; border-radius: var(--r-sm);
  font-variant-numeric: tabular-nums;
}
.viewer-bar { display: flex; align-items: center; gap: 10px; }
.viewer-bar input[type=range] { flex: 1; accent-color: var(--accent); min-width: 0; }
.viewer-bar select {
  background: var(--surface-2); border: 1px solid var(--border); color: var(--text);
  font: 500 12px/1 var(--sans); padding: 7px 9px; border-radius: var(--r-sm);
}
.btn-step { padding: 4px 13px; font-size: 19px; line-height: 1.2; }

/* ── Person modal ───────────────────────────────────────── */

.pv {
  position: fixed; inset: 0; z-index: 85; background: rgba(6, 9, 14, .8);
  display: flex; align-items: center; justify-content: center; padding: 28px;
}
.pv[hidden] { display: none; }
/* Explicit width plus min-width:0 on both the box and the scrollable strip:
   a flex item defaults to min-width:auto, so the strip's content width would
   otherwise force the box past its max-width and overflow off-screen. */
.pv-box {
  background: var(--surface-1); border: 1px solid var(--border);
  border-radius: var(--r-lg); padding: 20px 22px 22px;
  width: min(1100px, 94vw); min-width: 0;
  max-height: 88vh; overflow-y: auto;
  display: flex; flex-direction: column; gap: 12px;
}
.pv-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 20px; }
.pv-head h3 { font: 600 17px/1.2 var(--mono); }
.pv-sub { font-size: 12.5px; color: var(--text-2); margin-top: 5px; }
.pv-note { font-size: 12.5px; color: var(--text-3); }
.pv-close {
  background: var(--surface-2); border: 1px solid var(--border); color: var(--text-2);
  font-size: 20px; line-height: 1; padding: 5px 12px; border-radius: var(--r-sm);
  cursor: pointer;
}
.pv-close:hover { color: var(--text); border-color: var(--border-hover); }

.pm-strip {
  display: flex; gap: 5px; overflow-x: auto; min-width: 0;
  background: var(--bg); border-radius: var(--r-sm); padding: 8px;
}
.pm-shot { flex: 0 0 auto; cursor: zoom-in; text-align: center; }
/* Seam between two ids that identity merging joined into one person. */
.pm-shot.seam { border-left: 2px solid var(--amber); padding-left: 6px; margin-left: 4px; }
.pv-merged:empty { display: none; }
.linkish { background: none; border: 0; color: var(--accent); cursor: pointer;
  font: inherit; padding: 0; text-decoration: underline; }
.pm-shot.foreign img { opacity: .55; border-color: var(--red); }
.pm-visit {
  flex: 0 0 auto; align-self: stretch; display: flex; flex-direction: column;
  justify-content: center; gap: 4px; padding: 0 12px 0 10px;
  border-left: 2px solid var(--accent); margin-left: 6px;
}
.pm-visit:first-child { border-left: 0; margin-left: 0; padding-left: 2px; }
.pm-visit b { font: 600 11px/1 var(--mono); color: var(--accent);
  white-space: nowrap; letter-spacing: .04em; }
.pm-visit span { font: 500 10.5px/1 var(--mono); color: var(--text-3);
  white-space: nowrap; }
.pm-sep { flex: 0 0 auto; align-self: stretch; display: flex; align-items: center;
  writing-mode: vertical-rl; font: 500 10px/1 var(--mono); color: var(--red);
  letter-spacing: .08em; text-transform: uppercase; padding: 0 8px;
  border-left: 2px solid var(--red); margin-left: 6px; }
.pv-merged { color: var(--amber); }
.pm-shot img {
  height: 168px; width: auto; display: block; border-radius: 3px;
  border: 1px solid var(--border); background: var(--surface-3);
}
.pm-shot span { display: block; font: 500 10px/1.6 var(--mono); color: var(--text-3); }

.pm-spans { display: flex; flex-wrap: wrap; gap: 7px; }
.pm-span {
  font: 500 11.5px/1 var(--mono); color: var(--text-2);
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 100px; padding: 6px 11px; font-variant-numeric: tabular-nums;
}

/* ── Lightbox ───────────────────────────────────────────── */

.lb {
  position: fixed; inset: 0; z-index: 90; background: rgba(6, 9, 14, .95);
  display: flex; align-items: center; justify-content: center; padding: 56px 68px;
}
.lb[hidden] { display: none; }
/* Evidence crops are small by nature (a person is ~50x120 px in the source
   frame). Blowing one up to fill the screen just shows the pixel grid, so
   the lightbox caps at a size where it still reads as a photograph. */
#lb-img {
  max-width: 100%; max-height: min(58vh, 400px); object-fit: contain;
  border-radius: var(--r-sm); background: #000;
}
.lb-cap {
  position: absolute; bottom: 18px; left: 0; right: 0; text-align: center;
  font: 500 12px/1.5 var(--mono); color: var(--text-2);
}
.lb-close, .lb-nav {
  position: absolute; background: rgba(255, 255, 255, .08); color: #fff; border: 0;
  border-radius: var(--r-sm); cursor: pointer; line-height: 1; padding: 8px 15px;
  font-size: 26px;
}
.lb-close:hover, .lb-nav:hover { background: rgba(255, 255, 255, .18); }
.lb-close { top: 16px; right: 16px; font-size: 22px; }
.lb-prev { left: 12px; top: 50%; transform: translateY(-50%); }
.lb-next { right: 12px; top: 50%; transform: translateY(-50%); }

@media (prefers-reduced-motion: reduce) {
  .card, .dist-row .track i { transition: none; }
}
