:root {
    --fond: #f4f5f7; --carte: #fff; --texte: #1d2330; --doux: #5f6878; --ligne: #e1e4ea;
    --accent: #0b5cad; --accent-fond: #e7f0fa; --succes: #1f7a3d; --succes-fond: #e6f4ea;
    --attention: #8a5a00; --attention-fond: #fff4dc; --erreur: #b3261e; --erreur-fond: #fdecea;
    --barre: #141a26; --barre-texte: #c9d0dc;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, Ubuntu, sans-serif; color: var(--texte); background: var(--fond); }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.35rem; margin: 0 0 .9rem; }
h2 { font-size: 1.02rem; margin: 0 0 .6rem; }

/* Mise en page : barre latérale fixe ≥ 768 px, burger en dessous */
.menu-bascule { position: absolute; opacity: 0; pointer-events: none; }
.entete { display: none; }
.barre { position: fixed; inset: 0 auto 0 0; width: 210px; background: var(--barre); color: var(--barre-texte); display: flex; flex-direction: column; padding: 1rem 0; z-index: 10; }
.barre .marque { color: #fff; font-weight: 700; padding: 0 1.1rem 1rem; }
.barre a { color: var(--barre-texte); padding: .6rem 1.1rem; }
.barre a:hover { background: #1f2738; text-decoration: none; }
.barre a.actif { background: #243149; color: #fff; box-shadow: inset 3px 0 0 #4ea1f3; }
.utilisateur { margin-top: auto; padding: 1rem 1.1rem 0; border-top: 1px solid #2a3346; font-size: .9rem; display: flex; flex-direction: column; gap: .3rem; }
.utilisateur .lien { color: var(--barre-texte); padding: 0; text-align: left; }
.contenu { margin-left: 210px; padding: 1.25rem 1.5rem 3rem; max-width: 1200px; }

@media (max-width: 767px) {
    .entete { display: flex; align-items: center; gap: .75rem; background: var(--barre); color: #fff; padding: .6rem 1rem; position: sticky; top: 0; z-index: 11; }
    .burger { font-size: 1.4rem; cursor: pointer; line-height: 1; }
    .entete .marque { font-weight: 700; }
    .barre { transform: translateX(-100%); transition: transform .2s ease-out; top: 44px; width: 240px; }
    .barre .marque { display: none; }
    .menu-bascule:checked ~ .barre { transform: none; }
    .contenu { margin-left: 0; padding: 1rem; }
}

/* Composants */
.carte { background: var(--carte); border: 1px solid var(--ligne); border-radius: 8px; padding: 1rem; margin-bottom: 1rem; }
.titre-bloc { display: flex; justify-content: space-between; align-items: baseline; gap: .5rem; flex-wrap: wrap; margin-bottom: .5rem; }
.titre-bloc h2 { margin: 0; }
.message { border-radius: 6px; padding: .7rem .9rem; margin-bottom: .8rem; border: 1px solid transparent; }
.message ul { margin: .4rem 0 0; padding-left: 1.2rem; }
.message.succes { background: var(--succes-fond); color: var(--succes); }
.message.attention { background: var(--attention-fond); color: var(--attention); }
.message.erreur { background: var(--erreur-fond); color: var(--erreur); }
.bouton { display: inline-block; background: var(--accent); color: #fff; border: 0; border-radius: 6px; padding: .6rem 1rem; font: inherit; cursor: pointer; }
.bouton:hover { background: #094d91; text-decoration: none; }
.bouton.secondaire { background: var(--accent-fond); color: var(--accent); }
.bouton.petit { padding: .2rem .5rem; }
.lien { background: none; border: 0; font: inherit; color: var(--accent); cursor: pointer; padding: 0; }
.aide { color: var(--doux); font-size: .92rem; }
.fil { color: var(--doux); font-size: .9rem; margin: 0 0 .3rem; }
.liste { padding-left: 1.2rem; margin: 0 0 1rem; }
.liste li { margin-bottom: .35rem; }
.actions { display: flex; align-items: center; gap: 1rem; }
input, select { font: inherit; padding: .45rem .55rem; border: 1px solid #c4c9d3; border-radius: 6px; background: #fff; max-width: 100%; }
input[type=file] { border: 1px dashed #9aa3b2; padding: .8rem; width: 100%; margin: .5rem 0 1rem; }
label.case { display: inline-flex; align-items: center; gap: .3rem; }

/* Tableaux : défilent dans leur cadre, jamais la page */
.defile { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.tableau, .chiffres { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.tableau th, .tableau td, .chiffres th, .chiffres td { padding: .45rem .6rem; border-bottom: 1px solid var(--ligne); text-align: left; white-space: nowrap; }
.tableau thead th, .chiffres thead th { font-size: .82rem; color: var(--doux); font-weight: 600; background: #fafbfc; }
.tableau tfoot th { border-top: 2px solid var(--ligne); }
.tableau.serre th, .tableau.serre td { padding: .35rem .4rem; font-size: .88rem; }
.n { text-align: right !important; }
.zero { color: #b0b6c1; }
.ecart, .ecart td, .ecart th { color: var(--erreur); font-weight: 600; }
.inactif td { color: var(--doux); font-style: italic; }
.non-classe { color: var(--attention); font-weight: 600; }
.fige { position: sticky; left: 0; background: var(--carte); z-index: 1; }
thead .fige { background: #fafbfc; }

/* Tableau de bord */
.navigation-periode { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: .6rem; margin-bottom: 1rem; }
.onglets { display: inline-flex; background: #e6e9ef; border-radius: 8px; padding: 3px; }
.onglets a { padding: .4rem .8rem; border-radius: 6px; color: var(--texte); }
.onglets a.actif { background: #fff; box-shadow: 0 1px 2px rgba(0,0,0,.12); font-weight: 600; }
.onglets a:hover { text-decoration: none; }
.dates { display: flex; align-items: center; gap: .4rem; }
.dates form { margin: 0; }
.fleche { display: inline-flex; align-items: center; justify-content: center; width: 2.2rem; height: 2.2rem; border-radius: 6px; background: #fff; border: 1px solid var(--ligne); font-size: 1.3rem; }
.fleche:hover { text-decoration: none; background: var(--accent-fond); }
.grands-chiffres { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; margin-bottom: 1rem; }
.chiffre { background: var(--carte); border: 1px solid var(--ligne); border-radius: 8px; padding: 1rem; display: flex; flex-direction: column; gap: .15rem; }
.chiffre .etiquette { color: var(--doux); font-size: .9rem; }
.chiffre .valeur { font-size: 2.1rem; font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1.1; }
.chiffre .sous { font-size: .95rem; }
.chiffre .detail { color: var(--doux); font-size: .82rem; }
.hausse { color: var(--succes); }
.baisse { color: var(--erreur); }
.filtres { display: flex; flex-wrap: wrap; gap: .5rem; margin-bottom: 1rem; }
.en-ligne { display: flex; align-items: center; gap: .6rem; margin: 0; }
.en-ligne select { padding: .25rem .4rem; }

/* Fiche PDV */
.courbe { width: 100%; height: 160px; display: block; }
.courbe rect { fill: var(--accent); }
.courbe rect:hover { fill: #4ea1f3; }
.courbe line { stroke: var(--ligne); stroke-width: .3; }
.axe { display: flex; justify-content: space-between; color: var(--doux); font-size: .8rem; }

/* Connexion */
.page-connexion { display: flex; min-height: 100vh; min-height: 100dvh; align-items: center; justify-content: center; padding: 1rem; }
.connexion { width: 100%; max-width: 360px; display: flex; flex-direction: column; gap: .8rem; }
.connexion h1 { text-align: center; }
.connexion label:not(.case) { display: flex; flex-direction: column; gap: .25rem; font-size: .92rem; }
.connexion input { font-size: 16px; }

@media (max-width: 480px) {
    .grands-chiffres { gap: .6rem; }
    .chiffre .valeur { font-size: 1.7rem; }
    .onglets a { padding: .35rem .55rem; font-size: .9rem; }
    h1 { font-size: 1.15rem; }
}

/* ANA-01 : zones et affectation en masse */
details.zones summary { cursor: pointer; list-style: revert; }
.liste-zones { display: flex; flex-direction: column; gap: .35rem; margin: .7rem 0; }
.zone { display: flex; flex-wrap: wrap; align-items: center; gap: .6rem; padding: .25rem 0; border-bottom: 1px solid var(--ligne); }
.zone form { margin: 0; }
.zone input { width: 12rem; }
.nouvelle-zone input { width: 14rem; }
.lien.danger { color: var(--erreur); }
.barre-action { position: sticky; top: 0; z-index: 3; display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; background: var(--accent-fond); border: 1px solid #c9dcf2; border-radius: 8px; padding: .5rem .7rem; margin-bottom: .6rem; }
@media (max-width: 767px) { .barre-action { top: 44px; } }

/* ANA-02 : barre de filtres */
.barre-filtres { padding: .7rem 1rem; }
.barre-filtres summary { cursor: pointer; list-style: revert; }
.badge { display: inline-block; min-width: 1.4rem; padding: 0 .4rem; border-radius: 999px; background: var(--accent); color: #fff; font-size: .8rem; text-align: center; }
.grille-filtres { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: .8rem; margin: .8rem 0; }
.grille-filtres fieldset { border: 1px solid var(--ligne); border-radius: 6px; padding: .5rem .7rem; margin: 0; display: flex; flex-direction: column; gap: .3rem; min-width: 0; }
.grille-filtres fieldset.large { grid-column: 1 / -1; }
.grille-filtres legend { font-size: .85rem; font-weight: 600; color: var(--doux); padding: 0 .3rem; }
.choix-defile { max-height: 11rem; overflow-y: auto; display: flex; flex-direction: column; gap: .2rem; }
.pdv-liste { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); max-height: 14rem; }
.periode-libre label { display: flex; justify-content: space-between; align-items: center; gap: .4rem; }
.pastilles { display: flex; flex-wrap: wrap; gap: .4rem; margin-top: .5rem; }
.pastille { background: var(--accent-fond); color: var(--accent); border-radius: 999px; padding: .15rem .65rem; font-size: .88rem; }
.pastille:hover { text-decoration: none; background: #d5e6f8; }

/* ANA-03 : analyse croisée */
.reglages { display: flex; flex-wrap: wrap; align-items: flex-end; gap: .6rem .9rem; }
.reglages label:not(.case) { display: flex; flex-direction: column; gap: .2rem; font-size: .85rem; color: var(--doux); }
.reglages select, .reglages input { color: var(--texte); }
.reglages .court { width: 6rem; }
.raccourcis { flex-basis: 100%; display: flex; flex-wrap: wrap; gap: .35rem; }
.pastille.active { background: var(--accent); color: #fff; }
.moyen { width: 11rem; }
.actions-export { display: flex; flex-wrap: wrap; align-items: center; gap: .4rem; }
.croise th a { color: inherit; }
.croise td.total { background: #fafbfc; }
.croise tr.autres td { font-style: italic; color: var(--doux); }
.vues .vues-ligne { display: flex; flex-wrap: wrap; align-items: center; gap: .35rem; margin: .15rem 0; }
.vue-enregistree { display: inline-flex; align-items: center; gap: .15rem; }
.vue-enregistree form { margin: 0; }
.tres-court { width: 4.5rem; }
