/* =====================================================
   RX Stats — Design System
   ===================================================== */

/* --- Design tokens ---------------------------------- */
:root {
  --navy:        #001427;
  --brand:       #002652;
  --blue:        #0047ab;
  --red:         #dc3545;
  --green:       #28a745;
  --purple:      #800080;
  --yellow:      #ffc107;

  --bg:          #eaeaea;
  --surface:     #ffffff;
  --surface-2:   #f5f5f5;

  --text:        #333;
  --text-muted:  #666;
  --text-light:  #999;

  --border:      #ccc;
  --border-light:#e0e0e0;

  --shadow-sm:   0 1px 3px rgba(0,0,0,.1);
  --shadow:      0 2px 6px rgba(0,0,0,.12);
  --shadow-lg:   0 8px 24px rgba(0,0,0,.18);

  --radius-sm:   4px;
  --radius:      5px;
  --radius-lg:   8px;

  --font:        -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;

  --pos-1:       #f59e0b;
  --pos-2:       #94a3b8;
  --pos-3:       #cd7f32;

  --header-top-h: 80px;
  --header-nav-h: 40px;
  --header-h:    120px;
}

/* --- Reset ------------------------------------------ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
  min-height: 100vh;
}
a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; display: block; }
button { font-family: var(--font); cursor: pointer; }

/* --- Layout ----------------------------------------- */
.container {
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 20px;
}

/* --- Header ----------------------------------------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 200;
  background: var(--brand);
}

/* Top row: logo */
.header-top {
  display: flex;
  align-items: center;
  justify-content: center;
  height: var(--header-top-h);
  padding: 0 20px;
}

