/* ---------------------------------------------------------------------------
   F1 PIT STRATEGY — linguaggio "pit wall": carbon panels, near-zero chrome,
   Titillium Web + IBM Plex Mono. Il rosso (#e10600) è riservato al solo
   live badge; gli accenti funzionali (mescole, probabilità) usano i colori
   mescola come "team colors". Unico motivo decorativo: la banda a scacchi
   monocromatica sotto il titolo (il rosso resta del live badge).
--------------------------------------------------------------------------- */
:root {
  --bg: #0b0c0f;
  --panel: #141519;
  --panel-2: #1b1d22;
  --grid: #26282f;
  --axis: #565b66;
  --text: #e8e9ec;
  --text-dim: #8b8f99;
  --live: #e10600;
  /* mescole = team colors funzionali */
  --soft: #ff1744;
  --medium: #ffc107;
  --hard: #9e9e9e;
  --inter: #4caf50;
  --green: #2ecc71;
  --red: #e74c3c;
  --purple: #9b59b6;
  --radius: 8px;
  --font-disp: 'Barlow Condensed', 'Titillium Web', system-ui, sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Titillium Web', system-ui, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
.mono, code { font-family: 'IBM Plex Mono', monospace; }
::selection { background: var(--text); color: var(--bg); }

/* -------------------------------------------------------------- navbar --- */
.navbar {
  display: flex;
  align-items: center;
  gap: 24px;
  /* Pinned alla colonna contenuto: .layout ha 20px di padding laterale,
     percio' si aggiunge +20px per allineare brand/tab al contenuto. */
  padding: 0 max(20px, calc((100% - 1440px) / 2 + 20px));
  min-height: 52px;
  background: var(--panel);
  border-bottom: 1px solid var(--grid);
  position: sticky;
  top: 0;
  z-index: 20;
}
.nav-brand {
  font-family: 'IBM Plex Mono', monospace;
  font-weight: 600;
  letter-spacing: 0.22em;
  font-size: 15px;
  color: var(--text);
  text-decoration: none;
  white-space: nowrap;
  flex-shrink: 0;
}
.nav-back {
  display: inline-flex; align-items: center; justify-content: center;
  width: 26px; height: 26px; flex-shrink: 0;
  color: var(--text-dim);
  border: 1px solid var(--grid);
  border-radius: 6px;
  background: transparent;
  text-decoration: none;
  transition: color .15s, border-color .15s, background .15s;
}
.nav-back svg { display: block; }
.nav-back:hover { color: var(--text); border-color: var(--text-dim); background: var(--panel-2); }
.nav-tabs { display: flex; align-self: stretch; }
.nav-tab {
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-dim);
  font-family: 'IBM Plex Mono', monospace;
  font-size: 12px;
  letter-spacing: 0.14em;
  padding: 0 16px;
  cursor: pointer;
  text-decoration: none;
  display: flex;
  align-items: center;
  white-space: nowrap;
}
.nav-tab.on { color: var(--text); border-bottom-color: var(--text); }
.nav-tab:hover { color: var(--text); }
.live-badge {
  margin-left: auto;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 11px;
  letter-spacing: 0.12em;
  color: var(--live);
  white-space: nowrap;
  flex-shrink: 0;
}
.live-badge.off { color: var(--text-dim); }
.nv-red { color: var(--live); }

/* -------------------------------------------------------------- layout --- */
/* Pagina a scorrimento naturale: la sidebar è sticky, niente scroll innestati. */
.layout {
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr);
  gap: 28px;
  align-items: start;
  width: 100%;
  max-width: 1440px;
  margin: 0 auto;
  padding: 32px 20px 20px;
  flex: 1;
}
.layout.single { display: block; max-width: 1024px; }

.main { min-width: 0; }

