:root {
  --bg: #f3f6fb;
  --surface: #ffffff;
  --surface-2: #f7f9fc;
  --border: #e4eaf2;
  --text: #0f1b2d;
  --muted: #62728a;
  --brand: #1466c9;
  --brand-2: #0e8f9a;
  --brand-soft: #e8f1fc;
  --running: #16a34a;
  --idle: #f59e0b;
  --stopped: #ef4444;
  --offline: #94a3b8;
  --overspeed: #7c3aed;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(15, 27, 45, .04), 0 8px 24px -12px rgba(15, 27, 45, .14);
  --top: 60px;
  font-family: Inter, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--text);
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; background: var(--bg); }
body.booting .view { visibility: hidden; }
button { font: inherit; cursor: pointer; color: inherit; -webkit-tap-highlight-color: transparent; }
/* No focus ring on mouse/touch clicks; keep a clear one for keyboard users. */
button:focus, a:focus, [tabindex]:focus { outline: none; }
button:focus-visible, a:focus-visible, [tabindex]:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
input { font: inherit; color: inherit; }
[hidden] { display: none !important; }
.muted { color: var(--muted); }
svg { flex-shrink: 0; }

/* ================= TOP BAR ================= */
.topbar {
  position: relative; z-index: 1000; height: var(--top); display: flex; align-items: center; gap: 28px; padding: 0 20px;
  background: var(--surface); border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 17px; letter-spacing: -.01em; color: var(--text); text-decoration: none; }
