/*!
 * Pit Wall Tool
 * Copyright © 2026 Yoren Muyldermans. All rights reserved.
 * Proprietary and confidential. Unauthorized use, copying, or distribution
 * is prohibited and may result in legal action. See LICENSE.
 */
:root {
  --bg: #05070a;
  --bg-elevated: #0a0e14;
  --panel: #0f141c;
  --panel-alt: #141b25;
  --panel-hi: #1a2330;
  --border: #243040;
  --border-bright: #32465c;
  --text: #eef2f7;
  --text-dim: #8a9bb0;
  --subtext: #6d7f94;
  --accent: #e10600;
  --accent-alt: #ff2a1a;
  --cyan: #00d2be;
  --success: #00c853;
  --warning: #ffb300;
  --danger: #ff3d3d;
  --row-a: #141c28;
  --row-b: #101820;
  --input-bg: #121a24;
  --input-fg: #e8edf4;
  --input-border: #2a3a4e;
  --font: "Segoe UI", system-ui, -apple-system, sans-serif;
  --mono: "Cascadia Code", "Consolas", monospace;
  --radius: 8px;
  --shadow: 0 8px 32px rgba(0, 0, 0, 0.45);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.45;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

/* MRS accent line (house blues). Was the Belgian tricolour until 2026-09-24 - BRAND.md keeps
   a flag strip opt-in for a buyer's white-label, never the default. */
.mrs-accent-bar {
  height: 3px;
  background: linear-gradient(90deg, #1d4ed8, var(--mrs-blue, #3b82f6), var(--brand-accent, #60a5fa));
  flex-shrink: 0;
}

/* Red-flag takeover — the one flag transition severe enough (session
   stopped) to earn a full-viewport moment, not just a topbar flash.
   Shown/hidden by app.js toggling .show; never blocks input beyond a
   tap-anywhere-to-dismiss, since a stopped session still needs the UI.
   Real flag red (motorsport convention), not a brand color. */
.flag-takeover {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 300;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 14px;
  background: rgba(225, 6, 0, 0.94);
  cursor: pointer;
  animation: flag-takeover-in 0.25s ease-out;
}

.flag-takeover.show {
  display: flex;
}

@keyframes flag-takeover-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

.flag-takeover-text {
  font-family: var(--mono);
  font-size: clamp(36px, 9vw, 96px);
  font-weight: 700;
  letter-spacing: 0.06em;
  color: #fff;
  text-shadow: 0 3px 12px rgba(0, 0, 0, 0.5);
  text-align: center;
}

.flag-takeover-hint {
  font-size: 13px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.75);
}

.app {
  display: grid;
  grid-template-rows: auto 1fr;
  flex: 1;
  min-height: 0;
  height: calc(100vh - 8px);
}

.boot-overlay {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  background: var(--bg);
  color: var(--text-dim);
  font-size: 13px;
  transition: opacity 0.3s;
  pointer-events: auto;
}

.boot-overlay.hidden {
  display: none !important;
  pointer-events: none !important;
  visibility: hidden;
}

.boot-spinner {
  width: 28px;
  height: 28px;
  border: 2px solid var(--border);
  border-top-color: var(--cyan);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* Top bar */
.topbar {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 10px 18px;
  background: linear-gradient(180deg, var(--panel-hi) 0%, var(--panel) 100%);
  border-bottom: 1px solid var(--border);
}

.brand {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 200px;
}

.brand h1 {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.brand .sub {
  font-size: 11px;
  color: var(--subtext);
}

.car-chips {
  display: flex;
  gap: 10px;
  flex: 1;
  flex-wrap: wrap;
}

.car-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 12px;
  background: var(--panel-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 12px;
  transition: border-color 0.2s, transform 0.15s;
}

.car-chip.active {
  border-color: var(--cyan);
  box-shadow: 0 0 0 1px rgba(0, 210, 190, 0.25);
}

.car-chip .num { font-weight: 700; color: var(--cyan); }
.car-chip .fuel { font-family: var(--mono); }
.car-chip .pos { color: var(--text-dim); min-width: 28px; }
.car-chip .tyre-warn { color: var(--danger); font-size: 11px; }
.car-chip.alert { border-color: var(--danger); animation: pulse 1.5s infinite; }

@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(255, 61, 61, 0.3); }
  50% { box-shadow: 0 0 0 4px rgba(255, 61, 61, 0); }
}

/* Telemetry-style numerals — tabular figures + slashed zero, wherever two
   numbers need to line up (lap deltas, stint durations, drive-time totals). */
.mono-num {
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum" 1, "zero" 1;
}

/* Idle vs live — dims the accent/cyan identity when no timing feed is
   connected, so the crew can tell at a glance whether the app is actually
   pulling live data (and, incidentally, whether that RaceResults
   connection is even open right now). Self-references the cascaded
   --accent/--accent-alt/--cyan (set from brand.* in white-label.config.json
   via brand-tokens.css) rather than hardcoding a dimmed color, so idle
   dimming stays correct for whatever brand a buyer configures. */
body.timing-idle {
  --accent: color-mix(in srgb, var(--accent) 45%, #1a1a1a);
  --accent-alt: color-mix(in srgb, var(--accent-alt) 45%, #1a1a1a);
  --cyan: color-mix(in srgb, var(--cyan) 45%, #1a1a1a);
}

.topbar-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

select, input, textarea, button {
  font: inherit;
  color: var(--text);
}

select, input, textarea {
  background: var(--input-bg, #121a24);
  border: 1px solid var(--input-border, #2a3a4e);
  border-radius: 4px;
  padding: 6px 10px;
  font-size: 13px;
}

.select-ctl, .input-ctl {
  appearance: auto;
  -webkit-appearance: menulist-button;
  cursor: pointer;
  pointer-events: auto;
  position: relative;
  z-index: 2;
  min-height: 32px;
  color: var(--input-fg, #e8edf4);
}

.input-ctl {
  -webkit-appearance: none;
  appearance: none;
  cursor: text;
}

select.select-ctl { padding-right: 28px; min-width: 160px; }
select.select-ctl option { background: #121a24; color: #e8edf4; }

select:focus, input:focus, textarea:focus {
  outline: none;
  border-color: var(--cyan);
  box-shadow: 0 0 0 1px rgba(0, 210, 190, 0.25);
}

button.secondary {
  background: var(--panel-alt);
  border-color: var(--border-bright);
}

button, .btn {
  cursor: pointer;
  border: 1px solid var(--border-bright);
  background: var(--panel-alt);
  color: var(--text);
  padding: 7px 14px;
  border-radius: 6px;
  transition: background 0.15s, border-color 0.15s;
}

button.btn-icon,
.btn-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 34px;
  min-height: 32px;
  padding: 6px 10px;
  font-size: 14px;
  line-height: 1;
  letter-spacing: 0;
  gap: 4px;
}

.tb-fullscreen.btn-icon,
.tb-signout.btn-icon {
  min-width: 0;
  min-height: 0;
  padding: 3px 5px;
  font-size: 12px;
}

.tele-rec-start {
  color: #fecaca;
  border-color: rgba(220, 38, 38, 0.65) !important;
  font-size: 16px;
}

.tele-rec-start.recording,
#btn-tele-record-start.recording {
  background: var(--danger, #dc2626) !important;
  border-color: var(--danger, #dc2626) !important;
  color: #fff !important;
  animation: tele-record-pulse 1.4s ease-in-out infinite;
}

.tele-rec-stop {
  font-size: 13px;
}

.tele-recordings-select {
  min-width: 180px;
  max-width: 280px;
}

button:hover, .btn:hover {
  background: var(--panel-hi);
  border-color: var(--cyan);
}

button.primary {
  background: var(--accent);
  border-color: var(--accent-alt);
  color: #fff;
  font-weight: 600;
}

button.primary:hover { background: var(--accent-alt); }

button.success { background: #0a6e3a; border-color: var(--success); }
button.success.connected-active { background: var(--cyan, #0a9e8e); border-color: var(--cyan, #0a9e8e); opacity: 0.92; }
button.success:disabled { opacity: 0.55; cursor: not-allowed; }
button.danger { background: #6e1a1a; border-color: var(--danger); }

/* Tabs — base; race topbar grid styled in topbar.css */
.tabbar {
  display: flex;
  justify-content: center;
  flex-wrap: nowrap;
  gap: 4px;
  padding: 0;
  background: transparent;
  border: none;
  overflow-x: auto;
  scrollbar-width: thin;
}

.tab {
  flex-shrink: 0;
  padding: 10px 16px;
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-dim);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  border-radius: 0;
}

.tab:focus-visible {
  outline: 2px solid var(--cyan);
  outline-offset: -2px;
}

/* Legacy class — sign out now lives in .tb-signout (top bar) */
.tab-signout { display: none; }

/* Ownership watermark — © Yoren Muyldermans. Do not remove. */
.copyright-footer {
  flex: 0 0 auto;
  align-self: stretch;
  margin-top: 12px;
  padding: 4px var(--shell-pad-x, 16px) 8px;
  text-align: right;
  font-size: 10px;
  line-height: 1;
  letter-spacing: 0.04em;
  color: rgba(255, 255, 255, 0.3);
  pointer-events: none;
  user-select: none;
  white-space: nowrap;
}

/* Main content — scroll handled in layout.css */
.main {
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  position: relative;
  flex: 1;
  display: flex;
  flex-direction: column;
  -webkit-overflow-scrolling: touch;
}

.panel {
  display: none;
  flex: 1 0 auto;
  min-height: 100%;
  flex-direction: column;
  overflow-x: hidden;
  overflow-y: visible;
  padding: 12px 16px;
  animation: fadeIn 0.2s ease;
}

.panel.active { display: flex; }

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: none; }
}

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }

@media (max-width: 1100px) {
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
}

.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
  margin-bottom: 8px;
}

.toolbar-card, .source-card { padding: 8px 12px; }

.card h2, .card h3 {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-dim);
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}

.field-row {
  display: grid;
  grid-template-columns: 140px 1fr;
  gap: 10px;
  align-items: center;
  margin-bottom: 10px;
}

.field-row label { color: var(--text-dim); font-size: 12px; }
.field-row.block { flex-direction: column; align-items: stretch; gap: 6px; }
.field-row.block textarea { width: 100%; min-height: 72px; resize: vertical; }
.wk-comments { display: block; margin-top: 10px; }
.wk-comments span { display: block; margin-bottom: 6px; color: var(--text-dim); font-size: 12px; }

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
  align-items: center;
}

.hint { font-size: 12px; color: var(--subtext); margin-top: 8px; }

/* Tables */
.table-wrap {
  overflow: auto;
  max-height: none;
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

table.data {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}

table.data th {
  position: sticky;
  top: 0;
  background: var(--panel-hi);
  text-align: left;
  padding: 8px 10px;
  color: var(--text-dim);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  border-bottom: 1px solid var(--border);
  z-index: 1;
}

table.data td {
  padding: 7px 10px;
  border-bottom: 1px solid var(--border);
}

table.timing-data { font-family: var(--mono); font-size: 13px; }
table.timing-data th {
  font-family: var(--font);
  font-size: 11px;
  color: var(--cyan);
}
table.timing-data td { padding: 8px 6px; height: 34px; }
table.timing-data td:nth-child(3) { text-align: left; max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
table.timing-data td:not(:nth-child(3)) { text-align: center; }

.timing-sheet { max-height: none; flex: 1; }
.log-card { max-height: 220px; }
.timing-side .leaderboard { flex: 1; display: flex; flex-direction: column; min-height: 0; }

table.data tr:nth-child(even) td { background: var(--row-b); }
table.data tr:nth-child(odd) td { background: var(--row-a); }
table.data tr:hover td { background: var(--panel-hi); }
table.data tr.selected td { outline: 1px solid var(--cyan); }
table.data tr.follow td { background: rgba(0, 210, 190, 0.12) !important; }
table.data tr.team td { color: var(--cyan); }

/* V5 toolbar rows */
.v5-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 16px;
  align-items: flex-end;
}

.tb-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.tb-field.block { width: 100%; margin-top: 8px; }
.tb-field span {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.tb-field.wide { flex: 1; min-width: 220px; }
.tb-field.narrow { width: 90px; }
.tb-field .full { width: 100%; }

.tb-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  margin-left: auto;
}

/* Connection status (Live Timing "Live"/"Stopped", Telemetry "Live"/
   "Reconnecting…") — was a plain dim-gray label with only a tiny dot
   carrying color; now a colored chip: bright green background tint +
   border when actually connected, neutral otherwise. Pure CSS via :has(),
   so setStatus()/statusDotHtml() (ui-helpers.js) need no change. */
.tb-status {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  font-weight: 700;
  color: var(--subtext);
  padding: 3px 9px 3px 8px;
  margin-left: 8px;
  border: 1px solid var(--border);
}

.tb-status:has(.status-dot.live) {
  color: var(--success);
  border-color: rgba(0, 200, 83, 0.4);
  background: rgba(0, 200, 83, 0.08);
}

.mono-lg {
  font-family: var(--mono);
  font-size: 18px;
  font-weight: 700;
}

.mono-lg.green { color: var(--success); }

.session-header {
  display: grid;
  grid-template-columns: 1fr 2fr 1fr;
  align-items: center;
  gap: 8px;
  padding: 4px 6px 8px;
}

.session-center {
  text-align: center;
  font-size: 12px;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.session-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  margin-bottom: 8px;
  font-size: 11px;
}

/* Live timing layout */
.timing-layout {
  display: grid;
  grid-template-columns: 3fr 2fr;
  gap: 8px;
  height: calc(100vh - 130px);
  min-height: 520px;
}

.timing-main {
  display: flex;
  flex-direction: column;
  min-height: 0;
  gap: 0;
}

.map-card {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  margin-bottom: 0;
}

.temps {
  color: var(--cyan);
  font-family: var(--mono);
  font-size: 11px;
}

.weather-line {
  color: var(--subtext);
  font-size: 11px;
  flex: 1;
  min-width: 120px;
}

.mode-badge {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 3px 8px;
  border-radius: 4px;
  background: var(--panel-hi);
  border: 1px solid var(--border);
  color: var(--subtext);
}

.mode-badge.live { color: var(--cyan); border-color: rgba(0,210,190,0.35); }

.chk { font-size: 12px; color: var(--text-dim); display: inline-flex; align-items: center; gap: 6px; }

.flag-pill {
  padding: 4px 10px;
  border-radius: 4px;
  font-weight: 700;
  font-size: 11px;
  letter-spacing: 0.05em;
}

#track-canvas, #weekend-map {
  flex: 1;
  width: 100%;
  min-height: 360px;
  background: var(--panel-alt);
  border: 1px solid var(--border);
  border-radius: 4px;
  pointer-events: auto;
}

.timing-side {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 0;
}

.leaderboard {
  flex: 1;
  min-height: 0;
}

.log-feed {
  max-height: 200px;
  overflow-y: auto;
  font-family: var(--mono);
  font-size: 11px;
}

.log-line { padding: 4px 0; border-bottom: 1px solid var(--border); }
.log-line.our_car { color: var(--cyan); }
.log-line.flag_yellow { color: var(--warning); }
.log-line.flag_green { color: var(--success); }

/* Telemetry */
.tele-channels-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 10px 16px;
  margin-bottom: 12px;
}

.tele-channels-head h2 {
  margin: 0 0 2px;
}

.tele-record-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.tele-record-status {
  font-size: 12px;
  color: var(--text-dim);
}

#btn-tele-record.recording {
  background: var(--danger, #dc2626);
  border-color: var(--danger, #dc2626);
  color: #fff;
  animation: tele-record-pulse 1.4s ease-in-out infinite;
}

@keyframes tele-record-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(220, 38, 38, 0.45); }
  50% { box-shadow: 0 0 0 6px rgba(220, 38, 38, 0); }
}

.tele-perf {
  display: flex;
  flex-direction: column;
  gap: 14px;
  align-items: stretch;
  min-height: 0;
}

.tele-perf-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  overflow: visible;
  max-height: none;
  padding-right: 0;
}

.tele-channel {
  display: block;
  width: 100%;
  text-align: left;
  background: #121212;
  border: 2px solid var(--border-bright);
  border-radius: 8px;
  padding: 14px 16px 12px;
  cursor: pointer;
  color: inherit;
  transition: border-color 0.15s, background 0.15s;
  min-height: 118px;
}

.tele-channel:hover {
  border-color: rgba(255, 255, 255, 0.28);
  background: #171717;
}

.tele-channel.selected {
  border-color: #3dff8a;
  box-shadow: none;
  background: #141a16;
}

.tele-channel.pressure-low {
  border-color: var(--warning);
  background: rgba(255, 179, 0, 0.1);
}

.tele-channel.alert {
  border-color: var(--danger);
  background: rgba(255, 112, 112, 0.12);
}

.tele-ch-top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
}

.tele-channel .label {
  font-size: 11px;
  text-transform: uppercase;
  color: var(--subtext);
  letter-spacing: 0.06em;
}

.tele-channel .value {
  font-family: var(--mono);
  font-size: 28px;
  font-weight: 700;
  color: var(--text);
  line-height: 1;
  transition: color 0.15s;
}

.tele-channel.flash .value { color: var(--warning); }
.tele-channel.alert .value { color: var(--danger); }

.tele-spark {
  display: block;
  width: 100%;
  height: 52px;
}

.tele-perf-detail {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
  min-height: 0;
  background: #0d0d0d;
  border: 1px solid var(--border-bright);
  border-radius: 8px;
  padding: 10px 12px 12px;
}

.tele-detail-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.tele-detail-kicker {
  margin: 0;
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-dim);
}

