:root {
  color-scheme: dark;
  --bg: #111318;
  --panel: #1a1f27;
  --panel-2: #222935;
  --text: #eef2f7;
  --muted: #96a0ad;
  --line: #343c49;
  --ok: #22c55e;
  --bad: #ef4444;
  --warn: #f59e0b;
  --accent: #38bdf8;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--accent);
  color: #071018;
  cursor: pointer;
  font-weight: 700;
  min-height: 40px;
  padding: 0 14px;
}

button.secondary {
  background: var(--panel-2);
  color: var(--text);
}

button.active {
  border-color: var(--accent);
  box-shadow: inset 0 0 0 1px var(--accent);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.shell {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 24px 0;
}

.topbar {
  align-items: center;
  display: flex;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.actions {
  display: flex;
  gap: 8px;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 28px;
  line-height: 1.1;
}

h2 {
  font-size: 18px;
  margin-bottom: 14px;
}

.topbar p,
.label,
.placeholder p {
  color: var(--muted);
}

.layout {
  display: grid;
  gap: 18px;
  grid-template-columns: minmax(0, 1fr) 340px;
}

.viewer,
.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.video-frame {
  align-items: center;
  aspect-ratio: 16 / 9;
  background: #06080b;
  border-bottom: 1px solid var(--line);
  display: flex;
  justify-content: center;
  overflow: hidden;
  position: relative;
}

.placeholder {
  max-width: 560px;
  padding: 24px;
  position: relative;
  text-align: center;
  z-index: 2;
}

.placeholder strong {
  display: block;
  font-size: 20px;
  margin: 10px 0 6px;
}

.status-dot {
  border-radius: 999px;
  display: inline-block;
  height: 12px;
  width: 12px;
  background: var(--warn);
}

.status-dot.ok {
  background: var(--ok);
}

.status-dot.bad {
  background: var(--bad);
}

#snapshot,
#liveVideo {
  height: 100%;
  object-fit: contain;
  inset: 0;
  position: absolute;
  width: 100%;
}

#liveVideo {
  background: #000;
}

#overlayCanvas {
  cursor: crosshair;
  height: 100%;
  inset: 0;
  position: absolute;
  touch-action: none;
  width: 100%;
  z-index: 3;
}

.counter-strip {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
}

.counter-strip > div {
  border-right: 1px solid var(--line);
  padding: 16px;
}

.counter-strip > div:last-child {
  border-right: 0;
}

.label {
  display: block;
  font-size: 12px;
  margin-bottom: 6px;
  text-transform: uppercase;
}

.counter-strip strong {
  font-size: 18px;
}

.panel {
  padding: 18px;
}

.control-grid {
  display: grid;
  gap: 8px;
  grid-template-columns: 1fr 1fr;
  margin-bottom: 14px;
}

.metric-list {
  display: grid;
  gap: 8px;
  margin-bottom: 20px;
}

.check-row {
  align-items: center;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 6px;
  cursor: pointer;
  display: flex;
  gap: 10px;
  margin-bottom: 14px;
  padding: 10px 12px;
}

.check-row input {
  accent-color: var(--accent);
  height: 16px;
  width: 16px;
}

.check-row span {
  color: var(--text);
  font-size: 13px;
  font-weight: 700;
}

.metric-list > div {
  align-items: center;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 6px;
  display: flex;
  justify-content: space-between;
  padding: 10px 12px;
}

.metric-list span {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
}

.ports {
  display: grid;
  gap: 8px;
  margin-bottom: 14px;
}

.port {
  align-items: center;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 6px;
  display: flex;
  justify-content: space-between;
  padding: 10px 12px;
}

.badge {
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
  padding: 4px 8px;
}

.badge.open {
  background: rgba(34, 197, 94, 0.16);
  color: #86efac;
}

.badge.closed {
  background: rgba(239, 68, 68, 0.16);
  color: #fca5a5;
}

pre {
  background: #0c0f14;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: #cbd5e1;
  font-size: 12px;
  max-height: 280px;
  overflow: auto;
  padding: 12px;
  white-space: pre-wrap;
}

@media (max-width: 860px) {
  .layout {
    grid-template-columns: 1fr;
  }

  .counter-strip {
    grid-template-columns: 1fr;
  }

  .counter-strip > div {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .actions,
  .control-grid {
    grid-template-columns: 1fr;
    width: 100%;
  }

  .actions {
    display: grid;
  }

  .topbar {
    align-items: stretch;
    flex-direction: column;
  }
}
