/* Стройконтроль — Apple Liquid Glass, тёмная тема */
:root {
  --bg-0: #05070d;
  --bg-1: #0a0e17;
  --ink: #f2f5fa;
  --ink-dim: #aab4c5;
  --ink-mute: #6f7b90;
  --glass: rgba(22, 28, 40, 0.55);
  --glass-2: rgba(30, 38, 54, 0.5);
  --stroke: rgba(255, 255, 255, 0.10);
  --stroke-top: rgba(255, 255, 255, 0.22);
  --ok: #34e08a;
  --ok-dim: rgba(52, 224, 138, 0.16);
  --warn: #ff453a;
  --warn-dim: rgba(255, 69, 58, 0.16);
  --accent: #0a84ff;
  --amber: #ffd60a;
  --radius: 22px;
  --radius-sm: 14px;
  --blur: 30px;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --sans: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text",
    system-ui, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }

body {
  font-family: var(--sans);
  color: var(--ink);
  background: var(--bg-0);
  min-height: 100vh;
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
  position: relative;
}

/* Атмосферный фон: мягкие световые пятна */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -2;
  background:
    radial-gradient(60vw 60vw at 12% -8%, rgba(10, 132, 255, 0.16), transparent 60%),
    radial-gradient(55vw 55vw at 100% 0%, rgba(52, 224, 138, 0.10), transparent 55%),
    radial-gradient(70vw 70vw at 50% 120%, rgba(255, 214, 10, 0.06), transparent 60%),
    linear-gradient(180deg, var(--bg-1), var(--bg-0));
}
body::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  background-image: radial-gradient(rgba(255,255,255,0.035) 1px, transparent 1px);
  background-size: 3px 3px;
  opacity: 0.5;
  pointer-events: none;
}

.shell {
  max-width: 1120px;
  margin: 0 auto;
  padding: clamp(16px, 3vw, 34px) clamp(14px, 3vw, 30px) 60px;
}

/* ---------- Топбар ---------- */
.topbar {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: clamp(18px, 3vw, 30px);
}
.brand {
  display: flex;
  align-items: center;
  gap: 13px;
}
.brand .mark {
  width: 46px; height: 46px;
  border-radius: 13px;
  display: grid; place-items: center;
  background: linear-gradient(160deg, rgba(255,214,10,0.9), rgba(255,159,10,0.85));
  box-shadow: 0 6px 20px rgba(255, 176, 10, 0.32), inset 0 1px 0 rgba(255,255,255,0.5);
  flex: none;
}
.brand .mark svg { width: 26px; height: 26px; display: block; }
.brand h1 {
  font-size: clamp(19px, 2.4vw, 23px);
  letter-spacing: -0.02em;
  font-weight: 650;
  line-height: 1.05;
}
.brand p {
  font-size: 12.5px;
  color: var(--ink-mute);
  letter-spacing: 0.01em;
  margin-top: 2px;
}
.topbar .spacer { flex: 1; }
.pill {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 8px 13px;
  border-radius: 999px;
  font-size: 12.5px;
  font-weight: 550;
  color: var(--ink-dim);
  background: var(--glass);
  border: 1px solid var(--stroke);
  border-top-color: var(--stroke-top);
  backdrop-filter: blur(var(--blur)) saturate(1.4);
  -webkit-backdrop-filter: blur(var(--blur)) saturate(1.4);
  white-space: nowrap;
}
.pill .dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--ink-mute);
  box-shadow: 0 0 0 0 rgba(52,224,138,0);
}
.pill.live .dot { background: var(--ok); animation: pulse 1.8s var(--ease) infinite; }
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(52,224,138,0.5); }
  70% { box-shadow: 0 0 0 7px rgba(52,224,138,0); }
  100% { box-shadow: 0 0 0 0 rgba(52,224,138,0); }
}

