:root {
  color-scheme: dark;
  --bg: #06080c;
  --panel: #111821;
  --panel-2: #0c1219;
  --panel-3: #172230;
  --line: rgba(159, 179, 202, 0.18);
  --line-strong: rgba(174, 196, 220, 0.34);
  --text: #eef5fb;
  --muted: #8c9aaa;
  --good: #37d77b;
  --warn: #f3c84b;
  --critical: #ff5f57;
  --info: #46c6ff;
  --purple: #8b7dff;
  --radius: 8px;
  --shadow: 0 20px 60px rgba(0, 0, 0, 0.38);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  background:
    radial-gradient(circle at 20% -10%, rgba(70, 198, 255, 0.13), transparent 32%),
    linear-gradient(180deg, #101722 0, var(--bg) 360px),
    var(--bg);
  color: var(--text);
}

h1,
h2,
p {
  margin: 0;
}

.pitwall-shell {
  width: min(1840px, calc(100vw - 28px));
  margin: 0 auto;
  padding: 14px 0 30px;
}

.pit-header,
.driver-grid,
.command-grid,
.telemetry-overview,
.mini-chart-grid {
  display: grid;
  gap: 12px;
}

.pit-header {
  grid-template-columns: minmax(220px, 0.22fr) 1fr;
  align-items: stretch;
  margin-bottom: 12px;
}

.brand-block,
.panel,
.driver-card,
.metric-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.035), transparent),
    var(--panel);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

.brand-block {
  display: grid;
  align-content: center;
  min-height: 92px;
  padding: 18px;
  background:
    linear-gradient(135deg, rgba(70, 198, 255, 0.16), transparent 58%),
    #0d141d;
  box-shadow: var(--shadow);
}

.eyebrow {
  color: var(--info);
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0;
  text-transform: uppercase;
}

.brand-block h1 {
  margin-top: 3px;
  font-size: clamp(32px, 3vw, 48px);
  line-height: 0.95;
  text-transform: uppercase;
}

.brand-controls {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.display-picker {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 900;
  text-transform: uppercase;
}

.display-picker select {
  width: min(100%, 220px);
  height: 34px;
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  background: #090f16;
  color: var(--text);
  padding: 0 10px;
  font: inherit;
  text-transform: none;
}

.log-download {
  display: flex;
  align-items: center;
  gap: 9px;
  min-width: 0;
  flex-wrap: nowrap;
  overflow: hidden;
}

.log-download button {
  flex: 0 0 auto;
  min-height: 34px;
  padding: 0 11px;
  border: 1px solid rgba(70, 198, 255, 0.44);
  border-radius: 7px;
  background: rgba(70, 198, 255, 0.1);
  color: var(--text);
  font: inherit;
  font-size: 12px;
  font-weight: 900;
  cursor: pointer;
}

.log-download button:hover {
  border-color: var(--info);
  background: rgba(70, 198, 255, 0.18);
}

.log-download button:focus-visible {
  outline: 2px solid var(--info);
  outline-offset: 2px;
}

.log-download span {
  display: block;
  min-width: 0;
  overflow: hidden;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.session-strip {
  display: grid;
  grid-template-columns: 1.25fr 1.1fr 1fr 0.8fr;
  gap: 10px;
}

.metric-card {
  min-width: 0;
  min-height: 92px;
  padding: 13px 14px;
}

.metric-card span,
.panel-note,
.driver-primary span,
.metric-card small,
.dbc-signal-row small,
.subsystem-copy span {
  color: var(--muted);
}

.metric-card span {
  display: block;
  font-size: 11px;
  font-weight: 850;
  text-transform: uppercase;
}

.metric-card strong {
  display: block;
  margin-top: 7px;
  color: var(--text);
  font-size: clamp(20px, 1.5vw, 28px);
  font-weight: 900;
  line-height: 1;
  overflow-wrap: anywhere;
}

.metric-card small {
  display: block;
  margin-top: 8px;
  font-size: 12px;
}

.metric-good {
  border-color: rgba(55, 215, 123, 0.36);
}

.metric-warning {
  border-color: rgba(243, 200, 75, 0.36);
}

.metric-critical {
  border-color: rgba(255, 95, 87, 0.4);
}

.metric-blue {
  border-color: rgba(70, 198, 255, 0.32);
}

.metric-purple {
  border-color: rgba(139, 125, 255, 0.32);
}

.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 24px;
  width: max-content;
  max-width: 100%;
  padding: 0 9px;
  border: 1px solid currentColor;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 900;
  text-transform: uppercase;
}

.status-badge::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
  box-shadow: 0 0 12px currentColor;
}