.tele-detail-head h3 {
  margin: 2px 0 0;
  font-size: 16px;
  font-weight: 800;
  color: var(--text);
}

.tele-detail-live {
  font-family: var(--mono);
  font-size: 22px;
  font-weight: 700;
  color: #3dff8a;
  line-height: 1;
}

.tele-detail-chart-wrap {
  flex: 0 0 auto;
  height: 140px;
  min-height: 140px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 6px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.02), transparent 40%),
    #090909;
  overflow: hidden;
}

#tele-detail-chart {
  display: block;
  width: 100%;
  height: 100%;
  min-height: 140px;
}

.tele-detail-stats {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 8px;
}

.tele-stat {
  background: #141414;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 6px;
  padding: 6px 8px;
}

.tele-stat span {
  display: block;
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-dim);
  margin-bottom: 2px;
}

.tele-stat strong {
  font-family: var(--mono);
  font-size: 14px;
  color: var(--text);
}

.tele-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  padding: 8px 10px;
  background: var(--panel-alt);
  border-radius: 6px;
  font-size: 12px;
}

.tele-stats .stat strong {
  font-family: var(--mono);
  color: var(--cyan);
  margin-left: 6px;
}

.tele-foot { margin-top: 12px; }
.channels-card { margin-top: 0; }

