:root {
  --bg: #090d12; --surface: #121a22; --surface2: #1a242e; --line: #26323d;
  --text: #eef3f6; --muted: #8fa1af; --cyan: #2ddaeb; --red: #ee3139; --amber: #f5ad4e;
  --green: #40cf99; --blue: #5aaee0; --violet: #a68cf0; --r: 12px;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text);
  font: 14px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
a { color: var(--cyan); text-decoration: none; }
button, .btn, select, input { font: inherit; color: inherit; }
button, .btn { cursor: pointer; border: 1px solid var(--line); background: var(--surface2); border-radius: 8px;
  padding: 8px 14px; display: inline-flex; align-items: center; gap: 6px; }
button:hover, .btn:hover { border-color: var(--cyan); }
button:disabled { opacity: .5; cursor: default; }
.primary { background: var(--red); border-color: var(--red); color: #fff; font-weight: 600; }
.primary:hover { background: #ff4a52; border-color: #ff4a52; }
.ghost { background: transparent; }
.small { padding: 5px 10px; font-size: 13px; }
.wide { width: 100%; justify-content: center; padding: 12px; }
.muted { color: var(--muted); }
small, .small { font-size: 12px; }
select, input[type=text], input[type=password], input[type=date], input[type=search] {
  background: var(--surface2); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; }
input:focus, select:focus { outline: 2px solid var(--cyan); outline-offset: 0; }

/* login */
.login-body { min-height: 100vh; display: grid; place-items: center; padding: 20px;
  background: radial-gradient(circle at 30% 10%, #13303a 0, transparent 50%), var(--bg); }
.login-card { width: 100%; max-width: 400px; background: var(--surface); border: 1px solid var(--line);
  border-radius: 18px; padding: 30px; box-shadow: 0 20px 60px #0008; }
.login-card h1 { margin: 22px 0 4px; font-size: 22px; }
.login-card label { display: block; margin: 18px 0 6px; font-weight: 600; }
.login-card .check { display: flex; gap: 8px; align-items: center; font-weight: 400; color: var(--muted); }
.login-card form button.primary { margin-top: 20px; }
.pw { display: flex; gap: 8px; } .pw input { flex: 1; min-width: 0; }
.err { color: var(--red); min-height: 1.4em; margin: 10px 0 0; }

/* chrome */
.brand { display: flex; gap: 10px; align-items: center; }
.brand b { display: block; font-size: 16px; } .brand span { display: block; color: var(--muted); font-size: 12px; }
.top { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 20px; padding: 12px 22px;
  background: #090d12e6; backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); }
nav { display: flex; gap: 4px; flex: 1; overflow-x: auto; }
nav button { border: 0; background: transparent; color: var(--muted); padding: 8px 14px; border-radius: 8px; white-space: nowrap; }
nav button.on { color: var(--text); background: var(--surface2); box-shadow: inset 0 -2px 0 var(--cyan); }
.top-right { display: flex; align-items: center; gap: 8px; }
.pill { padding: 4px 10px; border-radius: 99px; font-size: 12px; background: var(--surface2); border: 1px solid var(--line); white-space: nowrap; }
.pill.ok { color: var(--green); border-color: #2b6b55; } .pill.warn { color: var(--amber); border-color: #6b5530; }
.pill.bad { color: var(--red); border-color: #6b2b2f; }
.menu { position: relative; }
.menu-pop { position: absolute; right: 0; top: 40px; background: var(--surface); border: 1px solid var(--line);
  border-radius: 10px; padding: 6px; display: flex; flex-direction: column; min-width: 190px; box-shadow: 0 10px 30px #0009; }
.menu-pop[hidden], .toast[hidden] { display: none; }
.menu-pop button { border: 0; background: transparent; justify-content: flex-start; }
.menu-pop button:hover { background: var(--surface2); }
main { padding: 22px; max-width: 1500px; margin: 0 auto; }
.tab { display: none; } .tab.on { display: block; }
h2 { font-size: 15px; margin: 26px 0 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; font-weight: 600; }
h2:first-child { margin-top: 0; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }

/* cards */
.grid { display: grid; gap: 14px; }
.kpis { grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); }
.two { grid-template-columns: 1fr 1fr; } .three { grid-template-columns: 2fr 1fr; }
@media (max-width: 900px) { .two, .three { grid-template-columns: 1fr; } .top { flex-wrap: wrap; } nav { order: 3; flex-basis: 100%; } }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 16px; min-width: 0; }
.kpi .v { font-size: 26px; font-weight: 700; margin-top: 4px; } .kpi .l { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .06em; }
.kpi .s { color: var(--muted); font-size: 12px; margin-top: 2px; }
.card h3 { margin: 0 0 12px; font-size: 14px; }
.alert { border-color: #6b5530; background: #1d1810; }

/* meters */
.meter { height: 14px; border-radius: 99px; background: var(--surface2); overflow: hidden; display: flex; }
.meter > i { display: block; height: 100%; }
.legend { display: flex; flex-wrap: wrap; gap: 14px; margin-top: 10px; font-size: 12px; color: var(--muted); }
.legend span::before { content: ""; display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; background: var(--c); vertical-align: -1px; }
.ring-wrap { display: flex; gap: 20px; align-items: center; }
.ring-wrap .big { font-size: 30px; font-weight: 700; }
.c-clips { --c: var(--blue); } .c-kept { --c: var(--green); } .c-events { --c: var(--red); } .c-other { --c: #2c3741; } .c-parked { --c: #7d8b99; } .c-free { --c: var(--surface2); }

/* charts */
svg.chart { width: 100%; height: auto; display: block; }
svg.chart text { fill: var(--muted); font-size: 10px; }
svg.chart .grid-l { stroke: var(--line); stroke-width: 1; }
.heat { display: grid; grid-template-columns: repeat(24, 1fr); gap: 3px; }
.heat i { aspect-ratio: 1; border-radius: 3px; background: var(--cyan); }
.heat-l { display: grid; grid-template-columns: repeat(24, 1fr); font-size: 10px; color: var(--muted); margin-top: 4px; }

/* galleries */
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 14px; }
.tile { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; cursor: pointer; }
.tile:hover { border-color: var(--cyan); }
.tile .th { position: relative; aspect-ratio: 1440 / 1040; background: #141c24; }
.tile img { width: 100%; height: 100%; object-fit: cover; display: block; }
.tile .badge { position: absolute; left: 8px; top: 8px; }
.tile .dur { position: absolute; right: 8px; bottom: 8px; background: #000b; padding: 2px 7px; border-radius: 6px; font-size: 12px; }
.tile .meta { padding: 10px 12px; } .tile .meta b { display: block; }
.badge { padding: 2px 8px; border-radius: 6px; font-size: 11px; font-weight: 700; letter-spacing: .04em; }
.b-event { background: var(--red); color: #fff; } .b-kept { background: var(--green); color: #052; }
.b-web { background: var(--violet); color: #fff; } .b-car { background: var(--blue); color: #012; }
.list { display: flex; flex-direction: column; gap: 8px; }
.drive { display: grid; grid-template-columns: 160px 1fr auto; gap: 14px; align-items: center; background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--r); padding: 10px; }
.drive img { width: 160px; aspect-ratio: 1440/1040; object-fit: cover; border-radius: 8px; cursor: pointer; background: #141c24; }
.drive .acts { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
@media (max-width: 700px) { .drive { grid-template-columns: 100px 1fr; } .drive img { width: 100px; } .drive .acts { grid-column: 1 / -1; justify-content: flex-start; } }
.daybar { position: sticky; top: 62px; background: var(--bg); padding: 8px 0 4px; color: var(--muted); font-weight: 600; z-index: 1; }
.empty { padding: 40px; text-align: center; color: var(--muted); border: 1px dashed var(--line); border-radius: var(--r); }
table { width: 100%; border-collapse: collapse; } th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); }
th { color: var(--muted); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .05em; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }

/* player */
.modal { position: fixed; inset: 0; background: #000c; z-index: 20; display: grid; place-items: center; padding: 16px; }
.modal[hidden] { display: none; }
.modal-card { width: min(1200px, 100%); max-height: 100%; overflow: auto; background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 14px; }
.modal-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.modal-head b { margin-right: 10px; }
video { width: 100%; max-height: 68vh; background: #000; border-radius: 10px; display: block; }
.pgrid { display: grid; grid-template-columns: 1fr; gap: 12px; }
.pgrid.has-tel { grid-template-columns: minmax(0, 2.2fr) minmax(260px, 1fr); }
@media (max-width: 900px) { .pgrid.has-tel { grid-template-columns: 1fr; } }
.tel { display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.tel[hidden] { display: none; }
.readouts { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.readouts div { background: var(--surface2); border-radius: 8px; padding: 8px 10px; }
.readouts .l { display: block; font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.readouts b { font-size: 20px; font-variant-numeric: tabular-nums; }
.map { position: relative; overflow: hidden; border-radius: 10px; background: #1b232b; flex: 1; min-height: 220px; }
.map img { position: absolute; width: 256px; height: 256px; user-select: none; -webkit-user-drag: none; filter: brightness(.8) saturate(.7); }
.map svg { position: absolute; left: 0; top: 0; overflow: visible; pointer-events: none; }
.map .attr { position: absolute; right: 4px; bottom: 2px; font-size: 10px; color: #ccc; background: #0009; padding: 0 4px; border-radius: 3px; }
#speedchart svg { cursor: pointer; }
.b-parked { background: #4a5966; color: #dde; }
.stats { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12px; color: var(--muted); margin-top: 3px; }
.stats b { color: var(--text); font-weight: 600; }
.bigmap { height: 420px; }
.pbar { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-top: 10px; flex-wrap: wrap; }
.pbtns { display: flex; gap: 6px; flex-wrap: wrap; }
.clock { font: 600 20px ui-monospace, monospace; }
.strip { display: flex; gap: 6px; overflow-x: auto; margin-top: 10px; padding-bottom: 4px; }
.strip button { flex: 0 0 auto; font-size: 12px; padding: 6px 10px; }
.strip button.on { border-color: var(--cyan); color: var(--cyan); }
.strip button.k { box-shadow: inset 0 -3px 0 var(--green); }
.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--surface2); border: 1px solid var(--line);
  padding: 10px 16px; border-radius: 10px; z-index: 30; box-shadow: 0 10px 30px #000a; }
