/* ============================================================
   MF TELEMETRY HUB — Dark industrial telemetry theme
   Honors VisualData's lineage (black bg, green data, red bests)
   while modernizing typography, spacing, motion.
   ============================================================ */

:root {
  /* Surface palette — near-black with a slight cyan/green tint */
  --bg-0: #07090a;
  --bg-1: #0d1112;
  --bg-2: #131819;
  --bg-3: #1a2123;
  --bg-hover: #1f2729;
  --border: #1f2628;
  --border-strong: #2a3437;

  /* Text */
  --text: #e6ece8;
  --text-dim: #8a9994;
  --text-faint: #5a6764;

  /* Accents — racing telemetry palette */
  --accent: #00ff8c;     /* electric green: primary data */
  --accent-soft: #00bd6b;
  --best:   #ff3656;     /* hot red: 'best of column' / fastest */
  --warn:   #ffaa1a;     /* amber: pit / theoretical */
  --info:   #59c8ff;     /* cyan: secondary chart series */

  /* Channel colors for charts */
  --ch-rpm:    #ff3656;
  --ch-speed:  #00ff8c;
  --ch-gf-lon: #ffaa1a;
  --ch-gf-lat: #59c8ff;
  --ch-pulse:  #b08aff;

  /* Typography */
  --font-display: "Bebas Neue", Impact, sans-serif;
  --font-mono:    "IBM Plex Mono", ui-monospace, "Courier New", monospace;
  --font-sans:    "IBM Plex Sans", system-ui, sans-serif;

  --radius-s: 4px;
  --radius:   8px;
  --shadow-1: 0 1px 0 0 rgba(255,255,255,0.02), 0 0 0 1px var(--border);
  --shadow-2: 0 8px 24px rgba(0,0,0,0.5), 0 0 0 1px var(--border);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font-sans);
  background: var(--bg-0);
  color: var(--text);
  /* subtle CRT-ish grain via SVG noise + faint horizontal scanlines */
  background-image:
    repeating-linear-gradient(0deg, rgba(255,255,255,0.012) 0 1px, transparent 1px 3px),
    radial-gradient(1200px 600px at 70% -10%, rgba(0,255,140,0.04), transparent 60%),
    radial-gradient(900px 600px at 0% 100%, rgba(89,200,255,0.03), transparent 60%);
  font-size: 14px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  overflow: hidden; /* layout owns the scrolling */
}

/* ----- Top bar ------------------------------------------------ */
.topbar {
  height: 56px;
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 0 20px;
  background: linear-gradient(180deg, var(--bg-2), var(--bg-1));
  border-bottom: 1px solid var(--border);
  position: relative;
  z-index: 5;
}
.brand {
  display: flex; align-items: center;
  user-select: none;
  text-decoration: none;
  flex-shrink: 0;
}
.brand-logo {
  display: block;
  height: 40px;        /* leave a few px of breathing room above/below within the 56px topbar */
  width: auto;
  object-fit: contain;
}
/* Older brand text fallbacks — kept around in case any other view re-uses them */
.brand-mark {
  color: var(--accent);
  font-size: 14px;
  text-shadow: 0 0 10px var(--accent);
}
.brand-name {
  font-family: var(--font-display);
  font-size: 26px;
  letter-spacing: 0.08em;
  color: var(--text);
}
.brand-sub {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.18em;
  color: var(--text-dim);
}
.file-info {
  flex: 1;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.file-info-empty { opacity: 0.55; font-style: italic; }
.file-info b { color: var(--accent); font-weight: 500; }
.file-info .file-stat {
  display: inline-block;
  padding: 2px 7px;
  margin-left: 8px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-s);
  background: var(--bg-3);
  color: var(--text);
}
.topbar-actions { display: flex; gap: 8px; }

/* Multi-lap compare CTA — sits in the topbar, lights up when ≥2 laps are selected */
.compare-cta {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 8px;
  background: var(--bg-1);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-s);
  margin-right: 8px;
}
.compare-cta[hidden] { display: none; }
.compare-cta-dots {
  display: inline-flex;
  gap: 3px;
  align-items: center;
  padding-right: 4px;
  border-right: 1px solid var(--border-strong);
}
.compare-cta-dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  display: inline-block;
  box-shadow: 0 0 0 1px rgba(0,0,0,0.5);
}
.compare-cta-btn { padding: 5px 11px; font-size: 12px; }
.compare-cta-clear {
  padding: 4px 8px;
  font-size: 14px;
  line-height: 1;
  font-weight: 700;
  color: var(--text-dim);
}
.compare-cta-clear:hover:not(:disabled) { color: var(--best); border-color: var(--best); }

.btn {
  font-family: var(--font-sans);
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  background: var(--bg-3);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-s);
  padding: 7px 13px;
  cursor: pointer;
  display: inline-flex; align-items: center; gap: 6px;
  transition: background 120ms ease, border-color 120ms ease, color 120ms ease;
}
.btn:hover:not(:disabled) { background: var(--bg-hover); border-color: var(--accent-soft); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }
.btn-primary { background: var(--accent-soft); border-color: var(--accent-soft); color: #00120a; font-weight: 600; }
.btn-primary:hover:not(:disabled) { background: var(--accent); border-color: var(--accent); }
.btn-ic { font-size: 14px; line-height: 1; }
.btn-sm { padding: 4px 9px; font-size: 12px; }

/* ----- Layout ------------------------------------------------- */
.layout {
  display: grid;
  grid-template-columns: 280px 1fr;
  height: calc(100vh - 56px - 24px);
}

.sidebar {
  background: var(--bg-1);
  border-right: 1px solid var(--border);
  overflow-y: auto;
  padding: 14px 0;
}
.sidebar-section { padding: 8px 14px 16px; }
.sidebar-h {
  font-family: var(--font-display);
  font-size: 13px;
  letter-spacing: 0.18em;
  color: var(--text-dim);
  margin: 6px 4px 10px;
  font-weight: 400;
}

.outs-list { list-style: none; margin: 0; padding: 0; }
.out-item {
  margin-bottom: 4px;
  border-radius: var(--radius-s);
  overflow: hidden;
}
.out-header {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 10px;
  cursor: pointer;
  border-radius: var(--radius-s);
  background: var(--bg-2);
  border: 1px solid var(--border);
  transition: background 120ms;
}
.out-header:hover { background: var(--bg-hover); }
.out-header.active {
  background: linear-gradient(90deg, rgba(0,255,140,0.10), transparent 60%);
  border-color: var(--accent-soft);
}
.out-name {
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  flex: 1;
}
.out-stats {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-dim);
}
.out-best { color: var(--best); }

.lap-sublist { list-style: none; margin: 4px 0 8px; padding: 0 0 0 12px; }
.lap-sub-item {
  display: flex; align-items: center; gap: 6px;
  font-family: var(--font-mono);
  font-size: 12px;
  padding: 4px 8px;
  cursor: pointer;
  color: var(--text-dim);
  border-left: 2px solid transparent;
  transition: color 100ms, border-color 100ms;
}
.lap-sub-item:hover { color: var(--text); border-left-color: var(--accent-soft); }
.lap-sub-item.active { color: var(--accent); border-left-color: var(--accent); }
.lap-sub-item.pit { color: var(--warn); }
.lap-sub-num { width: 24px; text-align: right; opacity: 0.7; }

.meta-dl { margin: 0; font-family: var(--font-mono); font-size: 11px; }
.meta-dl dt { color: var(--text-faint); margin-top: 6px; }
.meta-dl dd { margin: 0; color: var(--text); }

/* ----- Main content ------------------------------------------ */
.content { overflow-y: auto; padding: 0; position: relative; }

/* drop zone (empty state) */
.dropzone {
  height: 100%;
  display: flex; align-items: center; justify-content: center;
  background:
    radial-gradient(800px 500px at 50% 50%, rgba(0,255,140,0.04), transparent 70%),
    var(--bg-0);
  border: 2px dashed transparent;
  transition: background 200ms, border-color 200ms;
}
.dropzone.dragover {
  border-color: var(--accent);
  background:
    radial-gradient(800px 500px at 50% 50%, rgba(0,255,140,0.10), transparent 70%),
    var(--bg-0);
}
.dropzone-inner { text-align: center; max-width: 460px; padding: 40px; }
.dropzone-icon {
  font-size: 80px;
  color: var(--accent);
  text-shadow: 0 0 30px rgba(0,255,140,0.5);
  margin-bottom: 24px;
  animation: pulse 2.4s ease-in-out infinite;
}
@keyframes pulse {
  0%, 100% { opacity: 0.6; transform: scale(1); }
  50% { opacity: 1; transform: scale(1.04); }
}
.dropzone-title {
  font-family: var(--font-display);
  font-size: 56px;
  letter-spacing: 0.04em;
  margin: 0 0 10px;
  color: var(--text);
}
.dropzone-sub { color: var(--text-dim); font-size: 16px; margin: 0 0 24px; }
.dropzone-sub em { color: var(--accent); font-style: normal; font-weight: 500; }
.dropzone-hint {
  color: var(--text-faint); font-size: 12px; line-height: 1.6;
  font-family: var(--font-mono);
}

/* Out detail (lap table) ------------------------------------- */
.out-view { padding: 20px 24px 60px; }
.out-view-header {
  display: flex; align-items: baseline; gap: 16px;
  margin-bottom: 18px;
}
.out-view-title {
  font-family: var(--font-display);
  font-size: 32px;
  letter-spacing: 0.06em;
  margin: 0;
  color: var(--text);
}
.out-view-sub {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-dim);
}
.out-view-sub b { color: var(--accent); font-weight: 500; }

/* Lap table — replicates VisualData layout */
.lap-table-wrap {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--bg-1);
  box-shadow: var(--shadow-1);
}
.lap-table {
  width: 100%;
  border-collapse: collapse;
  font-family: var(--font-mono);
  font-size: 12.5px;
}
.lap-table thead th {
  background: var(--bg-2);
  color: var(--text-dim);
  text-align: right;
  padding: 10px 12px;
  font-weight: 500;
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  border-bottom: 1px solid var(--border-strong);
  white-space: nowrap;
}
.lap-table thead th:first-child { text-align: left; }
.lap-table thead th .th-sub {
  display: block;
  color: var(--text-faint);
  font-size: 9px;
  letter-spacing: 0.08em;
  margin-top: 2px;
}
.lap-table thead th.cb-col { width: 24px; padding: 10px 4px 10px 10px; text-align: center; }
.lap-table thead th.cb-col .th-sub { font-size: 8px; }
.lap-table tbody td {
  padding: 8px 12px;
  text-align: right;
  border-bottom: 1px solid var(--bg-3);
  white-space: nowrap;
  color: var(--accent);
}
.lap-table tbody td.cb-col {
  text-align: center;
  padding: 8px 4px 8px 10px;
  width: 24px;
  color: var(--text-dim);
}
.lap-table tbody td:nth-child(2) { text-align: left; color: var(--text); }
.lap-table tbody tr { cursor: pointer; transition: background 100ms; }
.lap-table tbody tr:hover { background: rgba(0,255,140,0.04); }
.lap-table tbody tr.pit td { color: var(--text-dim); }
.lap-table tbody tr.pit td:nth-child(2) { color: var(--warn); }
.lap-table tbody tr.theoretical {
  background: rgba(255,170,26,0.04);
  border-top: 1px solid var(--border-strong);
}
.lap-table tbody tr.theoretical td { color: var(--warn); font-weight: 500; }
.lap-table tbody tr.theoretical td:nth-child(2) { color: var(--warn); }
.lap-table tbody tr.selected {
  background: rgba(0,255,140,0.07);
  box-shadow: inset 3px 0 0 0 var(--accent);
}
.lap-table tbody tr.selected:hover { background: rgba(0,255,140,0.12); }

/* Compare-selection checkbox styled as a colored dot */
.row-cb {
  display: inline-flex;
  cursor: pointer;
  width: 16px; height: 16px;
  align-items: center; justify-content: center;
}
.row-cb input { position: absolute; opacity: 0; width: 0; height: 0; pointer-events: none; }
.row-cb-mark {
  width: 13px; height: 13px;
  border-radius: 3px;
  border: 1.5px solid var(--text-faint);
  background: transparent;
  transition: background 120ms, border-color 120ms;
  display: inline-block;
  box-sizing: border-box;
}
.row-cb:hover .row-cb-mark { border-color: var(--accent); }
.row-cb input:checked + .row-cb-mark {
  background: var(--mk, var(--accent));
  border-color: var(--mk, var(--accent));
  box-shadow: 0 0 0 2px rgba(0,255,140,0.18);
}

.lap-table tbody td.best { color: var(--best); font-weight: 500; }
.lap-table tbody td.muted { color: var(--text-faint); }

/* Lap detail view ------------------------------------------- */
.lap-detail { padding: 20px 24px 60px; }
.lap-detail-header {
  display: flex; align-items: baseline; gap: 14px;
  margin-bottom: 8px;
  flex-wrap: wrap;
}
.lap-back {
  background: transparent;
  border: 1px solid var(--border-strong);
  color: var(--text-dim);
  padding: 4px 10px;
  border-radius: var(--radius-s);
  font-family: var(--font-mono);
  font-size: 11px;
  cursor: pointer;
}
.lap-back:hover { color: var(--text); border-color: var(--accent-soft); }

.lap-detail-title {
  font-family: var(--font-display);
  font-size: 30px;
  letter-spacing: 0.05em;
  margin: 0;
}
.lap-detail-time {
  font-family: var(--font-mono);
  font-size: 24px;
  font-weight: 600;
  color: var(--accent);
  letter-spacing: 0.03em;
}

.lap-stats {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 8px;
  margin: 18px 0 24px;
}
.lap-stat {
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: var(--radius-s);
  padding: 10px 12px;
}
.lap-stat-label {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.12em;
  color: var(--text-faint);
  text-transform: uppercase;
}
.lap-stat-value {
  font-family: var(--font-mono);
  font-size: 18px;
  font-weight: 500;
  color: var(--accent);
  margin-top: 4px;
}
.lap-stat-value.lat { color: var(--ch-gf-lat); }
.lap-stat-value.lon { color: var(--ch-gf-lon); }
.lap-stat-value.muted { color: var(--text-faint); font-style: italic; }
.lap-stat-value.physics { color: #f0c75e; font-size: 16px; }
.lap-stat-value .lap-stat-alt {
  color: var(--text-faint); font-size: 12px; font-weight: 400;
  margin-left: 4px;
}
.lap-stat-sub-line { grid-column: span 2; }
.lap-stat-sub {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-faint);
  margin-top: 2px;
}

/* Charts */
.chart-card {
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px 12px;
  margin-bottom: 16px;
  box-shadow: var(--shadow-1);
}
.chart-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 8px;
}
.chart-title {
  font-family: var(--font-display);
  font-size: 16px;
  letter-spacing: 0.1em;
  color: var(--text);
  margin: 0;
}
.chart-legend { display: flex; gap: 14px; font-family: var(--font-mono); font-size: 11px; }
.chart-legend .lg-item { display: flex; align-items: center; gap: 5px; color: var(--text-dim); }
.chart-legend .lg-dot { width: 10px; height: 10px; border-radius: 50%; }
/* SVG line indicator: inherits the dim text colour via stroke="currentColor"
   so it reads at the same weight as the surrounding legend text. */
.chart-legend .lg-line { flex: 0 0 22px; }

