/* Le Petit Salon — feuille de styles unique, aucune ressource externe.
   Thème sombre par défaut (préférence de Marc), thème clair commutable. */

:root {
  --fond: #0f1115;
  --fond-doux: #161a21;
  --carte: #1a1f27;
  --carte-haute: #212732;
  --ligne-alternee: #1f2530;
  --bordure: #2a313d;
  --texte: #e9ecf1;
  --texte-doux: #98a1b0;
  --accent: #6ea8fe;
  --accent-fonce: #1d2b45;
  --vert: #4ade80;
  --orange: #fbbf24;
  --rouge: #f87171;
  --violet: #c084fc;
  --alerte-fond: #2a1414;
  --teinte-chq: rgba(192, 132, 252, .18);
  --teinte-esp: rgba(74, 222, 128, .16);
  --teinte-vir: rgba(110, 168, 254, .18);
  --rayon: 14px;
  --ombre: 0 8px 24px rgba(0, 0, 0, .35);
}

html[data-theme="clair"] {
  --fond: #f5f6f8;
  --fond-doux: #ffffff;
  --carte: #ffffff;
  --carte-haute: #f0f2f5;
  --ligne-alternee: #f7f8fa;
  --bordure: #dfe3e9;
  --texte: #16181d;
  --texte-doux: #5d6470;
  --accent: #2563eb;
  --accent-fonce: #e8efff;
  --vert: #16a34a;
  --orange: #b45309;
  --rouge: #dc2626;
  --violet: #7c3aed;
  --alerte-fond: #fef2f2;
  --teinte-chq: rgba(124, 58, 237, .12);
  --teinte-esp: rgba(22, 163, 74, .12);
  --teinte-vir: rgba(37, 99, 235, .12);
  --ombre: 0 6px 18px rgba(16, 24, 40, .08);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--fond);
  color: var(--texte);
  font: 15px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-text-size-adjust: 100%;
  padding-bottom: env(safe-area-inset-bottom);
}

h1, h2, h3 { line-height: 1.2; margin: 0 0 .5rem; letter-spacing: -.01em; }
h1 { font-size: 1.5rem; }
h2 { font-size: 1.12rem; }
h3 { font-size: .98rem; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
code, .mono { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: .86em; }
small, .petit { font-size: .82rem; }
.discret { color: var(--texte-doux); }
.erreur { color: var(--rouge); }
[hidden] { display: none !important; }

/* ---------------------------------------------------------------- connexion */
.connexion {
  min-height: 100dvh; display: grid; place-items: center; padding: 24px;
  background: radial-gradient(120% 90% at 50% 0%, var(--accent-fonce), var(--fond) 70%);
}
.connexion-boite { width: 100%; max-width: 380px; text-align: center; }
.logo-grand { font-size: 2.6rem; line-height: 1; margin-bottom: .4rem; color: var(--accent); }
.connexion-boite label { display: block; text-align: left; margin: 1rem 0 .3rem; font-size: .85rem; color: var(--texte-doux); }

/* ------------------------------------------------------------------ entête */
.entete {
  position: sticky; top: 0; z-index: 30;
  background: color-mix(in srgb, var(--fond) 88%, transparent);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--bordure);
  padding: .6rem clamp(.7rem, 3vw, 1.4rem) 0;
}
.entete-ligne { display: flex; align-items: center; gap: .7rem; }
.marque { display: flex; align-items: center; gap: .55rem; color: var(--texte); text-decoration: none; flex: 0 0 auto; }
.marque:hover { text-decoration: none; }
.logo {
  width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center;
  background: var(--accent-fonce); color: var(--accent); font-size: 1.1rem;
}
.marque-texte { display: flex; flex-direction: column; line-height: 1.1; }
.marque-texte strong { font-size: .95rem; }
.marque-texte small { color: var(--texte-doux); font-size: .74rem; }
.recherche { flex: 1 1 auto; min-width: 0; }
.recherche input {
  width: 100%; padding: .58rem .85rem; border-radius: 999px;
  border: 1px solid var(--bordure); background: var(--carte); color: var(--texte);
  font-size: .92rem;
}
.recherche input:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.entete-actions { flex: 0 0 auto; display: flex; gap: .35rem; }

.onglets-haut { display: none; gap: .2rem; margin-top: .5rem; overflow-x: auto; }
.onglets-haut a {
  padding: .45rem .8rem; border-radius: 9px 9px 0 0; color: var(--texte-doux);
  font-size: .88rem; white-space: nowrap; text-decoration: none;
}
.onglets-haut a.actif { color: var(--texte); background: var(--carte); border: 1px solid var(--bordure); border-bottom-color: transparent; }

.onglets-bas {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 40;
  display: flex; background: var(--fond-doux); border-top: 1px solid var(--bordure);
  padding: .25rem .2rem calc(.25rem + env(safe-area-inset-bottom));
}
.onglets-bas a {
  flex: 1 1 0; min-width: 0; text-align: center; padding: .35rem .1rem;
  color: var(--texte-doux); font-size: .68rem; text-decoration: none;
}
.onglets-bas a .g { display: block; font-size: 1.15rem; line-height: 1.25; }
.onglets-bas a.actif { color: var(--accent); }

/* Pastille d'alerte sur l'onglet Anomalies : elle prévient qu'il reste des
   points à vérifier sans avoir à ouvrir l'onglet. Rouge = erreur de saisie,
   orange = simple point d'attention. */
.onglets-haut a, .onglets-bas a { position: relative; }
.onglets-haut a.alerte, .onglets-bas a.alerte { color: var(--orange); }
.onglets-haut a.alerte-erreur, .onglets-bas a.alerte-erreur { color: var(--rouge); }
.pastille-alerte {
  position: absolute; top: -5px; right: -7px;
  min-width: 17px; height: 17px; padding: 0 4px;
  border-radius: 999px; background: var(--rouge); color: #fff;
  font-size: .66rem; font-weight: 700; line-height: 17px; text-align: center;
  letter-spacing: 0;
}