/* ------------------------------------------------------------- control --- */
.control-panel {
  background: var(--panel);
  border: 1px solid var(--grid);
  border-radius: 10px;
  padding: 18px 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  position: sticky;
  top: 72px;
}
.panel-title {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 11px;
  letter-spacing: 0.22em;
  color: var(--text-dim);
  display: flex;
  align-items: center;
  gap: 10px;
}
.panel-title::after { content: ""; flex: 1; height: 1px; background: var(--grid); }
.setup-grid { display: grid; grid-template-columns: 1fr; gap: 14px; counter-reset: setup; }
.setup-grid .field { counter-increment: setup; }
.setup-grid .field::before {
  content: "0" counter(setup);
  font-family: 'IBM Plex Mono', monospace;
  font-size: 10px;
  letter-spacing: 0.2em;
  color: var(--axis);
}
.field {
  display: flex; flex-direction: column; gap: 6px;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 11px;
  letter-spacing: 0.06em; text-transform: uppercase;
  color: var(--text-dim);
  min-width: 0;
}
.field select, .field input, .field textarea {
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--grid);
  border-radius: 4px;
  padding: 8px 10px;
  min-height: 42px;
  font-family: 'Titillium Web', system-ui, sans-serif;
  font-size: 14px;
  text-transform: none;
  letter-spacing: normal;
  width: 100%;
  outline: none;
}
.field select:focus-visible,
.start-btn:focus-visible,
.export-btn:focus-visible,
button:focus-visible,
a:focus-visible,
input:focus-visible,
textarea:focus-visible {
  outline: 2px solid var(--text);
  outline-offset: 1px;
}
.field textarea {
  resize: vertical;
  min-height: 90px;
  line-height: 1.55;
  font-size: 13px;
}
.hint { font-size: 12px; color: var(--text-dim); line-height: 1.5; }

.start-btn {
  padding: 12px;
  min-height: 50px;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 13px;
  letter-spacing: 0.12em;
  background: var(--text);
  color: var(--bg);
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-weight: 600;
  text-transform: uppercase;
}
.start-btn:hover:not(:disabled) { filter: brightness(1.08); }
.start-btn:active:not(:disabled) { transform: translateY(1px); }
.start-btn:disabled { opacity: 0.3; cursor: not-allowed; }
.start-btn.live { background: var(--live); color: #fff; }

/* ---------------------------------------------------------------- main --- */
/* AI notice: resta il componente condiviso, qui solo un ritocco mono */
.ai-notice { font-family: 'IBM Plex Mono', monospace; }

.page-head { margin-bottom: 20px; }
.page-head .kicker {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 10px;
  letter-spacing: 0.28em;
  color: var(--text-dim);
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 12px;
}
.page-head .kicker::after { content: ""; height: 1px; width: 72px; background: var(--grid); }
.page-head h1 {
  font-size: clamp(26px, 3.4vw, 36px);
  font-weight: 700;
  letter-spacing: -0.01em;
  line-height: 1.05;
}
.page-head .sub { color: var(--text-dim); font-size: 14px; margin-top: 8px; max-width: 62ch; }

.res-title {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 13px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  margin-bottom: 12px;
}
.res-title::before {
  content: "";
  display: inline-block;
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--green);
  margin-right: 8px;
}

/* error box (predictor) */
.error-box {
  display: none;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 11px;
  background: var(--panel);
  border: 1px solid var(--grid);
  border-left: 3px solid var(--live);
  border-radius: 4px;
  padding: 10px 12px;
  color: var(--text);
  margin-bottom: 12px;
}

/* ------------------------------------------------------------ results --- */
#results.show { animation: rise .5s ease both; }
@keyframes rise {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: none; }
}
.charts { display: flex; flex-direction: column; gap: 12px; }
.chart-block {
  background: var(--panel);
  border: 1px solid var(--grid);
  border-radius: var(--radius);
  padding: 16px 16px 18px;
  min-width: 0;
}
.chart-label {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 10px;
  letter-spacing: 0.24em;
  color: var(--text-dim);
  padding: 2px 4px 12px;
  text-transform: uppercase;
}

/* stint timeline (piano stint): barre proporzionali ai giri */
.stint-timeline { display: flex; gap: 6px; padding: 2px 6px 4px; }
.stint-seg {
  flex: 0 1 auto;
  min-width: 0;
  overflow: hidden;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 2px;
  padding: 10px 8px;
  background: var(--panel-2);
  border-radius: 6px;
  border-top: 3px solid var(--team, var(--grid));
}
.stint-seg .dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--team, var(--grid));
  flex-shrink: 0;
}
.stint-seg .cmp {
  font-family: 'IBM Plex Mono', monospace; font-size: 12px; font-weight: 600;
  color: var(--team, var(--text-dim));
  white-space: nowrap;
}
.stint-seg .laps {
  font-family: 'IBM Plex Mono', monospace; font-size: 10px; color: var(--text-dim);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%;
}
.stint-seg:hover { filter: brightness(1.18); }
.giro-range {
  display: flex; justify-content: space-between;
  padding: 6px 8px 2px;
  font-family: 'IBM Plex Mono', monospace; font-size: 10px; color: var(--text-dim);
}

