:root {
  --ink: #172033;
  --ink-soft: #667084;
  --navy: #18283f;
  --navy-2: #223a59;
  --canvas: #eef2f6;
  --paper: #ffffff;
  --line: #d9e0e8;
  --line-dark: #bdc7d3;
  --blue: #2a67d5;
  --blue-soft: #e6efff;
  --green: #178666;
  --green-soft: #dff5ec;
  --amber: #c57c0b;
  --amber-soft: #fff0d1;
  --red: #c94444;
  --red-soft: #fde8e8;
  --shadow: 0 18px 50px rgba(32, 48, 70, .12);
  --radius: 16px;
}

* { box-sizing: border-box; }

html { min-width: 320px; background: var(--canvas); }

body {
  margin: 0;
  color: var(--ink);
  background:
    linear-gradient(90deg, transparent 0 49.85%, rgba(67, 85, 108, .035) 49.85% 50.15%, transparent 50.15%) 0 0 / 72px 72px,
    var(--canvas);
  font-family: "Segoe UI Variable", "Segoe UI", Arial, sans-serif;
  font-size: 15px;
  line-height: 1.45;
}

button, input, select, textarea { font: inherit; }
button { color: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }

button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, a:focus-visible {
  outline: 3px solid rgba(42, 103, 213, .35);
  outline-offset: 2px;
}

