:root {
  --bg: #090b10;
  --panel: #10151c;
  --line: #273140;
  --text: #e7eef7;
  --muted: #93a0b3;
  --faint: #6d7b8e;
  --red: #e10600;
  --ok: #3dd68c;
  --purple: #d7b4ff;
  color-scheme: dark;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: "IBM Plex Sans", "Segoe UI", sans-serif;
  font-size: 14px;
}

button, select { font: inherit; color: inherit; }

.top {
  height: 64px;
  display: flex;
  align-items: center;
  gap: 28px;
  padding: 0 18px;
  background: #0c1016;
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 30;
}

.brand { display: flex; align-items: center; gap: 10px; min-width: 180px; }
.brand strong {
  display: block;
  font-family: "Barlow Condensed", sans-serif;
  font-size: 28px;
  letter-spacing: .14em;
  line-height: .9;
}
.brand small {
  color: var(--faint);
  letter-spacing: .16em;
  font-size: 10px;
}
.mark { width: 12px; height: 32px; background: var(--red); }

.session-title { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.session-title span:first-child {
  font-family: "Barlow Condensed", sans-serif;
  font-size: 26px;
  letter-spacing: .04em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.session-title span:last-child { color: var(--muted); font-size: 13px; }

.top-meta { display: flex; align-items: center; gap: 12px; color: var(--muted); font-family: "IBM Plex Mono", monospace; }
.dot { width: 10px; height: 10px; border-radius: 50%; background: #4b5568; box-shadow: 0 0 0 4px rgba(75, 85, 104, .25); }
.dot.live { background: var(--ok); box-shadow: 0 0 0 4px rgba(61, 214, 140, .18); }
.dot.wait { background: #f0c14a; box-shadow: 0 0 0 4px rgba(240, 193, 74, .18); }
.dot.off { background: var(--red); }

.shell { display: grid; grid-template-columns: 300px minmax(0, 1fr); align-items: start; }

aside {
  position: sticky;
  top: 64px;
  height: calc(100vh - 64px);
  overflow: auto;
  padding: 16px;
  background: #0c1016;
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 6px;
}

aside label {
  margin-top: 10px;
  color: var(--faint);
  font-size: 11px;
  letter-spacing: .12em;
  text-transform: uppercase;
}

select, .primary {
  width: 100%;
  background: #121820;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px 10px;
}

.primary {
  margin-top: 14px;
  background: var(--red);
  border-color: #9d120e;
  font-weight: 600;
  cursor: pointer;
}
.primary:hover { filter: brightness(1.08); }

.segment { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.segment button, .session-grid button {
  background: #121820;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px;
  cursor: pointer;
}
.segment button.active, .session-grid button.active {
  border-color: var(--red);
  background: #221416;
}

.session-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.session-grid button { text-align: left; }
.session-grid strong { display: block; font-family: "Barlow Condensed", sans-serif; font-size: 18px; letter-spacing: .06em; }
.session-grid small { color: var(--faint); }

.aside-note, .note, footer {
  color: var(--faint);
  font-size: 12px;
  line-height: 1.45;
}
.aside-note { margin: 12px 0 0; }
.note { margin: 0; padding: 8px 12px 12px; }
footer { padding: 4px 2px 18px; }

main { padding: 14px; display: flex; flex-direction: column; gap: 12px; min-width: 0; }

.panel {
  background: rgba(16, 21, 28, .94);
  border: 1px solid var(--line);
  border-radius: 8px;
  min-width: 0;
}
.panel h2 {
  margin: 0;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  font-family: "Barlow Condensed", sans-serif;
  font-size: 16px;
  letter-spacing: .12em;
  font-weight: 600;
  color: var(--muted);
  display: flex;
  justify-content: space-between;
  gap: 12px;
}
.panel h2 span { color: var(--faint); letter-spacing: .04em; font-family: "IBM Plex Sans", sans-serif; font-size: 12px; font-weight: 400; }

.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(128px, 1fr)); gap: 8px; }
.kpi { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; min-width: 0; }
.kpi span { display: block; color: var(--faint); font-size: 10px; letter-spacing: .1em; text-transform: uppercase; }
.kpi strong { display: block; margin-top: 2px; font-family: "IBM Plex Mono", monospace; font-size: 18px; font-weight: 500; }
.kpi em { font-style: normal; color: var(--muted); font-size: 11px; }

.grid-2 { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(280px, .75fr); gap: 12px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }

canvas { width: 100%; display: block; }
canvas.mid { height: 280px; }
canvas.tall { height: 420px; }
canvas.map { height: 460px; }
#strategyChart { height: 280px; }

.scroll { overflow: auto; max-height: 540px; }
.scroll.short { max-height: 320px; }

table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
th, td { padding: 6px 8px; border-bottom: 1px solid #1d2632; white-space: nowrap; }
th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #151b24;
  color: var(--faint);
  font-size: 10px;
  font-weight: 500;
  letter-spacing: .08em;
  text-transform: uppercase;
  text-align: left;
}
td.num, th.num { text-align: right; font-family: "IBM Plex Mono", monospace; }
tbody tr { cursor: pointer; }
tbody tr:hover { background: rgba(255, 255, 255, .03); }
tbody tr.selected { background: rgba(225, 6, 0, .1); }
.best { color: var(--purple); }
.own { color: var(--ok); }
.muted { color: var(--faint); }
.warn { color: #f0c14a; }

.who { display: flex; align-items: center; gap: 8px; }
.plate {
  min-width: 28px;
  height: 22px;
  padding: 0 4px;
  display: inline-grid;
  place-items: center;
  border-radius: 3px;
  font-family: "Barlow Condensed", sans-serif;
  font-weight: 700;
  color: white;
}
.pill {
  display: inline-block;
  min-width: 52px;
  text-align: center;
  padding: 1px 6px;
  border-radius: 99px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .04em;
}

.banner { padding: 10px 12px; border-radius: 8px; border: 1px solid #34512f; background: #132016; color: #d5efd0; }
.banner.error { border-color: #6d3030; background: #241416; color: #ffd4d4; }
.banner button { margin-left: 8px; background: transparent; border: 1px solid currentColor; border-radius: 99px; padding: 2px 8px; cursor: pointer; }

.live-head, .chips { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.live-head { padding: 12px; border-bottom: 1px solid var(--line); justify-content: space-between; }
.live-grid { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(240px, .6fr); }
.badge { font-family: "Barlow Condensed", sans-serif; letter-spacing: .14em; padding: 2px 8px; border-radius: 99px; background: #222; }
.badge.live { background: var(--ok); color: #062214; }
.badge.closed { background: #f0c14a; color: #241c08; }
.chip { border: 1px solid var(--line); border-radius: 99px; padding: 3px 8px; color: var(--muted); font-family: "IBM Plex Mono", monospace; font-size: 12px; }

.gauges { display: grid; grid-template-columns: 120px 1fr; gap: 10px; padding: 12px; }
.speed { font-family: "IBM Plex Mono", monospace; font-size: 42px; line-height: .9; }
.speed small { display: block; color: var(--faint); font-size: 12px; letter-spacing: .08em; }
.gear {
  margin-top: 8px;
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  font-family: "Barlow Condensed", sans-serif;
  font-size: 32px;
}
.bar { height: 8px; background: #1c2430; border-radius: 99px; margin-top: 8px; overflow: hidden; }
.bar i { display: block; height: 100%; width: 0; background: var(--ok); }
.bar.brake i { background: var(--red); }
.bar-label { display: flex; justify-content: space-between; color: var(--faint); font-size: 11px; margin-top: 8px; }
#liveMap { height: 220px; }

.car { display: grid; grid-template-columns: 88px 1fr; gap: 12px; padding: 12px; }
.car img { width: 88px; height: 88px; object-fit: cover; border-radius: 6px; background: #1a212b; }
.car h3 { margin: 0; font-family: "Barlow Condensed", sans-serif; font-size: 28px; letter-spacing: .04em; }
.car p { margin: 4px 0; color: var(--muted); }
.facts { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 12px; margin-top: 8px; }
.facts div span { display: block; color: var(--faint); font-size: 10px; letter-spacing: .08em; text-transform: uppercase; }
.facts strong { font-family: "IBM Plex Mono", monospace; font-weight: 500; }
.msg { padding: 8px 12px; border-bottom: 1px solid #1d2632; }
.msg b { color: var(--muted); font-weight: 500; margin-right: 6px; }
.empty { padding: 18px 12px; color: var(--faint); }

.tip {
  position: fixed;
  z-index: 50;
  max-width: 280px;
  padding: 6px 8px;
  border-radius: 6px;
  background: #07090d;
  border: 1px solid var(--line);
  color: var(--text);
  font-family: "IBM Plex Mono", monospace;
  font-size: 12px;
  pointer-events: none;
  white-space: pre-line;
}

@media (max-width: 1100px) {
  .shell, .grid-2, .grid-3, .live-grid, .car { grid-template-columns: 1fr; }
  aside { position: relative; top: 0; height: auto; }
  .top { height: auto; flex-wrap: wrap; padding: 12px; }
}