.chart-canvas-wrap { position: relative; height: 220px; }
.chart-canvas-wrap.tall { height: 280px; }

/* Lap detail two-column grid: charts left (2/3), track + table right (1/3) */
.lap-content-grid {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 16px;
  align-items: start;
}
.lap-charts-col { min-width: 0; }
.lap-track-col {
  position: sticky;
  top: 16px;
  display: flex; flex-direction: column; gap: 16px;
  min-width: 0;
}
@media (max-width: 1100px) {
  .lap-content-grid { grid-template-columns: 1fr; }
  .lap-track-col { position: static; }
}

/* Track panel (reuses chart-card look) */
.track-panel {
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px 12px;
  box-shadow: var(--shadow-1);
}
.track-meta {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-dim);
}
.track-svg-wrap {
  position: relative;
  width: 100%;
  /* min-height matters: the Leaflet container child needs intrinsic
     height to render tiles. Without it Leaflet measures 0 and the map
     stays invisible until the next invalidateSize() tick. */
  min-height: 280px;
  background: #0a0e0f;
  border-radius: var(--radius-s);
  overflow: hidden;
  margin-top: 4px;
}
.track-svg-wrap > svg {
  display: block;
  width: 100%;
  height: auto;
  max-height: 60vh;
}
.track-hint {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-faint);
  margin-top: 6px;
  text-align: right;
}

/* Data table — values at cursor */
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-family: var(--font-mono);
  font-size: 12px;
  margin-top: 4px;
}
.data-table .dt-row td {
  padding: 6px 4px;
  border-bottom: 1px solid rgba(255,255,255,0.04);
}
.data-table .dt-row:last-child td { border-bottom: none; }
.data-table .dt-key {
  color: var(--text-dim);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  font-size: 10px;
}
.data-table .dt-val {
  color: var(--text);
  text-align: right;
  font-variant-numeric: tabular-nums;
  font-weight: 500;
}
.data-table .dt-row.speed   .dt-val { color: var(--ch-speed); }
.data-table .dt-row.rpm     .dt-val { color: var(--ch-rpm); }
.data-table .dt-row.lon     .dt-val { color: var(--ch-gf-lon); }
.data-table .dt-row.lat     .dt-val { color: var(--ch-gf-lat); }
.data-table .dt-row.lon-dir .dt-val,
.data-table .dt-row.lat-dir .dt-val {
  color: var(--text-faint);
  font-style: italic;
}

/* Multi-column variant of the cursor table — used by the cross-circuit
   compare view. One column per overlaid lap, headed by a colored dot. */
.data-table tr td,
.data-table tr th {
  padding: 6px 4px;
  border-bottom: 1px solid rgba(255,255,255,0.04);
}
.data-table tr:last-child td { border-bottom: none; }
.data-table tr td.dt-key {
  text-align: left;
  white-space: nowrap;
  width: 60px;
}
.data-table tr td.dt-val {
  text-align: right;
  font-variant-numeric: tabular-nums;
  color: var(--text);
}
.data-table .dt-lap-head {
  text-align: center;
  padding: 4px;
}
.data-table .dt-swatch {
  display: inline-block;
  width: 10px; height: 10px;
  border-radius: 99px;
  box-shadow: 0 0 0 1px rgba(0,0,0,0.45) inset;
  vertical-align: middle;
}

/* Comparison toolbar */
.compare-bar {
  display: flex; align-items: center; gap: 12px;
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: var(--radius-s);
  padding: 8px 12px;
  margin-bottom: 14px;
  font-family: var(--font-mono);
  font-size: 12px;
  flex-wrap: wrap;
}
.compare-bar-label { color: var(--text-dim); }
.compare-chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 8px;
  border-radius: var(--radius-s);
  background: var(--bg-3);
  border: 1px solid var(--border-strong);
  font-size: 11px;
  color: var(--text);
}
.compare-chip .x {
  cursor: pointer; opacity: 0.6; font-size: 13px;
}
.compare-chip .x:hover { opacity: 1; color: var(--best); }
.compare-chip-color { width: 9px; height: 9px; border-radius: 50%; }

/* ----- Status bar -------------------------------------------- */
.status-bar {
  height: 24px;
  display: flex; align-items: center;
  padding: 0 16px;
  background: var(--bg-2);
  border-top: 1px solid var(--border);
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-dim);
  letter-spacing: 0.04em;
}
.status-spacer { flex: 1; }
.status-version { color: var(--text-faint); }
.status-build {
  color: var(--text-faint);
  margin-right: 12px;
  white-space: nowrap;
}
.status-build:empty { display: none; }
.status-build .sb-sha {
  color: var(--text-dim);
  font-weight: 500;
}
.fmt-badge .fmt-badge-ver {
  font-size: 0.85em;
  opacity: 0.65;
  margin-left: 4px;
  font-weight: 400;
}

/* ----- Toast ------------------------------------------------- */
.toast {
  position: fixed;
  bottom: 40px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg-3);
  border: 1px solid var(--best);
  color: var(--text);
  padding: 12px 18px;
  border-radius: var(--radius);
  font-family: var(--font-mono);
  font-size: 13px;
  box-shadow: var(--shadow-2);
  z-index: 100;
  max-width: 80vw;
  animation: toast-in 200ms ease-out;
}
.toast.ok { border-color: var(--accent); }
@keyframes toast-in {
  from { opacity: 0; transform: translate(-50%, 8px); }
  to   { opacity: 1; transform: translate(-50%, 0); }
}

/* loading overlay */
.loading {
  position: absolute; inset: 0;
  background: rgba(7,9,10,0.7);
  display: flex; align-items: center; justify-content: center;
  flex-direction: column;
  z-index: 20;
}
.loading-bar {
  width: 200px; height: 3px;
  background: var(--bg-3);
  border-radius: 3px;
  overflow: hidden;
  position: relative;
}
.loading-bar::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(90deg, transparent, var(--accent), transparent);
  animation: loading-slide 1.2s ease-in-out infinite;
}
@keyframes loading-slide {
  0%   { transform: translateX(-100%); }
  100% { transform: translateX(200%); }
}
.loading-text {
  margin-top: 14px; font-family: var(--font-mono);
  font-size: 12px; color: var(--text-dim); letter-spacing: 0.08em;
}

/* scrollbars */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: var(--bg-1); }
::-webkit-scrollbar-thumb { background: var(--bg-3); border-radius: 5px; border: 2px solid var(--bg-1); }
::-webkit-scrollbar-thumb:hover { background: var(--border-strong); }

/* ----- Modal -------------------------------------------------- */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center;
  z-index: 1000;
  animation: fadeIn 120ms ease;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.modal {
  background: var(--bg-1);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  box-shadow: var(--shadow-2);
  width: min(440px, 92vw);
  padding: 24px 26px 20px;
  animation: modalIn 180ms cubic-bezier(.2,.7,.4,1);
}
@keyframes modalIn { from { transform: translateY(8px) scale(0.98); opacity: 0; } to { transform: none; opacity: 1; } }
.modal-title {
  font-family: var(--font-display);
  font-size: 22px;
  letter-spacing: 0.06em;
  color: var(--text);
  margin: 0 0 4px;
}
.modal-sub {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-dim);
  margin: 0 0 18px;
}
.modal-sub b { color: var(--accent); font-weight: 500; }
.modal-form { display: flex; flex-direction: column; gap: 12px; }
.modal-row {
  display: flex; flex-direction: column; gap: 4px;
}
.modal-lbl {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-dim);
}
.modal-form input[type="text"],
.modal-form input[type="date"] {
  background: var(--bg-3);
  border: 1px solid var(--border-strong);
  color: var(--text);
  border-radius: var(--radius-s);
  padding: 8px 11px;
  font-family: var(--font-sans);
  font-size: 14px;
  outline: none;
  transition: border-color 120ms;
}
.modal-form input[type="text"]:focus,
.modal-form input[type="date"]:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(0, 255, 140, 0.12);
}
.modal-actions {
  display: flex; justify-content: flex-end; gap: 8px;
  margin-top: 6px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}

/* ----- Wide metadata modal (track recognition) -------------------- */
.modal-wide {
  width: min(640px, 94vw);
  max-height: 88vh;
  display: flex; flex-direction: column;
}
.modal-wide .modal-form {
  overflow-y: auto;
  padding-right: 2px;       /* keep scrollbar from overlapping inputs */
}
.modal-grid-top {
  display: grid;
  grid-template-columns: 140px 1fr;
  gap: 12px;
  margin-bottom: 4px;
}
.meta-banner {
  font-size: 13px;
  padding: 10px 12px;
  border-radius: var(--radius-s);
  margin: 0 0 14px;
  border: 1px solid var(--border);
  background: var(--bg-2);
  color: var(--text);
}
.meta-banner.ok {
  border-color: rgba(95, 200, 136, 0.45);
  background: rgba(95, 200, 136, 0.07);
}
.meta-banner.warn {
  border-color: rgba(245, 162, 91, 0.5);
  background: rgba(245, 162, 91, 0.08);
}
.meta-banner b { color: var(--accent); font-weight: 600; }
.banner-score {
  font-family: var(--font-mono);
  color: var(--text-dim);
  margin-left: 6px;
  font-size: 11px;
}
.out-list {
  display: flex; flex-direction: column;
  gap: 10px;
  margin-top: 8px;
}
.out-row {
  display: grid;
  grid-template-columns: 170px 1fr;
  gap: 14px;
  align-items: start;
  padding: 10px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-s);
}
.out-preview {
  width: 160px; height: 110px;
  border: 1px solid var(--border-strong);
  border-radius: 4px;
  overflow: hidden;
  background: #0a0e0f;
}
.track-mini { display: block; width: 100%; height: 100%; }
.track-mini-empty {
  display: flex; align-items: center; justify-content: center;
  color: var(--text-faint);
  font-family: var(--font-mono);
  font-size: 11px;
  width: 100%; height: 100%;
}
.out-meta { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.out-title {
  display: flex; align-items: center; gap: 8px;
  flex-wrap: wrap;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text);
}
.out-title b { font-family: var(--font-display); letter-spacing: 0.05em; font-size: 13px; }
.out-stats { color: var(--text-dim); }
.out-badge {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 2px 8px;
  border-radius: 99px;
  border: 1px solid;
}
.out-badge.ok    { color: #5fc888; border-color: rgba(95,200,136,0.45); background: rgba(95,200,136,0.08); }
.out-badge.maybe { color: #e0c060; border-color: rgba(224,192,96,0.45); background: rgba(224,192,96,0.08); }
.out-badge.warn  { color: #f5a25b; border-color: rgba(245,162,91,0.5);  background: rgba(245,162,91,0.08); }
.out-badge.group { /* color set inline from JS */ }
.out-circuit-input {
  width: 100%;
  background: var(--bg-3);
  border: 1px solid var(--border-strong);
  color: var(--text);
  border-radius: var(--radius-s);
  padding: 7px 10px;
  font-family: var(--font-sans);
  font-size: 13px;
  outline: none;
}
.out-circuit-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(0, 255, 140, 0.12);
}
.out-hint {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-dim);
}

/* ----- Library header — flex row to host the right-side button ---- */
.library-header-row {
  display: flex; align-items: flex-end; justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
}

/* ----- Cross-file compare view ------------------------------------ */
.crossfile-view { padding: 20px 24px 60px; }
.crossfile-view .library-title { display: inline-block; vertical-align: middle; }

.cf-control-bar {
  display: flex; align-items: end; gap: 18px;
  padding: 12px 14px;
  margin: 16px 0 18px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-s);
}
.cf-circuit-pick { display: flex; flex-direction: column; gap: 4px; min-width: 320px; flex: 1; }
.cf-circuit-pick select {
  background: var(--bg-3);
  border: 1px solid var(--border-strong);
  color: var(--text);
  border-radius: var(--radius-s);
  padding: 8px 11px;
  font-family: var(--font-sans);
  font-size: 14px;
  outline: none;
}
.cf-circuit-pick select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(0, 255, 140, 0.12);
}
.cf-status {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.05em;
  color: var(--text-dim);
}
.cf-status #cfCount { color: var(--accent); font-weight: 600; }

.cf-laps-table {
  width: 100%;
  border-collapse: collapse;
  font-family: var(--font-mono);
  font-size: 12.5px;
}
.cf-laps-table thead th {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-dim);
  text-align: left;
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
}
.cf-laps-table thead th.num { text-align: right; }
.cf-laps-table tbody td {
  padding: 7px 10px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
}
.cf-laps-table tbody td.num { text-align: right; font-variant-numeric: tabular-nums; }
.cf-laps-table tbody td.time { font-variant-numeric: tabular-nums; }
.cf-laps-table tbody td.time.best { color: var(--accent); font-weight: 600; }
.cf-laps-table tbody tr:hover {
  background: rgba(255,255,255,0.02);
  cursor: pointer;
}
.cf-laps-table tbody tr.cf-row-selected {
  background: rgba(0, 255, 140, 0.05);
  border-left: 2px solid var(--accent);
}
.cf-laps-table input[type="checkbox"] {
  width: 16px; height: 16px;
  accent-color: var(--accent);
  cursor: pointer;
}
.cf-laps-table input[type="checkbox"]:disabled { opacity: 0.4; cursor: not-allowed; }
.cf-laps-table .filename {
  max-width: 220px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

/* ----- Library: Circuits section as primary entry point ----------- */
.section-title {
  font-family: var(--font-display);
  font-size: 16px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text);
  margin: 28px 0 4px;
}
.section-hint {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-dim);
  margin: 0 0 12px;
}
.circuits-section { margin-bottom: 8px; }
.circuits-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 12px;
  margin-bottom: 24px;
}
.circuits-loading {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-dim);
  padding: 18px;
  background: var(--bg-2);
  border: 1px dashed var(--border);
  border-radius: var(--radius-s);
  grid-column: 1 / -1;
}
.circuit-card {
  display: block;
  text-align: left;
  padding: 16px 18px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  transition: border-color 120ms, transform 120ms, background 120ms;
  font-family: inherit;
  color: inherit;
}
.circuit-card:hover {
  border-color: var(--accent);
  background: rgba(0, 255, 140, 0.03);
  transform: translateY(-1px);
}
.circuit-card:active { transform: none; }
.circuit-card-name {
  font-family: var(--font-display);
  font-size: 18px;
  letter-spacing: 0.04em;
  color: var(--text);
  margin-bottom: 6px;
}
.circuit-card-meta {
  display: flex; gap: 14px;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-dim);
}
.circuit-card-meta b {
  color: var(--accent);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.circuit-card-len { color: var(--text); font-variant-numeric: tabular-nums; }
.circuit-card-bands { color: var(--text-dim); }
.circuit-card-stub { color: var(--text-dim); opacity: 0.75; font-style: italic; }
.circuit-card-meta-empty { flex-wrap: wrap; gap: 10px; }
.circuit-card-flag {
  position: absolute;
  top: 10px; right: 12px;
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.1em;
  color: var(--text-dim);
  padding: 2px 6px;
  border: 1px solid var(--border);
  border-radius: 3px;
  background: rgba(0, 0, 0, 0.25);
}
.circuit-card { position: relative; }
/* Bundled-only ref (no uploaded data yet): dimmed so the user's active
   circuits naturally win attention. Hover still wakes them up fully. */
.circuit-card-empty {
  opacity: 0.62;
  background: transparent;
}
.circuit-card-empty:hover {
  opacity: 1;
  background: rgba(0, 255, 140, 0.025);
}
/* Section dividers between "Tes circuits" and the bundled library */
.circuits-section-title {
  grid-column: 1 / -1;
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-dim);
  margin: 14px 4px 4px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border);
}
.circuits-section-title-empty { opacity: 0.7; }
.files-section .section-title { margin-top: 18px; }