.sr-only, .visually-hidden {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

.topbar {
  height: 74px;
  padding: 0 clamp(20px, 4vw, 64px);
  display: flex;
  align-items: center;
  gap: 28px;
  color: #fff;
  background: var(--navy);
  border-bottom: 1px solid rgba(255,255,255,.09);
  position: sticky;
  top: 0;
  z-index: 30;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 11px;
  color: #fff;
  text-decoration: none;
  min-width: 176px;
}

.brand > span:last-child { display: flex; align-items: baseline; gap: 6px; }
.brand b { font: 700 21px/1 "Bahnschrift", "Arial Narrow", sans-serif; letter-spacing: .07em; }
.brand small { font: 600 10px/1 "Consolas", monospace; letter-spacing: .2em; color: #9db7d5; }

.brand-mark {
  width: 34px;
  height: 34px;
  position: relative;
  display: inline-grid;
  grid-template-columns: 1fr 1fr;
  gap: 5px;
  transform: skewX(-10deg);
}

.brand-mark i { display: block; background: #fff; border-radius: 3px 3px 8px 3px; }
.brand-mark i:last-child { background: #75a7ff; border-radius: 3px 3px 3px 8px; }

.topbar-context {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 9px;
  color: #aebed1;
  font: 500 12px/1.3 "Consolas", monospace;
}

.pulse-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #6f7c8e;
  box-shadow: 0 0 0 4px rgba(111,124,142,.12);
}
.pulse-dot.is-live { background: #58d1a7; box-shadow: 0 0 0 4px rgba(88,209,167,.12); }
.pulse-dot.is-error { background: #f17272; box-shadow: 0 0 0 4px rgba(241,114,114,.12); }

.topbar-actions { display: flex; gap: 9px; }

.button {
  min-height: 40px;
  padding: 9px 15px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  border: 1px solid transparent;
  border-radius: 10px;
  cursor: pointer;
  font-weight: 650;
  transition: transform .15s ease, background .15s ease, border-color .15s ease, opacity .15s ease;
}
.button:hover { transform: translateY(-1px); }
.button:active { transform: translateY(0); }
.button:disabled { opacity: .55; cursor: wait; transform: none; }
.button-primary { color: #fff; background: var(--blue); border-color: #3878e7; box-shadow: 0 7px 18px rgba(32,92,193,.2); }
.button-primary:hover { background: #205cc4; }
.button-quiet { color: var(--ink); background: #fff; border-color: var(--line); }
.topbar .button-quiet { color: #d8e3ee; background: rgba(255,255,255,.06); border-color: rgba(255,255,255,.17); }
.topbar .button-quiet:hover { background: rgba(255,255,255,.1); }

main { width: min(1500px, 100%); margin: 0 auto; padding: 34px clamp(18px, 4vw, 62px) 64px; }

.command-deck {
  min-height: 256px;
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(390px, .9fr);
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 22px;
  overflow: hidden;
  box-shadow: 0 6px 22px rgba(44,60,82,.06);
}

.deck-copy { padding: clamp(30px, 5vw, 58px); position: relative; }
.deck-copy::after {
  content: "";
  position: absolute;
  right: -16px;
  top: 0;
  height: 100%;
  width: 32px;
  background: var(--paper);
  clip-path: polygon(0 0, 100% 0, 55% 100%, 0 100%);
  z-index: 2;
}

.eyebrow {
  margin: 0 0 9px;
  color: var(--blue);
  font: 700 11px/1.2 "Consolas", monospace;
  letter-spacing: .13em;
  text-transform: uppercase;
}

h1, h2, h3, p { margin-top: 0; }
h1, h2, h3 { font-family: "Bahnschrift", "Arial Narrow", sans-serif; }
h1 { max-width: 700px; margin-bottom: 15px; font-size: clamp(36px, 5vw, 64px); line-height: .97; letter-spacing: -.035em; font-weight: 650; }
h2 { margin-bottom: 0; font-size: clamp(26px, 3vw, 36px); line-height: 1.05; letter-spacing: -.025em; }
h3 { margin-bottom: 7px; }

.deck-lead { max-width: 670px; margin-bottom: 25px; color: var(--ink-soft); font-size: 16px; }
.provider-line { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; color: var(--ink-soft); font-size: 12px; }
.provider-badge { padding: 6px 9px; color: #6d4c05; background: var(--amber-soft); border: 1px solid #efd28e; border-radius: 7px; font: 700 10px/1 "Consolas", monospace; letter-spacing: .05em; text-transform: uppercase; }
.provider-badge.is-active { color: #0a654c; background: var(--green-soft); border-color: #a9decf; }

.odometer-panel {
  padding: 44px 42px 34px 56px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  color: #e8eef6;
  background:
    radial-gradient(circle at 72% 18%, rgba(77,132,203,.22), transparent 30%),
    linear-gradient(138deg, var(--navy-2), #111c2c 67%);
  position: relative;
}

.odometer-label { margin-bottom: 19px; display: flex; justify-content: space-between; align-items: flex-end; gap: 20px; }
.odometer-label span { font: 600 18px/1 "Bahnschrift", sans-serif; }
.odometer-label small { color: #8fa1b6; font: 500 10px/1 "Consolas", monospace; text-transform: uppercase; letter-spacing: .12em; }

.odometer { display: flex; align-items: center; gap: 4px; white-space: nowrap; }
.odometer span {
  width: clamp(32px, 3.4vw, 52px);
  height: clamp(52px, 5vw, 72px);
  display: grid;
  place-items: center;
  color: #f8fbff;
  background: linear-gradient(#0c131f 0 48%, #253246 49% 51%, #0c131f 52% 100%);
  border: 1px solid #35445a;
  border-radius: 7px;
  box-shadow: inset 0 0 14px rgba(0,0,0,.65), 0 1px 0 rgba(255,255,255,.13);
  font: 500 clamp(30px, 3.5vw, 48px)/1 "Consolas", monospace;
  text-shadow: 0 0 12px rgba(133,178,231,.25);
}
.odometer span.decimal { color: #a8c7ed; }
.odometer i { padding: 0 2px; align-self: flex-end; font: normal 700 30px/1 "Consolas", monospace; }

.road-scale { height: 24px; margin-top: 26px; display: flex; justify-content: space-between; border-bottom: 2px solid rgba(255,255,255,.18); }
.road-scale b { width: 1px; height: 8px; margin-top: auto; background: rgba(255,255,255,.45); }

.instrument-row {
  margin: 16px 0 42px;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}

.instrument { min-height: 116px; padding: 21px 26px; border-right: 1px solid var(--line); position: relative; }
.instrument:last-child { border-right: 0; }
.instrument strong { display: block; margin: 3px 0 1px; font: 650 34px/1 "Bahnschrift", sans-serif; letter-spacing: -.03em; }
.instrument p { margin: 0; color: var(--ink-soft); font-size: 12px; }
.instrument-code { color: #6f7b8e; font: 700 9px/1 "Consolas", monospace; letter-spacing: .14em; }
.code-blue { color: var(--blue); }
.code-green { color: var(--green); }
.code-amber { color: var(--amber); }
.attention-instrument.has-alerts { background: linear-gradient(105deg, #fff, #fff8e9); }
.attention-instrument.has-alerts::after { content: ""; position: absolute; top: 0; left: 0; right: 0; height: 3px; background: var(--amber); }

.fleet-section { min-width: 0; }
.section-heading { margin-bottom: 18px; display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; }
.fleet-tools { display: flex; align-items: center; gap: 12px; }

.search-box { width: min(300px, 30vw); height: 42px; display: flex; align-items: center; gap: 8px; padding: 0 12px; color: #7b8797; background: #fff; border: 1px solid var(--line); border-radius: 10px; }
.search-box:focus-within { border-color: #87adef; box-shadow: 0 0 0 3px rgba(42,103,213,.1); }
.search-box input { width: 100%; border: 0; outline: 0; color: var(--ink); background: transparent; }
.search-box input::placeholder { color: #9aa4b3; }

.filter-tabs { padding: 4px; display: flex; gap: 2px; background: #dfe5ec; border-radius: 10px; }
.filter-tabs button { height: 34px; padding: 0 11px; border: 0; border-radius: 7px; color: #687486; background: transparent; cursor: pointer; font-size: 12px; font-weight: 650; }
.filter-tabs button.is-active { color: var(--ink); background: #fff; box-shadow: 0 1px 5px rgba(31,45,64,.12); }

.fleet-board { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; box-shadow: 0 5px 18px rgba(42,56,76,.05); }
.fleet-header, .fleet-row { display: grid; grid-template-columns: minmax(240px, 1.4fr) minmax(120px, .7fr) minmax(128px, .72fr) minmax(145px, .82fr) minmax(145px, .82fr) minmax(125px, .62fr); align-items: center; }
.fleet-header { min-height: 44px; padding: 0 18px; color: #7e8998; background: #f6f8fa; border-bottom: 1px solid var(--line); font: 700 9px/1 "Consolas", monospace; letter-spacing: .1em; text-transform: uppercase; }
.fleet-row { width: 100%; min-height: 91px; padding: 0 18px; border: 0; border-bottom: 1px solid var(--line); background: #fff; text-align: left; cursor: pointer; position: relative; }
.fleet-row:last-child { border-bottom: 0; }
.fleet-row:hover { z-index: 1; background: #fafdff; box-shadow: inset 4px 0 0 var(--blue); }
.fleet-row > span { min-width: 0; padding-right: 15px; }

.vehicle-cell { display: grid; grid-template-columns: 7px 1fr; gap: 15px; align-items: stretch; }
.vehicle-lane { min-height: 52px; border-radius: 5px; background: #a7b0bc; position: relative; overflow: hidden; }
.vehicle-lane::after { content: ""; position: absolute; width: 1px; height: 60%; left: 3px; top: 20%; background: repeating-linear-gradient(to bottom, #fff 0 4px, transparent 4px 8px); }
.vehicle-lane.status-moving { background: var(--green); }
.vehicle-lane.status-parked, .vehicle-lane.status-idle { background: var(--blue); }
.vehicle-lane.status-service { background: var(--amber); }
.vehicle-lane.status-offline, .vehicle-lane.status-inactive { background: #8d97a4; }
.vehicle-title { align-self: center; min-width: 0; }
.vehicle-title strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font: 650 17px/1.25 "Bahnschrift", sans-serif; }
.vehicle-title small { display: block; margin-top: 4px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--ink-soft); font-size: 11px; }
.plate { display: inline-block; margin-right: 6px; padding: 2px 5px; color: #26344a; background: #f0f3f6; border: 1px solid #c9d0d8; border-radius: 4px; font: 700 10px/1.1 "Consolas", monospace; }

.status-pill { width: fit-content; padding: 6px 9px; display: inline-flex; align-items: center; gap: 6px; color: #566171; background: #edf0f3; border-radius: 999px; font-size: 11px; font-weight: 700; }
.status-pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.status-pill.status-moving { color: #087052; background: var(--green-soft); }
.status-pill.status-parked, .status-pill.status-idle { color: #285fae; background: var(--blue-soft); }
.status-pill.status-service { color: #8b5907; background: var(--amber-soft); }
.status-pill.status-offline, .status-pill.status-inactive { color: #6f7885; background: #edf0f3; }

.data-value { display: block; font: 650 17px/1.2 "Bahnschrift", sans-serif; font-variant-numeric: tabular-nums; }
.data-value small { color: var(--ink-soft); font-size: 10px; font-weight: 500; }
.data-note { display: block; margin-top: 4px; color: var(--ink-soft); font-size: 11px; }
.mini-gauges { display: flex; flex-direction: column; gap: 8px; }
.mini-gauge { display: grid; grid-template-columns: 24px 1fr 39px; align-items: center; gap: 5px; color: var(--ink-soft); font: 600 10px/1 "Consolas", monospace; }
.gauge-track { height: 4px; overflow: hidden; background: #e4e8ed; border-radius: 4px; }
.gauge-track i { height: 100%; display: block; background: var(--blue); border-radius: inherit; }
.mini-gauge.is-low .gauge-track i { background: var(--amber); }

.alert-stack { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 5px; }
.alert-chip { max-width: 150px; padding: 3px 5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: #8d5a06; background: var(--amber-soft); border-radius: 4px; font-size: 9px; font-weight: 700; }

.empty-state { min-height: 380px; padding: 56px 20px; text-align: center; }
.empty-state h3 { font-size: 25px; }
.empty-state p { max-width: 480px; margin: 0 auto 22px; color: var(--ink-soft); }
.empty-road { width: 104px; height: 76px; margin: 0 auto 22px; border-radius: 52px 52px 9px 9px; background: #dbe2e9; overflow: hidden; transform: perspective(70px) rotateX(8deg); }
.empty-road i { width: 3px; height: 100%; display: block; margin: auto; background: repeating-linear-gradient(to bottom, #fff 0 12px, transparent 12px 23px); }

.vehicle-drawer { position: fixed; inset: 0; z-index: 80; visibility: hidden; pointer-events: none; }
.vehicle-drawer.is-open { visibility: visible; pointer-events: auto; }
.drawer-scrim { position: absolute; inset: 0; background: rgba(10,19,31,.42); opacity: 0; transition: opacity .2s ease; }
.vehicle-drawer.is-open .drawer-scrim { opacity: 1; }
.drawer-panel { width: min(590px, 94vw); height: 100%; margin-left: auto; padding: 34px; overflow-y: auto; background: #fff; box-shadow: -20px 0 60px rgba(20,31,47,.2); transform: translateX(100%); transition: transform .24s cubic-bezier(.2,.75,.25,1); position: relative; }
.vehicle-drawer.is-open .drawer-panel { transform: translateX(0); }
.drawer-close { position: absolute; top: 22px; right: 22px; }
.drawer-kicker { color: var(--ink-soft); font: 700 10px/1.2 "Consolas", monospace; letter-spacing: .12em; text-transform: uppercase; }
.drawer-title { margin: 5px 48px 3px 0; font-size: 37px; }
.drawer-subtitle { color: var(--ink-soft); }
.drawer-status-line { margin: 21px 0; padding: 14px 0; display: flex; flex-wrap: wrap; align-items: center; gap: 9px; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.drawer-actions { display: flex; gap: 8px; margin-bottom: 28px; }
.detail-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 9px; margin-bottom: 26px; }
.detail-card { min-height: 90px; padding: 14px; background: #f4f7fa; border-radius: 10px; }
.detail-card small { display: block; margin-bottom: 7px; color: var(--ink-soft); font: 600 9px/1.2 "Consolas", monospace; letter-spacing: .07em; text-transform: uppercase; }
.detail-card strong { font: 650 20px/1.1 "Bahnschrift", sans-serif; }
.detail-card strong i { color: var(--ink-soft); font: normal 500 10px/1 "Segoe UI", sans-serif; }
.drawer-block { margin-top: 26px; }
.drawer-block-heading { margin-bottom: 12px; display: flex; justify-content: space-between; align-items: center; }
.drawer-block h3 { margin: 0; font-size: 20px; }
.sparkline { height: 150px; padding: 12px; background: #f6f8fb; border: 1px solid var(--line); border-radius: 12px; }
.sparkline svg { width: 100%; height: 100%; overflow: visible; }
.sparkline .grid { stroke: #dce3ea; stroke-width: 1; stroke-dasharray: 3 5; }
.sparkline .line { fill: none; stroke: var(--blue); stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; }
.sparkline .area { fill: url(#chartGradient); opacity: .45; }
.sparkline-empty { height: 100%; display: grid; place-items: center; color: var(--ink-soft); font-size: 12px; }
.service-list { display: flex; flex-direction: column; }
.service-item { padding: 12px 0 12px 20px; border-left: 2px solid #d8dee6; position: relative; }
.service-item::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--blue); position: absolute; left: -5px; top: 18px; box-shadow: 0 0 0 4px #fff; }
.service-item strong { display: block; font-size: 13px; }
.service-item span { color: var(--ink-soft); font-size: 11px; }
.drawer-empty { padding: 20px; color: var(--ink-soft); background: #f6f8fa; border-radius: 10px; text-align: center; font-size: 12px; }

.icon-button { width: 38px; height: 38px; display: grid; place-items: center; border: 1px solid var(--line); border-radius: 9px; color: #5e6978; background: #fff; cursor: pointer; font-size: 23px; line-height: 1; }
.icon-button:hover { background: #f2f5f8; }

.modal { width: min(680px, calc(100vw - 28px)); padding: 0; border: 0; border-radius: 18px; box-shadow: var(--shadow); }
.compact-modal { width: min(570px, calc(100vw - 28px)); }
.modal::backdrop { background: rgba(15,25,39,.55); backdrop-filter: blur(2px); }
.modal form { padding: 28px; }
.modal-heading { margin-bottom: 23px; display: flex; justify-content: space-between; align-items: flex-start; gap: 20px; }
.modal-heading h2 { font-size: 29px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-grid label:not(.check-field) { display: flex; flex-direction: column; gap: 6px; color: #536071; font-size: 12px; font-weight: 650; }
.form-grid input, .form-grid select, .form-grid textarea { width: 100%; min-height: 43px; padding: 9px 11px; color: var(--ink); background: #fff; border: 1px solid var(--line-dark); border-radius: 8px; outline: 0; }
.form-grid textarea { resize: vertical; }
.form-grid input:focus, .form-grid select:focus, .form-grid textarea:focus { border-color: #6794df; box-shadow: 0 0 0 3px rgba(42,103,213,.1); }
.check-field { min-height: 43px; display: flex; align-items: center; gap: 9px; align-self: end; color: #536071; font-size: 12px; font-weight: 650; }
.check-field input { width: 18px; height: 18px; accent-color: var(--blue); }
.span-two { grid-column: 1 / -1; }
.form-error { min-height: 20px; margin: 15px 0 0; color: var(--red); font-size: 12px; }
.modal-actions { margin-top: 8px; display: flex; justify-content: flex-end; gap: 9px; }

.toast { max-width: min(440px, calc(100vw - 30px)); padding: 13px 17px; color: #fff; background: var(--navy); border-left: 4px solid #77a7f4; border-radius: 9px; box-shadow: var(--shadow); position: fixed; left: 50%; bottom: 24px; z-index: 120; opacity: 0; transform: translate(-50%, 18px); pointer-events: none; transition: opacity .2s ease, transform .2s ease; }
.toast.is-visible { opacity: 1; transform: translate(-50%, 0); }
.toast.is-error { border-left-color: #f07070; }

@media (max-width: 1100px) {
  .command-deck { grid-template-columns: 1fr; }
  .deck-copy::after { display: none; }
  .odometer-panel { min-height: 230px; padding: 36px; }
  .instrument-row { grid-template-columns: 1fr 1fr; }
  .instrument:nth-child(2) { border-right: 0; }
  .instrument:nth-child(-n+2) { border-bottom: 1px solid var(--line); }
  .section-heading { align-items: flex-start; flex-direction: column; }
  .fleet-tools { width: 100%; }
  .search-box { flex: 1; width: auto; }
  .fleet-header { display: none; }
  .fleet-row { grid-template-columns: 1.5fr .8fr .8fr; min-height: 118px; padding: 16px 18px; }
  .fleet-row > span:nth-child(4), .fleet-row > span:nth-child(5), .fleet-row > span:nth-child(6) { display: none; }
}

@media (max-width: 720px) {
  .topbar { height: 66px; padding: 0 14px; gap: 10px; }
  .brand { min-width: 0; }
  .brand > span:last-child, .topbar-context { display: none; }
  .brand-mark { width: 31px; height: 31px; }
  .topbar-actions { margin-left: auto; }
  .topbar .button { min-height: 38px; padding: 8px 10px; font-size: 12px; }
  #syncButton { width: 40px; font-size: 0; }
  #syncButton span { font-size: 20px; }
  main { padding: 18px 12px 42px; }
  .command-deck { border-radius: 16px; }
  .deck-copy { padding: 27px 22px; }
  h1 { font-size: 38px; }
  .deck-lead { font-size: 14px; }
  .provider-line { align-items: flex-start; flex-direction: column; }
  .odometer-panel { min-height: 198px; padding: 28px 20px; }
  .odometer-label { align-items: flex-start; flex-direction: column; gap: 7px; }
  .odometer span { width: calc((100vw - 90px) / 7); max-width: 42px; height: 56px; font-size: 29px; }
  .instrument-row { margin-bottom: 34px; }
  .instrument { min-height: 102px; padding: 17px; }
  .instrument strong { font-size: 29px; }
  .fleet-tools { align-items: stretch; flex-direction: column; }
  .filter-tabs { width: 100%; overflow-x: auto; }
  .filter-tabs button { flex: 1 0 auto; }
  .fleet-row { grid-template-columns: 1fr auto; min-height: 127px; align-items: start; gap: 14px; }
  .fleet-row > span { padding-right: 0; }
  .fleet-row > span:nth-child(2) { justify-self: end; }
  .fleet-row > span:nth-child(3) { display: block; grid-column: 1 / -1; padding-left: 22px; }
  .vehicle-lane { min-height: 50px; }
  .drawer-panel { width: 100%; padding: 27px 20px; }
  .detail-grid { grid-template-columns: 1fr 1fr; }
  .drawer-actions { flex-direction: column; }
  .form-grid { grid-template-columns: 1fr; }
  .span-two { grid-column: auto; }
  .modal form { padding: 22px 18px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; }
}
