/* =========================================================================
   Vues : tableau de bord, bande de caisse, reçu, encaissement, portail.
   ========================================================================= */

/* ------------------------------------------------------------------ En-tête de vue */

.entete-vue { display: flex; align-items: flex-end; gap: 16px; flex-wrap: wrap; margin-bottom: 18px; }
.entete-vue .titre { font-family: var(--display); font-size: 1.55rem; font-weight: 700; letter-spacing: -0.03em; }
.entete-vue .sous { color: var(--encre-2); font-size: 13.5px; }
.entete-vue .actions { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; }

.barre-filtres {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 10px 12px; margin-bottom: 16px;
  background: var(--surface); border: 1px solid var(--trait); border-radius: var(--r-md);
}

/* ------------------------------------------------------------------ Tuiles d'indicateurs */

.tuiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(196px, 1fr)); gap: 14px; margin-bottom: 18px; }

.tuile {
  position: relative;
  padding: 15px 16px 14px;
  background: var(--surface);
  border: 1px solid var(--trait);
  border-radius: var(--r-lg);
  box-shadow: var(--ombre-1);
  overflow: hidden;
  animation: montee-tuile 0.45s cubic-bezier(0.2, 0, 0, 1) backwards;
}
.tuile:nth-child(1) { animation-delay: 0.02s; }
.tuile:nth-child(2) { animation-delay: 0.06s; }
.tuile:nth-child(3) { animation-delay: 0.1s; }
.tuile:nth-child(4) { animation-delay: 0.14s; }
.tuile:nth-child(5) { animation-delay: 0.18s; }
.tuile:nth-child(6) { animation-delay: 0.22s; }
@keyframes montee-tuile { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

.tuile .valeur {
  font-family: var(--chiffres);
  font-variant-numeric: tabular-nums;
  font-size: 26px;
  font-weight: 600;
  letter-spacing: -0.045em;
  line-height: 1.1;
  margin-top: 6px;
}
.tuile .valeur .unite { font-size: 13px; font-weight: 500; color: var(--encre-3); letter-spacing: 0; margin-left: 3px; }
.tuile .pied { display: flex; align-items: center; gap: 6px; margin-top: 7px; font-size: 12px; color: var(--encre-3); }
.tuile .fond-courbe { position: absolute; inset: auto 0 0; height: 42px; opacity: 0.5; pointer-events: none; }
.tuile.accent-argent .valeur { color: var(--safran); }
.tuile.accent-brique .valeur { color: var(--brique); }
.tuile.accent-jade .valeur { color: var(--jade); }

/* ------------------------------------------------------------------ Bande de caisse (ticker temps réel) */

.bande-caisse { display: flex; flex-direction: column; height: 100%; min-height: 320px; }

.bande-flux {
  flex: 1;
  overflow-y: auto;
  max-height: 430px;
  background:
    repeating-linear-gradient(var(--surface) 0 27px, color-mix(in srgb, var(--surface-2) 70%, transparent) 27px 28px);
}

.bande-ligne {
  display: grid;
  grid-template-columns: 46px 1fr auto;
  align-items: baseline;
  gap: 10px;
  padding: 8px 16px;
  border-bottom: 1px dashed var(--trait);
  font-size: 13px;
}
.bande-ligne .heure { font-family: var(--chiffres); font-size: 11px; color: var(--encre-3); }
.bande-ligne .qui { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bande-ligne .qui b { font-weight: 600; }
.bande-ligne .qui small { display: block; color: var(--encre-3); font-size: 11px; }
.bande-ligne .somme {
  font-family: var(--chiffres);
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  letter-spacing: -0.03em;
  color: var(--safran);
}
.bande-ligne.neuve { animation: entree-bande 0.6s cubic-bezier(0.2, 0, 0, 1); }
@keyframes entree-bande {
  0% { opacity: 0; transform: translateY(-14px); background: var(--safran-voile); }
  60% { background: var(--safran-voile); }
  100% { opacity: 1; transform: none; background: transparent; }
}

.bande-pied {
  display: flex; align-items: center; justify-content: space-between;
  padding: 11px 16px;
  border-top: 1px solid var(--trait);
  background: var(--surface-2);
}

/* ------------------------------------------------------------------ Graphiques */

.graphique { width: 100%; display: block; overflow: visible; }
.graphique text { font-family: var(--corps); font-size: 10.5px; fill: var(--encre-3); }
.graphique .quadrillage { stroke: var(--trait); stroke-width: 1; stroke-dasharray: 2 4; }
.graphique .courbe { fill: none; stroke: var(--indigo); stroke-width: 2.2; stroke-linejoin: round; stroke-linecap: round; }
.graphique .aire { fill: url(#degrade-indigo); }
.graphique .barre { fill: var(--indigo); }
.graphique .point { fill: var(--surface); stroke: var(--indigo); stroke-width: 2; }
.graphique .curseur { stroke: var(--encre-3); stroke-width: 1; stroke-dasharray: 3 3; }

.legende { display: flex; flex-wrap: wrap; gap: 12px; padding-top: 10px; font-size: 12px; }
.legende span { display: inline-flex; align-items: center; gap: 6px; color: var(--encre-2); }
.legende i { width: 9px; height: 9px; border-radius: 3px; }

.infobulle {
  position: fixed;
  z-index: 300;
  pointer-events: none;
  padding: 7px 10px;
  border-radius: var(--r-sm);
  background: var(--encre);
  color: var(--papier);
  font-size: 12px;
  box-shadow: var(--ombre-2);
  white-space: nowrap;
}
:root[data-theme='sombre'] .infobulle { background: var(--surface-3); color: var(--encre); border: 1px solid var(--trait); }

/* ------------------------------------------------------------------ Liste établissements du tableau de bord */

.rang-etab {
  display: grid;
  grid-template-columns: 1fr 92px 120px;
  align-items: center;
  gap: 12px;
  padding: 11px 18px;
  border-bottom: 1px solid var(--trait);
  cursor: pointer;
}
.rang-etab:last-child { border-bottom: 0; }
.rang-etab:hover { background: var(--surface-2); }
.rang-etab .nom { font-weight: 600; font-size: 13.5px; display: flex; align-items: center; gap: 8px; }
.rang-etab .nom i { width: 9px; height: 9px; border-radius: 3px; flex: none; }
.rang-etab .detail { font-size: 11.5px; color: var(--encre-3); margin-left: 17px; }

/* ------------------------------------------------------------------ Encaissement */

.encaissement { display: grid; grid-template-columns: minmax(320px, 420px) 1fr; gap: 16px; align-items: start; }
@media (max-width: 1100px) { .encaissement { grid-template-columns: 1fr; } }

.resultat-eleve {
  display: flex; align-items: center; gap: 11px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--trait);
  cursor: pointer;
  width: 100%;
  border-left: 0; border-right: 0; border-top: 0;
  background: transparent;
  text-align: left;
  color: inherit;
}
.resultat-eleve:hover, .resultat-eleve[aria-selected='true'] { background: var(--indigo-voile); }
.resultat-eleve .solde { margin-left: auto; font-family: var(--chiffres); font-weight: 600; font-size: 13px; }

.pave-montant {
  font-family: var(--chiffres);
  font-size: 34px;
  font-weight: 600;
  letter-spacing: -0.05em;
  text-align: right;
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--trait-fort);
  border-radius: var(--r-md);
  background: var(--surface-2);
  color: var(--encre);
}
.pave-montant:focus { outline: none; border-color: var(--safran); box-shadow: 0 0 0 3px color-mix(in srgb, var(--safran) 20%, transparent); }

.raccourcis-montant { display: flex; gap: 6px; flex-wrap: wrap; }
.raccourcis-montant button {
  flex: 1;
  min-width: 78px;
  padding: 7px 6px;
  border: 1px solid var(--trait);
  border-radius: var(--r-sm);
  background: var(--surface);
  font-family: var(--chiffres);
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  color: var(--encre-2);
}
.raccourcis-montant button:hover { border-color: var(--safran); color: var(--safran); background: var(--safran-voile); }

.modes-paiement { display: grid; grid-template-columns: repeat(4, 1fr); gap: 7px; }
.modes-paiement button {
  display: flex; flex-direction: column; align-items: center; gap: 5px;
  padding: 10px 4px;
  border: 1px solid var(--trait);
  border-radius: var(--r-sm);
  background: var(--surface);
  cursor: pointer;
  font-size: 11.5px;
  font-weight: 550;
  color: var(--encre-2);
  transition: border-color 0.14s, background 0.14s, color 0.14s;
}
.modes-paiement button svg { width: 19px; height: 19px; stroke-width: 1.6; }
.modes-paiement button[aria-pressed='true'] { border-color: var(--indigo); background: var(--indigo-voile); color: var(--indigo); }

.echeancier { display: flex; flex-direction: column; }
.echeance {
  display: grid;
  grid-template-columns: 26px 1fr auto;
  align-items: center;
  gap: 11px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--trait);
}
.echeance:last-child { border-bottom: 0; }
.echeance .rond {
  width: 24px; height: 24px; border-radius: 50%;
  display: grid; place-items: center;
  font-family: var(--chiffres); font-size: 11px; font-weight: 600;
  border: 1.5px solid var(--trait-fort); color: var(--encre-3);
}
.echeance[data-etat='soldee'] .rond { background: var(--jade); border-color: var(--jade); color: #fff; }
.echeance[data-etat='en_retard'] .rond { border-color: var(--brique); color: var(--brique); background: var(--brique-voile); }
.echeance[data-etat='en_retard'] .libelle { color: var(--brique); }

/* ------------------------------------------------------------------ Le reçu : pièce maîtresse */

.recu-cadre { filter: drop-shadow(0 22px 44px rgb(8 12 22 / 34%)); width: min(430px, 100%); margin: 0 auto; }

.recu {
  --dent: 11px;
  position: relative;
  display: grid;
  grid-template-columns: 54px 1fr;
  background: #fffdf7;
  color: #14181f;
  padding-bottom: calc(var(--dent) + 4px);
  font-size: 13px;
  -webkit-mask:
    radial-gradient(var(--dent) at 50% 0, #0000 98%, #000) 50% 100% / 22px var(--dent) repeat-x,
    linear-gradient(#000 0 0) 50% 0 / 100% calc(100% - var(--dent)) no-repeat;
  mask:
    radial-gradient(var(--dent) at 50% 0, #0000 98%, #000) 50% 100% / 22px var(--dent) repeat-x,
    linear-gradient(#000 0 0) 50% 0 / 100% calc(100% - var(--dent)) no-repeat;
}

.recu-souche {
  border-right: 2px dashed #c8c2b2;
  padding: 14px 0 18px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: repeating-linear-gradient(45deg, #faf6ec 0 6px, #fffdf7 6px 12px);
}
.recu-souche .mot {
  writing-mode: vertical-rl;
  transform: rotate(180deg);
  font-family: var(--display);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.42em;
  text-transform: uppercase;
  color: #9a927f;
}
.recu-souche .numero {
  writing-mode: vertical-rl;
  transform: rotate(180deg);
  font-family: var(--chiffres);
  font-size: 11.5px;
  font-weight: 600;
  color: #33383f;
  letter-spacing: 0.04em;
}

.recu-corps { padding: 15px 16px 12px; min-width: 0; }

.recu-entete { display: flex; gap: 10px; align-items: flex-start; padding-bottom: 11px; border-bottom: 1.5px solid #14181f; }
.recu-entete .sceau { width: 30px; height: 30px; border-radius: 8px; font-size: 13px; }
.recu-entete .groupe { font-family: var(--display); font-weight: 800; font-size: 13.5px; line-height: 1.15; letter-spacing: -0.01em; }
.recu-entete .etab { font-size: 10.5px; color: #6b6455; line-height: 1.3; }

.recu-type {
  margin: 11px 0 4px;
  font-family: var(--display);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.3em;
  text-transform: uppercase;
  color: #8a8270;
}

.recu-somme {
  font-family: var(--chiffres);
  font-size: 30px;
  font-weight: 600;
  letter-spacing: -0.05em;
  line-height: 1.05;
  color: #14181f;
}
.recu-somme span { font-size: 13px; color: #6b6455; letter-spacing: 0; margin-left: 4px; }
.recu-lettres { font-size: 10.5px; color: #6b6455; font-style: italic; margin-top: 2px; line-height: 1.35; }

.recu-grille { display: grid; grid-template-columns: auto 1fr; gap: 3px 12px; margin: 13px 0 11px; font-size: 11.5px; }
.recu-grille dt { color: #8a8270; }
.recu-grille dd { margin: 0; font-weight: 550; text-align: right; }
.recu-grille dd.mono { font-family: var(--chiffres); font-size: 11px; }

.recu-pied { display: flex; align-items: flex-end; gap: 11px; border-top: 1px dashed #c8c2b2; padding-top: 10px; }
.recu-qr { flex: none; width: 66px; height: 66px; }
.recu-qr svg { width: 100%; height: 100%; display: block; }
.recu-mentions { font-size: 9.5px; line-height: 1.4; color: #7d7666; }
.recu-mentions b { display: block; font-size: 10px; color: #4b4638; }

.tampon {
  position: absolute;
  right: 12px;
  top: 96px;
  transform: rotate(-12deg);
  padding: 5px 12px 4px;
  border: 2.5px solid currentColor;
  border-radius: 5px;
  box-shadow: inset 0 0 0 1.5px currentColor;
  font-family: var(--display);
  font-size: 15px;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: #12735a;
  opacity: 0.82;
  pointer-events: none;
}
.tampon[data-etat='annule'] { color: #b3372a; }
.tampon.frappe { animation: frappe-tampon 0.42s cubic-bezier(0.2, 0.9, 0.3, 1.3) backwards; animation-delay: 0.22s; }
@keyframes frappe-tampon {
  from { opacity: 0; transform: rotate(-26deg) scale(2.6); }
  70% { opacity: 0.95; transform: rotate(-10deg) scale(0.94); }
  to { opacity: 0.82; transform: rotate(-12deg) scale(1); }
}

.recu-actions { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; margin-top: 18px; }

/* ------------------------------------------------------------------ Connexion */

.connexion { display: grid; grid-template-columns: 1.05fr 1fr; min-height: 100vh; }
@media (max-width: 900px) { .connexion { grid-template-columns: 1fr; } .connexion-vitrine { display: none; } }

.connexion-vitrine {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 42px 46px;
  background:
    radial-gradient(120% 90% at 12% 8%, #3d4fb8 0%, transparent 55%),
    radial-gradient(90% 80% at 92% 96%, #7c3168 0%, transparent 58%),
    #131c46;
  color: #eef1fb;
  overflow: hidden;
}
.connexion-vitrine::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image: linear-gradient(rgb(255 255 255 / 5%) 1px, transparent 1px);
  background-size: 100% 28px;
  pointer-events: none;
}
.connexion-vitrine .these {
  font-family: var(--display);
  font-size: clamp(30px, 4vw, 46px);
  font-weight: 800;
  letter-spacing: -0.04em;
  line-height: 1.02;
  max-width: 13ch;
}
.connexion-vitrine .these em { font-style: normal; color: #f7bb62; }
.connexion-vitrine .appui { max-width: 42ch; color: #b9c2e6; font-size: 14px; margin-top: 14px; }
.connexion-vitrine .socle { display: flex; gap: 26px; flex-wrap: wrap; position: relative; }
.connexion-vitrine .socle div { font-size: 12px; color: #99a4d0; }
.connexion-vitrine .socle b { display: block; font-family: var(--chiffres); font-size: 19px; color: #fff; font-weight: 600; letter-spacing: -0.04em; }

.connexion-vitrine .recu-cadre { position: absolute; right: -44px; top: 46%; width: 320px; transform: rotate(6deg); opacity: 0.96; }

.connexion-panneau { display: grid; place-items: center; padding: 32px 24px; background: var(--surface); }
.connexion-formulaire { width: min(360px, 100%); display: flex; flex-direction: column; gap: 14px; }

.comptes-demo { display: grid; grid-template-columns: repeat(2, 1fr); gap: 6px; }
.comptes-demo button {
  padding: 7px 9px;
  border: 1px solid var(--trait);
  border-radius: var(--r-sm);
  background: var(--surface-2);
  cursor: pointer;
  text-align: left;
  font-size: 11.5px;
  line-height: 1.25;
  color: var(--encre-2);
}
.comptes-demo button:hover { border-color: var(--indigo); color: var(--indigo); }
.comptes-demo b { display: block; font-family: var(--chiffres); font-size: 11.5px; color: var(--encre); }

.alerte {
  padding: 9px 12px;
  border-radius: var(--r-sm);
  background: var(--brique-voile);
  color: var(--brique);
  font-size: 13px;
  border: 1px solid color-mix(in srgb, var(--brique) 28%, transparent);
}

/* ------------------------------------------------------------------ Portail parent */

.portail { max-width: 720px; margin: 0 auto; padding: 18px 16px 70px; }

.portail-entete {
  display: flex; align-items: center; gap: 12px;
  padding: 16px 0 20px;
}

.carte-enfant { overflow: hidden; margin-bottom: 16px; }
.carte-enfant .bandeau {
  display: flex; align-items: center; gap: 13px;
  padding: 16px 18px;
  color: #fff;
}
.carte-enfant .bandeau .initiales {
  width: 44px; height: 44px; border-radius: 13px;
  display: grid; place-items: center;
  background: rgb(255 255 255 / 22%);
  font-family: var(--display); font-weight: 800; font-size: 16px;
}
.carte-enfant .bandeau .nom { font-family: var(--display); font-weight: 700; font-size: 17px; letter-spacing: -0.02em; }
.carte-enfant .bandeau .meta { font-size: 12px; opacity: 0.85; }

.anneau { position: relative; width: 108px; height: 108px; flex: none; }
.anneau svg { transform: rotate(-90deg); }
.anneau .fond { stroke: var(--surface-3); }
.anneau .arc { stroke: var(--jade); stroke-linecap: round; transition: stroke-dashoffset 0.9s cubic-bezier(0.2, 0, 0, 1); }
.anneau[data-etat='partiel'] .arc { stroke: var(--safran); }
.anneau[data-etat='faible'] .arc { stroke: var(--brique); }
.anneau .centre {
  position: absolute; inset: 0;
  display: grid; place-content: center; text-align: center;
}
.anneau .centre b { font-family: var(--chiffres); font-size: 22px; font-weight: 600; letter-spacing: -0.05em; }
.anneau .centre span { font-size: 10px; color: var(--encre-3); letter-spacing: 0.08em; text-transform: uppercase; }

.ligne-recu {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 12px;
  padding: 11px 18px;
  border-bottom: 1px solid var(--trait);
  cursor: pointer;
}
.ligne-recu:last-child { border-bottom: 0; }
.ligne-recu:hover { background: var(--surface-2); }
.ligne-recu .jeton-recu {
  width: 34px; height: 34px; border-radius: 9px;
  display: grid; place-items: center;
  background: var(--safran-voile); color: var(--safran);
}

/* ------------------------------------------------------------------ Listes de définitions */

.fiche-grille { display: grid; grid-template-columns: auto 1fr; gap: 5px 16px; margin: 0; font-size: 13px; }
.fiche-grille dt { color: var(--encre-3); }
.fiche-grille dd { margin: 0; text-align: right; font-weight: 550; }

/* ------------------------------------------------------------------ Journal d'audit */

.journal-ligne {
  display: grid;
  grid-template-columns: 34px 1fr auto;
  align-items: start;
  gap: 12px;
  padding: 11px 18px;
  border-bottom: 1px solid var(--trait);
}
.journal-ligne:last-child { border-bottom: 0; }
.journal-ligne:hover { background: var(--surface-2); }

.journal-marque {
  width: 30px; height: 30px;
  display: grid; place-items: center;
  border-radius: 9px;
  background: var(--surface-3);
  color: var(--encre-2);
}
.journal-marque.jade { background: var(--jade-voile); color: var(--jade); }
.journal-marque.safran { background: var(--safran-voile); color: var(--safran); }
.journal-marque.brique { background: var(--brique-voile); color: var(--brique); }
.journal-marque.indigo { background: var(--indigo-voile); color: var(--indigo); }

/* ------------------------------------------------------------------ Vérification publique */

.verification { min-height: 100vh; display: grid; place-items: center; padding: 26px 16px; background: var(--papier); }
.verification-panneau { width: min(470px, 100%); text-align: center; }
.verdict {
  display: inline-flex; align-items: center; gap: 9px;
  padding: 9px 18px; border-radius: 99px;
  font-weight: 650; font-size: 14px;
  margin-bottom: 20px;
}
.verdict[data-valide='oui'] { background: var(--jade-voile); color: var(--jade); }
.verdict[data-valide='non'] { background: var(--brique-voile); color: var(--brique); }

/* ------------------------------------------------------------------ Impression */

@media print {
  /* Format par défaut : un rapport s'imprime sur A4.
     Le reçu impose son propre A5 en injectant sa règle @page au moment d'imprimer. */
  @page { size: A4; margin: 14mm; }
  body { background: #fff; }

  .barre, .rail, .notifications, .recu-actions, .barre-filtres,
  .entete-vue .actions, .voile > .modale > .modale-entete, .modale-pied { display: none !important; }

  /* Une pièce ouverte s'imprime seule : l'application derrière elle s'efface. */
  :root.impression-recu .coquille, :root.impression-recu .portail { display: none !important; }

  .coquille { display: block; min-height: 0; }
  .contenu { padding: 0; max-width: none; }
  .carte, .tuile, .journal-ligne, .graphique, .rang-etab { break-inside: avoid; box-shadow: none; }

  .voile { position: static; display: block; padding: 0; background: none; backdrop-filter: none; animation: none; }
  .modale { box-shadow: none; border: 0; max-height: none; width: 100%; animation: none; }
  .modale-corps { padding: 0; overflow: visible; }
  .recu-cadre { filter: none; width: 100%; max-width: 380px; }
  .recu { box-shadow: none; }
  .imprimable, .imprimable * { visibility: visible; }
}