/* team color ridondante: bordo + lettera + dot (mai più tinta sbagliata) */
.stint-seg.seg-S { --team: #ff1744; }
.stint-seg.seg-M { --team: #ffc107; }
.stint-seg.seg-H { --team: #9e9e9e; }
.stint-seg.seg-I { --team: #4caf50; }
.stint-seg.seg-U { --team: #565b66; }

/* indicatori a tutta larghezza */
.kpi-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; padding: 2px 6px 4px; }
.stat {
  background: var(--panel);
  border: 1px solid var(--grid);
  border-radius: 4px;
  padding: 10px 12px;
  display: flex; flex-direction: column; gap: 3px;
  min-width: 0;
}
.kpi-grid .stat { background: transparent; }
.stat-label, .stat .k {
  font-family: 'IBM Plex Mono', monospace; font-size: 9px;
  letter-spacing: 0.2em; color: var(--text-dim); text-transform: uppercase;
}
.stat-value, .stat .v {
  font-family: var(--font-disp);
  font-size: 26px; font-weight: 600; letter-spacing: 0.02em; line-height: 1;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.stat-sub { font-size: 10px; color: var(--text-dim); }

/* tabella scrollabile con header fisso */
.tbl-wrap { overflow-x: auto; padding: 2px 6px 4px; }
.lap-scroll { max-height: 420px; overflow-y: auto; }
.lap-scroll thead th { position: sticky; top: 0; z-index: 2; }
.lap-tbl { border-collapse: collapse; width: 100%; }
.lap-tbl th {
  font-size: 10px; font-weight: 600;
  letter-spacing: 0.14em; text-transform: uppercase; color: var(--text-dim);
  background: var(--panel); padding: 8px 10px; text-align: center;
  border-bottom: 1px solid var(--grid);
  font-family: 'Titillium Web', sans-serif;
  white-space: nowrap;
}
.lap-tbl th:first-child { text-align: left; }
.lap-tbl td {
  font-family: 'IBM Plex Mono', monospace; text-align: center;
  font-size: 12px; white-space: nowrap;
  padding: 7px 10px;
  border-bottom: 1px solid #1d1f26;
}
.lap-tbl tbody tr:last-child td { border-bottom: none; }
.lap-tbl td:first-child { text-align: left; font-weight: 600; }
.lap-tbl tbody tr:hover td { background: rgba(255, 255, 255, 0.025); }
.cmp {
  display: inline-block; min-width: 56px;
  font-size: 10px; font-weight: 600; letter-spacing: 0.1em;
  padding: 2px 8px; border-radius: 3px;
  border: 1px solid currentColor;
  border-left-width: 3px;
}
.cmp-S { background: rgba(255,23,68,.14); color: #ff5c7a; }
.cmp-M { background: rgba(255,193,7,.13); color: #ffd54d; }
.cmp-H { background: rgba(158,158,158,.14); color: #cfcfcf; }
.cmp-I { background: rgba(76,175,80,.14); color: #6fdc73; }
.cmp-U { background: rgba(86,91,102,.16); color: #8b8f99; }
.ev-real {
  display: inline-block; font-size: 9px; font-weight: 600; letter-spacing: 0.08em;
  padding: 1px 6px; border-radius: 3px; margin-right: 4px;
  background: rgba(232, 233, 236, 0.14); color: #e8e9ec;
}
.ev-pred {
  display: inline-block; font-size: 9px; font-weight: 600; letter-spacing: 0.08em;
  padding: 1px 6px; border-radius: 3px; margin-right: 4px;
  background: rgba(95, 217, 255, 0.13); color: #5fd9ff;
}
tr.is-real-pit td { box-shadow: inset 3px 0 0 var(--green); }
td.prob-high { color: var(--red); font-weight: 600; box-shadow: inset 3px 0 0 var(--red); }
td.prob-med { color: var(--medium); }

/* download finali, evidenti */
.dl-bar { display: none; flex-direction: column; gap: 8px; margin: 4px 0 8px; }
.dl-bar .start-btn { width: 100%; }
.dl-bar .export-btn { align-self: center; min-height: 44px; }

/* export buttons */
.export-btn {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 11px;
  letter-spacing: 0.08em;
  color: var(--text-dim);
  background: var(--panel-2);
  border: 1px solid var(--grid);
  border-radius: 4px;
  padding: 8px 12px;
  cursor: pointer;
  text-transform: uppercase;
}
.export-btn:hover { color: var(--text); border-color: var(--text-dim); }
.export-btn.danger:hover { border-color: var(--red); color: #ff6b5b; }

/* loader = macchinina che gira sulla mini pista */
.sim-loader { display: none; margin-bottom: 12px; }
.sim-loader.show { display: block; }
.race-loader {
  background: var(--panel);
  border: 1px solid var(--grid);
  border-radius: var(--radius);
  padding: 18px 16px 14px;
  max-width: 560px;
  margin: 0 auto;
}
/* loader sobrio: riga di avanzamento indeterminata + messaggi di fase */
.rl-kicker {
  font-family: 'IBM Plex Mono', monospace; font-size: 10px;
  letter-spacing: 0.26em; color: var(--text-dim); text-align: center;
}
.rl-bar {
  height: 2px; background: var(--grid); border-radius: 1px;
  overflow: hidden; margin: 14px 4px 4px;
}
.rl-bar > span {
  display: block; height: 100%; width: 30%;
  background: var(--text); border-radius: 1px;
  animation: rl-slide 1.2s ease-in-out infinite;
}
@keyframes rl-slide {
  0% { transform: translateX(-110%); }
  100% { transform: translateX(360%); }
}
.sk-note {
  text-align: center; color: var(--text-dim); font-size: 12px;
  font-family: 'IBM Plex Mono', monospace; margin-top: 10px;
}

/* empty state */
.empty-state {
  display: flex; flex-direction: column; align-items: center;
  justify-content: center; gap: 10px; min-height: 280px; padding: 40px 20px;
  text-align: center; color: var(--text-dim);
}
.empty-icon { color: var(--axis); }
.empty-title { font-size: 16px; font-weight: 600; color: var(--text); letter-spacing: 0.02em; }
.empty-hint { font-size: 13px; color: var(--text-dim); max-width: 420px; line-height: 1.5; }

/* ------------------------------------------------------------- drivers --- */
/* (tab Stats: riuso stat-grid + history-table del template) */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 10px;
  margin-bottom: 16px;
}
/* righe sempre complete: 4 card → 4 o 2+2 · 6 card → 3+3 o 2+2+2 */
.stat-grid.cols-4 { grid-template-columns: repeat(4, 1fr); }
.stat-grid.cols-6 { grid-template-columns: repeat(3, 1fr); }
.history-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.history-table th {
  font-family: 'IBM Plex Mono', monospace; font-size: 10px;
  letter-spacing: 0.18em; color: var(--text-dim); text-align: left;
  padding: 8px 12px; border-bottom: 1px solid var(--grid);
  text-transform: uppercase; white-space: nowrap;
}
.history-table td { padding: 9px 12px; border-bottom: 1px solid var(--grid); }
.history-table tr:hover td { background: var(--panel); }
.history-table td.num, .history-table th.num { text-align: right; font-family: 'IBM Plex Mono', monospace; }
.paid { color: var(--green); font-family: 'IBM Plex Mono', monospace; font-size: 12px; }
.unpaid { color: var(--medium); font-family: 'IBM Plex Mono', monospace; font-size: 12px; }
#sc { width: 100%; height: auto; display: block; }

/* --------------------------------------------------------------- about --- */
.about-view { max-width: 880px; margin: 0 auto; width: 100%; }
.about-block { margin-bottom: 32px; border-top: 1px solid var(--grid); padding-top: 20px; }
.about-block:first-child { border-top: none; padding-top: 0; }
.about-block h2 { font-size: 20px; font-weight: 700; margin-bottom: 12px; letter-spacing: 0.02em; }
.about-block h3 {
  font-family: 'IBM Plex Mono', monospace; font-size: 11px; font-weight: 600;
  letter-spacing: 0.22em; text-transform: uppercase;
  color: var(--text-dim); margin: 18px 0 8px;
}
.about-block p { font-size: 14px; line-height: 1.65; color: var(--text-dim); margin-bottom: 12px; }
.about-block p strong { color: var(--text); }
.about-block a { color: var(--text); border-bottom: 1px solid var(--grid); text-decoration: none; }
.about-block a:hover { border-bottom-color: var(--text); }
.stack-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.stack-item {
  background: var(--panel-2); border: 1px solid var(--grid);
  border-radius: 6px; padding: 10px 14px;
  display: flex; flex-direction: column; gap: 2px;
  min-width: 0;
}
.stack-name { font-family: 'IBM Plex Mono', monospace; font-size: 13px; font-weight: 600; color: var(--text); }
.stack-role { font-size: 12px; color: var(--text-dim); }
/* guida rapida: step numerati editoriali */
.steps { list-style: none; counter-reset: step; display: flex; flex-direction: column; }
.steps li {
  counter-increment: step;
  display: flex; gap: 8px; align-items: baseline;
  padding: 10px 0; border-bottom: 1px solid #1d1f26;
  font-size: 14px; line-height: 1.6; color: var(--text-dim);
}
.steps li:last-child { border-bottom: none; }
.steps li::before {
  content: "0" counter(step);
  font-family: 'IBM Plex Mono', monospace; font-size: 11px;
  color: var(--text); flex-shrink: 0; min-width: 20px;
}
.steps li strong { color: var(--text); font-weight: 600; }
.about-note { font-style: italic; }
/* blocco AI in evidenza: giallino + parole rosse F1 */
.about-block.warn {
  background: rgba(255, 193, 7, 0.05);
  border: 1px solid rgba(255, 193, 7, 0.25);
  border-radius: var(--radius);
  padding: 16px 18px;
}
.about-block.warn h2 { color: var(--medium); }
.about-block.warn .stack-item { background: rgba(255, 193, 7, 0.04); }
.f1red { color: #ff5c5c; font-weight: 600; }
.res-links { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin-top: 4px; }
.res-links > a, .res-links > span {
  font-family: 'IBM Plex Mono', monospace; font-size: 11px; letter-spacing: 0.08em;
  color: var(--text-dim); background: var(--panel-2);
  border: 1px solid var(--grid); border-radius: 4px; padding: 8px 12px;
  min-height: 40px;
  display: inline-flex; align-items: center; justify-content: center; text-align: center;
  text-decoration: none;
}
.res-links > a:hover { color: var(--text); border-color: var(--text-dim); }
.res-links > span { opacity: 0.45; cursor: not-allowed; }

/* -------------------------------------------------------------- testing --- */
.test-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 10px; }
.status-bar {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 12px;
  color: var(--text-dim);
  padding: 10px 12px;
  background: var(--panel);
  border: 1px solid var(--grid);
  border-radius: 4px;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.test-msgs { display: flex; flex-direction: column; gap: 8px; margin-top: 10px; }
.test-msg {
  background: var(--panel-2); border: 1px solid var(--grid);
  border-left: 3px solid var(--axis); border-radius: 4px;
  padding: 10px 12px;
  min-width: 0;
}
.test-msg .phase {
  font-family: 'IBM Plex Mono', monospace; font-size: 10px;
  letter-spacing: 0.14em; color: var(--text-dim); margin-bottom: 6px;
  text-transform: uppercase;
}
.test-msg pre {
  margin: 0; white-space: pre-wrap; word-break: break-word;
  font-size: 11px; font-family: 'IBM Plex Mono', monospace;
  color: var(--text);
}
.radio-row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; font-size: 12px; }
.radio-row label { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; min-height: 32px; }
.endpoint-line { display: flex; gap: 10px; align-items: center; margin-bottom: 10px; flex-wrap: wrap; }
.endpoint-line .k { font-family: 'IBM Plex Mono', monospace; font-size: 10px; letter-spacing: 0.18em; color: var(--text-dim); min-width: 70px; }
.endpoint-line code { word-break: break-all; }

/* reveal (mantenuto dal progetto, ammorbidito) */
.reveal { opacity: 0; transform: translateY(14px); transition: opacity .5s ease, transform .5s ease; }
.reveal.visible { opacity: 1; transform: translateY(0); }

@media (prefers-reduced-motion: reduce) {
  .reveal { transition: none; }
  .rl-bar > span { animation: none; }
  #results.show { animation: none; }
}

/* ============================ schermi medi ============================ */
@media (max-width: 1020px) {
  /* Sidebar impilata, ma titolo + banner AI restano SEMPRE sopra la card:
     il main si "apre" (display:contents) così i suoi figli diventano item del
     layout e possiamo ordinarli (titolo/AI = 1, card = 2, risultati = 3). */
  /* align-items: stretch obbligatorio: la regola base .layout ha
     align-items: start, che in colonna fa restringere i blocchi al contenuto
     e lascia una colonna vuota a destra. */
  .layout:not(.single) { display: flex; flex-direction: column; gap: 16px; align-items: stretch; }
  .layout:not(.single) > * { width: 100%; }
  .layout:not(.single) .control-panel { position: static; order: 2; }
  .layout:not(.single) .main { display: contents; }
  .layout:not(.single) .main > .page-head { order: 1; }
  .layout:not(.single) .main > .ai-notice { order: 1; }
  .layout:not(.single) .main > :not(.page-head):not(.ai-notice) { order: 3; }
  .setup-grid { grid-template-columns: 1fr 1fr; }
  .setup-grid .span-all { grid-column: 1 / -1; }
}

/* ============================ schermi piccoli ============================ */
@media (max-width: 640px) {
  body { font-size: 14px; }
  .layout, .layout.single { padding: 14px 12px 20px; }

  /* navbar su due righe: brand + badge sopra, tab scrollabili sotto */
  .navbar { flex-wrap: wrap; gap: 6px 10px; padding: 8px 12px; }
  .nav-brand { font-size: 13px; letter-spacing: 0.16em; }
  .nav-tabs {
    order: 3; flex-basis: 100%;
    align-self: auto;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  .nav-tab { font-size: 11px; letter-spacing: 0.08em; padding: 10px 12px; flex-shrink: 0; }
  .live-badge { font-size: 10px; letter-spacing: 0.06em; }

  .page-head h1 { font-size: 24px; }
  .page-head .sub { font-size: 13px; }

  /* setup compatto: pilota intero, stagione + GP affiancati */
  .control-panel { padding: 16px 14px; }
  .field select { font-size: 16px; } /* niente auto-zoom su iOS */
  .start-btn { width: 100%; }

  /* timeline in verticale: una card per stint, niente più schiacciamento */
  .stint-timeline { flex-direction: column; }
  .stint-seg {
    width: 100% !important;
    flex-direction: row;
    align-items: center;
    text-align: left;
    gap: 10px;
    padding: 10px 12px;
    border-top: none;
    border-left: 3px solid var(--team, var(--grid));
  }
  .stint-seg .dot { margin: 0; }
  .stint-seg .laps { margin-left: auto; text-align: right; }

  .kpi-grid { grid-template-columns: 1fr 1fr; }

  /* tabella giri → cards: una card per giro, header nascosto */
  .lap-scroll { max-height: none; overflow: visible; }
  .lap-tbl, .lap-tbl tbody { display: block; width: 100%; }
  .lap-tbl { border-spacing: 0; }
  .lap-tbl thead { display: none; }
  .lap-tbl tbody tr {
    display: block;
    background: var(--panel-2);
    border: 1px solid var(--grid);
    border-radius: 6px;
    margin-bottom: 8px;
    padding: 4px 6px;
  }
  .lap-tbl tbody tr.is-real-pit { border-left: 3px solid var(--green); }
  .lap-tbl tbody tr.is-real-pit td { box-shadow: none; }
  .lap-tbl td, .lap-tbl td:first-child {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    background: none;
    border-radius: 0;
    text-align: right;
    font-size: 13px;
    padding: 7px 8px;
    white-space: normal;
  }
  .lap-tbl td::before {
    content: attr(data-label);
    font-family: 'Titillium Web', sans-serif;
    font-size: 10px; font-weight: 600;
    letter-spacing: 0.12em; text-transform: uppercase;
    color: var(--text-dim);
    text-align: left;
    flex-shrink: 0;
  }
  td.prob-high { box-shadow: none; }
  td.prob-high::after { content: ""; }

  .stat-value, .stat .v { font-size: 22px; }
  .stat-grid.cols-4, .stat-grid.cols-6 { grid-template-columns: 1fr 1fr; }
  .res-links { grid-template-columns: 1fr 1fr; }
  .history-table { font-size: 12px; }
  .history-table th, .history-table td { padding: 8px; }

  .stack-grid { grid-template-columns: 1fr; }
  .test-grid { grid-template-columns: 1fr; }
  .empty-state { min-height: 200px; padding: 24px 16px; }
  .about-block h2 { font-size: 18px; }
}