.tele-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}

@media (max-width: 1100px) {
  .tele-perf {
    min-height: 0;
  }

  .tele-perf-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .tele-detail-chart-wrap,
  #tele-detail-chart {
    height: 120px;
    min-height: 120px;
  }

  .tele-detail-stats {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 900px) {
  .tele-grid { grid-template-columns: repeat(2, 1fr); }
  .tele-perf-list { grid-template-columns: 1fr; }
  .tele-channel { min-height: 100px; }
  .tele-channel .value { font-size: 24px; }
  .tele-detail-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

.section-label {
  margin-top: 16px;
  color: var(--text-dim);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.tyre-car {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  grid-template-rows: auto auto auto;
  gap: 8px;
  max-width: 280px;
  margin-top: 10px;
}

.tyre-corner {
  padding: 10px;
  background: var(--panel-alt);
  border-radius: 6px;
  text-align: center;
  border: 1px solid var(--border);
}

.tyre-corner.fl { grid-column: 1; grid-row: 1; }
.tyre-corner.fr { grid-column: 3; grid-row: 1; }
.tyre-corner.rl { grid-column: 1; grid-row: 3; }
.tyre-corner.rr { grid-column: 3; grid-row: 3; }
.tyre-car::after {
  content: "CAR";
  grid-column: 2;
  grid-row: 2;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  color: var(--subtext);
  letter-spacing: 0.2em;
  border: 1px dashed var(--border);
  border-radius: 6px;
  min-height: 48px;
}

.tyre-corner.low { border-color: var(--danger); background: rgba(255, 61, 61, 0.12); animation: pulse 2s infinite; }

/* Fuel chart */
#fuel-chart-wrap { height: 220px; margin-top: 12px; }

/* M2 guide */
.guide-section { margin-bottom: 16px; }
.guide-section h4 { color: var(--cyan); margin-bottom: 6px; font-size: 13px; }
.guide-section ul { padding-left: 18px; color: var(--text-dim); }
.guide-section li { margin-bottom: 4px; }

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
  margin-right: 6px;
}
.status-dot.live { background: var(--success); box-shadow: 0 0 6px var(--success); }
.status-dot.off { background: var(--subtext); }

/* Global scrollbar theme — was only ever applied to a handful of named
   containers (.table-wrap/.log-feed/.panel/.tabbar), and never defined a
   track color at all, so anything else scrollable (the Data viewer's
   session list, modal bodies, form panels, ...) fell back to the browser's
   default light/white scrollbar against a dark app. Universal selector so
   nothing is missed again. */
* {
  scrollbar-width: thin;
  scrollbar-color: var(--border-bright) var(--panel-hi);
}

*::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

*::-webkit-scrollbar-track {
  background: var(--panel-hi);
}

*::-webkit-scrollbar-thumb {
  background: var(--border-bright);
  border-radius: 4px;
}

*::-webkit-scrollbar-thumb:hover {
  background: var(--accent-muted);
}

*::-webkit-scrollbar-corner {
  background: var(--panel-hi);
}

.toast {
  display: none;
  position: fixed;
  bottom: 20px;
  right: 20px;
  padding: 10px 16px;
  background: var(--panel-hi);
  border: 1px solid var(--border-bright);
  border-radius: 8px;
  box-shadow: var(--shadow);
  z-index: 100;
  animation: fadeIn 0.2s;
}

.toast.is-visible {
  display: block;
}

.bridge-modal,
.app-modal {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 200;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.55);
  padding: 16px;
}