/* -------------------------------------------------------------------- vues */
.vue {
  padding: 1rem clamp(.7rem, 3vw, 1.4rem) 6rem; max-width: 1180px; margin: 0 auto;
  /* Le balayage horizontal nous revient, le défilement vertical et le zoom
     restent au navigateur — sinon le navigateur garde le geste pour lui et ne
     nous envoie jamais le mouvement. */
  touch-action: pan-y pinch-zoom;
}

/* Balayage entre onglets : la nouvelle vue entre depuis le côté du doigt.
   Sous `prefers-reduced-motion: reduce`, l'animation est neutralisée plus bas —
   le balayage lui-même reste actif. */
@keyframes entree-depuis-droite { from { transform: translateX(26px); opacity: .35; } }
@keyframes entree-depuis-gauche { from { transform: translateX(-26px); opacity: .35; } }
.vue.entree-droite { animation: entree-depuis-droite .22s ease-out; }
.vue.entree-gauche { animation: entree-depuis-gauche .22s ease-out; }
.vue > section { margin-bottom: 1.1rem; }
.carte {
  background: var(--carte); border: 1px solid var(--bordure);
  border-radius: var(--rayon); padding: 1rem 1.1rem; margin-bottom: 1rem;
}
.carte > :first-child { margin-top: 0; }
.carte > :last-child { margin-bottom: 0; }
.titre-vue { display: flex; flex-wrap: wrap; align-items: baseline; gap: .6rem; margin-bottom: .8rem; }
.titre-vue h1 { margin: 0; }
/* Bouton « retour à la liste » sur les fiches facture / client. */
.bouton.retour { align-self: center; background: transparent; color: var(--accent); border-color: color-mix(in srgb, var(--accent) 55%, var(--bordure)); font-weight: 600; }
.bouton.retour:hover { color: var(--texte); background: var(--accent-fonce); border-color: var(--accent); }

