/* ── Reset / base ─────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:        #0d0f14;
  --surface:   #181b22;
  --border:    #2a2e3a;
  --accent:    #3b82f6;
  --accent-h:  #2563eb;
  --text:      #e2e8f0;
  --text-muted:#94a3b8;
  --danger:    #ef4444;
  --ok:        #22c55e;
  --radius:    8px;
  --gap:       12px;
}

html, body { height: 100%; background: var(--bg); color: var(--text); font-family: system-ui, sans-serif; font-size: 14px; }

/* ── Header ──────────────────────────────────────────────────────────────── */
header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  height: 52px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}

.logo { font-weight: 700; font-size: 16px; letter-spacing: .5px; }

nav { display: flex; gap: 4px; }

.tab-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 6px 14px;
  border-radius: var(--radius);
  font-size: 14px;
  transition: background .15s, color .15s;
}
.tab-btn:hover  { background: var(--border); color: var(--text); }
.tab-btn.active { background: var(--accent); color: #fff; }

/* ── Main ────────────────────────────────────────────────────────────────── */
main { padding: var(--gap); }

.tab   { display: none; }
.tab.active { display: block; }

/* ── Video grid ──────────────────────────────────────────────────────────── */
.video-grid {
  display: grid;
  gap: var(--gap);
  grid-template-columns: repeat(auto-fill, minmax(380px, 1fr));
}

.video-tile {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.video-label {
  padding: 6px 10px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.proto-badge {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .4px;
  padding: 1px 6px;
  border-radius: 99px;
  text-transform: uppercase;
}
.proto-badge.webrtc { background: #16a34a22; color: var(--ok); }
.proto-badge.hls    { background: #2563eb22; color: var(--accent); }

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

/* ── Live bar ────────────────────────────────────────────────────────────── */
.live-bar {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}

.live-bar label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 12px;
  color: var(--text-muted);
}

/* ── Replay bar ──────────────────────────────────────────────────────────── */
.replay-bar {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}

.replay-bar label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 12px;
  color: var(--text-muted);
}

.replay-controls {
  display: flex;
  align-items: center;
  gap: 15px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 15px;
  margin-bottom: 16px;
}

.replay-controls button {
  min-width: 85px;
  font-weight: 600;
}

.replay-controls input[type="range"] {
  flex: 1;
  height: 6px;
  background: var(--border);
  border-radius: 99px;
  outline: none;
  cursor: pointer;
  accent-color: var(--accent);
  -webkit-appearance: none;
}

.replay-controls input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--accent);
  transition: transform .1s;
}

.replay-controls input[type="range"]::-webkit-slider-thumb:hover {
  transform: scale(1.2);
}

#replay-time {
  font-family: monospace;
  font-size: 12px;
  color: var(--text-muted);
  white-space: nowrap;
}

input[type="datetime-local"] {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  padding: 7px 10px;
  font-size: 14px;
  outline: none;
  transition: border-color .15s;
}
input[type="datetime-local"]:focus { border-color: var(--accent); }

select {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  padding: 7px 10px;
  font-size: 14px;
  outline: none;
  transition: border-color .15s;
  cursor: pointer;
}
select:focus { border-color: var(--accent); }

button {
  background: var(--accent);
  border: none;
  border-radius: var(--radius);
  color: #fff;
  cursor: pointer;
  font-size: 14px;
  padding: 8px 18px;
  transition: background .15s;
}
button:hover { background: var(--accent-h); }

/* ── Misc ────────────────────────────────────────────────────────────────── */
.hint { color: var(--text-muted); padding: 8px 0 14px; font-size: 13px; }

/* ── Storage panel ───────────────────────────────────────────────────────── */
.storage-panel {
  display: flex;
  flex-direction: column;
  gap: var(--gap);
  max-width: 540px;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.stat-card h3 { font-size: 13px; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: .5px; }

.stat-bar {
  height: 8px;
  background: var(--border);
  border-radius: 99px;
  overflow: hidden;
}
.stat-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 99px;
  transition: width .5s;
}
.stat-fill.warn  { background: #f59e0b; }
.stat-fill.danger { background: var(--danger); }

.stat-card p  { font-size: 14px; }
.stat-card small { font-size: 12px; color: var(--text-muted); }
.stat-card strong { color: var(--text); }

/* ── Responsive ──────────────────────────────────────────────────────────── */
@media (max-width: 480px) {
  .video-grid { grid-template-columns: 1fr; }
  header { padding: 0 12px; }
}