.status-good {
  color: var(--good);
  background: rgba(55, 215, 123, 0.1);
}

.status-warning {
  color: var(--warn);
  background: rgba(243, 200, 75, 0.1);
}

.status-critical {
  color: var(--critical);
  background: rgba(255, 95, 87, 0.11);
}

.status-info {
  color: var(--info);
  background: rgba(70, 198, 255, 0.1);
}

.driver-grid {
  grid-template-columns: minmax(0, 1fr) 430px;
  align-items: stretch;
  margin-bottom: 12px;
}

.driver-card,
.gps-map-card {
  padding: 14px;
}

.gps-map-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.035), transparent),
    var(--panel);
  overflow: hidden;
}

.driver-muted {
  opacity: 0.72;
}

.driver-card-head,
.panel-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.car-number {
  color: var(--info);
  font-size: 12px;
  font-weight: 900;
}

.driver-card h2,
.panel-title h2 {
  margin-top: 3px;
  font-size: 20px;
  text-transform: uppercase;
}

.driver-primary {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin: 14px 0 10px;
}

.driver-primary div {
  min-height: 92px;
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #0a1017;
}

.driver-primary strong {
  display: block;
  margin-top: 8px;
  font-size: clamp(28px, 2.7vw, 48px);
  line-height: 0.94;
  font-weight: 950;
  font-variant-numeric: tabular-nums;
}

.driver-metrics,
.subsystem-grid,
.mini-chart-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.driver-metrics .metric-card {
  min-height: 78px;
  padding: 11px;
  background: var(--panel-2);
}

.driver-metrics .metric-card strong {
  font-size: 18px;
}

.gps-map-frame {
  position: relative;
  height: 292px;
  margin-top: 12px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background:
    linear-gradient(rgba(255, 255, 255, 0.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.04) 1px, transparent 1px),
    #090f16;
  background-size: 25% 25%;
  overflow: hidden;
}

.gps-map-frame iframe {
  width: 100%;
  height: 100%;
  border: 0;
  filter: saturate(0.78) contrast(1.05) brightness(0.85);
}

.map-overlay {
  position: absolute;
  right: 10px;
  bottom: 10px;
  left: 10px;
  padding: 9px 10px;
  border: 1px solid rgba(243, 200, 75, 0.38);
  border-radius: 7px;
  background: rgba(6, 8, 12, 0.82);
  color: var(--warn);
  font-size: 12px;
  font-weight: 850;
}

.gps-map-metrics {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-top: 10px;
}

.gps-map-metrics article {
  min-width: 0;
  min-height: 54px;
  padding: 9px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #0a1017;
}

.gps-map-metrics span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 900;
  text-transform: uppercase;
}

.gps-map-metrics strong {
  display: block;
  margin-top: 4px;
  color: var(--text);
  font-size: 14px;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
  overflow-wrap: anywhere;
}

.command-grid {
  grid-template-columns: minmax(0, 1fr) 390px;
  align-items: start;
  margin-bottom: 12px;
}

.command-grid.single-panel {
  grid-template-columns: 1fr;
}

.left-column {
  display: grid;
  gap: 12px;
}

.panel {
  padding: 14px;
}

.subsystem-grid {
  margin: 14px 0 12px;
}

.subsystem-copy {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.subsystem-copy article,
.empty-state {
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #0a1017;
  padding: 12px;
}

.subsystem-copy span {
  display: block;
  margin-bottom: 6px;
  font-size: 11px;
  font-weight: 900;
  text-transform: uppercase;
}

.subsystem-copy p {
  color: #d9e4ee;
  font-size: 14px;
  line-height: 1.45;
}

.risk-copy {
  border-color: rgba(243, 200, 75, 0.28) !important;
}

.alert-list {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.alert-card {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #0a1017;
}

.alert-card strong {
  display: block;
  margin-bottom: 5px;
}

.alert-card p {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.4;
}

.alert-critical {
  border-color: rgba(255, 95, 87, 0.48);
  background: rgba(255, 95, 87, 0.1);
}

.alert-warning {
  border-color: rgba(243, 200, 75, 0.42);
  background: rgba(243, 200, 75, 0.09);
}

.mini-chart-grid {
  margin-bottom: 12px;
}

.telemetry-overview {
  grid-template-columns: minmax(0, 1fr) 430px;
  align-items: stretch;
  margin-bottom: 12px;
}

.telemetry-tiles {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 10px;
}

.telemetry-tile,
.live-feed-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.035), transparent),
    var(--panel);
}

