/* Variables, header and type are taken from the runfp report (OORB Run View),
   so the console reads as part of runfp. */
:root {
  --bg: #0f1112;
  --panel: #121517;
  --panel-2: #16191b;
  --ink: #ffffff;
  --text: #e6e9ec;
  --muted: #94a3b8;
  --muted-2: #6b7280;
  --line: #25292c;
  --accent: #16bbc4;
  --accent-2: #0f7278;
  --blue: #60a5fa;
  --red: #fb7185;
  --green: #4ade80;
  --yellow: #facc15;
  --orange: #fb923c;
  --ok: var(--accent);
  --warn: var(--yellow);
  --crit: var(--red);
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --sans: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 14px/1.45 var(--sans); }
[hidden] { display: none !important; }
a { color: var(--accent); }
button {
  font: inherit; color: var(--ink); background: #17111d; border: 1px solid var(--accent-2);
  border-radius: 6px; padding: 6px 11px; cursor: pointer; white-space: nowrap;
}
button:hover { border-color: var(--accent); }
button:disabled { opacity: 0.45; cursor: default; }
button.primary { background: color-mix(in srgb, var(--accent) 16%, transparent); border-color: var(--accent); }
button.quiet { background: transparent; border-color: var(--line); color: var(--muted); }
.mono { font-family: var(--mono); }
.muted { color: var(--muted); }

/* ------------------------------------------------------------ header */
header {
  display: flex; align-items: center; gap: 18px; flex-wrap: wrap;
  padding: 10px 18px; border-bottom: 1px solid var(--line); background: #08070a;
  position: sticky; top: 0; z-index: 5;
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand-logo { height: 22px; width: auto; display: block; }
.title { font-size: 15px; font-weight: 760; color: var(--ink); }
.subtitle { color: var(--muted); font-size: 12px; font-family: var(--mono); }
nav.tabs { display: flex; gap: 4px; }
nav.tabs button { background: transparent; border-color: transparent; color: var(--muted); padding: 6px 12px; }
nav.tabs button.active { color: var(--ink); border-color: var(--accent-2); background: color-mix(in srgb, var(--accent) 10%, transparent); }
.spacer { flex: 1; }
.pills { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.pill {
  font: 12px var(--mono); padding: 2px 8px; border-radius: 999px;
  border: 1px solid var(--line); color: var(--muted); white-space: nowrap;
}
.pill.ok { color: var(--ok); border-color: color-mix(in srgb, var(--ok) 45%, transparent); }
.pill.warn { color: var(--warn); border-color: color-mix(in srgb, var(--warn) 45%, transparent); }
.pill.crit { color: var(--crit); border-color: color-mix(in srgb, var(--crit) 45%, transparent); }
.pill.pass { color: var(--green); border-color: color-mix(in srgb, var(--green) 45%, transparent); }

/* ------------------------------------------------------------ layout */
main { padding: 14px 18px; max-width: 1600px; margin: 0 auto; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 12px 14px; min-width: 0; }
.card-head { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; flex-wrap: wrap; }
.card-head .spacer { flex: 1; }
.eyebrow { color: var(--accent); text-transform: uppercase; font-size: 11px; letter-spacing: 0.08em; margin: 0; font-weight: 760; }
.note { font: 12px var(--mono); color: var(--muted); }

#view-live { display: grid; gap: 14px; grid-template-columns: minmax(0, 1fr) 330px; align-items: start; }
.live-main { display: grid; gap: 14px; min-width: 0; }
.live-side { display: grid; gap: 14px; }

video, #video-fallback { width: 100%; aspect-ratio: 4 / 3; max-height: calc(100vh - 290px); background: #000; border-radius: 6px; display: block; object-fit: contain; }
video.wide, #video-fallback.wide { aspect-ratio: 2 / 1; }
.segmented { display: flex; border: 1px solid var(--line); border-radius: 6px; overflow: hidden; }
.segmented button { border: 0; border-radius: 0; background: transparent; color: var(--muted); padding: 3px 10px; font-size: 12px; }
.segmented button.active { background: color-mix(in srgb, var(--accent) 16%, transparent); color: var(--ink); }
#lidar { width: 100%; aspect-ratio: 1; display: block; background: var(--panel-2); border-radius: 6px; }

.drive { display: flex; gap: 14px; align-items: center; }
#pad {
  position: relative; flex: 0 0 140px; height: 140px; border-radius: 50%;
  border: 1px solid var(--line); background: var(--panel-2); touch-action: none; user-select: none;
}
#pad.active { border-color: var(--accent); }
#knob {
  position: absolute; left: 50%; top: 50%; width: 50px; height: 50px; margin: -25px 0 0 -25px;
  border-radius: 50%; background: var(--line); pointer-events: none;
}
#pad.active #knob { background: var(--accent); }
.drive .note { display: grid; gap: 6px; }