/* ---------- Переключатель режимов ---------- */
.segmented {
  display: inline-flex;
  padding: 5px;
  gap: 4px;
  border-radius: 15px;
  background: var(--glass);
  border: 1px solid var(--stroke);
  border-top-color: var(--stroke-top);
  backdrop-filter: blur(var(--blur)) saturate(1.4);
  -webkit-backdrop-filter: blur(var(--blur)) saturate(1.4);
  margin-bottom: 18px;
}
.segmented button {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--ink-dim);
  font-family: inherit;
  font-size: 14px;
  font-weight: 560;
  letter-spacing: -0.01em;
  padding: 9px 18px;
  border-radius: 11px;
  cursor: pointer;
  transition: color 0.25s var(--ease), background 0.25s var(--ease);
  display: inline-flex; align-items: center; gap: 8px;
}
.segmented button svg { width: 16px; height: 16px; opacity: 0.9; }
.segmented button[aria-selected="true"] {
  color: #fff;
  background: linear-gradient(180deg, rgba(255,255,255,0.16), rgba(255,255,255,0.07));
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.28), 0 2px 8px rgba(0,0,0,0.3);
}

/* ---------- Панель со сценой ---------- */
.stage-card {
  border-radius: var(--radius);
  background: var(--glass);
  border: 1px solid var(--stroke);
  border-top-color: var(--stroke-top);
  backdrop-filter: blur(var(--blur)) saturate(1.5);
  -webkit-backdrop-filter: blur(var(--blur)) saturate(1.5);
  box-shadow: 0 24px 60px rgba(0,0,0,0.45), inset 0 1px 0 rgba(255,255,255,0.06);
  padding: 14px;
  overflow: hidden;
}
.stage {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: #04060b;
  display: grid;
  place-items: center;
}
.stage video, .stage canvas.overlay {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}
.stage video { object-fit: cover; }
.stage video.contain { object-fit: contain; }
.stage canvas.overlay { pointer-events: none; }

/* Плейсхолдер до старта */
.placeholder {
  position: absolute; inset: 0;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 16px; text-align: center; padding: 24px;
  color: var(--ink-dim);
  z-index: 3;
}
.placeholder .glyph {
  width: 66px; height: 66px; border-radius: 20px;
  display: grid; place-items: center;
  background: var(--glass-2);
  border: 1px solid var(--stroke);
  border-top-color: var(--stroke-top);
}
.placeholder .glyph svg { width: 32px; height: 32px; opacity: 0.85; }
.placeholder h3 { font-size: 17px; font-weight: 600; color: var(--ink); letter-spacing: -0.01em; }
.placeholder p { font-size: 13.5px; max-width: 34ch; line-height: 1.45; color: var(--ink-mute); }