/* =========================================================================
   Circuits — map of France + dense list (v=14)
   ========================================================================= */
.circuits-view { display: flex; flex-direction: column; gap: 16px; }

/* --- Map container ------------------------------------------------- */
.circuits-map-wrap {
  position: relative;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.circuits-map {
  width: 100%;
  height: 420px;
  background: #0a0e10;          /* shows before tiles arrive */
}
.circuits-map-legend {
  position: absolute;
  left: 12px; bottom: 12px;
  z-index: 500;                  /* above Leaflet overlay panes (400) */
  display: flex; align-items: center; gap: 14px;
  padding: 6px 12px;
  background: rgba(13, 17, 18, 0.86);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-s);
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-dim);
  backdrop-filter: blur(6px);
}
.circ-leg { display: inline-flex; align-items: center; gap: 6px; }
.circ-leg i {
  width: 9px; height: 9px; border-radius: 50%;
  display: inline-block;
  box-shadow: 0 0 0 2px rgba(0,0,0,0.35);
}
.circ-leg-mine i { background: var(--accent); }
.circ-leg-ref  i { background: #6b7470; }
.circ-leg-spacer { flex: 1; min-width: 8px; }
.circ-leg-count {
  font-variant-numeric: tabular-nums;
  color: var(--text);
}

/* Leaflet pins — small round dots. Drawn via L.divIcon's HTML so we
   keep them styleable without bundling an SVG sprite. */
.circ-pin {
  width: 14px; height: 14px;
  border-radius: 50%;
  background: #6b7470;
  border: 2px solid #0a0e10;
  box-shadow: 0 0 0 1px rgba(0,0,0,0.6), 0 2px 4px rgba(0,0,0,0.5);
  transition: transform 120ms;
}
.circ-pin-mine {
  background: var(--accent);
  box-shadow: 0 0 0 1px rgba(0,0,0,0.6),
              0 0 8px rgba(0, 255, 140, 0.55),
              0 2px 4px rgba(0,0,0,0.5);
}
.leaflet-marker-icon:hover .circ-pin { transform: scale(1.25); }

/* Leaflet zoom + attribution — dark theme override */
.leaflet-bar a, .leaflet-bar a:hover {
  background: var(--bg-2);
  border-bottom: 1px solid var(--border);
  color: var(--text);
}
.leaflet-bar a:hover { background: var(--bg-hover); }
.leaflet-control-attribution {
  background: rgba(13,17,18,0.78) !important;
  color: var(--text-dim) !important;
  font-family: var(--font-mono);
  font-size: 10px;
}
.leaflet-control-attribution a { color: var(--text-dim); }

/* Popup — themed to match the dark surface */
.leaflet-popup.circ-popup .leaflet-popup-content-wrapper {
  background: var(--bg-2);
  color: var(--text);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  box-shadow: 0 12px 28px rgba(0,0,0,0.55);
  padding: 0;
}
.leaflet-popup.circ-popup .leaflet-popup-content {
  margin: 0;
  font-family: var(--font-sans);
}
.leaflet-popup.circ-popup .leaflet-popup-tip {
  background: var(--bg-2);
  border: 1px solid var(--border-strong);
}
.leaflet-popup.circ-popup .leaflet-popup-close-button {
  color: var(--text-dim);
  padding: 6px 8px 0 0;
}
.cp { padding: 12px 14px; min-width: 200px; }
.cp-head {
  display: flex; align-items: baseline; justify-content: space-between;
  gap: 10px;
  margin-bottom: 6px;
}
.cp-name {
  margin: 0;
  font-family: var(--font-display);
  font-size: 16px;
  letter-spacing: 0.04em;
  color: var(--text);
}
.cp-tag {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--accent);
  background: rgba(0, 255, 140, 0.08);
  padding: 1px 6px;
  border-radius: 3px;
  font-variant-numeric: tabular-nums;
}
.cp-op {
  font-size: 12px;
  color: var(--text);
  margin-bottom: 4px;
  line-height: 1.35;
}
.cp-addr {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-dim);
  margin-bottom: 10px;
  line-height: 1.4;
}
.cp-foot {
  display: flex; align-items: center; justify-content: space-between;
  gap: 8px;
  margin-top: 8px;
}
.cp-site {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-dim);
  text-decoration: none;
}
.cp-site:hover { color: var(--accent); }
/* Multi-config site popup — list of variants */
.cp-list {
  list-style: none;
  padding: 0;
  margin: 8px 0 0;
  display: flex; flex-direction: column; gap: 2px;
}
.cp-item {
  display: flex; align-items: center; gap: 8px;
  width: 100%;
  padding: 6px 8px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius-s);
  color: var(--text);
  font-family: inherit;
  font-size: 12px;
  text-align: left;
  cursor: pointer;
  transition: background 120ms, border-color 120ms;
}
.cp-item:hover {
  background: var(--bg-3);
  border-color: var(--border-strong);
}
.cp-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: #6b7470;
  flex-shrink: 0;
}
.cp-dot-mine { background: var(--accent); }
.cp-item-name { flex: 1; }
.cp-item-len {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-dim);
  font-variant-numeric: tabular-nums;
}

/* --- Toolbar (search + filter pills) ------------------------------- */
.circuits-toolbar {
  display: flex; align-items: center; gap: 12px;
  flex-wrap: wrap;
}
.circ-search {
  flex: 1; min-width: 220px;
  height: 36px;
  padding: 0 12px;
  background: var(--bg-2);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-s);
  color: var(--text);
  font-family: inherit;
  font-size: 13px;
}
.circ-search::placeholder { color: var(--text-faint); }
.circ-search:focus {
  outline: none;
  border-color: var(--accent);
  background: var(--bg-3);
}
.circ-filter-group {
  display: flex;
  background: var(--bg-2);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-s);
  overflow: hidden;
}
.circ-filter-btn {
  padding: 8px 14px;
  background: transparent;
  border: 0;
  border-right: 1px solid var(--border);
  color: var(--text-dim);
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  cursor: pointer;
  transition: background 120ms, color 120ms;
}
.circ-filter-btn:last-child { border-right: 0; }
.circ-filter-btn:hover { color: var(--text); background: var(--bg-3); }
.circ-filter-btn.is-active {
  background: var(--bg-3);
  color: var(--accent);
}

/* --- Dense list (table) -------------------------------------------- */
.circuits-list-wrap {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.circuits-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.circuits-table thead th {
  position: sticky; top: 0; z-index: 1;
  text-align: left;
  background: var(--bg-1);
  color: var(--text-dim);
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  padding: 9px 14px;
  border-bottom: 1px solid var(--border-strong);
  font-weight: 500;
}
.circuits-table th.num { text-align: right; }
.circuits-table td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.circuits-table td.num {
  text-align: right;
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  color: var(--text);
}
.ct-row { cursor: pointer; transition: background 100ms; }
.ct-row:hover { background: rgba(0, 255, 140, 0.04); }
.ct-row:hover .ct-name-text { color: var(--accent); }
.ct-row:last-child td { border-bottom: 0; }

.ct-row .ct-name {
  display: flex; align-items: center; gap: 10px;
  font-weight: 500;
}
.ct-name-text { color: var(--text); transition: color 120ms; }
.ct-row-mine .ct-name-text { color: var(--text); font-weight: 600; }
.ct-counts {
  margin-left: auto;
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-dim);
  white-space: nowrap;
  padding-left: 10px;
}
.ct-badge {
  display: inline-block;
  width: 14px; text-align: center;
  font-size: 10px;
  line-height: 1;
}
.ct-badge-mine { color: var(--accent); }
.ct-badge-ref  { color: var(--text-faint); }

.ct-op {
  color: var(--text-dim);
  font-size: 12px;
  max-width: 280px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.ct-addr {
  color: var(--text-dim);
  font-family: var(--font-mono);
  font-size: 11px;
  max-width: 280px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.ct-city {
  color: var(--text);
  font-size: 12px;
  white-space: nowrap;
}

/* Compact phones — drop the operator + counts columns so the row still fits */
@media (max-width: 760px) {
  .circuits-table .ct-op,
  .circuits-table th.ct-op,
  .ct-counts { display: none; }
  .circuits-map { height: 320px; }
}

/* ----- Primary navigation in the left sidebar -------------------- */
.primary-nav {
  display: flex; flex-direction: column;
  gap: 2px;
  padding: 12px 8px 8px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 10px;
}
.primary-nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius-s);
  color: var(--text);
  font-family: var(--font-display);
  font-size: 13px;
  letter-spacing: 0.10em;
  text-transform: uppercase;
  cursor: pointer;
  transition: background 100ms, border-color 100ms;
  text-align: left;
}
/* The class-level display:flex would otherwise override the [hidden]
   attribute on the role-conditional items, leaking "Mon profil",
   "Mon équipe", "Admin" to every visitor regardless of role. */
.primary-nav-item[hidden] { display: none !important; }
.primary-nav-item:hover {
  background: rgba(255,255,255,0.03);
  border-color: var(--border);
}
.primary-nav-item.active {
  background: rgba(0, 255, 140, 0.06);
  border-color: rgba(0, 255, 140, 0.35);
  color: var(--accent);
}
.pn-ic { font-size: 16px; line-height: 1; }
.pn-label { flex: 1; }

.sidebar-context {
  padding: 4px 12px 12px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 10px;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-dim);
}
.sidebar-context b { color: var(--text); font-weight: 600; }

/* ----- Pilot card variant of circuit-card ------------------------- */
.pilot-card .circuit-card-meta { flex-wrap: wrap; }
.circuit-card-foot {
  margin-top: 10px;
  padding-top: 8px;
  border-top: 1px solid var(--border);
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-dim);
}

/* ----- Dashboard view -------------------------------------------- */
.dashboard-view { padding-bottom: 80px; }

