/*
 * La facturation (module facturation, lot C) : l'ecran #/facturation (facturation.js) et
 * les blocs poses dans les ecrans du suivi (blocs.js) : la carte de la Vue d'ensemble, les
 * blocs des fiches projet et client. Contrat : src/modules/facturation/API.md, sections 7
 * et 10 (les trois onglets de l'ecran, 30/09).
 *
 * Prefixe fa- partout. Le socle (web/suivi/socle.css) et les fiches (fiches.css) ne sont
 * pas redefinis : la facturation y prend les lignes (.p-lignes, .p-ligne), les boutons
 * (.p-btn, .p-prim, .p-petit), les pastilles (.p-pastille, .p-nombre, .p-tag-ent), les
 * liens (.p-lien, .f-lien-interne), les formulaires en ligne (.p-fi) et les blocs (.f-bloc,
 * .f-form, .f-deux, .f-err, .f-actions, .f-pli, .f-vide, .f-note). Les couleurs sont les
 * jetons du theme (commun/style.css) et du socle : --texte, --doux, --fond, --carte,
 * --carte-haut, --bord, --bord-haut, --accent, --p-pale.
 *
 * Jamais de rouge ni d'orange (tests/couleurs-refonte.test.js, API.md 1) : la barre de
 * l'objectif est verte, la priorite se lit au contraste, une panne est un texte clair et
 * gras avec un filet a gauche. Les chiffres s'alignent (font-variant-numeric: tabular-nums).
 *
 * Telephone (700 px et moins) : cibles de 44 px ; aucun defilement horizontal de la page
 * a 375 px : les onglets remplissent leur rangee (et passent a la ligne plutot que de
 * deborder), le tableau des 6 mois defile seul, dans son cadre (.fa-defile).
 *
 * Classes :
 *   .fa-ecran                        la racine de l'ecran ; .fa-attente, .fa-echec
 *   .fa-tete > .fa-titre, .fa-aide   le titre, et ce qu'on lit dans Qonto
 *   .fa-onglets > .fa-onglet         À faire, Suivi, Chiffres : des boutons (aria-pressed), le
 *                                    nombre de « À faire » en .p-nombre du socle
 *   .fa-panneau                      le bloc d'un onglet ; celui d'un autre onglet porte [hidden]
 *   .fa-carte                        l'encaisse du mois : .fa-encaisse-titre, .fa-barre (un
 *                                    <progress>), .fa-part, .fa-agences > .fa-agence
 *                                    (.fa-sans-agence), .fa-petit, .fa-chiffre
 *   .fa-defile > table.fa-mois       les 6 mois (tr.fa-mois-courant), dans leur cadre
 *   .fa-section > .fa-section-titre  une liste de l'ecran : .fa-section-aide, .fa-vide,
 *                                    .fa-note-bas
 *   .fa-montant                      le montant a droite d'une ligne (small : TTC, reste)
 *   .fa-actions, a.fa-btn-lien       les gestes d'une ligne ; un lien en forme de bouton
 *   .fa-etat, .fa-projets            l'etat d'un devis et ses projets
 *   .fa-autres > summary, .fa-autres-corps   les gestes rares d'une ligne, replies
 *   .fa-sous                         le choix du projet a rattacher, sous la ligne
 *   .fa-copie                        le lien a copier a la main
 *   .fa-connexion, .fa-texte, .fa-alerte     Qonto : connexion, synchro, panne
 *   .fa-resume                       la carte de la Vue d'ensemble : .fa-resume-haut,
 *                                    .fa-resume-titre, .fa-resume-lien, .fa-resume-texte,
 *                                    .fa-resume-alertes > .fa-resume-alerte, .fa-resume-detail
 *   .fa-bloc                         le bloc des fiches projet et client : .fa-sous-titre,
 *                                    .fa-devis-liste > .fa-devis (.fa-devis-haut,
 *                                    .fa-devis-titre, .fa-chiffres), .fa-factures >
 *                                    .fa-facture (.fa-facture-texte, .fa-facture-gestes),
 *                                    .fa-totaux > .fa-total (.fa-fort), .fa-rattacher
 *   .fa-discret                      une lecture impossible, en une ligne
 *   Tout relier (API.md 9) : .fa-barre-pack (la barre des biens livres d'un pack),
 *   .fa-parts > .fa-part (.fa-part-texte ; .fort : une part qui presse), .fa-mois-abo >
 *   .fa-mois-abo-mois (les derniers mois d'un abonnement et leur etat)
 *   Les factures a relier (29/09) : .fa-recherche (le champ de recherche en tete de la liste)
 *   et .fa-compte (« 3 sur 32 ») ; une ligne masquee par la recherche porte [hidden]
 */