.bridge-modal.open,
.app-modal.open {
  display: flex;
}

.bridge-modal-card,
.app-modal-card {
  width: min(420px, 100%);
  background: var(--panel-hi);
  border: 1px solid var(--border-bright);
  border-radius: 12px;
  box-shadow: var(--shadow);
  padding: 20px 22px;
}

.bridge-modal-card h3,
.app-modal-card h3 {
  margin: 0 0 10px;
  font-size: 1.05rem;
}

.bridge-modal-card p,
.app-modal-card p {
  margin: 0 0 18px;
  color: var(--text-muted);
  line-height: 1.45;
  font-size: 0.92rem;
  white-space: pre-line;
}

.bridge-modal-actions,
.app-modal-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}

.password-modal-hint {
  margin: 0 0 12px;
  font-size: 0.85rem;
  color: var(--text-dim);
  line-height: 1.45;
}

#password-change-form .login-field {
  margin-bottom: 12px;
}

#password-change-form .login-field:last-of-type {
  margin-bottom: 16px;
}

#password-change-form .login-field input {
  width: 100%;
  box-sizing: border-box;
  margin-top: 4px;
  padding: 8px 10px;
}

.app-modal-card.is-success h3 {
  color: var(--accent);
}

.app-modal-card.is-error h3 {
  color: #e07070;
}

