:root {
  color-scheme: dark;
  --bg: #071320;
  --surface: #0d2132;
  --surface-2: #122d41;
  --line: #203d52;
  --text: #e6eef3;
  --muted: #9bb1c2;
  --brand: #33bfb1;
  --blue: #3fa9f5;
  --amber: #f1b84a;
  --red: #ef6b65;
  --green: #49c58b;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: Inter, "Segoe UI", Arial, sans-serif;
  background: radial-gradient(circle at top right, #153a48, var(--bg) 38%);
  color: var(--text);
}
.shell { max-width: 1520px; margin: 0 auto; padding: 28px; }
.masthead, .command-bar, .panel-head, .session-panel, .range-buttons { display: flex; align-items: center; gap: 12px; }
.masthead { justify-content: space-between; margin-bottom: 22px; }
.eyebrow { margin: 0 0 6px; color: var(--brand); font-size: 12px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; }
h1 { font-size: clamp(30px, 4vw, 43px); margin: 0 0 8px; }
h2 { font-size: 18px; margin: 0 0 6px; }
.subtitle, .panel p, .status { color: var(--muted); margin: 0; }
.session-panel { justify-content: flex-end; }
.panel, .login-card, .metric {
  background: rgba(13, 33, 50, .96);
  border: 1px solid var(--line);
  border-radius: 14px;
}
.login-card { max-width: 470px; margin: 70px auto; padding: 28px; }
.login-card h2 { font-size: 26px; margin: 0 0 8px; }
form { display: grid; gap: 14px; margin-top: 22px; }
label { display: grid; gap: 7px; color: var(--muted); font-size: 13px; font-weight: 600; }
input, select {
  width: 100%; border-radius: 8px; border: 1px solid var(--line);
  background: #091a28; color: var(--text); font: inherit; padding: 12px;
}
button {
  border: 0; border-radius: 8px; min-height: 40px; padding: 0 15px;
  cursor: pointer; font: inherit; font-weight: 650; background: var(--brand); color: #05211f;
}
button.outline, .range-buttons button, .session-panel button {
  color: var(--text); background: var(--surface-2); border: 1px solid var(--line);
}
.range-buttons button.active { border-color: var(--brand); color: var(--brand); }
.command-bar {
  flex-wrap: wrap; justify-content: flex-end; margin-bottom: 14px;
}
.toggle { display: flex; grid-auto-flow: column; align-items: center; gap: 8px; margin-left: auto; }
.toggle input { width: auto; accent-color: var(--brand); }
.status { min-height: 22px; margin-bottom: 13px; }
.metrics { display: grid; grid-template-columns: repeat(6, minmax(135px, 1fr)); gap: 12px; margin-bottom: 14px; }
.metric { padding: 15px; min-height: 96px; }
.metric small { display: block; color: var(--muted); font-size: 12px; margin-bottom: 9px; }
.metric strong { display: block; font-size: 26px; letter-spacing: -.03em; }
.metric span { color: var(--muted); font-size: 12px; }
.grid { display: grid; gap: 14px; }
.map-grid { grid-template-columns: minmax(500px, 2.15fr) minmax(310px, .85fr); margin-bottom: 14px; }
.panel { padding: 16px; min-height: 180px; }
.panel-head { justify-content: space-between; margin-bottom: 13px; }
.panel-head p { font-size: 12px; max-width: 660px; }
#map { height: 542px; border-radius: 10px; background: #0a1a24; }
.legend { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; font-size: 12px; color: var(--muted); }
.legend span:before { content: ""; width: 10px; height: 10px; display: inline-block; border-radius: 3px; margin-right: 5px; }
.legend .clear:before { background: #31c587; }
.legend .moderate:before { background: #f1b84a; }
.legend .slow:before { background: #f28a39; }
.legend .stopped:before { background: var(--red); }
.trip-summary { display: flex; flex-wrap: wrap; gap: 9px; margin: 0 0 13px; }
.trip-chip {
  display: flex; align-items: center; gap: 9px; background: var(--surface-2); border: 1px solid var(--line);
  border-left: 4px solid var(--trip-color); border-radius: 9px; padding: 9px 11px; color: var(--muted); font-size: 12px;
}
.trip-chip strong { color: var(--text); font-size: 13px; }
.trip-label {
  color: #071320; font: 700 12px/1.2 Inter, "Segoe UI", Arial, sans-serif; white-space: nowrap;
  background: var(--trip-color); border: 2px solid #061321; border-radius: 999px; padding: 5px 9px;
  box-shadow: 0 4px 14px rgba(0,0,0,.36);
}
.trip-end {
  width: 12px; height: 12px; border-radius: 50%; border: 2px solid #071320;
  background: var(--trip-color); box-shadow: 0 0 0 2px rgba(255,255,255,.7);
}
.route-telemetry-tooltip {
  background: #091a28; border: 1px solid #2a556c; border-radius: 10px; color: var(--text);
  box-shadow: 0 12px 28px rgba(0,0,0,.38); padding: 0;
}
.route-telemetry-tooltip:before { border-top-color: #2a556c; }
.route-tooltip { display: grid; gap: 4px; padding: 10px 12px; min-width: 250px; font-size: 12px; }
.route-tooltip strong { color: var(--brand); font-size: 13px; margin-bottom: 3px; text-transform: capitalize; }
.route-tooltip span { color: #c7d6e1; white-space: nowrap; }
.route-tooltip b { color: #fff; font-weight: 650; margin-right: 3px; }
.insight-panel, .playback-panel { margin-bottom: 14px; }
.analysis-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(295px, 1fr)); gap: 12px; }
.analysis-card {
  background: var(--surface-2); border: 1px solid var(--line); border-left: 4px solid var(--trip-color);
  border-radius: 11px; padding: 14px; display: grid; gap: 12px;
}
.analysis-title { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.analysis-title small { color: var(--muted); display: block; margin-bottom: 5px; }
.analysis-title strong { display: block; font-size: 19px; }
.analysis-title span {
  color: var(--amber); background: rgba(241,184,74,.14); border: 1px solid rgba(241,184,74,.3);
  padding: 4px 8px; border-radius: 999px; font-size: 11px; font-weight: 700;
}
.analysis-card p { font-size: 12px; line-height: 1.5; min-height: 37px; }
.analysis-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.analysis-stats span { border-radius: 8px; background: #091a28; padding: 8px; color: var(--muted); font-size: 11px; }
.analysis-stats b { display: block; color: var(--text); font-size: 17px; margin-bottom: 2px; }
.analysis-card button { justify-self: start; }
.playback-head { align-items: end; gap: 20px; }
.playback-actions { display: flex; align-items: end; justify-content: flex-end; flex-wrap: wrap; gap: 8px; }
.playback-actions label { width: 180px; }
.playback-actions label:last-child { width: 74px; }
.playback-actions select { padding: 9px 10px; min-height: 40px; }
.scrubber { accent-color: var(--brand); margin: 5px 0 18px; padding: 0; border: 0; background: transparent; }
.cockpit {
  display: grid; grid-template-columns: 245px 1fr; align-items: center; gap: 22px;
  border-radius: 12px; padding: 18px; background: linear-gradient(135deg, #091924, #102a3b);
}
.speedometer { position: relative; height: 202px; text-align: center; padding-top: 40px; }
.dial {
  position: absolute; top: 5px; left: 22px; height: 190px; width: 190px; border-radius: 50%;
  background: conic-gradient(from 220deg, #243f54 0deg 12deg, #2d8f8b 20deg 170deg, #f1b84a 198deg 230deg, #ef6b65 235deg 260deg, transparent 261deg);
}
.dial:after {
  content: ""; position: absolute; inset: 15px; border-radius: 50%; background: #091a28;
  box-shadow: inset 0 0 0 1px #1e394d;
}
.needle {
  position: absolute; z-index: 2; left: 92px; top: 28px; height: 72px; width: 3px;
  background: #f7fbff; transform-origin: 50% 67px; transform: rotate(var(--needle-angle));
  border-radius: 2px; box-shadow: 0 0 9px rgba(255,255,255,.55);
}
.dial-center {
  position: absolute; z-index: 3; left: 87px; top: 91px; width: 12px; height: 12px;
  border-radius: 50%; background: var(--brand);
}
.speedometer strong { position: relative; z-index: 4; display: block; font-size: 44px; letter-spacing: -.05em; margin-top: 55px; }
.speedometer span { position: relative; z-index: 4; color: var(--muted); font-size: 12px; text-transform: uppercase; }
.telemetry-cluster { display: grid; grid-template-columns: 1fr .7fr 1fr; gap: 12px; }
.drive-status, .gear-box, .pedal-box, .playback-readings {
  background: #0d2132; border: 1px solid var(--line); border-radius: 10px; padding: 13px;
}
.drive-status small, .gear-box small, .pedal-box small, .playback-readings small { color: var(--muted); display: block; font-size: 11px; margin-bottom: 7px; }
.drive-status strong { color: var(--brand); display: block; font-size: 20px; min-height: 47px; }
.drive-status span, .gear-box span { color: var(--muted); font-size: 12px; }
.gear-box strong { display: block; font-size: 43px; line-height: 1; margin: 6px 0 10px; }
.pedal-box { display: grid; gap: 13px; }
.pedal-box progress { width: 100%; height: 12px; accent-color: var(--green); }
.pedal-box progress.brake { accent-color: var(--red); }
.playback-readings { grid-column: 1 / -1; display: grid; grid-template-columns: repeat(3, minmax(145px, 1fr)); gap: 11px; }
.playback-readings span { padding-right: 9px; border-right: 1px solid var(--line); }
.playback-readings span:nth-child(3n) { border: 0; }
.playback-readings b { display: block; font-size: 14px; font-weight: 650; }
.playback-vehicle {
  width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center;
  background: #071320; border: 3px solid var(--trip-color); box-shadow: 0 0 0 3px rgba(255,255,255,.74), 0 6px 14px rgba(0,0,0,.42);
  transform: rotate(var(--heading));
}
.playback-vehicle i {
  width: 0; height: 0; border-left: 7px solid transparent; border-right: 7px solid transparent;
  border-bottom: 17px solid var(--trip-color); transform: translateY(-2px);
}
.pill { padding: 5px 9px; border-radius: 999px; font-size: 12px; color: var(--green); background: rgba(73,197,139,.12); }
.timeline-head { align-items: flex-start; }
.timeline-head p { max-width: none; }
.user-filter { margin-bottom: 13px; }
.user-filter select { margin-top: 2px; padding: 10px 11px; }
.vehicle-list { display: grid; gap: 10px; max-height: 479px; overflow: auto; padding-right: 2px; }
.route-card {
  background: var(--surface-2); border: 1px solid var(--line); border-left: 4px solid var(--trip-color);
  padding: 13px; border-radius: 10px; display: grid; gap: 11px;
}
.route-card header { display: flex; justify-content: space-between; align-items: start; gap: 8px; }
.route-card header small { display: block; color: var(--muted); font-size: 11px; margin-bottom: 4px; }
.route-card header strong { display: block; font-size: 16px; }
.route-card header span {
  color: var(--brand); background: rgba(51,191,177,.12); padding: 5px 7px; border-radius: 999px;
  font-size: 11px; max-width: 120px; text-align: right;
}
.route-user {
  background: #091a28; border-radius: 7px; color: #c5d5e1 !important; font-size: 12px !important;
  padding: 7px 8px; overflow-wrap: anywhere;
}
.time-span { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 8px; font-size: 14px; }
.time-span i { display: block; height: 2px; background: linear-gradient(90deg, var(--trip-color), var(--brand)); position: relative; }
.time-span i:before, .time-span i:after {
  content: ""; position: absolute; top: -4px; width: 10px; height: 10px; border-radius: 50%; background: var(--trip-color);
}
.time-span i:before { left: 0; }
.time-span i:after { right: 0; background: var(--brand); }
.time-label { display: flex; justify-content: space-between; margin-top: -9px; color: var(--muted); font-size: 10px; }
.route-stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 7px; }
.route-stats span { padding: 8px; background: #091a28; border-radius: 7px; }
.route-stats small { color: var(--muted); font-size: 10px; display: block; margin-bottom: 4px; }
.route-stats strong { font-size: 14px; font-weight: 650; }
.route-actions { display: flex; gap: 8px; }
.route-actions button { flex: 1; min-height: 34px; font-size: 12px; }
.charts { display: grid; grid-template-columns: repeat(3, minmax(280px, 1fr)); gap: 14px; }
.charts canvas { width: 100%; height: 220px; display: block; margin-top: 10px; }
.hidden { display: none !important; }
.empty { color: var(--muted); padding: 26px 0; text-align: center; }
@media (max-width: 1080px) {
  .metrics { grid-template-columns: repeat(3, 1fr); }
  .map-grid, .charts { grid-template-columns: 1fr; }
  #map { height: 450px; }
  .playback-head { display: block; }
  .playback-actions { justify-content: flex-start; margin-top: 15px; }
  .cockpit { grid-template-columns: 1fr; }
  .speedometer { width: 235px; margin: 0 auto; }
}
@media (max-width: 640px) {
  .shell { padding: 15px; }
  .masthead { display: block; }
  .session-panel { margin-top: 14px; justify-content: flex-start; }
  .metrics { grid-template-columns: repeat(2, 1fr); }
  .command-bar { justify-content: flex-start; }
  .toggle { margin-left: 0; }
  .analysis-stats, .telemetry-cluster, .playback-readings { grid-template-columns: 1fr; }
  .playback-readings span { border-right: 0; border-bottom: 1px solid var(--line); padding-bottom: 10px; }
}
