:root {
  --bg: #f4f7f5;
  --surface: #ffffff;
  --surface-2: #eaf0ec;
  --text: #14211a;
  --muted: #5b6b62;
  --border: #d6e0da;
  --accent: #15803d;
  --accent-text: #ffffff;
  --accent-soft: #dcfce7;
  --warn-bg: #fef3c7;
  --warn-text: #7c4a03;
  --bad: #b91c1c;
  --bad-soft: #fee2e2;
  --good: #15803d;
  --info-bg: #e0f2fe;
  --info-text: #0c4a6e;
  --c1: #16a34a;
  --cN: #d97706;
  --c2: #2563eb;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.06);
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0c1511;
    --surface: #14211a;
    --surface-2: #1c2d24;
    --text: #e8f1ec;
    --muted: #9db0a5;
    --border: #274034;
    --accent: #4ade80;
    --accent-text: #052e16;
    --accent-soft: #123b24;
    --warn-bg: #3b2a08;
    --warn-text: #fcd34d;
    --bad: #f87171;
    --bad-soft: #3f1515;
    --good: #4ade80;
    --info-bg: #0b2a3d;
    --info-text: #7dd3fc;
    --c1: #4ade80;
    --cN: #fbbf24;
    --c2: #60a5fa;
    --shadow: none;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.45 system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  padding-bottom: env(safe-area-inset-bottom);
}
h1, h2, h3 { line-height: 1.2; margin: 0 0 8px; }
h1 { font-size: 1.6rem; }
h2 { font-size: 1.05rem; }
h3 { font-size: 0.95rem; margin-top: 10px; }
p { margin: 0 0 8px; }
a { color: var(--accent); }
.muted { color: var(--muted); }
.small { font-size: 0.82rem; }
.big { font-size: 1.1rem; }
.capital::first-letter { text-transform: uppercase; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.noscript { padding: 16px; }

/* Barre du haut et navigation */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 10px;
  padding: calc(8px + env(safe-area-inset-top)) 16px 8px;
  background: #0f2a1d; color: #fff;
}
.topbar .brand { font-weight: 700; letter-spacing: 0.2px; }
.spacer { flex: 1; }
.icon-btn { background: transparent; color: #fff; border: 1px solid rgba(255, 255, 255, 0.3); border-radius: 10px; width: 40px; height: 40px; font-size: 1.2rem; cursor: pointer; }
.topnav {
  position: sticky; top: calc(56px + env(safe-area-inset-top)); z-index: 19;
  display: flex; gap: 8px; overflow-x: auto; white-space: nowrap;
  padding: 8px 16px; background: var(--bg); border-bottom: 1px solid var(--border);
  scrollbar-width: none;
}
.topnav::-webkit-scrollbar { display: none; }
.tab {
  flex: 0 0 auto; padding: 8px 14px; border-radius: 999px; text-decoration: none;
  color: var(--text); background: var(--surface); border: 1px solid var(--border); font-size: 0.92rem; min-height: 40px; display: inline-flex; align-items: center;
}
.tab.active { background: var(--accent); color: var(--accent-text); border-color: var(--accent); font-weight: 600; }

.content { padding: 12px 16px 40px; max-width: 760px; margin: 0 auto; outline: none; }
.view { display: flex; flex-direction: column; gap: 4px; }
.section { margin-top: 14px; }
.section > h2 { margin-bottom: 8px; }

/* Cartes */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px; margin-bottom: 10px; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 8px; }
a.card { color: inherit; text-decoration: none; }
a.card:active { background: var(--surface-2); }
.row { display: flex; gap: 8px; align-items: center; }
.row.between { justify-content: space-between; }
.row.wrap { flex-wrap: wrap; }
.teams { display: grid; grid-template-columns: 1fr auto 1fr; gap: 8px; align-items: center; font-weight: 600; }
.team { overflow-wrap: anywhere; }
.team.right { text-align: right; }
.vs { color: var(--muted); font-weight: 500; font-size: 0.9rem; }
.reco-text { font-size: 0.95rem; }
.match-head { margin: 4px 0 8px; }
.match-title { font-size: 1.3rem; }
.bigscore { font-size: 1.6rem; font-weight: 700; }