/* Explications repliées sous les titres de l'accueil : un clic pour les ouvrir. */
.explication { margin: .1rem 0 .75rem; }
.explication > summary {
  display: inline-flex; align-items: center; gap: .35rem; cursor: pointer;
  list-style: none; width: fit-content; padding: .12rem .6rem;
  font-size: .78rem; font-weight: 600; color: var(--accent);
  border: 1px solid color-mix(in srgb, var(--accent) 55%, var(--bordure));
  border-radius: 999px; background: transparent;
}
.explication > summary::-webkit-details-marker { display: none; }
.explication > summary::before { content: 'ⓘ'; font-weight: 400; }
.explication[open] > summary::before { content: '▾'; }
.explication > summary:hover { background: var(--accent-fonce); border-color: var(--accent); }
.explication > p { margin: .55rem 0 0; }
@media (max-width: 620px) {
  .titre-vue .bouton.retour { flex: 1 0 100%; justify-content: flex-start; }
}
.grille { display: grid; gap: .7rem; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
.grille-2 { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }

.kpi {
  background: var(--carte); border: 1px solid var(--bordure);
  border-left: 4px solid var(--accent); border-radius: 12px; padding: .75rem .9rem;
}
.kpi .l { font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; color: var(--texte-doux); font-weight: 600; }
.kpi .v { font-size: 1.3rem; font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.kpi .n { font-size: .76rem; color: var(--texte-doux); }
.kpi.vert { border-left-color: var(--vert); }
.kpi.orange { border-left-color: var(--orange); }
.kpi.violet { border-left-color: var(--violet); }

/* Carte d'alerte : incohérence à corriger (erreur de saisie) */
.carte.alerte { border-left: 4px solid var(--rouge); background: var(--alerte-fond); }
.carte.alerte h2 { color: var(--rouge); }
a.etiquette { text-decoration: none; }
a.etiquette:hover { text-decoration: none; border-color: currentColor; }

/* ---------------------------------------------------------------- boutons */
.bouton {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  min-height: 42px; padding: .5rem .9rem; border-radius: 10px; cursor: pointer;
  border: 1px solid var(--bordure); background: var(--carte-haute); color: var(--texte);
  font-size: .88rem; font-family: inherit; text-decoration: none;
}
.bouton:hover { border-color: var(--accent); text-decoration: none; }
.bouton.principal { background: var(--accent); border-color: var(--accent); color: #08111f; font-weight: 600; }
.bouton.danger { color: var(--rouge); border-color: color-mix(in srgb, var(--rouge) 45%, var(--bordure)); }
.bouton.icone { min-width: 42px; padding: .5rem; }
.bouton.petit { min-height: 34px; padding: .25rem .6rem; font-size: .8rem; }
.bouton:disabled { opacity: .5; cursor: not-allowed; }
.barre-actions { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }

/* --------------------------------------------------------------- filtres */
.filtres { display: grid; gap: .6rem; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); }
.champ { display: flex; flex-direction: column; gap: .25rem; min-width: 0; }
.champ label { font-size: .74rem; text-transform: uppercase; letter-spacing: .05em; color: var(--texte-doux); }
input, select, textarea {
  width: 100%; padding: .5rem .6rem; border-radius: 9px; font-family: inherit; font-size: .9rem;
  border: 1px solid var(--bordure); background: var(--fond-doux); color: var(--texte);
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
textarea { min-height: 78px; resize: vertical; }
select[multiple] { min-height: 108px; }

.puces { display: flex; flex-wrap: wrap; gap: .4rem; margin: .7rem 0 0; }

/* Panneau de filtres repliable (confort mobile) */
/* Une pastille discrète plutôt qu'une grande barre : replié, le panneau ne doit
   coûter qu'une trentaine de pixels à la liste (v2.35). */
.carte.carte-filtres { padding: .5rem .8rem; margin-bottom: .8rem; }
/* Replié, le panneau ne garde que sa pastille : la carte elle-même s'efface (le
   `:has` n'est pas indispensable — sans lui, le cadre reste, simplement plus large). */
.carte-filtres:has(.panneau-filtres:not([open])) {
  padding: 0; border-color: transparent; background: none; margin-bottom: .6rem;
}
.panneau-filtres > summary {
  cursor: pointer; list-style: none; width: fit-content;
  display: inline-flex; align-items: center; gap: .4rem;
  padding: .28rem .7rem; border-radius: 999px;
  border: 1px solid var(--bordure); background: var(--carte-haute);
  font-weight: 600; font-size: .82rem; color: var(--texte);
  transition: border-color .15s, color .15s;
}
.panneau-filtres > summary:hover { border-color: var(--accent); color: var(--accent); }
.panneau-filtres > summary::-webkit-details-marker { display: none; }
.panneau-filtres > summary::after { content: '▾'; color: var(--texte-doux); font-size: .8rem; }
.panneau-filtres[open] > summary::after { content: '▴'; }
.panneau-filtres[open] > summary { margin-bottom: .75rem; }
.compteur-filtres { font-size: .74rem; color: var(--accent); }
.compteur-filtres::before { content: '·'; color: var(--texte-doux); margin-right: .4rem; }
.puce {
  display: inline-flex; align-items: center; gap: .4rem; font-size: .8rem;
  background: var(--accent-fonce); color: var(--accent);
  border: 1px solid color-mix(in srgb, var(--accent) 35%, var(--bordure));
  border-radius: 999px; padding: .22rem .6rem;
}
.puce button { background: none; border: none; color: inherit; cursor: pointer; font-size: 1rem; line-height: 1; padding: 0; }
.etiquette {
  display: inline-block; font-size: .72rem; padding: .12rem .5rem; border-radius: 999px;
  border: 1px solid var(--bordure); color: var(--texte-doux); margin: 0 .25rem .25rem 0;
}

/* Pointage d'une facture en un clic, depuis la liste : la pastille oui/non est
   cliquable (elle est posée dans un lien de ligne, d'où le role="button"). */
.pastille-pointage { cursor: pointer; user-select: none; }
.pastille-pointage:hover { border-color: currentColor; }
.pastille-pointage:hover::after { content: ' ⇄'; font-size: .85em; opacity: .6; }
.pastille-pointage.en-cours { opacity: .45; cursor: progress; }
.etiquette.vert { color: var(--vert); border-color: color-mix(in srgb, var(--vert) 45%, var(--bordure)); }
.etiquette.orange { color: var(--orange); border-color: color-mix(in srgb, var(--orange) 45%, var(--bordure)); }
.etiquette.violet { color: var(--violet); border-color: color-mix(in srgb, var(--violet) 45%, var(--bordure)); }
.etiquette.rouge { color: var(--rouge); border-color: color-mix(in srgb, var(--rouge) 45%, var(--bordure)); }

/* ---------------------------------------------------------------- listes */
.liste { border: 1px solid var(--bordure); border-radius: var(--rayon); overflow: hidden; background: var(--carte); }
.liste .entete-liste, .liste .ligne {
  display: grid; gap: .5rem; align-items: center;
  padding: .6rem .85rem; border-bottom: 1px solid var(--bordure);
}
.liste .entete-liste {
  background: var(--carte-haute); font-size: .72rem; text-transform: uppercase;
  letter-spacing: .05em; color: var(--texte-doux); font-weight: 600;
}
.liste .ligne { text-decoration: none; color: var(--texte); }
/* Listes qui défilent toutes seules (Factures, Clients) : les filtres, le bandeau
   de totaux et la pagination restent en place, seules les lignes défilent. La
   hauteur maximale est calculée en JS (elle dépend de ce qui est au-dessus). */
.liste.defilante { overflow-y: auto; }

/* Détail d'une facture (v2.33) : le bouton « ← Liste des factures » reste en place,
   tout ce qui est en dessous défile dans son propre cadre. */
.entete-detail { display: flex; align-items: center; gap: .5rem; margin-bottom: .6rem; }
.detail.defilant { overflow-y: auto; overscroll-behavior: contain; padding-right: 2px; }
.detail.defilant .titre-vue { margin-bottom: .6rem; }
.liste.defilante .entete-liste {
  position: sticky; top: 0; z-index: 2;
  box-shadow: inset 0 -1px 0 var(--bordure);
}

/* Alternance de fond d'une ligne sur deux : la lecture ligne par ligne est
   nettement plus facile sur une liste longue (factures, clients). */
.liste a.ligne:nth-of-type(even) { background: var(--ligne-alternee); }
.liste .ligne:last-child { border-bottom: none; }
.liste .ligne:hover, .liste a.ligne:hover { background: var(--carte-haute); text-decoration: none; }
.liste .ligne.corrigee { box-shadow: inset 3px 0 0 var(--orange); }
.col-factures { grid-template-columns: 74px 96px 1fr 92px 84px 96px 96px; }
/* La date est mise en gras comme le nom du client : sur une liste dense, c'est
   le repère de lecture le plus fiable (le nom se répète, la date non). */
.liste .ligne .cell.date { font-weight: 600; }
/* ... et le nom garde le même gras sur PC, pour que les deux repères se lisent
   d'un seul coup d'œil (le gras du nom n'était appliqué qu'en mobile). */
.liste .ligne .cell.principal { font-weight: 600; }

/* Liens vers les synthèses annuelles (onglet Synthèse, bas de page) */
.liens-syntheses { display: grid; gap: .55rem; margin-top: .7rem; }
.lien-synthese {
  display: flex; flex-direction: column; gap: .15rem;
  padding: .7rem .9rem; border: 1px solid var(--bordure); border-radius: 12px;
  background: var(--carte-haute); text-decoration: none; color: inherit;
  transition: border-color .15s, transform .15s;
}
.lien-synthese:hover { border-color: var(--accent); transform: translateX(2px); }
.lien-synthese .titre-synthese { font-weight: 600; color: var(--accent); }
.lien-synthese .titre-synthese::before { content: "↗ "; }

/* Montant facturé : le chiffre qui compte dans une liste de factures. */
.liste .ligne .montant-facture { font-weight: 600; }

/* Moyen de paiement : pastille colorée, même lecture sur téléphone et sur PC.
   CHQ = violet, ESP = vert (espèces), VIR = bleu (virement). */
.badge-reglement {
  display: inline-block;
  padding: .05rem .45rem;
  border: 1px solid var(--bordure);
  border-radius: 999px;
  background: var(--carte-haute);
  color: var(--texte-doux);
  font-size: .74rem;
  font-weight: 600;
  letter-spacing: .02em;
  line-height: 1.6;
  white-space: nowrap;
}
.badge-reglement.reglement-chq { color: var(--violet); border-color: var(--violet); background: var(--teinte-chq); }
.badge-reglement.reglement-esp { color: var(--vert); border-color: var(--vert); background: var(--teinte-esp); }
.badge-reglement.reglement-vir { color: var(--accent); border-color: var(--accent); background: var(--teinte-vir); }
.col-clients { grid-template-columns: 1fr 120px 78px 104px 104px 118px 46px; }

/* Client venu il y a moins d'un an : sa date de dernier passage passe en vert,
   précédée d'un point (v2.37). Le point reste lisible sur téléphone, où la date
   est en petit et grise. */
.cell.dernier .rond {
  display: inline-block; width: 7px; height: 7px; margin-right: .35rem;
  border-radius: 50%; background: var(--vert); vertical-align: middle;
}
.liste .ligne.col-clients.recent .cell.dernier {
  color: var(--vert); font-weight: 600;
}
.n { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.c { text-align: center; }
.pointille { border-bottom: 1px dotted var(--bordure); }

/* ---------------------------------------------------------- fiche / détail */
.duo { display: grid; gap: .3rem .9rem; grid-template-columns: auto 1fr; align-items: baseline; }
.duo dt { color: var(--texte-doux); font-size: .84rem; }
.duo dd { margin: 0; font-variant-numeric: tabular-nums; }
.facture-ligne { display: grid; grid-template-columns: 1fr 110px; gap: .5rem; align-items: baseline; }

/* Détail d'une facture — carte « Prestations » (v2.34) : chaque prestation est une
   ligne alternée, le montant aligné à droite, et le total détaché dans un bandeau. */
.carte-prestations h2 .compte {
  display: inline-block; margin-left: .4rem; padding: .05rem .45rem;
  font-size: .74rem; font-weight: 600; color: var(--texte-doux);
  background: var(--carte-haute); border: 1px solid var(--bordure); border-radius: 999px;
  vertical-align: middle;
}
.lignes-prestations { display: flex; flex-direction: column; gap: 2px; }
.ligne-prestation {
  display: grid; grid-template-columns: 1fr auto; gap: .75rem; align-items: baseline;
  padding: .55rem .7rem; border-radius: 9px;
}
.ligne-prestation:nth-child(odd) { background: var(--ligne-alternee); }
.ligne-prestation .designation { font-weight: 500; }
.ligne-prestation .montant {
  font-variant-numeric: tabular-nums; font-weight: 600; white-space: nowrap;
}
.total-prestations {
  display: flex; justify-content: space-between; align-items: baseline; gap: .75rem;
  margin-top: .7rem; padding: .6rem .8rem; border-radius: 10px;
  background: var(--accent-fonce); border: 1px solid var(--bordure);
}
.total-prestations span:first-child {
  font-size: .74rem; font-weight: 600; letter-spacing: .06em;
  text-transform: uppercase; color: var(--texte-doux);
}
.total-prestations span:last-child {
  font-size: 1.15rem; font-weight: 700; font-variant-numeric: tabular-nums;
}

/* Détail d'une facture — carte « Informations » (v2.34) : deux blocs (Facture,
   Cliente) en tuiles, puis les mentions techniques en pied, discrètes. */
.infos-bloc + .infos-bloc { margin-top: .9rem; padding-top: .9rem; border-top: 1px solid var(--bordure); }
.infos-bloc h3 {
  margin: 0 0 .5rem; font-size: .72rem; font-weight: 700; letter-spacing: .08em;
  text-transform: uppercase; color: var(--texte-doux);
}
.infos-grille { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .5rem; }
.info {
  display: flex; flex-direction: column; gap: .12rem;
  padding: .45rem .6rem; border-radius: 10px;
  background: var(--carte-haute); border: 1px solid var(--bordure);
}
.info .et { font-size: .68rem; letter-spacing: .06em; text-transform: uppercase; color: var(--texte-doux); }
.info .va { font-weight: 600; font-variant-numeric: tabular-nums; }
.infos-cliente { display: flex; flex-wrap: wrap; align-items: center; gap: .3rem .75rem; }
.infos-cliente .nom-cliente { font-weight: 700; }
.infos-cliente .ville-cliente { color: var(--texte-doux); font-size: .9rem; }
.infos-cliente .bouton.petit { margin-left: auto; }
.infos-technique {
  display: flex; flex-wrap: wrap; gap: .15rem .9rem;
  margin-top: .9rem; padding-top: .7rem; border-top: 1px dashed var(--bordure);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: .74rem; color: var(--texte-doux);
}
.infos-technique b { color: var(--texte); font-weight: 600; margin-right: .3rem; }
.badge-base { font-size: .7rem; text-transform: uppercase; letter-spacing: .05em; color: var(--texte-doux); }
.correction { border-left: 3px solid var(--orange); padding-left: .7rem; margin: .5rem 0; }
.barre-progression { height: 8px; border-radius: 999px; background: var(--carte-haute); overflow: hidden; }
.barre-progression span { display: block; height: 100%; background: var(--accent); }
.barre-progression span.vert { background: var(--vert); }

/* Bouton « écarter » d'une anomalie : discret, en bout de ligne. Sur téléphone,
   le tableau défile horizontalement : la case reste collée à droite, sinon il
   faut faire défiler pour trouver le bouton. */
table.tableau td.ignorer { width: 1%; text-align: right; padding-left: .3rem; }
@media (max-width: 720px) {
  table.tableau td.ignorer {
    position: sticky; right: 0; background: var(--carte);
    box-shadow: -8px 0 10px -8px rgba(0, 0, 0, .45);
  }
}
.bouton.ignorer {
  color: var(--texte-doux); border-color: transparent; background: transparent;
  font-weight: 700; line-height: 1; padding: .25rem .45rem;
}
.bouton.ignorer:hover { color: var(--rouge); border-color: var(--rouge); }

table.tableau { width: 100%; border-collapse: collapse; font-size: .87rem; }
table.tableau th, table.tableau td { padding: .45rem .55rem; border-bottom: 1px solid var(--bordure); text-align: left; }
table.tableau th { font-size: .72rem; text-transform: uppercase; letter-spacing: .05em; color: var(--texte-doux); }
table.tableau td.n, table.tableau th.n { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
/* Reprend la main sur `touch-action` du conteneur de vues : un tableau large doit
   pouvoir se faire défiler dans les deux sens. */
.tableau-defilant { overflow-x: auto; touch-action: auto; }

/* Barres horizontales (téléphone) : une ligne par poste, libellé et montant
   au-dessus de la barre. Remplace les barres verticales quand les libellés sont
   longs ou l'écran étroit (v2.36). */
.barres-h { display: flex; flex-direction: column; gap: .7rem; margin: .2rem 0 .1rem; }
.barres-h .item .tete {
  display: flex; justify-content: space-between; align-items: baseline;
  gap: .6rem; margin-bottom: .28rem;
}
.barres-h .libelle { font-weight: 600; font-size: .88rem; }
.barres-h .valeur {
  color: var(--texte-doux); font-size: .84rem; font-weight: 600;
  font-variant-numeric: tabular-nums; white-space: nowrap;
}
.barres-h .note, .legende-camembert .note {
  display: block; font-size: .74rem; font-weight: 400; color: var(--texte-doux); margin-top: .1rem;
}
.barres-h .piste { height: 9px; border-radius: 999px; background: var(--carte-haute); overflow: hidden; }
.barres-h .part { display: block; height: 100%; border-radius: 999px; }

/* Tableaux en fiches sur téléphone (v2.36) : sept colonnes ne tiennent pas sur
   390 px, et un tableau qui défile horizontalement ne se lit pas. Chaque ligne
   devient une fiche : libellé de la colonne à gauche, valeur à droite. */
@media (max-width: 700px) {
  table.tableau.cartes-mobile { display: block; font-size: .9rem; }
  table.tableau.cartes-mobile thead { display: none; }
  table.tableau.cartes-mobile tbody, table.tableau.cartes-mobile tr { display: block; }
  table.tableau.cartes-mobile tr {
    background: var(--carte-haute); border: 1px solid var(--bordure);
    border-radius: 10px; padding: .55rem .7rem; margin-bottom: .55rem;
  }
  table.tableau.cartes-mobile td {
    display: flex; justify-content: space-between; align-items: baseline;
    gap: 1rem; padding: .16rem 0; border: 0; text-align: left;
  }
  table.tableau.cartes-mobile td + td { border-top: 1px dotted var(--bordure); }
  table.tableau.cartes-mobile td::before {
    content: attr(data-libelle); color: var(--texte-doux);
    font-size: .76rem; text-transform: uppercase; letter-spacing: .04em;
  }
  table.tableau.cartes-mobile td:first-child {
    display: block; font-weight: 700; font-size: 1.02rem; padding: 0 0 .3rem;
  }
  table.tableau.cartes-mobile td:first-child::before { content: none; }
  table.tableau.cartes-mobile td.n, table.tableau.cartes-mobile td[class*="delta"] { text-align: right; }
  .tableau-defilant:has(.cartes-mobile) { overflow-x: visible; }
  /* Le graphique porte déjà ces chiffres sur téléphone : la fiche serait un doublon. */
  table.tableau.masquer-mobile { display: none; }
}

.barre-outils { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; justify-content: space-between; margin-bottom: .6rem; }
/* « Sauvegarder cette vue » : bouton d'action secondaire mais repérable. */
#sauver-vue { color: var(--accent); border-color: color-mix(in srgb, var(--accent) 55%, var(--bordure)); font-weight: 600; }
#sauver-vue:hover { background: var(--accent-fonce); border-color: var(--accent); }
.pagination { display: flex; gap: .4rem; align-items: center; justify-content: center; margin-top: .9rem; flex-wrap: wrap; }

/* ------------------------------------------------------------ notification */
.notification {
  position: fixed; left: 50%; bottom: 76px; transform: translateX(-50%);
  background: var(--carte-haute); border: 1px solid var(--bordure); color: var(--texte);
  border-radius: 12px; padding: .6rem 1rem; box-shadow: var(--ombre); z-index: 60;
  max-width: min(92vw, 520px); font-size: .88rem;
  display: flex; align-items: center; gap: .7rem;
}
.notification.erreur { border-color: var(--rouge); color: var(--rouge); }
.notification #notification-action { flex: 0 0 auto; }

.vide { text-align: center; color: var(--texte-doux); padding: 1.6rem 1rem; }

/* ------------------------------------------------------------- camembert */
.camembert { display: flex; align-items: center; gap: 1.4rem; flex-wrap: wrap; }
/* Anneau des modes de règlement : assez grand pour lire les parts d'un coup d'œil
   (v2.38). Il reste plafonné par la largeur de la carte sur un petit écran. */
.camembert svg { width: 280px; max-width: 100%; height: auto; flex: 0 0 auto; }
.legende-camembert {
  list-style: none; margin: 0; padding: 0; flex: 1 1 220px; min-width: 200px;
}
.legende-camembert li {
  display: grid; grid-template-columns: 12px 1fr auto auto; align-items: center;
  gap: .55rem; padding: .35rem 0; border-bottom: 1px solid var(--bordure);
  font-size: .88rem;
}
.legende-camembert li:last-child { border-bottom: none; }
.legende-camembert .pastille {
  width: 12px; height: 12px; border-radius: 3px; display: block;
}
.legende-camembert .nom { font-weight: 600; }
.legende-camembert .valeur { font-variant-numeric: tabular-nums; }
.legende-camembert .part { color: var(--texte-doux); font-variant-numeric: tabular-nums; min-width: 3.6rem; text-align: right; }
@media (max-width: 560px) {
  .camembert { justify-content: center; }
  .camembert svg { width: 240px; }
}

/* ------------------------------------------------- modale de saisie */
dialog.modale {
  border: none; padding: 0; background: transparent; color: var(--texte);
  width: min(760px, 96vw); max-height: 92dvh;
  /* Le dialogue ne défile pas lui-même : c'est `.modale-corps` qui le fait,
     sinon une barre horizontale apparaît en bas de la fenêtre. */
  overflow: hidden;
}
dialog.modale::backdrop { background: rgba(0, 0, 0, .55); }
.modale-boite {
  display: flex; flex-direction: column; max-height: 92dvh; overflow: hidden;
  background: var(--carte); border: 1px solid var(--bordure); border-radius: var(--rayon);
  box-shadow: var(--ombre);
}
.modale-entete {
  display: flex; align-items: center; justify-content: space-between; gap: .5rem;
  padding: .85rem 1.1rem; border-bottom: 1px solid var(--bordure);
}
.modale-entete h2 { margin: 0; font-size: 1.05rem; }
.modale-corps { padding: 1rem 1.1rem; overflow-y: auto; overflow-x: hidden; }
/* Les champs natifs (date, nombre) ont une largeur intrinsèque qui dépasse
   parfois le bloc : sans plafond, une barre de défilement horizontale apparaît. */
.modale-corps input, .modale-corps select, .modale-corps textarea { max-width: 100%; }
.modale-corps h3 { margin: 1.1rem 0 .4rem; font-size: .95rem; }
.modale-pied {
  display: flex; justify-content: flex-end; gap: .5rem;
  padding: .8rem 1.1rem; border-top: 1px solid var(--bordure); background: var(--carte-haute);
}
/* ------------------------------------------------- modale : blocs de saisie */
/* Chaque étape de la saisie est un bloc titré et numéroté : sur un téléphone,
   un formulaire à plat oblige à relire toute la page pour se repérer. */
.bloc-saisie {
  background: var(--fond-doux); border: 1px solid var(--bordure); border-radius: 12px;
  padding: .85rem .95rem; margin-bottom: .8rem;
}
.bloc-saisie h3 { display: flex; align-items: center; gap: .5rem; margin: 0 0 .6rem; font-size: .95rem; }
.bloc-saisie h3 .num {
  display: inline-flex; align-items: center; justify-content: center; flex: 0 0 auto;
  width: 22px; height: 22px; border-radius: 50%;
  background: var(--accent); color: #fff; font-size: .74rem; font-weight: 700;
}

/* Choix exclusif en segments : plus rapide au doigt qu'un menu déroulant. */
.segmented { display: flex; gap: .4rem; flex-wrap: wrap; }
.segment { flex: 1 1 0; min-width: 92px; position: relative; }
.segment input { position: absolute; opacity: 0; pointer-events: none; }
.segment > span {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .1rem;
  padding: .5rem .4rem; min-height: 48px; text-align: center;
  border: 1px solid var(--bordure); border-radius: 10px; background: var(--carte);
  font-weight: 600; font-size: .9rem; cursor: pointer;
}
.segment > span small { font-weight: 500; font-size: .68rem; color: var(--texte-doux); }
.segment input:checked + span { border-color: var(--accent); background: var(--accent-fonce); color: var(--accent); }
.segment.reglement-chq input:checked + span { border-color: var(--violet); background: var(--teinte-chq); color: var(--violet); }
.segment.reglement-esp input:checked + span { border-color: var(--vert); background: var(--teinte-esp); color: var(--vert); }
.segment.reglement-vir input:checked + span { border-color: var(--accent); background: var(--teinte-vir); color: var(--accent); }
.segment input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }

.raccourcis-date { display: flex; gap: .4rem; margin-top: .5rem; }
.puce-date {
  border: 1px dashed var(--bordure); background: transparent; color: var(--texte-doux);
  border-radius: 999px; padding: .3rem .8rem; font-size: .8rem; font-weight: 600; cursor: pointer;
}
.puce-date:hover { border-color: var(--accent); color: var(--accent); }

/* Interrupteur « déjà encaissée ». */
.bascule { display: flex; align-items: center; gap: .6rem; margin-top: .8rem; cursor: pointer; min-height: 44px; }
.bascule input { position: absolute; opacity: 0; pointer-events: none; }
.bascule .piste {
  width: 46px; height: 26px; border-radius: 999px; background: var(--carte-haute);
  border: 1px solid var(--bordure); position: relative; flex: 0 0 auto; transition: background .15s;
}
.bascule .piste::after {
  content: ""; position: absolute; top: 2px; left: 2px; width: 20px; height: 20px;
  border-radius: 50%; background: var(--texte-doux); transition: transform .15s, background .15s;
}
.bascule input:checked + .piste { background: var(--teinte-esp); border-color: var(--vert); }
.bascule input:checked + .piste::after { transform: translateX(20px); background: var(--vert); }
.bascule input:focus-visible + .piste { outline: 2px solid var(--accent); outline-offset: 2px; }
.bascule .texte { font-weight: 600; font-size: .9rem; }

/* Résultats de recherche de cliente : lignes tactiles. */
.resultats-clients { display: flex; flex-direction: column; gap: .35rem; margin-top: .5rem; max-height: 15rem; overflow-y: auto; }
.resultat-client {
  display: flex; flex-direction: column; align-items: flex-start; gap: .1rem;
  width: 100%; min-height: 46px; padding: .45rem .7rem; text-align: left;
  border: 1px solid var(--bordure); border-radius: 10px; background: var(--carte);
  color: var(--texte); cursor: pointer;
}
.resultat-client .nom-client { font-weight: 600; }
.resultat-client:hover { border-color: var(--accent); }
.resultat-client.choisi { border-color: var(--accent); background: var(--accent-fonce); }
.resultat-client.choisi .nom-client::after { content: " ✓"; color: var(--accent); }

/* Pied de modale : le total reste sous les yeux pendant la saisie. */
.modale-pied { flex-direction: column; align-items: stretch; gap: .6rem; }
.total-pied { display: flex; align-items: baseline; justify-content: space-between; gap: 1rem; }
.total-pied span { color: var(--texte-doux); font-size: .8rem; text-transform: uppercase; letter-spacing: .05em; }
.total-pied strong { font-size: 1.4rem; font-variant-numeric: tabular-nums; color: var(--accent); }
.actions-pied { display: flex; gap: .5rem; justify-content: flex-end; }
.actions-pied .bouton { flex: 1 1 auto; }

.prestations-saisie { display: flex; flex-direction: column; gap: .4rem; }
.ligne-prestation { display: grid; grid-template-columns: 1fr 110px; gap: .5rem; }
.ligne-prestation[hidden] { display: none; }
.choix-client {
  display: flex; flex-wrap: wrap; gap: 1.2rem;
  margin: .2rem 0 .8rem; padding: .6rem .8rem;
  background: var(--fond-doux); border-radius: 10px;
}
.choix-client .case { margin: 0; }
.erreur-champ { border-color: var(--rouge) !important; }
.total-saisie {
  display: flex; justify-content: space-between; align-items: baseline;
  margin-top: .9rem; padding-top: .7rem; border-top: 1px solid var(--bordure);
}
.total-saisie strong { font-size: 1.2rem; font-variant-numeric: tabular-nums; }
label.case { display: flex; align-items: center; gap: .4rem; min-height: 42px; }
label.case input { width: auto; }

@media (max-width: 640px) {
  dialog.modale { width: 100vw; max-width: 100vw; height: 100dvh; max-height: 100dvh; margin: 0; }
  .modale-boite { border-radius: 0; height: 100dvh; max-height: 100dvh; }
  .ligne-prestation { grid-template-columns: 1fr 84px; }
}

/* --------------------------------------------------------------- PC large */
@media (min-width: 900px) {
  .vue { padding-bottom: 2rem; }
  .onglets-bas { display: none; }
  .onglets-haut { display: flex; }
  .entete-ligne { padding-bottom: .1rem; }
}

/* ------------------------------------------------------------- téléphone */
@media (max-width: 720px) {
  .liste .entete-liste { display: none; }
  .liste .ligne {
    grid-template-columns: 1fr !important;
    gap: .15rem;
    padding: .8rem .9rem;
    align-items: start;
  }
  .liste .ligne .cell::before {
    content: attr(data-libelle) " "; color: var(--texte-doux); font-size: .74rem;
    text-transform: uppercase; letter-spacing: .04em;
  }
  .liste .ligne .cell { display: block; }
  .liste .ligne .cell.principal { font-weight: 600; font-size: 1rem; }
  .liste .ligne .n { text-align: left; }
  .duo { grid-template-columns: 1fr; gap: 0; }
  .duo dt { margin-top: .5rem; }
  .facture-ligne { grid-template-columns: 1fr 96px; }
  /* Barre d'outils compacte sur téléphone : chaque pixel économisé ici est donné
     à la liste, qui est la seule zone à défiler. */
  .barre-outils { flex-direction: column; align-items: stretch; gap: .35rem; margin-bottom: .5rem; }
  .barre-outils .barre-actions { gap: .35rem; }
  .barre-outils .bouton { padding: .38rem .6rem; font-size: .82rem; }

  /* ---- La liste est la seule zone à défiler : tout l'espace récupérable ici
     lui revient (titre, réserve sous la page, réglages secondaires). ------- */
  /* #vue réserve 6 rem pour la barre d'onglets fixe : on la déduit déjà dans le
     calcul de hauteur de la liste, donc cette réserve devient inutile. */
  #vue.vue-defilante { padding-bottom: calc(.4rem + env(safe-area-inset-bottom)); }
  #vue.vue-defilante .titre-vue { margin-bottom: .5rem; }
  #vue.vue-defilante .titre-vue h1 { font-size: 1.25rem; }
  #vue.vue-defilante .titre-vue .discret { font-size: .76rem; line-height: 1.35; }
  /* « Aucun filtre actif » n'apprend rien : on ne l'affiche que s'il y a des puces. */
  .puces.vide { display: none; }
  /* Vues sauvegardées, nombre par page et sauvegarde : rangés dans le panneau
     de filtres sur téléphone, pour laisser la barre d'outils sur une ligne. */
  .outils-liste {
    margin-top: .7rem; padding-top: .7rem; border-top: 1px solid var(--bordure);
  }
  .outils-liste #vues-enregistrees { flex: 1 1 140px; min-width: 0; }

  /* ---- Factures : une carte par facture, trois repères seulement -------
     Avant, chaque ligne empilait 7 champs étiquetés (« RÉF », « DATE »,
     « CLIENT »…) : illisible et très long. On garde la date, la cliente et le
     montant facturé (les repères choisis par Marc), le reste passe en petit. */
  .liste .ligne.col-factures {
    grid-template-columns: auto 1fr auto !important;
    grid-template-areas:
      "date   date   facture"
      "client client client"
      "ref    regl   pointage";
    align-items: center;
    column-gap: .5rem;
    row-gap: .35rem;
    padding: .8rem .9rem;
  }
  .liste .ligne.col-factures > .cell:nth-child(1) { grid-area: ref; }
  .liste .ligne.col-factures > .cell:nth-child(2) { grid-area: date; }
  .liste .ligne.col-factures > .cell:nth-child(3) { grid-area: client; }
  .liste .ligne.col-factures > .cell:nth-child(4) { grid-area: regl; }
  .liste .ligne.col-factures > .cell:nth-child(5) { grid-area: pointage; justify-self: end; }
  .liste .ligne.col-factures > .cell:nth-child(6) { grid-area: facture; justify-self: end; font-size: 1.08rem; }
  /* L'encaissé fait doublon avec le facturé dès que la facture est pointée. */
  .liste .ligne.col-factures > .cell:nth-child(7) { display: none; }
  .liste .ligne.col-factures > .cell:nth-child(1)::before { content: "n° "; }
  .liste .ligne.col-factures > .cell:nth-child(2)::before,
  .liste .ligne.col-factures > .cell:nth-child(3)::before,
  .liste .ligne.col-factures > .cell:nth-child(4)::before,
  .liste .ligne.col-factures > .cell:nth-child(5)::before,
  .liste .ligne.col-factures > .cell:nth-child(6)::before { content: none; }
  .liste .ligne.col-factures > .cell:nth-child(1) {
    font-size: .76rem; color: var(--texte-doux); font-weight: 500;
  }
  .liste .ligne.col-factures > .cell:nth-child(3) small {
    display: block; margin-top: .15rem; font-size: .8rem; font-weight: 400;
  }
  .liste .ligne.col-factures > .cell:nth-child(4) { justify-self: start; }

  /* ---- Clientes : la fiche se lit en trois lignes ---------------------- */
  .liste .ligne.col-clients {
    grid-template-columns: 1fr auto auto !important;
    grid-template-areas:
      "client   facture  ignorer"
      "ville    dernier  ignorer"
      "passages encaisse ignorer";
    align-items: center;
    column-gap: .6rem;
    row-gap: .3rem;
    padding: .75rem .9rem;
  }
  .liste .ligne.col-clients > .cell:nth-child(1) { grid-area: client; }
  .liste .ligne.col-clients > .cell:nth-child(2) { grid-area: ville; }
  .liste .ligne.col-clients > .cell:nth-child(3) { grid-area: passages; }
  .liste .ligne.col-clients > .cell:nth-child(4) { grid-area: dernier; justify-self: end; }
  .liste .ligne.col-clients > .cell:nth-child(5) { grid-area: facture; justify-self: end; font-size: 1.02rem; }
  .liste .ligne.col-clients > .cell:nth-child(6) { grid-area: encaisse; justify-self: end; }
  .liste .ligne.col-clients > .cell:nth-child(1)::before,
  .liste .ligne.col-clients > .cell:nth-child(2)::before,
  .liste .ligne.col-clients > .cell:nth-child(5)::before { content: none; }
  .liste .ligne.col-clients > .cell:nth-child(4)::before { content: "vu le "; }
  .liste .ligne.col-clients > .cell:nth-child(2),
  .liste .ligne.col-clients > .cell:nth-child(3),
  .liste .ligne.col-clients > .cell:nth-child(4),
  .liste .ligne.col-clients > .cell:nth-child(6) {
    font-size: .8rem; color: var(--texte-doux); font-weight: 500;
  }
  .liste .ligne.col-clients > .cell:nth-child(3)::before { content: "passages : "; }
  .liste .ligne.col-clients > .cell:nth-child(6)::before { content: "encaissé "; }
  /* La croix reste atteignable au pouce, sur toute la hauteur de la carte. */
  .liste .ligne.col-clients > .cell:nth-child(7) {
    grid-area: ignorer; align-self: center; justify-self: end; padding-left: .2rem;
  }
  .liste .ligne.col-clients > .cell:nth-child(7)::before { content: none; }
  .liste .ligne .cell.ignorer .bouton.ignorer { width: 34px; height: 34px; font-size: .95rem; }

  /* Pastilles un peu plus grandes au doigt. */
  .liste .ligne .badge-reglement,
  .liste .ligne .etiquette { padding: .2rem .6rem; font-size: .78rem; }
}

/* Cellule « écarter » de la liste des clients : une croix discrète, alignée à droite. */
.liste .ligne .cell.ignorer { display: flex; justify-content: flex-end; align-items: center; }
.liste .ligne .cell.ignorer .bouton.ignorer { padding: 0; }

/* Une facture non pointée = de l'argent à suivre : on le signale. */
.liste .ligne .montant-facture.a-encaisser { color: var(--orange); }
.liste .ligne .pastille-pointage:not(.vert) {
  color: var(--orange);
  border-color: color-mix(in srgb, var(--orange) 55%, var(--bordure));
}

@media print {
  .entete, .onglets-bas, .onglets-haut, .barre-actions, .barre-outils { display: none !important; }
  body { background: #fff; color: #000; }
  .carte { border-color: #ccc; }
}

/* Le balayage lui-même reste actif, seule l'animation est neutralisée. */
@media (prefers-reduced-motion: reduce) {
  .vue.entree-droite, .vue.entree-gauche { animation: none; }
}