.app-modal-card.is-warn h3 {
  color: #e8952a;
}

.input-with-btn {
  display: flex;
  gap: 6px;
  align-items: center;
  width: 100%;
}

.input-with-btn .input-ctl {
  flex: 1;
  min-width: 0;
}

.btn-field-today {
  flex-shrink: 0;
  padding: 5px 10px;
  font-size: 0.72rem;
  white-space: nowrap;
}

.form-row .input-with-btn,
.form-cell .input-with-btn {
  flex: 1;
}

/* ── Next-step save banner ── */
.form-next-step {
  margin-top: 8px;
}
.form-next-step-btn {
  width: 100%;
  font-weight: 600;
  letter-spacing: 0.02em;
}

/* ── Form card title note ── */
.form-card-title-note {
  font-size: 0.72rem;
  font-weight: 400;
  color: var(--text-dim);
  margin-left: 8px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

/* ── Pit stop pressure section ── */
.pit-pressure-head {
  margin-top: 14px;
}
.pit-pressure-input {
  width: 64px;
}
.pit-pressures-cell {
  font-family: var(--mono);
  font-size: 0.78rem;
  white-space: nowrap;
}
.pit-fuel-link {
  margin-top: 10px;
}
.pit-fuel-link-btn {
  width: 100%;
}

/* ── Fuel pit-window predictor ── */
.fuel-pit-window {
  margin-top: 8px;
  padding: 8px 12px;
  background: var(--panel-alt);
  border: 1px solid var(--border-bright);
  border-radius: 6px;
  font-size: 0.88rem;
  color: var(--text);
}
.fuel-pit-window strong {
  color: var(--warning);
}

/* ── Lap time trend chart ── */
.laptime-chart-wrap {
  margin-top: 14px;
}
.laptime-chart-head {
  margin-bottom: 6px;
  font-size: 0.82rem;
}
#laptime-chart {
  width: 100%;
}

