/* Abandons — charte Sierre-Zinal : noir, anthracite, or #FBBD3C, croix suisse rouge, Montserrat en capitales grasses.
   Clair par défaut comme le site de la course, sombre selon le réglage du téléphone. */
:root {
  --bg: #f2f2f2; --surface: #ffffff; --surface-2: #f8f8f8; --line: #e2e2e2;
  --tx: #2b2b2b; --tx2: #707070; --head: #000000; --head-tx: #ffffff;
  --gold: #fbbd3c; --gold-ink: #141414; --gold-soft: #fff3d6; --gold-tx: #9a6a00;
  --red: #da291c; --ok: #1e9e57; --ok-bg: #12804a; --warn: #fbbd3c; --warn-bg: #fbbd3c; --bad: #da291c; --bad-bg: #c0231a;
  --ok-soft: #e1f5ea; --bad-soft: #fde4e2; --scrim: rgba(0,0,0,.55); --shadow: 0 1px 3px rgba(0,0,0,.08);
  --font: "Montserrat", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --r: 6px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) {
  --bg: #111111; --surface: #1c1c1c; --surface-2: #242424; --line: #333333;
  --tx: #f1f1f1; --tx2: #a3a3a3; --gold-soft: #3a2e12; --gold-tx: #fbbd3c;
  --ok-soft: #133524; --bad-soft: #3d1612; --shadow: none; color-scheme: dark; } }
:root[data-theme="dark"] {
  --bg: #111111; --surface: #1c1c1c; --surface-2: #242424; --line: #333333;
  --tx: #f1f1f1; --tx2: #a3a3a3; --gold-soft: #3a2e12; --gold-tx: #fbbd3c;
  --ok-soft: #133524; --bad-soft: #3d1612; --shadow: none; color-scheme: dark; }

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--tx); font: 500 16px/1.45 var(--font); }
body { min-height: 100vh; min-height: 100dvh; padding-bottom: env(safe-area-inset-bottom); }
body::before { content: ""; position: fixed; inset: 0 0 auto; height: env(safe-area-inset-top, 0px); background: var(--head); z-index: 20; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: 1px solid var(--line); border-radius: var(--r); background: var(--surface); padding: 12px 16px; font-weight: 700; }
button:active { transform: scale(.98); }
button.primary { background: var(--gold); border-color: var(--gold); color: var(--gold-ink); text-transform: uppercase; letter-spacing: .04em; font-weight: 800; }
button.big { width: 100%; padding: 17px; font-size: 1.05rem; }
button.ghost { background: transparent; }
button.danger { background: var(--bad-bg); border-color: var(--bad-bg); color: #fff; }
button.small { padding: 6px 10px; font-size: .8rem; }
button:disabled { opacity: .5; }
:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }
input, select, textarea { width: 100%; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 12px 14px; }
input:focus, textarea:focus, select:focus { outline: 2px solid var(--gold); border-color: transparent; }
label { display: block; color: var(--tx2); font-size: .78rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; margin: 14px 0 6px; }
h1, h2 { font-weight: 800; text-transform: uppercase; letter-spacing: .02em; line-height: 1.15; }
h1 { font-size: 1.4rem; margin: 0 0 6px; }
h2 { font-size: 1rem; margin: 18px 0 8px; }
p { margin: 6px 0; }
.muted { color: var(--tx2); }
.wrap { max-width: 560px; margin: 0 auto; padding: 14px 16px 40px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 14px; margin: 10px 0; box-shadow: var(--shadow); }
.row { display: flex; gap: 10px; align-items: center; }
.row > * { flex: 1; }
.hidden { display: none !important; }
.err { color: var(--bad); font-weight: 600; margin-top: 8px; min-height: 1.2em; }

