/* Rapport des appels (V3, suivi par ligne d'agence) : écran et feuille d'impression.
   Jetons et composants de app.css seulement ; classes propres préfixées m-rapport-. Cases bien séparées : fond --fond, cartes blanches bordées. */

/* ===== Barre de choix : période, flèches, ligne ===== */
.m-rapport-outils {
  display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; margin: -8px 0 24px; padding: 10px 12px;
  background: var(--surface); border: 1px solid var(--contour-carte); border-radius: var(--r-l); box-shadow: var(--ombre-carte);
}
.m-rapport-outils > .segments { flex: none; }
.m-rapport-navigation { display: flex; align-items: center; gap: 6px; flex: 1 1 340px; min-width: 0; }
.m-rapport-fleche { flex: none; width: 40px; height: 40px; padding: 0; background: var(--surface); box-shadow: inset 0 0 0 1px var(--separateur-fort); }
.m-rapport-fleche svg { width: 18px; height: 18px; }
@media (hover: hover) { .m-rapport-fleche:hover { background: var(--survol-ligne); } }
.m-rapport-fleche[aria-disabled="true"] { opacity: .4; cursor: default; transform: none; background: var(--surface); }
.m-rapport-periode {
  flex: 1 1 auto; min-width: 0; margin: 0; padding: 0 6px; text-align: center;
  font: 650 1rem/1.3 var(--police); letter-spacing: -0.012em; color: var(--texte); font-variant-numeric: tabular-nums;
}
.m-rapport-periode:focus { outline: none; }
.m-rapport-periode:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: var(--r-s); }
.m-rapport-maintenant { flex: none; }
.m-rapport-choix-ligne { display: flex; align-items: center; gap: 10px; margin-left: auto; min-width: 0; }
.m-rapport-choix-ligne label { font: 600 0.8125rem/1.3 var(--police); letter-spacing: 0; color: var(--texte-2); white-space: nowrap; }
.m-rapport-select { width: 240px; max-width: 100%; text-overflow: ellipsis; }
.m-rapport-ligne-fixe { margin: 0 0 0 auto; font: 600 0.9375rem/1.3 var(--police); color: var(--texte); overflow-wrap: anywhere; }

/* ===== Résultats ===== */
.m-rapport-resultats { display: grid; gap: 20px; min-width: 0; transition: opacity var(--d-rapide) var(--c-standard); }
.m-rapport-resultats[aria-busy="true"] { opacity: .5; }
.m-rapport-vide {
  margin: 0; padding: 14px 16px; border-radius: var(--r-m); background: var(--surface-inset);
  font: 500 0.9375rem/1.5 var(--police); color: var(--texte-2);
}
.m-rapport-titre-section { margin: 8px 0 14px; font: 700 1.25rem/1.3 var(--police); letter-spacing: -0.018em; }

/* Indicateur de chargement (bouton « Générer maintenant », état du récap) */
.m-rapport-chargeur {
  width: 14px; height: 14px; flex: none; border-radius: 50%; border: 2px solid var(--separateur-fort); border-top-color: var(--accent);
  animation: m-rapport-tourne .8s linear infinite;
}
@keyframes m-rapport-tourne { to { transform: rotate(360deg); } }

