/* ============================================================
   GoodBeauty — module Statistiques (rapports)
   Filtres de période, variations, graphiques (colonnes, barres, courbe), commissions imprimables,
   tableau consolidé, bilan annuel (document A4).
   Chargée sur toutes les pages (bloc « mois en cours » de l'accueil) : tout est préfixé « rp- ».
   ============================================================ */

/* ---------- Filtres de période ---------- */
.rp-filtres { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 16px; margin-bottom: 16px; }
.rp-nav { display: flex; align-items: center; gap: 4px; }
.rp-periode { font-size: 1.02rem; padding: 0 6px; min-width: 9em; text-align: center; }
.rp-nav .btn-ic.inactif { opacity: .3; }
.rp-dates { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; }
.rp-dates .champ { min-width: 150px; }
.rp-comparer { display: flex; align-items: center; gap: 8px; margin-left: auto; font-size: .88rem; color: var(--muet); font-weight: 600; }
.rp-comparer select { width: auto; min-height: 38px; padding: 6px 10px; }

/* ---------- Variations ---------- */
.rp-delta { display: inline-flex; align-items: center; gap: 3px; font-weight: 650; font-size: .8rem; white-space: nowrap; font-variant-numeric: tabular-nums; }
.rp-delta .ic { width: 14px; height: 14px; }
.rp-delta.bon { color: var(--ok); }
.rp-delta.mauvais { color: var(--danger); }
.rp-delta.neutre { color: var(--muet); font-weight: 500; }
.rp-stats .stat-det { display: flex; flex-wrap: wrap; gap: 4px 6px; align-items: center; }
.rp-stats .stat-val { font-size: 1.4rem; }

/* ---------- Graphique en colonnes ---------- */
.rp-graph { position: relative; margin: 8px 0 0; padding: 0 0 0 48px; }
.rp-axe { position: absolute; left: 0; right: 0; top: 0; height: 180px; pointer-events: none; }
.rp-axe span { position: absolute; left: 48px; right: 0; border-top: 1px solid var(--ligne); }
.rp-axe span b { position: absolute; right: calc(100% + 8px); top: -.65em; font-size: .72rem; font-weight: 500; color: var(--muet); white-space: nowrap; font-variant-numeric: tabular-nums; }
.rp-colonnes { display: grid; grid-template-columns: repeat(var(--n), minmax(0, 1fr)); position: relative; }
.rp-col { display: flex; flex-direction: column; align-items: stretch; min-width: 0; outline: none; cursor: default; border-radius: 6px; }
.rp-col:hover, .rp-col:focus-visible { background: color-mix(in oklab, var(--accent) 7%, transparent); }
.rp-paire { height: 180px; display: flex; align-items: flex-end; justify-content: center; gap: 2px; }
.rp-barre { display: block; width: clamp(3px, 44%, 24px); background: var(--accent); border-radius: 4px 4px 0 0; }
.double .rp-barre { width: clamp(2px, 32%, 16px); }
.rp-barre.avant { background: color-mix(in oklab, var(--muet) 45%, var(--surface)); }
.rp-col small { display: block; height: 22px; line-height: 22px; text-align: center; font-size: .7rem; color: var(--muet); white-space: nowrap; overflow: visible; }
.rp-col small.cache { visibility: hidden; }
.rp-legende { display: flex; flex-wrap: wrap; gap: 6px 18px; font-size: .82rem; color: var(--encre-2); margin: 8px 0 0; }
.rp-legende span { display: inline-flex; align-items: center; gap: 6px; }
.rp-cle { display: inline-block; width: 11px; height: 11px; border-radius: 3px; background: var(--accent); }
.rp-cle.avant { background: color-mix(in oklab, var(--muet) 45%, var(--surface)); }

