/* Charte SlotMetrics (voir brand/brand.css) — interface sombre « piste » par défaut,
   variante claire (body.light) pour les pages publiques. */
:root {
  --bg: var(--sm-d-surface); --panel: var(--sm-d-raised); --panel2: var(--sm-d-raised2); --line: var(--sm-d-line);
  --text: var(--sm-d-ink); --muted: var(--sm-d-muted);
  --accent: var(--sm-brand); --on-accent: var(--sm-on-brand); --link: var(--sm-brand);
  --green: var(--sm-d-pb); --yellow: var(--sm-yellow); --red: var(--sm-red); --purple: var(--sm-d-best);
  --radius: 12px; --mono: var(--sm-font-mono);
}
:root:has(body.light), body.light {
  --bg: var(--sm-surface); --panel: var(--sm-raised); --panel2: #ecebe6; --line: var(--sm-line);
  --text: var(--sm-ink); --muted: var(--sm-ink-muted); --link: var(--sm-brand-ink);
  --green: var(--sm-pb); --purple: var(--sm-best);
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 400 15px/1.45 var(--sm-font-sans); -webkit-font-smoothing: antialiased; }
h1, h2 { font-family: var(--sm-font-display); font-weight: 700; letter-spacing: -.005em; }
button, input, select { font: inherit; color: inherit; }
a { color: var(--link); }
.num { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.hidden { display: none !important; }

/* ---------- En-tête ---------- */
header.top { display: flex; align-items: center; gap: 18px; padding: 10px 18px; background: var(--panel); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 10px; font: 600 13px var(--sm-font-sans); letter-spacing: .12em; text-transform: uppercase; color: var(--muted); text-decoration: none; }
.brand img { height: 28px; width: auto; display: block; }
@media (max-width: 1000px) { header.top { position: static; } } /* sur écran étroit l'en-tête est haut : ne pas recouvrir le contenu */
nav.tabs { display: flex; gap: 4px; flex-wrap: wrap; }
nav.tabs button { background: none; border: 0; padding: 8px 12px; border-radius: 8px; color: var(--muted); cursor: pointer; font-weight: 600; }
nav.tabs button:hover { background: var(--panel2); color: var(--text); }
nav.tabs button.active { background: var(--panel2); color: var(--text); box-shadow: inset 0 -2px 0 var(--accent); }
.status-chips { margin-left: auto; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 999px; background: var(--panel2); font-size: 13px; border: 1px solid var(--line); white-space: nowrap; }
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--muted); }
.dot.ok { background: var(--green); box-shadow: 0 0 6px var(--green); }
.dot.err { background: var(--red); }
.dot.warn { background: var(--yellow); }

main { padding: 18px; max-width: 1500px; margin: 0 auto; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin-bottom: 16px; }
.panel h2 { margin: 0 0 12px; font-size: 22px; }
.panel h3 { margin: 14px 0 8px; font-size: 14px; color: var(--muted); text-transform: uppercase; letter-spacing: .5px; }

