/* ==========================================================================
   Stake · Gros Parieurs — feuille de style unique
   Theme sombre, lisible de nuit, utilisable au telephone comme au bureau.
   Aucune dependance, aucune police distante : tout est local et statique.
   REGLE D'ACCESSIBILITE : la couleur ne porte JAMAIS seule une information.
   Chaque etat (palier de montant, resultat, consensus, connexion) a aussi
   un libelle ecrit ou une forme.
   ========================================================================== */

:root {
  --bg: #0b1117;
  --bg2: #111b24;
  --bg3: #0d1620;
  --bg4: #16222d;
  --line: #1e2c38;
  --line2: #2a3d4d;
  --txt: #e6edf3;
  --dim: #8b9aa8;
  --dim2: #64798a;
  --acc: #58a6ff;
  --acc2: #1f6feb;
  --ok: #2ea043;
  --ko: #f85149;
  --warn: #d29922;
  /* paliers de montant (bornes affichees dans la legende) */
  --p1: #5b6b7a;
  --p2: #2ea043;
  --p3: #d29922;
  --p4: #f85149;
  --p5: #a371f7;
  --rayon: 10px;
  --ombre: 0 8px 24px rgba(0, 0, 0, .45);
}

* { box-sizing: border-box; }

/* `hidden` doit gagner sur nos display:flex / display:grid : sans cette regle,
   un bloc masque en HTML reste visible des qu'il porte une classe de mise en page. */
[hidden] { display: none !important; }

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--txt);
  font: 14px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-text-size-adjust: 100%;
}

a { color: var(--acc); }

/* ---------------------------------------------------------------- entete */
header.top {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  background: var(--bg2);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 30;
  flex-wrap: wrap;
}
header.top h1 {
  font-size: 15px;
  margin: 0;
  font-weight: 600;
  white-space: nowrap;
}
header.top h1 small { color: var(--dim); font-weight: 400; font-size: 12px; }

nav.vues { display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none; }
nav.vues::-webkit-scrollbar { display: none; }
nav.vues button {
  background: transparent;
  border: 1px solid transparent;
  color: var(--dim);
  padding: 7px 13px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
}
nav.vues button:hover { color: var(--txt); background: var(--bg3); }
nav.vues button[aria-current="page"] {
  background: var(--bg4);
  color: var(--txt);
  border-color: var(--line2);
}

.etat-lien {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 12px;
  color: var(--dim);
  margin-left: auto;
  background: var(--bg3);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 5px 11px;
  cursor: help;
}
.voyant {
  width: 9px; height: 9px; border-radius: 50%;
  background: var(--dim); flex: 0 0 auto;
}
.etat-lien[data-etat="direct"] .voyant { background: var(--ok); animation: pulse 2s infinite; }
.etat-lien[data-etat="secours"] .voyant { background: var(--warn); }
.etat-lien[data-etat="pause"] .voyant { background: var(--dim); }
.etat-lien[data-etat="hors"] .voyant { background: var(--ko); }
/* Le voyant repondait a la question « le navigateur parle-t-il au service ? », et
   restait donc VERT pendant que le texte a cote annoncait « collecteur COOKIE_EXPIRE ».
   La question qui interesse l'utilisateur est « est-ce que ca collecte ? » : quand la
   reponse est non, le voyant passe a l'orange, meme si la liaison est parfaite. */
.etat-lien[data-collecte="ko"] .voyant { background: var(--warn); animation: none; }
@keyframes pulse { 0%, 100% { opacity: 1 } 50% { opacity: .25 } }