/* ---- Signature Sierre-Zinal (texte + trait doré + croix suisse) ---- */
.brand { display: inline-flex; align-items: center; gap: 4px; color: #fff; font-weight: 800; letter-spacing: .06em; font-size: .95rem; line-height: 1; white-space: nowrap; }
.brand .trail { width: 30px; height: 14px; fill: none; stroke: var(--gold); stroke-width: 2.4; stroke-linejoin: round; stroke-linecap: round; }
.brand .cross { width: 12px; height: 12px; margin-left: 4px; background: var(--red); position: relative; flex: none; }
.brand .cross::before, .brand .cross::after { content: ""; position: absolute; background: #fff; }
.brand .cross::before { left: 5px; top: 2px; width: 2px; height: 8px; }
.brand .cross::after { top: 5px; left: 2px; width: 8px; height: 2px; }
.tagline { color: var(--gold); font-size: .62rem; font-weight: 700; letter-spacing: .14em; text-transform: uppercase; margin-top: 4px; }
.ridge { display: block; width: 100%; height: 26px; }
.ridge path { fill: var(--bg); }

/* ---- Bandeau noir ---- */
.top { background: var(--head); color: var(--head-tx); position: sticky; top: 0; z-index: 5; padding: calc(10px + env(safe-area-inset-top, 0px)) 16px 0; }
.top .bar { display: flex; align-items: center; gap: 10px; }
.top .bar .brand { flex: 1; }
.top .sub { display: flex; align-items: flex-end; gap: 10px; padding: 10px 0 12px; }
.top .t { flex: 1; min-width: 0; }
.top .poste { font-weight: 800; font-size: 1.3rem; line-height: 1.15; text-transform: uppercase; color: var(--gold); letter-spacing: .02em; overflow-wrap: anywhere; }
.top .row2 { display: flex; align-items: center; gap: 10px; margin-top: 6px; }
.top .race { flex: 1; min-width: 0; font-size: .78rem; color: #bdbdbd; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bi { width: 20px; height: 20px; fill: none; stroke: var(--gold-tx); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; vertical-align: -4px; margin-right: 8px; flex: none; }
.actions button { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; }
.actions button .bi { width: 26px; height: 26px; margin: 0; }
.actions button.wide { grid-column: 1 / -1; flex-direction: row; gap: 10px; }
.proof > button { display: flex; align-items: center; justify-content: center; }
.menu-btn { background: transparent; border: 0; color: #fff; padding: 4px 8px; font-size: 1.4rem; line-height: 1; }
.pill { border-radius: 999px; padding: 6px 12px; font-size: .78rem; font-weight: 800; white-space: nowrap; text-transform: uppercase; letter-spacing: .03em; }
.pill.ok { background: var(--ok); color: #fff; }
.pill.wait { background: var(--gold); color: var(--gold-ink); }
.pill.off { background: var(--red); color: #fff; }

/* ---- Accueil (configuration du poste) ---- */
.hero { background: var(--head); color: #fff; padding: calc(28px + env(safe-area-inset-top, 0px)) 16px 0; text-align: center; }
.hero .brand { font-size: 1.35rem; }
.hero .brand .trail { width: 44px; height: 20px; }
.hero .brand .cross { width: 16px; height: 16px; }
.hero .brand .cross::before { left: 6.5px; top: 3px; width: 3px; height: 10px; }
.hero .brand .cross::after { top: 6.5px; left: 3px; width: 10px; height: 3px; }
.hero h1 { color: #fff; margin: 18px 0 4px; font-size: 1.15rem; }
.hero .tagline { font-size: .7rem; }

/* ---- Caméra ---- */
.cam { position: relative; background: #000; border-radius: var(--r); overflow: hidden; aspect-ratio: 4 / 3; margin-top: 12px; }
.cam video { width: 100%; height: 100%; object-fit: cover; display: block; }
.cam .frame { position: absolute; inset: 14% 18%; pointer-events: none; transition: inset .14s;
  background: linear-gradient(var(--fc), var(--fc)) 0 0 / 30px 5px no-repeat, linear-gradient(var(--fc), var(--fc)) 0 0 / 5px 30px no-repeat,
    linear-gradient(var(--fc), var(--fc)) 100% 0 / 30px 5px no-repeat, linear-gradient(var(--fc), var(--fc)) 100% 0 / 5px 30px no-repeat,
    linear-gradient(var(--fc), var(--fc)) 0 100% / 30px 5px no-repeat, linear-gradient(var(--fc), var(--fc)) 0 100% / 5px 30px no-repeat,
    linear-gradient(var(--fc), var(--fc)) 100% 100% / 30px 5px no-repeat, linear-gradient(var(--fc), var(--fc)) 100% 100% / 5px 30px no-repeat; }
.cam .hint { position: absolute; left: 0; right: 0; bottom: 8px; text-align: center; font-size: .78rem; font-weight: 700; color: #fff; text-shadow: 0 1px 3px #000; }
.cam .start { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; background: #1a1a1a; border: 0; border-radius: 0; color: #fff; font-size: 1.05rem; font-weight: 800; text-transform: uppercase; letter-spacing: .05em; width: 100%; }
.cam .start .ico { width: 74px; height: 74px; border-radius: 50%; background: var(--gold); color: var(--gold-ink); display: flex; align-items: center; justify-content: center; font-size: 2rem; }
.cam .live { position: absolute; top: 10px; left: 10px; background: var(--red); color: #fff; font-size: .72rem; font-weight: 800; text-transform: uppercase; letter-spacing: .05em; padding: 5px 10px; border-radius: 999px; animation: blink 1.6s infinite; }
@keyframes blink { 50% { opacity: .55; } }
/* Résultat d'un scan autour du viseur : cadre épais, coins et bandeau de la couleur du résultat. */
.cam { --fc: var(--gold); }
.cam::after { content: ""; position: absolute; inset: 0; z-index: 3; pointer-events: none; border-radius: inherit; box-shadow: inset 0 0 0 0 transparent; transition: box-shadow .12s; }
.cam.fb-ok { --fc: var(--ok); } .cam.fb-warn { --fc: var(--gold); } .cam.fb-bad { --fc: var(--red); }
.cam.fb-ok::after, .cam.fb-warn::after, .cam.fb-bad::after { box-shadow: inset 0 0 0 12px var(--fc); }
.cam.fb-ok .frame, .cam.fb-warn .frame, .cam.fb-bad .frame { inset: 12% 16%; }
.cam .fb { position: absolute; z-index: 4; left: 12px; right: 12px; bottom: 12px; display: flex; align-items: center; justify-content: center; gap: 12px; padding: 8px 12px; border-radius: 4px;
  background: var(--fc); color: #fff; transform: translateY(140%); opacity: 0; transition: transform .14s ease-out, opacity .14s; pointer-events: none; }
.cam.fb-ok .fb, .cam.fb-warn .fb, .cam.fb-bad .fb { transform: none; opacity: 1; }
.cam.fb-warn .fb { color: var(--gold-ink); }
.cam .fb-n { font-size: 2.3rem; font-weight: 800; line-height: 1; font-variant-numeric: tabular-nums; }
.cam .fb-m { font-size: .8rem; font-weight: 800; text-transform: uppercase; letter-spacing: .04em; text-align: left; line-height: 1.25; }
.cam.fb-ok .hint, .cam.fb-warn .hint, .cam.fb-bad .hint { opacity: 0; }
.actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 10px; }
.actions button { padding: 15px 8px; font-size: .9rem; }
.count { text-align: center; margin: 18px 0 6px; color: var(--tx2); font-size: .78rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; }
.count b { color: var(--tx); font-size: 2.2rem; font-weight: 800; display: block; letter-spacing: 0; line-height: 1.1; }

.list { margin-top: 6px; }
.item { display: flex; align-items: center; gap: 12px; padding: 11px 12px; border-bottom: 1px solid var(--line); }
.item:last-child { border-bottom: 0; }
.item .bib { font-size: 1.45rem; font-weight: 800; min-width: 74px; font-variant-numeric: tabular-nums; border-left: 4px solid var(--gold); padding-left: 10px; }
.item .meta { flex: 1; min-width: 0; font-size: .8rem; color: var(--tx2); }
.item .meta .nom { color: var(--tx); font-size: .95rem; font-weight: 700; }
.item .meta .other { color: var(--gold-tx); font-weight: 700; }
.item.void .bib { text-decoration: line-through; color: var(--tx2); border-left-color: var(--line); }

/* ---- Écran de confirmation ---- */
.flash { position: fixed; inset: 0; z-index: 50; display: flex; flex-direction: column; align-items: center; justify-content: center; color: #fff; pointer-events: none; opacity: 0; transition: opacity .12s; }
.flash.on { opacity: 1; }
.flash.ok { background: var(--ok-bg); }
.flash.warn { background: var(--warn-bg); color: var(--gold-ink); }
.flash.bad { background: var(--bad-bg); }
.flash .n { font-size: 26vw; font-weight: 800; line-height: 1; font-variant-numeric: tabular-nums; }
.flash .m { font-size: 1.2rem; font-weight: 800; margin-top: 12px; text-align: center; padding: 0 20px; text-transform: uppercase; letter-spacing: .04em; }
@media (min-width: 600px) { .flash .n { font-size: 160px; } }

.banner { margin: 10px 0 0; padding: 10px 12px; border-radius: var(--r); background: var(--bad-bg); color: #fff; font-weight: 700; }
.banner.warn { background: var(--gold); color: var(--gold-ink); }

#scrim { position: fixed; inset: 0; background: var(--scrim); z-index: 30; }
.sheet { position: fixed; left: 0; right: 0; bottom: 0; z-index: 31; background: var(--surface); border-top: 4px solid var(--gold); border-radius: 14px 14px 0 0; padding: 18px 16px calc(18px + env(safe-area-inset-bottom)); max-height: 90vh; overflow: auto; max-width: 560px; margin: 0 auto; }
.sheet h2 { margin-top: 0; font-size: 1.05rem; }
.keyin { font-size: 2.6rem; text-align: center; font-weight: 800; letter-spacing: 3px; padding: 14px; border: 2px solid var(--tx); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 10px 0; }
.chip { padding: 8px 12px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--line); font-weight: 800; font-variant-numeric: tabular-nums; }
.chip.off { opacity: .4; text-decoration: line-through; }
.chip.on { background: var(--gold); border-color: var(--gold); color: var(--gold-ink); }
/* Carte de confirmation d'un numéro (clavier, lecture du dossard) */
.bibcard { display: flex; align-items: center; gap: 14px; width: 100%; text-align: left; margin: 10px 0; padding: 12px 14px; border-radius: var(--r);
  border: 2px solid var(--line); border-left-width: 10px; background: var(--surface-2); color: var(--tx); font-weight: 600; }
.bibcard .bc-n { font-size: 2.2rem; font-weight: 800; line-height: 1; font-variant-numeric: tabular-nums; }
.bibcard .bc-t { display: flex; flex-direction: column; min-width: 0; }
.bibcard .bc-nom { font-size: 1.05rem; font-weight: 800; }
.bibcard .bc-m { font-size: .8rem; color: var(--tx2); }
.bibcard.ok { border-color: var(--ok); background: var(--ok-soft); }
.bibcard.warn { border-color: var(--gold); background: var(--gold-soft); }
.bibcard.bad { border-color: var(--red); background: var(--bad-soft); }
.bibcard.ok .bc-m { color: var(--ok); } .bibcard.bad .bc-m { color: var(--bad); } .bibcard.warn .bc-m { color: var(--gold-tx); }
button.bibcard { cursor: pointer; }
/* Carte du dossard reconnu, en haut du viseur : un appui confirme. */
.cam .ocrcard { position: absolute; z-index: 5; left: 10px; right: 10px; top: 10px; }
.cam .ocrcard:empty { display: none; }
.cam .ocrcard .bibcard { margin: 0; box-shadow: 0 4px 16px rgba(0,0,0,.35); animation: pop .16s ease-out; }
.cam .ocrcard .oc-h { margin-top: 6px; text-align: center; font-size: .75rem; font-weight: 700; color: #fff; text-shadow: 0 1px 3px #000; }
.cam .ocrcard .oc-h a { color: var(--gold); }
@keyframes pop { from { transform: scale(.94); opacity: 0; } }
.who { min-height: 1.5em; text-align: center; font-weight: 800; margin: 8px 0; }
.who.ok { color: var(--ok); }
.who.warn { color: var(--gold-tx); }
.proof { margin: 8px 0; display: flex; gap: 10px; align-items: center; }
.proof > button { width: 100%; }
.proof img { width: 96px; height: 72px; object-fit: cover; border-radius: var(--r); }
canvas.shot { width: 100%; height: auto; border-radius: var(--r); display: block; margin: 8px 0; cursor: pointer; }

/* ---- Tableau de l'organisation ---- */
.admin .wrap { max-width: 1140px; }
.admin .top { padding-bottom: 0; }
.admin .top .sub { padding: 14px 0 0; flex-wrap: wrap; }
.admin .top h1 { color: #fff; margin: 0; font-size: 1.3rem; }
.tabs { display: flex; gap: 2px; overflow-x: auto; margin-top: 12px; }
.tabs button { background: transparent; border: 0; border-bottom: 3px solid transparent; border-radius: 0; color: #bdbdbd; text-transform: uppercase; letter-spacing: .05em; font-size: .82rem; padding: 12px 14px; white-space: nowrap; }
.tabs button.on { color: #fff; border-bottom-color: var(--gold); }
.stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 10px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-top: 4px solid var(--line); border-radius: var(--r); padding: 12px; text-align: left; font-weight: 600; font-size: .8rem; color: var(--tx2); text-transform: uppercase; letter-spacing: .03em; }
.stat b { display: block; font-size: 1.9rem; font-weight: 800; color: var(--tx); font-variant-numeric: tabular-nums; letter-spacing: 0; }
.stat.on { border-top-color: var(--gold); background: var(--gold-soft); }
.stat.total { background: var(--head); color: #bdbdbd; border-color: var(--head); border-top-color: var(--gold); }
.stat.total b { color: var(--gold); }
.tablewrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); }
table { width: 100%; border-collapse: collapse; font-size: .92rem; }
th, td { text-align: left; padding: 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--tx2); font-weight: 800; font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; position: sticky; top: 0; background: var(--surface-2); }
td.b { font-weight: 800; font-size: 1.15rem; font-variant-numeric: tabular-nums; }
tr.void td { color: var(--tx2); text-decoration: line-through; }
tr.new td { background: var(--ok-soft); }
tr.new td.b { box-shadow: inset 4px 0 0 var(--ok); }
.tag { display: inline-block; font-size: .7rem; font-weight: 700; padding: 2px 8px; border-radius: 999px; background: var(--gold-soft); color: var(--gold-tx); margin: 2px 0; }
.postes { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.poste-card { border-top: 4px solid var(--gold); }
.poste-card h2 { font-size: 1.05rem; }
.poste-card .qr svg { width: 100%; height: auto; background: #fff; border-radius: var(--r); display: block; }
.poste-card .link { font-size: .72rem; color: var(--tx2); word-break: break-all; margin: 6px 0; }
.btns { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 14px 0; }
.toolbar input { flex: 1; min-width: 160px; width: auto; }
.toolbar input[type=checkbox] { flex: none; min-width: 0; width: auto; accent-color: var(--gold); }
.toolbar label { margin: 0; display: flex; gap: 6px; align-items: center; text-transform: none; letter-spacing: 0; font-size: .88rem; }
.upd { font-size: .75rem; color: #bdbdbd; }
.login { max-width: 420px; }

@media print {
  body { background: #fff; color: #000; }
  body::before { display: none; }
  .noprint { display: none !important; }
  .print-sheet { display: block !important; }
  .print-poste { page-break-inside: avoid; text-align: center; padding: 20px 0 40px; border-bottom: 1px dashed #999; }
  .print-poste svg { width: 9cm; height: 9cm; }
  .print-poste h2 { font-size: 22pt; margin: 0 0 6px; }
}
.print-sheet { display: none; }
