/* Rally gateway console: dark, high contrast, big touch targets, phone first. */
:root {
  --bg: #0b0f14; --panel: #151b23; --panel2: #1d2530; --line: #2b3542;
  --fg: #f2f5f8; --muted: #9fb0c3; --ok: #2ecc71; --warn: #f1c40f; --bad: #ff5252; --accent: #3da5ff;
  --radius: 14px;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--fg); font: 17px/1.35 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
a { color: var(--accent); }
header { display: flex; align-items: center; gap: 12px; padding: 12px 16px; background: var(--panel); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 2; }
header h1 { font-size: 20px; margin: 0; letter-spacing: .02em; }
header .car { font-weight: 700; color: var(--accent); }
.modebadge { display: inline-block; margin-left: 8px; padding: 2px 10px; border-radius: 12px; font-size: 13px; font-weight: 700; letter-spacing: .03em; border: 1px solid var(--line, #556); color: var(--fg, #ddd); vertical-align: middle; }
.modebadge.k4 { background: #6b3fa0; border-color: #a67ad8; color: #fff; }
.modebadge.hd { background: #1f4d6b; border-color: #4d97c4; color: #fff; }
.modebadge.pending { outline: 2px dashed var(--warn, #e0a030); }
#zowie-4k-note.err { color: var(--bad, #e05050); font-weight: 600; }
header .spacer { flex: 1; }
header .clock { color: var(--muted); font-variant-numeric: tabular-nums; }
header nav a { margin-left: 12px; font-weight: 600; text-decoration: none; }
main { padding: 12px 12px 110px; max-width: 760px; margin: 0 auto; }
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(290px, 1fr)); gap: 12px; }
.tile { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; }
.tile h2 { margin: 0 0 8px; font-size: 14px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); display: flex; align-items: center; gap: 8px; }
.tile .big { font-size: 30px; font-weight: 700; line-height: 1.1; }
.tile .row { display: flex; justify-content: space-between; gap: 8px; padding: 4px 0; border-top: 1px solid var(--line); font-variant-numeric: tabular-nums; }
.tile .row:first-of-type { border-top: 0; }
.muted { color: var(--muted); }
.dot { display: inline-block; width: 12px; height: 12px; border-radius: 50%; background: var(--muted); }
.dot.ok { background: var(--ok); } .dot.warn { background: var(--warn); } .dot.bad { background: var(--bad); }
.link { display: grid; grid-template-columns: 1fr auto auto auto; gap: 8px; align-items: center; padding: 8px 0; border-top: 1px solid var(--line); }
.link:first-of-type { border-top: 0; }
.link .name { font-weight: 700; }
.link.active .name::after { content: " · tunnel"; color: var(--accent); font-weight: 600; }
.logtile { margin-top: 12px; }
.logtile h2 { justify-content: space-between; }
.logtile h2 .muted { text-transform: none; letter-spacing: 0; font-size: 13px; }
pre.log { margin: 0; height: 210px; overflow: auto; white-space: pre-wrap; overflow-wrap: anywhere; font-size: 13px; line-height: 1.4; background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; font-variant-numeric: tabular-nums; }
pre.log .t { color: var(--muted); } pre.log .u { color: var(--accent); font-weight: 600; }
pre.log .p3 { color: var(--bad); } pre.log .p4 { color: var(--warn); }
.btnrow { display: flex; gap: 10px; flex-wrap: wrap; }
button, .btn { font: inherit; font-weight: 700; color: var(--fg); background: var(--panel2); border: 2px solid var(--line); border-radius: var(--radius); padding: 14px 18px; min-height: 56px; min-width: 56px; cursor: pointer; touch-action: manipulation; }
button:active { transform: translateY(1px); }
button.primary { background: var(--accent); border-color: var(--accent); color: #041018; }
button.danger { background: var(--bad); border-color: var(--bad); color: #fff; }
button.on { outline: 3px solid var(--accent); }
button:disabled { opacity: .45; cursor: default; }
.seg { display: flex; gap: 6px; flex-wrap: wrap; }
.seg button { flex: 1; min-width: 80px; }
input, select, textarea { font: inherit; color: var(--fg); background: var(--bg); border: 2px solid var(--line); border-radius: 10px; padding: 12px; min-height: 48px; width: 100%; }
label { display: block; color: var(--muted); font-size: 14px; margin: 10px 0 4px; }
.toast { position: fixed; left: 50%; bottom: 100px; transform: translateX(-50%); background: var(--panel2); border: 2px solid var(--line); border-radius: var(--radius); padding: 12px 18px; max-width: 90vw; z-index: 5; }
.toast.bad { border-color: var(--bad); } .toast.ok { border-color: var(--ok); }
.stale { opacity: .55; }
.banner { background: #3a1d1d; border: 1px solid var(--bad); border-radius: var(--radius); padding: 10px 14px; margin-bottom: 12px; }
.center { max-width: 420px; margin: 10vh auto; padding: 0 16px; }
.center h1 { font-size: 24px; }
details { border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); margin-bottom: 10px; }
summary { padding: 12px 14px; font-weight: 700; cursor: pointer; }
details .body { padding: 0 14px 14px; }
.kv { display: grid; grid-template-columns: minmax(140px, 1fr) 2fr; gap: 6px 10px; align-items: center; }
.kv label { margin: 0; }
.kv input[type=checkbox] { width: 28px; height: 28px; min-height: 0; }
pre { background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 10px; overflow: auto; font-size: 13px; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
td, th { text-align: left; padding: 6px 8px; border-top: 1px solid var(--line); }
@media (max-width: 480px) { .link { grid-template-columns: 1fr auto; } .link .rtt, .link .score { grid-column: span 1; } header h1 { font-size: 17px; } }
.camrow { display: grid; grid-template-columns: auto 2fr 1fr; gap: 8px; align-items: center; margin-top: 8px; }
.camrow .camlabel { color: var(--muted); font-size: 14px; white-space: nowrap; }
.camrow .camnote { grid-column: 2 / span 2; font-size: 14px; }
.camrow.cams { grid-template-columns: auto 2fr 1fr 1.3fr 1fr; }     /* source, format, size, frame rate */
.camrow.cams .camnote { grid-column: 2 / span 4; }
select { appearance: auto; }
.camrow input[type=range] { min-height: 0; padding: 0; width: 100%; accent-color: var(--accent, #4a9eff); }
.camrow input[type=checkbox] { width: 28px; height: 28px; min-height: 0; justify-self: start; }
.camrow .picval { font-size: 14px; color: var(--muted); font-variant-numeric: tabular-nums; }
.camrow.inactive { opacity: .45; }
#picture-rows .camrow { grid-template-columns: 10em 1fr 6em; }   /* one label column for every control */
@media (max-width: 720px) { #picture-rows .camrow { grid-template-columns: 1fr; } }
details.adv { background: transparent; border-style: dashed; margin-top: 10px; }
details.adv summary { color: var(--muted); font-size: 14px; }
@media (max-width: 720px) { .camrow, .camrow.cams { grid-template-columns: 1fr; } .camrow .camnote, .camrow.cams .camnote { grid-column: auto; } }
/* Files page */
.filesroot { margin-bottom: 12px; }
.filesroot h2 .muted { text-transform: none; letter-spacing: 0; font-size: 13px; overflow-wrap: anywhere; }
.bar { height: 14px; background: var(--bg); border: 1px solid var(--line); border-radius: 8px; overflow: hidden; margin: 4px 0; }
.bar span { display: block; height: 100%; background: var(--ok); } .bar span.warn { background: var(--warn); } .bar span.bad { background: var(--bad); }
.crumbs { margin: 10px 0 6px; overflow-wrap: anywhere; }
.flist .frow { display: grid; grid-template-columns: minmax(0, 3fr) 1.4fr 1.6fr 1.4fr auto; gap: 8px; align-items: center; padding: 8px 0; border-top: 1px solid var(--line); font-variant-numeric: tabular-nums; }
.frow .fname { overflow-wrap: anywhere; font-weight: 600; } .frow .facts { display: flex; gap: 6px; align-items: center; justify-content: flex-end; flex-wrap: wrap; }
.frow .small, button.small, .btn.small { font-size: 14px; min-height: 40px; padding: 6px 12px; text-decoration: none; }
.tag { display: inline-block; font-size: 13px; padding: 2px 8px; border: 1px solid var(--line); border-radius: 999px; color: var(--muted); }
.tag.ok { color: var(--ok); border-color: var(--ok); } .tag.warn { color: var(--warn); border-color: var(--warn); }
.small { font-size: 13px; }
@media (max-width: 640px) { .flist .frow { grid-template-columns: 1fr 1fr; } .frow .fname, .frow .facts { grid-column: 1 / -1; justify-content: flex-start; } }
.unreachable main > .grid, .unreachable .logtile { opacity: .55; }
.slider { display: flex; align-items: center; gap: 12px; }
.slider input[type=range] { flex: 1; min-height: 36px; }   /* lowest on the left, highest on the right */
.slider output { min-width: 84px; text-align: right; font-variant-numeric: tabular-nums; }

/* Operate page: the status hero, the cards and the START/STOP bar */
.hero { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; margin-bottom: 12px; }
.hero-main { display: flex; align-items: center; gap: 14px; }
.hero-title { font-size: 28px; font-weight: 800; line-height: 1.1; letter-spacing: .02em; }
.hero-sub { color: var(--muted); margin-top: 2px; font-size: 15px; overflow-wrap: anywhere; }
.dot.big { width: 26px; height: 26px; flex: none; }
.hero.ok { border-color: var(--ok); } .hero.warn { border-color: var(--warn); } .hero.bad { border-color: var(--bad); }
.hero.ok .hero-title { color: var(--ok); } .hero.warn .hero-title { color: var(--warn); } .hero.bad .hero-title { color: var(--bad); }
.chips { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 8px; margin-top: 12px; }
.chip { display: grid; grid-template-columns: auto 1fr; column-gap: 8px; align-items: center; background: var(--panel2); border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; }
.chip b { font-size: 13px; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; font-weight: 600; }
.chip .v { grid-column: 2; font-weight: 700; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.cards { display: grid; grid-template-columns: 1fr; gap: 12px; margin: 12px 0; align-items: start; }
.cards details.card { margin: 0; }
details.card > summary { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; font-size: 16px; text-transform: uppercase; letter-spacing: .06em; }
details.card > summary .sum { text-transform: none; letter-spacing: 0; font-weight: 500; font-size: 14px; color: var(--muted); text-align: right; overflow-wrap: anywhere; }
details.card[hidden] { display: none; }
details.card .body label:first-child { margin-top: 0; }
.actionbar { position: fixed; left: 0; right: 0; bottom: 0; display: flex; gap: 12px; padding: 10px 12px; background: var(--panel); border-top: 1px solid var(--line); z-index: 3; }
.actionbar button { flex: 1; font-size: 20px; }
.actionbar { max-width: 1100px; margin: 0 auto; }
#preset-buttons { display: grid; grid-template-columns: repeat(auto-fit, minmax(68px, 1fr)); gap: 4px; }
#preset-buttons button { min-width: 0; min-height: 38px; padding: 6px 4px; font-size: 14px; border-radius: 10px; white-space: nowrap; }
header { flex-wrap: wrap; }
.card .row { display: flex; justify-content: space-between; gap: 8px; padding: 4px 0; border-top: 1px solid var(--line); font-variant-numeric: tabular-nums; }
.card .row:first-of-type { border-top: 0; }

/* Operate page tabs (phone first): one tab shown at a time, a tab bar in the sticky header, one column everywhere */
[hidden] { display: none !important; }
nav.tabs { position: sticky; top: 0; z-index: 2; display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; padding: 8px 12px; background: var(--panel); border-bottom: 1px solid var(--line); }
header:has(+ nav.tabs) { position: static; }   /* the title row scrolls away; the tab bar stays */
nav.tabs button { min-height: 44px; min-width: 0; padding: 8px 2px; font-size: 15px; border-radius: 10px; background: var(--panel2); }
nav.tabs button.on { background: var(--accent); border-color: var(--accent); color: #041018; }
.tab { display: none; }
body[data-tab="status"] .tab[data-tab="status"],
body[data-tab="feed"] .tab[data-tab="feed"],
body[data-tab="camera"] .tab[data-tab="camera"],
body[data-tab="network"] .tab[data-tab="network"],
body[data-tab="storage"] .tab[data-tab="storage"] { display: block; }
/* the hero stays on every tab; its chips only on Status */
body:not([data-tab="status"]) .hero .chips { display: none; }
body:not([data-tab="status"]) .hero { padding: 10px 14px; }
body:not([data-tab="status"]) .hero-title { font-size: 22px; }
.chips { grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); }
.grid { grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }
/* a camera or audio block: every picker full width with its own label, so the open list is as wide as the screen */
.pick { margin-top: 14px; padding-top: 10px; border-top: 1px solid var(--line); }
.pick h3 { margin: 0 0 2px; font-size: 15px; text-transform: uppercase; letter-spacing: .06em; }
.pick label { margin: 10px 0 4px; }
.pick select { width: 100%; text-overflow: ellipsis; font-size: 17px; }
.pick .camnote { margin-top: 6px; font-size: 14px; }
@media (max-width: 400px) { header h1 { font-size: 16px; } header nav a { margin-left: 8px; } nav.tabs button { font-size: 14px; } }
body:not([data-tab]) .tab[data-tab="status"] { display: block; }   /* before the script has picked a tab */

.zrow { margin: 8px 0; }
.zrow label { display: block; margin-bottom: 4px; }
.zrow select { width: 100%; }
#zowie-panel-body h3 { margin: 14px 0 4px; }

.row.off { opacity: .4; }

/* the camera mode buttons: the mode in use is green */
#mode-buttons button.on { background: #1d6b34; border-color: #46c46a; color: #fff; outline: 3px solid #46c46a; outline-offset: -1px; }

/* The fleet console's scope bar: HOME and the clock always first, then the scope (SERVER or the car) and its buttons */
header.scoped { gap: 6px 12px; }
header.scoped .home { font-weight: 800; letter-spacing: .06em; text-decoration: none; padding: 6px 12px; border-radius: 8px; background: var(--panel2); border: 1px solid var(--line); }
header.scoped .scope { display: flex; align-items: center; flex-wrap: wrap; gap: 4px 12px; margin-left: 4px; padding-left: 14px; border-left: 3px solid var(--scope, var(--accent)); }
header.scoped .scope-label { font-weight: 800; letter-spacing: .08em; color: var(--scope, var(--accent)); white-space: nowrap; }
header.scoped nav { display: flex; flex-wrap: wrap; gap: 4px 14px; }
header.scoped nav a { margin-left: 0; }
header.scoped .logoutlink { font-weight: 600; text-decoration: none; }
header.scope-server { --scope: #5aa9ff; }
header.scope-car { --scope: #ffb347; }
@media (max-width: 700px) {
  header.scoped .scope { order: 5; flex: 1 0 100%; margin-left: 0; padding: 6px 0 0 10px; overflow-x: auto; flex-wrap: nowrap; white-space: nowrap; }
  header.scoped nav { flex-wrap: nowrap; }
}
