:root {
  --orange: #E07820;
  --orange-dark: #b85c0a;
  --ink: #1c1208;
  --bg: #faf8f5;
}

* { box-sizing: border-box; }
.hidden { display: none !important; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--ink);
  background: var(--bg);
  line-height: 1.5;
}

.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  padding: 0 1.25rem;
  background: var(--orange);
  color: #fff;
  min-height: 54px;
}

.site-header a { color: #fff; text-decoration: none; }
.site-header .brand {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-weight: 700;
  font-size: 1.05rem;
  letter-spacing: 0.02em;
  padding: 0.5rem 0;
}
.site-header .brand img {
  height: 40px;
  width: auto;
}
.site-header nav { display: flex; align-items: center; gap: 0.25rem; flex-wrap: wrap; }
.site-header nav a {
  padding: 0.35rem 0.75rem;
  border-radius: 5px;
  font-size: 0.9rem;
  transition: background 0.15s;
}
.site-header nav a:hover { background: rgba(255,255,255,0.18); }
.site-header .user { opacity: 0.85; margin-right: 0.25rem; font-size: 0.88rem; }
.site-header nav button.linklike {
  background: none; border: none; color: inherit; cursor: pointer;
  font: inherit; font-size: 0.9rem; padding: 0.35rem 0.75rem; border-radius: 5px;
  transition: background 0.15s;
}
.site-header nav button.linklike:hover { background: rgba(255,255,255,0.18); }

/* Nav dropdown */
.nav-dropdown {
  position: relative;
}
.nav-dropdown-toggle {
  padding: 0.35rem 0.75rem;
  border-radius: 5px;
  font-size: 0.9rem;
  font-family: inherit;
  font-weight: inherit;
  color: #fff;
  background: none;
  border: none;
  cursor: pointer;
  transition: background 0.15s;
  white-space: nowrap;
}
.nav-dropdown-toggle:hover,
.nav-dropdown.open .nav-dropdown-toggle {
  background: rgba(255,255,255,0.18);
}
.nav-dropdown-menu {
  display: none;
  position: absolute;
  top: calc(100% + 4px);
  right: 0;
  background: #fff;
  border: 1px solid #e8ddd0;
  border-radius: 8px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.12);
  min-width: 150px;
  z-index: 200;
  overflow: hidden;
  padding: 0.25rem 0;
}
.nav-dropdown.open .nav-dropdown-menu { display: block; }
.nav-dropdown-menu a {
  display: block;
  padding: 0.5rem 1rem;
  color: #3a2a1a !important;
  font-size: 0.9rem;
  white-space: nowrap;
  border-radius: 0;
  transition: background 0.1s;
}
.nav-dropdown-menu a:hover { background: #faf3ea; }

.container { max-width: 980px; margin: 2rem auto; padding: 0 1.25rem; }

.lead { font-size: 1.15rem; color: #5c3010; }

.status {
  margin-top: 2rem;
  padding: 1.25rem 1.5rem;
  background: #fff;
  border: 1px solid #e8d0b0;
  border-radius: 8px;
}

code { background: #fde8cc; padding: 0.1em 0.35em; border-radius: 4px; color: #8c4010; }

.site-footer {
  margin-top: 3rem;
  padding: 1rem 1.25rem;
  text-align: center;
  color: #7a6050;
  border-top: 1px solid #e8d0b0;
}

/* ── Home ─────────────────────────────────────────────────────────── */

.home-hero {
  text-align: center;
  padding: 2rem 0 1.5rem;
}
.home-hero h1 {
  margin: 0 0 0.4rem;
  font-size: 1.8rem;
  color: var(--ink);
}
.home-hero .lead { margin: 0 0 2rem; }

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1.25rem;
  margin-top: 1.5rem;
}

.card {
  background: #fff;
  border: 1px solid #e8d0b0;
  border-radius: 8px;
  padding: 1.25rem 1.5rem;
}

.card h2 { margin-top: 0; font-size: 1.05rem; color: var(--orange); }

/* ── Car photo grid (home page) ───────────────────────────────────── */

.car-photo-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 1rem;
  margin-top: 1.5rem;
  margin-bottom: 2rem;
}

.car-photo-card {
  display: block;
  background: #fff;
  border: 1px solid #e8d0b0;
  border-radius: 10px;
  overflow: hidden;
  text-decoration: none;
  color: var(--ink);
  transition: box-shadow 0.18s, transform 0.18s, border-color 0.18s;
}
.car-photo-card:hover {
  box-shadow: 0 6px 24px rgba(224,120,32,0.18);
  transform: translateY(-2px);
  border-color: var(--orange);
}

.car-photo-wrap {
  width: 100%;
  aspect-ratio: 16/9;
  background: #faf0e8;
  overflow: hidden;
}
.car-photo-wrap img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.car-photo-info {
  padding: 0.65rem 0.85rem 0.75rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.car-photo-name {
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--orange);
  flex: 1;
}

/* ── Car banner (history page) ────────────────────────────────────── */

.car-banner {
  width: 100%;
  max-height: 220px;
  object-fit: cover;
  border-radius: 10px;
  margin-bottom: 1.25rem;
  display: block;
  background: #faf0e8;
}

/* ── Stat table ───────────────────────────────────────────────────── */

.car-list { list-style: none; margin: 0 0 1rem; padding: 0; }
.car-list li { padding: 0.35rem 0; border-bottom: 1px solid #f5e8d0; }
.car-list li:last-child { border-bottom: none; }
.car-list a { font-weight: 600; color: var(--orange); text-decoration: none; }
.car-list a:hover { text-decoration: underline; }

.stat-table { width: 100%; border-collapse: collapse; }
.stat-table th { text-align: left; color: #7a4a18; font-weight: 500; padding: 0.3rem 0; width: 60%; }
.stat-table td { text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; }

.btn {
  display: inline-block;
  padding: 0.45rem 1rem;
  background: var(--orange);
  color: #fff;
  border-radius: 5px;
  text-decoration: none;
  font-size: 0.9rem;
  border: none;
  cursor: pointer;
}
.btn:hover { background: var(--orange-dark); }

/* ── Utilities ────────────────────────────────────────────────────── */

.badge {
  display: inline-block;
  padding: 0.1em 0.45em;
  background: #fde8cc;
  color: var(--orange-dark);
  border-radius: 4px;
  font-size: 0.78rem;
  font-weight: 600;
}

.muted { color: #7a6050; }
.small { font-size: 0.85em; }
.mono { font-family: ui-monospace, monospace; }
.nowrap { white-space: nowrap; }
.error { color: #b91c1c; }

/* ── Filter form ──────────────────────────────────────────────────── */

.filter-form {
  background: #fff;
  border: 1px solid #e8d0b0;
  border-radius: 8px;
  padding: 1rem 1.25rem;
  margin-bottom: 1.5rem;
}

.filter-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1.25rem;
  align-items: center;
}

.filter-row label {
  font-size: 0.85rem;
  font-weight: 600;
  color: #7a4a18;
}

.filter-row select {
  padding: 0.35rem 0.6rem;
  border: 1px solid #d4b090;
  border-radius: 5px;
  font-size: 0.9rem;
  background: #fff;
  color: var(--ink);
  cursor: pointer;
}

/* ── Results table ────────────────────────────────────────────────── */

.table-wrap { overflow-x: auto; margin-bottom: 2rem; }

.results-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
  background: #fff;
  border: 1px solid #e8d0b0;
  border-radius: 8px;
  overflow: hidden;
}

.results-table th {
  background: #faf0e5;
  text-align: left;
  padding: 0.55rem 0.75rem;
  font-size: 0.8rem;
  font-weight: 600;
  color: #7a4a18;
  border-bottom: 1px solid #e8d0b0;
  white-space: nowrap;
}

.results-table td {
  padding: 0.5rem 0.75rem;
  border-bottom: 1px solid #f5e8d0;
  vertical-align: middle;
}

.results-table tbody tr:last-child td { border-bottom: none; }
.results-table tbody tr:hover { background: #fdf5ee; }
.results-table .num { text-align: right; font-variant-numeric: tabular-nums; }

/* ── Charts ───────────────────────────────────────────────────────── */

.charts {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  margin-top: 1.5rem;
}

.chart-card {
  background: #fff;
  border: 1px solid #e8d0b0;
  border-radius: 8px;
  padding: 1.1rem 1.25rem 1.25rem;
}

.chart-card h3 {
  margin: 0 0 0.75rem;
  font-size: 0.9rem;
  font-weight: 600;
  color: #7a4a18;
}

/* ── Tabs ─────────────────────────────────────────────────────────── */

.tab-bar {
  display: flex;
  gap: 0.25rem;
  border-bottom: 2px solid #e8d0b0;
  margin-bottom: 1.25rem;
}

.tab-btn {
  padding: 0.5rem 1.1rem;
  border: none;
  background: none;
  font-size: 0.92rem;
  font-weight: 600;
  color: #7a6050;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  border-radius: 4px 4px 0 0;
  transition: color 0.15s, border-color 0.15s;
}
.tab-btn:hover { color: var(--ink); }
.tab-btn.active { color: var(--orange); border-bottom-color: var(--orange); }

.tab-panel.hidden { display: none; }

/* ── Lap chart controls ───────────────────────────────────────────── */

.lap-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.lap-toggle {
  padding: 0.3rem 0.75rem;
  border-radius: 999px;
  border: 2px solid var(--col, #888);
  background: transparent;
  color: #7a6050;
  font-size: 0.8rem;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.lap-toggle.active {
  background: var(--col, #888);
  color: #fff;
}

/* ── Messages ─────────────────────────────────────────────────────── */

.messages { list-style: none; margin: 0 0 1rem; padding: 0; }
.msg {
  padding: 0.65rem 1rem;
  border-radius: 6px;
  margin-bottom: 0.5rem;
  font-size: 0.9rem;
}
.msg--success { background: #dcfce7; color: #166534; border: 1px solid #bbf7d0; }
.msg--error   { background: #fee2e2; color: #991b1b; border: 1px solid #fecaca; }
.msg--info    { background: #dbeafe; color: #1e40af; border: 1px solid #bfdbfe; }
.msg--warning { background: #fef9c3; color: #854d0e; border: 1px solid #fde68a; }

/* ── Import dashboard ─────────────────────────────────────────────── */

.import-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
}
.import-header h1 { margin: 0; }

.stat-bar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1.25rem;
  font-size: 0.9rem;
  color: #7a4a18;
}

.pill {
  display: inline-block;
  padding: 0.15em 0.6em;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 600;
}
.pill--ok   { background: #dcfce7; color: #166534; }
.pill--warn { background: #fef9c3; color: #854d0e; }
.pill--err  { background: #fee2e2; color: #991b1b; }

.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1rem;
}
.filter-form.inline { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; }
.bulk-form { margin-left: auto; }

.btn--ghost {
  background: transparent;
  border: 1px solid #d4b090;
  color: #7a4a18;
  padding: 0.4rem 0.8rem;
  border-radius: 5px;
  text-decoration: none;
  font-size: 0.88rem;
  cursor: pointer;
}
.btn--ghost:hover { border-color: var(--orange); color: var(--orange); }
.btn--accent { background: #2563eb; }
.btn--accent:hover { background: #1d4ed8; }
.btn--sm { padding: 0.25rem 0.6rem; font-size: 0.82rem; }
.btn[disabled] { opacity: 0.45; cursor: not-allowed; }

.import-table .row--imported td { color: #9aab9f; }
.import-table .row--imported .tick { color: #16a34a; font-weight: 700; }
.import-table .cross { color: #9ca3af; }
.center { text-align: center; }
.inline-form { display: inline; }

.badge--type-race     { background: #dbeafe; color: #1e40af; }
.badge--type-practice { background: #f3e8ff; color: #6b21a8; }
.badge--type-heat     { background: #ffedd5; color: #9a3412; }

.pagination {
  display: flex;
  gap: 1rem;
  align-items: center;
  justify-content: center;
  margin: 1.25rem 0;
  font-size: 0.9rem;
}
.pagination a { color: var(--orange); text-decoration: none; font-weight: 600; }
.pagination a:hover { text-decoration: underline; }

.runs-section { margin-top: 2.5rem; }
.runs-section h2 { font-size: 1rem; color: #7a4a18; margin-bottom: 0.75rem; }

/* ── Progress overlay ─────────────────────────────────────────────── */

.progress-overlay {
  position: fixed;
  inset: 0;
  background: rgba(28,18,8,0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}
.progress-overlay.hidden { display: none; }

.progress-box {
  background: #fff;
  border-radius: 12px;
  padding: 2rem 2.25rem;
  width: min(480px, 90vw);
  box-shadow: 0 20px 60px rgba(28,18,8,0.25);
  text-align: center;
}
.progress-box h2 { margin: 0 0 1.25rem; font-size: 1.1rem; color: var(--ink); }

.progress-track {
  background: #e8d0b0;
  border-radius: 999px;
  height: 12px;
  overflow: hidden;
  margin-bottom: 0.75rem;
}
.progress-fill {
  height: 100%;
  background: var(--orange);
  border-radius: 999px;
  transition: width 0.25s ease;
  width: 0%;
}

.progress-label {
  font-size: 0.88rem;
  color: #7a4a18;
  margin: 0 0 0.25rem;
  min-height: 1.25em;
  word-break: break-all;
}
.progress-count {
  font-size: 0.82rem;
  color: #9ca3af;
  margin: 0 0 0.25rem;
}
.progress-eta {
  font-size: 0.8rem;
  margin: 0 0 0.5rem;
}

.progress-errors {
  margin-top: 0.75rem;
  text-align: left;
  max-height: 140px;
  overflow-y: auto;
  background: #fef2f2;
  border: 1px solid #fecaca;
  border-radius: 6px;
  padding: 0.5rem 0.75rem;
}
.progress-errors.hidden { display: none; }
.prog-err { font-size: 0.8rem; color: #991b1b; padding: 0.2rem 0; }

/* ── Merge page ───────────────────────────────────────────────────── */

.merge-section {
  background: #fff;
  border: 1px solid #e8d0b0;
  border-radius: 8px;
  padding: 1.25rem 1.5rem;
  margin-bottom: 1.5rem;
}
.merge-section h2 { margin-top: 0; font-size: 1rem; color: var(--orange); }

.merge-grid { display: flex; flex-direction: column; gap: 1rem; }

.merge-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 0.75rem;
}
.merge-field { display: flex; flex-direction: column; gap: 0.3rem; flex: 1; min-width: 200px; }
.merge-field label { font-size: 0.82rem; font-weight: 600; color: #7a4a18; }
.merge-select { padding: 0.4rem 0.6rem; border: 1px solid #d4b090; border-radius: 5px; font-size: 0.9rem; width: 100%; }

.merge-arrow { font-size: 1.4rem; color: var(--orange); padding-bottom: 0.25rem; align-self: flex-end; }

.merge-preview {
  padding: 0.75rem 1rem;
  border-radius: 6px;
  font-size: 0.88rem;
  line-height: 1.6;
}
.merge-preview p { margin: 0.2rem 0; }
.merge-preview--ok  { background: #dcfce7; border: 1px solid #bbf7d0; }
.merge-preview--error { background: #fee2e2; border: 1px solid #fecaca; color: #991b1b; }

/* ── Pitstop detection panel ──────────────────────────────────────── */

.pitstop-panel {
  background: #fff;
  border: 1px solid #e8d0b0;
  border-left: 4px solid var(--orange);
  border-radius: 8px;
  padding: 0.85rem 1rem;
  margin-bottom: 1rem;
}
.pitstop-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.75rem;
}
.pitstop-panel-footer {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-top: 0.75rem;
  padding-top: 0.75rem;
  border-top: 1px solid #f5e8d0;
}

.detect-btn {
  font-size: 0.75rem;
  padding: 0.2rem 0.55rem;
  margin-left: 0.15rem;
}

/* ── Tag picker tooltip ───────────────────────────────────────────── */

.tag-picker {
  position: absolute;
  background: #fff;
  border: 1px solid #e8d0b0;
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(28,18,8,0.15);
  padding: 0.6rem 0.75rem 0.75rem;
  z-index: 200;
  min-width: 160px;
}
.tag-picker-title {
  font-size: 0.8rem;
  color: #7a4a18;
  margin-bottom: 0.5rem;
}
.tag-picker-options {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}
.tag-btn {
  text-align: left;
  padding: 0.35rem 0.6rem;
  border: 1px solid #e8d0b0;
  background: #faf8f5;
  border-radius: 5px;
  font-size: 0.85rem;
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s;
}
.tag-btn:hover      { background: #fde8cc; border-color: var(--orange); }
.tag-btn--active    { background: #fde8cc; border-color: var(--orange); font-weight: 600; }
.tag-btn--clear     { color: #7a6050; }

/* ── Pitstop summary table ────────────────────────────────────────── */

.pit-table-heading {
  font-size: 0.95rem;
  font-weight: 600;
  color: #7a4a18;
  margin: 1.5rem 0 0.6rem;
}

/* ── Lap chart tab position context (needed for tag-picker absolute) */

#tab-laps { position: relative; }

/* ── Confirmation modal ───────────────────────────────────────────── */

.confirm-box { text-align: left; }
.confirm-box h2 { margin-top: 0; font-size: 1.05rem; }
.confirm-raw {
  background: #faf0e5;
  border: 1px solid #e8d0b0;
  border-radius: 5px;
  padding: 0.5rem 0.75rem;
  font-family: ui-monospace, monospace;
  font-size: 0.88rem;
  word-break: break-all;
}
.confirm-suggestions {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin: 0.75rem 0;
}
.suggest-btn {
  text-align: left;
  padding: 0.55rem 0.85rem;
  background: #fef5e8;
  border: 1px solid #d4a868;
  color: var(--ink);
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.88rem;
}
.suggest-btn:hover { background: #fde8cc; border-color: var(--orange); }
.confirm-actions {
  display: flex;
  gap: 0.75rem;
  margin-top: 0.5rem;
  flex-wrap: wrap;
}

/* ── Live timing ──────────────────────────────────────────────────── */

.live-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1.5rem;
}
.live-header h1 { margin: 0; }

.live-status-bar {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.88rem;
  color: #7a6050;
}

.live-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #aaa;
  flex-shrink: 0;
}
.live-dot-ok  { background: #22c55e; animation: live-pulse 1.8s ease-in-out infinite; }
.live-dot-err { background: #ef4444; }
@keyframes live-pulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.4; }
}

.live-refresh-info { color: #aaa; }

.live-event-block {
  background: #fff;
  border: 1px solid #e8ddd0;
  border-radius: 10px;
  margin-bottom: 2rem;
  overflow: hidden;
}
.live-event-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.5rem;
  padding: 0.85rem 1.1rem 0;
  border-bottom: 1px solid #f0e8dc;
}
.live-event-name { margin: 0; font-size: 1.1rem; color: var(--orange); }

.live-session-tabs {
  display: flex;
  gap: 0.25rem;
  flex-wrap: wrap;
  padding-bottom: 0;
}
.live-session-tabs .tab-btn { font-size: 0.82rem; padding: 0.35rem 0.75rem; }
.tab-live { color: #16a34a !important; border-bottom-color: #16a34a !important; }
.tab-not-started { color: #aaa !important; }

.live-session-meta {
  padding: 0.45rem 1.1rem;
  font-size: 0.83rem;
  color: #7a6050;
  background: #faf8f5;
  border-bottom: 1px solid #f0e8dc;
  min-height: 1.8rem;
}
.live-pulse {
  color: #16a34a;
  font-weight: 700;
  animation: live-pulse 1.2s ease-in-out infinite;
}

.live-table-wrap { overflow-x: auto; }

.live-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
  font-variant-numeric: tabular-nums;
}
.live-table th {
  padding: 0.45rem 0.65rem;
  text-align: left;
  font-weight: 600;
  color: #7a4a18;
  background: #fdf8f3;
  border-bottom: 2px solid #e8ddd0;
  white-space: nowrap;
}
.live-table td {
  padding: 0.4rem 0.65rem;
  border-bottom: 1px solid #f0e8dc;
  white-space: nowrap;
}
.live-table tbody tr:hover { background: #fef8f0; }

.live-row-ours {
  background: #fff8ee !important;
  border-left: 3px solid var(--orange);
}
.live-row-ours:hover { background: #fef3e0 !important; }

.live-best-time { color: #7c3aed; font-weight: 700; }

.col-pos  { width: 3rem; text-align: center; }
.col-no   { width: 3.5rem; }
.col-name { max-width: 220px; overflow: hidden; text-overflow: ellipsis; }
.col-class { width: 4.5rem; }
.col-laps { width: 3.5rem; text-align: center; }
.col-best, .col-last, .col-gap, .col-hist { width: 7rem; }

.badge-pit {
  background: #fef08a;
  color: #713f12;
  border: 1px solid #fde047;
  font-size: 0.72rem;
  padding: 0 0.35em;
  border-radius: 4px;
  margin-left: 0.35rem;
  font-weight: 700;
}

.col-dist, .col-spd { width: 5.5rem; }
.live-hist-lap { cursor: help; border-bottom: 1px dotted #aaa; }

.live-chart-section {
  padding: 1rem 1.1rem 1.25rem;
  border-top: 1px solid #f0e8dc;
  background: #fdfbf8;
}
.live-chart-title {
  margin: 0 0 0.75rem;
  font-size: 0.95rem;
  color: #7a4a18;
}

.live-weather-badge { display: flex; align-items: center; }
.live-weather {
  font-size: 0.82rem;
  color: #5c3010;
  background: #fef3e0;
  border: 1px solid #f0c07a;
  border-radius: 20px;
  padding: 0.2rem 0.65rem;
}
.live-countdown { color: #16a34a; font-variant-numeric: tabular-nums; }

/* ── Settings page ────────────────────────────────────────────────── */

.settings-section {
  background: #fff;
  border: 1px solid #e8ddd0;
  border-radius: 10px;
  padding: 1.25rem 1.4rem;
  margin-bottom: 2rem;
}
.settings-section h2 { margin: 0 0 0.25rem; font-size: 1.05rem; color: var(--orange); }
.settings-section h3 { margin: 1.25rem 0 0.5rem; font-size: 0.95rem; color: #7a4a18; }

.car-colour-list { display: flex; flex-direction: column; gap: 0.6rem; margin-top: 0.75rem; }
.car-colour-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  padding: 0.5rem 0.75rem;
  background: #faf8f5;
  border: 1px solid #f0e8dc;
  border-radius: 8px;
}
.car-wc-label { white-space: nowrap; }
.car-wc-input {
  font-size: 0.88rem;
  padding: 0.3rem 0.5rem;
  border: 1px solid #d4a868;
  border-radius: 6px;
  width: 80px;
}
.car-wc-status { min-width: 50px; }
.car-colour-swatch {
  width: 28px; height: 28px;
  border-radius: 6px;
  border: 1px solid rgba(0,0,0,.12);
  flex-shrink: 0;
}
.car-colour-name { flex: 1; font-weight: 500; min-width: 120px; }
.car-colour-picker {
  width: 38px; height: 34px;
  padding: 2px 3px;
  border: 1px solid #d4a868;
  border-radius: 6px;
  cursor: pointer;
  background: none;
}
.car-colour-hex {
  width: 6.5rem;
  font-family: monospace;
  font-size: 0.88rem;
  padding: 0.3rem 0.5rem;
  border: 1px solid #d4a868;
  border-radius: 6px;
  background: #fff;
}
.car-colour-status { min-width: 60px; }

.add-event-box {
  background: #faf8f5;
  border: 1px solid #f0e8dc;
  border-radius: 8px;
  padding: 1rem 1.1rem;
  margin-bottom: 1rem;
}
.add-event-row { display: flex; gap: 0.6rem; margin-top: 0.5rem; }
.add-event-input {
  flex: 1;
  padding: 0.45rem 0.7rem;
  border: 1px solid #d4a868;
  border-radius: 6px;
  font-size: 0.88rem;
}
.event-preview-card {
  margin-top: 1rem;
  padding: 0.85rem 1rem;
  background: #fff;
  border: 1px solid #d4a868;
  border-radius: 8px;
}
.event-preview-header { display: flex; align-items: baseline; gap: 0.75rem; margin-bottom: 0.35rem; }
.event-preview-meta { font-size: 0.85rem; color: #7a6050; margin-bottom: 0.65rem; display: flex; flex-direction: column; gap: 0.2rem; }

.live-event-list { display: flex; flex-direction: column; gap: 0.5rem; margin-top: 0.5rem; }
.live-event-settings-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.6rem 0.85rem;
  background: #faf8f5;
  border: 1px solid #f0e8dc;
  border-radius: 8px;
}
.live-event-settings-info { display: flex; flex-direction: column; gap: 0.15rem; }
.live-event-settings-actions { display: flex; align-items: center; gap: 0.5rem; flex-shrink: 0; }
.badge-live { background: #dcfce7; color: #166534; border: 1px solid #bbf7d0; }

/* ── Red flag banner ──────────────────────────────────────────────── */
.live-red-flag {
  background: #fef2f2;
  border-top: 2px solid #dc2626;
  border-bottom: 2px solid #dc2626;
  color: #991b1b;
  font-weight: 700;
  font-size: 1.05rem;
  text-align: center;
  padding: 0.55rem 1rem;
  letter-spacing: 0.04em;
  animation: live-pulse 1.2s ease-in-out infinite;
}

/* ── Overall estimated position column ───────────────────────────── */
.col-overall { width: 9rem; }
.live-overall-ours { background: #fff0d6 !important; font-weight: 700; }

/* ── Between-sessions banner ──────────────────────────────────────── */
.live-between-sessions {
  background: #eff6ff;
  border-top: 1px solid #bfdbfe;
  border-bottom: 1px solid #bfdbfe;
  color: #1e40af;
  font-size: 0.9rem;
  text-align: center;
  padding: 0.5rem 1rem;
}

/* ── Sortable live table headers ──────────────────────────────────── */
.live-table th { transition: background .12s; }
.live-table th:hover { background: #f5ede0; }
.sort-asc::after  { content: " ▲"; font-size: .68em; opacity: .65; }
.sort-desc::after { content: " ▼"; font-size: .68em; opacity: .65; }

/* ── Race analysis section ────────────────────────────────────────── */
.live-race-analysis {
  padding: .85rem 1.1rem 1.1rem;
  border-top: 1px solid #f0e8dc;
  display: flex;
  flex-direction: column;
  gap: .6rem;
}
.ra-heading {
  margin: 0 0 .4rem;
  font-size: .9rem;
  color: #7a4a18;
  font-weight: 600;
}
.ra-card {
  background: #faf8f5;
  border: 1px solid #e8ddd0;
  border-radius: 8px;
  padding: .6rem .9rem;
  border-left-width: 4px;
}
.ra-title {
  font-weight: 700;
  font-size: .9rem;
  color: var(--orange);
  margin-bottom: .35rem;
}
.ra-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: .35rem .6rem;
  padding: .18rem 0;
  font-size: .82rem;
}
.ra-label { font-weight: 600; color: #7a4a18; min-width: 4.5rem; }
.ra-gap   { color: #7a6050; }
.ra-gain  { color: #16a34a; font-weight: 600; }
.ra-lose  { color: #dc2626; font-weight: 600; }
.ra-neutral { color: #7a6050; }
.ra-eta   { color: #7c3aed; font-size: .78rem;
            background: #f5f3ff; border: 1px solid #e9d5ff;
            border-radius: 4px; padding: 0 .4em; }
.ra-divider { border-top: 1px solid #e8ddd0; margin: .4rem 0; }

/* ── Telemetry confidence badges (used in history + import) ─────────── */
.confidence-badge {
  display: inline-block; padding: .15rem .5rem;
  border-radius: 12px; font-size: .75rem; font-weight: 700;
}
.conf-strong   { background: #c8e6c9; color: #1b5e20; }
.conf-likely   { background: #fff9c4; color: #f57f17; }
.conf-possible { background: #ffe0b2; color: #bf360c; }
.conf-weak     { background: #ffcdd2; color: #b71c1c; }

.tab-count {
  display: inline-block; background: #c04e00; color: #fff;
  border-radius: 10px; font-size: .7rem; padding: 0 .45rem;
  vertical-align: middle; line-height: 1.6;
}

.btn-small {
  display: inline-block; padding: .3rem .8rem;
  background: #c04e00; color: #fff; border-radius: 4px;
  font-size: .85rem; text-decoration: none; font-weight: 600;
}

/* ── History: summary table row interactions ────────────────────────── */
.summary-row {
  cursor: pointer;
  transition: background .08s;
}
.summary-row:hover { background: #fdf7f2; }
.summary-row--active { background: #fff3e8 !important; outline: 2px solid #e07820; outline-offset: -2px; }
.summary-row--has-telem td { }  /* no extra style needed — dot handles it */

.col-telem { text-align: center; width: 52px; }
.telem-dot { color: #2e7d32; font-size: 1rem; cursor: default; }

/* ── Session detail panel ───────────────────────────────────────────── */
.sdp {
  background: #fff;
  border: 1px solid #e8ddd0;
  border-radius: 10px;
  box-shadow: 0 2px 8px rgba(44,26,14,.10);
  margin: .75rem 0 1.25rem;
  overflow: hidden;
}
.sdp-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: .65rem 1rem;
  background: #faf6f1;
  border-bottom: 1px solid #ede4d8;
}
.sdp-title {
  font-weight: 700;
  font-size: .95rem;
  color: var(--ink);
}
.sdp-close {
  background: none;
  border: none;
  cursor: pointer;
  font-size: .9rem;
  color: #999;
  padding: .1rem .4rem;
  border-radius: 4px;
  line-height: 1;
}
.sdp-close:hover { background: #f0e8e0; color: #444; }

.sdp-body {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0;
}
.sdp-col {
  padding: 1rem 1.1rem;
}
.sdp-col--chart { border-right: 1px solid #f0e8e0; }

.sdp-section-heading {
  margin: 0 0 .6rem;
  font-size: .72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: #a0907e;
}

.sdp-telem-table { font-size: .82rem; }
.sdp-telem-table td { padding: .35rem .6rem; }
.sdp-filename { max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.sdp-qi { font-size: .78rem; font-weight: 600; }
.sdp-qi--warn  { color: #e65100; }
.sdp-qi--info  { color: #1565c0; }
.sdp-qi--clean { color: #2e7d32; }

/* Responsive: stack sdp columns */
@media (max-width: 760px) {
  .sdp-body { grid-template-columns: 1fr; }
  .sdp-col--chart { border-right: none; border-bottom: 1px solid #f0e8e0; }
}

/* ── Data quality issue badges ──────────────────────────────────────── */
.qi-badge {
  display: inline-block; padding: .1rem .45rem;
  border-radius: 10px; font-size: .72rem; font-weight: 600;
  margin: .1rem .15rem; white-space: nowrap;
  cursor: default;
}
.qi-badge--warning { background: #fff3e0; color: #e65100; border: 1px solid #ffcc80; }
.qi-badge--info    { background: #e3f2fd; color: #0d47a1; border: 1px solid #90caf9; }
.qi-badge--ok      { background: #e8f5e9; color: #1b5e20; border: 1px solid #a5d6a7; }

/* ── Quality issues panel (telemetry detail page) ────────────────────── */
.qi-panel {
  margin: .75rem 0 1rem;
  border: 1px solid #e0e0e0; border-radius: 6px;
  background: #fafafa;
}
.qi-panel--has-warnings { border-color: #ffcc80; background: #fffde7; }
.qi-panel__summary {
  padding: .6rem 1rem; cursor: pointer;
  font-weight: 600; font-size: .9rem; list-style: none;
  display: flex; align-items: center; gap: .5rem;
}
.qi-panel__summary::-webkit-details-marker { display: none; }
.qi-panel__summary::before { content: "▶"; font-size: .7rem; transition: transform .15s; }
details[open] .qi-panel__summary::before { transform: rotate(90deg); }
.qi-panel__body { padding: 0 1rem .75rem; }

.qi-table { width: 100%; border-collapse: collapse; font-size: .85rem; }
.qi-table th { text-align: left; padding: .35rem .5rem; border-bottom: 1px solid #ddd;
               font-weight: 600; color: #555; }
.qi-table td { padding: .35rem .5rem; border-bottom: 1px solid #f0f0f0; vertical-align: top; }
.qi-row--warning td:first-child { border-left: 3px solid #ff9800; }
.qi-row--info    td:first-child { border-left: 3px solid #2196f3; }

.qi-sev--warning { color: #e65100; font-weight: 600; }
.qi-sev--info    { color: #0d47a1; }
.qi-code { font-size: .8rem; background: #f5f5f5; padding: .1rem .3rem; border-radius: 3px; }

/* ── Quality issues in import preview ───────────────────────────────── */
.qi-import-issues { margin: .5rem 0; }
.qi-import-list { margin: .4rem 0 0 1rem; padding: 0; list-style: disc; font-size: .82rem; }
.qi-import-item { margin: .2rem 0; }
.qi-import-item--warning { color: #bf360c; }
.qi-import-item--info    { color: #1565c0; }

/* ── Match confidence & manual confirmation panel ──────────────────────── */
.match-confirm-panel {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: .5rem;
  padding: .6rem 1rem;
  background: #faf8f5;
  border: 1px solid #e8e0d8;
  border-radius: 8px;
  margin-bottom: 1rem;
  font-size: .85rem;
}
.match-confirm-label {
  font-size: .72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: #a0907e;
  flex-shrink: 0;
}
.match-session-name {
  font-weight: 600;
  color: var(--ink);
}
.match-score-pill {
  display: inline-block;
  padding: .15rem .5rem;
  border-radius: 20px;
  font-size: .72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .04em;
}
.match-score-pill--strong   { background: #e8f5e9; color: #1b5e20; border: 1px solid #a5d6a7; }
.match-score-pill--likely   { background: #e3f2fd; color: #0d47a1; border: 1px solid #90caf9; }
.match-score-pill--possible { background: #fff3e0; color: #e65100; border: 1px solid #ffcc80; }
.match-score-pill--weak     { background: #fce4ec; color: #880e4f; border: 1px solid #f48fb1; }

.match-confirm-status { margin-left: auto; }
.match-badge {
  display: inline-block;
  padding: .2rem .6rem;
  border-radius: 20px;
  font-size: .75rem;
  font-weight: 700;
}
.match-badge--confirmed  { background: #e8f5e9; color: #1b5e20; border: 1px solid #a5d6a7; }
.match-badge--rejected   { background: #fce4ec; color: #880e4f; border: 1px solid #f48fb1; }
.match-badge--unreviewed { background: #f5f5f5; color: #757575; border: 1px solid #e0e0e0; }

.match-confirm-actions { display: flex; gap: .35rem; }
.match-btn {
  padding: .2rem .55rem;
  border-radius: 5px;
  font-size: .75rem;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid transparent;
  transition: opacity .12s;
}
.match-btn:hover { opacity: .8; }
.match-btn--confirm { background: #e8f5e9; color: #2e7d32; border-color: #a5d6a7; }
.match-btn--reject  { background: #fce4ec; color: #c62828; border-color: #ef9a9a; }
.match-btn--reset   { background: #f5f5f5; color: #616161; border-color: #e0e0e0; }

/* confirmed/rejected indicator in telemetry list */
.tl-match-badge {
  display: inline-block;
  font-size: .65rem;
  font-weight: 700;
  padding: .1rem .35rem;
  border-radius: 10px;
  vertical-align: middle;
  margin-left: .3rem;
}
.tl-match-badge--confirmed { background: #e8f5e9; color: #2e7d32; border: 1px solid #a5d6a7; }
.tl-match-badge--rejected  { background: #fce4ec; color: #c62828; border: 1px solid #ef9a9a; }

/* ══════════════════════════════════════════════════════════════════════
   Telemetry Library — Option C refined layout
   Scoped entirely to .tl-* — no other pages affected.
   ══════════════════════════════════════════════════════════════════════ */

/* Page wrapper: bleeds past .container to fill viewport with grey bg */
.tl-page {
  margin: -2rem -1.25rem -2rem;
  padding: 2rem 1.25rem 3rem;
  background: #ede8e1;
  min-height: calc(100vh - 60px);
}

/* Two-column grid */
.tl-layout {
  display: grid;
  grid-template-columns: 210px 1fr;
  gap: 1.5rem;
  align-items: start;
  max-width: 980px;
  margin: 0 auto;
}

/* ── Sidebar ──────────────────────────────────────────────────────────── */
.tl-sidebar {
  position: sticky;
  top: 1.25rem;
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 1px 4px rgba(44,26,14,.10), 0 0 0 1px rgba(44,26,14,.06);
  padding: 1rem;
  font-size: .84rem;
}

.tl-filter-section { margin-bottom: 1.1rem; }
.tl-filter-section--actions { margin-bottom: 0; }

.tl-filter-heading {
  font-size: .68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: #a0907e;
  margin: 0 0 .5rem;
}

.tl-filter-label {
  display: flex;
  align-items: center;
  gap: .45rem;
  padding: .22rem 0;
  cursor: pointer;
  color: #3a2a1c;
  font-size: .83rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.tl-filter-label input { cursor: pointer; flex-shrink: 0; accent-color: var(--orange); }

.tl-filter-year {
  font-size: .69rem;
  color: #b0a090;
  margin-left: auto;
  padding-left: .3rem;
}

.tl-empty-hint { color: #bbb; font-size: .78rem; margin: .25rem 0; }

.tl-reset-btn {
  width: 100%;
  padding: .38rem .6rem;
  border: 1px solid #e0d8d0;
  border-radius: 6px;
  background: #faf8f5;
  cursor: pointer;
  font-size: .78rem;
  color: #888;
  transition: background .12s, border-color .12s;
}
.tl-reset-btn:hover { background: #f0ece8; border-color: #c8bfb5; color: #555; }

/* ── Main header ─────────────────────────────────────────────────────── */
.tl-main-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 1.4rem;
}

.tl-title {
  margin: 0 0 .45rem;
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--ink);
  letter-spacing: -.02em;
}

.tl-stat-chips {
  display: flex;
  gap: .4rem;
  flex-wrap: wrap;
}
.tl-stat-chip {
  display: inline-block;
  padding: .2rem .6rem;
  background: rgba(44,26,14,.07);
  border-radius: 20px;
  font-size: .75rem;
  color: #6b5744;
  font-weight: 500;
}

.tl-empty {
  text-align: center;
  padding: 4rem 1rem;
  color: #a09080;
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 1px 4px rgba(44,26,14,.08);
}
.tl-empty p { margin-bottom: .75rem; }

/* ── Event accordion cards ───────────────────────────────────────────── */
.tl-event {
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 1px 4px rgba(44,26,14,.10), 0 0 0 1px rgba(44,26,14,.05);
  margin-bottom: 1rem;
  overflow: hidden;
}

.tl-event-summary {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: .85rem 1.1rem;
  cursor: pointer;
  background: #fff;
  border-bottom: 1px solid #f0e8e0;
  list-style: none;
  user-select: none;
  transition: background .1s;
}
.tl-event-summary:hover { background: #fdf9f6; }
.tl-event-summary::-webkit-details-marker { display: none; }

.tl-event-chevron {
  font-size: .6rem;
  color: #c0b0a0;
  transition: transform .15s;
  flex-shrink: 0;
  margin-top: 1px;
}

.tl-event-info { flex: 1; min-width: 0; }

.tl-event-circuit {
  font-size: .72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: #a0907e;
  display: block;
  margin-bottom: .12rem;
}

.tl-event-name {
  font-size: .97rem;
  font-weight: 600;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: block;
}

.tl-event-meta {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: .15rem;
  flex-shrink: 0;
  text-align: right;
}
.tl-event-date { font-size: .78rem; color: #8a7a6a; }
.tl-event-counts { font-size: .72rem; color: #b0a090; }
.tl-event-warn { font-size: .72rem; color: #d45a00; font-weight: 600; }

.tl-event-body { }

/* ── Table ───────────────────────────────────────────────────────────── */
.tl-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .85rem;
}

.tl-table thead tr {
  border-bottom: 1px solid #f0e8e0;
}
.tl-table th {
  text-align: left;
  padding: .45rem 1rem;
  font-size: .67rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: #b0a090;
}

.tl-row {
  border-bottom: 1px solid #f8f4f0;
  transition: background .08s;
}
.tl-row:last-child { border-bottom: none; }
.tl-row:hover { background: #fdf9f6; }
.tl-table td { padding: .6rem 1rem; vertical-align: middle; }

/* Session cell */
.tl-cell-session { min-width: 130px; }
.tl-session-name {
  font-weight: 600;
  font-size: .88rem;
  color: var(--ink);
}
.tl-session-type {
  display: inline-block;
  font-size: .62rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .05em;
  padding: .1rem .4rem;
  border-radius: 20px;
  margin-left: .35rem;
  vertical-align: middle;
  border: 1px solid transparent;
}
.tl-session-type--race     { background: #fde8f0; color: #9c1550; border-color: #f7c0d8; }
.tl-session-type--practice { background: #e8f0fd; color: #0d3d8c; border-color: #b8cef7; }
.tl-session-type--heat     { background: #fff0e0; color: #b84400; border-color: #ffd0a0; }
.tl-session-type--test     { background: #f0e8fd; color: #5c0a9c; border-color: #d4b8f7; }

/* Car pill */
.tl-cell-car { white-space: nowrap; }
.tl-car-pill {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  font-size: .85rem;
  color: #3a2a1c;
}
.tl-car-dot {
  display: inline-block;
  width: 11px; height: 11px;
  border-radius: 50%;
  flex-shrink: 0;
  box-shadow: 0 0 0 1.5px rgba(0,0,0,.18);
}

/* Data cells */
.tl-cell-time, .tl-cell-dur, .tl-cell-pwr {
  color: #6b5a4a;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
  font-size: .84rem;
}
.tl-cell-pwr { font-weight: 500; }

/* Quality column */
.tl-cell-qi { white-space: nowrap; min-width: 80px; }
.tl-qi-dots {
  display: inline-flex;
  gap: 3px;
  align-items: center;
  flex-wrap: wrap;
}
.tl-qi-dot {
  display: inline-block;
  width: 8px; height: 8px;
  border-radius: 50%;
  cursor: default;
  flex-shrink: 0;
}
.tl-qi-dot--warning { background: #e65100; box-shadow: 0 0 0 1px rgba(230,81,0,.2); }
.tl-qi-dot--info    { background: #1565c0; box-shadow: 0 0 0 1px rgba(21,101,192,.2); }
.tl-qi-clean {
  font-size: .75rem;
  font-weight: 700;
  color: #2e7d32;
  letter-spacing: .02em;
}

/* Link cell */
.tl-cell-link { text-align: right; padding-right: 1.1rem; }
.tl-view-link {
  font-size: .78rem;
  color: var(--orange);
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
  padding: .25rem .55rem;
  border-radius: 6px;
  border: 1px solid rgba(224,120,32,.25);
  transition: background .1s, border-color .1s;
}
.tl-view-link:hover {
  background: rgba(224,120,32,.08);
  border-color: rgba(224,120,32,.5);
  text-decoration: none;
}

/* Responsive */
@media (max-width: 900px) {
  .tl-page { margin: -1rem -1.25rem; padding: 1rem 1rem 2rem; }
  .tl-layout { grid-template-columns: 1fr; gap: 1rem; }
  .tl-sidebar {
    position: static;
    display: flex;
    flex-wrap: wrap;
    gap: .75rem 1.5rem;
    padding: .75rem 1rem;
  }
  .tl-filter-section { margin-bottom: 0; min-width: 130px; }
  .tl-filter-section--actions { width: 100%; }
  .tl-reset-btn { width: auto; }
}

/* ── Guides page ──────────────────────────────────────────────────────────── */
.guides-page {
  max-width: 900px;
  margin: 0 auto;
  padding-bottom: 3rem;
}
.guides-page h1 { margin-bottom: 0.25rem; }
.guides-intro {
  font-size: 1.05rem;
  color: #555;
  margin-bottom: 1.5rem;
}

/* ToC — vertical numbered list */
.guides-toc {
  background: #faf8f5;
  border: 1px solid #e8ddd0;
  border-radius: 8px;
  padding: 0.85rem 1.1rem 0.85rem 1.4rem;
  font-size: 0.9rem;
  margin-bottom: 1.5rem;
  display: inline-block;
  min-width: 260px;
}
.guides-toc strong {
  display: block;
  margin-bottom: 0.4rem;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: #999;
}
.guides-toc ol {
  margin: 0;
  padding-left: 1.3rem;
}
.guides-toc li { margin: 0.15rem 0; }
.guides-toc a { color: var(--orange); text-decoration: none; }
.guides-toc a:hover { text-decoration: underline; }

.guides-page section { margin-bottom: 0.5rem; }
.guides-page section h2 {
  font-size: 1.2rem;
  color: var(--orange);
  margin: 1.5rem 0 0.6rem;
}
.guides-page section h3 {
  font-size: 1rem;
  color: #7a4a18;
  margin: 1.1rem 0 0.4rem;
}

.guides-callout {
  border-radius: 8px;
  padding: 0.75rem 1rem;
  margin: 1rem 0;
  font-size: 0.9rem;
  line-height: 1.5;
}
.guides-callout--info { background: #e8f0fb; border-left: 3px solid #1565c0; }
.guides-callout--warn { background: #fff3e0; border-left: 3px solid #e65100; }

.guides-formula {
  font-family: monospace;
  background: #f5f0ea;
  border: 1px solid #e8ddd0;
  border-radius: 6px;
  padding: 0.6rem 1rem;
  margin: 0.75rem 0;
  font-size: 0.95rem;
}

/* Channel cards */
.guides-channel {
  background: #fff;
  border: 1px solid #e8ddd0;
  border-radius: 10px;
  padding: 0.9rem 1.1rem;
  margin-bottom: 0.75rem;
}
.guides-channel-header {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  flex-wrap: wrap;
  margin-bottom: 0.45rem;
}
.guides-channel-name {
  font-size: 1rem;
  font-weight: 700;
  background: #f0e8dc;
  padding: 0.1rem 0.45rem;
  border-radius: 4px;
  color: #7a4a18;
}
.guides-channel-label { font-weight: 600; flex: 1; min-width: 120px; }
.guides-channel-units {
  font-size: 0.8rem;
  color: #888;
  font-style: italic;
}
.guides-channel-cars {
  display: flex;
  gap: 0.3rem;
  flex-wrap: wrap;
  align-items: center;
}
.guides-channel-notes {
  margin: 0;
  font-size: 0.9rem;
  color: #444;
  line-height: 1.6;
}

/* Car availability pills */
.guides-pill-legend {
  font-size: 0.82rem;
  color: #888;
  display: flex;
  align-items: center;
  gap: 0.45rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}
.guides-car-pill {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 600;
  padding: 0.1rem 0.45rem;
  border-radius: 20px;
  white-space: nowrap;
  line-height: 1.6;
}
.guides-car-pill--present {
  background: var(--car-colour, #888);
  color: #fff;
  opacity: 0.9;
}
.guides-car-pill--absent {
  background: transparent;
  color: #bbb;
  border: 1px solid #ddd;
  text-decoration: line-through;
}
.guides-car-pill--unreliable {
  background: transparent;
  color: #c17a00;
  border: 1px dashed #c17a00;
}

/* Speed sensor badges */
.guides-car-name-dot {
  display: inline-block;
  width: 10px; height: 10px;
  border-radius: 50%;
  margin-right: 4px;
  vertical-align: middle;
}
.guides-sensor-badge {
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.1rem 0.45rem;
  border-radius: 4px;
}
.guides-sensor-badge--unreliable { background: #fff3e0; color: #c17a00; }
.guides-sensor-badge--absent     { background: #f3f4f6; color: #888; }

/* Severity badges in quality table */
.guides-sev {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 0.1rem 0.4rem;
  border-radius: 4px;
  white-space: nowrap;
}
.guides-sev--warning { background: #fff3e0; color: #c17a00; }
.guides-sev--info    { background: #e8f0fb; color: #1565c0; }

/* Table warn rows */
.guides-table-row--warn td { background: #fff8f0; }

.guides-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
  margin: 0.75rem 0 1rem;
}
.guides-table th {
  text-align: left;
  padding: 0.5rem 0.75rem;
  background: #f5f0ea;
  font-weight: 600;
  color: #7a4a18;
  border-bottom: 2px solid #e8ddd0;
}
.guides-table td {
  padding: 0.45rem 0.75rem;
  border-bottom: 1px solid #f0e8dc;
  vertical-align: top;
}
.guides-table tr:last-child td { border-bottom: none; }

/* Settings table (used in settings page Telemetry section) */
.settings-table {
  border-collapse: collapse;
  font-size: 0.9rem;
  margin: 0.75rem 0 0.5rem;
}
.settings-table th {
  text-align: left;
  padding: 0.4rem 0.75rem;
  background: #f5f0ea;
  font-weight: 600;
  color: #7a4a18;
  border-bottom: 2px solid #e8ddd0;
}
.settings-table td {
  padding: 0.4rem 0.75rem;
  border-bottom: 1px solid #f0e8dc;
  vertical-align: middle;
}

/* ── Nav car dot & number ─────────────────────────────────────────────────── */
.nav-car-dot {
  display: inline-block;
  width: 9px; height: 9px;
  border-radius: 50%;
  margin-right: 5px;
  vertical-align: middle;
  flex-shrink: 0;
}
.nav-car-num {
  margin-left: 4px;
  opacity: 0.65;
  font-size: 0.8em;
}

/* ── Car summary page ─────────────────────────────────────────────────────── */
.cs-page { max-width: 980px; margin: 0 auto; padding-bottom: 3rem; }

/* Header */
.cs-header {
  display: flex;
  gap: 1.5rem;
  align-items: flex-start;
  background: #fff;
  border: 1px solid #e8ddd0;
  border-radius: 14px;
  padding: 1.25rem 1.5rem;
  margin-bottom: 1.5rem;
  box-shadow: 0 2px 8px rgba(0,0,0,.04);
}
.cs-photo-wrap {
  flex-shrink: 0;
  width: 220px;
  height: 150px;
  border-radius: 10px;
  overflow: hidden;
  background: #f5f0ea;
  display: flex;
  align-items: center;
  justify-content: center;
}
.cs-photo {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.cs-header-info { flex: 1; }
.cs-header-top {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-bottom: 0.6rem;
}
.cs-race-number {
  font-size: 1.4rem;
  font-weight: 800;
  border: 2px solid;
  border-radius: 8px;
  padding: 0.1rem 0.55rem;
  line-height: 1.4;
  letter-spacing: -0.02em;
}
.cs-car-name {
  font-size: 1.6rem;
  font-weight: 700;
  margin: 0;
  line-height: 1.2;
}
.cs-class-badge { font-size: 0.85rem; }
.cs-header-meta {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
  font-size: 0.88rem;
  color: #666;
}

/* Grid layout */
.cs-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.25rem;
}
.cs-card {
  background: #fff;
  border: 1px solid #e8ddd0;
  border-radius: 12px;
  padding: 1.1rem 1.25rem;
  box-shadow: 0 1px 4px rgba(0,0,0,.04);
}
.cs-card--full { grid-column: 1 / -1; }
.cs-card-title {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #999;
  margin: 0 0 0.85rem;
}

/* Last event */
.cs-event-name { font-size: 1.1rem; font-weight: 600; margin: 0 0 0.2rem; }
.cs-event-meta { margin: 0 0 0.75rem; }
.cs-position-display {
  display: flex;
  align-items: baseline;
  gap: 0.4rem;
  margin-bottom: 0.75rem;
}
.cs-pos-number {
  font-size: 2.8rem;
  font-weight: 800;
  line-height: 1;
}
.cs-pos-of { font-size: 1rem; color: #888; }
.cs-pos-unknown { font-size: 1rem; }
.cs-event-stats {
  display: flex;
  gap: 1.25rem;
  flex-wrap: wrap;
  margin: 0;
}
.cs-event-stats > div { display: flex; flex-direction: column; }
.cs-event-stats dt { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.06em; color: #aaa; }
.cs-event-stats dd { font-size: 1rem; font-weight: 600; margin: 0; }

/* Placeholder (season standing) */
.cs-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 1.5rem 1rem;
  text-align: center;
  color: #aaa;
  min-height: 120px;
}
.cs-placeholder-icon { font-size: 2rem; margin-bottom: 0.5rem; }
.cs-placeholder p { margin: 0; font-size: 0.9rem; }

/* Hardware issues */
.cs-issue-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}
.cs-issue-table th {
  text-align: left;
  padding: 0.4rem 0.75rem;
  background: #f5f0ea;
  font-weight: 600;
  color: #7a4a18;
  border-bottom: 2px solid #e8ddd0;
  font-size: 0.82rem;
}
.cs-issue-table td {
  padding: 0.5rem 0.75rem;
  border-bottom: 1px solid #f0e8dc;
  vertical-align: top;
}
.cs-issue-table tr:last-child td { border-bottom: none; }
.cs-no-issues {
  padding: 1rem 0;
  font-size: 0.95rem;
  color: #555;
}
.cs-check { color: #2e7d32; font-weight: 700; margin-right: 0.35rem; }

/* Events table */
.cs-events-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.75rem;
}
.cs-events-header .cs-card-title { margin: 0; }
.cs-year-filter { display: flex; align-items: center; gap: 0.5rem; }
.cs-year-select {
  font-size: 0.88rem;
  padding: 0.25rem 0.5rem;
  border: 1px solid #d4a868;
  border-radius: 6px;
  background: #faf8f5;
}
.cs-events-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}
.cs-events-table th {
  text-align: left;
  padding: 0.4rem 0.7rem;
  background: #f5f0ea;
  font-weight: 600;
  color: #7a4a18;
  border-bottom: 2px solid #e8ddd0;
  white-space: nowrap;
}
.cs-events-table td {
  padding: 0.4rem 0.7rem;
  border-bottom: 1px solid #f0e8dc;
  vertical-align: top;
}
.cs-events-table tr:last-child td { border-bottom: none; }
.cs-events-table .nowrap { white-space: nowrap; }

@media (max-width: 700px) {
  .cs-header { flex-direction: column; }
  .cs-photo-wrap { width: 100%; height: 180px; }
  .cs-grid { grid-template-columns: 1fr; }
}

/* ── Car summary tweaks ─────────────────────────────────────────────────── */
.cs-issue-link { color: inherit; text-decoration: none; }
.cs-issue-link:hover strong { text-decoration: underline; color: #7a4a18; }
.cs-telem-link { font-size: .85rem; white-space: nowrap; }

/* ── Car Issue Detail ────────────────────────────────────────────────────── */
.cid-page { max-width: 1000px; margin: 0 auto; }
.cid-breadcrumb { font-size: .85rem; color: #888; margin-bottom: 1.25rem; }
.cid-breadcrumb a { color: #7a4a18; }

.cid-header {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 1rem; margin-bottom: 1.5rem; flex-wrap: wrap;
}
.cid-header-left { display: flex; flex-direction: column; gap: .3rem; }
.cid-title { font-size: 1.5rem; font-weight: 700; color: #3a2000; margin: 0; }
.cid-code { font-size: .8rem; color: #888; }
.cid-severity-badge {
  display: inline-block; padding: .2rem .6rem; border-radius: 10px;
  font-size: .78rem; font-weight: 700; width: fit-content;
}
.cid-severity-badge--warning { background: #fff3cd; color: #856404; border: 1px solid #ffc107; }
.cid-severity-badge--info    { background: #e8f4fd; color: #0c5460; border: 1px solid #bee5eb; }
.cid-header-right { display: flex; align-items: center; gap: .5rem; font-size: .9rem; color: #555; }
.cid-car-dot { width: 12px; height: 12px; border-radius: 50%; flex-shrink: 0; }
.cid-car-name { font-weight: 600; }

.cid-card {
  background: #fff; border: 1px solid #e0d6c8; border-radius: 8px;
  padding: 1.25rem 1.5rem; margin-bottom: 1.5rem;
}
.cid-section-title {
  font-size: 1rem; font-weight: 700; color: #5a3500; margin: 0 0 .75rem;
  display: flex; align-items: center; gap: .75rem;
}
.cid-count {
  font-size: .78rem; font-weight: 400; color: #888; background: #f5f0ea;
  padding: .15rem .5rem; border-radius: 10px;
}
.cid-description { font-size: .95rem; line-height: 1.6; color: #444; margin: 0; }

.cid-files-table { width: 100%; border-collapse: collapse; font-size: .88rem; }
.cid-files-table th {
  text-align: left; padding: .4rem .75rem; background: #f5f0ea;
  font-weight: 600; color: #7a4a18; border-bottom: 2px solid #e8ddd0; white-space: nowrap;
}
.cid-files-table td {
  padding: .45rem .75rem; border-bottom: 1px solid #f0e8dc; vertical-align: top;
}
.cid-files-table tr:last-child td { border-bottom: none; }
.cid-files-table .nowrap { white-space: nowrap; }
.cid-issue-msg { font-size: .82rem; color: #555; max-width: 300px; }

/* ── Event Overview ──────────────────────────────────────────────────────── */
.eo-page { max-width: 1100px; margin: 0 auto; }

.eo-header {
  margin-bottom: 1.5rem;
}
.eo-title {
  font-size: 1.6rem;
  font-weight: 700;
  color: #3a2000;
  margin: 0 0 0.35rem;
}
.eo-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1.5rem;
  font-size: 0.92rem;
  color: #666;
}
.eo-meta span::before { content: "· "; }
.eo-meta span:first-child::before { content: ""; }

.eo-card {
  background: #fff;
  border: 1px solid #e0d6c8;
  border-radius: 8px;
  padding: 1.25rem 1.5rem;
  margin-bottom: 1.5rem;
}
.eo-section-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: #5a3500;
  margin: 0 0 1rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid #e8ddd0;
}
.eo-no-data {
  padding: 1rem 0;
  color: #999;
  font-size: 0.9rem;
}
.eo-telem-form {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-bottom: 1.25rem;
}
.eo-telem-label {
  font-size: 0.88rem;
  color: #555;
  font-weight: 600;
  white-space: nowrap;
}
.eo-telem-select {
  font-size: 0.88rem;
  padding: 0.3rem 0.6rem;
  border: 1px solid #c8a060;
  border-radius: 6px;
  background: #faf8f5;
  min-width: 280px;
  max-width: 600px;
  flex: 1;
}

/* Lap controls (reuse from history) */
.lap-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}
.lap-controls.hidden { display: none; }
.eo-no-data.hidden   { display: none; }

/* Clip bar */
.eo-clip-bar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.4rem;
  min-height: 1.5rem;
}

/* Filter bar */
.eo-filter-bar {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex-wrap: wrap;
  margin-bottom: 0.75rem;
  font-size: 0.85rem;
}
.eo-filter-label { color: #888; margin-right: 0.2rem; }
.eo-filter-pill {
  padding: 0.2rem 0.65rem;
  border-radius: 12px;
  border: 1px solid #c8a060;
  background: #faf8f5;
  color: #5a3500;
  text-decoration: none;
  transition: background 0.15s;
}
.eo-filter-pill:hover { background: #f0e8dc; }
.eo-filter-pill--active {
  background: var(--pill-col, #5a3500);
  border-color: var(--pill-col, #5a3500);
  color: #fff;
  font-weight: 600;
  cursor: default;
}
.eo-filter-pill--active:hover { background: var(--pill-col, #5a3500); }
/* Car-coloured inactive pills get a tinted border */
a.eo-filter-pill[style*="--pill-col"] {
  border-color: var(--pill-col);
  color: var(--pill-col);
}

/* Sortable table headers (static/js/sortable.js) */
th.sortable { cursor: pointer; user-select: none; white-space: nowrap; }
th.sortable:hover { text-decoration: underline; }
th.sortable::after { content: "\2195"; opacity: 0.35; font-size: 0.8em; margin-left: 0.3em; }
th.sortable[data-dir="asc"]::after { content: "\2191"; opacity: 1; }
th.sortable[data-dir="desc"]::after { content: "\2193"; opacity: 1; }

/* == Mobile UI (Phase 20) ============================================== */
.live-next-event .live-next-title { font-size: 1.15rem; margin: 0.25rem 0; }
.live-next-countdown {
  font-size: 2.1rem; font-weight: 700; font-variant-numeric: tabular-nums;
  color: var(--orange, #c96a1f); margin: 0.5rem 0 0.75rem; letter-spacing: 0.01em;
}

.m-nav { display: none; }
.m-sheet { display: none; }

@media (max-width: 768px) {
  /* top nav collapses to brand only; bottom bar takes over */
  .site-header nav { display: none; }
  .site-header .brand { font-size: 1rem; }
  body { padding-bottom: calc(60px + env(safe-area-inset-bottom)); }
  .container { padding-left: 0.75rem; padding-right: 0.75rem; }

  .m-nav {
    display: flex; position: fixed; bottom: 0; left: 0; right: 0; z-index: 60;
    background: var(--orange, #c96a1f); color: #fff;
    padding-bottom: env(safe-area-inset-bottom);
    box-shadow: 0 -2px 8px rgba(0,0,0,0.18);
  }
  .m-nav a, .m-nav .m-nav-more {
    flex: 1; display: flex; flex-direction: column; align-items: center;
    gap: 2px; padding: 8px 0 6px; color: #fff; text-decoration: none;
    font-size: 0.68rem; background: none; border: none; font-family: inherit;
    cursor: pointer;
  }
  .m-nav-ico { font-size: 1.15rem; line-height: 1; }

  .m-sheet { display: block; position: fixed; inset: 0; z-index: 70; }
  .m-sheet[hidden] { display: none; }
  .m-sheet-backdrop { position: absolute; inset: 0; background: rgba(0,0,0,0.4); }
  .m-sheet-panel {
    position: absolute; bottom: 0; left: 0; right: 0;
    background: #fff; border-radius: 14px 14px 0 0;
    padding: 0.75rem 1rem calc(1rem + env(safe-area-inset-bottom));
    max-height: 70vh; overflow-y: auto;
  }
  .m-sheet-panel a {
    display: block; padding: 0.7rem 0.25rem; color: #333;
    text-decoration: none; font-size: 1rem;
    border-bottom: 1px solid #f2ece4;
  }
  .m-sheet-panel hr { border: none; border-top: 2px solid #e8ddd0; margin: 0.4rem 0; }

  /* wide tables scroll inside their card instead of breaking the page */
  .cs-card, .card { overflow-x: auto; }
  .cs-events-table, .cs-issue-table { min-width: 560px; }

  .cs-page h1, .home-hero h1 { font-size: 1.4rem; }
  .car-photo-grid { grid-template-columns: 1fr 1fr; gap: 0.6rem; }
  .cs-events-header { flex-direction: column; align-items: flex-start; gap: 0.5rem; }

  /* live dashboard: hide secondary columns, keep race-critical ones */
  .live-table .m-hide { display: none; }
  .live-table { font-size: 0.82rem; }
  .live-table td, .live-table th { padding: 0.35rem 0.4rem; }
}