/* Крупный статус-баннер */
.banner {
  position: absolute;
  top: 14px; left: 14px; right: 14px;
  z-index: 4;
  display: flex; align-items: center; gap: 12px;
  padding: 13px 17px;
  border-radius: 15px;
  font-weight: 640;
  letter-spacing: -0.01em;
  backdrop-filter: blur(18px) saturate(1.5);
  -webkit-backdrop-filter: blur(18px) saturate(1.5);
  border: 1px solid var(--stroke-top);
  transform: translateY(-8px);
  opacity: 0;
  transition: opacity 0.35s var(--ease), transform 0.35s var(--ease), background 0.4s var(--ease);
  pointer-events: none;
}
.banner.show { opacity: 1; transform: translateY(0); }
.banner .ico { width: 26px; height: 26px; flex: none; }
.banner .txt { display: flex; flex-direction: column; line-height: 1.15; }
.banner .txt b { font-size: clamp(16px, 2.4vw, 20px); }
.banner .txt span { font-size: 12px; font-weight: 500; opacity: 0.85; }
.banner.ok { background: linear-gradient(180deg, rgba(52,224,138,0.30), rgba(52,224,138,0.14)); color: #eafff4; }
.banner.warn { background: linear-gradient(180deg, rgba(255,69,58,0.34), rgba(255,69,58,0.16)); color: #ffeceb; }
.banner.warn { animation: warnflash 1.1s var(--ease) infinite; }
@keyframes warnflash {
  0%,100% { box-shadow: 0 0 0 0 rgba(255,69,58,0); }
  50% { box-shadow: 0 0 22px 1px rgba(255,69,58,0.45); }
}
.banner.neutral { background: linear-gradient(180deg, rgba(255,255,255,0.16), rgba(255,255,255,0.07)); color: var(--ink); }

/* FPS/бэкенд метка */
.badge-tl {
  position: absolute; bottom: 12px; left: 12px; z-index: 4;
  font-size: 11px; font-weight: 550; letter-spacing: 0.02em;
  color: var(--ink-dim);
  padding: 6px 10px; border-radius: 9px;
  background: rgba(4,6,11,0.5);
  border: 1px solid var(--stroke);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  font-variant-numeric: tabular-nums;
}

/* ---------- Контролы под сценой ---------- */
.controls {
  display: flex; flex-wrap: wrap; gap: 10px;
  margin-top: 14px;
}
.btn {
  appearance: none; border: 0; cursor: pointer;
  font-family: inherit; font-size: 14.5px; font-weight: 570;
  letter-spacing: -0.01em;
  padding: 12px 20px; border-radius: 13px;
  display: inline-flex; align-items: center; gap: 9px;
  color: #fff;
  transition: transform 0.18s var(--ease), filter 0.2s var(--ease), opacity 0.2s;
}
.btn svg { width: 17px; height: 17px; }
.btn:active { transform: scale(0.97); }
.btn-primary {
  background: linear-gradient(180deg, #2a93ff, #0a84ff);
  box-shadow: 0 8px 22px rgba(10,132,255,0.35), inset 0 1px 0 rgba(255,255,255,0.35);
}
.btn-primary:hover { filter: brightness(1.08); }
.btn-danger {
  background: linear-gradient(180deg, #ff5a50, #ff3b30);
  box-shadow: 0 8px 22px rgba(255,59,48,0.32), inset 0 1px 0 rgba(255,255,255,0.3);
}
.btn-ghost {
  background: var(--glass-2);
  color: var(--ink);
  border: 1px solid var(--stroke);
  border-top-color: var(--stroke-top);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}
.btn-ghost:hover { filter: brightness(1.15); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }
.select-wrap {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 4px 4px 4px 14px; border-radius: 13px;
  background: var(--glass-2); border: 1px solid var(--stroke);
  border-top-color: var(--stroke-top);
  font-size: 13px; color: var(--ink-dim);
}
.select-wrap select {
  appearance: none; border: 0; background: transparent;
  color: var(--ink); font-family: inherit; font-size: 13.5px; font-weight: 520;
  padding: 8px 10px; border-radius: 9px; cursor: pointer;
  max-width: 190px;
}
.select-wrap select option { background: #10151f; }

/* ---------- Метрики ---------- */
.metrics {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-top: 16px;
}
.metric {
  border-radius: 17px;
  padding: 16px 17px;
  background: var(--glass);
  border: 1px solid var(--stroke);
  border-top-color: var(--stroke-top);
  backdrop-filter: blur(var(--blur)) saturate(1.4);
  -webkit-backdrop-filter: blur(var(--blur)) saturate(1.4);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.05);
  display: flex; flex-direction: column; gap: 3px;
  position: relative; overflow: hidden;
}
.metric .label {
  font-size: 12px; font-weight: 550; letter-spacing: 0.01em;
  color: var(--ink-mute);
  display: flex; align-items: center; gap: 7px;
}
.metric .label .swatch { width: 9px; height: 9px; border-radius: 3px; flex: none; }
.metric .value {
  font-size: clamp(30px, 5vw, 40px);
  font-weight: 680; letter-spacing: -0.03em;
  line-height: 1.05;
  font-variant-numeric: tabular-nums;
  transition: color 0.3s var(--ease);
}
.metric.people .value { color: var(--accent); }
.metric.hats .value { color: var(--ok); }
.metric.viol .value { color: var(--ink); }
.metric.viol.active .value { color: var(--warn); }
.metric .sub { font-size: 11.5px; color: var(--ink-mute); }

/* Компактная легенда/подпись */
.foot {
  margin-top: 22px;
  font-size: 12px;
  color: var(--ink-mute);
  line-height: 1.55;
  display: flex; flex-wrap: wrap; gap: 8px 18px;
  align-items: center;
}
.foot .legend { display: inline-flex; align-items: center; gap: 7px; }
.foot .legend i { width: 14px; height: 14px; border-radius: 4px; display: inline-block; }
.foot .legend i.g { background: var(--ok); }
.foot .legend i.r { background: var(--warn); }
.foot a { color: var(--ink-dim); text-decoration: none; border-bottom: 1px solid var(--stroke); }
.foot a:hover { color: var(--ink); }

.hidden { display: none !important; }

/* ---------- Адаптив ---------- */
@media (max-width: 560px) {
  .brand p { display: none; }
  .metric .value { font-size: 30px; }
  .segmented button { padding: 9px 13px; font-size: 13px; }
  .segmented button span { display: none; }
  .banner .txt span { display: none; }
  .btn { flex: 1 1 auto; justify-content: center; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