/* ---------- Barres horizontales ---------- */
.rp-barres { list-style: none; margin: 0; padding: 0; }
.rp-barres li { display: grid; grid-template-columns: minmax(110px, 34%) minmax(60px, 1fr) auto; gap: 12px; align-items: center; padding: 7px 4px; border-radius: 8px; outline: none; }
.rp-barres li:hover, .rp-barres li:focus-visible { background: var(--surface-2); }
.rp-lib { display: block; min-width: 0; font-weight: 560; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rp-lib .pastille { margin-right: 8px; }
.rp-lib a { color: inherit; }
.rp-piste { height: 10px; border-radius: 99px; background: var(--surface-3); overflow: hidden; }
.rp-rempli { display: block; height: 100%; border-radius: 0 99px 99px 0; background: var(--accent); min-width: 2px; }
.rp-val { text-align: right; font-weight: 650; font-variant-numeric: tabular-nums; white-space: nowrap; }
.rp-val small { display: block; font-weight: 500; color: var(--muet); font-size: .76rem; }
.rp-barres.empile li { grid-template-columns: minmax(0, 1fr) auto; gap: 2px 12px; }
.rp-barres.empile .rp-lib { grid-column: 1 / -1; white-space: normal; }
.rp-barres.empile .rp-piste { grid-row: 2; }

/* ---------- Divers ---------- */
.rp-liste-chiffres li strong { font-variant-numeric: tabular-nums; }
.rp-liste-chiffres li small { flex-basis: 100%; text-align: right; }
.rp-liste-chiffres li { flex-wrap: wrap; }
.rp-proportion { display: flex; height: 14px; border-radius: 99px; overflow: hidden; gap: 2px; background: var(--surface); margin: 6px 0; }
.rp-proportion .nouv { background: var(--accent); }
.rp-proportion .rev { background: color-mix(in oklab, var(--muet) 45%, var(--surface)); }
.rp-rang { display: inline-grid; place-items: center; min-width: 34px; height: 24px; padding: 0 6px; border-radius: 99px; font-size: .74rem; background: var(--surface-3); color: var(--encre-2); margin-right: 6px; }
.rp-rang.r1 { background: var(--accent); color: var(--sur-accent); }
.rp-courbe { width: 120px; height: 34px; flex: none; }
.rp-courbe .ligne { fill: none; stroke: var(--accent); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.rp-courbe .aire { fill: color-mix(in oklab, var(--accent) 12%, transparent); }
.rp-evolutions .detail { font-size: .76rem; }
.rp-bloc-mois .liste li strong { font-variant-numeric: tabular-nums; }
.rp-table-soins .rp-delta { justify-content: flex-end; }
.rp-detail-com summary { cursor: pointer; display: flex; gap: 10px; align-items: baseline; flex-wrap: wrap; padding: 2px 0; }
.rp-detail-com[open] summary { margin-bottom: 12px; }
.rp-detail-com summary::after { content: "Voir le détail"; margin-left: auto; color: var(--accent); font-size: .85rem; font-weight: 600; }
.rp-detail-com[open] summary::after { content: "Masquer"; }
.rp-detail-com .rp-remb td { color: var(--danger); }
.rp-imprime-titre { display: none; }
.rp-regles > summary { cursor: pointer; }
.rp-regles > summary .ic { color: var(--accent); }
.rp-regles[open] > summary { margin-bottom: 12px; }

/* Info-bulle des graphiques (rapports.js) */
.rp-bulle { position: fixed; z-index: 95; max-width: 260px; padding: 7px 10px; border-radius: 9px; background: var(--encre); color: var(--surface);
  font-size: .82rem; font-weight: 560; line-height: 1.35; pointer-events: none; box-shadow: var(--ombre-forte); }

@media (max-width: 720px) {
  .rp-comparer { margin-left: 0; }
  .rp-graph { padding-left: 38px; }
  .rp-axe span { left: 38px; }
  .rp-barres li { grid-template-columns: minmax(0, 1fr) auto; gap: 4px 10px; }
  .rp-barres .rp-piste { grid-column: 1 / -1; grid-row: 2; }
  .rp-col small { font-size: .62rem; }
  .rp-courbe { width: 90px; }
}

/* ---------- Commissions : impression ---------- */
@media print {
  .rp-filtres, .rp-comparer { display: none !important; }
  .rp-imprime-titre { display: block; margin-bottom: 10px; }
  .rp-detail-com { break-inside: avoid; }
  .rp-detail-com summary { list-style: none; }
  .rp-detail-com summary::after { content: none; }
  .rp-bulle { display: none; }
}

/* ---------- Bilan annuel (document A4) ---------- */
.rp-bilan-page { background: var(--surface-3); }
.rp-bilan-page .contenu-nu { display: block; place-items: normal; padding: 0 12px 40px; }
.rp-bilan-outils { position: sticky; top: 0; z-index: 20; max-width: 210mm; margin: 0 auto 14px; display: flex; flex-wrap: wrap; align-items: center; gap: 10px;
  padding: 10px 0; background: color-mix(in oklab, var(--surface-3) 90%, transparent); backdrop-filter: blur(8px); }
.rp-bilan-outils > a { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; text-decoration: none; margin-right: auto; }
.rp-annees { display: flex; align-items: center; gap: 2px; }
.rp-annees strong { font-size: 1.1rem; padding: 0 6px; }

/* le document garde ses couleurs de papier, même en mode sombre */
.rp-bilan { --surface: #fff; --surface-2: #faf8f7; --surface-3: #f1ece9; --encre: #241d21; --encre-2: #54474e; --muet: #7a6c73; --ligne: #e9e2df; --ligne-forte: #d8cfcb;
  --ok: #2f7d55; --ok-doux: #e5f3ec; --info: #2c6aa8; --info-doux: #e6eff8; --alerte: #a8650f; --alerte-doux: #fbf0dc; --danger: #c0392b; --danger-doux: #fbe7e4;
  --accent-doux: color-mix(in oklab, var(--accent) 11%, white); --accent-fonce: color-mix(in oklab, var(--accent) 82%, black);
  color-scheme: light; color: var(--encre); max-width: 210mm; margin: 0 auto; }
.rp-feuille { background: #fff; padding: 13mm 14mm; margin-bottom: 14px; border-radius: 6px; box-shadow: var(--ombre); }
.rp-feuille h2 { font-size: 1.3rem; color: var(--accent-fonce); margin-bottom: 4px; font-family: Georgia, "Times New Roman", serif; font-weight: 600; letter-spacing: 0; }
.rp-feuille h3 { font-size: .95rem; margin: 10px 0 8px; }
.rp-intro, .rp-note { color: var(--muet); font-size: .9rem; }
.rp-couverture { min-height: 250mm; display: flex; flex-direction: column; justify-content: center; text-align: center; position: relative; overflow: hidden;
  background: linear-gradient(160deg, var(--accent-doux), #fff 55%); }
.rp-couverture::before { content: ""; position: absolute; inset: 9mm; border: 1px solid color-mix(in oklab, var(--accent) 35%, white); border-radius: 4px; pointer-events: none; }
.rp-sur-titre { text-transform: uppercase; letter-spacing: .3em; font-size: .8rem; color: var(--accent-fonce); font-weight: 650; }
.rp-couverture h1 { font-family: Georgia, "Times New Roman", serif; font-size: 2.4rem; font-weight: 500; margin: 6px 0; }
.rp-annee { font-family: Georgia, "Times New Roman", serif; font-size: 5.5rem; line-height: 1; color: var(--accent); margin: 12px 0; }
.rp-sous { font-size: 1.05rem; color: var(--encre-2); }
.rp-couverture .note { max-width: 420px; margin: 16px auto 0; text-align: left; }
.rp-prepare { margin-top: 40px; color: var(--muet); font-size: .9rem; }
.rp-tuiles { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; margin-top: 12px; }
.rp-tuiles.trois { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.rp-tuile { border: 1px solid var(--ligne); border-radius: 10px; padding: 12px; display: flex; flex-direction: column; gap: 2px; break-inside: avoid; }
.rp-tuile > span { font-size: .78rem; color: var(--muet); font-weight: 600; }
.rp-tuile strong { font-size: 1.35rem; font-weight: 700; letter-spacing: -.01em; }
.rp-tuile strong small { font-size: .8rem; color: var(--muet); font-weight: 600; }
.rp-tuile > small { color: var(--muet); font-size: .76rem; }
.rp-table-bilan { width: 100%; border-collapse: collapse; margin-top: 14px; font-size: .88rem; }
.rp-table-bilan th { text-align: left; font-size: .72rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muet); border-bottom: 1px solid var(--ligne-forte); padding: 6px; }
.rp-table-bilan td { border-bottom: 1px solid var(--ligne); padding: 6px; vertical-align: top; }
.rp-table-bilan .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.rp-table-bilan .rp-delta { justify-content: flex-end; }
.rp-futur td { color: var(--muet); }
.rp-plan td:nth-child(2) { white-space: nowrap; }
.rp-plan em { color: var(--accent-fonce); font-style: normal; font-size: .84rem; }
.rp-deux { display: grid; grid-template-columns: 1.4fr 1fr; gap: 22px; }
.rp-classement { margin: 0; padding: 0; list-style: none; counter-reset: rang; }
.rp-classement li { display: flex; gap: 10px; align-items: baseline; padding: 7px 0; border-bottom: 1px solid var(--ligne); counter-increment: rang; }
.rp-classement li::before { content: counter(rang) "."; color: var(--muet); min-width: 1.3em; font-variant-numeric: tabular-nums; }
.rp-classement li span { flex: 1; }
.rp-classement li strong { font-variant-numeric: tabular-nums; }
.rp-pistes { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin-top: 12px; }
.rp-piste-carte { border: 1px solid var(--ligne); border-left: 3px solid var(--accent); border-radius: 8px; padding: 12px 14px; break-inside: avoid; }
.rp-piste-carte h3 { display: flex; align-items: center; gap: 8px; margin: 0 0 6px; font-size: .98rem; }
.rp-piste-carte h3 .ic { color: var(--accent); }
.rp-piste-carte p { margin: 0 0 6px; font-size: .88rem; }
.rp-constat { color: var(--encre-2); }
.rp-mot { margin-bottom: 18px; }
.rp-signatures { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; margin: 18px 0; }
.rp-signatures > div { border: 1px solid var(--ligne-forte); border-radius: 8px; padding: 12px 14px; min-height: 42mm; display: flex; flex-direction: column; }
.rp-sig-titre { font-weight: 700; margin: 0; }
.rp-sig-zone { margin-top: auto; color: var(--muet); font-size: .8rem; border-top: 1px dashed var(--ligne-forte); padding-top: 4px; }
.rp-mention { font-size: .8rem; color: var(--muet); text-align: center; }
.rp-mention a { color: var(--accent-fonce); }

@media (max-width: 720px) {
  .rp-feuille { padding: 18px 14px; }
  .rp-couverture { min-height: 70vh; }
  .rp-annee { font-size: 3.6rem; }
  .rp-couverture h1 { font-size: 1.7rem; }
  .rp-tuiles, .rp-tuiles.trois { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .rp-deux, .rp-pistes, .rp-signatures { grid-template-columns: 1fr; }
  .rp-plan td:nth-child(2) { white-space: normal; }
}
@media print {
  @page { size: A4; margin: 12mm; }
  .rp-bilan-page { background: #fff; }
  .rp-bilan-page .contenu-nu { padding: 0; }
  .rp-bilan { max-width: none; }
  .rp-feuille { box-shadow: none; border-radius: 0; padding: 0 0 8mm; margin: 0; }
  .rp-couverture { min-height: 260mm; break-after: page; padding: 0; }
  .rp-feuille + .rp-feuille:not(.rp-couverture) { border-top: 1px solid var(--ligne); padding-top: 6mm; }
  .rp-fin { break-inside: avoid; }
  .rp-bilan a { color: inherit; }
}
.rp-consolide td:first-child { white-space: nowrap; }