.tabs { display: flex; gap: 4px; height: 100%; }
.tab {
  display: flex; align-items: center; gap: 8px; padding: 0 14px; color: var(--muted); text-decoration: none; font-weight: 600; font-size: 14px;
  border-bottom: 2.5px solid transparent; margin-bottom: -1px;
}
.tab svg { width: 18px; height: 18px; fill: currentColor; }
.tab:hover { color: var(--text); }
.tab.active { color: var(--brand); border-bottom-color: var(--brand); }
.top-right { margin-left: auto; display: flex; align-items: center; gap: 16px; }
.conn { display: flex; align-items: center; gap: 7px; font-size: 13px; color: var(--muted); padding: 6px 10px; border-radius: 99px; background: var(--surface-2); }
.conn .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--offline); }
.conn.ok .dot { background: var(--running); box-shadow: 0 0 0 3px rgba(22, 163, 74, .18); }
.user { position: relative; }
.user-btn { display: flex; align-items: center; gap: 8px; border: 0; background: none; padding: 4px; border-radius: 99px; }
.avatar-sm {
  width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; font-size: 13px; color: #fff;
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
}
.user-name { font-weight: 600; font-size: 14px; }
.user-menu {
  position: absolute; right: 0; top: calc(100% + 8px); width: 200px; background: var(--surface); border: 1px solid var(--border);
  border-radius: 12px; box-shadow: var(--shadow); overflow: hidden;
}
.um-head { padding: 12px 14px; border-bottom: 1px solid var(--border); }
.um-head b { display: block; font-size: 14px; }
.um-head small { color: var(--muted); text-transform: capitalize; }
.user-menu button { width: 100%; text-align: left; border: 0; background: none; padding: 11px 14px; color: #b42318; font-weight: 600; }
.user-menu button:hover { background: #fef2f2; }

.view { height: calc(100% - var(--top)); }

/* ================= DASHBOARD ================= */
.dashboard { overflow-y: auto; }
.dash-inner { max-width: 1400px; margin: 0 auto; padding: 28px 24px 48px; }
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.page-head h1 { margin: 0 0 4px; font-size: 26px; letter-spacing: -.02em; }
.page-head p { margin: 0; }
.clock { font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }

.kpis { display: grid; grid-template-columns: repeat(6, 1fr); gap: 14px; margin-bottom: 30px; }
.kpi {
  position: relative; overflow: hidden; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px 18px; box-shadow: var(--shadow); text-align: left; transition: transform .12s, box-shadow .12s;
}
button.kpi { cursor: pointer; user-select: none; }
button.kpi:hover { transform: translateY(-2px); box-shadow: 0 12px 28px -12px rgba(15, 27, 45, .25); }
button.kpi:active { transform: translateY(0) scale(.98); }
.kpi::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: var(--c, var(--brand)); }
.kpi .k-label { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 13px; font-weight: 600; }
.kpi .k-icon { width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center; background: color-mix(in srgb, var(--c, var(--brand)) 12%, transparent); color: var(--c, var(--brand)); }
.kpi .k-icon svg { width: 17px; height: 17px; fill: currentColor; }
.kpi .k-val { font-size: 30px; font-weight: 800; letter-spacing: -.02em; margin-top: 10px; font-variant-numeric: tabular-nums; }
.kpi .k-sub { font-size: 12px; color: var(--muted); margin-top: 2px; }

.section { margin-bottom: 28px; }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.section-head h2 { margin: 0; font-size: 18px; letter-spacing: -.01em; }
.section-tools input {
  width: 240px; padding: 9px 12px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface);
}
.count-badge { background: #fee2e2; color: #b42318; font-weight: 700; font-size: 12px; padding: 2px 9px; border-radius: 99px; }

.vendor-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 16px; }
.vcard {
  background: var(--surface); border: 1px solid var(--border); border-radius: 18px; padding: 20px; box-shadow: var(--shadow);
  display: flex; flex-direction: column; gap: 16px; transition: transform .15s, box-shadow .15s, border-color .15s;
}
.vcard { cursor: pointer; user-select: none; }
.vcard:hover { transform: translateY(-3px); box-shadow: 0 18px 36px -16px rgba(15, 27, 45, .3); border-color: #cddbee; }
.vcard:active { transform: translateY(-1px) scale(.99); }
.vcard:hover .vc-cta { background: var(--brand); color: #fff; border-color: var(--brand); }
.vc-head { display: flex; align-items: center; gap: 12px; }
.vc-avatar {
  width: 46px; height: 46px; border-radius: 13px; display: grid; place-items: center; color: #fff; font-weight: 800; font-size: 16px;
  background: linear-gradient(135deg, hsl(var(--h) 70% 48%), hsl(calc(var(--h) + 40) 70% 42%));
  box-shadow: 0 8px 18px -8px hsl(var(--h) 70% 40%);
}
.vc-name { flex: 1; min-width: 0; }
.vc-name h3 { margin: 0 0 2px; font-size: 16px; line-height: 1.25; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.vc-name small { color: var(--muted); font-size: 12.5px; }
.ring { width: 54px; height: 54px; position: relative; }
.ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.ring b { position: absolute; inset: 0; display: grid; place-items: center; font-size: 12.5px; font-weight: 800; }
.vc-total { display: flex; align-items: baseline; gap: 8px; }
.vc-total b { font-size: 30px; font-weight: 800; letter-spacing: -.02em; }
.vc-total span { color: var(--muted); font-size: 14px; }
.vc-total .vc-live { margin-left: auto; font-size: 12.5px; color: var(--running); font-weight: 600; }
.sbar { display: flex; height: 10px; border-radius: 99px; overflow: hidden; background: var(--surface-2); gap: 2px; }
.sbar span { display: block; height: 100%; transition: width .4s; }
.sbar .running { background: var(--running); } .sbar .idle { background: var(--idle); }
.sbar .stopped { background: var(--stopped); } .sbar .offline { background: var(--offline); }
.vc-legend { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.vc-legend div { background: var(--surface-2); border-radius: 10px; padding: 8px 10px; }
.vc-legend b { display: block; font-size: 16px; font-variant-numeric: tabular-nums; }
.vc-legend small { display: flex; align-items: center; gap: 5px; color: var(--muted); font-size: 11.5px; }
.vc-legend i { width: 7px; height: 7px; border-radius: 50%; background: var(--c); }
.vc-types { display: flex; flex-wrap: wrap; gap: 6px; }
.tchip { display: inline-flex; align-items: center; gap: 6px; padding: 4px 9px 4px 7px; border-radius: 8px; background: var(--brand-soft); color: var(--brand); font-size: 12px; font-weight: 600; }
.tchip .glyph { width: 24px; height: 18px; }
.vc-cta {
  margin-top: auto; display: flex; align-items: center; justify-content: center; gap: 8px; padding: 10px; border-radius: 11px;
  border: 1px solid var(--border); background: var(--surface); font-weight: 600; font-size: 14px; color: var(--brand);
}
.vc-cta:hover { background: var(--brand); color: #fff; border-color: var(--brand); }

.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.card-box { background: var(--surface); border: 1px solid var(--border); border-radius: 18px; padding: 20px; box-shadow: var(--shadow); margin: 0; }
.type-list { display: grid; gap: 10px; }
.trow { display: grid; grid-template-columns: 44px 1fr auto; align-items: center; gap: 12px; }
.trow .t-ic { width: 44px; height: 38px; border-radius: 10px; background: var(--brand-soft); color: var(--brand); display: grid; place-items: center; }
.trow .t-name { font-weight: 600; font-size: 14px; margin-bottom: 5px; }
.trow .t-bar { height: 7px; border-radius: 99px; background: var(--surface-2); overflow: hidden; display: flex; }
.trow .t-bar span { height: 100%; }
.trow .t-num { font-weight: 800; font-size: 16px; font-variant-numeric: tabular-nums; min-width: 34px; text-align: right; }
.alert-list { display: grid; gap: 8px; max-height: 340px; overflow-y: auto; }
.arow {
  display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 12px; border: 1px solid var(--border);
  background: var(--surface); text-align: left; width: 100%;
}
.arow:hover { background: var(--surface-2); }
.arow .a-ic { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; font-size: 15px; background: color-mix(in srgb, var(--c) 14%, transparent); color: var(--c); font-weight: 800; }
.arow .a-main { flex: 1; min-width: 0; }
.arow b { font-size: 14px; }
.arow small { display: block; color: var(--muted); font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.arow .a-tag { font-size: 11px; font-weight: 700; padding: 3px 8px; border-radius: 6px; color: #fff; background: var(--c); white-space: nowrap; }
.empty { color: var(--muted); font-size: 14px; padding: 18px; text-align: center; background: var(--surface-2); border-radius: 12px; }

/* ================= LIVE MAP ================= */
.mapview { display: flex; position: relative; }
.sidebar { width: 340px; flex-shrink: 0; background: var(--surface); border-right: 1px solid var(--border); display: flex; flex-direction: column; }
.sb-top { padding: 14px; border-bottom: 1px solid var(--border); display: grid; gap: 10px; }
.search { display: flex; align-items: center; gap: 8px; padding: 0 12px; height: 40px; border-radius: 10px; border: 1px solid var(--border); background: var(--surface-2); }
.search:focus-within { border-color: var(--brand); background: var(--surface); }
.search svg { width: 18px; height: 18px; fill: var(--muted); }
.search input { flex: 1; border: 0; outline: 0; background: none; min-width: 0; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 5px 10px; border-radius: 99px; border: 1px solid var(--border);
  background: var(--surface); font-size: 12.5px; font-weight: 600; color: var(--muted);
}
.chip i { width: 7px; height: 7px; border-radius: 50%; }
.chip b { color: var(--text); font-variant-numeric: tabular-nums; }
.chip.running i { background: var(--running); } .chip.idle i { background: var(--idle); }
.chip.stopped i { background: var(--stopped); } .chip.offline i { background: var(--offline); }
.chip.active { background: var(--text); border-color: var(--text); color: #fff; }
.chip.active b { color: #fff; }
.vendor-filter { display: flex; align-items: center; gap: 8px; margin: 10px 14px 0; padding: 8px 10px; border-radius: 10px; background: var(--brand-soft); color: var(--brand); font-size: 13px; font-weight: 600; }
.vendor-filter span { flex: 1; }
.vendor-filter button { border: 0; background: none; color: var(--brand); font-weight: 700; }
.vendors { overflow-y: auto; flex: 1; padding: 8px; }
.vgroup { border-radius: 12px; margin-bottom: 6px; border: 1px solid transparent; }
.vgroup.open { border-color: var(--border); background: var(--surface-2); }
.vg-head { width: 100%; display: flex; align-items: center; gap: 10px; padding: 10px; border: 0; background: none; text-align: left; border-radius: 12px; }
.vg-head:hover { background: var(--surface-2); }
.vg-av { width: 32px; height: 32px; border-radius: 9px; display: grid; place-items: center; color: #fff; font-weight: 800; font-size: 12px; background: linear-gradient(135deg, hsl(var(--h) 70% 48%), hsl(calc(var(--h) + 40) 70% 42%)); }
.vg-name { flex: 1; min-width: 0; }
.vg-name b { display: block; font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.vg-name .mini-bar { display: flex; height: 4px; border-radius: 99px; overflow: hidden; margin-top: 5px; background: var(--border); }
.vg-name .mini-bar span { height: 100%; }
.vg-count { font-size: 12px; color: var(--muted); font-weight: 600; }
.chev { color: var(--muted); transition: transform .15s; font-size: 11px; }
.vgroup.open .chev { transform: rotate(90deg); }
.vlist { display: none; padding: 0 6px 6px; }
.vgroup.open .vlist { display: block; }
.vrow { width: 100%; display: flex; align-items: center; gap: 10px; padding: 7px 8px; border: 0; background: none; text-align: left; font-size: 13px; border-radius: 9px; }
.vrow:hover { background: var(--surface); }
.vrow.selected { background: var(--surface); box-shadow: inset 3px 0 0 var(--brand); }
.vr-ic { width: 34px; height: 28px; border-radius: 8px; display: grid; place-items: center; color: var(--c); background: color-mix(in srgb, var(--c) 12%, transparent); }
.vr-main { flex: 1; min-width: 0; }
.vr-main b { display: block; font-size: 13px; }
.vr-main small { color: var(--muted); font-size: 11.5px; }
.vr-spd { font-variant-numeric: tabular-nums; font-size: 12px; font-weight: 600; color: var(--muted); }
.vr-spd.over { color: var(--overspeed); }

/* Map on top, playback player docked underneath (never covering the map). */
.map-wrap { flex: 1; position: relative; min-width: 0; display: flex; flex-direction: column; }
#map { position: relative; flex: 1; min-height: 0; background: #e8edf3; }
.sidebar-toggle { display: none; position: absolute; top: 12px; left: 12px; z-index: 500; width: 42px; height: 42px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); font-size: 18px; box-shadow: var(--shadow); }

/* markers */
.vmarker { background: none; border: 0; }
.vm { position: relative; width: 40px; height: 40px; }
.vm-body {
  position: absolute; inset: 4px; border-radius: 50%; background: #fff; border: 3px solid var(--c); color: var(--c);
  display: grid; place-items: center; box-shadow: 0 3px 8px rgba(15, 27, 45, .3);
}
.vm-dir { position: absolute; inset: 0; transition: transform .6s linear; }
.vm-dir span { position: absolute; left: 50%; top: -3px; margin-left: -5px; width: 0; height: 0; border-left: 5px solid transparent; border-right: 5px solid transparent; border-bottom: 8px solid var(--c); }
.vm-over .vm-body::after { content: ""; position: absolute; inset: -8px; border-radius: 50%; border: 2.5px solid var(--overspeed); animation: pulse 1.2s infinite; }
.vm-sel .vm-body { box-shadow: 0 0 0 4px rgba(20, 102, 201, .35), 0 3px 8px rgba(15, 27, 45, .3); }
@keyframes pulse { from { opacity: 1; transform: scale(.85); } to { opacity: 0; transform: scale(1.35); } }

/* tooltips */
.leaflet-tooltip.vtip { padding: 0; border-radius: 12px; border: 1px solid var(--border); box-shadow: 0 12px 32px -8px rgba(15, 27, 45, .3); font-family: inherit; }
.tt { min-width: 250px; font-size: 12.5px; }
.tt-head { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-bottom: 1px solid var(--border); }
.tt-ic { width: 38px; height: 32px; border-radius: 8px; display: grid; place-items: center; color: var(--c); background: color-mix(in srgb, var(--c) 12%, transparent); }
.tt-head b { display: block; font-size: 14px; }
.tt-head small { color: var(--muted); }
.tt-grid { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; padding: 10px 12px; }
.tt-grid span:nth-child(odd) { color: var(--muted); }
.tt-grid span:nth-child(even) { font-weight: 600; text-align: right; }
.tt-alerts { display: flex; flex-wrap: wrap; gap: 4px; padding: 0 12px 10px; }
.badge { display: inline-block; font-size: 10.5px; font-weight: 700; padding: 2px 7px; border-radius: 5px; color: #fff; text-transform: uppercase; letter-spacing: .02em; }
.badge.running { background: var(--running); } .badge.idle { background: var(--idle); }
.badge.stopped { background: var(--stopped); } .badge.offline { background: var(--offline); }
.badge.overspeed { background: var(--overspeed); } .badge.alert { background: #b91c1c; }

/* legend */
.legend { position: absolute; left: 12px; bottom: 24px; z-index: 450; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow); font-size: 12px; max-width: 230px; }
.legend-toggle { border: 0; background: none; padding: 8px 12px; font-weight: 700; font-size: 12px; width: 100%; text-align: left; }
.legend-body { padding: 0 12px 10px; display: grid; gap: 6px; }
.legend.collapsed .legend-body { display: none; }
.lg-row { display: flex; align-items: center; gap: 8px; }
.lg-row .glyph { color: var(--text); }
.lg-dot { width: 10px; height: 10px; border-radius: 50%; }
.lg-sep { height: 1px; background: var(--border); margin: 2px 0; }
.map-wrap.playing .legend { display: none; }

/* ================= PLAYER ================= */
.player {
  position: relative; z-index: 800; flex-shrink: 0; background: var(--surface);
  border-top: 1px solid var(--border); box-shadow: 0 -10px 24px -18px rgba(15, 27, 45, .45); padding: 12px 18px 10px;
}
.pl-top { display: flex; align-items: center; gap: 18px; }
.pl-sub { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 10px; flex-wrap: wrap; }
.pl-legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 11.5px; color: var(--muted); font-weight: 600; }
.pl-legend span { display: inline-flex; align-items: center; gap: 5px; }
.pl-legend i { display: inline-block; width: 14px; height: 8px; border-radius: 2px; }
.pl-legend .k-speed { height: 3px; background: var(--brand); }
.pl-legend .k-over { height: 3px; background: var(--overspeed); }
.pl-legend .k-idle { background: rgba(245, 158, 11, .35); }
.pl-legend .k-stop { background: rgba(239, 68, 68, .28); }
.pl-legend .k-limit { height: 0; border-top: 2px dashed var(--overspeed); }
.pl-controls { display: flex; align-items: center; gap: 6px; }
.pl-btn { width: 36px; height: 36px; border-radius: 10px; border: 1px solid var(--border); background: var(--surface); display: grid; place-items: center; }
.pl-btn svg { width: 18px; height: 18px; fill: var(--text); }
.pl-btn.play { width: 44px; height: 44px; border-radius: 50%; border: 0; background: linear-gradient(135deg, var(--brand), var(--brand-2)); box-shadow: 0 8px 18px -6px rgba(20, 102, 201, .6); }
.pl-btn.play svg { fill: #fff; width: 22px; height: 22px; }
.pl-btn.play .i-pause { display: none; }
.player.is-playing .pl-btn.play .i-play { display: none; }
.player.is-playing .pl-btn.play .i-pause { display: block; }
.pl-speed { display: flex; background: var(--surface-2); border-radius: 10px; padding: 3px; border: 1px solid var(--border); }
.pl-speed button { border: 0; background: none; padding: 5px 9px; border-radius: 7px; font-size: 12px; font-weight: 700; color: var(--muted); }
.pl-speed button.on { background: var(--surface); color: var(--brand); box-shadow: 0 1px 3px rgba(15, 27, 45, .15); }
.pl-readout { display: flex; align-items: center; gap: 14px; min-width: 0; }
.pl-time { font-size: 19px; font-weight: 800; font-variant-numeric: tabular-nums; letter-spacing: -.01em; white-space: nowrap; }
.pl-now { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); white-space: nowrap; }
.pl-now b { color: var(--text); font-variant-numeric: tabular-nums; }
.pl-right { margin-left: auto; display: flex; align-items: center; gap: 12px; }
.pl-follow {
  display: flex; align-items: center; gap: 6px; font-size: 12.5px; font-weight: 600; color: var(--muted); cursor: pointer;
  white-space: nowrap; padding: 5px 9px; border-radius: 99px; border: 1px solid var(--border); background: var(--surface-2);
}
.pl-follow input { margin: 0; accent-color: var(--brand); }
.pl-right { gap: 8px; }
.pl-close { width: 32px; height: 32px; border-radius: 50%; border: 0; background: var(--surface-2); color: var(--muted); }
.pl-close:hover { background: #fee2e2; color: #b42318; }
.pl-chart { position: relative; height: 78px; margin-top: 8px; cursor: pointer; touch-action: none; }
.pl-chart canvas { width: 100%; height: 100%; display: block; }
.pl-hover { position: absolute; top: -6px; transform: translate(-50%, -100%); background: var(--text); color: #fff; font-size: 11.5px; padding: 4px 8px; border-radius: 6px; white-space: nowrap; pointer-events: none; }
.pl-axis { display: flex; justify-content: space-between; font-size: 11px; color: var(--muted); margin-top: 3px; font-variant-numeric: tabular-nums; }

/* ================= PANEL ================= */
.panel { width: 380px; flex-shrink: 0; background: var(--surface); border-left: 1px solid var(--border); display: flex; flex-direction: column; }
.panel-head { display: flex; align-items: center; gap: 12px; padding: 14px 16px; border-bottom: 1px solid var(--border); }
.ph-icon { width: 52px; height: 44px; border-radius: 12px; display: grid; place-items: center; color: var(--c); background: color-mix(in srgb, var(--c) 12%, transparent); }
.ph-text { flex: 1; min-width: 0; }
.panel-title { font-size: 18px; font-weight: 800; display: flex; gap: 8px; align-items: center; letter-spacing: -.01em; }
.panel-sub { color: var(--muted); font-size: 13px; margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.close { border: 0; background: var(--surface-2); width: 32px; height: 32px; border-radius: 50%; color: var(--muted); }
.panel-body { padding: 16px; overflow-y: auto; flex: 1; }
.panel h3 { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 22px 0 10px; }

.pb-card { border-radius: 14px; padding: 14px; background: linear-gradient(160deg, #eef5fe, #eefaf8); border: 1px solid #d6e6f7; display: grid; gap: 12px; }
.pb-card-head { display: flex; align-items: center; gap: 8px; font-size: 15px; }
.pb-card-head svg { width: 20px; height: 20px; fill: var(--brand); }
.presets { display: flex; flex-wrap: wrap; gap: 6px; }
.presets button { padding: 6px 11px; border-radius: 99px; border: 1px solid #cfdcee; background: var(--surface); font-size: 12.5px; font-weight: 600; color: var(--muted); }
.presets button.on { background: var(--brand); border-color: var(--brand); color: #fff; }
.custom-range { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.custom-range label { display: grid; gap: 4px; font-size: 12px; font-weight: 600; color: var(--muted); }
.custom-range input { padding: 7px 8px; border: 1px solid #cfdcee; border-radius: 9px; font-size: 12.5px; background: var(--surface); min-width: 0; }
.btn-primary {
  display: flex; align-items: center; justify-content: center; gap: 8px; height: 42px; border: 0; border-radius: 11px; color: #fff; font-weight: 700;
  background: linear-gradient(135deg, var(--brand), var(--brand-2)); box-shadow: 0 8px 18px -8px rgba(20, 102, 201, .6);
}
.btn-primary svg { width: 18px; height: 18px; fill: #fff; }
.btn-primary:disabled { opacity: .7; cursor: wait; }
.pb-msg { font-size: 13px; color: var(--muted); }
.pb-msg:empty { display: none; }

#pb-result { margin-top: 14px; }
.stat-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.stat-grid div { background: var(--surface-2); border: 1px solid var(--border); border-radius: 11px; padding: 9px 10px; }
.stat-grid b { display: block; font-size: 15px; font-variant-numeric: tabular-nums; }
.stat-grid small { color: var(--muted); font-size: 11px; }
.events { position: relative; display: grid; gap: 2px; }
.ev { display: flex; gap: 10px; align-items: flex-start; width: 100%; border: 0; background: none; text-align: left; padding: 8px; border-radius: 10px; }
.ev:hover { background: var(--surface-2); }
.ev-dot { width: 28px; height: 28px; border-radius: 50%; flex-shrink: 0; display: grid; place-items: center; font-size: 12px; font-weight: 800; color: #fff; background: var(--c); }
.ev-main b { font-size: 13px; display: block; }
.ev-main small { color: var(--muted); font-size: 12px; }
.ev-time { margin-left: auto; font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }

.kv { display: grid; grid-template-columns: 115px 1fr; row-gap: 8px; font-size: 13px; }
.kv span:nth-child(odd) { color: var(--muted); }
.kv span:nth-child(even) { font-weight: 600; }

/* playback map pins */
.pin-ev { background: none; border: 0; }
.pin-ev div {
  width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; color: #fff; font-size: 11px; font-weight: 800;
  background: var(--c); border: 2.5px solid #fff; box-shadow: 0 2px 6px rgba(15, 27, 45, .35);
}

/* ================= MOBILE ================= */
@media (max-width: 1100px) {
  .kpis { grid-template-columns: repeat(3, 1fr); }
  .two-col { grid-template-columns: 1fr; }
}
@media (max-width: 900px) {
  .brand span, .user-name, #conn-text { display: none; }
  .topbar { gap: 12px; padding: 0 12px; }
  .tab { padding: 0 10px; }
  .kpis { grid-template-columns: repeat(2, 1fr); }
  .section-tools input { width: 160px; }
  .sidebar { position: absolute; z-index: 900; height: 100%; transform: translateX(-100%); transition: transform .2s; box-shadow: 8px 0 24px rgba(0, 0, 0, .12); }
  .sidebar.open { transform: none; }
  .sidebar-toggle { display: block; }
  .panel { position: absolute; z-index: 950; right: 0; bottom: 0; width: 100%; height: 62%; border-top: 1px solid var(--border); border-radius: 18px 18px 0 0; box-shadow: 0 -12px 32px rgba(0, 0, 0, .15); }
  .player { padding: 10px 12px 8px; }
  .pl-top { flex-wrap: wrap; gap: 10px; }
  .pl-readout { order: 3; width: 100%; }
  .pl-legend { display: none; }
  .legend { display: none; }
}