/* ===== Récap du soir de Léa (avatar libre, jamais dans une bulle : règle globale de app.css) ===== */
.m-rapport-recap { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 0 22px; align-items: start; }
.m-rapport-recap-lea { display: block; height: 104px; aspect-ratio: 170 / 192; margin-top: 2px; }
.m-rapport-recap-lea img { display: block; width: 100%; height: 100%; }
.m-rapport-recap-corps { min-width: 0; }
.m-rapport-recap-tete { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px 16px; flex-wrap: wrap; }
.m-rapport-recap-titres { min-width: 0; }
.m-rapport-recap-tete h2 { margin: 0; font: 700 1.125rem/1.3 var(--police); letter-spacing: -0.016em; }
.m-rapport-recap-tete h2:focus { outline: none; }
.m-rapport-recap-quand { margin: 3px 0 0; font: 400 0.8125rem/1.45 var(--police); letter-spacing: 0; color: var(--texte-2); }
.m-rapport-recap-qui { font-weight: 600; color: var(--texte); }
.m-rapport-generer { flex: none; }
.m-rapport-generer[aria-disabled="true"] { cursor: progress; transform: none; }
.m-rapport-recap-texte { margin-top: 14px; max-width: 80ch; font: 400 0.9375rem/1.6 var(--police); color: var(--texte); }
.m-rapport-recap-texte p { margin: 0 0 10px; }
.m-rapport-recap-texte ul { margin: 0 0 10px; padding-left: 20px; display: grid; gap: 6px; }
.m-rapport-recap-texte li { padding-left: 2px; }
.m-rapport-recap-texte li::marker { color: var(--accent); }
.m-rapport-recap-texte strong { font-weight: 650; }
.m-rapport-recap-texte .m-rapport-recap-intertitre { margin: 14px 0 6px; font-weight: 650; }
.m-rapport-recap-texte > :last-child { margin-bottom: 0; }
.m-rapport-recap-phrase { margin: 14px 0 0; max-width: 70ch; font: 400 0.9375rem/1.55 var(--police); color: var(--texte-2); }
.m-rapport-recap-etat {
  display: flex; align-items: center; gap: 10px; margin: 14px 0 0; padding: 10px 14px; border-radius: var(--r-m);
  background: var(--accent-teinte); color: var(--accent-texte); font: 500 0.875rem/1.45 var(--police);
}
.m-rapport-recap-etat.m-rapport-recap-erreur { background: var(--rouge-pale); color: var(--rouge-texte); }
.m-rapport-recap-etat svg { width: 16px; height: 16px; flex: none; }

/* ===== Ensemble des lignes : chiffres en cases séparées par des filets ===== */
.m-rapport-ensemble .carte-tete { flex-wrap: wrap; }
.m-rapport-chiffres {
  display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 1px; margin: 4px 0 0;
  background: var(--separateur); border: 1px solid var(--separateur); border-radius: var(--r-m); overflow: hidden;
}
.m-rapport-chiffre { display: grid; align-content: start; gap: 4px; min-width: 0; padding: 16px 18px 18px; background: var(--surface); }
.m-rapport-chiffre dt { font: 600 0.8125rem/1.3 var(--police); letter-spacing: 0; color: var(--texte-2); }
.m-rapport-chiffre dd { margin: 0; }
.m-rapport-chiffre-valeur { margin-top: 4px !important; font: 700 1.75rem/1.1 var(--police); letter-spacing: -0.03em; white-space: nowrap; font-variant-numeric: tabular-nums; }
.m-rapport-chiffre-detail { font: 400 0.8125rem/1.45 var(--police); letter-spacing: 0; color: var(--texte-2); }

/* ===== Par ligne d'agence ===== */
.m-rapport-lignes { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; align-items: stretch; }
.m-rapport-ligne { display: grid; grid-template-rows: auto 1fr auto; gap: 16px; }
.m-rapport-ligne > .m-rapport-vide { align-self: start; }
.m-rapport-ligne-tete { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px 12px; flex-wrap: wrap; }
.m-rapport-ligne-titres { min-width: 0; }
.m-rapport-ligne h3 { margin: 0; font: 700 1.0625rem/1.3 var(--police); letter-spacing: -0.014em; overflow-wrap: anywhere; }
.m-rapport-ligne-numero { margin: 3px 0 0; font: 400 0.8125rem/1.4 var(--police); letter-spacing: 0; color: var(--texte-2); font-variant-numeric: tabular-nums; }
.m-rapport-pastilles-ligne { display: flex; flex-wrap: wrap; gap: 6px; }
.m-rapport-mini { display: grid; grid-template-columns: repeat(auto-fill, minmax(124px, 1fr)); gap: 16px 18px; margin: 0; align-content: start; }
.m-rapport-mini > div { display: grid; align-content: start; gap: 2px; min-width: 0; }
.m-rapport-mini dt { font: 500 0.8125rem/1.3 var(--police); letter-spacing: 0; color: var(--texte-2); }
.m-rapport-mini dd { margin: 0; }
.m-rapport-mini-valeur { margin-top: 2px !important; font: 700 1.3125rem/1.2 var(--police); letter-spacing: -0.02em; white-space: nowrap; font-variant-numeric: tabular-nums; }
.m-rapport-mini-detail { font: 400 0.8125rem/1.4 var(--police); letter-spacing: 0; color: var(--texte-2); }
.m-rapport-ligne-pied {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 4px 14px; padding-top: 12px;
  border-top: 1px solid var(--separateur); font: 400 0.8125rem/1.45 var(--police); letter-spacing: 0; color: var(--texte-2);
}