.telemetry-tile {
  display: grid;
  align-content: space-between;
  min-height: 128px;
  padding: 14px;
  overflow: hidden;
  position: relative;
}

.telemetry-tile::after {
  content: "";
  position: absolute;
  right: 14px;
  bottom: 12px;
  left: 14px;
  height: 3px;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--info), transparent);
  opacity: 0.7;
}

.telemetry-tile span,
.live-feed-grid span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 900;
  text-transform: uppercase;
}

.telemetry-tile strong {
  display: block;
  margin-top: 8px;
  color: var(--text);
  font-size: clamp(28px, 2.5vw, 44px);
  font-weight: 950;
  line-height: 0.95;
  font-variant-numeric: tabular-nums;
}

.telemetry-tile small {
  color: var(--muted);
  font-size: 13px;
  font-weight: 850;
  text-transform: uppercase;
}

.tile-accent strong {
  color: var(--info);
}

.tile-good {
  border-color: rgba(55, 215, 123, 0.34);
}

.tile-warning {
  border-color: rgba(243, 200, 75, 0.36);
}

.tile-critical {
  border-color: rgba(255, 95, 87, 0.42);
}

.live-feed-card {
  min-height: 128px;
  padding: 12px;
}

.live-feed-card .panel-title {
  align-items: flex-start;
}

.live-feed-card h2 {
  max-width: 100%;
  color: var(--text);
  font-size: 13px;
  line-height: 1.3;
  overflow-wrap: anywhere;
  text-transform: none;
}

.live-feed-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-top: 10px;
}

.live-feed-grid article {
  min-width: 0;
  min-height: 54px;
  padding: 9px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #0a1017;
}

.live-feed-grid strong {
  display: block;
  margin-top: 4px;
  color: var(--text);
  font-size: 14px;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
  overflow-wrap: anywhere;
}

.mini-chart-card {
  min-height: 176px;
  overflow: hidden;
}

.panel-title.compact h2 {
  font-size: 16px;
}

.mini-chart-card svg {
  display: block;
  width: 100%;
  height: 100px;
  margin-top: 12px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background:
    linear-gradient(rgba(255, 255, 255, 0.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.04) 1px, transparent 1px),
    #090f16;
  background-size: 100% 25%, 16.66% 100%;
}

.chart-empty {
  display: grid;
  place-items: center;
  min-height: 100px;
  margin-top: 12px;
  color: var(--muted);
}

.cmu-panel {
  margin-bottom: 12px;
}

.cmu-voltage-table {
  display: grid;
  grid-template-columns: minmax(128px, 1.25fr) repeat(8, minmax(82px, 1fr));
  margin-top: 14px;
  border: 1px solid rgba(20, 28, 38, 0.24);
  border-radius: 8px;
  background: #f4f5f5;
  color: #515a64;
  overflow: hidden;
  box-shadow:
    inset 0 0 18px rgba(255, 255, 255, 0.82),
    0 14px 26px rgba(0, 0, 0, 0.22);
}

.cmu-voltage-table > div {
  min-height: 36px;
  padding: 8px 10px;
  border-right: 1px solid rgba(255, 255, 255, 0.62);
  border-bottom: 1px solid rgba(218, 222, 225, 0.92);
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.cmu-voltage-table > div:nth-child(9n) {
  border-right: 0;
}

.cmu-head {
  background: #ececec;
  color: #4f5963;
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}

.cmu-node {
  background: #fbfbfb;
  color: #68717a;
  font-weight: 850;
}

.cmu-cell.empty {
  background: #d8d8d8;
  color: transparent;
}

.cmu-cell.low,
.cmu-bar-wrap i.low {
  background: #ff9a78;
}

.cmu-cell.warm,
.cmu-bar-wrap i.warm {
  background: #f4f7c8;
}

.cmu-cell.ok,
.cmu-bar-wrap i.ok {
  background: #deedc0;
}

.cmu-cell.balanced,
.cmu-bar-wrap i.balanced {
  background: #c4dfad;
}

.cmu-cell.high,
.cmu-bar-wrap i.high {
  background: #74bd86;
}

.cmu-cell.critical,
.cmu-bar-wrap i.critical {
  background: #ffd20b;
}

.cmu-empty {
  grid-column: 1 / -1;
  margin: 12px;
  background: #fbfbfb;
  color: #68717a;
}

.cmu-detail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(360px, 1fr));
  gap: 12px;
  margin-top: 14px;
}