/* ---------- l'ecran ---------- */

.fa-ecran {
  display: flex; flex-direction: column; gap: 14px;
  max-width: 900px; min-width: 0; overflow-wrap: anywhere;
}
.fa-attente { margin: 0; color: var(--doux); font-size: 14px; }
.fa-echec {
  display: flex; flex-direction: column; align-items: flex-start; gap: 10px;
  padding: 12px 14px; border-left: 3px solid var(--alerte); border-radius: 0 8px 8px 0;
  background: var(--carte);
}
.fa-echec p { margin: 0; color: var(--texte); font-size: 13.5px; }
.fa-echec b { font-weight: 650; }

.fa-tete { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
/* Une classe contre la balise : passe devant le h1 de commun/style.css. */
.fa-titre { margin: 0; font-size: 20px; line-height: 1.3; text-wrap: balance; }
.fa-aide { margin: 0; color: var(--doux); font-size: 13px; }

.fa-chiffre, .fa-montant, .fa-mois, .fa-totaux dd { font-variant-numeric: tabular-nums; }

/* ---------- les onglets (30/09) ---------- */

/* Des boutons en pilule, comme les onglets des publications ; celui qui est montre au
   contraste, jamais a la teinte. Deux classes : passent devant le button de
   commun/style.css (son fond, sa bordure verte au survol, sa hauteur). */
.fa-onglets { display: flex; flex-wrap: wrap; gap: 6px; min-width: 0; margin: 2px 0 0; }
.fa-onglets .fa-onglet {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 36px; padding: 6px 14px;
  border: 1px solid var(--bord); border-radius: 999px; background: var(--carte);
  color: var(--doux); font: inherit; font-size: 13.5px; line-height: 1.2; white-space: nowrap; cursor: pointer;
}
.fa-onglets .fa-onglet:hover { color: var(--texte); border-color: var(--bord-haut); }
.fa-onglets .fa-onglet[aria-pressed="true"] {
  background: var(--carte-haut); color: var(--texte); font-weight: 650; border-color: var(--p-pale);
}
.fa-onglets .fa-onglet:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
/* Le nombre de « À faire » garde sa pastille sur le fond de l'onglet montre. */
.fa-onglet[aria-pressed="true"] .p-nombre:not(.fort) { background: var(--bord-haut); }

/* Un seul bloc a la fois : [hidden] passe devant le display: flex. */
.fa-panneau { display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.fa-panneau[hidden] { display: none; }

/* ---------- l'encaisse du mois ---------- */

.fa-carte {
  display: flex; flex-direction: column; gap: 10px; min-width: 0;
  padding: 14px 16px; background: var(--carte); border: 1px solid var(--bord); border-radius: 12px;
}
/* Deux classes : passe devant le h2 de commun/style.css (majuscules, grande marge). */
.fa-carte .fa-encaisse-titre {
  margin: 0; color: var(--texte); font-size: 17px; font-weight: 500; line-height: 1.35;
  text-transform: none; letter-spacing: 0;
}
.fa-encaisse-titre b, .fa-resume-titre b { font-weight: 700; }
.fa-part { margin: 0; color: var(--doux); font-size: 13px; font-variant-numeric: tabular-nums; }
.fa-petit { margin: 0; color: var(--doux); font-size: 12.5px; font-variant-numeric: tabular-nums; }

/* La barre vers l'objectif : un <progress>, vert sur le fond des bordures. */
.fa-barre {
  display: block; width: 100%; height: 10px; margin: 0;
  -webkit-appearance: none; appearance: none;
  border: 0; border-radius: 999px; overflow: hidden;
  background: var(--bord-haut); color: var(--accent);
}
.fa-barre::-webkit-progress-bar { background: var(--bord-haut); border-radius: 999px; }
.fa-barre::-webkit-progress-value { background: var(--accent); border-radius: 999px; }
.fa-barre::-moz-progress-bar { background: var(--accent); border-radius: 999px; }

.fa-agences { display: flex; flex-wrap: wrap; gap: 6px 18px; margin: 0; padding: 0; list-style: none; }
.fa-agence { display: inline-flex; align-items: center; gap: 8px; font-size: 13.5px; }
.fa-agence b { font-weight: 650; }
.fa-sans-agence { color: var(--doux); font-size: 11.5px; }

/* Les 6 mois : le seul defilement horizontal de l'ecran, dans son cadre. */
.fa-defile { min-width: 0; max-width: 100%; overflow-x: auto; overscroll-behavior-x: contain; }
.fa-defile:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
.fa-mois { width: 100%; min-width: max-content; border-collapse: collapse; font-size: 13px; }
.fa-mois caption { padding: 0 0 6px; color: var(--doux); font-size: 12px; text-align: left; }
.fa-mois th, .fa-mois td { padding: 6px 10px; border-bottom: 1px solid var(--bord); white-space: nowrap; }
.fa-mois thead th { color: var(--doux); font-size: 12px; font-weight: 600; text-align: right; }
.fa-mois thead th:first-child, .fa-mois tbody th { text-align: left; }
.fa-mois tbody th { color: var(--doux); font-weight: 400; }
.fa-mois td { text-align: right; }
.fa-mois td:last-child { font-weight: 650; }
.fa-mois .fa-mois-courant th, .fa-mois .fa-mois-courant td { color: var(--texte); font-weight: 650; }

/* ---------- les listes de l'ecran ---------- */

.fa-section { display: flex; flex-direction: column; gap: 8px; min-width: 0; margin-top: 8px; }
/* Deux classes : passe devant le h2 de commun/style.css. */
.fa-section .fa-section-titre {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 0;
  color: var(--doux); font-size: 12px; font-weight: 600; line-height: 1.4;
  text-transform: uppercase; letter-spacing: .09em;
}
.fa-section-aide { margin: 0; color: var(--doux); font-size: 13px; font-variant-numeric: tabular-nums; }
/* Un groupe d'une liste (l'onglet Vidéos, 30/09) : À facturer, À la livraison, Facturées. */
.fa-groupe-titre {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 10px 0 0;
  font-size: 14px; font-weight: 600; line-height: 1.4;
}
.fa-vide {
  margin: 0; padding: 14px;
  border: 1px dashed var(--bord-haut); border-radius: 10px;
  background: var(--carte); color: var(--doux); font-size: 13px;
}
.fa-note-bas { margin: 0; color: var(--doux); font-size: 12.5px; }

/* Le montant d'une ligne, a droite : le chiffre en gras, TTC ou « reste » en petit. */
.fa-montant {
  display: flex; flex-direction: column; align-items: flex-end; flex: 0 0 auto;
  margin: 0; text-align: right; white-space: nowrap;
}
.fa-montant b { font-size: 15px; font-weight: 700; line-height: 1.3; }
.fa-montant small { color: var(--doux); font-size: 11.5px; line-height: 1.3; }

.fa-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px; min-width: 0; }
/* Un lien qui ouvre un ecran (Creer les projets), en forme de bouton. */
a.fa-btn-lien { display: inline-flex; align-items: center; justify-content: center; text-decoration: none; }
.fa-etat { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; }
.fa-projets { margin: 0; color: var(--doux); font-size: 13px; }
.fa-sous { min-width: 0; }
.fa-sous:empty { display: none; }
.fa-copie {
  flex: 1 1 100%; width: 100%; min-width: 0; padding: 8px 10px;
  border: 1px solid var(--bord-haut); border-radius: 7px;
  background: var(--fond); color: var(--texte); font: inherit; font-size: 12.5px;
}

/* Les gestes rares d'une ligne (agence, Ne plus suivre), replies. */
.fa-autres { min-width: 0; }
.fa-autres > summary {
  display: inline-flex; align-items: center; gap: 6px; width: max-content; max-width: 100%;
  padding: 2px 0; color: var(--doux); font-size: 12.5px; cursor: pointer; list-style: none;
}
.fa-autres > summary::-webkit-details-marker { display: none; }
.fa-autres > summary::before { content: "\25B8"; font-size: 11px; }
.fa-autres[open] > summary::before { content: "\25BE"; }
.fa-autres > summary:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 3px; }
.fa-autres-corps { display: flex; flex-direction: column; gap: 8px; padding-top: 8px; }

