:root {
  --bg: #111418;
  --panel: #1a1f26;
  --line: #2a313b;
  --text: #e6e9ee;
  --muted: #8b95a3;
  --accent: #3b82f6;
  --ok: #22c55e;
  --bad: #ef4444;
  color-scheme: dark;
}

* { box-sizing: border-box; }

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

header {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 10px 16px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 5;
}
.logo { font-weight: 700; letter-spacing: .02em; }
nav { display: flex; gap: 4px; flex: 1; }
nav button { background: none; border: 0; color: var(--muted); padding: 8px 12px; border-radius: 6px; cursor: pointer; font: inherit; }
nav button.active { color: var(--text); background: var(--line); }

main { padding: 16px; max-width: 1800px; margin: 0 auto; }
h1, h2 { margin: 0 0 12px; font-weight: 600; }
h2 { font-size: 17px; }

button { font: inherit; cursor: pointer; border-radius: 6px; padding: 8px 14px; border: 1px solid var(--line); }
button:disabled { opacity: .5; cursor: default; }
.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.ghost { background: none; color: var(--text); }
.danger { color: var(--bad); }

input { font: inherit; color: var(--text); background: var(--bg); border: 1px solid var(--line); border-radius: 6px; padding: 8px 10px; width: 100%; }
label { display: block; margin-bottom: 12px; color: var(--muted); font-size: 13px; }
label input { margin-top: 4px; font-size: 15px; }
label.check { display: flex; gap: 8px; align-items: center; }
label.check input { width: auto; margin: 0; }

.card { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 16px; margin: 16px 0; max-width: 640px; }
.row { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.muted { color: var(--muted); }
.error { color: var(--bad); }
.ok { color: var(--ok); }
.hidden { display: none !important; }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 380px), 1fr)); gap: 10px; }
.tile { position: relative; background: #000; border-radius: 8px; overflow: hidden; aspect-ratio: 16 / 9; cursor: zoom-in; }
.tile video-stream, .tile video { width: 100%; height: 100%; display: block; object-fit: contain; pointer-events: none; }
.tile .label { position: absolute; left: 8px; top: 8px; background: rgba(0,0,0,.6); padding: 2px 8px; border-radius: 4px; font-size: 13px; }

.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; background: var(--ok); }
.dot.off { background: var(--bad); }

table { width: 100%; border-collapse: collapse; margin-top: 8px; }
th, td { text-align: left; padding: 8px; border-bottom: 1px solid var(--line); }
th { color: var(--muted); font-weight: 500; font-size: 13px; }
td input.name { max-width: 260px; }

.device { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 10px 0; border-top: 1px solid var(--line); }
.badge { font-size: 12px; padding: 1px 8px; border-radius: 10px; background: var(--line); color: var(--muted); margin-left: 6px; }
.badge.new { background: var(--accent); color: #fff; }
.steps li { margin: 4px 0; }

.viewer { position: fixed; inset: 0; background: #000; z-index: 20; display: flex; flex-direction: column; }
.viewer-bar { display: flex; gap: 16px; align-items: center; padding: 8px 12px; background: var(--panel); }
.viewer-bar span:first-child { font-weight: 600; }
.viewer-bar button { margin-left: auto; }
#viewer-body { flex: 1; min-height: 0; }
#viewer-body video-stream, #viewer-body video { width: 100%; height: 100%; display: block; object-fit: contain; }

.login-body { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login { width: 100%; max-width: 340px; }
.login button { width: 100%; }

@media (max-width: 640px) {
  header { flex-wrap: wrap; }
  nav { order: 3; flex-basis: 100%; }
  table th:nth-child(3), table td:nth-child(3) { display: none; }
}