/* ---------- Boutons ---------- */
.btn { border: 1px solid var(--line); background: var(--panel2); padding: 8px 14px; border-radius: 8px; cursor: pointer; font-weight: 600; white-space: nowrap; }
.btn:hover { filter: brightness(1.2); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn.primary:hover { background: var(--sm-brand-hover); filter: none; }
.btn.go { background: var(--green); border-color: var(--green); color: var(--sm-on-brand); }
.btn.warn { background: var(--yellow); border-color: var(--yellow); color: #111; }
.btn.danger { background: transparent; border-color: var(--red); color: var(--red); }
.btn.big { padding: 12px 22px; font-size: 17px; }
.btn.small { padding: 3px 8px; font-size: 12px; border-radius: 6px; }
.btn.ghost { background: transparent; }
.row-actions { display: flex; gap: 6px; justify-content: flex-end; }

/* ---------- Formulaires ---------- */
label.field { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); }
input[type=text], input[type=number], input[type=url], input[type=password], select {
  background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; color: var(--text); min-width: 0; }
input:focus, select:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
.grid { display: grid; gap: 12px; }
.grid.c2 { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.grid.c4 { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 9px; overflow: hidden; }
.seg button { border: 0; background: var(--bg); padding: 9px 16px; cursor: pointer; color: var(--muted); font-weight: 600; }
.seg button.on { background: var(--accent); color: var(--on-accent); }
.check { display: flex; gap: 8px; align-items: center; cursor: pointer; }
.check input { width: 17px; height: 17px; accent-color: var(--accent); }

/* ---------- Tableaux ---------- */
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .5px; color: var(--muted); font-weight: 600; padding: 8px; border-bottom: 1px solid var(--line); }
td { padding: 8px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
td.r, th.r { text-align: right; }
td.c, th.c { text-align: center; }
.chip { display: inline-flex; align-items: center; justify-content: center; min-width: 26px; height: 26px; padding: 0 6px; border-radius: 6px; font-weight: 800; font-size: 14px; }
.chip.big { min-width: 1.6em; height: 1.6em; font-size: 1em; border-radius: .25em; }
.best { color: var(--purple); font-weight: 700; }
.swatch { display: inline-block; width: 14px; height: 14px; border-radius: 3px; border: 1px solid var(--line); vertical-align: -2px; }
input[type=color] { width: 48px; height: 36px; padding: 2px; border: 1px solid var(--line); border-radius: 8px; background: var(--bg); }
.sus { color: var(--yellow); }
.ignored td { color: var(--muted); text-decoration: line-through; text-decoration-color: rgba(255,255,255,.25); }
.ignored td.keep { text-decoration: none; }
.tag { display: inline-block; font-size: 11px; padding: 1px 7px; border-radius: 5px; background: var(--panel2); border: 1px solid var(--line); color: var(--muted); }
.tag.green { color: var(--green); border-color: var(--green); }
.tag.yellow { color: var(--yellow); border-color: var(--yellow); }
.tag.red { color: var(--red); border-color: var(--red); }
.flash { animation: flash 1.2s ease-out; }
@keyframes flash { from { background: rgba(61,139,253,.35); } to { background: transparent; } }

/* ---------- Direction de course ---------- */
.race-head { display: flex; gap: 20px; align-items: center; flex-wrap: wrap; }
.race-title { flex: 1 1 280px; }
.race-title h1 { margin: 0; font-size: 32px; }
.clock { text-align: center; min-width: 170px; }
.clock .big { font-family: var(--mono); font-size: 44px; font-weight: 500; line-height: 1; }
.clock .lbl { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .6px; }
.controls { display: flex; gap: 8px; flex-wrap: wrap; }
.status-badge { font-weight: 800; padding: 4px 10px; border-radius: 6px; font-size: 13px; text-transform: uppercase; letter-spacing: .5px; }
.st-prete { background: var(--panel2); color: var(--muted); }
.st-en_cours { background: var(--green); color: var(--sm-on-brand); }
.st-pause { background: var(--yellow); color: #111; }
.st-drapeau { background: repeating-conic-gradient(#fff 0 25%, #111 0 50%) 0 0/14px 14px; color: #111; text-shadow: 0 0 3px #fff, 0 0 3px #fff; }
.st-terminee { background: #444; color: #fff; }
.layout { display: grid; grid-template-columns: minmax(0, 1fr) 380px; gap: 16px; }
@media (max-width: 1100px) { .layout { grid-template-columns: 1fr; } }
.recent { max-height: 620px; overflow: auto; }
.recent td { padding: 6px; font-size: 13px; }
.empty { text-align: center; padding: 40px 10px; color: var(--muted); }
.seen { font-size: 12px; }

/* ---------- Fenêtre modale ---------- */
.modal-bg { position: fixed; inset: 0; background: rgba(0,0,0,.6); display: flex; align-items: flex-start; justify-content: center; padding: 40px 16px; z-index: 20; overflow: auto; }
.modal { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 18px; width: min(760px, 100%); }
.modal header { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.modal header h2 { margin: 0; font-size: 18px; flex: 1; }

.toast { position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%); background: var(--red); color: #fff; padding: 10px 18px; border-radius: 9px; z-index: 30; font-weight: 600; max-width: 90vw; }
.toast.info { background: var(--green); }

.entries td { padding: 6px 8px; }
.entries select { width: 100%; }
.entries tr.off td:not(:first-child) { opacity: .35; }

/* ---------- Écran pilotes ---------- */
body.screen { overflow: hidden; }
.scr { height: 100vh; display: flex; flex-direction: column; }
.scr-head { display: flex; align-items: center; gap: 2vw; padding: 1.2vh 2vw; background: #0a0d12; border-bottom: .4vh solid var(--line); }
.scr-head .t { flex: 1; min-width: 0; }
.scr-head .t .n { font-size: 3.4vh; font-weight: 800; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.scr-head .t .s { font-size: 2.2vh; color: var(--muted); }
.scr-clock { font-family: var(--mono); font-weight: 500; font-size: 7vh; line-height: 1; }
.scr-flag { font-size: 2.4vh; font-weight: 800; padding: .6vh 1.2vw; border-radius: .6vh; text-transform: uppercase; }
.scr-table { flex: 1; overflow: hidden; padding: 0 1vw; }
.scr-table table { height: 100%; }
.scr-table th { font-size: 1.9vh; padding: .8vh 1vw; }
.scr-table td { font-size: var(--fs, 4vh); padding: 0 1vw; border-bottom: .15vh solid var(--line); line-height: 1.15; }
.scr-table td .team { display: block; font-size: .5em; color: var(--muted); font-weight: 500; }
.scr-table td.pos { font-weight: 800; width: 1%; }
.scr-table td.name { font-weight: 700; max-width: 30vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.scr-table tr.fin td.pos::after { content: " 🏁"; font-size: .6em; }
.scr-foot { display: flex; justify-content: space-between; padding: .8vh 2vw; font-size: 2vh; color: var(--muted); background: #0a0d12; }
.fs-btn { position: fixed; right: 12px; bottom: 12px; opacity: .25; }
.fs-btn:hover { opacity: 1; }
.waiting { flex: 1; display: flex; align-items: center; justify-content: center; font-size: 4vh; color: var(--muted); text-align: center; }