.cmu-detail-card {
  min-width: 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.04), transparent),
    #0a1017;
}

.cmu-detail-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}

.cmu-detail-head small {
  color: var(--muted);
  font-weight: 850;
  text-transform: uppercase;
}

.cmu-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 12px;
}

.cmu-stats div {
  min-width: 0;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #101824;
}

.cmu-stats span {
  display: block;
  color: var(--muted);
  font-size: 11px;
  font-weight: 900;
  text-transform: uppercase;
}

.cmu-stats strong {
  display: inline-block;
  margin-top: 6px;
  color: var(--text);
  font-size: 22px;
  font-weight: 950;
  font-variant-numeric: tabular-nums;
}

.cmu-stats small {
  margin-left: 5px;
  color: var(--muted);
  font-weight: 850;
}

.cmu-bars {
  display: grid;
  grid-template-columns: repeat(8, minmax(0, 1fr));
  gap: 8px;
  align-items: end;
  min-height: 188px;
  padding: 14px 12px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background:
    linear-gradient(rgba(255, 255, 255, 0.06) 1px, transparent 1px),
    #f7f7f7;
  background-size: 100% 20%;
}

.cmu-bar-wrap {
  display: grid;
  grid-template-rows: 18px 120px 20px;
  gap: 5px;
  align-items: end;
  min-width: 0;
  color: #68717a;
  text-align: center;
  font-size: 11px;
  font-weight: 850;
}

.cmu-bar-wrap i {
  display: block;
  width: 100%;
  min-height: 3px;
  border-radius: 3px 3px 0 0;
  background: #d8d8d8;
}

.cmu-bar-wrap strong {
  color: #515a64;
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}

.dbc-signal-table {
  margin-top: 14px;
  border: 1px solid var(--line);
  border-radius: 7px;
  overflow: hidden;
}

.dbc-signal-head,
.dbc-signal-row {
  display: grid;
  grid-template-columns: 0.8fr 1.6fr 1fr 0.8fr 1.3fr 0.9fr 0.9fr;
  gap: 10px;
  align-items: center;
  min-height: 40px;
  padding: 8px 12px;
}

.dbc-signal-head {
  background: #172230;
  color: #b9c7d7;
  font-size: 11px;
  font-weight: 900;
  text-transform: uppercase;
}

.dbc-signal-row {
  border-top: 1px solid var(--line);
  color: #dce7f0;
  font-size: 13px;
}

.dbc-signal-row:nth-child(odd) {
  background: rgba(255, 255, 255, 0.025);
}

.dbc-signal-row strong {
  min-width: 0;
  overflow-wrap: anywhere;
}

.row-critical {
  background: rgba(255, 95, 87, 0.09) !important;
}

.row-warning {
  background: rgba(243, 200, 75, 0.08) !important;
}

.row-good {
  background: rgba(55, 215, 123, 0.045) !important;
}

.table-empty {
  grid-column: 1 / -1;
  margin: 12px;
}

.empty-state {
  color: var(--muted);
  font-size: 13px;
}

@media (max-width: 1280px) {
  .pit-header,
  .telemetry-overview,
  .command-grid {
    grid-template-columns: 1fr;
  }

  .session-strip {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .driver-metrics,
  .driver-grid,
  .telemetry-tiles,
  .subsystem-copy {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 880px) {
  .pitwall-shell {
    width: min(100vw - 18px, 1840px);
  }

  .driver-grid,
  .mini-chart-grid,
  .session-strip,
  .driver-primary,
  .driver-metrics,
  .telemetry-tiles,
  .live-feed-grid,
  .subsystem-grid,
  .subsystem-copy {
    grid-template-columns: 1fr;
  }

  .driver-card-head,
  .panel-title {
    align-items: flex-start;
    flex-direction: column;
  }

  .dbc-signal-table {
    overflow-x: auto;
  }

  .cmu-panel {
    overflow-x: auto;
  }

  .cmu-voltage-table {
    min-width: 880px;
  }

  .cmu-detail-grid {
    grid-template-columns: 1fr;
  }

  .dbc-signal-head,
  .dbc-signal-row {
    min-width: 860px;
  }
}
