/* Luminescent B&W design system — tokens copied from gpsdozor-fleet/src/index.css */
:root, :root[data-theme="dark"] {
  --surface: #050505;
  --surface-card: rgba(10, 10, 10, 0.5);
  --surface-hover: rgba(255, 255, 255, 0.03);
  --surface-raised: rgba(255, 255, 255, 0.05);
  --border: rgba(255, 255, 255, 0.07);
  --border-strong: rgba(255, 255, 255, 0.14);
  --text-primary: rgba(255, 255, 255, 0.9);
  --text-secondary: rgba(255, 255, 255, 0.7);
  --text-dim: rgba(255, 255, 255, 0.42);
  --text-muted: rgba(255, 255, 255, 0.2);
  --glow-shadow: rgba(255, 255, 255, 0.04);
  --glow-strong: rgba(255, 255, 255, 0.12);
  --sidebar-bg: #080808;
  --void-300: #222;
  --status-live: #c8ffc8;
  --status-moving: #fff5cc;
  --status-offline: #888888;
  --status-danger: #ffaaaa;
  --compare-b: #88b4e8;
  --compare-c: #e8b488;
  --header-bg: rgba(8, 8, 8, 0.86);
  color-scheme: dark;
}
:root[data-theme="light"] {
  --surface: #ffffff;
  --surface-card: rgba(255, 255, 255, 0.9);
  --surface-hover: rgba(0, 0, 0, 0.04);
  --surface-raised: rgba(0, 0, 0, 0.07);
  --border: rgba(0, 0, 0, 0.13);
  --border-strong: rgba(0, 0, 0, 0.25);
  --text-primary: rgba(0, 0, 0, 0.9);
  --text-secondary: rgba(0, 0, 0, 0.7);
  --text-dim: rgba(0, 0, 0, 0.55);
  --text-muted: rgba(0, 0, 0, 0.32);
  --glow-shadow: rgba(0, 0, 0, 0.06);
  --glow-strong: rgba(0, 0, 0, 0.1);
  --sidebar-bg: #f3f3f3;
  --void-300: #ddd;
  --status-live: #0a8a0a;
  --status-moving: #9a7400;
  --status-offline: #777777;
  --status-danger: #c42020;
  --compare-b: #2d68b0;
  --compare-c: #b0602d;
  --header-bg: rgba(255, 255, 255, 0.92);
  color-scheme: light;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { background: var(--surface); }
body {
  font-family: 'Manrope', system-ui, sans-serif;
  color: var(--text-primary);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
  padding-top: 32px;
  font-size: 14px;
}
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; }
a { color: inherit; }
:focus-visible { outline: 2px solid var(--status-live); outline-offset: 2px; border-radius: 6px; }
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-thumb { background: var(--void-300); border-radius: 10px; }
[v-cloak] { display: none; }