.brand-logo {
  display: flex;
  align-items: center;
  gap: 16px;
  text-decoration: none;
  color: #fff;
}
.brand-logo img { height: 70px; width: auto; }
.brand-text { display: flex; flex-direction: column; line-height: 1.3; }
.brand-title { font-size: 22px; font-weight: 700; color: #eaeaea; }
.brand-sub   { font-size: 12px; color: rgba(234,234,234,.6); font-style: italic; }

/* Nav row */
.header-nav-row {
  height: var(--header-nav-h);
  border-top: 1px dotted rgba(234,234,234,.3);
}

.site-nav {
  display: flex;
  align-items: stretch;
  height: 100%;
}
.nav-link {
  display: flex;
  align-items: center;
  color: #eaeaea;
  font-size: 14px;
  font-weight: 500;
  padding: 0 20px;
  border-right: 1px dotted rgba(234,234,234,.3);
  text-decoration: none;
  white-space: nowrap;
  transition: background .15s, color .15s;
}
.nav-link:first-child { border-left: 1px dotted rgba(234,234,234,.3); }
.nav-link:hover  { background: var(--blue); color: #fff; text-decoration: none; }
.nav-link.active { background: var(--blue); color: #fff; font-weight: 600; }
.nav-search { padding: 0 16px; }

.nav-spacer { flex: 1; }

.mobile-toggle {
  display: none;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  background: none;
  border: none;
  padding: 8px 15px;
  cursor: pointer;
  color: #eaeaea;
  font-size: 14px;
  font-weight: 500;
}
.mobile-toggle span {
  display: block;
  width: 22px;
  height: 2px;
  background: rgba(255,255,255,.85);
  border-radius: 2px;
}

.mobile-nav {
  display: none;
  position: fixed;
  inset: var(--header-h) 0 0 0;
  background: rgba(0,20,39,.97);
  z-index: 190;
  transform: translateX(100%);
  transition: transform .25s;
}
.mobile-nav.open { transform: translateX(0); }
.mobile-nav-inner {
  display: flex;
  flex-direction: column;
  padding: 16px;
  gap: 2px;
}
.mobile-nav-inner a {
  color: #eaeaea;
  font-size: 16px;
  font-weight: 500;
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  text-decoration: none;
  border-bottom: 1px solid rgba(234,234,234,.1);
}
.mobile-nav-inner a.active,
.mobile-nav-inner a:hover { background: var(--blue); color: #fff; }

/* --- Main / Footer ---------------------------------- */
.site-main {
  padding: 20px 0 50px;
  min-height: calc(100vh - var(--header-h) - 50px);
}
.site-footer {
  background: var(--navy);
  color: rgba(255,255,255,.5);
  font-size: 12px;
  padding: 14px 0;
}
.footer-inner {
  display: flex;
  align-items: center;
  gap: 8px;
}
.footer-inner a { color: rgba(255,255,255,.6); }
.footer-sep { opacity: .4; }

/* --- Card ------------------------------------------- */
.card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
  overflow: hidden;
  margin-bottom: 16px;
}
.card-header {
  padding: 8px 15px;
  font-weight: 600;
  font-size: 11px;
  border-bottom: 1px solid rgba(0,0,0,.15);
  color: #eaeaea;
  letter-spacing: .5px;
  text-transform: uppercase;
  background: var(--brand);
  border-radius: var(--radius-sm) var(--radius-sm) 1px 1px;
}

/* --- Badges & pills --------------------------------- */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 99px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .4px;
}
.badge-season { background: var(--blue); color: #fff; }

.class-tag {
  display: inline-block;
  background: var(--brand);
  color: #eaeaea;
  font-size: 11px;
  font-weight: 700;
  padding: 1px 7px;
  border-radius: 99px;
  width: 17px;
  height: 17px;
  line-height: 15px;
  text-align: center;
}
.class-pills { display: inline-flex; flex-wrap: wrap; gap: 4px; margin-left: 6px; }
.class-pill  { font-size: 11px; color: var(--text-muted); }

/* Status badges — old-school colors */
.status-badge {
  display: inline-block;
  padding: 2px 6px;
  border-radius: 3px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .5px;
  margin-left: 4px;
}
.status-dnf { background: var(--yellow); color: #333; }
.status-dns { background: #999; color: #fff; }
.status-dsq { background: #000; color: #fff; }
.status-exc { background: var(--red); color: #fff; }
.status-ok  { background: var(--green); color: #fff; }

/* Start number badge */
.start-num {
  display: inline-block;
  background: var(--brand);
  color: #eaeaea;
  font-size: 11px;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: 3px;
  min-width: 28px;
  text-align: center;
}

.pos-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 700;
}
.pos-1 { background: var(--pos-1); color: #fff; }
.pos-2 { background: var(--pos-2); color: #fff; }
.pos-3 { background: var(--pos-3); color: #fff; }
.pos-plain { font-size: 13px; font-weight: 600; color: var(--text-muted); }
.rank-num  { font-size: 13px; color: var(--text-muted); }

.penalty-badge  { font-size: 11px; color: var(--red); margin-left: 4px; font-weight: 600; }
.sanction-dot   { font-size: 10px; font-weight: 700; background: #fff3cd; color: #856404; padding: 1px 5px; border-radius: 3px; margin-left: 2px; }
.sanction-tag   { display: inline-block; font-size: 10px; font-weight: 700; background: var(--surface-2); border: 1px solid var(--border); padding: 0 5px; border-radius: 3px; }

/* --- Page header ------------------------------------ */
.page-header {
  display: flex;
  align-items: baseline;
  gap: 16px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.page-title  { font-size: 22px; font-weight: 700; }
.page-sub    { color: var(--text-muted); font-size: 13px; margin-top: -12px; margin-bottom: 14px; }
.page-count  { font-size: 13px; color: var(--text-muted); }
.back-link   { font-size: 13px; color: var(--text-muted); margin-right: auto; }
.back-link:hover { color: var(--blue); }

/* --- Section ---------------------------------------- */
.section { margin-bottom: 24px; }
.section-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.section-title  { font-size: 16px; font-weight: 700; }
.link-more { font-size: 13px; color: var(--blue); }

/* --- Filter bar ------------------------------------- */
.filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 14px;
}
.filter-btn {
  padding: 5px 10px;
  border-radius: 3px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  cursor: pointer;
  text-decoration: none;
  transition: .15s;
}
.filter-btn:hover  { border-color: var(--blue); color: var(--blue); background: #fff; text-decoration: none; }
.filter-btn.active { background: var(--brand); border-color: var(--brand); color: #fff; font-weight: 600; }

.filter-pills { display: flex; flex-wrap: wrap; gap: 6px; }
.filter-pill  { padding: 4px 10px; border-radius: 3px; border: 1px solid var(--border); background: var(--surface-2); font-size: 12px; color: var(--text); text-decoration: none; transition: .15s; }
.filter-pill:hover  { color: var(--blue); border-color: var(--blue); }
.filter-pill.active { background: var(--brand); border-color: var(--brand); color: #fff; }

/* --- Filter form ------------------------------------ */
.filter-form { padding: 15px 20px; background: #f8f8f8; border-bottom: 1px solid var(--border); }
.filter-row  { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; }
.filter-group { display: flex; flex-direction: column; gap: 4px; min-width: 140px; }
.filter-group label { font-size: 11px; font-weight: 600; color: var(--text-muted); letter-spacing: .4px; text-transform: uppercase; }
.filter-actions { flex-direction: row; gap: 8px; align-items: center; }

.form-input, .form-select {
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: var(--font);
  font-size: 13px;
  color: var(--text);
  background: var(--surface);
  outline: none;
  transition: border-color .15s;
}
.form-input:focus, .form-select:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(0,38,82,.1);
}

/* --- Buttons ---------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 15px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  border: none;
  cursor: pointer;
  text-decoration: none;
  transition: background .15s;
  white-space: nowrap;
}
.btn-primary { background: var(--brand); color: #eaeaea; }
.btn-primary:hover { background: var(--blue); text-decoration: none; color: #fff; }
.btn-ghost { background: var(--surface-2); color: var(--text); border: 1px solid var(--border); }
.btn-ghost:hover { background: #ddd; text-decoration: none; }

/* --- Data tables ------------------------------------ */
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.data-table th {
  padding: 8px 15px;
  text-align: left;
  font-size: 13px;
  font-weight: 600;
  color: #eaeaea;
  border-bottom: 1px solid rgba(0,0,0,.2);
  background: var(--brand);
  white-space: nowrap;
}
.data-table td {
  padding: 5px 15px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.data-table tbody tr:nth-child(even) td { background: rgba(0,0,0,.02); }
.data-table tbody tr:last-child td { border-bottom: none; }
.data-table tbody tr:hover td { background: rgba(0,0,0,.05) !important; }

.data-table.compact th,
.data-table.compact td { padding: 3px 5px; }

.clickable-row { cursor: pointer; }
.row-link { color: var(--text-muted); font-size: 16px; }

/* Column types */
.pos-col  { width: 30px; text-align: center; }
.num-col  { width: 40px; text-align: center; font-weight: 700; }
.time-col { text-align: right; font-variant-numeric: tabular-nums; font-family: 'Courier New', monospace; font-size: 12px; color: var(--blue); font-weight: 600; }
.lap-col  { font-size: 11px; }
.nowrap   { white-space: nowrap; }
.font-medium { font-weight: 500; }
.font-bold { font-weight: 700; }
.text-right  { text-align: right; }
.text-center { text-align: center; }
.text-muted  { color: var(--text-muted); }
.p-md   { padding: 15px; }
.p-lg   { padding: 20px; }
.mb-md  { margin-bottom: 16px; }
.mt-lg  { margin-top: 24px; }
.stat-count { font-size: 16px; color: var(--red); }

/* Row status highlights */
.best-session td { background: rgba(40, 167, 69, .08) !important; }
.best-session .time-col { color: var(--green) !important; font-weight: 700; }
.best-overall td { background: rgba(128, 0, 128, .08) !important; }
.best-overall .time-col { color: var(--purple) !important; font-weight: 700; }
.status-row td   { color: var(--text-muted); }
.podium-1 td:first-child { border-left: 3px solid var(--pos-1); }
.podium-2 td:first-child { border-left: 3px solid var(--pos-2); }
.podium-3 td:first-child { border-left: 3px solid var(--pos-3); }

/* --- Tabs ------------------------------------------- */
.tabs-wrapper  { margin-top: 6px; }
.tabs-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-bottom: 8px;
}
.tab-btn {
  padding: 5px 12px;
  font-size: 13px;
  font-weight: 500;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  cursor: pointer;
  border-radius: 3px;
  transition: .15s;
}
.tab-btn:hover  { background: #ddd; }
.tab-btn.active { background: var(--brand); border-color: var(--brand); color: #fff; font-weight: 600; }

.tab-content {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  min-height: 100px;
}

/* --- Result sections -------------------------------- */
.result-section { margin-bottom: 20px; }
.result-section-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--brand);
  margin-bottom: 10px;
  padding-bottom: 4px;
  border-bottom: 1px solid var(--border);
}
.result-class-block { margin-bottom: 16px; }
.result-class-label {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-muted);
  letter-spacing: .4px;
  text-transform: uppercase;
  margin-bottom: 6px;
}
.heat-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  margin: 8px 0 4px;
}
.final-block  { margin-bottom: 20px; }
.final-type-label {
  display: inline-block;
  background: var(--brand);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 3px;
  margin-bottom: 6px;
}

/* --- Hero (index) ----------------------------------- */
.hero-event {
  background: linear-gradient(135deg, var(--brand) 0%, #003a7a 100%);
  color: #fff;
  padding: 28px 24px;
  border-radius: var(--radius);
  margin-bottom: 20px;
  box-shadow: var(--shadow);
}
.hero-meta  { display: flex; align-items: center; gap: 10px; margin-bottom: 6px; }
.hero-label { font-size: 11px; color: rgba(255,255,255,.6); text-transform: uppercase; letter-spacing: .5px; }
.hero-title { font-size: 28px; font-weight: 700; margin-bottom: 4px; }
.hero-date  { font-size: 14px; color: rgba(255,255,255,.7); margin-bottom: 16px; }

.winners-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 10px;
}
.winner-card {
  background: rgba(255,255,255,.1);
  border-radius: var(--radius-sm);
  padding: 12px;
  border: 1px solid rgba(255,255,255,.15);
}
.winner-class {
  display: inline-block;
  background: rgba(255,255,255,.2);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  padding: 1px 7px;
  border-radius: 3px;
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: .4px;
}
.winner-name  { font-weight: 600; font-size: 14px; margin-bottom: 2px; color: #fff; }
.winner-name a { color: #fff; }
.winner-number { font-size: 11px; color: rgba(255,255,255,.6); }
.winner-time   { font-size: 11px; color: rgba(255,255,255,.6); font-variant-numeric: tabular-nums; }

/* --- Stats bar (home + club) ----------------------- */
.stats-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 20px;
}
.stat-pill {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 90px;
  flex: 1;
  box-shadow: var(--shadow-sm);
}
.stat-num { font-size: 26px; font-weight: 700; color: var(--brand); line-height: 1; }
.stat-lbl { font-size: 11px; color: var(--text-muted); margin-top: 3px; text-align: center; text-transform: uppercase; letter-spacing: .4px; }

/* --- Event list (home) ------------------------------ */
.event-list .event-row {
  display: grid;
  grid-template-columns: 150px 1fr 80px 20px;
  align-items: center;
  gap: 12px;
  padding: 10px 15px;
  border-bottom: 1px solid var(--border);
  text-decoration: none;
  color: var(--text);
  transition: background .1s;
}
.event-list .event-row:last-child { border-bottom: none; }
.event-list .event-row:hover { background: var(--surface-2); }
.event-name   { font-weight: 500; }
.event-date   { font-size: 12px; color: var(--text-muted); }
.event-season { font-size: 12px; color: var(--text-muted); text-align: right; }
.event-arrow  { color: var(--text-light); }

/* --- Event detail hero ------------------------------ */
.event-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
  font-size: 13px;
}
.event-nav-btn   { color: var(--blue); }
.event-nav-season { color: var(--text-muted); }

.event-hero {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 16px;
  background: linear-gradient(135deg, var(--brand) 0%, #003a7a 100%);
  color: #fff;
  padding: 22px 24px;
  border-radius: var(--radius);
  margin-bottom: 16px;
  box-shadow: var(--shadow);
}
.event-hero-title { font-size: 22px; font-weight: 700; margin: 4px 0; }
.event-hero-date  { color: rgba(255,255,255,.7); font-size: 13px; }
.event-hero-meta  { color: rgba(255,255,255,.55); font-size: 12px; margin-top: 3px; }

.event-classes {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: flex-start;
}
.event-class-card {
  background: rgba(255,255,255,.12);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  text-align: center;
  min-width: 64px;
  border: 1px solid rgba(255,255,255,.15);
}
.event-class-card.total { background: rgba(255,255,255,.2); }
.event-class-abb   { font-size: 16px; font-weight: 700; }
.event-class-name  { font-size: 10px; opacity: .7; margin: 1px 0; }
.event-class-count { font-size: 11px; font-weight: 600; }

.track-map-wrap iframe { width: 100%; max-height: 300px; border-radius: var(--radius); }

/* --- Seasons ---------------------------------------- */
.season-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 10px;
}
.season-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 14px;
  text-align: center;
  text-decoration: none;
  color: var(--text);
  transition: .15s;
  box-shadow: var(--shadow-sm);
}
.season-card:hover { border-color: var(--blue); box-shadow: var(--shadow); text-decoration: none; }
.season-year { font-size: 28px; font-weight: 700; color: var(--brand); }
.season-meta { font-size: 12px; color: var(--text-muted); margin-top: 3px; }

/* Event list detail (seasons page) */
.event-row-detail {
  display: grid;
  grid-template-columns: 150px 1fr auto 24px;
  gap: 12px;
  padding: 10px 15px;
  align-items: center;
  border-bottom: 1px solid var(--border);
  text-decoration: none;
  color: var(--text);
  transition: background .1s;
}
.event-row-detail:hover { background: var(--surface-2); text-decoration: none; }
.event-row-detail:last-child { border-bottom: none; }
.event-participants { font-size: 12px; color: var(--text-muted); }
.table-header {
  display: grid;
  grid-template-columns: 150px 1fr auto 24px;
  gap: 12px;
  padding: 6px 15px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .4px;
  color: #eaeaea;
  background: var(--brand);
  border-bottom: 1px solid rgba(0,0,0,.15);
}

/* --- Driver profile --------------------------------- */
.driver-hero {
  padding: 20px;
  margin-bottom: 16px;
}
.driver-hero-main {
  display: flex;
  align-items: flex-start;
  gap: 16px;
}
.driver-thumb {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--border);
}
.driver-thumb-placeholder {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: var(--brand);
  color: #fff;
  font-size: 24px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.driver-name  { font-size: 22px; font-weight: 700; margin-bottom: 6px; }
.driver-numbers { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 6px; }
.driver-number-badge {
  background: var(--brand);
  color: #eaeaea;
  border-radius: var(--radius-sm);
  padding: 3px 10px;
  display: flex;
  align-items: center;
  gap: 5px;
}
.number-num  { font-weight: 700; font-size: 14px; color: #fff; }
.number-meta { font-size: 11px; color: rgba(234,234,234,.7); }
.driver-clubs { font-size: 13px; color: var(--text-muted); }

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
  gap: 10px;
  margin-bottom: 16px;
}
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 12px;
  text-align: center;
  box-shadow: var(--shadow-sm);
}
.stat-card.accent { border-top: 3px solid var(--red); }
.stat-card-num { font-size: 28px; font-weight: 700; color: var(--brand); line-height: 1; }
.stat-card.accent .stat-card-num { color: var(--red); }
.stat-card-lbl { font-size: 11px; color: var(--text-muted); margin-top: 4px; text-transform: uppercase; letter-spacing: .4px; }

.sanctions-row {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  padding: 12px 15px;
  align-items: center;
}
.sanction-item { display: flex; align-items: center; gap: 5px; font-size: 13px; }

/* --- Results matrix --------------------------------- */
.matrix-table .matrix-event-col { min-width: 150px; }
.matrix-cell { padding: 0 !important; }
.matrix-btn {
  width: 100%;
  height: 32px;
  background: #e8f0fe;
  border: none;
  font-size: 12px;
  font-weight: 600;
  color: var(--blue);
  cursor: pointer;
  transition: background .1s;
}
.matrix-btn:hover { background: #c5d8fd; }
.matrix-empty { color: var(--text-light); font-size: 12px; }
.overflow-x-auto { overflow-x: auto; }

/* --- Statistics ------------------------------------- */
.stats-layout {
  display: grid;
  grid-template-columns: 190px 1fr;
  gap: 16px;
  align-items: start;
}
.stats-sidebar {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}
.sidebar-title {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: #eaeaea;
  padding: 7px 14px;
  background: var(--brand);
}
.sidebar-link {
  display: block;
  padding: 7px 14px;
  font-size: 13px;
  color: var(--text);
  text-decoration: none;
  transition: .1s;
  border-bottom: 1px solid var(--border-light);
}
.sidebar-link:last-child { border-bottom: none; }
.sidebar-link:hover { background: var(--surface-2); text-decoration: none; }
.sidebar-link.active { color: var(--brand); font-weight: 600; background: #e8f0fe; }
.stats-main { min-width: 0; }

.chart-card .chart-wrap { padding: 14px 16px 16px; height: 260px; }

/* --- Search ----------------------------------------- */
.search-form { margin-bottom: 20px; }
.search-input-wrap {
  display: flex;
  gap: 10px;
}
.search-input {
  flex: 1;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-family: var(--font);
  font-size: 14px;
  outline: none;
  transition: border-color .15s;
}
.search-input:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(0,38,82,.1);
}
.search-section { margin-bottom: 20px; }
.search-section-title { font-size: 15px; font-weight: 700; margin-bottom: 8px; }

/* --- Modals ----------------------------------------- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.28);
  z-index: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.modal {
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 600px;
  max-height: 80vh;
  overflow-y: auto;
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--brand);
  color: #eaeaea;
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}
.modal-title { font-size: 15px; font-weight: 600; color: #fff; }
.modal-close {
  background: none;
  border: none;
  font-size: 18px;
  color: rgba(255,255,255,.7);
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 3px;
}
.modal-close:hover { background: rgba(255,255,255,.15); color: #fff; }
.modal-body { padding: 16px; }

/* Sticky table header in modal */
.modal .data-table th {
  position: sticky;
  top: 0;
  z-index: 10;
}

/* --- Loading & empty states ------------------------ */
.loading-state {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 20px;
  color: var(--text-muted);
  font-size: 13px;
}
.spinner {
  width: 20px;
  height: 20px;
  border: 3px solid var(--border);
  border-top-color: var(--blue);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.empty-state { padding: 28px; text-align: center; color: var(--text-muted); }

/* Alpine.js cloak */
[x-cloak] { display: none !important; }

/* Fade transitions for Alpine */
.fade-in  { animation: fadeIn .2s ease; }
.fade-out { animation: fadeOut .15s ease; }
@keyframes fadeIn  { from { opacity: 0; } to { opacity: 1; } }
@keyframes fadeOut { from { opacity: 1; } to { opacity: 0; } }

/* --- Responsive ------------------------------------- */
@media (max-width: 900px) {
  :root { --header-top-h: 60px; }
  .stats-layout { grid-template-columns: 1fr; }
  .stats-sidebar { order: 2; }
  .stats-main    { order: 1; }
  .sidebar-link.active { background: #e8f0fe; }
}

@media (max-width: 768px) {
  :root { --header-top-h: 56px; --header-nav-h: 0px; --header-h: 56px; }
  .header-top { justify-content: flex-start; }
  .header-nav-row { display: none; }
  .brand-logo img { height: 40px; }
  .brand-title { font-size: 18px; }
  .brand-sub { display: none; }
  .mobile-toggle { display: flex; margin-left: auto; }
  .mobile-nav { display: block; }

  .hero-event { padding: 20px 16px; }
  .hero-title { font-size: 22px; }
  .event-hero { flex-direction: column; }
  .event-classes { justify-content: flex-start; }
  .winners-grid { grid-template-columns: repeat(2, 1fr); }
  .page-title { font-size: 18px; }
  .lap-col { display: none; }
  .filter-row { flex-direction: column; }
  .filter-group { min-width: 0; width: 100%; }
  .event-list .event-row { grid-template-columns: 120px 1fr 20px; }
  .event-season { display: none; }
  .event-row-detail { grid-template-columns: 110px 1fr 24px; }
  .stats-grid { grid-template-columns: repeat(3, 1fr); }
  .driver-hero-main { flex-direction: column; }
  .data-table th, .data-table td { padding: 4px 8px; font-size: 12px; }
}

@media (max-width: 480px) {
  .container { padding: 0 10px; }
  .winners-grid { grid-template-columns: 1fr 1fr; }
  .stats-bar { flex-direction: row; flex-wrap: wrap; }
  .stat-pill { min-width: 70px; padding: 10px 12px; }
  .stat-num  { font-size: 20px; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .search-input-wrap { flex-direction: column; }
}