/* ----- Circuit dashboard sections ------------------------------------ */
.circuit-dashboard .circuit-operator {
  font-size: 0.7em; font-weight: 400;
  color: var(--text-muted, #888); margin-left: 6px;
}
.dash-section { margin: 28px 0 12px; }
.dash-section-title {
  font-size: 13px; font-weight: 600; letter-spacing: 0.06em;
  color: var(--text-muted, #888); text-transform: uppercase;
  margin: 0 0 12px; padding: 0 0 6px;
  border-bottom: 1px solid var(--border-soft, #25252b);
}

/* --- Section 1: track characteristics --- */
.char-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 18px; align-items: start;
}
@media (min-width: 1200px) {
  /* On wider screens, stats + visuals can sit side by side, with the
     visuals column wide enough to hold map + track at decent size. */
  .char-grid {
    grid-template-columns: minmax(0, 1fr) minmax(540px, 620px);
  }
}
.char-stats {
  display: grid; grid-template-columns: 1fr; gap: 8px;
  background: var(--bg-2, #1a1a1f);
  border: 1px solid var(--border, #2a2a32);
  border-radius: 10px; padding: 14px 18px;
}
.char-stat {
  display: grid; grid-template-columns: 1fr auto; align-items: baseline;
  gap: 12px; padding: 8px 0;
  border-bottom: 1px solid var(--border-soft, #25252b);
}
.char-stat:last-child { border-bottom: none; }
.char-stat-label {
  font-size: 13px; color: var(--text-muted, #888);
  text-transform: uppercase; letter-spacing: 0.04em;
}
.char-stat-body {
  text-align: right; color: var(--text, #ddd); font-size: 14px;
  display: flex; flex-direction: column; align-items: flex-end; gap: 4px;
}
.char-stat-body b { font-weight: 600; }
.char-stat-body a { color: var(--accent, #6ab0f3); text-decoration: none; }
.char-stat-body a:hover { text-decoration: underline; }
.char-stat-link { font-size: 12px; }
.char-stat-sub { font-size: 12px; color: var(--text-muted, #888); margin-left: 6px; }
.char-map-wrap {
  background: #0f0f12; border: 1px solid var(--border, #2a2a32);
  border-radius: 10px; padding: 10px;
  display: flex; flex-direction: column; gap: 8px; align-items: center;
}
.char-map { max-width: 100%; max-height: 360px; object-fit: contain; border-radius: 4px; }
.char-map-cap { font-size: 11px; color: var(--text-muted, #888); }
.char-poly-svg {
  /* Smooth, glowing track illustration rendered from the bundled
     centreline data. `currentColor` lets the inner / glow layers pick up
     the app's accent here without changing the SVG markup. Sized to
     match .char-map for visual parity when stacked. */
  width: 100%; max-width: 100%; max-height: 360px;
  color: var(--accent);
  background: #0a0a0d; border-radius: 4px;
  padding: 12px; box-sizing: border-box;
}
@media (max-width: 880px) {
  .char-grid { grid-template-columns: 1fr; }
}

/* --- Section 2: records by category --- */
.records-cat-block { margin-top: 18px; }
.records-cat-title {
  font-size: 14px; font-weight: 600; color: var(--text, #ddd);
  margin: 0 0 10px;
}
.records-cat-tabs { display: flex; gap: 4px; flex-wrap: wrap; margin-bottom: 8px; }
.records-cat-tab {
  background: transparent; color: var(--text-muted, #888);
  border: 1px solid var(--border, #2a2a32); border-radius: 6px;
  padding: 6px 14px; cursor: pointer; font-size: 13px;
  transition: background 0.15s, color 0.15s;
}
.records-cat-tab:hover {
  background: var(--bg-2, #1a1a1f); color: var(--text, #ddd);
}
.records-cat-tab.active {
  background: var(--accent, #6ab0f3); color: #0a0a0d;
  border-color: var(--accent, #6ab0f3);
}
.records-cat-pane { display: none; }
.records-cat-pane.active { display: block; }
.records-cat-table {
  width: 100%; border-collapse: collapse;
  background: var(--bg-2, #1a1a1f);
  border: 1px solid var(--border, #2a2a32); border-radius: 8px; overflow: hidden;
}
.records-cat-table th {
  text-align: left; padding: 10px 12px; font-size: 12px;
  color: var(--text-muted, #888); text-transform: uppercase; letter-spacing: 0.04em;
  background: var(--bg-3, #16161a); border-bottom: 1px solid var(--border, #2a2a32);
  font-weight: 600;
}
.records-cat-table td {
  padding: 10px 12px; border-bottom: 1px solid var(--border-soft, #25252b);
  font-size: 13px; color: var(--text, #ddd);
}
.records-cat-table tbody tr:last-child td { border-bottom: none; }
.records-cat-table .num-cell { text-align: right; font-variant-numeric: tabular-nums; }
.records-cat-table .time-cell b { font-variant-numeric: tabular-nums; color: var(--accent, #6ab0f3); }
.records-cat-table .cat-cell .cat-vtype {
  display: block; font-size: 11px; color: var(--text-muted, #888); margin-top: 2px;
}
.records-cat-table .cat-cell .cat-unset { color: var(--text-muted, #888); font-style: italic; }
.records-cat-empty {
  padding: 20px; text-align: center; color: var(--text-muted, #888);
  font-size: 13px; background: var(--bg-2, #1a1a1f);
  border: 1px dashed var(--border, #2a2a32); border-radius: 8px;
}

/* --- Section 3: rentals --- */
.rentals-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 12px;
}
.rental-card {
  background: var(--bg-2, #1a1a1f); border: 1px solid var(--border, #2a2a32);
  border-radius: 10px; padding: 14px 16px; display: flex; flex-direction: column; gap: 6px;
}
.rental-head {
  display: flex; align-items: baseline; justify-content: space-between; gap: 8px;
}
.rental-name { font-size: 15px; font-weight: 600; color: var(--text, #ddd); }
.rental-price { color: var(--accent, #6ab0f3); font-size: 13px; }
.rental-price b { font-size: 18px; font-weight: 700; }
.rental-price span { font-size: 11px; color: var(--text-muted, #888); margin-left: 2px; }
.rental-model {
  font-size: 12px; color: var(--text-muted, #888);
  text-transform: uppercase; letter-spacing: 0.04em;
}
.rental-engine { font-size: 13px; color: var(--text, #ddd); }
.rental-meta {
  display: flex; flex-wrap: wrap; gap: 4px 10px;
  font-size: 12px; color: var(--text-muted, #888); margin-top: 4px;
}
.rental-note {
  font-size: 11px; font-style: italic; color: var(--text-muted, #888);
  padding-top: 6px; border-top: 1px dashed var(--border-soft, #25252b);
}
.rentals-foot {
  margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--border-soft, #25252b);
  display: flex; flex-wrap: wrap; gap: 10px 18px; align-items: baseline;
  font-size: 12px; color: var(--text-muted, #888);
}
.rentals-pdf-link { color: var(--accent, #6ab0f3); text-decoration: none; }
.rentals-pdf-link:hover { text-decoration: underline; }

/* Secondary button style for the "Site officiel" link */
.btn-secondary {
  background: transparent; color: var(--text, #ddd);
  border: 1px solid var(--border, #2a2a32); margin-left: 8px;
}
.btn-secondary:hover { background: var(--bg-2, #1a1a1f); }

/* --- Legacy circuit-ref panel (kept for compatibility, no longer used) --- */
.circuit-ref-panel {
  display: flex; gap: 20px; align-items: flex-start;
  background: var(--surface-2, #1a1a1f); border: 1px solid var(--border, #2a2a32);
  border-radius: 10px; padding: 16px; margin: 14px 0;
}
.circuit-ref-meta { flex: 0 0 200px; }
.circuit-ref-title {
  font-size: 13px; color: var(--text-muted, #888); text-transform: uppercase;
  letter-spacing: 0.05em; margin-bottom: 12px;
}
.circuit-ref-stat {
  display: flex; justify-content: space-between; align-items: baseline;
  padding: 6px 0; border-bottom: 1px solid var(--border-soft, #25252b);
}
.circuit-ref-stat:last-child { border-bottom: none; }
.circuit-ref-stat span { color: var(--text-muted, #888); font-size: 13px; }
.circuit-ref-stat b { color: var(--text, #ddd); font-weight: 600; font-size: 14px; }
.circuit-ref-map {
  flex: 1 1 auto; min-width: 0; max-height: 280px;
  object-fit: contain; border-radius: 6px; background: #0f0f12;
}

.dash-actions {
  margin: 14px 0 18px;
}
.dash-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 14px;
}
.dash-stat-card {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  display: flex; flex-direction: column;
  gap: 8px;
  min-height: 120px;
}
.dash-stat-title {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.10em;
  text-transform: uppercase;
  color: var(--text-dim);
}
.dash-stat-body { flex: 1; display: flex; flex-direction: column; gap: 4px; }
.dash-stat-line { font-family: var(--font-sans); font-size: 14px; color: var(--text); }
.dash-stat-line b { color: var(--accent); font-weight: 600; }
.dash-stat-num {
  font-family: var(--font-display);
  font-size: 32px;
  letter-spacing: 0.04em;
  color: var(--text);
  line-height: 1;
}
.dash-stat-sub { font-family: var(--font-mono); font-size: 11px; color: var(--text-dim); }
.dash-stat-foot {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-faint);
  border-top: 1px solid var(--border);
  padding-top: 6px;
}
.dash-stat-empty {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-faint);
  font-style: italic;
}
.dash-time {
  font-family: var(--font-display);
  font-size: 28px;
  letter-spacing: 0.04em;
  color: var(--accent);
  line-height: 1;
  font-variant-numeric: tabular-nums;
}
.dash-time-progress { color: #5fc888; }

/* ----- Per-circuit / per-session tables in pilot dashboard -------- */
.dash-circuits-table tbody tr,
.dash-sessions-table tbody tr {
  cursor: pointer;
}
.dash-circuits-table tbody tr:hover,
.dash-sessions-table tbody tr:hover {
  background: rgba(255,255,255,0.02);
}

/* ----- Pilot profile header ------------------------------------- */
.pilot-profile {
  display: flex;
  gap: 22px;
  align-items: center;
  padding: 22px 22px 22px 22px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin: 16px 0 22px;
}
.pilot-profile-avatar { flex-shrink: 0; }
.pilot-profile-body { flex: 1; min-width: 0; }
.pilot-profile-name {
  font-family: var(--font-display);
  font-size: 28px;
  letter-spacing: 0.04em;
  color: var(--text);
  margin: 0 0 10px;
}
.pilot-profile-stats {
  display: flex; flex-wrap: wrap; gap: 24px;
}
.pilot-profile-stat { display: flex; flex-direction: column; gap: 2px; }
.pps-label {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.10em;
  text-transform: uppercase;
  color: var(--text-dim);
}
.pps-val {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--text);
}
.pilot-profile-actions { flex-shrink: 0; }

.avatar {
  display: block;
  width: 96px; height: 96px;
  border-radius: 50%;
  object-fit: cover;
  border: 1px solid var(--border-strong);
  background: var(--bg-3);
}
.avatar-placeholder {
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-display);
  font-size: 36px;
  letter-spacing: 0.04em;
  color: var(--accent);
  background: var(--bg-3);
  border: 1px solid var(--border-strong);
  text-align: center;
}

/* ----- Vehicles grid -------------------------------------------- */
.vehicles-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 14px;
  margin-bottom: 24px;
}
.vehicle-card {
  display: flex; flex-direction: column;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  transition: border-color 120ms;
}
.vehicle-card.is-default {
  border-color: rgba(0, 255, 140, 0.4);
  box-shadow: 0 0 0 1px rgba(0, 255, 140, 0.1) inset;
}
.vehicle-card:hover { border-color: var(--border-strong); }

.vehicle-photo {
  display: block;
  width: 100%;
  height: 140px;
  object-fit: cover;
  background: var(--bg-3);
}
.vehicle-photo-empty {
  display: flex; align-items: center; justify-content: center;
  font-size: 42px;
  color: var(--text-faint);
  background: var(--bg-3);
}

.vehicle-body { padding: 12px 14px 14px; flex: 1; display: flex; flex-direction: column; gap: 8px; }
.vehicle-head {
  display: flex; align-items: center; gap: 8px;
  flex-wrap: wrap;
}
.vehicle-name {
  font-family: var(--font-display);
  font-size: 16px;
  letter-spacing: 0.04em;
  color: var(--text);
  margin: 0;
  flex: 1; min-width: 0;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.vehicle-badge {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 2px 8px;
  border-radius: 99px;
  border: 1px solid;
}
.vehicle-badge.default {
  color: var(--accent);
  border-color: rgba(0, 255, 140, 0.45);
  background: rgba(0, 255, 140, 0.06);
}
.vehicle-badge.type {
  color: var(--text-dim);
  border-color: var(--border-strong);
  background: var(--bg-3);
}
.vehicle-specs {
  list-style: none; margin: 0; padding: 0;
  display: flex; flex-direction: column; gap: 3px;
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--text-dim);
}
.vehicle-specs li {
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.vehicle-actions {
  display: flex; gap: 6px;
  margin-top: 6px;
  padding-top: 8px;
  border-top: 1px solid var(--border);
}

/* "+ Add vehicle" tile mimics the same card shape but is interactive */
.add-vehicle-card {
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  background: transparent;
  border: 1.5px dashed var(--border-strong);
  border-radius: var(--radius);
  cursor: pointer;
  min-height: 200px;
  color: var(--text-dim);
  transition: border-color 120ms, color 120ms;
  font-family: var(--font-mono);
}
.add-vehicle-card:hover {
  border-color: var(--accent);
  color: var(--accent);
}
.add-vehicle-plus {
  font-size: 36px;
  font-weight: 300;
  line-height: 1;
  margin-bottom: 8px;
}
.add-vehicle-text {
  font-size: 12px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

/* ----- Photo input (used by both pilot + vehicle modals) ------- */
.photo-input-wrap {
  display: flex; align-items: center; gap: 12px;
}
.photo-preview {
  width: 80px; height: 80px;
  border-radius: 6px;
  background: var(--bg-3);
  border: 1px solid var(--border-strong);
  overflow: hidden;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.photo-preview img {
  width: 100%; height: 100%; object-fit: cover;
}
.photo-empty {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-faint);
  text-align: center;
  padding: 4px;
}
.photo-input-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.photo-input-actions label.btn { display: inline-flex; align-items: center; cursor: pointer; }

/* ----- Per-Out vehicle selector in the Out header --------------- */
.out-view-header-row {
  display: flex; align-items: center; gap: 14px;
  flex-wrap: wrap;
}
.out-vehicle {
  display: flex; align-items: center; gap: 10px;
  margin-left: auto;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-s);
  padding: 6px 10px;
}
.out-vehicle-label {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-dim);
}
.out-vehicle-select {
  background: var(--bg-3);
  border: 1px solid var(--border-strong);
  color: var(--text);
  border-radius: var(--radius-s);
  padding: 5px 8px;
  font-family: var(--font-mono);
  font-size: 12px;
  outline: none;
}
.out-vehicle-select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(0, 255, 140, 0.12);
}
.out-vehicle-thumb {
  width: 32px; height: 32px;
  border-radius: 4px;
  object-fit: cover;
  border: 1px solid var(--border);
}

/* Modal textarea reuses general input styling */
.modal textarea {
  background: var(--bg-3);
  border: 1px solid var(--border-strong);
  color: var(--text);
  border-radius: var(--radius-s);
  padding: 7px 10px;
  font-family: var(--font-sans);
  font-size: 13px;
  outline: none;
  resize: vertical;
  min-height: 36px;
}
.modal textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(0, 255, 140, 0.12);
}

/* ----- Cross-file compare detail view ----------------------------- */
.crossfile-detail .lap-header-title {
  font-family: var(--font-display);
  font-size: 26px;
  letter-spacing: 0.06em;
  color: var(--text);
  margin: 0;
  vertical-align: middle;
}

.cross-side-list {
  list-style: none; margin: 0; padding: 0 12px;
  display: flex; flex-direction: column; gap: 6px;
}
.cross-side-item {
  display: flex; align-items: center; gap: 8px;
  padding: 7px 8px;
  border-radius: var(--radius-s);
  cursor: pointer;
  transition: background 100ms;
}
.cross-side-item:hover { background: rgba(255,255,255,0.03); }
.cross-side-item.active { background: rgba(255,255,255,0.06); }
.cross-side-swatch {
  width: 10px; height: 10px;
  border-radius: 99px;
  background: var(--swatch);
  flex-shrink: 0;
  box-shadow: 0 0 0 1px rgba(0,0,0,0.4) inset;
}
.cross-side-text { min-width: 0; flex: 1; }
.cross-side-label {
  font-family: var(--font-mono);
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.cross-side-sub {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-dim);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* ----- Library view ------------------------------------------- */
.library-view { padding: 20px 24px 60px; }
.library-header { margin-bottom: 18px; }
.library-title {
  font-family: var(--font-display);
  font-size: 30px;
  letter-spacing: 0.06em;
  margin: 0;
  color: var(--text);
}
.library-sub {
  color: var(--text-dim);
  font-family: var(--font-mono);
  font-size: 12px;
  margin: 4px 0 0;
}

.library-empty {
  display: flex; flex-direction: column; align-items: center;
  text-align: center;
  padding: 80px 24px;
  color: var(--text-dim);
}
.library-empty-icon {
  font-size: 56px; color: var(--text-faint); margin-bottom: 12px;
}
.library-empty-title {
  font-family: var(--font-display);
  font-size: 32px;
  letter-spacing: 0.06em;
  color: var(--text);
  margin: 0 0 6px;
}
.library-empty-sub { font-size: 15px; margin: 0 0 4px; }
.library-empty-sub em { font-style: normal; color: var(--accent); }
.library-empty-hint { font-family: var(--font-mono); font-size: 12px; color: var(--text-faint); margin: 14px 0 0; }

.library-table {
  width: 100%;
  border-collapse: collapse;
  font-family: var(--font-mono);
  font-size: 13px;
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.library-table thead th {
  background: var(--bg-2);
  color: var(--text-dim);
  text-align: left;
  padding: 10px 14px;
  font-weight: 500;
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  border-bottom: 1px solid var(--border-strong);
  white-space: nowrap;
}
.library-table thead th.num { text-align: right; }
.library-table thead th.actions { width: 90px; }

/* ---- Format badges (Import view) ---------------------------------- */
/* Each row gets a small coloured pill showing where the data came from.
   The colours don't carry semantic weight — they just help the eye scan
   the source column when imports of different formats are interleaved. */
.fmt-badge {
  display: inline-block; padding: 2px 8px; border-radius: 10px;
  font-family: var(--font-mono); font-size: 10px; letter-spacing: 0.05em;
  text-transform: uppercase; font-weight: 600;
  background: var(--bg-2, #1a1a1f);
  border: 1px solid var(--border, #2a2a32);
  color: var(--text-faint, #888);
}
.fmt-badge.fmt-alf             { color: #6ab0f3; border-color: #2a3a52; }
.fmt-badge.fmt-dashware_csv    { color: #f0c75e; border-color: #4a3a18; }
.fmt-badge.fmt-fastlap_csv     { color: #ff8e5e; border-color: #4a2a18; }
.fmt-badge.fmt-alfano7_lap_zip { color: #3ddc84; border-color: #1a3a2a; }
.library-table tbody td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--bg-3);
  color: var(--text);
  white-space: nowrap;
}
.library-table tbody td.num { text-align: right; color: var(--accent); font-variant-numeric: tabular-nums; }
.library-table tbody td.num.best { color: var(--best); font-weight: 500; }
.library-table tbody td.filename { color: var(--text-dim); font-size: 12px; max-width: 200px; overflow: hidden; text-overflow: ellipsis; }
.library-table tbody td.actions { text-align: right; padding: 6px 8px; }
.library-table tbody tr { cursor: pointer; transition: background 100ms; }
.library-table tbody tr:hover { background: rgba(0, 255, 140, 0.05); }
.library-table tbody tr:hover td { color: var(--text); }
.library-table tbody tr:last-child td { border-bottom: none; }

/* responsive */
@media (max-width: 800px) {
  /* `.layout` 1-column + `.sidebar` off-canvas drawer are now defined
     in the mobile responsive layer at the bottom of this file (issue
     #12). Only keep the lap-table density tweak here. */
  .lap-table { font-size: 11px; }
  .lap-table thead th, .lap-table tbody td { padding: 6px 8px; }
  .dropzone-title { font-size: 36px; }
}

/* =========================================================================
   Multi-tenant auth UI (v=15)
   Login overlay, user chip, profile page, team manager dashboard, admin grid.
   ========================================================================= */

/* ----- Auth overlay (full-screen, shown until /api/auth/me succeeds) ----- */
.auth-screen {
  position: fixed; inset: 0;
  z-index: 9000;
  display: flex; align-items: center; justify-content: center;
  background: radial-gradient(ellipse at top, #0d1518 0%, #07090a 70%);
  padding: 24px;
}
/* The [hidden] attribute applies display:none via the UA stylesheet, but the
   `.auth-screen { display: flex }` rule above has a higher specificity so
   would otherwise keep the overlay visible. Re-affirm display:none with an
   attribute selector so JS toggling .hidden works as intended. Without
   this, a successful login transitions the app to the main view but the
   auth overlay stays visible on top — and the user just sees the login
   form even though they're actually authenticated. */
.auth-screen[hidden] { display: none !important; }
.auth-card {
  width: 100%;
  max-width: 460px;
  padding: 32px 36px;
  background: var(--bg-1);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  box-shadow: 0 24px 60px rgba(0,0,0,0.65),
              0 0 0 1px rgba(0, 255, 140, 0.04);
}
.auth-brand {
  display: flex; align-items: center; gap: 14px;
  margin-bottom: 22px;
}
.auth-brand .auth-logo {
  width: 52px; height: 52px;
  filter: drop-shadow(0 0 6px rgba(0, 255, 140, 0.35));
}
.auth-brand h1 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 22px;
  letter-spacing: 0.06em;
  color: var(--text);
}

.auth-tabs {
  display: flex;
  border-bottom: 1px solid var(--border);
  margin-bottom: 20px;
}
.auth-tab {
  flex: 1;
  background: transparent;
  border: 0;
  padding: 10px 0;
  color: var(--text-dim);
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: color 120ms, border-color 120ms;
}
.auth-tab:hover { color: var(--text); }
.auth-tab.is-active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

.auth-form {
  display: none;
  flex-direction: column;
  gap: 14px;
}
.auth-form.is-visible { display: flex; }
.auth-form label {
  display: flex; flex-direction: column;
  gap: 5px;
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-dim);
}
.auth-form input[type="text"],
.auth-form input[type="password"],
.auth-form input[type="date"],
.auth-form input[type="number"],
.auth-form textarea {
  padding: 10px 12px;
  background: var(--bg-2);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-s);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 14px;
  letter-spacing: normal;
  text-transform: none;
}
.auth-form input:focus,
.auth-form textarea:focus {
  outline: none;
  border-color: var(--accent);
  background: var(--bg-3);
}

.auth-row { display: flex; gap: 12px; }
.auth-row > label { flex: 1; }

/* Role-picker cards (radio buttons styled as tiles) */
.auth-role-picker {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 8px;
}
.auth-role { cursor: pointer; }
.auth-role input { position: absolute; opacity: 0; pointer-events: none; }
.auth-role-card {
  display: flex; flex-direction: column;
  gap: 4px;
  padding: 14px 14px 12px;
  background: var(--bg-2);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-s);
  transition: border-color 120ms, background 120ms;
}
.auth-role input:checked + .auth-role-card {
  border-color: var(--accent);
  background: rgba(0, 255, 140, 0.05);
  box-shadow: 0 0 0 1px var(--accent) inset;
}
.auth-role-ic {
  font-size: 22px;
  color: var(--accent);
  font-family: var(--font-mono);
}
.auth-role-title {
  font-family: var(--font-display);
  font-size: 16px;
  letter-spacing: 0.04em;
  color: var(--text);
}
.auth-role-sub {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-dim);
  letter-spacing: 0.04em;
  text-transform: none;
}

.auth-submit {
  margin-top: 6px;
  padding: 12px 16px;
  font-size: 14px;
  font-weight: 600;
}

.auth-error {
  margin-top: 12px;
  padding: 9px 12px;
  background: rgba(255, 80, 80, 0.08);
  border: 1px solid rgba(255, 100, 100, 0.35);
  border-radius: var(--radius-s);
  color: #ff9090;
  font-family: var(--font-mono);
  font-size: 12px;
}

/* ----- User chip in the topbar ------------------------------------------ */
.user-chip {
  display: flex; align-items: center; gap: 8px;
  margin-left: 8px;
  padding: 0 0 0 10px;
  border-left: 1px solid var(--border);
}
/* Same [hidden] precedence issue as .auth-screen above */
.user-chip[hidden] { display: none !important; }
.user-chip-name {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text);
}
.user-chip-role {
  font-family: var(--font-mono);
  font-size: 9px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-dim);
  background: var(--bg-3);
  padding: 2px 6px;
  border-radius: 3px;
  border: 1px solid var(--border);
}
.user-chip-role[data-role="admin"] {
  color: var(--accent);
  border-color: rgba(0, 255, 140, 0.4);
  background: rgba(0, 255, 140, 0.06);
}
.user-chip-role[data-role="team_manager"] {
  color: #ffc257;
  border-color: rgba(255, 194, 87, 0.35);
}
.user-chip-logout {
  padding: 4px 8px !important;
}

/* ----- Profile page ----------------------------------------------------- */
.profile-view { padding: 20px 24px 60px; max-width: 760px; }
.profile-loading {
  font-family: var(--font-mono); font-size: 12px;
  color: var(--text-dim); padding: 18px;
}
.profile-form {
  display: flex; flex-direction: column;
  gap: 14px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
}
.profile-form label {
  display: flex; flex-direction: column;
  gap: 5px;
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-dim);
}
.profile-form input,
.profile-form textarea {
  padding: 8px 10px;
  background: var(--bg-1);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-s);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 13px;
  letter-spacing: normal;
  text-transform: none;
}
.profile-form input:focus,
.profile-form textarea:focus {
  outline: none;
  border-color: var(--accent);
}
.profile-row { display: flex; gap: 14px; }
.profile-row > label { flex: 1; }
.profile-actions {
  display: flex; align-items: center; gap: 14px;
  margin-top: 4px;
}
.profile-saved {
  color: var(--accent);
  font-family: var(--font-mono);
  font-size: 12px;
}
.profile-sep {
  border: none;
  border-top: 1px solid var(--border);
  margin: 28px 0 18px;
}
.profile-team h3 {
  font-family: var(--font-display);
  font-size: 18px;
  letter-spacing: 0.04em;
  color: var(--text);
  margin: 0 0 10px;
}
.profile-aff {
  font-family: var(--font-mono); font-size: 12px;
  color: var(--text);
  padding: 10px 14px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius-s);
  margin-bottom: 12px;
  display: flex; justify-content: space-between; align-items: center;
}
.profile-aff-empty {
  color: var(--text-dim);
  border-left-color: var(--text-faint);
}
.profile-aff-form {
  display: flex; gap: 10px; align-items: flex-end;
}
.profile-aff-form label {
  flex: 1;
  display: flex; flex-direction: column;
  gap: 5px;
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-dim);
}
.profile-aff-form input {
  padding: 8px 10px;
  background: var(--bg-1);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-s);
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 13px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

/* ----- Team manager page ----------------------------------------------- */
.team-view { padding: 20px 24px 60px; }
.team-loading {
  font-family: var(--font-mono); font-size: 12px;
  color: var(--text-dim); padding: 18px;
}
.tm-card {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 22px;
  margin-bottom: 20px;
}
.tm-card-head {
  display: flex; justify-content: space-between; align-items: center;
  flex-wrap: wrap; gap: 12px;
}
.tm-card-head h3 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 22px;
  letter-spacing: 0.04em;
  color: var(--text);
}
.tm-public-id {
  display: flex; align-items: center; gap: 10px;
  font-family: var(--font-mono); font-size: 12px;
  color: var(--text-dim);
}
.tm-public-id-code {
  padding: 4px 10px;
  background: var(--bg-0);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-s);
  color: var(--accent);
  letter-spacing: 0.12em;
  font-weight: 600;
}
.tm-toolbar {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 14px;
}
.tm-h {
  margin: 0;
  font-family: var(--font-display);
  font-size: 18px;
  letter-spacing: 0.04em;
  color: var(--text);
}
.tm-tag-account, .tm-tag-stub {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  padding: 2px 6px;
  border-radius: 3px;
}
.tm-tag-account {
  color: var(--accent);
  background: rgba(0, 255, 140, 0.06);
  border: 1px solid rgba(0, 255, 140, 0.25);
}
.tm-tag-stub {
  color: var(--text-dim);
  background: var(--bg-3);
  border: 1px solid var(--border);
}
.tm-table .actions {
  white-space: nowrap;
  text-align: right;
}
.tm-table .actions .btn { margin-left: 4px; }
.tm-empty {
  color: var(--text-dim);
  font-style: italic;
  padding: 24px !important;
  text-align: center;
}
.tm-empty code {
  font-family: var(--font-mono);
  background: var(--bg-3);
  padding: 2px 6px;
  border-radius: 3px;
  color: var(--accent);
}

/* ----- Admin page ------------------------------------------------------- */
.admin-view { padding: 20px 24px 60px; }
.admin-tabs {
  display: flex;
  gap: 2px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-s);
  padding: 4px;
  margin-bottom: 18px;
  width: fit-content;
}
.admin-tab {
  padding: 8px 18px;
  background: transparent;
  border: 0;
  border-radius: 3px;
  color: var(--text-dim);
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  cursor: pointer;
  transition: background 120ms, color 120ms;
}
.admin-tab:hover { color: var(--text); }
.admin-tab.is-active {
  background: var(--bg-3);
  color: var(--accent);
}
.admin-pane {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.admin-pane .circuits-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.admin-pane .circuits-table th {
  background: var(--bg-1);
  text-align: left;
  padding: 9px 14px;
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-dim);
  border-bottom: 1px solid var(--border-strong);
}
.admin-pane .circuits-table td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
}
.admin-pane .circuits-table tr:last-child td { border-bottom: 0; }
.admin-pane .circuits-table .num { text-align: right; font-variant-numeric: tabular-nums; }
.admin-pane .circuits-table .actions { text-align: right; }
.admin-pane code {
  font-family: var(--font-mono);
  color: var(--accent);
  background: var(--bg-3);
  padding: 2px 6px;
  border-radius: 3px;
  font-size: 12px;
}

.admin-role {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  padding: 2px 6px;
  border-radius: 3px;
  border: 1px solid var(--border);
  background: var(--bg-3);
  color: var(--text-dim);
}
.admin-role-admin {
  color: var(--accent);
  background: rgba(0, 255, 140, 0.08);
  border-color: rgba(0, 255, 140, 0.35);
}
.admin-role-team_manager {
  color: #ffc257;
  border-color: rgba(255, 194, 87, 0.35);
}

.admin-pane-info {
  padding: 28px;
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--text-dim);
}
.admin-pane-info a {
  color: var(--accent);
  text-decoration: none;
  border-bottom: 1px dotted var(--accent);
}

/* ----- Smaller screens -------------------------------------------------- */
@media (max-width: 720px) {
  .auth-card { padding: 24px 22px; }
  .auth-row { flex-direction: column; gap: 14px; }
  .auth-role-picker { grid-template-columns: 1fr; }
  .profile-row { flex-direction: column; }
  .tm-card-head { flex-direction: column; align-items: flex-start; }
  .user-chip-name { display: none; }
}

/* Upload modal — pilote field variants by role */
.modal-row input[name="pilote"][readonly] {
  background: var(--bg-1);
  color: var(--text-dim);
  cursor: not-allowed;
  border-style: dashed;
}
.modal-row select[name="pilote"] {
  padding: 8px 10px;
  background: var(--bg-2);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-s);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 13px;
  width: 100%;
}
.modal-row select[name="pilote"]:focus {
  outline: none;
  border-color: var(--accent);
}

/* =========================================================================
   Admin circuit edit modal (v=18)
   ========================================================================= */
.modal-wide { width: min(92vw, 720px) !important; max-height: 90vh; overflow-y: auto; }
.modal-head {
  display: flex; justify-content: space-between; align-items: center;
  padding: 18px 22px;
  border-bottom: 1px solid var(--border);
}
.modal-head h3 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 18px;
  letter-spacing: 0.04em;
  color: var(--text);
}
.modal-head code {
  font-family: var(--font-mono);
  color: var(--accent);
  background: var(--bg-3);
  padding: 2px 8px;
  border-radius: 3px;
}
.modal-close {
  background: transparent; border: 0;
  font-size: 22px; line-height: 1;
  color: var(--text-dim);
  cursor: pointer;
  padding: 4px 8px;
}
.modal-close:hover { color: var(--text); }

.modal-form-grid {
  padding: 18px 22px 22px;
  display: flex; flex-direction: column;
  gap: 14px;
}
.modal-section {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--accent);
  margin: 10px 0 -2px;
  padding-top: 8px;
  border-top: 1px dashed var(--border);
}
.modal-section:first-child { border-top: 0; padding-top: 0; margin-top: 0; }

.modal-form-grid label {
  display: flex; flex-direction: column;
  gap: 5px;
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-dim);
}
.modal-form-grid input[type="text"],
.modal-form-grid input[type="number"],
.modal-form-grid input[type="email"],
.modal-form-grid textarea {
  padding: 8px 10px;
  background: var(--bg-1);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-s);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 13px;
  letter-spacing: normal;
  text-transform: none;
}
.modal-form-grid input:focus,
.modal-form-grid textarea:focus {
  outline: none;
  border-color: var(--accent);
}
.modal-row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.modal-row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; }
.modal-actions {
  display: flex; align-items: center; gap: 10px;
  margin-top: 12px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}
.modal-actions-spread { justify-content: space-between; }
.modal-actions-right { display: flex; gap: 10px; }
.modal-hint {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-dim);
  font-style: italic;
}
.btn-warn {
  background: rgba(255, 100, 100, 0.08);
  border-color: rgba(255, 100, 100, 0.35);
  color: #ff9090;
}
.btn-warn:hover {
  background: rgba(255, 100, 100, 0.15);
  border-color: rgba(255, 100, 100, 0.6);
}

/* Admin circuits table — extra "édité" pill on overridden rows */
.admin-role-edit {
  color: #ffc257;
  background: rgba(255, 194, 87, 0.08);
  border-color: rgba(255, 194, 87, 0.35);
  margin-left: 6px;
}
.admin-circuits-table {
  font-size: 12px;
}
.admin-circuits-table td.actions {
  text-align: right;
  white-space: nowrap;
}
.admin-circuits-table td.actions .btn {
  margin-left: 4px;
}

/* Mobile compaction */
@media (max-width: 720px) {
  .modal-wide { width: 96vw !important; }
  .modal-row-2, .modal-row-3 { grid-template-columns: 1fr; }
  .modal-actions { flex-direction: column; align-items: stretch; }
  .modal-actions-right { justify-content: flex-end; }
}

/* =========================================================================
   Circuit visuals — map + track stacked (map above, track below) (v=23)
   ========================================================================= */
.char-visuals {
  display: flex;
  flex-direction: column;
  gap: 14px;
  align-items: stretch;
}

/* Admin circuit edit modal — map editor section */
.circ-map-edit {
  display: flex; flex-direction: column;
  gap: 10px;
}
.circ-map-current {
  display: flex; align-items: center; justify-content: center;
  min-height: 90px;
  background: #0a0a0d;
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-s);
  padding: 10px;
}
.circ-map-thumb {
  max-height: 220px;
  max-width: 100%;
  object-fit: contain;
  border-radius: 3px;
}
.circ-map-empty {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-dim);
  font-style: italic;
}
.circ-map-actions {
  display: flex; align-items: center; flex-wrap: wrap; gap: 10px;
}
.circ-map-actions .btn {
  cursor: pointer;
}
.circ-map-filename {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-dim);
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* =========================================================================
   Abnormal-lap filter (v=26)
   ========================================================================= */
.lap-table-controls {
  margin-bottom: 10px;
  padding: 8px 10px;
  background: rgba(255,255,255,0.02);
  border: 1px solid var(--border-strong);
  border-radius: 4px;
  display: flex; align-items: center; gap: 12px;
}
.lap-filter-tog {
  display: flex; align-items: center; gap: 8px;
  cursor: pointer;
  user-select: none;
  font-size: 13px;
  color: var(--text);
}
.lap-filter-tog input[type="checkbox"] { cursor: pointer; accent-color: var(--accent); }
.lap-filter-hint {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-dim);
  font-style: italic;
}
/* Subtle warning marker on the lap-number cell when a lap is flagged. The
   ⚠ inherits its own colour via direct styling, not the row's text color. */
.lap-warn {
  color: #f5a25b;
  margin-right: 4px;
  cursor: help;
  font-size: 13px;
}
/* When the filter is on, hide rows tagged data-abnormal. We hide via
   table-row → display:none rather than visibility:hidden so they don't
   leave gaps in the table layout. */
.lap-table-wrap.filter-abnormal tr[data-abnormal="1"] { display: none; }

/* Even when not hidden, abnormal rows get a subtle amber left-border so
   they read as flagged at a glance. */
.lap-table tr[data-abnormal="1"] td:first-of-type {
  box-shadow: inset 3px 0 0 0 rgba(245,162,91,0.6);
}

/* =========================================================================
   Circuit aerial / satellite view (v=28)
   ========================================================================= */
.char-aerial {
  width: 100%;
  height: 360px;
  border-radius: 4px;
  background: #0a0a0d;       /* shows through before tiles load */
  border: 1px solid var(--border-strong);
  /* Leaflet adds its own internal CSS; we just need the container sized. */
}
.char-aerial .leaflet-control-attribution {
  background: rgba(10,10,13,0.7);
  color: #888;
  font-size: 10px;
}
.char-aerial .leaflet-control-attribution a { color: #aaa; }

/* =========================================================================
   Logger / acquisition device chip — appears in the Out header showing
   brand, model, serial number and firmware/software version inferred at
   import time from each file format. (v=34)
   ========================================================================= */
.logger-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-left: 8px;
  padding: 2px 8px;
  font-size: 11px;
  background: rgba(61, 220, 132, 0.08);     /* faint accent tint */
  border: 1px solid rgba(61, 220, 132, 0.25);
  border-radius: 999px;
  color: var(--ink-muted, #b5b5b9);
  white-space: nowrap;
  cursor: help;                              /* signals the tooltip */
}
.logger-chip:hover { background: rgba(61, 220, 132, 0.14); }
.logger-chip b      { color: var(--accent, #3ddc84); font-weight: 600; }
.logger-chip .logger-ic {
  font-size: 11px;
  filter: grayscale(0.4);
  opacity: 0.85;
}

/* =========================================================================
   Track-mode segmented control + Leaflet satellite layer (v=35)
   Two layouts for the lap-detail track view:
     [📐 Schématique]  — current dark-bg SVG with reconstructed XY
     [🛰️ Satellite]    — Esri aerial map with GPS trace polylines overlaid
   The Satellite button auto-disables for files without GPS data.
   ========================================================================= */
.track-mode-tog {
  display: inline-flex;
  gap: 0;
  margin: 0 0 6px 0;
  border-radius: 6px;
  overflow: hidden;
  border: 1px solid var(--border-strong, #2a2d31);
}
.track-mode-btn {
  flex: 0 0 auto;
  background: rgba(255,255,255,0.02);
  color: var(--ink-muted, #b5b5b9);
  border: 0;
  padding: 4px 10px;
  font-size: 11px;
  cursor: pointer;
  font-family: inherit;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  transition: background 0.12s ease, color 0.12s ease;
}
.track-mode-btn:not(:first-child) {
  border-left: 1px solid var(--border-strong, #2a2d31);
}
.track-mode-btn:hover:not(:disabled) {
  background: rgba(61, 220, 132, 0.08);
  color: var(--ink, #e8e8ea);
}
.track-mode-btn.active {
  background: rgba(61, 220, 132, 0.18);
  color: var(--accent, #3ddc84);
}
.track-mode-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}
.track-mode-ic { font-size: 11px; }

/* Leaflet container — same footprint as the SVG so the panel doesn't
   reflow when toggling modes. The map appears above any overlay and the
   attribution gets the dark-theme treatment. */
.track-leaflet {
  width: 100%;
  height: 100%;
  min-height: 280px;
  border-radius: 4px;
  background: #0a0a0d;
  border: 1px solid var(--border-strong, #2a2d31);
}
.track-leaflet .leaflet-control-attribution {
  background: rgba(10,10,13,0.7);
  color: #888;
  font-size: 10px;
}
.track-leaflet .leaflet-control-attribution a { color: #aaa; }
.track-leaflet-empty {
  padding: 24px 16px;
  font-size: 12px;
  color: var(--ink-muted, #b5b5b9);
  text-align: center;
}

/* =========================================================================
   Power-analysis panel (v=38) — appears below the lap table on the Out
   view. Shows per-lap peak power as a bar chart so degradation jumps out
   visually, plus tuning sliders for the physics model (Cd·A, η, Crr).
   ========================================================================= */
.power-analysis-panel {
  margin-top: 16px;
  padding: 16px;
  background: rgba(255,255,255,0.02);
  border: 1px solid var(--border-strong, #2a2d31);
  border-radius: 8px;
}
.power-analysis-loading,
.power-analysis-empty {
  padding: 24px;
  text-align: center;
  color: var(--ink-muted, #b5b5b9);
  font-size: 13px;
}
.pwr-head {
  display: flex;
  align-items: baseline;
  gap: 12px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}
.pwr-title {
  margin: 0;
  font-size: 14px;
  font-weight: 600;
  color: var(--ink, #e8e8ea);
}
.pwr-subtitle {
  font-size: 12px;
  color: var(--ink-muted, #b5b5b9);
}
.pwr-subtitle b { color: var(--accent, #3ddc84); }

.pwr-worst {
  padding: 8px 12px;
  margin-bottom: 12px;
  font-size: 12px;
  border-radius: 6px;
  background: rgba(255, 150, 0, 0.08);
  border: 1px solid rgba(255, 150, 0, 0.25);
}
.pwr-worst-good {
  background: rgba(61, 220, 132, 0.06);
  border-color: rgba(61, 220, 132, 0.25);
  color: var(--accent, #3ddc84);
}
.pwr-worst-title { font-weight: 600; margin-right: 8px; }
.pwr-worst-chip {
  display: inline-block;
  padding: 2px 8px;
  margin: 2px 4px 2px 0;
  background: rgba(0,0,0,0.3);
  border-radius: 999px;
  font-size: 11px;
  font-family: var(--font-mono, monospace);
}

/* Per-lap bar rows — grid layout so columns align across all rows */
.pwr-bars { margin-bottom: 16px; }
.pwr-bars-head, .pwr-row {
  display: grid;
  grid-template-columns: 56px 1fr 80px 90px 70px;
  gap: 10px;
  align-items: center;
  padding: 4px 6px;
  font-size: 12px;
  font-family: var(--font-mono, monospace);
}
.pwr-bars-head {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--ink-faint, #6e6e72);
  border-bottom: 1px solid var(--border-strong, #2a2d31);
  margin-bottom: 4px;
}
.pwr-row:hover { background: rgba(255,255,255,0.03); }
.pwr-lap { font-weight: 600; }
.pwr-bar-wrap {
  height: 14px;
  background: rgba(255,255,255,0.04);
  border-radius: 3px;
  overflow: hidden;
}
.pwr-bar {
  display: block;
  height: 100%;
  transition: width 0.2s ease;
}
.pwr-ok   { background: linear-gradient(90deg, #3ddc84, #2cb96a); }
.pwr-soft { background: linear-gradient(90deg, #c2e84c, #95b430); }
.pwr-warn { background: linear-gradient(90deg, #ffaa1a, #d98a00); }
.pwr-bad  { background: linear-gradient(90deg, #ff5a3c, #c83820); }
.pwr-kw  { text-align: right; color: var(--ink, #e8e8ea); }
.pwr-rpm { text-align: right; color: var(--ink-muted, #b5b5b9); font-size: 11px; }
.pwr-drop { text-align: right; }
.pwr-drop-ok   { color: var(--accent, #3ddc84); }
.pwr-drop-soft { color: #c2e84c; }
.pwr-drop-warn { color: #ffaa1a; }
.pwr-drop-bad  { color: #ff5a3c; font-weight: 600; }

/* Tuning sliders */
.pwr-tune {
  padding: 12px;
  background: rgba(0,0,0,0.2);
  border-radius: 6px;
}
.pwr-tune-title {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--ink-faint, #6e6e72);
  margin-bottom: 8px;
}
.pwr-tune-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 10px 18px;
}
.pwr-tune-grid label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--ink-muted, #b5b5b9);
}
.pwr-tune-grid label b { color: var(--ink, #e8e8ea); font-weight: 500; }
.pwr-tune-grid input[type="range"] {
  flex: 1 1 auto;
  min-width: 80px;
  accent-color: var(--accent, #3ddc84);
}
.pwr-tune-grid span {
  font-family: var(--font-mono, monospace);
  font-size: 11px;
  color: var(--accent, #3ddc84);
  min-width: 50px;
  text-align: right;
}
.pwr-tune-hint {
  margin-top: 8px;
  font-size: 11px;
  color: var(--ink-faint, #6e6e72);
  line-height: 1.4;
}
.pwr-tune-hint em { color: var(--ink-muted, #b5b5b9); font-style: normal; }

/* =========================================================================
   Fullscreen overlay for the satellite track view (v=39).
   ========================================================================= */

/* The fullscreen button sits at the end of the track-mode-tog control,
   styled as a compact icon-only action (rather than a mode toggle). */
.track-fs-btn {
  flex: 0 0 auto;
  background: rgba(255,255,255,0.02);
  color: var(--ink-muted, #b5b5b9);
  border: 0;
  border-left: 1px solid var(--border-strong, #2a2d31);
  padding: 4px 10px;
  font-size: 13px;
  cursor: pointer;
  font-family: inherit;
  line-height: 1;
  transition: background 0.12s ease, color 0.12s ease;
}
.track-fs-btn:hover {
  background: rgba(61, 220, 132, 0.08);
  color: var(--accent, #3ddc84);
}

/* The overlay itself — fixed positioning so it covers the viewport
   regardless of where it lives in the DOM. Hidden by default; .active
   reveals it. We use opacity + display rather than display:none so we
   can have a brief fade-in. */
.track-fs-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 9000;
  background: #060708;
  flex-direction: column;
}
.track-fs-overlay.active { display: flex; }

/* Top bar with title + close button. Compact so the map gets maximum
   real estate. */
.track-fs-bar {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  background: rgba(10, 14, 15, 0.92);
  border-bottom: 1px solid var(--border-strong, #2a2d31);
}
.track-fs-title {
  font-size: 13px;
  font-family: var(--font-mono, monospace);
  color: var(--ink, #e8e8ea);
}
.track-fs-close {
  background: rgba(255,255,255,0.04);
  color: var(--ink, #e8e8ea);
  border: 1px solid var(--border-strong, #2a2d31);
  border-radius: 4px;
  width: 32px;
  height: 32px;
  font-size: 16px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  font-family: inherit;
  transition: background 0.12s ease, color 0.12s ease;
}
.track-fs-close:hover {
  background: rgba(255, 90, 60, 0.18);
  color: #ff5a3c;
  border-color: rgba(255, 90, 60, 0.5);
}

/* Body holds the moved-in Leaflet container; flex:1 so it fills all
   remaining vertical space. */
.track-fs-body {
  flex: 1 1 auto;
  position: relative;
  overflow: hidden;
}

/* When the Leaflet container is inside the fullscreen body, override
   the in-panel sizing so it fills 100% × 100% of the body instead. */
.track-leaflet.track-leaflet-fs {
  width: 100%;
  height: 100%;
  min-height: 0;
  border: 0;
  border-radius: 0;
}

/* Lock body scroll while fullscreen is active so scrolling the page
   underneath doesn't shift the layout when we exit. */
body.track-fs-active {
  overflow: hidden;
}

/* =========================================================================
   Brake-highlight mode + accel/brake legend (v=40)
   ========================================================================= */
.track-fs-btn-active {
  background: rgba(239, 68, 68, 0.18) !important;   /* brake-red tint */
  color: #ef4444 !important;
}
.track-fs-btn-active:hover {
  background: rgba(239, 68, 68, 0.28) !important;
}

/* Legend overlay inside the Leaflet map, top-right corner. The
   .leaflet-control class is added automatically by Leaflet when we
   call addTo() so we just style our custom container. */
.track-leaflet-legend {
  background: rgba(10, 14, 15, 0.85);
  color: var(--ink, #e8e8ea);
  padding: 6px 10px;
  border-radius: 6px;
  border: 1px solid var(--border-strong, #2a2d31);
  font-size: 11px;
  font-family: var(--font-mono, monospace);
  line-height: 1.5;
  box-shadow: 0 2px 8px rgba(0,0,0,0.4);
}
.track-leaflet-legend .tll-row {
  display: flex;
  align-items: center;
  gap: 6px;
}
.track-leaflet-legend .tll-swatch {
  display: inline-block;
  width: 18px;
  height: 4px;
  border-radius: 2px;
}

/* =========================================================================
   Inline info icons in the power-tune panel (v=41). Native browser
   tooltips so we get auto-positioning and line-breaks without a
   dedicated tooltip library.
   ========================================================================= */
.pwr-info {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 14px;
  height: 14px;
  margin: 0 4px;
  font-size: 10px;
  font-style: normal;
  color: var(--ink-muted, #b5b5b9);
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 50%;
  cursor: help;
  user-select: none;
  flex: 0 0 14px;
  font-family: serif;
  line-height: 1;
  transition: color 0.12s ease, background 0.12s ease, border-color 0.12s ease;
}
.pwr-info:hover, .pwr-info:focus {
  color: var(--accent, #3ddc84);
  background: rgba(61, 220, 132, 0.12);
  border-color: rgba(61, 220, 132, 0.45);
  outline: none;
}

/* =========================================================================
   Data-source chips for the power-analysis tune panel (v=41).
   ========================================================================= */
.pwr-tune-sources {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 12px;
  font-size: 11px;
  font-family: var(--font-mono, monospace);
}
.pwr-src-chip {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 3px 8px;
  border-radius: 999px;
  white-space: nowrap;
  cursor: help;
}
.pwr-src-chip.used {
  color: var(--accent, #3ddc84);
  background: rgba(61, 220, 132, 0.10);
  border: 1px solid rgba(61, 220, 132, 0.35);
}
.pwr-src-chip.absent {
  color: var(--ink-faint, #6e6e72);
  background: rgba(255,255,255,0.03);
  border: 1px solid rgba(255,255,255,0.10);
}
.pwr-src-chip.used:hover  { background: rgba(61, 220, 132, 0.16); }
.pwr-src-chip.absent:hover { background: rgba(255,255,255,0.06); }

/* =========================================================================
   Telemetry view (v=43) — flat filterable lap table replacing the old
   pilots-grid. Single entry point for finding & comparing laps.
   ========================================================================= */
.telemetry-view {
  padding: 16px 24px;
}
.telemetry-view .library-header { margin-bottom: 12px; }

.telemetry-filters {
  margin: 8px 0 16px 0;
  padding: 10px 12px;
  background: rgba(255,255,255,0.02);
  border: 1px solid var(--border-strong, #2a2d31);
  border-radius: 8px;
}
.telemetry-loading,
.telemetry-empty {
  padding: 24px;
  text-align: center;
  font-size: 13px;
  color: var(--ink-muted, #b5b5b9);
}

/* Filter grid — auto-fit columns, responsive */
.tlm-filter-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 8px 12px;
  align-items: end;
}
.tlm-filter-cell {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.tlm-filter-search { grid-column: 1 / -1; }
@media (min-width: 1000px) { .tlm-filter-search { grid-column: 1 / span 2; } }
.tlm-filter-lbl {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--ink-faint, #6e6e72);
}
.tlm-filter-cell input,
.tlm-filter-cell select {
  background: rgba(0,0,0,0.3);
  border: 1px solid var(--border-strong, #2a2d31);
  color: var(--ink, #e8e8ea);
  padding: 5px 8px;
  border-radius: 4px;
  font-family: inherit;
  font-size: 12px;
  min-width: 0;
  width: 100%;
}
.tlm-filter-cell input:focus,
.tlm-filter-cell select:focus {
  border-color: var(--accent, #3ddc84);
  outline: none;
}
.tlm-filter-reset {
  font-size: 14px;
  align-self: end;
  height: fit-content;
}

/* The actual table */
.telemetry-table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border-strong, #2a2d31);
  border-radius: 8px;
}
.telemetry-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
  font-family: var(--font-mono, monospace);
}
.telemetry-table thead {
  background: rgba(255,255,255,0.04);
  position: sticky;
  top: 0;
  z-index: 1;
}
.telemetry-table th {
  padding: 8px 10px;
  text-align: left;
  font-weight: 500;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--ink-muted, #b5b5b9);
  border-bottom: 1px solid var(--border-strong, #2a2d31);
  white-space: nowrap;
}
.telemetry-table td {
  padding: 6px 10px;
  border-bottom: 1px solid rgba(255,255,255,0.04);
}
.tlm-sortable {
  cursor: pointer;
  user-select: none;
}
.tlm-sortable:hover { color: var(--accent, #3ddc84); }
.tlm-sort-arr {
  display: inline-block;
  margin-left: 4px;
  color: var(--accent, #3ddc84);
}
.tlm-row:hover { background: rgba(255,255,255,0.04); }
.tlm-row-sel  { background: rgba(61, 220, 132, 0.10) !important; }
.tlm-row-sel:hover { background: rgba(61, 220, 132, 0.15) !important; }

.tlm-num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.tlm-time { color: var(--accent, #3ddc84); font-weight: 600; }
.tlm-cat  { color: var(--ink-faint, #6e6e72); font-size: 11px; }
.tlm-col-cb { width: 28px; padding-right: 0; }
.tlm-col-cb input[type="checkbox"] {
  accent-color: var(--accent, #3ddc84);
  cursor: pointer;
}
.tlm-col-act { width: 36px; text-align: center; }
.tlm-open-btn {
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--border-strong, #2a2d31);
  color: var(--ink-muted, #b5b5b9);
  width: 24px;
  height: 24px;
  border-radius: 4px;
  font-size: 12px;
  cursor: pointer;
  padding: 0;
  line-height: 1;
}
.tlm-open-btn:hover {
  border-color: var(--accent, #3ddc84);
  color: var(--accent, #3ddc84);
}

/* Bottom compare bar — sticky at the viewport bottom so it's always
   reachable while scrolling through hundreds of rows. */
.telemetry-cmp-bar {
  position: sticky;
  bottom: 16px;
  margin: 16px 0 0 auto;
  width: fit-content;
  padding: 8px 14px;
  background: rgba(10, 14, 15, 0.95);
  border: 1px solid var(--accent, #3ddc84);
  border-radius: 999px;
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 12px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.4);
  backdrop-filter: blur(6px);
}
.telemetry-cmp-count {
  font-family: var(--font-mono, monospace);
  color: var(--accent, #3ddc84);
}

/* =========================================================================
   Tire-window analysis panel (v=44) — sits below the power-analysis
   panel in the Out view. SVG-based scatter chart with optimal-window
   highlight band.
   ========================================================================= */
.tire-analysis-panel {
  margin-top: 16px;
  padding: 16px;
  background: rgba(255,255,255,0.02);
  border: 1px solid var(--border-strong, #2a2d31);
  border-radius: 8px;
}
.tire-head {
  display: flex;
  align-items: baseline;
  gap: 12px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}
.tire-title {
  margin: 0;
  font-size: 14px;
  font-weight: 600;
  color: var(--ink, #e8e8ea);
}
.tire-subtitle {
  font-size: 12px;
  color: var(--ink-muted, #b5b5b9);
}
.tire-subtitle b  { color: var(--accent, #3ddc84); }
.tire-subtitle em { color: var(--ink, #e8e8ea); font-style: normal; }

.tire-controls {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}
.tire-controls label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--ink-muted, #b5b5b9);
}
.tire-controls select {
  background: rgba(0,0,0,0.3);
  border: 1px solid var(--border-strong, #2a2d31);
  color: var(--ink, #e8e8ea);
  padding: 4px 8px;
  border-radius: 4px;
  font-family: inherit;
  font-size: 12px;
}
.tire-controls select:focus {
  border-color: var(--accent, #3ddc84);
  outline: none;
}

.tire-window-pill {
  margin-left: auto;
  padding: 4px 12px;
  background: rgba(61, 220, 132, 0.10);
  border: 1px solid rgba(61, 220, 132, 0.35);
  border-radius: 999px;
  font-size: 12px;
  font-family: var(--font-mono, monospace);
  color: var(--ink, #e8e8ea);
}
.tire-window-pill b { color: var(--accent, #3ddc84); }
.tire-window-n     { color: var(--ink-faint, #6e6e72); }
.tire-window-empty { color: var(--ink-faint, #6e6e72); }

.tire-chart {
  background: #0a0e0f;
  border-radius: 4px;
  padding: 8px 4px 0 4px;
  margin-bottom: 8px;
}
.tire-chart-svg {
  display: block;
  width: 100%;
  height: auto;
}
.tire-chart-svg .tire-dot:hover circle { stroke-width: 2; }

.tire-hint {
  font-size: 11px;
  color: var(--ink-faint, #6e6e72);
  line-height: 1.5;
}
.tire-hint b  { color: var(--accent, #3ddc84); }
.tire-hint em { color: var(--ink, #e8e8ea); font-style: normal; }

.tire-empty {
  padding: 36px;
  text-align: center;
  font-size: 12px;
  color: var(--ink-muted, #b5b5b9);
}

/* =========================================================================
   Telemetry — session-grouped expandable cards (v=46). Each card collapses
   to a compact 1-line summary; expands to show the inline tire window
   + power curve analyses + a per-lap pick table for compare.
   ========================================================================= */
.tlm-sessions {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.tlm-session {
  border: 1px solid var(--border-strong, #2a2d31);
  border-radius: 8px;
  background: rgba(255,255,255,0.02);
  overflow: hidden;
  transition: border-color 0.15s;
}
.tlm-session:hover { border-color: rgba(61,220,132,0.35); }
.tlm-session-open  { border-color: rgba(61,220,132,0.5); }

.tlm-session-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  cursor: pointer;
  user-select: none;
}
.tlm-session-chev {
  font-family: monospace;
  font-size: 14px;
  color: var(--ink-muted, #b5b5b9);
  transition: transform 0.2s ease;
  width: 12px;
  text-align: center;
}
.tlm-session-open .tlm-session-chev {
  transform: rotate(90deg);
  color: var(--accent, #3ddc84);
}
.tlm-session-meta { flex: 1; min-width: 0; }
.tlm-session-line1 {
  font-size: 13px;
  color: var(--ink, #e8e8ea);
  display: flex; gap: 6px; align-items: baseline; flex-wrap: wrap;
}
.tlm-session-pilote  { font-weight: 600; }
.tlm-session-circuit { color: var(--accent, #3ddc84); }
.tlm-session-date    { color: var(--ink-muted, #b5b5b9); font-family: var(--font-mono, monospace); font-size: 12px; }
.tlm-session-sep     { color: var(--ink-faint, #6e6e72); }
.tlm-session-line2 {
  font-size: 11px;
  color: var(--ink-muted, #b5b5b9);
  margin-top: 2px;
}
.tlm-session-stats {
  display: flex;
  gap: 16px;
  font-size: 12px;
  color: var(--ink-muted, #b5b5b9);
  font-family: var(--font-mono, monospace);
  white-space: nowrap;
}
.tlm-session-stat b { color: var(--ink, #e8e8ea); font-weight: 600; }
.tlm-session-stat b.tlm-time { color: var(--accent, #3ddc84); }
.tlm-session-selpill {
  padding: 2px 8px;
  background: rgba(61,220,132,0.15);
  border: 1px solid rgba(61,220,132,0.35);
  border-radius: 999px;
  color: var(--accent, #3ddc84);
  font-size: 11px;
}
.tlm-session-go {
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--border-strong, #2a2d31);
  color: var(--ink-muted, #b5b5b9);
  width: 28px;
  height: 28px;
  border-radius: 4px;
  font-size: 13px;
  cursor: pointer;
  padding: 0; line-height: 1;
}
.tlm-session-go:hover {
  border-color: var(--accent, #3ddc84);
  color: var(--accent, #3ddc84);
}

/* The expansion area is hidden when collapsed (display:none) so the
   document layout doesn't pay for unhydrated cards. */
.tlm-session-body { display: none; }
.tlm-session-open > .tlm-session-body {
  display: block;
  padding: 0 14px 14px 14px;
  border-top: 1px solid var(--border-strong, #2a2d31);
}
/* The analysis pair sits side-by-side on wide screens, stacked otherwise */
.tlm-session-analysis-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 12px;
  margin-bottom: 12px;
}
@media (max-width: 1100px) {
  .tlm-session-analysis-row { grid-template-columns: 1fr; }
}
.tlm-session-power,
.tlm-session-tire {
  background: rgba(0,0,0,0.2);
  border: 1px solid var(--border-strong, #2a2d31);
  border-radius: 6px;
  min-height: 200px;
}
/* The per-corner panels carry their own internal padding via .power-analysis-panel
   / .tire-analysis-panel — kill the outer panel chrome inside the session
   card so we don't double-frame them. */
.tlm-session-power > .power-analysis-panel,
.tlm-session-tire  > .tire-analysis-panel {
  margin-top: 0;
  border: none;
  background: transparent;
}
.tlm-session-laps {
  border: 1px solid var(--border-strong, #2a2d31);
  border-radius: 6px;
  overflow: hidden;
}

/* Best-lap highlight inside a session card. Red on the row (text + a
   subtle left border) so it pops without clobbering legibility. Overrides
   the green .tlm-time color on the time column since "fastest red" is
   the convention we want here. The selection class still wins via the
   row order — a user-checked best lap shows the green selection halo
   ON TOP of the red colouring so both signals stay visible. */
.tlm-row-best         { color: #ff5b5b; }
.tlm-row-best td      { border-left: 1px solid transparent; }
.tlm-row-best td:first-child { border-left: 3px solid #ff5b5b; padding-left: 5px; }
.tlm-row-best .tlm-time { color: #ff5b5b; font-weight: 600; }
.tlm-row-best:hover   { background: rgba(255, 91, 91, 0.07); }
.tlm-row-best.tlm-row-sel { background: rgba(61, 220, 132, 0.10); } /* sel still wins for bg */

/* Clickable row affordance for the per-session lap list. Cursor signals
   intent; the hover row already had a subtle bg change inherited from
   .tlm-row:hover. */
.tlm-row-clickable    { cursor: pointer; }
.tlm-row-clickable .tlm-col-cb,
.tlm-row-clickable .tlm-cb { cursor: default; }

/* === Community section (issue #4) =================================== */
.community-view { padding: 0 8px; }
.community-header-row {
  display: flex; align-items: center; gap: 14px;
}
.community-header-row .library-title { margin: 0; }
.community-circuits {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 12px;
  margin-top: 12px;
}
.community-circuit-card {
  display: block;
  text-align: left;
  padding: 14px 16px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  font-family: inherit; color: inherit;
  transition: border-color 120ms, background 120ms, transform 120ms;
}
.community-circuit-card:hover {
  border-color: var(--accent);
  background: rgba(0, 255, 140, 0.03);
  transform: translateY(-1px);
}
.community-circuit-card .cc-name {
  font-family: var(--font-display);
  font-size: 16px;
  letter-spacing: 0.04em;
  margin-bottom: 6px;
}
.community-circuit-card .cc-stats {
  display: flex; gap: 12px;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-dim);
  margin-bottom: 4px;
}
.community-circuit-card .cc-stats b {
  color: var(--accent);
  font-variant-numeric: tabular-nums;
}
.community-circuit-card .cc-last {
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--text-dim);
  opacity: 0.8;
}
.community-sessions { margin-top: 12px; }
.community-session { cursor: pointer; }
.community-session .tlm-session-chev { color: var(--accent); }

/* ---- Community leaderboard panel -------------------------------------- */
.community-leaderboard { margin: 16px 0 4px; }
.community-leaderboard:empty { display: none; }
.leaderboard-card {
  border: 1px solid var(--border);
  border-radius: var(--radius-s);
  background: var(--surface, rgba(255,255,255,0.02));
  overflow: hidden;
}
.leaderboard-header {
  display: flex; align-items: baseline; justify-content: space-between;
  gap: 12px;
  padding: 10px 14px; border-bottom: 1px solid var(--border);
  background: rgba(255,255,255,0.02);
}
.leaderboard-title {
  margin: 0; font-size: 14px; font-weight: 600; letter-spacing: 0.02em;
}
.leaderboard-sub {
  font-size: 11.5px; color: var(--text-dim); font-family: var(--font-mono);
  text-transform: uppercase; letter-spacing: 0.05em;
}
.leaderboard-body { padding: 0; }
.leaderboard-table {
  width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums;
}
.leaderboard-table thead th {
  font-size: 11px; font-weight: 500; text-align: left;
  color: var(--text-dim); padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  background: rgba(255,255,255,0.015);
}
.leaderboard-table tbody td {
  padding: 7px 10px; font-size: 13px; border-bottom: 1px solid rgba(255,255,255,0.04);
}
.leaderboard-table tbody tr:last-child td { border-bottom: none; }
.leaderboard-table .lb-rank { width: 36px; color: var(--text-dim); text-align: center; }
.leaderboard-table .lb-time { font-family: var(--font-mono); }
.leaderboard-table .lb-gap  { font-family: var(--font-mono); color: var(--text-dim); }
.leaderboard-table .lb-speed,
.leaderboard-table .lb-power { font-family: var(--font-mono); color: var(--text-dim); }
.leaderboard-table .lb-date  { color: var(--text-dim); white-space: nowrap; }
.leaderboard-row { cursor: pointer; transition: background-color 80ms ease; }
.leaderboard-row:hover,
.leaderboard-row:focus-visible {
  background: rgba(61, 220, 132, 0.06);
  outline: none;
}
.leaderboard-row:first-child .lb-rank { color: var(--accent); font-weight: 600; }

.privacy-btn { width: 28px; padding: 2px 0; }
.privacy-btn.is-public  { color: var(--accent); border-color: rgba(61, 220, 132, 0.45); }
.privacy-btn.is-private { color: #f4b350;       border-color: rgba(244, 179, 80, 0.45); }
.privacy-btn:hover { filter: brightness(1.15); }
.profile-share { border: 1px solid var(--border); border-radius: var(--radius-s); padding: 10px 14px; margin-top: 14px; }
.profile-share legend { padding: 0 6px; font-family: var(--font-mono); font-size: 11px; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.05em; }
.profile-share-toggle { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.profile-share-hint { font-size: 11.5px; color: var(--text-dim); margin: 4px 0 10px; }
.profile-share-bulk { display: flex; gap: 8px; }

.privacy-chip-btn { cursor: pointer; font-family: inherit; }
.privacy-chip-btn.is-private { color: #f4b350; border-color: rgba(244, 179, 80, 0.45); background: rgba(244, 179, 80, 0.08); }
.privacy-chip-btn.is-private:hover { background: rgba(244, 179, 80, 0.16); }
.privacy-chip-static { color: var(--accent); border-color: rgba(61, 220, 132, 0.35); cursor: default; }

/* === Per-lap + partial-share chips (issue #5) ====================== */
.privacy-chip-btn.is-partial { color: #62c4ff; border-color: rgba(98, 196, 255, 0.45); background: rgba(98, 196, 255, 0.08); }
.privacy-chip-btn.is-partial:hover { background: rgba(98, 196, 255, 0.16); }
.privacy-chip-btn.is-public  { color: var(--accent); border-color: rgba(61, 220, 132, 0.45); background: rgba(61, 220, 132, 0.08); }
.privacy-chip-btn.is-public:hover  { background: rgba(61, 220, 132, 0.16); }
.tlm-share-chip { font-family: inherit; }
.tlm-col-share { width: 64px; text-align: center; }
.tlm-col-share .privacy-btn { padding: 1px 6px; }

/* ===================================================================
   Language picker (topbar)
   =================================================================== */
.lang-picker {
  position: relative;
  display: inline-flex;
  align-items: center;
}
.lang-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 8px;
  height: 28px;
  background: var(--bg-3);
  color: var(--text);
  border: 1px solid var(--border-strong);
  border-radius: 14px;
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.04em;
  cursor: pointer;
  user-select: none;
  transition: background 0.12s ease, border-color 0.12s ease;
}
.lang-pill:hover {
  background: var(--bg-hover, var(--bg-2));
  border-color: var(--accent-soft);
}
.lang-pill[aria-expanded="true"] {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent) inset;
}
.lang-flag { font-size: 14px; line-height: 1; }
.lang-code { font-weight: 600; }
.lang-caret { font-size: 9px; color: var(--text-dim); }

.lang-menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  margin: 0;
  padding: 4px;
  list-style: none;
  min-width: 160px;
  background: var(--bg-2);
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  box-shadow: var(--shadow-2);
  z-index: 1000;
}
.lang-menu[hidden] { display: none; }
.lang-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border-radius: 4px;
  cursor: pointer;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text);
  outline: none;
}
.lang-item:hover,
.lang-item:focus {
  background: var(--bg-3);
}
.lang-item.is-selected {
  color: var(--accent);
}
.lang-item .lang-label { flex: 1; }
.lang-item .lang-check {
  width: 12px;
  text-align: right;
  color: var(--accent);
  font-weight: 600;
}
@media (max-width: 640px) {
  .lang-pill .lang-code { display: none; }
  .lang-pill { padding: 4px 6px; }
}

/* ----- Actualité — nav unread badge ----------------------- */
.primary-nav-item { position: relative; }
.pn-badge {
  position: absolute; top: 6px; right: 8px;
  min-width: 18px; height: 18px;
  border-radius: 9px;
  background: var(--best, #00ff8c);
  color: #001;
  font-size: 10px; font-weight: 700;
  display: inline-flex; align-items: center; justify-content: center;
  padding: 0 5px; line-height: 1;
  font-family: var(--font-mono);
}
.pn-badge:empty, .pn-badge[hidden] { display: none; }

/* ----- Actualité — feed view ----------------------------- */
.news-wrap { padding: 20px 24px; max-width: 1080px; margin: 0 auto; }
.news-header { display: flex; align-items: baseline; gap: 16px; margin-bottom: 8px; }
.news-title  { font-family: "Bebas Neue", sans-serif; font-size: 32px; letter-spacing: 0.04em; margin: 0; }
.news-sub    { color: var(--text-dim); font-size: 13px; }
.news-toolbar {
  display: flex; gap: 8px; align-items: center; flex-wrap: wrap;
  margin: 14px 0 18px 0;
}
.news-toolbar .filter-chip {
  background: var(--bg-2); border: 1px solid var(--border);
  color: var(--text-dim); padding: 5px 12px; border-radius: 14px;
  font-size: 12px; cursor: pointer; font-family: var(--font-mono);
}
.news-toolbar .filter-chip.is-active {
  background: var(--accent, #59c8ff); color: #001; border-color: transparent;
}
.news-day-header {
  font-family: var(--font-mono); font-size: 11px; letter-spacing: 0.1em;
  color: var(--text-faint); text-transform: uppercase;
  margin: 18px 0 6px 0; border-bottom: 1px solid var(--border); padding-bottom: 4px;
}
.news-card {
  background: var(--bg-2); border: 1px solid var(--border); border-radius: 8px;
  padding: 12px 14px; margin-bottom: 8px;
  display: flex; gap: 12px; align-items: flex-start;
}
.news-card.is-unread { border-left: 3px solid var(--best, #00ff8c); }
.news-card-icon {
  font-size: 22px; line-height: 1; width: 36px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
}
.news-card-body { flex: 1; min-width: 0; }
.news-card-title {
  font-weight: 600; font-size: 14px; line-height: 1.4;
}
.news-card-meta {
  color: var(--text-dim); font-size: 12px; margin-top: 4px;
  font-family: var(--font-mono);
}
.news-card-actions { margin-top: 6px; display: flex; gap: 8px; }
.news-empty {
  text-align: center; color: var(--text-dim); font-size: 14px;
  padding: 40px 16px; border: 1px dashed var(--border); border-radius: 8px;
}

.news-subs-section { margin-top: 28px; }
.news-subs-title {
  font-family: "Bebas Neue", sans-serif; font-size: 18px; letter-spacing: 0.04em;
  margin: 0 0 10px 0; color: var(--text-dim);
}
.news-subs-list { list-style: none; padding: 0; margin: 0; }
.news-subs-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 12px; border: 1px solid var(--border); border-radius: 6px;
  margin-bottom: 6px; background: var(--bg-2);
}
.news-subs-item-name { flex: 1; font-weight: 500; }
.news-subs-item-source {
  font-size: 11px; color: var(--text-faint);
  font-family: var(--font-mono); text-transform: uppercase;
}

.subscribe-pill {
  background: var(--bg-2); border: 1px solid var(--border);
  color: var(--text-dim); padding: 5px 12px; border-radius: 14px;
  font-size: 12px; cursor: pointer; font-family: var(--font-mono);
  display: inline-flex; align-items: center; gap: 6px;
}
.subscribe-pill:hover { background: var(--bg-3, var(--bg-2)); }
.subscribe-pill.is-subscribed {
  background: rgba(0, 255, 140, 0.12); color: var(--best, #00ff8c);
  border-color: rgba(0, 255, 140, 0.3);
}


/* =====================================================================
   Mobile responsive layer (issue #12)
   =====================================================================
   Strictly additive: desktop layout above 768px stays byte-for-byte the
   same. Below that breakpoint the sidebar becomes an off-canvas drawer
   toggled by the hamburger in the top-bar, side-by-side analysis grids
   stack vertically, tables overflow horizontally with a sticky first
   column, and hit-targets bump to ≥ 44 px per Apple HIG / 48 dp Material.
   ===================================================================== */

/* Hamburger + backdrop — invisible on desktop regardless of state. */
.nav-burger        { display: none; }
.nav-backdrop      { display: none; }

@media (max-width: 768px) {

  /* ---- top-bar : hamburger appears, padding tightens, brand text hides ---- */
  .nav-burger {
    display: inline-flex; flex-direction: column; justify-content: center;
    gap: 4px;
    width: 44px; height: 44px;     /* Apple HIG min hit-target */
    padding: 0; margin: 0;
    background: transparent; border: 1px solid var(--border);
    border-radius: var(--radius-s, 6px);
    cursor: pointer;
    -webkit-tap-highlight-color: rgba(0, 255, 140, 0.18);
  }
  .nav-burger:active { background: rgba(255,255,255,0.04); }
  .nav-burger-bar {
    display: block; width: 20px; height: 2px; background: var(--text);
    margin: 0 auto; transition: transform 160ms ease, opacity 160ms ease;
  }
  /* Morph into an X when the drawer is open (when aria-expanded=true). */
  .nav-burger[aria-expanded="true"] .nav-burger-bar:nth-child(1) {
    transform: translateY(6px) rotate(45deg);
  }
  .nav-burger[aria-expanded="true"] .nav-burger-bar:nth-child(2) {
    opacity: 0;
  }
  .nav-burger[aria-expanded="true"] .nav-burger-bar:nth-child(3) {
    transform: translateY(-6px) rotate(-45deg);
  }

  .topbar {
    padding: env(safe-area-inset-top, 0) 10px 0 10px;
    height: calc(56px + env(safe-area-inset-top, 0px));
    gap: 10px;
  }
  /* Hide the verbose middle file-info on phones — sessions get their own
     header inside the content area, the top-bar stays focused on actions. */
  .topbar .file-info { display: none; }
  /* Library button text label hides on phones; the ⚏ icon is enough. */
  #libraryBtn span:not(.btn-ic) { display: none; }
  /* Import button keeps its label — it's the primary CTA on mobile too. */

  /* ---- layout : single column, sidebar becomes off-canvas drawer ---- */
  .layout {
    grid-template-columns: 1fr;
    height: calc(100dvh - 56px - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px));
  }

  .sidebar {
    position: fixed;
    top: calc(56px + env(safe-area-inset-top, 0px));
    left: 0;
    width: min(80vw, 320px);
    height: calc(100dvh - 56px - env(safe-area-inset-top, 0px));
    /* Slightly lighter than the page bg + a green right accent, so the
       drawer reads as a distinct panel over the dimmed content beneath
       it. Without this, bg-1 on drawer + bg-1 on page + a semi-
       transparent backdrop all look the same dark wash and the drawer
       feels invisible (issue #12 follow-up). */
    background: #14191c;
    border-right: 2px solid var(--accent, #00ff8c);
    /* Above Leaflet's zoom controls (z-index ~1000) to keep the drawer
       cleanly on top when a map is rendered underneath. */
    z-index: 2000;
    transform: translateX(-100%);
    transition: transform 220ms cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 6px 0 32px rgba(0, 0, 0, 0.55);
    padding-bottom: env(safe-area-inset-bottom, 0px);
    /* WebKit (iOS Safari) sometimes drops `transform: translateX` from
       the compositor when the element starts with `display: none`;
       will-change forces a compositor layer up front so the slide
       animation actually shows. */
    will-change: transform;
  }
  .sidebar.is-open { transform: translateX(0); }

  .nav-backdrop {
    display: block;
    position: fixed;
    top: calc(56px + env(safe-area-inset-top, 0px));
    left: 0; right: 0; bottom: 0;
    background: rgba(0, 0, 0, 0.55);
    z-index: 1900;            /* below the drawer (2000) but above Leaflet (~1000) */
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
  }
  .nav-backdrop[hidden] { display: none !important; }

  /* Bigger nav rows for tactile targets. */
  .primary-nav-item {
    min-height: 48px;
    font-size: 14px;
  }
  .pn-label { font-size: inherit; }

  /* ---- content area : tighter padding, full width ---- */
  #content, main.content, .content,
  .layout > section, .layout > div:not(.sidebar):not(.nav-backdrop) {
    padding-left:  12px;
    padding-right: 12px;
    padding-bottom: max(16px, env(safe-area-inset-bottom, 0px));
  }
  /* Library / per-section headers — wrap, not overflow. */
  .library-header, .community-header-row, .out-view-header-row {
    flex-wrap: wrap;
    gap: 8px;
  }
  .library-title, .out-view-title {
    font-size: 18px;
  }

  /* ---- analysis panels : stack the side-by-side grids ---- */
  /* Generic catch-all for any 2-column grid in the analysis area. */
  .tlm-session-body,
  .analysis-grid,
  .power-curve-grid,
  .tire-window-grid,
  .out-analysis,
  .compare-grid,
  .tlm-filter-grid {
    grid-template-columns: 1fr !important;
  }
  /* Lap-detail page: track + charts stacked rather than 2/3 + 1/3. */
  .lap-detail-grid,
  .out-view-grid,
  .lap-view-grid {
    grid-template-columns: 1fr !important;
  }
  /* Stat cards inside dashboards wrap. */
  .stat-card-row, .dashboard-cards, .pilote-cards, .circuit-cards {
    grid-template-columns: 1fr !important;
  }

  /* Chart.js canvases adapt to width on mobile; the Chart.js options
     in app.js already toggle maintainAspectRatio:false at the same
     breakpoint, this just clamps the height. */
  canvas.chart-canvas,
  .chart-wrap > canvas,
  .leaderboard-card canvas {
    max-height: 260px !important;
  }

  /* ---- tables : horizontal scroll w/ sticky first column ---- */
  /* Wrap any oversized table in a scroll container. Apply to known tables. */
  table.lap-table,
  table.files-table,
  table.imports-table,
  .leaderboard-table {
    display: block;
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    white-space: nowrap;
  }
  table.lap-table tbody tr td:first-child,
  table.lap-table thead tr th:first-child {
    position: sticky; left: 0;
    background: var(--bg-1, #0b0e10);
    z-index: 2;
  }

  /* ---- forms / inputs : touch-friendly ---- */
  input, select, textarea, button.btn {
    font-size: 16px;       /* prevents iOS Safari zoom-on-focus */
    min-height: 40px;
  }
  .btn { padding: 8px 12px; }

  /* ---- track view canvas takes full width on mobile ---- */
  .track-svg-wrap, .track-svg-wrap > svg, .track-leaflet {
    width: 100% !important;
    max-width: 100% !important;
  }
  .track-leaflet { height: 280px; }

  /* ---- auth screen : full-screen card on phones ---- */
  .auth-card {
    width: calc(100vw - 24px);
    max-width: 420px;
    padding: 18px;
  }

  /* ---- modals : full-bleed on phones ---- */
  .modal, .dialog {
    width: calc(100vw - 16px) !important;
    max-width: calc(100vw - 16px) !important;
    max-height: calc(100dvh - 32px);
  }
}

/* Tighter pass for very small screens (older iPhone SE, narrow Androids). */
@media (max-width: 380px) {
  .topbar { gap: 6px; padding-left: 6px; padding-right: 6px; }
  .lang-pill .lang-code { display: none; }   /* keep just the flag */
  .user-chip-role { display: none; }
}

/* Coarse-pointer (touch) regardless of width — slightly larger taps
   on touch-laptops and convertible tablets in desktop mode. */
@media (pointer: coarse) {
  .btn { min-height: 40px; }
  .primary-nav-item { min-height: 44px; }
}