/* ── Drive time tracker ── */
.drv-tracker-min-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
  font-size: 0.85rem;
  color: var(--text-dim);
}
.drv-tracker-min-inp {
  width: 90px;
}
.drv-tracker-content {
  overflow-x: auto;
}
.drv-tracker-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.84rem;
}
.drv-tracker-table th {
  text-align: left;
  padding: 4px 8px;
  border-bottom: 1px solid var(--border);
  color: var(--text-dim);
  font-weight: 500;
}
.drv-tracker-table td {
  padding: 5px 8px;
  border-bottom: 1px solid var(--border);
}
.drv-tracker-ok td:first-child { color: var(--success); }
.drv-tracker-warn td:first-child { color: var(--danger); }
/* Native <progress> — its fill renders through the CSS engine (pseudo-
   elements below), not a JS-set inline style, so it isn't affected by the
   CSP (style-src 'self') the way a hand-rolled width-percent div was. */
.drv-tracker-bar {
  -webkit-appearance: none;
  appearance: none;
  width: 80px;
  height: 8px;
  border: none;
  border-radius: 4px;
  overflow: hidden;
  background: var(--bg-elevated);
}
.drv-tracker-bar::-webkit-progress-bar {
  background: var(--bg-elevated);
}
.drv-tracker-bar::-webkit-progress-value {
  background: var(--success);
  border-radius: 4px;
  transition: width 0.3s;
}
.drv-tracker-bar::-moz-progress-bar {
  background: var(--success);
  border-radius: 4px;
}
.drv-tracker-bar.warn::-webkit-progress-value {
  background: var(--danger);
}
.drv-tracker-bar.warn::-moz-progress-bar {
  background: var(--danger);
}

/* ── Quick stint timer ── */
.drv-timer-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.drv-timer-sel {
  flex: 1;
  min-width: 120px;
}
.drv-timer-display {
  font-family: var(--mono);
  font-size: 2rem;
  font-weight: 700;
  color: var(--text-dim);
  letter-spacing: 0.06em;
  padding: 8px 0 0;
  transition: color 0.3s;
}
.drv-timer-display.drv-timer-active {
  color: var(--cyan);
}

/* ── public demo mode ──────────────────────────────────────────────────── */

#demo-badge {
  position: fixed;
  top: 8px;
  right: 8px;
  z-index: 190; /* above app content, below the consent modal at 200 */
  background: rgba(232, 149, 42, 0.16);
  border: 1px solid #e8952a;
  color: #e8952a;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.02em;
  padding: 5px 10px;
  border-radius: 999px;
  pointer-events: auto;
}
#demo-badge a {
  color: inherit;
  text-decoration: underline;
}

@media (max-width: 640px) {
  #demo-badge {
    top: auto;
    bottom: 8px;
    left: 8px;
    right: 8px;
    text-align: center;
  }
}