.record-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

#events { list-style: none; margin: 0; padding: 0; max-height: 132px; overflow-y: auto; font: 12px var(--mono); }
#events li { padding: 4px 0; border-top: 1px solid var(--line); }
#events li:first-child { border-top: 0; }
#events:empty::before { content: "No events yet."; color: var(--muted); }
#events .kind { color: var(--blue); margin-right: 8px; }
#events li.warn .kind { color: var(--warn); }
#events li.crit .kind { color: var(--crit); }

/* ------------------------------------------------------------ tables */
.stack { display: grid; gap: 14px; }
.summary { display: flex; gap: 28px; flex-wrap: wrap; }
.summary div { display: grid; }
.summary b { font-size: 18px; color: var(--ink); font-weight: 700; }
.summary span { font-size: 12px; color: var(--muted); }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { color: var(--muted); font-weight: 720; text-align: left; font-size: 12px; padding: 6px 10px 6px 0; border-bottom: 1px solid var(--line); }
td { color: var(--text); padding: 7px 10px 7px 0; border-bottom: 1px solid var(--line); font-family: var(--mono); font-size: 12px; white-space: nowrap; }
tr:last-child td { border-bottom: 0; }
td.actions { text-align: right; }
td.actions button { padding: 3px 9px; font-size: 12px; font-family: var(--sans); }
td .fail { color: var(--crit); white-space: normal; }

/* ------------------------------------------------------------ settings */
.settings { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); align-items: start; }
.field { display: grid; grid-template-columns: 1fr 110px; gap: 4px 12px; align-items: center; padding: 8px 0; border-top: 1px solid var(--line); }
.card-head + .field { border-top: 0; }
.field label { color: var(--text); }
.field .hint { grid-column: 1 / -1; font: 12px var(--mono); color: var(--muted); }
.field input[type=number] {
  width: 100%; font: 13px var(--mono); color: var(--ink); background: var(--panel-2);
  border: 1px solid var(--line); border-radius: 6px; padding: 5px 8px;
}
.field input[type=checkbox] { justify-self: end; width: 18px; height: 18px; accent-color: var(--accent); }
.save-row { display: flex; gap: 12px; align-items: center; margin-top: 14px; }
#settings-result.error { color: var(--crit); }

/* ------------------------------------------------------------ monitor */
.monitor-topics { grid-template-columns: 80px 1fr; border-top: 0; }
.monitor-topics input {
  width: 100%; font: 12px var(--mono); color: var(--ink); background: var(--panel-2);
  border: 1px solid var(--line); border-radius: 6px; padding: 6px 8px;
}
#monitor-frame { width: 100%; height: calc(100vh - 230px); min-height: 480px; border: 1px solid var(--line); border-radius: 8px; background: var(--bg); }

/* ------------------------------------------------------------ login */
.login { max-width: 340px; margin: 14vh auto; padding: 22px; }
.login .brand { margin-bottom: 18px; }
.login label { display: block; font-size: 12px; color: var(--muted); margin: 12px 0 4px; }
.login input {
  width: 100%; font: inherit; color: var(--ink); background: var(--panel-2);
  border: 1px solid var(--line); border-radius: 6px; padding: 8px;
}
.login button { width: 100%; margin-top: 18px; padding: 8px; }
.error { color: var(--crit); font-size: 13px; min-height: 1.4em; margin-top: 10px; }

@media (max-width: 900px) {
  header { gap: 10px; padding: 10px 12px; }
  main { padding: 10px; }
  #view-live { grid-template-columns: minmax(0, 1fr); }
  /* phone: video, then the controls, then context */
  .live-main, .live-side { display: contents; }
  #card-video { order: 1; } #card-drive { order: 2; } #card-record { order: 3; } #card-lidar { order: 4; } #card-events { order: 5; }
  video { max-height: none; }
  .subtitle { display: none; }
}
