:root {
  --bg: #0d0f14;
  --bg2: #151923;
  --card: #1a1f2b;
  --card2: #222838;
  --line: #2c3344;
  --text: #e8ebf2;
  --muted: #8b93a5;
  --accent: #e10600;
  --accent2: #3fa9f5;
  --good: #2ecc71;
  --warn: #f5b041;
  --bad: #ff4d4d;
  --radius: 10px;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font-family: 'Titillium Web', system-ui, sans-serif; font-size: 15px; }
h1 { font-size: 26px; margin: 0 0 6px; font-weight: 900; letter-spacing: .3px; }
h2 { font-size: 17px; margin: 0; font-weight: 700; }
h3 { font-size: 20px; margin: 0 0 4px; }
p { line-height: 1.5; }
b { font-weight: 700; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.good { color: var(--good); }
.neg { color: var(--bad); }
.warn { color: var(--warn); }
.row { display: flex; align-items: center; }
.gap { gap: 10px; }
.wrap { flex-wrap: wrap; }
.hidden { display: none !important; }

/* Boutons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 8px 16px; border-radius: 8px; border: 1px solid var(--line); background: var(--card2); color: var(--text); font: inherit; font-weight: 600; cursor: pointer; transition: .15s; }
.btn:hover { border-color: #4a5470; background: #2a3145; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { filter: brightness(1.12); }
.btn.big { padding: 12px 22px; font-size: 16px; }
.btn.small { padding: 4px 10px; font-size: 13px; }
.btn.ghost { background: transparent; }
.btn.danger { border-color: var(--bad); color: var(--bad); background: transparent; }
.btn:disabled { opacity: .4; cursor: not-allowed; }
.chip { display: inline-block; padding: 2px 9px; border-radius: 20px; background: var(--card2); border: 1px solid var(--line); font-size: 12px; font-weight: 600; color: var(--muted); }
.seg { display: inline-flex; flex-wrap: wrap; background: var(--bg2); border: 1px solid var(--line); border-radius: 8px; padding: 3px; gap: 3px; margin: 6px 0; }
.seg button { border: 0; background: transparent; color: var(--muted); font: inherit; font-weight: 600; padding: 5px 11px; border-radius: 6px; cursor: pointer; display: inline-flex; align-items: center; gap: 5px; }
.seg button:hover { color: var(--text); }
.seg button.on { background: var(--card2); color: var(--text); box-shadow: inset 0 -2px 0 var(--accent); }
.seg.mini button { padding: 3px 8px; font-size: 12.5px; }
select, input[type=text] { background: var(--bg2); color: var(--text); border: 1px solid var(--line); border-radius: 8px; padding: 7px 10px; font: inherit; }
.check { display: flex; align-items: center; gap: 8px; margin: 8px 0; cursor: pointer; }
.check input { accent-color: var(--accent); width: 16px; height: 16px; }

/* Démarrage */
.start { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 30px 16px; background: radial-gradient(ellipse at top, #2a0d10 0%, var(--bg) 60%); }
.start-card { max-width: 560px; text-align: center; background: rgba(26, 31, 43, .8); border: 1px solid var(--line); border-radius: 16px; padding: 40px 32px; }
.start-logo { display: flex; align-items: center; justify-content: center; gap: 12px; margin-bottom: 8px; }
.start-logo h1 { font-size: 40px; margin: 0; letter-spacing: 4px; }
.start-actions { display: flex; flex-direction: column; gap: 10px; margin-top: 24px; }
.logo { background: var(--accent); color: #fff; font-weight: 900; font-style: italic; padding: 1px 8px; border-radius: 4px; letter-spacing: 1px; }
.logo.big { font-size: 36px; padding: 2px 14px; }
.newgame { justify-content: flex-start; }
.newgame > h1, .newgame > p { text-align: center; }
.team-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px; width: 100%; max-width: 1280px; margin: 18px 0; }
.team-pick { text-align: left; background: var(--card); border: 2px solid var(--line); border-radius: var(--radius); padding: 14px; color: var(--text); font: inherit; cursor: pointer; transition: .15s; border-top: 4px solid var(--team); }
.team-pick:hover { transform: translateY(-2px); border-color: #4a5470; border-top-color: var(--team); }
.team-pick.on { border-color: var(--team); box-shadow: 0 0 0 3px color-mix(in srgb, var(--team) 35%, transparent); }
.tp-head { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.tp-head i { width: 12px; height: 12px; border-radius: 3px; background: var(--team); }
.tp-head b { flex: 1; }
.tp-foot { display: flex; justify-content: space-between; margin-top: 8px; font-size: 13px; color: var(--muted); }
.ng-options { display: flex; flex-wrap: wrap; gap: 16px; align-items: flex-end; justify-content: center; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.ng-options label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); }

/* Structure */
.topbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 18px; padding: 8px 18px; background: linear-gradient(90deg, color-mix(in srgb, var(--team) 25%, var(--bg2)) 0%, var(--bg2) 45%); border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.brand { font-weight: 900; letter-spacing: 2px; }
.tb-item { display: flex; flex-direction: column; line-height: 1.1; }
.tb-item small { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .5px; }
.tb-spacer { flex: 1; }
.layout { display: flex; min-height: calc(100vh - 56px); }
.sidebar { width: 200px; flex-shrink: 0; background: var(--bg2); border-right: 1px solid var(--line); padding: 12px 8px; display: flex; flex-direction: column; gap: 2px; }
.nav { display: flex; align-items: center; gap: 10px; background: transparent; border: 0; color: var(--muted); font: inherit; font-weight: 600; text-align: left; padding: 9px 12px; border-radius: 8px; cursor: pointer; }
.nav span { width: 20px; text-align: center; }
.nav:hover { background: var(--card); color: var(--text); }
.nav.on { background: var(--card2); color: var(--text); box-shadow: inset 3px 0 0 var(--accent); }
.main { flex: 1; padding: 22px; min-width: 0; max-width: 1500px; }
.tteam { display: inline-flex; align-items: center; gap: 7px; white-space: nowrap; }
.tteam i { width: 4px; height: 16px; border-radius: 2px; }

/* Cartes */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; min-width: 0; }
.card-h { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; flex-wrap: wrap; }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; margin-top: 12px; }
.span2 { grid-column: span 2; }
.cards3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 16px; margin-top: 16px; }
.cards4 { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; margin-top: 16px; }
.kpis { display: flex; gap: 12px; margin-bottom: 12px; flex-wrap: wrap; }
.kpi { flex: 1; min-width: 110px; background: var(--bg2); border-radius: 8px; padding: 10px 12px; display: flex; flex-direction: column; }
.kpi small { color: var(--muted); font-size: 11.5px; text-transform: uppercase; }
.kpi b { font-size: 22px; }
.kpi span { color: var(--muted); font-size: 12px; }
.kv { display: flex; justify-content: space-between; gap: 10px; padding: 6px 0; border-bottom: 1px dashed var(--line); flex-wrap: wrap; }
.kv span { color: var(--muted); }

/* Barres */
.bar { flex: 1; height: 7px; background: var(--bg2); border-radius: 4px; overflow: hidden; min-width: 40px; }
.bar > div { height: 100%; border-radius: 4px; transition: width .3s; }
.stat { display: flex; align-items: center; gap: 10px; margin: 6px 0; }
.stat-l { width: 108px; color: var(--muted); font-size: 13.5px; flex-shrink: 0; }
.stat-v { width: 30px; text-align: right; font-weight: 700; }
.rank { width: 34px; font-size: 12px; color: var(--muted); }
.delta { width: 58px; font-size: 12px; color: var(--muted); text-align: right; }
.confidence { display: flex; align-items: center; gap: 10px; margin: 8px 0 12px; }
.confidence span { color: var(--muted); font-size: 13px; white-space: nowrap; }

/* Tables */
.tbl { width: 100%; border-collapse: collapse; font-size: 14px; }
.tbl th { text-align: left; color: var(--muted); font-weight: 600; font-size: 12px; text-transform: uppercase; padding: 6px 8px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.tbl td { padding: 6px 8px; border-bottom: 1px solid rgba(255, 255, 255, .04); }
.tbl tr.me td { background: rgba(225, 6, 0, .09); }
.tbl tr.out td { opacity: .5; }
.tbl.compact td { padding: 4px 8px; }
.scroll-x { overflow-x: auto; }
.standings td.rc, .standings th { text-align: center; font-size: 12px; }
.rc.win { background: #b8860b55; font-weight: 700; }
.rc.pod { background: #ffffff18; }
.rc.pts { background: #2ecc7118; }
.rc.dnf { color: var(--bad); }

/* Pneus */
.tyre { display: inline-flex; align-items: center; justify-content: center; width: 22px; height: 22px; border-radius: 50%; border: 3px solid; font-size: 11px; font-weight: 900; background: #111; color: #fff; line-height: 1; flex-shrink: 0; }
.tyre-S { border-color: #ff3b3b; }
.tyre-M { border-color: #ffd21f; }
.tyre-H { border-color: #eeeeee; }
.tyre-I { border-color: #2fbf4a; }
.tyre-W { border-color: #2f86ff; }
.tyre-life { display: flex; flex-wrap: wrap; gap: 14px; align-items: center; margin: 6px 0; }
.tyre-life > span { display: inline-flex; align-items: center; gap: 5px; }

/* QG */
.gp-body { display: flex; gap: 16px; align-items: flex-start; flex-wrap: wrap; }
.mini-track { background: var(--bg2); border-radius: 8px; max-width: 100%; }
.traits { display: grid; grid-template-columns: repeat(2, minmax(130px, 1fr)); gap: 6px 16px; margin: 10px 0; flex: 1; min-width: 240px; }
.traits > div { display: flex; flex-direction: column; gap: 3px; }
.traits small { color: var(--muted); font-size: 12px; }
.news { list-style: none; margin: 0; padding: 0; }
.news li { padding: 7px 0 7px 10px; border-bottom: 1px solid rgba(255, 255, 255, .04); border-left: 3px solid var(--line); margin-bottom: 2px; }
.news .n-race { border-left-color: var(--accent); }
.news .n-rd { border-left-color: var(--accent2); }
.news .n-money { border-left-color: var(--good); }
.news .n-board { border-left-color: var(--warn); }
.news .n-driver { border-left-color: #a45bd6; }

/* R&D */
.preview { background: var(--bg2); border-radius: 8px; padding: 10px 12px; margin: 10px 0; }
.project { padding: 8px 0; border-bottom: 1px dashed var(--line); display: flex; flex-direction: column; gap: 5px; }

/* Installations */
.levels { display: flex; gap: 5px; margin: 10px 0; }
.levels i { flex: 1; height: 10px; border-radius: 3px; background: var(--bg2); }
.levels i.on { background: var(--accent); }
.fac p { min-height: 44px; }

/* Pilotes */
.driver .drv-head { display: flex; align-items: center; gap: 12px; margin-bottom: 10px; padding-bottom: 10px; border-bottom: 3px solid var(--team); }
.num { font-size: 30px; font-weight: 900; font-style: italic; color: var(--team); width: 46px; }
.drv-name { font-size: 19px; }
.ovr { margin-left: auto; text-align: center; background: var(--bg2); border-radius: 8px; padding: 4px 12px; }
.ovr small { display: block; color: var(--muted); font-size: 11px; }
.ovr b { font-size: 24px; }
.res-strip { display: flex; flex-wrap: wrap; gap: 3px; margin: 10px 0; }
.rs { min-width: 26px; text-align: center; font-size: 12px; padding: 2px 4px; border-radius: 4px; background: var(--bg2); }
.rs.pod { background: #b8860b66; }
.rs.pts { background: #2ecc7133; }
.rs.dnf { color: var(--bad); }
.contract { padding: 10px 0; border-bottom: 1px dashed var(--line); display: flex; flex-direction: column; gap: 6px; }

/* Week-end */
.wk-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; }
.steps { display: flex; gap: 4px; flex-wrap: wrap; }
.steps span { padding: 6px 12px; background: var(--bg2); border-radius: 6px; color: var(--muted); font-size: 13px; font-weight: 600; }
.steps span.on { background: var(--accent); color: #fff; }
.steps span.done { color: var(--good); }
.prog { padding: 12px 0; border-bottom: 1px dashed var(--line); }
.prog-d { font-size: 17px; margin-bottom: 8px; display: flex; gap: 10px; align-items: center; }
.prog-opts { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.opt { text-align: left; background: var(--bg2); border: 1px solid var(--line); border-radius: 8px; padding: 10px; color: var(--text); font: inherit; cursor: pointer; display: flex; flex-direction: column; gap: 3px; }
.opt small { color: var(--muted); font-size: 12px; line-height: 1.3; }
.opt.on { border-color: var(--accent); background: rgba(225, 6, 0, .1); }
.weather { display: flex; align-items: center; gap: 12px; background: var(--bg2); border-radius: 8px; padding: 10px 12px; margin: 12px 0; }
.wicon { font-size: 28px; }
.chip.fl { background: #7b2cbf; color: #fff; border-color: #7b2cbf; padding: 0 6px; }
.pos-chart { width: 100%; height: 360px; background: var(--bg2); border-radius: 8px; }

/* Course en direct */
.race-view { display: flex; flex-direction: column; height: 100vh; overflow: hidden; }
.rv-top { display: flex; align-items: center; gap: 14px; padding: 8px 14px; background: var(--bg2); border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.rv-title { display: flex; flex-direction: column; line-height: 1.15; }
.rv-title span { font-size: 22px; font-weight: 900; }
.rv-spacer { flex: 1; }
.flag { padding: 5px 12px; border-radius: 6px; font-weight: 900; font-size: 13px; letter-spacing: 1px; }
.flag.green { background: #1d7a3e; }
.flag.sc { background: #ffb000; color: #000; animation: blink 1s infinite; }
.flag.chk { background: repeating-conic-gradient(#fff 0 25%, #000 0 50%) 0 0 / 12px 12px; color: #fff; text-shadow: 0 0 4px #000, 0 0 4px #000; }
@keyframes blink { 50% { opacity: .6; } }
.rv-weather { display: flex; align-items: center; gap: 8px; font-size: 14px; }
.wetbar { width: 70px; }
.wetbar > div { background: var(--accent2); }
.rv-main { flex: 1; display: flex; min-height: 0; }
.rv-left { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.rv-track { flex: 1; position: relative; min-height: 260px; background: radial-gradient(ellipse at center, #1a2230 0%, #0d0f14 75%); }
.rv-track canvas { position: absolute; inset: 0; }
.rv-overlay { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; background: rgba(10, 12, 16, .7); text-align: center; }
.rv-overlay > div { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 26px 34px; }
.rv-panels { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; padding: 10px; background: var(--bg2); border-top: 1px solid var(--line); }
.pp { background: var(--card); border: 1px solid var(--line); border-left: 4px solid var(--team); border-radius: 8px; padding: 10px 12px; }
.pp.retired { opacity: .5; }
.pp-h { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.pp-pos { font-size: 22px; font-weight: 900; min-width: 42px; }
.pp-name { font-size: 16px; }
.pp-gap { margin-left: auto; font-size: 12.5px; display: flex; gap: 10px; color: var(--muted); }
.pp-row { display: flex; align-items: center; gap: 10px; margin-top: 6px; flex-wrap: wrap; }
.pp-row .seg { margin: 0; }
.bar.wear { max-width: 180px; height: 9px; }
.btn.box { margin-left: auto; font-weight: 900; letter-spacing: 1px; }
.btn.box.armed { background: var(--warn); color: #000; border-color: var(--warn); animation: blink 1s infinite; }
.rv-right { width: 380px; display: flex; flex-direction: column; border-left: 1px solid var(--line); background: var(--bg2); min-height: 0; }
.rv-tower { flex: 1.4; overflow-y: auto; min-height: 0; }
.tower-h { position: sticky; top: 0; z-index: 2; display: flex; justify-content: space-between; align-items: center; padding: 6px 10px; background: var(--bg2); border-bottom: 1px solid var(--line); font-weight: 700; font-size: 13px; text-transform: uppercase; color: var(--muted); }
.tower-h .seg { margin: 0; }
.trow { display: grid; grid-template-columns: 24px 4px 40px 32px 1fr 44px 16px 52px; align-items: center; gap: 6px; padding: 3px 10px; font-size: 13.5px; cursor: pointer; border-bottom: 1px solid rgba(255, 255, 255, .03); }
.trow:hover { background: var(--card); }
.trow.me { background: rgba(225, 6, 0, .14); }
.trow.focus { outline: 1px solid var(--accent2); }
.trow.ret { opacity: .45; }
.trow i { height: 16px; border-radius: 2px; }
.tp { font-weight: 700; text-align: right; }
.tn { font-weight: 700; }
.tmv { font-size: 11px; }
.tg { text-align: right; font-variant-numeric: tabular-nums; }
.tt { display: flex; align-items: center; gap: 3px; }
.tt .tyre { width: 18px; height: 18px; font-size: 9.5px; border-width: 2.5px; }
.tt small { color: var(--muted); font-size: 11px; }
.tpit { color: var(--muted); font-size: 12px; text-align: center; }
.ts span { font-size: 10.5px; font-weight: 900; padding: 1px 4px; border-radius: 3px; }
.pit { background: var(--accent2); color: #000; padding: 1px 5px; border-radius: 3px; font-weight: 900; font-size: 11px; }
.boxed { background: var(--warn); color: #000; }
.drs { background: var(--good); color: #000; }
.rv-feed { flex: 1; overflow-y: auto; border-top: 1px solid var(--line); min-height: 0; }
.rv-feed ul { list-style: none; margin: 0; padding: 0; }
.rv-feed li { padding: 5px 10px; font-size: 13px; border-bottom: 1px solid rgba(255, 255, 255, .03); border-left: 3px solid transparent; }
.rv-feed li.mine { background: rgba(225, 6, 0, .08); }
.ml { color: var(--muted); font-size: 11px; margin-right: 6px; font-weight: 700; }
.m-sc { border-left-color: #ffb000 !important; color: #ffd166; }
.m-dnf, .m-incident { border-left-color: var(--bad) !important; }
.m-overtake { border-left-color: var(--good) !important; }
.m-pit { border-left-color: var(--accent2) !important; }
.m-weather { border-left-color: #6fa8ff !important; color: #9cc3ff; }
.m-fastest { border-left-color: #b57bff !important; }
.m-radio { border-left-color: #888 !important; font-style: italic; }
.m-finish { border-left-color: #fff !important; font-weight: 700; }
.m-penalty { border-left-color: var(--warn) !important; }

/* Toast */
.toast { position: fixed; bottom: 20px; left: 50%; transform: translate(-50%, 20px); opacity: 0; transition: .25s; background: var(--card2); border: 1px solid var(--line); padding: 10px 18px; border-radius: 8px; z-index: 100; font-weight: 600; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.error { border-color: var(--bad); color: #ffb3b3; }
.toast.ok { border-color: var(--good); color: #b6f5cf; }

/* Responsive */
@media (max-width: 1100px) {
  .grid2 { grid-template-columns: minmax(0, 1fr); }
  .span2 { grid-column: auto; }
  .rv-right { width: 320px; }
}
@media (max-width: 820px) {
  .layout { flex-direction: column; }
  .sidebar { width: 100%; flex-direction: row; overflow-x: auto; padding: 6px; border-right: 0; border-bottom: 1px solid var(--line); }
  .nav { white-space: nowrap; padding: 7px 10px; }
  .main { padding: 14px 16px; }
  .prog-opts { grid-template-columns: minmax(0, 1fr); }
  .race-view { height: auto; overflow: visible; }
  .rv-main { flex-direction: column; }
  .rv-track { min-height: 320px; height: 55vw; flex: none; }
  .rv-panels { grid-template-columns: minmax(0, 1fr); }
  .rv-right { width: 100%; border-left: 0; }
  .rv-tower, .rv-feed { max-height: 420px; }
  .tb-item small { font-size: 10px; }
}
