:root {
    --bleu: #0b3d91;
    --bleu-clair: #e8eefa;
    --fond: #f4f6fa;
    --texte: #1b2433;
    --discret: #6b7485;
    --bord: #dde2ea;
    --vert: #1e8e3e;
    --vert-clair: #e3f4e8;
    --orange: #b26a00;
    --orange-clair: #fff1dc;
    --rouge: #c62828;
    --rouge-clair: #fdeaea;
    --rayon: 12px;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
    margin: 0;
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    font-size: 16px;
    line-height: 1.45;
    color: var(--texte);
    background: var(--fond);
}

body.avec-nav { padding-bottom: calc(70px + env(safe-area-inset-bottom)); }

a { color: var(--bleu); }

.barre {
    position: sticky;
    top: 0;
    z-index: 10;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    padding-top: calc(12px + env(safe-area-inset-top));
    background: var(--bleu);
    color: #fff;
}

.barre a { color: #fff; text-decoration: none; }
.barre .marque { font-weight: 700; font-size: 1.1rem; }
.barre .profil {
    background: rgba(255, 255, 255, .15);
    padding: 6px 12px;
    border-radius: 20px;
    font-size: .9rem;
}

main { max-width: 720px; margin: 0 auto; padding: 16px; }

h1 { font-size: 1.5rem; margin: 4px 0 16px; }
h2 { font-size: 1.15rem; margin: 0 0 12px; }
h3 { font-size: 1rem; margin: 20px 0 8px; color: var(--discret); }

.carte {
    background: #fff;
    border-radius: var(--rayon);
    padding: 16px;
    margin-bottom: 16px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, .06);
}

.carte.lien { display: block; text-decoration: none; color: inherit; }
.carte.annule { opacity: .6; }

.discret { color: var(--discret); font-size: .9rem; }
.lien-brut { text-decoration: none; color: inherit; }

.flash {
    padding: 12px 14px;
    border-radius: var(--rayon);
    margin-bottom: 12px;
    background: var(--vert-clair);
    color: var(--vert);
}
.flash.erreur { background: var(--rouge-clair); color: var(--rouge); }

/* ---------- Navigation basse ---------- */

.nav-bas {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 10;
    display: flex;
    background: #fff;
    border-top: 1px solid var(--bord);
    padding-bottom: env(safe-area-inset-bottom);
}

.nav-bas a {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 8px 2px;
    font-size: .75rem;
    color: var(--discret);
    text-decoration: none;
}

.nav-bas a .icone { font-size: 1.3rem; line-height: 1.2; }
.nav-bas a.actif { color: var(--bleu); font-weight: 700; }

/* ---------- Boutons ---------- */

.bouton, button {
    display: inline-block;
    min-height: 44px;
    padding: 10px 16px;
    border: 0;
    border-radius: 10px;
    background: var(--bleu);
    color: #fff;
    font: inherit;
    font-weight: 600;
    text-align: center;
    text-decoration: none;
    cursor: pointer;
}

.bouton, button, summary { touch-action: manipulation; -webkit-tap-highlight-color: transparent; }
.bouton.secondaire { background: var(--bleu-clair); color: var(--bleu); }
.bouton.danger { background: var(--rouge-clair); color: var(--rouge); }
.bouton.ok { background: var(--vert-clair); color: var(--vert); }
.bouton.petit { min-height: 36px; padding: 6px 12px; font-size: .9rem; }
.bouton.large { display: block; width: 100%; }

.barre-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }

/* ---------- Formulaires ---------- */

.formulaire label { display: block; margin-bottom: 14px; font-weight: 600; font-size: .95rem; }

.formulaire input:not([type=checkbox]):not([type=radio]),
.formulaire select,
.formulaire textarea {
    display: block;
    width: 100%;
    margin-top: 4px;
    padding: 11px 12px;
    border: 1px solid var(--bord);
    border-radius: 10px;
    font: inherit;
    font-weight: 400;
    background: #fff;
}

.formulaire textarea { min-height: 90px; }
.formulaire label.case { display: flex; align-items: center; gap: 10px; font-weight: 400; }
.formulaire label.case input { width: 22px; height: 22px; }
.formulaire .deux { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.formulaire.compact { margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--bord); }

fieldset { border: 1px solid var(--bord); border-radius: 10px; margin: 0 0 14px; padding: 10px 12px; }
legend { font-weight: 600; padding: 0 4px; }

