:root { --bg:#f2f3f5; --card:#fff; --ink:#1b2430; --mut:#6b7686; --line:#e1e5ec; --acc:#e03030; --acc2:#1f5fbf; --good:#1d9a57; --bad:#c0392b; --mid:#e08a00; --hov:#fbeaea; }
@media (prefers-color-scheme: dark) { :root { --bg:#141a22; --card:#1d2530; --ink:#e6ebf2; --mut:#9aa6b6; --line:#2e3948; --acc:#ff5a5a; --acc2:#5b9bff; --good:#4cc384; --bad:#ff7a7a; --mid:#f0a93a; --hov:#3a2427; } }
* { box-sizing: border-box; }
body { margin:0; background:var(--bg); color:var(--ink); font:14px/1.45 system-ui, "Segoe UI", sans-serif; }
a { color:var(--acc2); }

/* top bar */
header.top { background:var(--card); border-bottom:1px solid var(--line); display:flex; align-items:stretch; gap:26px; padding:0 18px; height:48px; position:sticky; top:0; z-index:500; }
header.top .brand { display:flex; align-items:center; gap:8px; font-weight:700; font-size:15px; white-space:nowrap; }
header.top .brand i { width:22px; height:22px; border-radius:50%; background:var(--acc); display:inline-block; box-shadow:inset 0 0 0 5px var(--card), 0 0 0 2px var(--acc); }
header.top nav { display:flex; gap:4px; flex:1; }
header.top nav a { color:var(--ink); text-decoration:none; font-weight:600; display:flex; align-items:center; padding:0 14px; border-bottom:2px solid transparent; }
header.top nav a:hover { color:var(--acc); }
header.top nav a.on { color:var(--acc); border-bottom-color:var(--acc); }
header.top .right { display:flex; align-items:center; gap:14px; color:var(--mut); font-size:13px; }
header.top form { margin:0; }
header.top .user { color:var(--ink); text-decoration:none; font-weight:600; } header.top .user small { color:var(--mut); font-weight:400; text-transform:capitalize; margin-left:2px; } header.top .user.on, header.top .user:hover { color:var(--acc); }
/* what the role may not do is not offered (the server refuses it anyway) */
body[data-role="viewer"] .needs-op, body[data-role="viewer"] .needs-admin, body[data-role="operator"] .needs-admin { display:none !important; }

/* page frame */
.shell { display:flex; min-height:calc(100vh - 48px); }
.rail { width:92px; background:var(--card); border-right:1px solid var(--line); flex:none; padding-top:6px; }
.rail a { display:block; text-align:center; padding:12px 4px; color:var(--mut); text-decoration:none; font-size:12px; border-left:3px solid transparent; }
.rail a b { display:block; font-size:18px; line-height:1.1; margin-bottom:2px; font-weight:400; }
.rail a:hover { color:var(--ink); background:var(--bg); }
.rail a.on { color:var(--acc); border-left-color:var(--acc); background:var(--hov); }
main { flex:1; min-width:0; padding:14px 18px 30px; }
main.full { padding:0; }
h1 { font-size:20px; margin:4px 0 12px; } h2 { font-size:16px; margin:18px 0 8px; }
h3.t { font-size:14px; margin:0 0 10px; padding-left:8px; border-left:3px solid var(--acc); line-height:1.2; }

/* cards, tables */
.card { background:var(--card); border:1px solid var(--line); border-radius:4px; padding:12px 14px; margin-bottom:12px; }
.grid { display:grid; gap:12px; } .g5 { grid-template-columns:repeat(5,1fr); } .g4 { grid-template-columns:repeat(4,1fr); } .g3 { grid-template-columns:repeat(3,1fr); } .g2 { grid-template-columns:repeat(2,1fr); }
.grid > .card { margin:0; }
table { width:100%; border-collapse:collapse; background:var(--card); } th, td { text-align:left; padding:7px 10px; border-bottom:1px solid var(--line); vertical-align:middle; }
th { color:var(--ink); font-weight:600; font-size:12px; background:var(--bg); white-space:nowrap; }
tr:hover td { background:var(--hov); }
.muted { color:var(--mut); } .small { font-size:12px; }
.pill { display:inline-block; border-radius:10px; padding:1px 9px; font-size:12px; background:var(--line); }
.pill.good { background:#d6f1e2; color:#0f5a32; } .pill.bad { background:#f6d4d4; color:#7f1d1d; } .pill.mid { background:#fdeccb; color:#7a4b00; } .pill.blue { background:#dbe8fb; color:#17407f; }
@media (prefers-color-scheme: dark) { .pill.good { background:#17402b; color:#7fe0ae; } .pill.bad { background:#4a2326; color:#ffb3b3; } .pill.mid { background:#493616; color:#ffd58a; } .pill.blue { background:#1c3050; color:#a9c8ff; } }
.dot { display:inline-block; width:8px; height:8px; border-radius:50%; background:var(--mut); margin-right:5px; } .dot.good { background:var(--good); } .dot.bad { background:var(--bad); } .dot.mid { background:var(--mid); }

/* forms and buttons */
button, .btn { background:var(--acc); color:#fff; border:0; border-radius:3px; padding:6px 14px; font:inherit; cursor:pointer; text-decoration:none; display:inline-block; }
button:hover, .btn:hover { filter:brightness(1.08); }
button.sec, .btn.sec { background:#6b7686; } button.ghost, .btn.ghost { background:transparent; color:var(--acc2); padding:2px 6px; } button:disabled { opacity:.5; cursor:default; }
.btn.sm, button.sm { padding:3px 9px; font-size:12px; }
input, select, textarea { font:inherit; padding:5px 8px; border:1px solid var(--line); border-radius:3px; background:var(--card); color:var(--ink); }
input:focus, select:focus, textarea:focus { outline:1px solid var(--acc); border-color:var(--acc); }
label { display:block; font-weight:600; font-size:12px; color:var(--mut); margin:6px 0 2px; }
.row { display:flex; gap:12px; flex-wrap:wrap; align-items:flex-end; } .row > div { min-width:140px; }
.msg { padding:8px 12px; border-radius:4px; margin:8px 0; } .msg.err { background:#f6d4d4; color:#7f1d1d; } .msg.warn { background:#fdeccb; color:#7a4b00; } .msg.ok { background:#d6f1e2; color:#0f5a32; }
code { background:var(--bg); border:1px solid var(--line); padding:0 4px; border-radius:3px; }
pre { background:var(--bg); border:1px solid var(--line); border-radius:4px; padding:10px; overflow:auto; font-size:12px; margin:6px 0; }
dialog { border:1px solid var(--line); border-radius:6px; background:var(--card); color:var(--ink); padding:18px; min-width:340px; max-width:92vw; }
dialog::backdrop { background:rgba(0,0,0,.4); }
.login { max-width:340px; margin:80px auto; }

/* dashboard */
.tile { text-align:center; } .tile h3.t { text-align:left; }
.ring { position:relative; width:92px; height:92px; margin:6px auto 2px; } .ring svg { width:92px; height:92px; transform:rotate(-90deg); } .ring b { position:absolute; inset:0; display:flex; align-items:center; justify-content:center; font-size:20px; }
.legend { font-size:12px; text-align:left; } .legend div { display:flex; align-items:center; gap:6px; margin:2px 0; } .legend i { width:9px; height:9px; border-radius:50%; flex:none; } .legend span { margin-left:auto; color:var(--mut); }
.donut { display:flex; gap:20px; align-items:center; justify-content:center; padding:6px 0; flex-wrap:wrap; } .donut .ring { width:170px; height:170px; margin:0; } .donut .ring svg { width:170px; height:170px; } .donut .ring b { font-size:26px; flex-direction:column; text-align:center; line-height:1.1; } .donut .ring b small { font-size:12px; font-weight:400; color:var(--mut); max-width:90px; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.big { font-size:26px; font-weight:700; } .res .row2 { display:flex; justify-content:space-between; font-size:12px; color:var(--mut); margin-top:4px; }
.bar { height:8px; background:var(--line); border-radius:4px; overflow:hidden; margin:8px 0 2px; } .bar i { display:block; height:100%; background:var(--acc); }
svg.spark { width:100%; height:44px; display:block; margin-top:6px; }
.counters { display:flex; gap:26px; flex-wrap:wrap; } .counters div b { display:block; font-size:18px; }

/* monitor */
.monitor { display:flex; height:calc(100vh - 48px); position:relative; }
.mlist { width:330px; flex:none; background:var(--card); border-right:1px solid var(--line); display:flex; flex-direction:column; }
.mlist .top { padding:10px; border-bottom:1px solid var(--line); } .mlist .top input { width:100%; }
.mlist .items { overflow:auto; flex:1; }
.mitem { padding:9px 12px; border-bottom:1px solid var(--line); cursor:pointer; display:flex; gap:8px; align-items:center; } .mitem:hover { background:var(--hov); } .mitem.sel { background:var(--hov); box-shadow:inset 3px 0 0 var(--acc); }
.mitem .nm { font-weight:600; } .mitem .sub { font-size:12px; color:var(--mut); } .mitem .st { margin-left:auto; text-align:right; font-size:12px; }
.mapwrap { flex:1; position:relative; min-width:0; } #map { position:absolute; inset:0; }
.detail { position:absolute; left:12px; top:12px; z-index:450; width:310px; background:var(--card); border:1px solid var(--line); border-radius:4px; box-shadow:0 2px 12px rgba(0,0,0,.25); display:none; max-height:calc(100% - 90px); overflow:auto; }
.detail .hd { display:flex; align-items:center; padding:10px 12px; border-bottom:1px solid var(--line); font-weight:700; } .detail .hd button { margin-left:auto; background:none; color:var(--mut); font-size:18px; padding:0 4px; }
.detail dl { margin:0; padding:6px 12px 12px; display:grid; grid-template-columns:1fr auto; gap:5px 10px; } .detail dt { grid-column:1; } .detail dd { margin:0; text-align:right; color:var(--mut); font-size:12px; } .detail dt { font-size:13px; }
.detail .acts { display:flex; gap:6px; padding:0 12px 12px; flex-wrap:wrap; }
.sbar { position:absolute; left:50%; transform:translateX(-50%); bottom:14px; z-index:450; display:flex; gap:6px; background:var(--card); border:1px solid var(--line); border-radius:6px; padding:6px; box-shadow:0 2px 12px rgba(0,0,0,.25); }
.sbar button { background:var(--bg); color:var(--ink); border:1px solid var(--line); border-radius:5px; text-align:center; min-width:74px; padding:4px 8px; } .sbar button b { display:block; font-size:16px; }
.sbar button.on { color:#fff; border-color:transparent; } .sbar button[data-s=all].on { background:var(--acc); } .sbar button[data-s=moving].on { background:var(--good); } .sbar button[data-s=idling].on { background:var(--mid); } .sbar button[data-s=parked].on { background:#3b6fd4; } .sbar button[data-s=offline].on { background:#6b7686; } .sbar button[data-s=other].on { background:#8e44ad; }

/* video */
.vwrap { display:flex; gap:12px; align-items:flex-start; }
.vtree { width:300px; flex:none; background:var(--card); border:1px solid var(--line); border-radius:4px; max-height:calc(100vh - 110px); display:flex; flex-direction:column; }
.vtree .top { padding:10px; border-bottom:1px solid var(--line); } .vtree .top input { width:100%; } .vtree .items { overflow:auto; }
.vdev { padding:8px 12px; border-bottom:1px solid var(--line); } .vdev .nm { font-weight:600; cursor:pointer; } .vdev .chs { display:grid; grid-template-columns:1fr 1fr; gap:4px; margin:6px 0 0; } .vdev .chs label { display:flex; gap:5px; align-items:center; font-weight:400; color:var(--ink); margin:0; font-size:13px; }
.vmain { flex:1; min-width:0; }
.vgrid { display:grid; gap:3px; background:var(--line); } .vgrid.l1 { grid-template-columns:1fr; } .vgrid.l4 { grid-template-columns:1fr 1fr; } .vgrid.l9 { grid-template-columns:repeat(3,1fr); }
.vtile { position:relative; background:#000; aspect-ratio:16/9; overflow:hidden; } .vtile video { width:100%; height:100%; object-fit:contain; background:#000; border-radius:0; aspect-ratio:auto; }
.vtile .cap { position:absolute; left:0; right:0; top:0; padding:3px 8px; font-size:12px; color:#fff; background:linear-gradient(#000a,#0000); display:flex; gap:8px; } .vtile .cap button { margin-left:auto; padding:0 7px; background:#0008; }
.vtile .info { position:absolute; inset:0; display:flex; align-items:center; justify-content:center; color:#9aa6b6; font-size:13px; text-align:center; padding:10px; pointer-events:none; }
video { width:100%; background:#000; aspect-ratio:16/9; border-radius:4px; }
.days { display:flex; flex-direction:column; gap:6px; width:120px; flex:none; } .days button { background:var(--card); color:var(--ink); border:1px solid var(--line); text-align:left; } .days button.on { background:var(--hov); color:var(--acc); border-color:var(--acc); }
.evgrid { display:grid; grid-template-columns:repeat(auto-fill,minmax(330px,1fr)); gap:12px; flex:1; }
.ev { background:var(--card); border:1px solid var(--line); border-radius:4px; padding:12px; } .ev b.nm { font-size:15px; } .ev .tt { font-weight:700; margin:4px 0; } .ev .acts { margin-top:8px; display:flex; gap:6px; flex-wrap:wrap; }
.ev .evd { display:grid; grid-template-columns:repeat(auto-fill,minmax(120px,1fr)); gap:8px; margin-top:8px; }
.ev .evd figure { margin:0; } .ev .evd img, .ev .evd video { width:100%; max-height:150px; object-fit:cover; border-radius:3px; background:#000; display:block; }
.ev .evd audio { width:100%; }
.statline { display:flex; gap:14px; flex-wrap:wrap; margin:6px 0 0; }
@media (max-width:1000px) { .g5 { grid-template-columns:repeat(3,1fr); } .g4, .g3 { grid-template-columns:repeat(2,1fr); } .rail { width:70px; } .vwrap { flex-direction:column; } .vtree { width:100%; max-height:300px; } }
@media (max-width:640px) { main { padding:10px; } table { font-size:12px; } .g5, .g4, .g3, .g2 { grid-template-columns:1fr; } header.top { gap:8px; overflow-x:auto; } .monitor { flex-direction:column; height:auto; } .mlist { width:100%; height:240px; } .mapwrap { height:70vh; } }
/* Swagger UI brings its own light theme: keep the platform's table styles out of it */
#swagger table, #swagger thead, #swagger tbody, #swagger tr, #swagger th, #swagger td { background:transparent !important; color:#3b4151 !important; border-color:#d8dde6; }

.chk { display:inline-flex; align-items:center; gap:4px; margin-right:10px; font-weight:400; } .chk input { width:auto; }
.bar { height:8px; background:var(--line); border-radius:4px; overflow:hidden; } .bar > i { display:block; height:100%; background:var(--acc); width:0; }
textarea.mono { width:100%; min-height:90px; font-family:ui-monospace,Consolas,monospace; font-size:12px; }
.tag { display:inline-block; padding:1px 7px; border-radius:9px; font-size:11px; font-weight:600; background:var(--line); color:var(--mut); } .tag.ok { background:#1d9a5733; color:#1d9a57; } .tag.warn { background:#e08a0033; color:#e08a00; }
