:root {
  --bg: #14161a;
  --panel: #1c1f26;
  --line: #2b303b;
  --text: #e7e9ee;
  --muted: #9aa3b2;
  --accent: #4f8cff;
  --error: #ff6b6b;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

#app {
  max-width: 1200px;
  margin: 0 auto;
  padding: 24px 16px;
}

.screen[hidden] {
  display: none;
}

h1 {
  font-size: 1.35rem;
  margin: 0 0 8px;
}

.muted {
  color: var(--muted);
}

.error {
  color: var(--error);
}

button {
  background: var(--accent);
  color: #fff;
  border: 0;
  border-radius: 6px;
  padding: 8px 16px;
  font: inherit;
  cursor: pointer;
}

button:hover {
  filter: brightness(1.1);
}

.bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 16px;
}

.bar-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 12px;
}

.grid > p {
  grid-column: 1 / -1;
}

/* --- вкладки --------------------------------------------------------------- */

.tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}

.tab {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--line);
}

.tab-active {
  background: var(--panel);
  color: var(--text);
  border-color: var(--accent);
}

/* --- баннер тревог --------------------------------------------------------- */

.banner {
  padding: 10px 14px;
  border-radius: 6px;
  margin-bottom: 12px;
  background: #4a2020;
  border: 1px solid #7a3030;
}

.banner[hidden] {
  display: none;
}

/* --- плитки камер ---------------------------------------------------------- */

.tile {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  position: relative;
}

.tile-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  font-size: 0.9rem;
}

.tile video {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 9;
  background: #000;
  object-fit: contain;
}

.state {
  font-size: 0.78rem;
  padding: 2px 8px;
  border-radius: 999px;
}

.state-ok {
  background: #1f3d29;
  color: #8fe0a6;
}

.state-warn {
  background: #453a1c;
  color: #e8cf85;
}

.state-critical {
  background: #4a2020;
  color: #ff9a9a;
}

.state-info {
  background: #263447;
  color: #9dc2f0;
}

/* Бейдж всегда называет транспорт: принять HLS с задержкой за живую картинку
   на антикражной системе — настоящая операционная беда. */
.badge {
  position: absolute;
  bottom: 8px;
  left: 8px;
  font-size: 0.75rem;
  padding: 3px 8px;
  border-radius: 4px;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(2px);
}

.badge-ok {
  color: #8fe0a6;
}

.badge-warn {
  color: #e8cf85;
}

/* --- архив ----------------------------------------------------------------- */

.archive-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 10px;
}

select {
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 6px 10px;
  font: inherit;
}

#archive-video {
  width: 100%;
  max-height: 60vh;
  background: #000;
  border-radius: 8px;
}

.timeline {
  display: block;
  width: 100%;
  height: 48px;
  margin-top: 10px;
  border-radius: 6px;
  cursor: crosshair;
  background: #5c2b2b;
}

.legend {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.8rem;
  color: var(--muted);
}

.swatch {
  display: inline-block;
  width: 12px;
  height: 12px;
  border-radius: 3px;
  margin-left: 10px;
}

.swatch-both {
  background: #3f8f4f;
  margin-left: 0;
}
.swatch-local {
  background: #4f8cff;
}
.swatch-s3 {
  background: #7a6cc4;
}
.swatch-gap {
  background: #5c2b2b;
}