/* ===== Répartitions en barres ===== */
.m-rapport-repartitions { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 20px; align-items: start; }
.m-rapport-barres { list-style: none; margin: 0; padding: 4px 0 0; display: grid; gap: 14px; }
.m-rapport-barre { display: grid; grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "nom n" "piste piste"; gap: 6px 12px; align-items: baseline; }
.m-rapport-barre-nom { grid-area: nom; min-width: 0; font: 500 0.875rem/1.35 var(--police); color: var(--texte); }
.m-rapport-barre-n { grid-area: n; font: 650 0.875rem/1.35 var(--police); white-space: nowrap; font-variant-numeric: tabular-nums; }
.m-rapport-barre-pct { margin-left: 8px; font-weight: 400; color: var(--texte-2); }
.m-rapport-barre-piste { grid-area: piste; display: block; height: 8px; border-radius: var(--r-capsule); background: var(--remplissage); overflow: hidden; }
.m-rapport-barre-remplie { display: block; height: 100%; border-radius: inherit; background: var(--texte-3); }
.m-rapport-barre-remplie.t-bleu { background: var(--accent); }
.m-rapport-barre-remplie.t-vert { background: var(--vert); }
.m-rapport-barre-remplie.t-ambre { background: var(--ambre); }
.m-rapport-barre-remplie.t-rose { background: var(--action); }
.m-rapport-barre-remplie.t-rouge { background: var(--rouge); }
.m-rapport-barre-remplie.t-contour { background: var(--separateur-fort); }