/* Payees depuis 30 jours : un bloc replie, comme les livres de la fiche client. */
.fa-pli { margin-top: 4px; }

/* ---------- Qonto ---------- */

/* Qonto pas connecte : le premier bloc de l'ecran, au cadre plus clair. */
.fa-connexion { border-color: var(--bord-haut); }
.fa-texte { margin: 0; font-size: 13.5px; }
.fa-texte b { font-weight: 650; }
/* Une panne de synchro : texte clair et gras, un filet a gauche (jamais de teinte d'alerte). */
.fa-alerte {
  display: flex; flex-direction: column; gap: 4px;
  padding: 8px 12px; border-left: 3px solid var(--texte); border-radius: 0 8px 8px 0;
  background: var(--carte-haut);
}
.fa-alerte p { margin: 0; color: var(--texte); font-size: 13.5px; }
.fa-alerte b { font-weight: 650; }
.fa-alerte .fa-petit { color: var(--doux); }

/* ---------- la carte de la Vue d'ensemble ---------- */

.fa-resume {
  display: flex; flex-direction: column; gap: 10px; min-width: 0; margin-top: 14px;
  padding: 12px 14px; background: var(--carte); border: 1px solid var(--bord); border-radius: 10px;
}
.fa-resume-haut {
  display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 4px 12px;
}
/* Deux classes : passe devant le h3 de commun/style.css (majuscules). */
.fa-resume .fa-resume-titre {
  margin: 0; color: var(--texte); font-size: 15px; font-weight: 500; line-height: 1.35;
  text-transform: none; letter-spacing: 0;
}
.fa-resume-lien {
  color: var(--texte); font-size: 13px;
  text-decoration: underline; text-decoration-color: var(--p-pale); text-underline-offset: 2px;
}
.fa-resume-lien:hover { text-decoration-color: var(--texte); }
.fa-resume-lien:focus-visible, .fa-resume-alerte:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 3px;
}
.fa-resume-texte { margin: 0; color: var(--doux); font-size: 13px; }
.fa-resume-alertes { display: flex; flex-direction: column; gap: 4px; margin: 0; padding: 0; list-style: none; }
.fa-resume-alerte {
  display: inline-flex; flex-wrap: wrap; align-items: center; gap: 4px 8px;
  color: var(--texte); font-size: 13px; text-decoration: none;
}
.fa-resume-detail { color: var(--doux); font-variant-numeric: tabular-nums; }
.fa-resume-alerte:hover .fa-resume-detail { color: var(--texte); }