/* ---------- Listes ---------- */

.liste { list-style: none; margin: 0; padding: 0; }
.liste li { padding: 12px 0; border-bottom: 1px solid var(--bord); }
.liste li:last-child { border-bottom: 0; }
.liste a { text-decoration: none; color: inherit; display: block; }
.liste a.evenement { display: flex; }

.evenement { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.evenement .titre { font-weight: 700; }
.evenement .score { font-weight: 700; font-size: 1.2rem; white-space: nowrap; }

.contacts { list-style: none; margin: 0; padding: 0; }
.contacts li {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    padding: 10px 0;
    border-bottom: 1px solid var(--bord);
    flex-wrap: wrap;
}
.contacts li:last-child { border-bottom: 0; }
.contacts .actions { display: flex; gap: 6px; flex-wrap: wrap; }

.badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 20px;
    background: var(--bleu-clair);
    color: var(--bleu);
    font-size: .75rem;
    font-weight: 600;
}
.badge.alerte { background: var(--orange-clair); color: var(--orange); }
.badge.ok { background: var(--vert-clair); color: var(--vert); }
.badge.rouge { background: var(--rouge-clair); color: var(--rouge); }

/* ---------- Statuts de présence ---------- */

.statut {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: .8rem;
    font-weight: 600;
    white-space: nowrap;
    background: #eef0f4;
    color: var(--discret);
}
.statut.present { background: var(--vert-clair); color: var(--vert); }
.statut.incertain { background: var(--orange-clair); color: var(--orange); }
.statut.absent { background: var(--rouge-clair); color: var(--rouge); }

.compteurs { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }

.liste-joueurs { list-style: none; margin: 0; padding: 0; }
.liste-joueurs li { padding: 12px 0; border-bottom: 1px solid var(--bord); }
.liste-joueurs .ligne { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.liste-joueurs .nom { font-weight: 600; }
.numero {
    display: inline-block;
    min-width: 26px;
    margin-right: 6px;
    padding: 1px 6px;
    border-radius: 6px;
    background: var(--bleu);
    color: #fff;
    font-size: .8rem;
    text-align: center;
}

.choix-statut { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin-top: 8px; }
.choix-statut button { min-height: 44px; padding: 8px 4px; border-radius: 10px; font-size: .9rem; }
.choix-statut:has(.choisi) button:not(.choisi) { opacity: .5; }
.choix-statut button.choisi { outline: 2px solid currentColor; }
.liste-joueurs .ligne { flex-wrap: wrap; }
.liste-joueurs .nom { flex: 1; min-width: 0; }
.convocation { margin: 0; }
.convocation .bouton { white-space: nowrap; }

/* Réponse d'un parent ou d'un joueur, en haut des fiches et sur l'accueil */
.ma-reponse { margin-top: 12px; }
.ma-reponse + .ma-reponse { padding-top: 12px; border-top: 1px solid var(--bord); }
.ma-reponse .ligne { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.ma-reponse .nom { font-weight: 600; }
#reponse { border-left: 4px solid var(--bleu); }
#reponse .ma-reponse:first-of-type { margin-top: 0; }
details.reponses-equipe { border: 0; padding: 0; }
details.reponses-equipe > summary { color: var(--bleu); font-weight: 600; }

/* Rôles du match : le bouton reste sur une ligne à côté du libellé */
.evenement.role > form { flex: none; margin: 0; }
.evenement.role .bouton, .evenement.role button { white-space: nowrap; }

/* ---------- Tableaux (admin, import) ---------- */

.defilement { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { border-collapse: collapse; width: 100%; font-size: .85rem; background: #fff; }
th, td { border: 1px solid var(--bord); padding: 6px 8px; text-align: left; vertical-align: top; }
th { background: var(--bleu-clair); }

.tuiles { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 16px; }
.tuile {
    display: block;
    padding: 16px;
    border-radius: var(--rayon);
    background: #fff;
    text-decoration: none;
    color: var(--texte);
    box-shadow: 0 1px 3px rgba(0, 0, 0, .06);
}
.tuile strong { display: block; font-size: 1.6rem; color: var(--bleu); }

.guide ul, .guide ol { margin: 0; padding-left: 20px; }
.guide li { margin-bottom: 8px; line-height: 1.45; }
.guide .statut { font-size: .8rem; }

.resultat { display: flex; flex-direction: column; align-items: center; min-width: 76px; padding: 4px 8px; border-radius: 8px;
    font-size: .85rem; font-weight: 700; white-space: nowrap; line-height: 1.25; }
.resultat strong { font-size: .7rem; text-transform: uppercase; letter-spacing: .04em; }
.resultat.ok { background: var(--vert-clair); color: var(--vert); }
.resultat.rouge { background: var(--rouge-clair); color: var(--rouge); }
.resultat.alerte { background: var(--orange-clair); color: var(--orange); }
.resultat-fiche { text-align: center; }
.resultat-fiche .badge { font-size: .95rem; padding: 4px 12px; }

.code-equipe { font-size: 1.8rem; font-weight: 700; letter-spacing: .12em; color: var(--bleu); text-align: center; margin: 8px 0; }

.titre-rubrique { font-size: .8rem; text-transform: uppercase; letter-spacing: .05em; color: var(--discret); margin: 20px 4px 8px; }
.liste.menu-admin a { display: flex; align-items: center; gap: 10px; }
.menu-admin a > span:first-child { flex: 1; min-width: 0; }
.menu-admin strong { display: block; }
.menu-admin small { display: block; margin-top: 2px; color: var(--discret); font-size: .85rem; line-height: 1.3; }
.menu-admin .fleche { color: var(--discret); font-size: 1.4rem; line-height: 1; }
.menu-admin.a-faire strong { color: var(--orange); }

.lien-copie { word-break: break-all; font-size: .85rem; background: var(--fond); padding: 10px; border-radius: 8px; }

.filtres { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 12px; }
.filtres a { padding: 6px 12px; border-radius: 20px; background: #fff; text-decoration: none; font-size: .9rem; }
.filtres a.actif { background: var(--bleu); color: #fff; }

details { border-bottom: 1px solid var(--bord); padding: 12px 0; }
details:last-child { border-bottom: 0; }
summary { cursor: pointer; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; min-height: 32px; }
details[open] summary { margin-bottom: 8px; }

.memo {
    padding: 12px 14px;
    margin-bottom: 16px;
    border-radius: var(--rayon);
    background: var(--orange-clair);
    color: var(--orange);
}
details.affecter { border: 0; padding: 4px 0 0; }
.apercu-icone { vertical-align: middle; border-radius: 8px; }

.code-mfa { font-size: 1.5rem !important; letter-spacing: .3em; text-align: center; font-family: ui-monospace, monospace; }
.cle-totp { font-family: ui-monospace, monospace; font-size: 1.05rem; word-spacing: .2em; background: var(--fond); padding: 10px; border-radius: 8px; }
.codes-secours { list-style: none; padding: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 8px; font-family: ui-monospace, monospace; font-size: 1.1rem; }
.codes-secours li { background: var(--fond); padding: 8px; border-radius: 8px; text-align: center; }
.etapes { padding-left: 20px; }
.etapes li { margin-bottom: 12px; }
.aide { background: var(--bleu-clair); color: var(--texte); padding: 12px 14px; border-radius: var(--rayon); margin-bottom: 14px; font-size: .92rem; }
.journal { font-family: ui-monospace, monospace; font-size: .75rem; white-space: pre-wrap; word-break: break-all; background: var(--fond); padding: 10px; border-radius: 8px; }
[hidden] { display: none !important; }
.hors-ecran { position: fixed; top: -1000px; left: 0; opacity: 0; }

.connexion { max-width: 420px; margin: 0 auto; }
.version { margin: 24px 0 4px; text-align: center; font-size: .75rem; color: var(--discret); }
.separateur { text-align: center; color: var(--discret); margin: 8px 0 16px; }

/* Rapports de statistiques */
svg.graphique { display: block; width: 100%; height: auto; margin: 8px 0; }
.rapport-entete { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; padding-bottom: 12px; border-bottom: 3px solid var(--bleu); }
.rapport-entete img { border-radius: 10px; }
.rapport-entete div { display: flex; flex-direction: column; }
.rapport-entete strong { font-size: 1.2rem; }
.rapport-type { font-size: .75rem; text-transform: uppercase; letter-spacing: .08em; color: var(--bleu); font-weight: 700; }
.score-rapport { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 8px; text-align: center; }
.equipe-score span { display: block; font-size: .85rem; font-weight: 600; color: var(--discret); }
.equipe-score strong { font-size: 2.6rem; line-height: 1.1; }
.equipe-score:first-child strong { color: var(--bleu); }
.equipe-score:last-child strong { color: var(--rouge); }
.centre-score { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.centre-score small { color: var(--discret); }
.filtre-rapport { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 10px; margin-bottom: 16px; }
.filtre-rapport label { flex: 1 1 220px; font-weight: 600; font-size: .9rem; }
.filtre-rapport select { display: block; width: 100%; margin-top: 4px; padding: 9px 10px; font-size: 1rem; border: 1px solid var(--bord); border-radius: 8px; background: #fff; }
.filtre-rapport .barre-actions { margin-bottom: 0; }
.kpis { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 8px; margin: 8px 0; }
.kpi { background: var(--fond); border-radius: 10px; padding: 10px; display: flex; flex-direction: column; }
.kpi strong { font-size: 1.35rem; color: var(--bleu); }
.kpi span { font-size: .8rem; font-weight: 600; }
.kpi small { font-size: .75rem; color: var(--discret); }
.anneaux { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; max-width: 480px; margin: 0 auto 8px; }
.points-cles { margin: 0; padding-left: 20px; }
.points-cles li { margin-bottom: 6px; }
.rapport-joueuse { border-left: 4px solid #f29900; }
.tableau { overflow-x: auto; margin: 8px 0; }
.tableau table { width: 100%; border-collapse: collapse; font-size: .85rem; font-variant-numeric: tabular-nums; }
.tableau th, .tableau td { padding: 7px 6px; text-align: center; border-bottom: 1px solid var(--bord); white-space: nowrap; }
.tableau thead th { font-size: .75rem; text-transform: uppercase; color: var(--discret); background: var(--fond); }
.tableau .gauche { text-align: left; }
.tableau .fort { font-weight: 700; }
.tableau tr.choisie td { background: #fff1dc; font-weight: 600; }
.comparaison td { width: 35%; font-size: 1rem; font-weight: 600; }
.comparaison tbody th { font-weight: 500; color: var(--discret); }
.comparaison thead .nous { color: var(--bleu); }
.comparaison thead .eux { color: var(--rouge); }
.comparaison td.meilleur, .tableau td.meilleur { color: var(--vert); }
.chronologie { list-style: none; margin: 0; padding: 0; font-size: .88rem; }
.chronologie li { display: flex; gap: 10px; padding: 5px 0; border-bottom: 1px solid var(--bord); }
.chronologie .temps { width: 48px; color: var(--discret); font-variant-numeric: tabular-nums; }
.chronologie .score-court { width: 44px; font-weight: 700; font-variant-numeric: tabular-nums; }
.chronologie li.periode { font-weight: 700; color: var(--bleu); padding-top: 12px; }
.chronologie li.eux { color: var(--discret); }
.chronologie li.but.nous, .chronologie li.but7m.nous { color: var(--bleu); font-weight: 600; }
.chronologie li.deux_min, .chronologie li.disqualification { color: var(--rouge); }
details summary { cursor: pointer; }
.source { font-size: .78rem; color: var(--discret); text-align: center; }
.titre-joueuse { display: flex; align-items: center; gap: 12px; }

/* Rôles à pourvoir */
.alerte-roles { background: var(--orange-clair); color: var(--orange); border-radius: 10px; padding: 10px 12px; margin: 8px 0; font-size: .92rem; font-weight: 600; }
.alerte-roles a { color: var(--orange); margin-left: 6px; }
.grandit { flex: 1; min-width: 0; }

/* Avertissements de l'accueil et assistant de démarrage */
.avertissements { border-left: 4px solid var(--orange); }
.avertissements h2 { color: var(--orange); }
.etapes .etape { padding: 10px 0; }
.etape .barre-actions { margin: 8px 0 0; flex-wrap: wrap; }
.etape .barre-actions form { margin: 0; }
li.evenement > form, li.evenement > a { margin: 0; }
li.evenement > a { color: inherit; text-decoration: none; flex: 1; min-width: 0; }
li.evenement > a.bouton { flex: 0 0 auto; color: var(--bleu); }
details > summary { cursor: pointer; padding: 8px 0; }
.evenement.rapprocher { flex-wrap: wrap; }
.evenement.rapprocher > span { flex: 1 1 100%; }
.evenement.rapprocher select { flex: 1 1 100%; width: 100%; margin-top: 6px; }

/* Logos et photos */
.logo { width: 28px; height: 28px; object-fit: contain; border-radius: 6px; background: #fff; flex: none; vertical-align: middle; }
.logo.grand { width: 56px; height: 56px; }
.barre .marque { display: flex; align-items: center; gap: 8px; }
.logo-barre { width: 26px; height: 26px; object-fit: contain; border-radius: 6px; background: #fff; padding: 1px; }
.affiche { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 8px; text-align: center; }
.affiche > span { display: flex; flex-direction: column; align-items: center; gap: 6px; font-weight: 600; font-size: .9rem; }
.affiche strong { font-size: 2rem; line-height: 1.1; color: var(--bleu); }
.avatar { width: 36px; height: 36px; border-radius: 50%; object-fit: cover; flex: none; display: inline-flex; align-items: center; justify-content: center; vertical-align: middle; }
.avatar.petit { width: 24px; height: 24px; font-size: .65rem; }
.avatar.grand { width: 96px; height: 96px; font-size: 2rem; }
.avatar.vide { background: var(--bleu-clair); color: var(--bleu); font-weight: 700; font-size: .85rem; }
.avatar.grand.vide { font-size: 2rem; }
.fiche-photo { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.form-photo { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 8px 0; }

/* Trajet */
.trajets { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 10px; margin: 8px 0; }
.trajet { background: var(--fond); border-radius: 10px; padding: 12px; display: flex; flex-direction: column; gap: 2px; }
.trajet span { font-size: .85rem; font-weight: 600; }
.trajet strong { font-size: 1.5rem; color: var(--bleu); }
.trajet small { color: var(--discret); }
.trajet.meilleur { border: 2px solid var(--vert); }

/* Aperçu d'une équipe FFHB */
.apercu { border: 2px solid var(--bleu); border-radius: var(--rayon); padding: 12px; margin: 12px 0; }
.apercu h3 { margin-top: 12px; }

/* Analyse de l'adversaire */
.analyse-points { display: grid; grid-template-columns: 1fr; gap: 12px; }
.analyse-points > div { border-radius: 10px; padding: 12px; }
.analyse-points .forts { background: var(--vert-clair); }
.analyse-points .faibles { background: var(--rouge-clair); }
.analyse-points h3 { margin: 0 0 6px; }
.analyse-points .forts h3 { color: var(--vert); }
.analyse-points .faibles h3 { color: var(--rouge); }
.analyse-points ul { margin: 0; padding-left: 18px; }
.analyse-points li { margin-bottom: 4px; }
.surveiller { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.surveiller li { display: flex; gap: 10px; align-items: flex-start; background: var(--fond); border-radius: 10px; padding: 10px; }
.surveiller .numero { flex: none; }
.surveiller small { display: block; color: var(--discret); }
.forme { display: inline-flex; gap: 3px; }
.forme span { width: 20px; height: 20px; border-radius: 50%; font-size: .7rem; font-weight: 700; color: #fff; display: inline-flex; align-items: center; justify-content: center; }
.forme .V { background: var(--vert); }
.forme .N { background: var(--orange); }
.forme .D { background: var(--rouge); }
.tableau tr.nous td { background: var(--bleu-clair); font-weight: 600; }
.tableau tr.eux td { background: var(--rouge-clair); font-weight: 600; }
.tableau td .logo { width: 22px; height: 22px; margin-right: 6px; }

@media (min-width: 640px) {
    .tuiles { grid-template-columns: repeat(3, 1fr); }
    .analyse-points { grid-template-columns: 1fr 1fr; }
}

@media print {
    @page { margin: 12mm; }
    body, body.avec-nav { background: #fff; padding: 0; font-size: 11pt; }
    .barre, .nav-bas, .pas-imprimer, .flash, .version { display: none !important; }
    main { max-width: none; padding: 0; }
    h1 { display: none; }
    .carte { box-shadow: none; border: 1px solid var(--bord); break-inside: avoid; padding: 10px 12px; margin-bottom: 10px; }
    .tableau { overflow: visible; }
    a { color: inherit; text-decoration: none; }
    .analyse-points { grid-template-columns: 1fr 1fr; }
    .kpi, .tableau thead th, .tableau tr.choisie td, .analyse-points > div, .forme span, .tableau tr.nous td, .tableau tr.eux td { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}