/* Badges */
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 3px 10px; border-radius: 999px; font-size: 0.8rem; font-weight: 600; border: 1px solid transparent; }
.lvl-prio { background: var(--accent-soft); color: var(--good); border-color: var(--good); }
.lvl-int { background: var(--info-bg); color: var(--info-text); }
.lvl-risk { background: var(--warn-bg); color: var(--warn-text); }
.lvl-none { background: var(--surface-2); color: var(--muted); }
.chip { align-self: flex-start; padding: 3px 10px; border-radius: 999px; font-size: 0.8rem; font-weight: 600; }
.chip.ok { background: var(--accent-soft); color: var(--good); }
.chip.ko { background: var(--bad-soft); color: var(--bad); }

/* Barre de probabilités */
.probwrap { display: flex; flex-direction: column; gap: 4px; }
.probbar { display: flex; height: 12px; border-radius: 999px; overflow: hidden; background: var(--surface-2); }
.seg { display: block; height: 100%; opacity: 0.55; }
.seg.reco { opacity: 1; }
.seg-1 { background: var(--c1); }
.seg-N { background: var(--cN); }
.seg-2 { background: var(--c2); }
.problegend { display: flex; justify-content: space-between; font-size: 0.82rem; color: var(--muted); }
.problegend b { margin-right: 4px; }
.problegend .reco { color: var(--text); font-weight: 700; }

/* Indicateurs */
.kpis { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 8px 0; }
.kpi { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 10px 8px; display: flex; flex-direction: column; align-items: center; text-align: center; gap: 2px; }
.kpi-value { font-size: 1.25rem; font-weight: 700; }
.kpi-label { font-size: 0.75rem; color: var(--muted); }

/* États et messages */
.state { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 6px; padding: 22px 14px; background: var(--surface); border: 1px dashed var(--border); border-radius: var(--radius); color: var(--muted); }
.state strong { color: var(--text); }
.state.error { border-style: solid; border-color: var(--bad); }
.spinner { width: 22px; height: 22px; border: 3px solid var(--border); border-top-color: var(--accent); border-radius: 50%; animation: spin 0.9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation: none; } }
.note { padding: 10px 12px; border-radius: 12px; font-size: 0.9rem; margin: 6px 0; background: var(--info-bg); color: var(--info-text); }
.note.warn { background: var(--warn-bg); color: var(--warn-text); }
.disclaimer { margin: 18px 0 0; padding: 10px 12px; font-size: 0.8rem; color: var(--muted); text-align: center; border-top: 1px solid var(--border); }