/* ---------- les blocs des fiches projet et client ---------- */

/* Deux classes : passe devant le h3 de commun/style.css (majuscules). */
.fa-bloc .fa-sous-titre {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 4px 0 0;
  color: var(--texte); font-size: 13px; font-weight: 650; line-height: 1.4;
  text-transform: none; letter-spacing: 0;
}
.fa-devis-liste { display: flex; flex-direction: column; gap: 8px; }
.fa-devis {
  display: flex; flex-direction: column; gap: 6px; min-width: 0;
  padding: 10px 12px; background: var(--fond); border: 1px solid var(--bord); border-radius: 10px;
}
.fa-devis-haut { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 6px 10px; }
.fa-devis-titre { margin: 0; font-size: 14px; font-variant-numeric: tabular-nums; }
.fa-devis-titre b { font-weight: 650; }
.fa-chiffres { margin: 0; color: var(--doux); font-size: 13px; font-variant-numeric: tabular-nums; }
.fa-chiffres b { color: var(--texte); font-weight: 650; }

.fa-factures { display: flex; flex-direction: column; margin: 0; padding: 0; list-style: none; }
.fa-facture {
  display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; min-width: 0;
  padding: 7px 0; border-top: 1px solid var(--bord); font-size: 13px;
}
.fa-facture:first-child { border-top: 0; }
.fa-facture-texte { display: flex; flex-direction: column; gap: 1px; flex: 1 1 12em; min-width: 0; }
.fa-facture-texte b { font-weight: 650; }
.fa-facture-texte small { color: var(--doux); font-size: 12.5px; }
.fa-facture .fa-montant b { font-size: 13.5px; font-weight: 650; }
.fa-facture-gestes { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; min-width: 0; }