/* ===== Appels de la période ===== */
.m-rapport-jours { display: grid; gap: 18px; }
.m-rapport-jour-titre {
  display: flex; align-items: baseline; flex-wrap: wrap; gap: 4px 10px; margin: 0 0 2px; padding-top: 4px;
  font: 650 0.9375rem/1.3 var(--police); letter-spacing: -0.01em; color: var(--texte);
}
.m-rapport-jour-n { font: 400 0.8125rem/1.3 var(--police); letter-spacing: 0; color: var(--texte-2); }
.m-rapport-appels { display: grid; margin: 0 -12px; }
.m-rapport-appel {
  position: relative; display: grid; grid-template-columns: 72px minmax(0, 1fr) 16px; gap: 0 14px; align-items: start;
  min-width: 0; padding: 12px; border-radius: 14px; color: inherit; text-decoration: none;
  transition: background-color var(--d-rapide) var(--c-standard);
}
.m-rapport-appel + .m-rapport-appel::before { content: ''; position: absolute; top: 0; left: 12px; right: 12px; height: 1px; background: var(--separateur); }
@media (hover: hover) {
  .m-rapport-appel:hover { background: var(--survol-ligne); text-decoration: none; }
  .m-rapport-appel:hover::before, .m-rapport-appel:hover + .m-rapport-appel::before { opacity: 0; }
  .m-rapport-appel:hover .m-rapport-appel-chevron { color: var(--accent); }
}
.m-rapport-appel:active { background: var(--remplissage); }
.m-rapport-appel:focus-visible { outline-offset: -2px; }
.m-rapport-appel-quand { display: grid; gap: 2px; min-width: 0; padding-top: 1px; }
.m-rapport-appel-heure { font: 650 0.9375rem/1.4 var(--police); letter-spacing: -0.01em; color: var(--texte); font-variant-numeric: tabular-nums; }
.m-rapport-appel-duree { font: 400 0.8125rem/1.4 var(--police); letter-spacing: 0; color: var(--texte-2); }
.m-rapport-appel-corps { display: grid; gap: 4px; min-width: 0; }
.m-rapport-appel-tete { font: 600 0.8125rem/1.45 var(--police); letter-spacing: 0; color: var(--texte-2); }
.m-rapport-appel-lea { display: inline-flex; align-items: center; gap: 5px; color: var(--texte); white-space: nowrap; }
.m-rapport-appel-lea-img { display: block; height: 22px; aspect-ratio: 170 / 192; margin: -3px 0; }
.m-rapport-appel-lea-img img { display: block; width: 100%; height: 100%; }
.m-rapport-appel-resume {
  font: 400 0.9375rem/1.5 var(--police); letter-spacing: -0.006em; color: var(--texte); overflow-wrap: anywhere;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.m-rapport-appel-pastilles { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }
.m-rapport-appel-pastilles .pastille { height: 24px; padding: 0 9px; }
.m-rapport-appel-chevron { width: 16px; height: 16px; margin-top: 3px; color: #A0A7C3; transition: color var(--d-rapide) var(--c-standard); }

/* Erreur de chargement */
.m-rapport-erreur { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 14px; align-items: start; }
.m-rapport-erreur-icone { display: grid; place-items: center; width: 40px; height: 40px; border-radius: 50%; background: var(--rouge-pale); color: var(--rouge-texte); }
.m-rapport-erreur-icone svg { width: 20px; height: 20px; }
.m-rapport-erreur h2 { margin: 0; font: 700 1.125rem/1.3 var(--police); }
.m-rapport-erreur p { margin: 4px 0 14px; color: var(--texte-2); }

/* En-tête du papier : jamais à l'écran */
.m-rapport-impression { display: none; }

/* ===== Largeurs ===== */
@media (max-width: 1279px) {
  .m-rapport-repartitions { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .m-rapport-repartitions > :last-child { grid-column: 1 / -1; }
}
@media (max-width: 1099px) {
  .m-rapport-choix-ligne { margin-left: 0; }
  .m-rapport-navigation { flex-basis: 300px; }
}
@media (max-width: 899px) {
  .m-rapport-lignes { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 760px) {
  .m-rapport-chiffres { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 640px) {
  .m-rapport-outils { gap: 10px; padding: 10px; margin-top: -12px; }
  .m-rapport-outils > .segments { flex: 1 1 100%; }
  .m-rapport-outils > .segments button { flex: 1 1 0; justify-content: center; }
  .m-rapport-navigation { flex: 1 1 100%; }
  .m-rapport-periode { font-size: 0.9375rem; }
  .m-rapport-maintenant { flex: 1 1 100%; }
  .m-rapport-choix-ligne { flex: 1 1 100%; flex-wrap: wrap; gap: 6px; }
  .m-rapport-choix-ligne label { flex: 1 1 100%; }
  .m-rapport-select { width: 100%; height: 44px; font-size: 1rem; }
  .m-rapport-ligne-fixe { margin: 0; }
  /* Récap : Léa et le titre côte à côte, puis le texte et le bouton sur toute la largeur */
  .m-rapport-recap { gap: 0 14px; }
  .m-rapport-recap-corps, .m-rapport-recap-tete { display: contents; }
  .m-rapport-recap-lea { height: 60px; margin: 0; }
  .m-rapport-recap-titres { align-self: center; }
  .m-rapport-recap-texte, .m-rapport-recap-phrase, .m-rapport-recap-etat, .m-rapport-generer { grid-column: 1 / -1; }
  .m-rapport-generer { order: 2; width: 100%; margin-top: 14px; }
  .m-rapport-recap-etat { order: 3; }
  .m-rapport-chiffre { padding: 14px 14px 16px; }
  .m-rapport-chiffre-valeur { font-size: 1.5rem; }
  .m-rapport-repartitions { grid-template-columns: minmax(0, 1fr); }
  .m-rapport-repartitions > :last-child { grid-column: auto; }
  .m-rapport-appel { grid-template-columns: 56px minmax(0, 1fr) 16px; gap: 0 10px; }
  .m-rapport-appel-resume { -webkit-line-clamp: 3; }
}
@media (max-width: 640px), (pointer: coarse) {
  .m-rapport-maintenant { min-height: 40px; }
}
@media (prefers-reduced-motion: reduce) {
  .m-rapport-resultats, .m-rapport-appel, .m-rapport-appel-chevron { transition: none; }
  .m-rapport-chargeur { animation: none; border-top-color: var(--separateur-fort); border-right-color: var(--accent); }
  .m-rapport-fleche:active, .m-rapport-generer:active { transform: none; }
}

/* ===== Feuille d'impression : seul le rapport, noir sur blanc, sans navigation ni boutons ===== */
@page {
  size: A4; margin: 14mm 13mm 16mm;
  @bottom-right { content: "Page " counter(page) " sur " counter(pages); font: 400 8pt/1 'Inter', Arial, sans-serif; color: #444444; }
}
@media print {
  html, body { background: #FFFFFF !important; }
  body:has(.m-rapport) > :not(#app) { display: none !important; }
  body:has(.m-rapport) .coque { display: block !important; min-height: 0 !important; background: none !important; }
  body:has(.m-rapport) .coque > :not(.principal) { display: none !important; }
  body:has(.m-rapport) .principal { max-width: none !important; margin: 0 !important; padding: 0 !important; }
  body:has(.m-rapport) .page { animation: none !important; }

  .m-rapport, .m-rapport * { color: #000000 !important; box-shadow: none !important; text-shadow: none !important; }
  .m-rapport { font-size: 10pt; }
  .m-rapport .entete, .m-rapport-outils, .m-rapport-sans-impression, .m-rapport-generer, .m-rapport-recap-etat, .m-rapport-appel-chevron { display: none !important; }

  .m-rapport-impression {
    display: grid !important; grid-template-columns: auto minmax(0, 1fr) auto; gap: 0 18px; align-items: center;
    margin: 0 0 16px; padding: 0 0 12px; border-bottom: 2px solid #000000;
  }
  .m-rapport-impression-logo { display: block; width: auto; height: 52px; }
  .m-rapport-impression-titres p { margin: 0; }
  .m-rapport-impression-produit { font: 600 8.5pt/1.3 var(--police); letter-spacing: .02em; }
  .m-rapport-impression-titre { font: 700 17pt/1.2 var(--police); letter-spacing: -0.01em; }
  .m-rapport-impression-agence { font: 600 11pt/1.3 var(--police); }
  .m-rapport-impression-infos { display: grid; gap: 2px; margin: 0; font: 400 9pt/1.35 var(--police); text-align: right; }
  .m-rapport-impression-infos div { display: flex; justify-content: flex-end; gap: 6px; }
  .m-rapport-impression-infos dt { font-weight: 600; }
  .m-rapport-impression-infos dt::after { content: ' :'; }
  .m-rapport-impression-infos dd { margin: 0; }

  .m-rapport-resultats { display: block !important; opacity: 1 !important; }
  .m-rapport-resultats > * + * { margin-top: 12px; }
  .m-rapport .carte { padding: 12px 14px 14px; border: 1px solid #8A8F9C !important; border-radius: 8px; background: #FFFFFF !important; break-inside: avoid; page-break-inside: avoid; }
  .m-rapport .carte-tete { margin-bottom: 8px; }
  .m-rapport .carte-tete h2, .m-rapport-recap-tete h2 { font-size: 12pt; }
  .m-rapport .carte-sous, .m-rapport-recap-quand { font-size: 8.5pt; }
  .m-rapport .carte-pied { border-top-color: #8A8F9C; font-size: 8.5pt; }
  .m-rapport-titre-section { margin: 4px 0 8px; font-size: 13pt; break-after: avoid; page-break-after: avoid; }

  .m-rapport-recap-lea { height: 64px; }
  .m-rapport-recap-texte, .m-rapport-recap-phrase { margin-top: 8px; font-size: 10pt; line-height: 1.5; max-width: none; }
  .m-rapport-recap-texte li::marker { color: #000000; }

  .m-rapport-chiffres { grid-template-columns: repeat(4, minmax(0, 1fr)); background: #8A8F9C !important; border-color: #8A8F9C !important; border-radius: 6px; }
  .m-rapport-chiffres, .m-rapport-barre-piste, .m-rapport-barre-remplie { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .m-rapport-chiffre { padding: 8px 10px 9px; background: #FFFFFF !important; }
  .m-rapport-chiffre dt, .m-rapport-chiffre-detail { font-size: 8pt; }
  .m-rapport-chiffre-valeur { font-size: 15pt; }

  .m-rapport-lignes { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .m-rapport-ligne { gap: 8px; }
  .m-rapport-ligne h3 { font-size: 11pt; }
  .m-rapport-ligne-numero, .m-rapport-mini dt, .m-rapport-mini-detail, .m-rapport-ligne-pied { font-size: 8pt; }
  .m-rapport-mini { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px 10px; }
  .m-rapport-mini-valeur { font-size: 12pt; }
  .m-rapport-ligne-pied { padding-top: 6px; border-top-color: #8A8F9C; }
  .m-rapport-vide { padding: 6px 0; background: none !important; font-size: 9.5pt; }

  .m-rapport-repartitions { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
  .m-rapport-repartitions > :last-child { grid-column: auto; }
  .m-rapport-barres { gap: 7px; }
  .m-rapport-barre { gap: 3px 8px; }
  .m-rapport-barre-nom, .m-rapport-barre-n { font-size: 8.5pt; }
  .m-rapport-barre-piste { height: 6px; background: #E2E2E2 !important; }
  .m-rapport-barre-remplie, .m-rapport-barre-remplie[class*="t-"] { background: #2B2B2B !important; }

  .m-rapport .pastille { height: auto; padding: 1px 6px; background: none !important; box-shadow: inset 0 0 0 1px #6B6B6B !important; font-size: 7.5pt; }
  .m-rapport .pastille::before, .m-rapport .pastille::after { display: none; }

  /* La liste des appels court sur plusieurs pages : sur papier, sans cadre (un cadre coupé laisserait des morceaux de bordure,
     voire une page vide), un filet sous son titre ; chaque appel reste entier. */
  .m-rapport .carte.m-rapport-carte-appels { padding: 0; border: 0 !important; border-radius: 0; break-inside: auto !important; page-break-inside: auto !important; }
  .m-rapport-carte-appels > .carte-tete { margin-bottom: 6px; padding-bottom: 6px; border-bottom: 2px solid #000000; break-after: avoid; page-break-after: avoid; }
  .m-rapport-jours { gap: 8px; }
  .m-rapport-jour-titre { margin: 0; padding: 4px 0 2px; font-size: 10pt; border-bottom: 1px solid #8A8F9C; break-after: avoid; page-break-after: avoid; }
  .m-rapport-appels { margin: 0; }
  .m-rapport-appel { grid-template-columns: 64px minmax(0, 1fr); gap: 0 10px; padding: 6px 0; border-radius: 0; break-inside: avoid; page-break-inside: avoid; }
  .m-rapport-appel + .m-rapport-appel::before { left: 0; right: 0; background: #C4C4C4; }
  .m-rapport-appel-heure { font-size: 9.5pt; }
  .m-rapport-appel-duree, .m-rapport-appel-tete { font-size: 8pt; }
  .m-rapport-appel-resume { display: block; overflow: visible; -webkit-line-clamp: unset; font-size: 9.5pt; line-height: 1.45; }
  .m-rapport-appel-pastilles { margin-top: 2px; gap: 4px; }
  .m-rapport-appel-lea-img { height: 16px; }
  .m-rapport a { text-decoration: none !important; }
}
