:root {
  --bg: #050b18;
  --panel: #0c1526;
  --panel-2: #101c33;
  --text: #e6edf3;
  --muted: #8b98a5;
  --accent: #ff9f1c;
  --accent-soft: rgba(255, 159, 28, 0.15);
  --blue: #4c9bff;
  --bar: #1d2d47;
  --border: #1f2d44;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  line-height: 1.5;
}

[hidden] { display: none !important; }

/* Top bar */
.topbar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px 20px;
  padding: 12px 16px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 1.05rem; }
.logo {
  display: inline-grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 6px;
  background: var(--accent);
  color: #111;
  font-size: 0.95rem;
}

.modules { display: flex; flex-wrap: wrap; gap: 4px; flex: 1; justify-content: center; }
.nav-btn {
  background: none;
  border: 0;
  border-bottom: 2px solid transparent;
  color: var(--muted);
  padding: 6px 10px;
  font: inherit;
  font-size: 0.9rem;
  cursor: pointer;
}
.nav-btn:hover { color: var(--text); }
.nav-btn.active { color: var(--accent); border-bottom-color: var(--accent); }

.levels {
  display: flex;
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
}
.level-btn {
  background: none;
  border: 0;
  color: var(--muted);
  padding: 6px 12px;
  font: inherit;
  font-size: 0.85rem;
  cursor: pointer;
}
.level-btn.active { background: var(--accent); color: #111; font-weight: 600; }

/* Medium screens: keep the module tabs on one full-width row under the brand and levels. */
@media (max-width: 1280px) {
  .topbar { flex-wrap: wrap; }
  .modules { order: 3; flex: 0 0 100%; justify-content: center; }
}

/* Views */
.view { flex: 1; width: 100%; }
.layout {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr);
  gap: 16px;
  padding: 16px;
  max-width: 1200px;
  margin: 0 auto;
}
@media (max-width: 800px) {
  .layout { grid-template-columns: 1fr; }
  .modules { justify-content: flex-start; }
}

.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px;
  min-width: 0;
}
.placeholder { max-width: 1200px; margin: 16px auto; color: var(--muted); }
.placeholder h2 { color: var(--text); margin-top: 0; }

.panel h2 {
  font-size: 0.8rem;
  margin: 20px 0 8px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.tabs { display: flex; gap: 8px; margin-bottom: 12px; flex-wrap: wrap; }
.tab {
  background: none;
  border: 1px solid var(--border);
  color: var(--muted);
  padding: 6px 12px;
  border-radius: 999px;
  cursor: pointer;
  font: inherit;
}
.tab.active { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }

.viewport {
  position: relative;
  width: 100%;
  aspect-ratio: 4 / 3;
  background: #000;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}
.viewport video,
.viewport img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.status {
  position: absolute;
  inset: auto 12px 12px 12px;
  color: #fff;
  background: rgba(0, 0, 0, 0.6);
  padding: 8px 10px;
  border-radius: 6px;
  font-size: 0.9rem;
}

.controls { display: flex; gap: 8px; margin-top: 12px; flex-wrap: wrap; align-items: center; }

button,
.file {
  font: inherit;
  padding: 8px 14px;
  border-radius: 6px;
  border: 1px solid var(--accent);
  background: var(--accent);
  color: #111;
  font-weight: 600;
  cursor: pointer;
}
button:disabled { opacity: 0.45; cursor: not-allowed; }
#stopBtn { background: none; color: var(--accent); }
.file { display: inline-block; }
.file input { display: none; }

.metrics {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}
.metrics > div {
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px;
  text-align: center;
}
.metrics span {
  display: block;
  font-size: 1.4rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--accent);
}
.metrics small { color: var(--muted); font-size: 0.75rem; }

.preds { list-style: none; padding: 0; margin: 0; }
.preds li { margin-bottom: 10px; }
.pred-row {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  font-size: 0.92rem;
  margin-bottom: 4px;
}
.pred-row span:last-child { font-variant-numeric: tabular-nums; color: var(--muted); }
.bar {
  height: 8px;
  background: var(--bar);
  border-radius: 4px;
  overflow: hidden;
}
.bar > div {
  height: 100%;
  background: var(--blue);
  transition: width 0.2s ease;
}

.hint { margin: 0; font-size: 0.95rem; }
.note { margin-top: 20px; font-size: 0.8rem; color: var(--muted); }

.footer {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 8px;
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 0.8rem;
}