.fa-totaux {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(min(140px, 100%), 1fr)); gap: 8px; margin: 0;
}
.fa-total {
  display: flex; flex-direction: column; gap: 2px; min-width: 0;
  padding: 8px 10px; background: var(--fond); border: 1px solid var(--bord); border-radius: 8px;
}
.fa-total dt { color: var(--doux); font-size: 12px; }
.fa-total dd { margin: 0; font-size: 16px; font-weight: 650; }
/* Du retard : le cadre plus clair, le chiffre plus gras (le contraste, pas la teinte). */
.fa-total.fa-fort { border-color: var(--alerte); }
.fa-total.fa-fort dd { font-weight: 750; }

.fa-rattacher { margin-top: 4px; }
.fa-discret { margin: 0; color: var(--doux); font-size: 12.5px; }

/* ---------- tout relier : les packs, les parts, les abonnements (API.md 9) ---------- */

/* La barre d'un pack : celle de l'objectif, un peu plus fine. */
.fa-barre.fa-barre-pack { height: 8px; }

/* L'acompte et le solde (ou l'integral) : une ligne chacun, comme les factures. */
.fa-parts { display: flex; flex-direction: column; margin: 0; padding: 0; list-style: none; }
.fa-part {
  display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; min-width: 0;
  padding: 7px 0; border-top: 1px solid var(--bord); font-size: 13px;
}
.fa-part:first-child { border-top: 0; }
.fa-part-texte { display: flex; flex-direction: column; gap: 1px; flex: 1 1 12em; min-width: 0; }
.fa-part-texte b { font-weight: 650; }
.fa-part-texte small { color: var(--doux); font-size: 12.5px; font-variant-numeric: tabular-nums; }
.fa-part .fa-montant b { font-size: 13.5px; font-weight: 650; }
/* Une part qui presse : le texte plus appuye (le contraste, jamais la teinte). */
.fa-part.fort .fa-part-texte b, .fa-part.fort .fa-montant b { font-weight: 750; }

/* Les derniers mois d'un abonnement : le mois et son etat, a la suite. */
.fa-mois-abo {
  display: flex; flex-wrap: wrap; align-items: center; gap: 4px 14px; margin: 0; padding: 0;
  list-style: none; color: var(--doux); font-size: 12.5px;
}
.fa-mois-abo-mois { display: inline-flex; align-items: center; gap: 6px; }

/* ---------- les factures a relier : la recherche ---------- */

.fa-recherche { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
/* Une classe contre la balise : passe devant le label de commun/style.css (bloc, marge basse). */
.fa-recherche label {
  display: flex; flex-direction: column; gap: 4px; min-width: 0; margin: 0;
  color: var(--doux); font-size: 12.5px;
}
.fa-recherche input[type="search"] {
  width: 100%; min-width: 0; min-height: 38px; margin: 0; padding: 8px 10px;
  -webkit-appearance: none; appearance: none;
  border: 1px solid var(--bord-haut); border-radius: 7px;
  background: var(--fond); color: var(--texte);
  font: inherit; font-size: 14px; line-height: 1.3;
}
.fa-recherche input[type="search"]:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.fa-compte { margin: 0; color: var(--doux); font-size: 12.5px; font-variant-numeric: tabular-nums; }
/* Une ligne que la recherche masque : [hidden] passe devant le display: flex de .p-ligne (socle). */
.fa-section .p-ligne[hidden] { display: none; }

/* ---------- telephone ---------- */

@media (max-width: 700px) {
  .fa-titre { font-size: 19px; }
  /* Les onglets remplissent leur rangee. */
  .fa-onglets .fa-onglet { flex: 1 1 auto; }
  .fa-carte { padding: 12px; }
  .fa-carte .fa-encaisse-titre { font-size: 16px; }
  .fa-copie { font-size: 16px; }
  /* 16 px : sous cette taille, l'iPhone agrandit la page quand le champ prend le focus. */
  .fa-recherche input[type="search"] { font-size: 16px; }
}

/* Au doigt, une cible de moins de 44 px se rate : onglets, liens, replis, cases du tableau, recherche. */
@media (max-width: 700px), (pointer: coarse) {
  .fa-onglets .fa-onglet { min-height: 44px; }
  a.fa-btn-lien { min-height: 44px; }
  .fa-autres > summary { min-height: 44px; }
  .fa-resume-lien, .fa-resume-alerte { display: inline-flex; align-items: center; min-height: 44px; }
  .fa-mois th, .fa-mois td { padding: 8px 10px; }
  .fa-recherche input[type="search"] { min-height: 44px; }
}