/* ------------------------------------------------------------ bandeau sante */
.bandeau {
  /* `wrap` : la ligne de disponibilite doit passer SOUS le message, pas se tasser
     dans une troisieme colonne de 20 caracteres a cote du formulaire de jeton. */
  display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-start;
  padding: 9px 16px;
  font-size: 13px;
  border-bottom: 1px solid var(--line);
  background: #2a1e12;
  color: #f0d9a8;
}
.bandeau.ko { background: #2a1416; color: #ffc7c2; }
.bandeau.ok { background: #10251a; color: #b7e3c3; }
.bandeau b { color: #fff; }
.bandeau .ferme { margin-left: auto; background: none; border: 0; color: inherit; cursor: pointer; font-size: 16px; }
/* Disponibilite reelle de la collecte : une ligne a part dans le bandeau, pour
   qu'elle reste lisible qu'elle accompagne une alerte ou qu'elle soit seule. */
.bandeau .dispo-ligne {
  flex-basis: 100%;
  margin-top: 6px; padding-top: 6px;
  border-top: 1px solid rgba(255, 255, 255, .12);
  line-height: 1.5;
}
.bandeau:not(.ko):not(.ok) .dispo-ligne { margin-top: 0; padding-top: 0; border-top: 0; }

/* ------------------------------------------------------------------- corps */
main { padding: 14px 16px 90px; max-width: 1340px; margin: 0 auto; }
section[hidden] { display: none !important; }

h2.titre {
  font-size: 12px; color: var(--dim); text-transform: uppercase;
  letter-spacing: .7px; margin: 22px 0 10px; font-weight: 600;
}
h2.titre:first-child { margin-top: 4px; }

/* --------------------------------------------------------------- controles */
/* Barres de filtres repliables : ouvertes sur ordinateur, fermees sur
   telephone (sinon six champs empiles poussent les paris hors de l'ecran). */
details.plis { margin-bottom: 12px; }
details.plis > summary {
  cursor: pointer; list-style: none;
  font-size: 12px; color: var(--dim); text-transform: uppercase; letter-spacing: .5px;
  padding: 8px 12px; background: var(--bg2); border: 1px solid var(--line);
  border-radius: var(--rayon); user-select: none;
}
details.plis > summary::-webkit-details-marker { display: none; }
details.plis > summary::before { content: "▸ "; }
details.plis[open] > summary::before { content: "▾ "; }
details.plis[open] > summary { border-radius: var(--rayon) var(--rayon) 0 0; border-bottom: 0; }
details.plis[open] > .barre { border-radius: 0 0 var(--rayon) var(--rayon); margin-bottom: 0; }

.barre {
  display: flex; gap: 8px; align-items: center; flex-wrap: wrap;
  margin-bottom: 12px;
  background: var(--bg2);
  border: 1px solid var(--line);
  border-radius: var(--rayon);
  padding: 10px 12px;
}
.champ { display: flex; flex-direction: column; gap: 3px; }
.champ label { font-size: 10px; color: var(--dim); text-transform: uppercase; letter-spacing: .5px; }
input, select {
  background: var(--bg3); border: 1px solid var(--line2); color: var(--txt);
  border-radius: 7px; padding: 7px 9px; font-size: 13px; min-width: 96px;
  font-family: inherit;
}
input:focus, select:focus, button:focus-visible {
  outline: 2px solid var(--acc); outline-offset: 1px;
}
input[type=search] { min-width: 190px; }
button.act {
  background: var(--acc2); border: 0; color: #fff; border-radius: 7px;
  padding: 8px 14px; font-size: 13px; font-weight: 600; cursor: pointer;
}
button.act:hover { background: #2b7cf3; }
button.gh {
  background: transparent; border: 1px solid var(--line2); color: var(--dim);
  border-radius: 7px; padding: 8px 12px; font-size: 13px; cursor: pointer;
}
button.gh:hover { color: var(--txt); border-color: var(--acc); }
button.gh[aria-pressed="true"] { color: var(--txt); border-color: var(--acc); background: var(--bg4); }

/* -------------------------------------------------------------------- KPIs */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(132px, 1fr)); gap: 9px; margin-bottom: 14px; }
.kpi { background: var(--bg2); border: 1px solid var(--line); border-radius: var(--rayon); padding: 11px 13px; }
.kpi b { display: block; font-size: 21px; font-variant-numeric: tabular-nums; line-height: 1.25; }
.kpi span { font-size: 10.5px; color: var(--dim); text-transform: uppercase; letter-spacing: .5px; }
.kpi.pos b { color: var(--ok); }
.kpi.neg b { color: var(--ko); }

/* ------------------------------------------------------------ liste de paris */
.liste { display: flex; flex-direction: column; gap: 6px; }

.pari {
  display: grid;
  grid-template-columns: 26px 1fr 78px 118px 72px;
  gap: 12px; align-items: center;
  background: var(--bg2);
  border: 1px solid var(--line);
  border-left: 4px solid var(--p1);
  border-radius: 9px;
  padding: 9px 12px;
  cursor: pointer;
  text-align: left;
  width: 100%;
  font: inherit;
  color: inherit;
}
.pari:hover { border-color: var(--line2); background: var(--bg4); }
.pari:focus-visible { outline: 2px solid var(--acc); outline-offset: 1px; }
.pari.p2 { border-left-color: var(--p2); }
.pari.p3 { border-left-color: var(--p3); }
.pari.p4 { border-left-color: var(--p4); background: #191215; }
.pari.p5 { border-left-color: var(--p5); background: #161126; }

/* Les cellules sont des <span> (un <button> ne peut pas contenir de <div>) :
   il faut donc leur rendre explicitement un comportement de bloc, sinon la
   ligne s'ecrase sur une seule ligne de texte et double de hauteur. */
.pari > span { display: block; min-width: 0; }
.pari .sp { font-size: 18px; text-align: center; }
.pari .ev { min-width: 0; }
.pari .ev .t, .pari .ev .s { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
/* Le NOM du match est tronque, jamais les etiquettes : sur un ecran de 375 px,
   un « GAGNE » ou un « COMBINE 7 » sortait du cadre et devenait invisible. */
.pari .ev .t { font-weight: 600; display: flex; align-items: center; gap: 0; }
.pari .ev .t .nom-ev { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.pari .ev .t .tag { flex: 0 0 auto; }
.pari .ev .s { font-size: 12px; color: var(--dim); }
.pari .num { text-align: right; font-variant-numeric: tabular-nums; }
.pari .num b { display: block; font-size: 15px; }
.pari .num s { display: block; font-size: 11px; color: var(--dim); text-decoration: none; }
.pari .cote b { color: #79c0ff; font-size: 16px; }
.pari.p4 .mise b, .pari.p5 .mise b { font-size: 17px; }
.pari .quand { font-size: 12px; color: var(--dim); font-variant-numeric: tabular-nums; text-align: right; }

/* arrivee d'un nouveau pari : glissement court puis halo qui s'estompe */
@keyframes entree { from { opacity: 0; transform: translateY(-10px); } to { opacity: 1; transform: none; } }
@keyframes halo {
  0% { box-shadow: 0 0 0 2px rgba(88, 166, 255, .55); }
  100% { box-shadow: 0 0 0 0 rgba(88, 166, 255, 0); }
}
.pari.neuf { animation: entree .35s ease, halo 6s ease-out forwards; }
@keyframes flash { 0% { background: #1b2b1f; } 100% { background: var(--bg2); } }
.pari.maj { animation: flash 1.4s ease-out; }
@media (prefers-reduced-motion: reduce) {
  .pari.neuf, .pari.maj { animation: none; }
  .voyant { animation: none !important; }
}

/* etiquettes */
.tag {
  display: inline-block; background: #1f2d3d; color: #79c0ff;
  font-size: 10px; padding: 1px 6px; border-radius: 4px; margin-left: 6px;
  vertical-align: 1px; font-weight: 600; letter-spacing: .3px;
}
.tag.w { background: #10331d; color: #56d364; }
.tag.l { background: #32171a; color: #f85149; }
.tag.c { background: #2b2517; color: #e3b341; }
.tag.live { background: #3a1420; color: #ff7b93; }
.tag.neuf { background: #16304a; color: #9ecbff; }
.tag.gris { background: #1c2833; color: var(--dim); }

/* Bouton flottant « N nouveaux paris ».
   Il est en `fixed` et non dans le flux : apparu au milieu de la liste, il
   decalait le contenu de 38 px et faisait bouger ce que l'utilisateur lisait. */
.rappel {
  position: fixed; top: 74px; left: 50%; transform: translateX(-50%); z-index: 25;
  display: flex; justify-content: center; pointer-events: none;
}
.rappel button { pointer-events: auto; }
.rappel button {
  background: var(--acc2); color: #fff; border: 0; border-radius: 999px;
  padding: 8px 16px; font-size: 13px; font-weight: 600; cursor: pointer;
  box-shadow: var(--ombre);
}

/* ------------------------------------------------------- cartes de matchs */
.grille { display: grid; grid-template-columns: repeat(auto-fill, minmax(330px, 1fr)); gap: 11px; }

.match {
  background: var(--bg2); border: 1px solid var(--line); border-radius: 12px;
  padding: 12px 13px; cursor: pointer; text-align: left; color: inherit;
  font: inherit; display: flex; flex-direction: column; gap: 9px;
}
.match:hover { border-color: var(--line2); background: var(--bg4); }
.match:focus-visible { outline: 2px solid var(--acc); outline-offset: 1px; }
.match .haut { display: flex; gap: 9px; align-items: flex-start; }
.match .rang {
  font-size: 12px; color: var(--dim); font-weight: 700; min-width: 24px;
  font-variant-numeric: tabular-nums; padding-top: 2px;
}
.match .nom { font-weight: 600; font-size: 14.5px; line-height: 1.3; }
.match .meta { font-size: 11.5px; color: var(--dim); margin-top: 2px; }
.match .chaleur { margin-left: auto; text-align: right; flex: 0 0 auto; }
.match .chaleur b { font-size: 17px; font-variant-numeric: tabular-nums; }
.match .chaleur span { display: block; font-size: 10px; color: var(--dim); text-transform: uppercase; letter-spacing: .4px; }

.jauge { height: 4px; background: var(--bg3); border-radius: 3px; overflow: hidden; }
.jauge i { display: block; height: 100%; background: linear-gradient(90deg, #d29922, #f85149); }

.chiffres { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.chiffres div { background: var(--bg3); border-radius: 7px; padding: 6px 7px; }
.chiffres b { display: block; font-size: 14px; font-variant-numeric: tabular-nums; }
.chiffres span { font-size: 9.5px; color: var(--dim); text-transform: uppercase; letter-spacing: .4px; }

/* barre de consensus : segments + libelles ecrits (jamais la couleur seule) */
.consensus { display: flex; flex-direction: column; gap: 5px; }
.barre-cons { display: flex; height: 9px; border-radius: 5px; overflow: hidden; background: var(--bg3); }
.barre-cons i { display: block; height: 100%; }
.barre-cons i:nth-child(1) { background: #58a6ff; }
.barre-cons i:nth-child(2) { background: #3fb950; }
.barre-cons i:nth-child(3) { background: #d29922; }
.barre-cons i:nth-child(4) { background: #a371f7; }
.barre-cons i:nth-child(5) { background: #4b5b6b; }
.legende-cons { display: flex; flex-wrap: wrap; gap: 4px 10px; font-size: 11px; color: var(--dim); }
.legende-cons span::before {
  content: ""; display: inline-block; width: 8px; height: 8px; border-radius: 2px;
  margin-right: 5px; background: currentColor; vertical-align: 0;
}
.legende-cons span:nth-child(1) { color: #79c0ff; }
.legende-cons span:nth-child(2) { color: #56d364; }
.legende-cons span:nth-child(3) { color: #e3b341; }
.legende-cons span:nth-child(4) { color: #c297ff; }
.legende-cons b { color: var(--txt); }

.verdict {
  font-size: 12.5px; color: var(--txt); background: var(--bg3);
  border-left: 3px solid var(--acc); border-radius: 0 7px 7px 0; padding: 7px 10px;
}
.verdict.fort { border-left-color: var(--p3); }

/* ------------------------------------------------------------------ tables */
table { width: 100%; border-collapse: collapse; background: var(--bg2); border: 1px solid var(--line); border-radius: var(--rayon); overflow: hidden; font-size: 13px; }
th, td { padding: 8px 11px; text-align: right; border-bottom: 1px solid var(--line); }
th { background: var(--bg3); color: var(--dim); font-size: 10.5px; text-transform: uppercase; letter-spacing: .5px; font-weight: 600; }
th:first-child, td:first-child { text-align: left; }
tr:last-child td { border-bottom: 0; }
td.pos, .pos { color: var(--ok); }
td.neg, .neg { color: var(--ko); }
.tab-enveloppe { overflow-x: auto; }

/* ------------------------------------------------------------------- notes */
.note {
  background: var(--bg2); border: 1px solid var(--line); border-left: 3px solid var(--acc);
  border-radius: 8px; padding: 11px 14px; margin-bottom: 12px; font-size: 13px; color: var(--dim);
}
.note b { color: var(--txt); }
.note.warn { border-left-color: var(--warn); }
.note.ko { border-left-color: var(--ko); }

.vide { padding: 34px 18px; text-align: center; color: var(--dim); background: var(--bg2); border: 1px dashed var(--line2); border-radius: var(--rayon); }
.vide b { display: block; color: var(--txt); margin-bottom: 5px; font-size: 15px; }

/* squelettes de chargement */
.squelette { display: flex; flex-direction: column; gap: 6px; }
.squelette i {
  display: block; height: 46px; border-radius: 9px;
  background: linear-gradient(90deg, var(--bg2) 25%, var(--bg4) 50%, var(--bg2) 75%);
  background-size: 400% 100%; animation: glisse 1.3s infinite;
}
@keyframes glisse { from { background-position: 100% 0 } to { background-position: 0 0 } }

/* ------------------------------------------------------- panneau de detail */
.voile {
  position: fixed; inset: 0; background: rgba(2, 6, 10, .62);
  opacity: 0; pointer-events: none; transition: opacity .18s; z-index: 40;
}
.voile.on { opacity: 1; pointer-events: auto; }
aside.panneau {
  position: fixed; top: 0; right: 0; height: 100%; width: min(520px, 100%);
  background: var(--bg2); border-left: 1px solid var(--line2);
  transform: translateX(102%); transition: transform .22s ease; z-index: 41;
  display: flex; flex-direction: column; box-shadow: var(--ombre);
}
aside.panneau.on { transform: none; }
/* Pendant qu'un detail est ouvert, le fond ne doit pas defiler sous le doigt. */
html.fige, html.fige body { overflow: hidden; }
aside.panneau header {
  display: flex; align-items: center; gap: 10px; padding: 13px 16px;
  border-bottom: 1px solid var(--line); background: var(--bg3);
}
aside.panneau header h3 { margin: 0; font-size: 14px; flex: 1; }
aside.panneau .corps { overflow-y: auto; padding: 14px 16px 30px; }
.fermer { background: none; border: 1px solid var(--line2); color: var(--dim); border-radius: 7px; padding: 5px 10px; cursor: pointer; font-size: 13px; }
.fermer:hover { color: var(--txt); }

.bloc { background: var(--bg3); border: 1px solid var(--line); border-radius: 9px; padding: 11px 12px; margin-bottom: 10px; }
.bloc h4 { margin: 0 0 8px; font-size: 11px; color: var(--dim); text-transform: uppercase; letter-spacing: .6px; }
.paires { display: grid; grid-template-columns: auto 1fr; gap: 5px 12px; font-size: 13px; }
.paires dt { color: var(--dim); }
.paires dd { margin: 0; text-align: right; font-variant-numeric: tabular-nums; }

.selection {
  display: grid; grid-template-columns: 1fr auto; gap: 3px 10px;
  padding: 9px 0; border-bottom: 1px solid var(--line);
}
.selection:last-child { border-bottom: 0; }
.selection .m { font-weight: 600; font-size: 13px; }
.selection .c { font-size: 12px; color: var(--dim); }
.selection .o { font-variant-numeric: tabular-nums; color: #79c0ff; font-weight: 600; grid-row: span 2; align-self: center; }

.calcul { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 12px; color: var(--dim); word-break: break-word; }
.calcul b { color: var(--txt); }

/* ------------------------------------------------------------- graphiques */
svg.graphe { width: 100%; height: 160px; background: var(--bg2); border: 1px solid var(--line); border-radius: var(--rayon); display: block; }

/* ------------------------------------------------------------------ toasts */
#toasts { position: fixed; bottom: 16px; left: 50%; transform: translateX(-50%); z-index: 60; display: flex; flex-direction: column; gap: 7px; align-items: center; }
.toast { background: var(--bg4); border: 1px solid var(--line2); color: var(--txt); border-radius: 8px; padding: 9px 15px; font-size: 13px; box-shadow: var(--ombre); }

/* ----------------------------------------------------------------- mobile */
@media (max-width: 860px) {
  main { padding: 12px 11px 96px; }
  header.top { padding: 9px 11px; gap: 9px; }
  header.top h1 { font-size: 14px; }
  .pari { grid-template-columns: 22px 1fr auto; gap: 9px; padding: 9px 10px; }
  .pari .cote { display: none; }
  .pari .quand { grid-column: 2 / 4; text-align: left; font-size: 11px; margin-top: -2px; }
  .grille { grid-template-columns: 1fr; }
  .kpis { grid-template-columns: repeat(3, 1fr); gap: 6px; }
  .kpi { padding: 8px 9px; }
  .kpi b { font-size: 16px; }
  .kpi span { font-size: 9px; letter-spacing: .3px; }
  .barre { padding: 9px 10px; }
  input, select { min-width: 84px; }
  input[type=search] { min-width: 140px; flex: 1; }
  .chiffres { grid-template-columns: repeat(2, 1fr); }
  aside.panneau { width: 100%; }
  .etat-lien { order: 3; margin-left: auto; }
  nav.vues { order: 4; width: 100%; }
}

/* barre de navigation basse, uniquement sur petit ecran tactile */
@media (max-width: 560px) {
  nav.vues {
    position: fixed; bottom: 0; left: 0; right: 0; z-index: 35;
    background: var(--bg2); border-top: 1px solid var(--line);
    padding: 5px 6px; gap: 2px; justify-content: space-between;
  }
  nav.vues button { flex: 1; padding: 8px 4px; font-size: 11px; text-align: center; border-radius: 7px; }
  main { padding-bottom: 76px; }
}

/* --- Installation d'un jeton depuis le bandeau d'alerte --- */
.jeton { display: block; margin-top: 10px; }
.jeton label { display: block; font-size: 12px; color: var(--dim, #8b9aa8); margin-bottom: 6px; }
.jeton-ligne { display: flex; gap: 8px; flex-wrap: wrap; }
.jeton input {
  flex: 1 1 320px; min-width: 200px; background: #0d1620;
  border: 1px solid var(--line, #1e2c38); color: var(--txt, #e6edf3);
  border-radius: 6px; padding: 7px 10px; font-size: 13px; font-family: inherit;
}
.jeton small { display: block; margin-top: 6px; font-size: 11px; color: var(--dim, #8b9aa8); }
.jeton code { background: rgba(255,255,255,.06); padding: 1px 4px; border-radius: 3px; }