/* Boutons et formulaires */
.btn { min-height: 44px; padding: 8px 16px; border-radius: 12px; border: 1px solid var(--border); background: var(--surface); color: var(--text); font: inherit; cursor: pointer; }
.btn.primary { background: var(--accent); color: var(--accent-text); border-color: var(--accent); font-weight: 600; }
.btn.danger { border-color: var(--bad); color: var(--bad); }
.btn.block { width: 100%; }
.btn:disabled { opacity: 0.6; cursor: not-allowed; }
.stack { display: flex; flex-direction: column; gap: 8px; }
label { display: block; font-weight: 600; font-size: 0.9rem; margin: 10px 0 4px; }
input[type='text'], input[type='email'], input[type='password'], select {
  width: 100%; min-height: 44px; padding: 8px 12px; border-radius: 12px; border: 1px solid var(--border); background: var(--surface); color: var(--text); font: inherit;
}
.field { margin-bottom: 4px; }
.field-error, .form-error { display: block; color: var(--bad); font-size: 0.85rem; min-height: 1px; }
.form-status { font-size: 0.9rem; margin: 8px 0; }
.form-status.good { color: var(--good); }
.form-status.bad { color: var(--bad); }
.check { display: flex; align-items: center; gap: 10px; font-weight: 500; margin: 8px 0; }
.check input { width: 22px; height: 22px; }
.filters { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 10px; }
.more { display: flex; justify-content: center; margin: 8px 0; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

/* Choix du jour */
.chips { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 8px; scrollbar-width: none; }
.chip-link { flex: 0 0 auto; padding: 8px 14px; border-radius: 999px; background: var(--surface); border: 1px solid var(--border); color: var(--text); text-decoration: none; font-size: 0.9rem; min-height: 40px; display: inline-flex; align-items: center; }
.chip-link.active { background: var(--accent-soft); border-color: var(--accent); font-weight: 700; }

/* Tableaux et listes */
.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.table { width: 100%; border-collapse: collapse; font-size: 0.86rem; }
.table th, .table td { padding: 8px 10px; text-align: right; border-bottom: 1px solid var(--border); white-space: nowrap; }
.table th[scope='row'], .table thead th:first-child { text-align: left; }
.table thead th { color: var(--muted); font-weight: 600; font-size: 0.78rem; }
.table tbody tr:last-child th, .table tbody tr:last-child td { border-bottom: 0; }
.bullets { margin: 0; padding-left: 20px; }
.bullets li { margin-bottom: 4px; }
.errlist { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.errlist li { display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 8px 10px; font-size: 0.86rem; overflow-wrap: anywhere; }
.formchips { display: inline-flex; gap: 2px; }
.fc { width: 18px; height: 18px; border-radius: 4px; font-size: 0.7rem; display: inline-flex; align-items: center; justify-content: center; color: #fff; font-weight: 700; }
.fc.w { background: var(--c1); }
.fc.d { background: var(--cN); }
.fc.l { background: var(--bad); }
.link { display: inline-block; margin: 6px 0; font-weight: 600; }
.link.back { margin-top: 0; }

/* Calibration */
.cal-row { display: grid; grid-template-columns: 1fr; gap: 4px; margin-bottom: 10px; }
.cal-label { font-size: 0.85rem; }
.cal-bars { display: flex; flex-direction: column; gap: 3px; }
.cal-track { display: block; height: 8px; background: var(--surface-2); border-radius: 999px; overflow: hidden; }
.cal-fill { display: block; height: 100%; border-radius: 999px; }
.cal-fill.announced { background: var(--muted); }
.cal-fill.observed { background: var(--accent); }

/* Connexion */
.login { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px 16px; }
.login-card { width: 100%; max-width: 380px; background: var(--surface); border: 1px solid var(--border); border-radius: 18px; padding: 24px 20px; text-align: center; }
.login-card .logo { border-radius: 16px; }
.login-form { text-align: left; margin-top: 12px; }
.login-form .btn { margin-top: 12px; }

/* Choix de l'utilisateur (Valider / Confirmer / Écarter) */
.card-wrap { margin-bottom: 10px; }
.card-wrap > .card { margin-bottom: 0; border-bottom-left-radius: 0; border-bottom-right-radius: 0; }
.pickbar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 8px 12px; background: var(--surface-2); border: 1px solid var(--border); border-top: 0; border-radius: 0 0 var(--radius) var(--radius); }
.card-wrap:not(:has(.pickbar)) > .card { border-radius: var(--radius); }
.btn.sm { min-height: 40px; padding: 6px 14px; font-size: 0.9rem; }
.btn.static { display: inline-flex; align-items: center; cursor: default; opacity: 0.7; }
.pickstate { font-size: 0.82rem; font-weight: 700; padding: 3px 10px; border-radius: 999px; background: var(--surface); border: 1px solid var(--border); color: var(--muted); }
.pickstate.valide { background: var(--info-bg); color: var(--info-text); border-color: transparent; }
.pickstate.confirme { background: var(--accent-soft); color: var(--good); border-color: var(--good); }
.pickstate.ecarte { background: var(--surface); color: var(--muted); text-decoration: line-through; }
.pick-error { flex-basis: 100%; color: var(--bad); font-size: 0.85rem; }
.example { border: 2px dashed var(--cN); border-radius: var(--radius); padding: 8px; margin: 8px 0; }
.example-tag { display: block; font-size: 0.75rem; font-weight: 700; color: var(--warn-text); background: var(--warn-bg); padding: 3px 10px; border-radius: 999px; margin-bottom: 8px; text-align: center; }
.example .card { margin-bottom: 0; }
.example .pickbar { margin-top: 6px; border-top: 1px solid var(--border); border-radius: var(--radius); }
