/* Module Analyse : graphiques SVG, sélecteur de période, filtres, comparaison A/B. Couleurs reprises des jetons de app.css (jour / nuit). */
/* Palette de la charte : cuivre, anthracite, cuivre clair, gris ; vert = bénéfice, rouge = alerte (pas de violet ni de bleu isolés) */
:root{--an1:var(--copper);--an2:#3a4950;--an3:#23784a;--an4:#dcae74;--an5:#9aa5aa;--an6:#c2563f}
@media (prefers-color-scheme:dark){:root:not([data-theme="light"]){--an2:#c9d2d6;--an3:#5fc68c;--an4:#8a5a26;--an5:#6f7c82;--an6:#ff9a85}}
:root[data-theme="dark"]{--an2:#c9d2d6;--an3:#5fc68c;--an4:#8a5a26;--an5:#6f7c82;--an6:#ff9a85}

/* Cartes chiffrées : une rangée, même largeur et même hauteur, titre court sur une ligne */
@media (min-width:1101px){.an-kpis{grid-template-columns:none;grid-auto-flow:column;grid-auto-columns:minmax(0,1fr)}}
.an-kpis{align-items:stretch}
.an-kpis .kpi .lab{white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.an-kpis .kpi .val{white-space:nowrap}
.an-kpis .kpi .sub{line-height:1.45}
.an-delta{display:inline-block;font-weight:var(--g-fort);font-size:var(--t-petit);color:var(--muted);white-space:nowrap}
.an-delta.bon{color:var(--ok)}
.an-delta.mauvais{color:var(--bad)}
/* Sur la carte cuivre, flèches et pourcentages en clair (lisibles) */
.kpi.hero .an-delta,.kpi.hero .an-delta.bon,.kpi.hero .an-delta.mauvais{color:#fff!important}
/* Période et filtres */
.an-periode{display:flex;flex-wrap:wrap;align-items:center;gap:6px}
.an-periode .inp{width:auto;min-width:0}
.an-filtres{display:flex;flex-wrap:wrap;gap:var(--esp-2);align-items:center;margin:0 0 14px}
.an-filtres-grille{flex:1 1 100%;display:grid;grid-template-columns:repeat(auto-fill,minmax(190px,1fr));gap:10px;background:var(--panel);border:1px solid var(--line);border-radius:var(--r-carte);padding:var(--esp-3)}
.an-filtres-grille .field{display:flex;flex-direction:column;gap:var(--esp-1);font-size:var(--t-petit);color:var(--muted)}
.an-filtres-grille select{width:100%}
.btn.on[data-act="anVoirFiltres"]{border-color:var(--copper);color:var(--copper)}
.panel-h .check input{accent-color:var(--copper)}

/* Graphiques */
.an-graphe{position:relative;width:100%}
.an-graphe svg{display:block;width:100%;height:auto;overflow:visible}
.an-grille{stroke:var(--line);stroke-width:1}
.an-zero{stroke:var(--muted);stroke-width:1}
.an-axe{fill:var(--muted);font-size:11px;font-family:inherit}
.an-barre{fill:var(--an1);opacity:.85;transform-box:fill-box;transform-origin:bottom;animation:anMonte .5s ease-out both}
.an-barre.mis{opacity:1;stroke:var(--ink);stroke-width:1.5}
.an-barre.c1{fill:var(--an1)}.an-barre.c2{fill:var(--an2)}.an-barre.c3{fill:var(--an3)}.an-barre.c4{fill:var(--an4)}.an-barre.c5{fill:var(--an5)}.an-barre.c6{fill:var(--an6)}
.an-graphe:has(.an-barre.mis) .an-barre:not(.mis){opacity:.45}
.an-ligne{fill:none;stroke-width:2.4;stroke-linejoin:round;stroke-linecap:round;stroke:var(--an1);stroke-dasharray:1;stroke-dashoffset:0;animation:anTrace .8s ease-out both}
.an-ligne.pointille{stroke-width:1.8;animation:anFondu .6s ease-out both}
.an-ligne.pointille{stroke-dasharray:6 5}
.an-ligne.c1{stroke:var(--an1)}.an-ligne.c2{stroke:var(--an2)}.an-ligne.c3{stroke:var(--an3)}.an-ligne.c4{stroke:var(--an4)}.an-ligne.c5{stroke:var(--an5)}.an-ligne.c6{stroke:var(--an6)}
.an-aire{opacity:.12;fill:var(--an1);stroke:none;animation:anFondu .8s ease-out both}
.an-aire.c1{fill:var(--an1)}.an-aire.c2{fill:var(--an2)}.an-aire.c5{fill:var(--an5)}
.an-point{fill:var(--panel);stroke-width:2;stroke:var(--an1)}
.an-point.c1{stroke:var(--an1)}.an-point.c2{stroke:var(--an2)}.an-point.c3{stroke:var(--an3)}.an-point.c4{stroke:var(--an4)}.an-point.c5{stroke:var(--an5)}.an-point.c6{stroke:var(--an6)}
.an-zone{fill:transparent;cursor:crosshair}
.an-zone:hover{fill:var(--ink);fill-opacity:.04}
.an-guide{stroke:var(--muted);stroke-width:1;stroke-dasharray:3 3;pointer-events:none;transition:opacity .15s}
.an-bulle{position:absolute;top:4px;z-index:5;pointer-events:none;background:var(--panel);color:var(--ink);border:1px solid var(--line);border-radius:var(--r-btn);box-shadow:0 6px 18px #0000002e;padding:8px 10px;font-size:var(--t-petit);display:flex;flex-direction:column;gap:3px;white-space:nowrap}
.an-bulle b{font-weight:var(--g-fort);margin-bottom:2px}
.an-bulle i,.an-leg i{display:inline-block;width:10px;height:10px;border-radius:2px;margin-right:6px;vertical-align:-1px;background:var(--an1)}
.an-leg i:not(.barre){height:3px;border-radius:2px;vertical-align:3px;width:16px}
.an-leg i.pointille{background:none!important;border-top:2px dashed var(--an1);height:0}
i.c1{background:var(--an1)}i.c2{background:var(--an2)}i.c3{background:var(--an3)}i.c4{background:var(--an4)}i.c5{background:var(--an5)}i.c6{background:var(--an6)}
.an-leg i.pointille.c4{border-color:var(--an4)}.an-leg i.pointille.c5{border-color:var(--an5)}
.an-legende{display:flex;flex-wrap:wrap;gap:6px 16px;margin-top:6px;font-size:var(--t-petit);color:var(--muted)}

/* Barres horizontales */
.an-hbarres{display:flex;flex-direction:column;gap:var(--esp-2)}
.an-hb{display:grid;grid-template-columns:minmax(110px,32%) 1fr auto;gap:10px;align-items:center;font-size:var(--t-texte)}
.an-hb-nom{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.an-hb-piste{height:12px;background:var(--panel2);border-radius:var(--r-btn);overflow:hidden}
.an-hb-piste i{display:block;height:100%;border-radius:var(--r-btn);transform-origin:left;animation:anGlisse .6s ease-out both}
.an-hb-val{white-space:nowrap;font-size:var(--t-petit)}

/* Résumé */
.an-phrases ul{list-style:none;margin:10px 0 0;padding:0;display:flex;flex-direction:column;gap:10px}
.an-ph{display:flex;gap:10px;align-items:flex-start;line-height:1.45;padding:10px 12px;border-radius:var(--r-btn);background:var(--info-soft)}
.an-ph svg{flex:none;width:18px;height:18px;margin-top:1px;color:var(--info)}
.an-ph.bon{background:var(--ok-soft)}.an-ph.bon svg{color:var(--ok)}
.an-ph.alerte{background:var(--warn-soft)}.an-ph.alerte svg{color:var(--warn)}

/* Comparer */
.an-comp-choix{display:flex;flex-direction:row;flex-wrap:wrap;align-items:center;gap:10px var(--esp-4);padding-top:10px;padding-bottom:10px}
.an-comp-choix>.row{margin-left:auto}
.an-comp-per{display:flex;align-items:center;gap:10px;flex-wrap:wrap}
.an-badge{display:inline-grid;place-items:center;width:22px;height:22px;border-radius:var(--r-btn);font-weight:var(--g-fort);font-size:var(--t-petit);color:#fff;background:var(--an1);vertical-align:middle}
.an-badge.b{background:var(--an5)}
.an-comp-table th .an-badge{width:18px;height:18px;font-size:var(--t-etiq)}

.an-roue{display:inline-block;width:16px;height:16px;margin-right:var(--esp-2);vertical-align:-3px;border:2px solid var(--line);border-top-color:var(--copper);border-radius:50%;animation:anTourne .8s linear infinite}

/* Chiffres masqués (bouton œil) */
:root[data-chiffres="caches"] #racine :is(.an-axe,.an-bulle,.an-hb-val){filter:blur(6px)}

@keyframes anMonte{from{transform:scaleY(0)}to{transform:scaleY(1)}}
@keyframes anTrace{from{stroke-dashoffset:1}to{stroke-dashoffset:0}}
@keyframes anFondu{from{opacity:0}}
@keyframes anGlisse{from{transform:scaleX(0)}to{transform:scaleX(1)}}
@keyframes anTourne{to{transform:rotate(360deg)}}
@media (prefers-reduced-motion:reduce){.an-barre,.an-ligne,.an-aire,.an-hb-piste i,.an-roue{animation:none!important}}

@media (max-width:700px){
  .an-hb{grid-template-columns:1fr auto;grid-template-areas:"nom val" "piste piste";gap:4px 10px}
  .an-hb-nom{grid-area:nom}.an-hb-val{grid-area:val}.an-hb-piste{grid-area:piste}
  .an-axe{font-size:11px}
  .an-filtres-grille{grid-template-columns:1fr 1fr}
}

@media print{
  .an-filtres button,.an-filtres:not(:has(.an-filtres-grille)),[data-act="anCsv"],[data-act="anRelancer"],[data-act="anRaccourciB"],.an-bulle,.an-guide,.an-roue{display:none!important}
  .an-barre,.an-ligne,.an-aire,.an-hb-piste i{animation:none!important}
  .an-comp-choix{display:none!important}
  .an-graphe,.an-hbarres,.an-badge,.an-ph{-webkit-print-color-adjust:exact;print-color-adjust:exact}
  .an-graphe,.panel:has(.an-graphe){break-inside:avoid}
  .an-axe{fill:#444}.an-grille{stroke:#ddd}
}
/* Téléphone : comparaison A / B en cartes, choix des périodes à la largeur de l'écran ; PC inchangé */
@media (max-width:760px){
  .an-comp-choix>.row{margin-left:0;width:100%;flex-wrap:wrap}
  .an-comp-per{width:100%}
  .an-comp-per select.inp,.an-comp-per input.inp{flex:1;min-width:0}
  .an-periode select.inp{flex:1 1 140px}
  .an-filtres>.btn,.an-periode>.btn{min-height:40px}
  .an-kpis .kpi .lab{white-space:normal}
  .an-kpis .kpi .val{white-space:normal;overflow-wrap:anywhere}
  .content table.ct.an-comp-table td[data-l="A"]::before,.content table.ct.an-comp-table td[data-l="B"]::before{content:attr(data-l);display:inline-grid;place-items:center;width:18px;height:18px;border-radius:var(--r-btn);color:#fff;background:var(--an1);letter-spacing:0}
  .content table.ct.an-comp-table td[data-l="B"]::before{background:var(--an5)}
}

/* Analyse › Contrôles, WhatsApp, Déplacements (public/analyse-autres.js) : phrase d'aide sous chaque titre, liens vers les autres pages */
.an-aide{margin:2px 0 10px;font-size:var(--t-petit);color:var(--muted);line-height:1.45;max-width:110ch}
.aa-liens{display:grid;grid-template-columns:repeat(auto-fill,minmax(230px,1fr));gap:8px}
.aa-lien{display:flex;flex-direction:column;gap:2px;text-align:left;background:var(--panel);border:1px solid var(--line);border-radius:var(--r-btn);padding:9px 12px;cursor:pointer;color:inherit;font:inherit}
.aa-lien:hover,.aa-lien:focus-visible{border-color:var(--copper)}
.aa-lien b{font-size:var(--t-normal,14px)}
.aa-lien span{font-size:var(--t-petit);color:var(--muted);line-height:1.35}
.an-groupe{margin:0 0 10px;max-width:100%;overflow-x:auto;flex-wrap:nowrap;scrollbar-width:none}.an-groupe::-webkit-scrollbar{display:none}.an-groupe button{white-space:nowrap}