.font-display { font-family: 'Syne', sans-serif; }
.mono { font-family: 'JetBrains Mono', monospace; }
.dim { color: var(--text-dim); }
.muted { color: var(--text-muted); }
.sec { color: var(--text-secondary); }
.lumi { color: var(--text-primary); text-shadow: 0 0 20px var(--glow-shadow); }
.upper { text-transform: uppercase; letter-spacing: 0.1em; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row { display: flex; align-items: center; }
.gap-1 { gap: 4px; } .gap-2 { gap: 8px; } .gap-3 { gap: 12px; }
.grow { flex: 1; min-width: 0; }
.ml-auto { margin-left: auto; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ─── Demo bar (portfolio chrome) ─── */
.demo-bar {
  position: fixed; inset: 0 0 auto 0; height: 32px; z-index: 3000;
  display: flex; align-items: center; gap: 14px; padding: 0 14px;
  background: #16181c; color: #cfd3da; border-bottom: 1px solid #2a2e35;
  font: 500 12.5px/1 system-ui, -apple-system, 'Segoe UI', sans-serif;
}
.demo-bar a { color: #e8ebf0; text-decoration: none; }
.demo-bar a:hover { text-decoration: underline; }
.demo-bar .db-title { font-weight: 600; color: #fff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.demo-bar .db-note { color: #8e95a1; white-space: nowrap; }
.demo-bar .db-actions { margin-left: auto; display: flex; gap: 6px; }
.demo-bar button {
  white-space: nowrap;
  height: 22px; padding: 0 10px; border-radius: 5px; border: 1px solid #3a3f48;
  background: #23272e; color: #e8ebf0; font-size: 12px;
}
.demo-bar button:hover { background: #2d323a; }

/* ─── Header ─── */
.app-header {
  position: sticky; top: 32px; z-index: 1500; height: 56px;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 0 20px; background: var(--header-bg); backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border-strong);
}
.logo { display: flex; align-items: center; gap: 10px; cursor: pointer; }
.logo-name { font-family: 'Syne', sans-serif; font-weight: 700; font-size: 19px; letter-spacing: -0.02em; }
.group-tag { font: 12px 'JetBrains Mono', monospace; color: var(--text-dim); background: var(--surface-raised); padding: 2px 7px; border-radius: 6px; }
.nav { display: flex; gap: 2px; }
.nav-btn {
  display: flex; align-items: center; gap: 6px; padding: 7px 14px; border-radius: 9px;
  font-size: 14.5px; font-weight: 500; color: var(--text-dim); transition: all .2s;
}
.nav-btn:hover { color: var(--text-secondary); background: var(--surface-hover); }
.nav-btn.active { color: var(--text-primary); background: var(--surface-raised); box-shadow: 0 0 20px var(--glow-shadow); }
.nav-btn .ico { opacity: .6; font-size: 13px; }
.header-right { display: flex; align-items: center; gap: 8px; }
.live-pill { display: flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--text-dim); white-space: nowrap; }
.live-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--status-live); box-shadow: 0 0 8px var(--status-live); animation: pulse 2s ease-in-out infinite; }
.live-dot.paused { background: var(--status-offline); box-shadow: none; animation: none; }
@keyframes pulse { 50% { opacity: .35; } }

/* ─── Controls ─── */
.btn {
  display: inline-flex; align-items: center; gap: 6px; padding: 7px 14px; border-radius: 9px;
  font-size: 13.5px; font-weight: 500; background: var(--surface-raised); border: 1px solid var(--border);
  color: var(--text-secondary); box-shadow: 0 0 12px var(--glow-shadow); transition: all .2s; white-space: nowrap;
}
.btn:hover { background: var(--surface-hover); border-color: var(--border-strong); color: var(--text-primary); }
.btn.accent { background: var(--glow-strong); border-color: var(--border-strong); color: var(--text-primary); }
.btn.danger { background: rgba(255, 100, 100, .08); border-color: rgba(255, 100, 100, .2); color: var(--status-danger); }
.btn.sm { padding: 4px 10px; font-size: 12.5px; }
.icon-btn {
  width: 34px; height: 34px; display: inline-flex; align-items: center; justify-content: center; border-radius: 9px;
  background: var(--surface-hover); border: 1px solid var(--border); color: var(--text-dim); font-size: 15px; transition: all .2s;
}
.icon-btn:hover { background: var(--surface-raised); color: var(--text-primary); }
.help-btn { font-size: 10.5px; padding: 1px 6px; border-radius: 5px; background: var(--surface-hover); color: var(--text-dim); }
.help-btn:hover { color: var(--text-primary); }
.input, .select {
  border-radius: 9px; padding: 7px 12px; background: var(--surface-hover); border: 1px solid var(--border);
  color: var(--text-primary); outline: none; font-size: 14px; transition: all .2s;
}
.select { color: var(--text-secondary); cursor: pointer; }
.select option { background: var(--surface); color: var(--text-primary); }
.input::placeholder { color: var(--text-muted); }
.input:focus, .select:focus { border-color: var(--border-strong); box-shadow: 0 0 18px var(--glow-shadow); }

.card {
  background: var(--surface-card); border: 1px solid var(--border); border-radius: 14px;
  box-shadow: 0 0 20px var(--glow-shadow); transition: border-color .3s;
}
:root[data-theme="light"] .card { box-shadow: 0 1px 4px rgba(0, 0, 0, .07); }
.card:hover { border-color: var(--border-strong); }
.stat { font-family: 'Syne', sans-serif; font-weight: 700; letter-spacing: -0.02em; text-shadow: 0 0 25px var(--glow-shadow); }
.label { font-size: 11.5px; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.12em; font-weight: 600; }
.badge {
  display: inline-flex; align-items: center; gap: 6px; padding: 3px 11px; border-radius: 999px;
  font-size: 12.5px; font-weight: 600; white-space: nowrap;
}
.badge .dot { width: 7px; height: 7px; border-radius: 50%; }
.chip { font-size: 10.5px; padding: 2px 6px; border-radius: 5px; white-space: nowrap; }
.bar { height: 6px; border-radius: 99px; overflow: hidden; background: var(--surface-raised); }
.bar > div { height: 100%; border-radius: 99px; opacity: .65; transition: width .4s; }
.tabs { display: flex; border-bottom: 1px solid var(--border); }
.tab {
  padding: 10px 14px; font-size: 13.5px; font-weight: 500; color: var(--text-dim);
  border-bottom: 2px solid transparent; margin-bottom: -1px; transition: color .2s;
}
.tab:hover { color: var(--text-secondary); }
.tab.active { color: var(--text-primary); border-color: var(--text-dim); }
.count-pill { margin-left: 5px; font-size: 11px; padding: 1px 6px; border-radius: 99px; background: var(--surface-raised); }
.count-pill.alert { background: rgba(255, 100, 100, .12); color: var(--status-danger); }

/* ─── Dashboard ─── */
.dash { display: flex; height: calc(100vh - 88px); }
.sidebar {
  width: 400px; flex-shrink: 0; display: flex; flex-direction: column;
  background: var(--sidebar-bg); border-right: 1px solid var(--border); min-height: 0;
}
.sb-head { padding: 14px 18px; border-bottom: 1px solid var(--border); }
.sb-stats { display: flex; gap: 6px; margin-top: 10px; }
.sb-stat { flex: 1; text-align: center; border-radius: 9px; padding: 7px 0; background: var(--surface-hover); }
.sb-stat .v { font-family: 'Syne', sans-serif; font-weight: 700; font-size: 19px; line-height: 1; }
.sb-stat .l { font-size: 10px; color: var(--text-dim); letter-spacing: .1em; margin-top: 4px; }
.sb-body { flex: 1; overflow-y: auto; min-height: 0; }
.sb-foot { padding: 7px 14px; border-top: 1px solid var(--border); font-size: 11.5px; color: var(--text-dim); display: flex; align-items: center; gap: 8px; }
.sb-tabs .tab { flex: 1; font-size: 13px; }
.section { padding: 12px 18px; border-bottom: 1px solid var(--border); }
.section-title { font-size: 11.5px; color: var(--text-dim); text-transform: uppercase; letter-spacing: .1em; font-weight: 600; margin-bottom: 8px; }
.top-item, .veh-item, .alert-item, .rank-item {
  display: flex; align-items: center; gap: 11px; width: 100%; text-align: left; transition: background .15s;
}
.top-item { padding: 7px 9px; border-radius: 9px; }
.top-item:hover, .veh-item:hover, .alert-item:hover, .rank-item:hover { background: var(--surface-raised); }
.veh-item { padding: 11px 18px; border-bottom: 1px solid var(--border); }
.veh-item.focus { background: var(--surface-raised); }
.status-dot { width: 12px; height: 12px; border-radius: 50%; flex-shrink: 0; }
.veh-name { font-size: 15.5px; font-weight: 600; }
.alert-item { padding: 11px 16px; border-bottom: 1px solid var(--border); align-items: flex-start; }
.rank-item { padding: 8px 11px; border-radius: 9px; background: var(--surface-hover); border: 1px solid var(--border); margin-bottom: 6px; }
.map-wrap { flex: 1; position: relative; min-width: 0; }
.map { width: 100%; height: 100%; }
.map-overlay { position: absolute; z-index: 1000; border-radius: 12px; padding: 9px 14px; background: var(--header-bg); border: 1px solid var(--border-strong); backdrop-filter: blur(16px); }
.feed { max-height: 168px; overflow: hidden; }
.feed-item { display: flex; gap: 8px; font-size: 12px; padding: 3px 0; color: var(--text-secondary); }
.feed-item time { color: var(--text-dim); font-family: 'JetBrains Mono', monospace; font-size: 11px; flex-shrink: 0; padding-top: 1px; }
.fade-enter-active { transition: all .4s ease; }
.fade-enter-from { opacity: 0; transform: translateY(-4px); }

/* ─── Pages ─── */
.page { padding: 20px; max-width: 100%; }
.page-head { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; flex-wrap: wrap; }
.grid-5 { display: grid; grid-template-columns: repeat(5, 1fr); gap: 12px; }
.grid-6 { display: grid; grid-template-columns: repeat(6, 1fr); gap: 10px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.kpi { padding: 14px 16px; }
.kpi .stat { font-size: 24px; }
.kpi .label { margin-top: 4px; }

.table-wrap { overflow-x: auto; }
table.fleet { width: 100%; border-collapse: collapse; min-width: 1080px; }
table.fleet th {
  text-align: left; padding: 10px 13px; font-size: 11.5px; font-weight: 600; color: var(--text-dim);
  text-transform: uppercase; letter-spacing: .1em; border-bottom: 1px solid var(--border); white-space: nowrap;
}
table.fleet th button { text-transform: inherit; letter-spacing: inherit; font-weight: inherit; color: inherit; }
table.fleet th button:hover { color: var(--text-primary); }
table.fleet td { padding: 11px 13px; border-bottom: 1px solid var(--border); font-size: 14px; }
table.fleet tbody tr { cursor: pointer; transition: background .2s; }
table.fleet tbody tr:hover { background: var(--surface-hover); }
table.fleet tbody tr:hover .veh-name { color: var(--text-primary); }

.method { padding: 18px; margin-bottom: 16px; }
.method p { font-size: 13px; color: var(--text-dim); margin-bottom: 8px; line-height: 1.5; }
.method .formula { font: 12px 'JetBrains Mono', monospace; background: var(--surface-raised); color: var(--text-secondary); padding: 8px 12px; border-radius: 7px; margin-bottom: 10px; }
.method .factor { display: flex; gap: 10px; font-size: 13px; margin-bottom: 6px; line-height: 1.45; }
.method .factor b { color: var(--text-primary); }

.detail-split { display: flex; gap: 16px; height: calc(100vh - 210px); min-height: 520px; }
.detail-split > div { width: 50%; display: flex; flex-direction: column; min-height: 0; gap: 8px; }
.trip-list { flex: 1; overflow-y: auto; min-height: 0; }
.trip { display: block; width: 100%; text-align: left; padding: 11px 16px; border-bottom: 1px solid var(--border); transition: background .15s; }
.trip:hover { background: var(--surface-hover); }
.trip.selected { background: var(--surface-raised); box-shadow: inset 2px 0 0 var(--status-live); }
.trip-meta { display: flex; gap: 10px; flex-wrap: wrap; font-size: 12.5px; color: var(--text-dim); margin-top: 3px; }
.mini-stats { display: grid; grid-template-columns: repeat(5, 1fr); gap: 7px; }
.mini-stats > div { padding: 8px; border-radius: 9px; text-align: center; background: var(--surface-hover); border: 1px solid var(--border); }
.mini-stats .stat { font-size: 17px; }
.mini-stats .l { font-size: 9.5px; color: var(--text-dim); letter-spacing: .12em; }
.map-card { flex: 1; overflow: hidden; display: flex; flex-direction: column; min-height: 260px; }
.map-slot { flex: 1; min-height: 0; position: relative; }
.map-slot > .map { position: absolute; inset: 0; height: auto; }
.map-card-head { padding: 8px 14px; display: flex; align-items: center; justify-content: space-between; gap: 8px; border-bottom: 1px solid var(--border); }
.dist-bar { display: flex; gap: 2px; height: 16px; border-radius: 4px; overflow: hidden; background: var(--surface-raised); }
.dist-bar > div { display: flex; align-items: center; justify-content: center; font: 9px 'JetBrains Mono', monospace; color: var(--text-primary); }

.cmp-grid { display: grid; gap: 14px; margin-bottom: 18px; }
table.cmp { width: 100%; border-collapse: collapse; }
table.cmp th, table.cmp td { padding: 10px 14px; border-bottom: 1px solid var(--border); }
table.cmp th { font-size: 11.5px; text-transform: uppercase; letter-spacing: .1em; }
table.cmp td { font: 14px 'JetBrains Mono', monospace; text-align: center; color: var(--text-secondary); }
table.cmp td:first-child { font-family: 'Manrope', sans-serif; font-size: 13px; text-align: left; color: var(--text-dim); }

/* ─── Leaflet ─── */
/* Offline Natural Earth basemap (SVG paths, coloured per theme) */
:root, :root[data-theme="dark"] {
  --map-sea: #0a0b0d; --map-land: #17181b; --map-border: rgba(255, 255, 255, 0.13);
  --map-water: #0a0b0d; --map-river: rgba(150, 170, 200, 0.22); --map-label: rgba(255, 255, 255, 0.5); --map-label-halo: #050505;
}
:root[data-theme="light"] {
  --map-sea: #d5dde3; --map-land: #f4f4f1; --map-border: rgba(0, 0, 0, 0.2);
  --map-water: #d5dde3; --map-river: rgba(90, 130, 170, 0.45); --map-label: rgba(0, 0, 0, 0.58); --map-label-halo: #ffffff;
}
.bm-land { fill: var(--map-land); fill-opacity: 1; stroke: var(--map-border); stroke-width: 0.8; }
.bm-lake { fill: var(--map-water); fill-opacity: 1; stroke: none; }
.bm-river { fill: none; stroke: var(--map-river); stroke-width: 1; }
.city-label { pointer-events: none; }
.city-label span {
  position: absolute; left: 6px; top: -8px; white-space: nowrap; font: 500 11px 'Manrope', sans-serif;
  color: var(--map-label); letter-spacing: .02em;
  text-shadow: 0 0 3px var(--map-label-halo), 0 0 3px var(--map-label-halo), 0 0 2px var(--map-label-halo);
}
.city-label span::before { content: ''; position: absolute; left: -6px; top: 6px; width: 3px; height: 3px; border-radius: 50%; background: var(--map-label); }
.city-label.major span { font-weight: 700; font-size: 11.5px; }
.map:not(.show-minor-cities) .city-label:not(.major), .map.hide-cities .city-label { display: none; }
.leaflet-container { background: var(--map-sea) !important; font-family: 'Manrope', sans-serif !important; }
.leaflet-control-zoom a { background: var(--surface-card) !important; color: var(--text-secondary) !important; border-color: var(--border) !important; backdrop-filter: blur(8px); }
.leaflet-control-attribution { background: var(--surface-card) !important; color: var(--text-dim) !important; font-size: 10.5px !important; }
.leaflet-control-attribution a { color: var(--text-secondary) !important; }
.vehicle-tooltip {
  background: var(--header-bg) !important; color: var(--text-primary) !important; backdrop-filter: blur(16px);
  border-radius: 10px !important; border: 1px solid var(--border-strong) !important; padding: 6px 10px !important;
  box-shadow: 0 6px 30px rgba(0, 0, 0, .25) !important;
}
.vehicle-tooltip::before { display: none; }
.veh-marker { transition: transform .3s; }

/* ─── Tour ─── */
.tour {
  position: fixed; z-index: 3100; right: 16px; top: 44px; width: min(360px, calc(100vw - 32px));
  background: #16181c; color: #e8ebf0; border: 1px solid #3a3f48; border-radius: 12px; padding: 16px;
  box-shadow: 0 16px 50px rgba(0, 0, 0, .5); font: 13.5px/1.5 system-ui, -apple-system, sans-serif;
}
.tour h2 { font-size: 14px; margin-bottom: 6px; }
.tour .steps { color: #8e95a1; font-size: 12px; margin-bottom: 4px; }
.tour .row { margin-top: 12px; justify-content: flex-end; gap: 6px; }
.tour button { height: 26px; padding: 0 12px; border-radius: 6px; border: 1px solid #3a3f48; background: #23272e; color: #e8ebf0; }
.tour button.primary { background: #e8ebf0; color: #16181c; border-color: #e8ebf0; }

/* ─── Responsive ─── */
@media (max-width: 1100px) {
  .grid-6 { grid-template-columns: repeat(3, 1fr); }
  .grid-3 { grid-template-columns: 1fr; }
  .sidebar { width: 340px; }
}
@media (max-width: 820px) {
  .app-header { padding: 0 10px; gap: 6px; }
  .group-tag, .units, .live-pill { display: none; }
  .icon-btn { width: 30px; height: 30px; font-size: 13px; }
  .header-right { gap: 4px; }
  .logo { gap: 6px; }
  .page-head > .grow { flex-basis: calc(100% - 100px); }
  .map-slot { min-height: 320px; }
  .demo-bar a { white-space: nowrap; }
  .nav-btn { padding: 6px 7px; font-size: 13px; }
  .nav-btn .ico { display: none; }
  .logo-name { font-size: 16px; }
  .dash { flex-direction: column-reverse; height: auto; }
  .sidebar { width: 100%; border-right: 0; border-top: 1px solid var(--border); }
  .sb-body { max-height: none; overflow: visible; }
  .map-wrap { height: 52vh; flex: none; }
  .grid-5 { grid-template-columns: repeat(2, 1fr); }
  .grid-6 { grid-template-columns: repeat(2, 1fr); }
  .detail-split { flex-direction: column; height: auto; }
  .detail-split > div { width: 100%; }
  .trip-list { max-height: 460px; }
  .map-card { min-height: 340px; }
  .page { padding: 12px; }
  .cmp-grid { grid-template-columns: 1fr !important; }
  .table-wrap.cmp-wrap table { min-width: 520px; }
  .demo-bar .db-note { display: none; }
  .demo-bar { gap: 8px; padding: 0 8px; }
  .hide-sm { display: none !important; }
}
@media (max-width: 480px) {
  .logo-name .sub { display: none; }
  .mini-stats { grid-template-columns: repeat(3, 1fr); }
  .mini-stats > div:nth-child(n+4) { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
