/* Nouvelle gestion du socle. Charte Casabianca : gris du logo #565656, orange #FF6600, fond crème, police Jost. */
:root {
  color-scheme: light;
  --encre: #24211e;
  --encre-2: #4a4540;
  --discret: #7c756c;
  --orange: #ff6600;
  --orange-texte: #b84a00;
  --orange-pale: #fff0e4;
  --orange-voile: rgba(255, 102, 0, .10);
  --fond: #f6f2ec;
  --carte: #ffffff;
  --carte-2: #fbf9f6;
  --ligne: #e9e2d8;
  --ligne-forte: #d9d0c3;
  --survol: #f7f2eb;
  --vert: #2f7a46;
  --vert-pale: #e4f2e8;
  --rouge: #b3261e;
  --rouge-pale: #fbe5e3;
  --ambre: #a86400;
  --ambre-pale: #fdf0dc;
  /* La barre de gauche reste foncée dans les deux thèmes : c'est le repère de l'appli. */
  --rail: #1f1c1a;
  --rail-2: #2a2623;
  --rail-texte: #cfc7bc;
  --rail-discret: #8a8279;
  --ombre-1: 0 1px 2px rgba(36, 33, 30, .06);
  --ombre-2: 0 1px 2px rgba(36, 33, 30, .05), 0 8px 24px rgba(36, 33, 30, .08);
  --ombre-3: 0 24px 64px rgba(20, 16, 12, .22);
  --r: 14px;
  --r-petit: 9px;
  --police: 'Jost', 'Segoe UI', system-ui, sans-serif;
  --largeur-rail: 236px;
  --haut-entete: 64px;
}
:root[data-theme="sombre"] {
  color-scheme: dark;
  --encre: #efe9e1;
  --encre-2: #cfc7bc;
  --discret: #9a9288;
  --orange: #ff7a1f;
  --orange-texte: #ff9b55;
  --orange-pale: #3a2618;
  --orange-voile: rgba(255, 122, 31, .14);
  --fond: #141210;
  --carte: #1e1b19;
  --carte-2: #191715;
  --ligne: #312d29;
  --ligne-forte: #433e38;
  --survol: #26221f;
  --vert: #6cc28a;
  --vert-pale: #1d2e22;
  --rouge: #ff8a80;
  --rouge-pale: #3a1e1c;
  --ambre: #f0b35a;
  --ambre-pale: #33270f;
  --rail: #0e0d0c;
  --rail-2: #1c1a18;
  --ombre-1: 0 1px 2px rgba(0, 0, 0, .3);
  --ombre-2: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .3);
  --ombre-3: 0 24px 64px rgba(0, 0, 0, .55);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; min-height: 100vh; background: var(--fond); color: var(--encre);
  font: 15px/1.45 var(--police); font-variant-numeric: tabular-nums;
}
h1, h2, h3, h4 { margin: 0; font-weight: 600; line-height: 1.2; }
a { color: var(--orange-texte); }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; }
input, select, textarea {
  width: 100%; padding: .55rem .7rem; border: 1px solid var(--ligne-forte); border-radius: var(--r-petit);
  background: var(--carte); transition: border-color .12s, box-shadow .12s;
}
input:hover, select:hover, textarea:hover { border-color: var(--discret); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--orange); box-shadow: 0 0 0 3px var(--orange-voile); }
button:focus-visible, a:focus-visible, [tabindex]:focus-visible { outline: 2px solid var(--orange); outline-offset: 2px; }
input[type="checkbox"] { width: auto; accent-color: var(--orange); }
textarea { min-height: 4.5rem; resize: vertical; }
label { display: grid; gap: .3rem; font-size: .85rem; font-weight: 500; color: var(--encre-2); }
::selection { background: var(--orange-voile); }

/* ---------- Boutons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .45rem; white-space: nowrap;
  height: 38px; padding: 0 1rem; border-radius: 10px; font-weight: 600; font-size: .92rem;
  border: 1px solid var(--ligne-forte); background: var(--carte); color: var(--encre);
  transition: background .12s, border-color .12s, transform .06s;
}
.btn:hover { border-color: var(--discret); background: var(--survol); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: default; }
.btn.plein { background: var(--orange); border-color: var(--orange); color: #fff; }
.btn.plein:hover { background: #e85c00; border-color: #e85c00; }
:root[data-theme="sombre"] .btn.plein { color: #1a0d03; }
.btn.danger { color: var(--rouge); }
.btn.danger:hover { background: var(--rouge-pale); border-color: var(--rouge); }
.btn.fantome { border-color: transparent; background: none; }
.btn.fantome:hover { background: var(--survol); }
.btn.petit { height: 30px; padding: 0 .7rem; font-size: .85rem; border-radius: 8px; }
.btn.icone-seule { width: 38px; padding: 0; }
.btn.petit.icone-seule { width: 30px; }
.btn svg, .ico { width: 18px; height: 18px; flex: none; }
a.btn { text-decoration: none; }
.lien { color: var(--orange-texte); text-decoration: underline; text-underline-offset: 2px; font-weight: 500; }
.ico { stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- Écrans de connexion ---------- */
.ecran-centre {
  min-height: 100vh; display: grid; place-items: center; padding: 24px;
  background:
    radial-gradient(1200px 600px at 85% -10%, var(--orange-voile), transparent 60%),
    radial-gradient(900px 500px at -10% 110%, rgba(86, 86, 86, .10), transparent 60%), var(--fond);
}
.carte-connexion {
  width: min(420px, 100%); background: var(--carte); border: 1px solid var(--ligne); border-radius: 20px;
  padding: 32px; box-shadow: var(--ombre-2); display: grid; gap: 14px;
}
.carte-connexion img { height: 64px; justify-self: center; margin-bottom: 6px; }
:root[data-theme="sombre"] .carte-connexion img, :root[data-theme="sombre"] .logo-clair { filter: invert(1) hue-rotate(180deg) brightness(1.1); }
.carte-connexion h1 { font-size: 1.6rem; text-align: center; }
.carte-connexion p { margin: 0; color: var(--discret); font-size: .9rem; text-align: center; }
.carte-connexion .btn { height: 44px; margin-top: 6px; }
.erreur { color: var(--rouge); font-size: .88rem; min-height: 1.2em; margin: 0; }

/* ---------- Mise en page ---------- */
.appli { display: grid; grid-template-columns: var(--largeur-rail) 1fr; min-height: 100vh; }
.appli.replie { --largeur-rail: 72px; }

.rail {
  position: sticky; top: 0; height: 100vh; background: var(--rail); color: var(--rail-texte);
  display: flex; flex-direction: column; padding: 14px 12px; gap: 4px; overflow: hidden auto; z-index: 30;
}
.rail-haut { display: flex; align-items: center; gap: 10px; padding: 4px 6px 14px; min-height: 52px; }
.rail-marque { display: flex; align-items: center; gap: 10px; text-decoration: none; color: #fff; min-width: 0; }
.rail-marque .sceau {
  width: 36px; height: 36px; border-radius: 10px; flex: none; display: grid; place-items: center;
  background: var(--orange); color: #fff; font-weight: 700; font-size: 1.1rem; letter-spacing: -.02em;
}
.rail-marque span { display: grid; line-height: 1.1; min-width: 0; }
.rail-marque strong { font-size: .98rem; font-weight: 600; white-space: nowrap; }
.rail-marque small { color: var(--rail-discret); font-size: .75rem; letter-spacing: .08em; text-transform: uppercase; }
.rail-replier { margin-left: auto; color: var(--rail-discret); width: 28px; height: 28px; border-radius: 8px; display: grid; place-items: center; flex: none; }
.rail-replier:hover { background: var(--rail-2); color: #fff; }
.rail-recherche {
  display: flex; align-items: center; gap: 10px; height: 38px; padding: 0 10px; margin-bottom: 8px; border-radius: 10px;
  background: var(--rail-2); color: var(--rail-discret); font-size: .9rem; border: 1px solid #ffffff10;
}
.rail-recherche:hover { color: #fff; border-color: #ffffff22; }
.rail-recherche kbd { margin-left: auto; }
kbd {
  font: 600 .7rem/1 var(--police); padding: 3px 6px; border-radius: 5px; border: 1px solid currentColor; opacity: .7; white-space: nowrap;
}
.rail-titre { font-size: .7rem; font-weight: 600; letter-spacing: .1em; text-transform: uppercase; color: var(--rail-discret); padding: 14px 10px 6px; white-space: nowrap; }
.rail a.entree, .rail button.entree {
  display: flex; align-items: center; gap: 12px; height: 38px; padding: 0 10px; border-radius: 10px;
  color: var(--rail-texte); text-decoration: none; font-weight: 500; white-space: nowrap; position: relative; width: 100%;
}
.rail .entree:hover { background: var(--rail-2); color: #fff; }
.rail .entree.actif { background: linear-gradient(90deg, rgba(255, 102, 0, .22), rgba(255, 102, 0, .06)); color: #fff; }
.rail .entree.actif::before { content: ''; position: absolute; left: -12px; top: 8px; bottom: 8px; width: 3px; border-radius: 0 3px 3px 0; background: var(--orange); }
.rail .entree.actif .ico { color: var(--orange); }
.rail .entree .externe { width: 14px; height: 14px; margin-left: auto; opacity: .5; }
.rail .badge { margin-left: auto; font-size: .72rem; font-weight: 600; background: var(--rail-2); color: var(--rail-texte); padding: 1px 7px; border-radius: 99px; }
.rail-bas { margin-top: auto; display: grid; gap: 4px; padding-top: 10px; border-top: 1px solid #ffffff12; }
.moi { display: flex; align-items: center; gap: 10px; padding: 8px 8px; border-radius: 10px; text-align: left; color: var(--rail-texte); width: 100%; }
.moi:hover { background: var(--rail-2); }
.moi .initiale { width: 32px; height: 32px; border-radius: 50%; background: #565656; color: #fff; display: grid; place-items: center; font-weight: 600; flex: none; }
.moi span { display: grid; line-height: 1.15; min-width: 0; }
.moi strong { color: #fff; font-weight: 600; }
.moi small { color: var(--rail-discret); font-size: .78rem; }
.appli.replie .rail-marque span, .appli.replie .rail-recherche span, .appli.replie .rail-recherche kbd,
.appli.replie .rail-titre, .appli.replie .entree span, .appli.replie .entree .externe, .appli.replie .badge, .appli.replie .moi span { display: none; }
.appli.replie .rail-haut { flex-direction: column; gap: 8px; }
.appli.replie .rail-replier { margin: 0; transform: rotate(180deg); }
.appli.replie .rail-titre { display: block; height: 10px; padding: 0; }
.appli.replie .entree, .appli.replie .rail-recherche, .appli.replie .moi { justify-content: center; padding: 0; }

.principal-zone { min-width: 0; display: flex; flex-direction: column; }
.bandeau-test {
  position: fixed; right: 16px; bottom: 16px; z-index: 70; max-width: 320px; pointer-events: none;
  background: var(--ambre-pale); color: var(--ambre); border: 1px solid color-mix(in srgb, var(--ambre) 35%, transparent);
  font-size: .78rem; font-weight: 600; padding: 6px 12px; border-radius: 10px; box-shadow: var(--ombre-2); opacity: .92;
}

/* En-tête de page : titre, lentille du point de vente, période. */
.entete {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
  min-height: 64px; padding: 10px 28px; background: color-mix(in srgb, var(--fond) 82%, transparent);
  backdrop-filter: saturate(1.4) blur(12px); -webkit-backdrop-filter: saturate(1.4) blur(12px); border-bottom: 1px solid var(--ligne);
}
.entete h1 { font-size: 1.45rem; letter-spacing: -.01em; white-space: nowrap; }
.entete .fil { color: var(--discret); font-size: .8rem; display: block; font-weight: 500; letter-spacing: .02em; }
.entete .espace { flex: 1; }
.entete-actions { display: flex; gap: 8px; align-items: center; }

/* La « lentille » : choisit le point de vente regardé, garde la page. */
.lentille { display: inline-flex; padding: 3px; gap: 2px; background: var(--carte); border: 1px solid var(--ligne); border-radius: 12px; box-shadow: var(--ombre-1); }
.lentille button {
  display: inline-flex; align-items: center; gap: 7px; height: 32px; padding: 0 12px; border-radius: 9px; font-weight: 500;
  color: var(--encre-2); white-space: nowrap; font-size: .9rem;
}
.lentille button:hover { background: var(--survol); color: var(--encre); }
.lentille button.actif { background: var(--encre); color: var(--fond); }
.lentille .pastille-c { width: 8px; height: 8px; border-radius: 50%; background: var(--c, var(--discret)); box-shadow: 0 0 0 2px color-mix(in srgb, var(--c) 25%, transparent); }
.lentille button.actif .pastille-c { box-shadow: 0 0 0 2px color-mix(in srgb, var(--c) 45%, transparent); }
.lentille kbd { font-size: .62rem; padding: 2px 4px; opacity: .45; }
.lentille button.actif kbd { opacity: .6; }

.periode { display: inline-flex; align-items: center; gap: 2px; background: var(--carte); border: 1px solid var(--ligne); border-radius: 12px; padding: 3px; box-shadow: var(--ombre-1); }
.periode button { height: 32px; min-width: 32px; border-radius: 9px; display: grid; place-items: center; color: var(--encre-2); }
.periode button:hover { background: var(--survol); color: var(--encre); }
.periode .libelle { position: relative; padding: 0 10px; font-weight: 600; min-width: 150px; text-align: center; height: 32px; display: grid; place-items: center; border-radius: 9px; cursor: pointer; white-space: nowrap; }
.periode .libelle:hover { background: var(--survol); }
.periode .libelle input { position: absolute; inset: 0; opacity: 0; cursor: pointer; padding: 0; border: 0; }
.periode .aujourdhui { padding: 0 10px; font-size: .85rem; font-weight: 500; }

/* ---------- Contenu ---------- */
.contenu { padding: 24px 28px 48px; display: grid; gap: 20px; align-content: start; min-width: 0; }
.carte { background: var(--carte); border: 1px solid var(--ligne); border-radius: var(--r); box-shadow: var(--ombre-1); min-width: 0; }
.carte > h3, .carte-titre { display: flex; align-items: center; gap: 10px; font-size: 1rem; padding: 16px 18px 0; }
.carte-titre .espace { flex: 1; }
.carte-corps { padding: 14px 18px 18px; }
.carte-titre small { color: var(--discret); font-weight: 400; font-size: .85rem; }
.grille { display: grid; gap: 20px; }
.grille.deux { grid-template-columns: repeat(auto-fit, minmax(420px, 1fr)); }
.grille.trois { grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); }
.aide { color: var(--discret); font-size: .85rem; margin: 0; }
.vide { color: var(--discret); text-align: center; padding: 48px 16px; }
.vide strong { display: block; color: var(--encre); font-size: 1.05rem; margin-bottom: 4px; }
.chargement { display: grid; gap: 12px; }
.chargement i { display: block; height: 90px; border-radius: var(--r); background: linear-gradient(90deg, var(--carte) 0%, var(--survol) 50%, var(--carte) 100%); background-size: 200% 100%; animation: luire 1.2s infinite linear; border: 1px solid var(--ligne); }
@keyframes luire { to { background-position: -200% 0; } }

/* Chiffres clés */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 14px; }
.kpi { background: var(--carte); border: 1px solid var(--ligne); border-radius: var(--r); padding: 14px 16px; box-shadow: var(--ombre-1); display: grid; gap: 2px; position: relative; overflow: hidden; }
.kpi span { color: var(--discret); font-size: .82rem; font-weight: 500; }
.kpi strong { font-size: 1.55rem; font-weight: 600; letter-spacing: -.01em; white-space: nowrap; }
.kpi small { color: var(--discret); font-size: .8rem; }
.kpi.vedette { background: linear-gradient(135deg, #2a2522, #1f1c1a); border-color: transparent; color: #fff; }
.kpi.vedette span, .kpi.vedette small { color: #c9bfb3; }
.kpi.vedette::after { content: ''; position: absolute; right: -40px; top: -40px; width: 140px; height: 140px; border-radius: 50%; background: radial-gradient(circle, rgba(255, 102, 0, .45), transparent 70%); }
:root[data-theme="sombre"] .kpi.vedette { background: linear-gradient(135deg, #2c2016, #1e1b19); border-color: #3a2a1c; }
.bon { color: var(--vert) !important; }
.moyen { color: var(--ambre) !important; }
.mauvais { color: var(--rouge) !important; }
.surplus { color: var(--bleu-ecart, #2563b0) !important; }
:root[data-theme="sombre"] { --bleu-ecart: #8ab4f8; }
.delta { font-weight: 600; font-size: .8rem; padding: 1px 6px; border-radius: 6px; }
.delta.bon { background: var(--vert-pale); }
.delta.mauvais { background: var(--rouge-pale); }

/* Graphique en barres (SVG dessiné en JS) */
.graphe { position: relative; height: 220px; margin-top: 6px; }
.graphe-barres { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; align-items: end; gap: 4px; height: 190px; border-bottom: 1px solid var(--ligne); }
.graphe-barres button { height: 100%; display: flex; flex-direction: column-reverse; justify-content: flex-start; border-radius: 5px 5px 0 0; position: relative; padding: 0; }
.graphe-barres button:hover { background: var(--survol); }
.graphe-barres button i { display: block; width: 100%; background: var(--c); }
.graphe-barres button i:last-of-type { border-radius: 4px 4px 0 0; }
.graphe-barres button.weekend::after { content: ''; }
.graphe-barres .n1 { position: absolute; left: 15%; right: 15%; height: 2px; background: var(--encre-2); opacity: .45; bottom: var(--n1); }
.graphe-axe { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 4px; font-size: .7rem; color: var(--discret); text-align: center; padding-top: 4px; }
.infobulle {
  position: fixed; z-index: 100; pointer-events: none; background: var(--encre); color: var(--fond); border-radius: 10px;
  padding: 8px 10px; font-size: .82rem; box-shadow: var(--ombre-2); min-width: 150px; transform: translate(-50%, calc(-100% - 10px));
}
.infobulle strong { display: block; margin-bottom: 3px; }
.infobulle div { display: flex; justify-content: space-between; gap: 14px; }
.infobulle i { display: inline-block; width: 8px; height: 8px; border-radius: 2px; background: var(--c); margin-right: 6px; }
.legende { display: flex; gap: 14px; flex-wrap: wrap; font-size: .82rem; color: var(--encre-2); }
.legende span { display: inline-flex; align-items: center; gap: 6px; }
.legende i { width: 10px; height: 10px; border-radius: 3px; background: var(--c); }

/* Cartes des points de vente (accueil) */
.points-cartes { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 14px; }
.point-carte {
  text-align: left; background: var(--carte); border: 1px solid var(--ligne); border-radius: var(--r); padding: 16px 18px; box-shadow: var(--ombre-1);
  display: grid; gap: 8px; position: relative; overflow: hidden; transition: transform .12s, box-shadow .12s, border-color .12s;
}
.point-carte::before { content: ''; position: absolute; inset: 0 auto 0 0; width: 4px; background: var(--c); }
.point-carte:hover { transform: translateY(-2px); box-shadow: var(--ombre-2); border-color: color-mix(in srgb, var(--c) 40%, var(--ligne)); }
.point-carte header { display: flex; align-items: center; gap: 8px; font-weight: 600; font-size: 1.05rem; }
.point-carte header small { margin-left: auto; color: var(--discret); font-weight: 400; font-size: .8rem; }
.point-carte .montant { font-size: 1.6rem; font-weight: 600; letter-spacing: -.01em; }
.point-carte .barre-part { height: 6px; border-radius: 6px; background: var(--ligne); overflow: hidden; }
.point-carte .barre-part i { display: block; height: 100%; width: var(--p); background: var(--c); border-radius: 6px; }
.point-carte dl { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; margin: 0; font-size: .82rem; }
.point-carte dt { color: var(--discret); }
.point-carte dd { margin: 0; font-weight: 600; }

/* ---------- Tableaux ---------- */
.tableau { width: 100%; border-collapse: separate; border-spacing: 0; font-size: .92rem; }
.tableau th { text-align: left; font-weight: 600; font-size: .76rem; letter-spacing: .04em; text-transform: uppercase; color: var(--discret); padding: 10px 12px; border-bottom: 1px solid var(--ligne); white-space: nowrap; background: var(--carte); }
.tableau td { padding: 9px 12px; border-bottom: 1px solid var(--ligne); vertical-align: middle; }
.tableau tr:last-child td { border-bottom: 0; }
.tableau .nb, .tableau th.nb { text-align: right; white-space: nowrap; }
.tableau tbody tr.cliquable { cursor: pointer; }
.tableau tbody tr.cliquable:hover td { background: var(--survol); }
.tableau tfoot td { font-weight: 600; border-top: 1px solid var(--ligne-forte); border-bottom: 0; }
.mini-barre { display: inline-block; width: 64px; height: 6px; border-radius: 6px; background: var(--ligne); vertical-align: middle; margin-right: 8px; overflow: hidden; }
.mini-barre i { display: block; height: 100%; width: var(--p); background: var(--c, var(--orange)); border-radius: 6px; }

.puce { display: inline-flex; align-items: center; gap: 5px; font-size: .76rem; font-weight: 600; padding: 2px 8px; border-radius: 99px; background: var(--survol); color: var(--encre-2); white-space: nowrap; border: 1px solid var(--ligne); }
.puce.orange { background: var(--orange-pale); color: var(--orange-texte); border-color: transparent; }
.puce.vert { background: var(--vert-pale); color: var(--vert); border-color: transparent; }
.puce.rouge { background: var(--rouge-pale); color: var(--rouge); border-color: transparent; }
.puce.c { background: color-mix(in srgb, var(--c) 14%, var(--carte)); color: color-mix(in srgb, var(--c) 80%, var(--encre)); border-color: transparent; }
.puce.c::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: var(--c); }
:root[data-theme="sombre"] .puce.c, :root[data-theme="sombre"] .bascule.oui { color: color-mix(in srgb, var(--c) 40%, var(--encre)); background: color-mix(in srgb, var(--c) 22%, var(--carte)); }

.avatar { width: 34px; height: 34px; border-radius: 50%; display: inline-grid; place-items: center; font-weight: 600; color: #fff; background: var(--c, #8a8580); flex: none; font-size: .95rem; }
.avatar.grand { width: 56px; height: 56px; font-size: 1.4rem; }

/* ---------- Listes maître / détail (produits, clients…) ---------- */
.maitre-detail { display: grid; grid-template-columns: minmax(0, 1fr); gap: 0; min-height: calc(100vh - var(--haut-entete)); align-items: start; }
.maitre-detail.avec-panneau { grid-template-columns: minmax(0, 1fr) var(--largeur-panneau, 520px); }
.maitre { padding: 18px 28px 40px; min-width: 0; display: grid; gap: 14px; align-content: start; }
.outils { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.champ-recherche { position: relative; flex: 1; min-width: 220px; max-width: 520px; }
.champ-recherche .ico { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--discret); width: 17px; height: 17px; }
.champ-recherche input { padding-left: 36px; height: 38px; background: var(--carte); }
.champ-recherche kbd { position: absolute; right: 10px; top: 50%; transform: translateY(-50%); color: var(--discret); }
.filtres { display: flex; gap: 6px; flex-wrap: wrap; }
.filtre {
  height: 30px; padding: 0 11px; border-radius: 99px; border: 1px solid var(--ligne); background: var(--carte); font-size: .84rem; font-weight: 500;
  color: var(--encre-2); display: inline-flex; align-items: center; gap: 6px; white-space: nowrap;
}
.filtre:hover { border-color: var(--ligne-forte); color: var(--encre); }
.filtre.actif { background: var(--encre); color: var(--fond); border-color: var(--encre); }
.filtre small { opacity: .6; font-weight: 600; }
.filtre .pastille-c { width: 7px; height: 7px; border-radius: 50%; background: var(--c); }
.compte { color: var(--discret); font-size: .85rem; }

.liste { background: var(--carte); border: 1px solid var(--ligne); border-radius: var(--r); box-shadow: var(--ombre-1); overflow: clip; }
.liste .tableau th { position: sticky; top: var(--haut-entete); z-index: 2; }
.liste .tableau th.triable { cursor: pointer; user-select: none; }
.liste .tableau th.triable:hover { color: var(--encre); }
.liste .tableau th .fleche { opacity: .8; margin-left: 3px; }
.liste .tableau tbody tr { cursor: pointer; }
.liste .tableau tbody tr:hover td { background: var(--survol); }
.liste .tableau tbody tr.choisi td { background: var(--orange-voile); }
.liste .tableau tbody tr.choisi td:first-child { box-shadow: inset 3px 0 var(--orange); }
.liste .tableau tbody tr.inactif td { color: var(--discret); }
.liste .tableau tbody tr.inactif .nom { text-decoration: line-through; text-decoration-color: var(--ligne-forte); }
.liste .nom { font-weight: 600; }
.surnom { font-style: italic; font-weight: 400; font-size: .85em; color: var(--discret); margin-left: 2px; }
.tableau .centre { text-align: center; }
.arret .nom-arret small.moyen { font-style: italic; }
.compte-mensuel { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border: 1px solid var(--ligne); border-radius: 12px; background: var(--carte-2); }
.compte-mensuel span { display: grid; line-height: 1.25; }
.compte-mensuel small { color: var(--discret); font-size: .8rem; }
.liste .sous { display: block; color: var(--discret); font-size: .8rem; font-weight: 400; }
.cellule-nom { display: flex; align-items: center; gap: 10px; min-width: 0; }
.prix-rapide { font-weight: 600; padding: 3px 8px; margin: -3px -8px; border-radius: 7px; border: 1px dashed transparent; }
.prix-rapide:hover { border-color: var(--ligne-forte); background: var(--carte); }
.prix-saisie { width: 90px; height: 30px; padding: 2px 8px; text-align: right; }
.bascules { display: flex; gap: 4px; flex-wrap: wrap; }
.bascule {
  height: 24px; padding: 0 8px; border-radius: 7px; font-size: .76rem; font-weight: 600; border: 1px dashed var(--ligne-forte); color: var(--discret);
  display: inline-flex; align-items: center; gap: 5px;
}
.bascule::before { content: ''; width: 6px; height: 6px; border-radius: 50%; border: 1.5px solid var(--discret); }
.bascule.oui { border-style: solid; border-color: transparent; background: color-mix(in srgb, var(--c) 15%, var(--carte)); color: color-mix(in srgb, var(--c) 80%, var(--encre)); }
.bascule.oui::before { background: var(--c); border-color: var(--c); }
.bascule:hover { border-color: var(--c); }
.marge { font-size: .85rem; }

/* Panneau de détail, à droite (plein écran sur téléphone) */
.panneau {
  position: sticky; top: var(--haut-entete); height: calc(100vh - var(--haut-entete)); background: var(--carte); border-left: 1px solid var(--ligne); display: flex; flex-direction: column; min-width: 0;
  box-shadow: -12px 0 32px rgba(20, 16, 12, .06); animation: glisser .18s ease-out;
}
@keyframes glisser { from { transform: translateX(24px); opacity: 0; } }
.panneau-entete { display: flex; align-items: center; gap: 10px; padding: 14px 16px 12px 20px; border-bottom: 1px solid var(--ligne); min-height: 64px; }
.panneau-entete h2 { font-size: 1.15rem; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.panneau-entete small { display: block; color: var(--discret); font-size: .78rem; font-weight: 500; }
.panneau > form { display: flex; flex-direction: column; flex: 1; min-height: 0; }
.panneau-corps { flex: 1; min-height: 0; overflow: auto; padding: 18px 20px 28px; display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; align-content: start; }
#vue-client { overflow-x: auto; }
.panneau-pied { display: flex; gap: 8px; align-items: center; padding: 12px 20px; border-top: 1px solid var(--ligne); background: var(--carte-2); }
.panneau-pied .espace { flex: 1; }
.panneau .erreur:empty { display: none; }

/* Formulaires du panneau */
.section { display: grid; gap: 12px; padding: 16px; border: 1px solid var(--ligne); border-radius: 12px; background: var(--carte-2); }
.section > h4 { font-size: .78rem; letter-spacing: .08em; text-transform: uppercase; color: var(--discret); font-weight: 600; }
.deux-champs { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.trois-champs { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.avec-bouton { display: flex; gap: 8px; }
.avec-bouton > :first-child { flex: 1; min-width: 0; }
.cases { display: flex; flex-wrap: wrap; gap: 6px; }
.case {
  display: inline-flex; align-items: center; gap: 7px; padding: 5px 10px 5px 8px; border-radius: 8px; border: 1px solid var(--ligne);
  background: var(--carte); font-weight: 500; font-size: .85rem; color: var(--encre); cursor: pointer; user-select: none;
}
.case:has(input:checked) { border-color: var(--orange); background: var(--orange-pale); color: var(--orange-texte); }
.calcul { font-size: .88rem; color: var(--encre-2); background: var(--carte); border: 1px dashed var(--ligne-forte); border-radius: 9px; padding: 9px 12px; }
.infos { display: grid; gap: 8px; }
.info { display: grid; grid-template-columns: 1fr 1.4fr auto; gap: 8px; }
.interrupteur { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; font-weight: 500; color: var(--encre); font-size: .9rem; }
.interrupteur input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.interrupteur i { width: 38px; height: 22px; border-radius: 99px; background: var(--ligne-forte); position: relative; transition: background .15s; flex: none; }
.interrupteur i::after { content: ''; position: absolute; left: 3px; top: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: transform .15s; box-shadow: 0 1px 2px rgba(0,0,0,.2); }
.interrupteur input:checked + i { background: var(--vert); }
.interrupteur input:checked + i::after { transform: translateX(16px); }
.interrupteur input:focus-visible + i { outline: 2px solid var(--orange); outline-offset: 2px; }

/* Fiche client dans le panneau */
.client-tete { display: flex; gap: 14px; align-items: center; }
.client-tete h3 { font-size: 1.35rem; }
.client-tete .puces { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 6px; }
.coordonnees { display: grid; gap: 6px; font-size: .9rem; margin: 0; }
.coordonnees div { display: flex; gap: 10px; align-items: flex-start; }
.coordonnees .ico { color: var(--discret); width: 16px; height: 16px; margin-top: 2px; }
.note-client { background: var(--ambre-pale); color: var(--encre); border-radius: 10px; padding: 10px 12px; font-size: .88rem; margin: 0; white-space: pre-line; }
.kpis.compacts { grid-template-columns: repeat(2, 1fr); gap: 10px; }
.kpis.compacts .kpi { padding: 10px 12px; box-shadow: none; }
.kpis.compacts .kpi strong { font-size: 1.2rem; }
.onglets { display: flex; gap: 2px; border-bottom: 1px solid var(--ligne); overflow-x: auto; scrollbar-width: none; }
.onglets button { padding: 8px 12px; font-weight: 500; color: var(--discret); border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; font-size: .9rem; }
.onglets button:hover { color: var(--encre); }
.onglets button.actif { color: var(--encre); border-color: var(--orange); }
.onglets small { font-size: .75rem; background: var(--survol); border-radius: 99px; padding: 0 6px; margin-left: 4px; }
.ajout-remise { margin-top: 10px; }
/* Dans le volet du client, la liste prend sa place dans la page : sinon le bas du volet la coupe. */
.ajout-remise .combo-liste { position: static; width: 100%; margin-top: 4px; }
.ajout-remise .combo-item .rayon { font-weight: 600; }
.ajout-remise .combo-item .sous { padding-left: 18px; }
.remises input.court { width: 62px; padding: 4px 6px; }
.remise-en-attente { display: flex; align-items: center; gap: 8px; margin-top: 10px; padding: 8px 10px; border: 1px solid var(--orange); border-radius: var(--r-petit); background: var(--carte); }
.remise-en-attente strong { flex: 1; min-width: 0; }
.remise-en-attente input { width: 64px; padding: 6px 4px 6px 8px; }

/* ---------- Journal ---------- */
.tournee-carte .carte-titre { padding-bottom: 4px; flex-wrap: wrap; }
.tournee-carte .carte-titre .pastille-c { width: 10px; height: 10px; border-radius: 50%; background: var(--c); }
.ruban { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); border-top: 1px solid var(--ligne); border-bottom: 1px solid var(--ligne); margin-top: 12px; }
.ruban > div { padding: 10px 16px; border-right: 1px solid var(--ligne); display: grid; }
.ruban > div:last-child { border-right: 0; }
.ruban span { color: var(--discret); font-size: .76rem; font-weight: 500; }
.ruban strong { font-size: 1.1rem; font-weight: 600; white-space: nowrap; }
.trois-cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 0; }
.trois-cols > div { padding: 12px 6px; border-right: 1px solid var(--ligne); min-width: 0; }
.trois-cols > div:last-child { border-right: 0; }
.trois-cols h4 { font-size: .78rem; letter-spacing: .06em; text-transform: uppercase; color: var(--discret); padding: 4px 12px 6px; }

/* ---------- Notes ---------- */
.notes-grille { display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: 16px; align-items: start; }
.note { display: grid; gap: 0; }
.note header { display: flex; align-items: center; gap: 10px; padding: 14px 16px 10px; }
.note header h3 { font-size: 1.02rem; flex: 1; min-width: 0; }
.note header h3 button { text-align: left; font-weight: 600; }
.note header h3 button:hover { color: var(--orange-texte); }
.note .total { font-size: 1.2rem; font-weight: 600; }
.note.payee { opacity: .72; }
.note.payee .total { color: var(--vert); }
.note .lignes { padding: 0 16px; }
.note .lignes .tableau td { padding: 5px 4px; font-size: .88rem; }
.note .lignes .tableau td:first-child { width: 36px; color: var(--discret); font-weight: 600; }
.note .report td { color: var(--rouge); }
.note footer { display: flex; align-items: center; gap: 8px; padding: 10px 16px 14px; }
.note footer .espace { flex: 1; }
.note details { padding: 4px 16px 0; font-size: .85rem; }
.note summary { cursor: pointer; color: var(--discret); }
.note-tampon { color: var(--vert); font-weight: 600; font-size: .85rem; }
.resume-notes { display: flex; gap: 18px; align-items: center; flex-wrap: wrap; }
.resume-notes strong { font-size: 1.05rem; }

/* ---------- Ordre de passage ---------- */
.arrets { display: grid; gap: 0; }
.arret { display: grid; grid-template-columns: auto 36px 1fr auto; gap: 12px; align-items: center; padding: 8px 14px; border-bottom: 1px solid var(--ligne); background: var(--carte); }
.arret:last-child { border-bottom: 0; }
.arret .rang { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; font-weight: 600; font-size: .85rem; background: color-mix(in srgb, var(--c) 15%, var(--carte)); color: color-mix(in srgb, var(--c) 80%, var(--encre)); }
.arret .nom-arret { text-align: left; font-weight: 600; }
.arret .nom-arret small { display: block; color: var(--discret); font-weight: 400; font-size: .8rem; }
.arret .nom-arret:hover { color: var(--orange-texte); }
.poignee { width: 28px; height: 32px; display: grid; place-items: center; color: var(--discret); cursor: grab; border-radius: 6px; touch-action: none; }
.poignee:hover { background: var(--survol); color: var(--encre); }
.arret.en-deplacement { box-shadow: var(--ombre-3); position: relative; z-index: 3; border-radius: 10px; }
.barre-flottante {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 40; display: flex; gap: 10px; align-items: center;
  background: var(--encre); color: var(--fond); padding: 10px 10px 10px 18px; border-radius: 14px; box-shadow: var(--ombre-3); font-weight: 500;
}
.barre-flottante .btn:not(.plein) { background: transparent; color: var(--fond); border-color: #ffffff40; }

/* ---------- Palette de commandes (Ctrl+K) ---------- */
dialog { border: 0; padding: 0; background: transparent; color: inherit; max-width: none; max-height: none; }
dialog::backdrop { background: rgba(20, 16, 12, .45); backdrop-filter: blur(3px); }
#palette { margin: 12vh auto auto; }
.palette { width: min(640px, calc(100vw - 32px)); background: var(--carte); border-radius: 16px; box-shadow: var(--ombre-3); border: 1px solid var(--ligne); overflow: hidden; }
.palette-champ { display: flex; align-items: center; gap: 10px; padding: 0 16px; border-bottom: 1px solid var(--ligne); }
.palette-champ .ico { color: var(--discret); }
.palette-champ input { border: 0; box-shadow: none !important; height: 56px; font-size: 1.05rem; padding: 0; background: transparent; }
.palette-resultats { max-height: min(56vh, 480px); overflow: auto; padding: 6px; }
.palette-groupe { font-size: .72rem; letter-spacing: .08em; text-transform: uppercase; color: var(--discret); font-weight: 600; padding: 10px 10px 4px; }
.palette-item { display: flex; align-items: center; gap: 12px; width: 100%; padding: 9px 10px; border-radius: 10px; text-align: left; }
.palette-item .ico { color: var(--discret); }
.palette-item small { color: var(--discret); margin-left: auto; font-size: .82rem; white-space: nowrap; }
.palette-item.actif { background: var(--orange-voile); }
.palette-item.actif .ico { color: var(--orange-texte); }
.palette-item mark { background: none; color: var(--orange-texte); font-weight: 600; }
.palette-pied { display: flex; gap: 16px; padding: 8px 16px; border-top: 1px solid var(--ligne); color: var(--discret); font-size: .78rem; background: var(--carte-2); }

.boite { width: min(440px, calc(100vw - 32px)); margin: auto; background: var(--carte); border-radius: 16px; box-shadow: var(--ombre-3); border: 1px solid var(--ligne); padding: 22px; display: grid; gap: 14px; }
.boite h2 { font-size: 1.2rem; }
.boite p { margin: 0; color: var(--encre-2); white-space: pre-line; }
.boite .actions { display: flex; justify-content: flex-end; gap: 8px; }

.menu-flottant { position: fixed; z-index: 60; min-width: 220px; background: var(--carte); border: 1px solid var(--ligne); border-radius: 12px; box-shadow: var(--ombre-3); padding: 6px; display: grid; gap: 2px; }
.menu-flottant button, .menu-flottant a { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 8px; text-align: left; color: var(--encre); text-decoration: none; font-weight: 500; }
.menu-flottant button:hover, .menu-flottant a:hover { background: var(--survol); }
.menu-flottant .danger { color: var(--rouge); }
.menu-flottant hr { border: 0; border-top: 1px solid var(--ligne); margin: 4px 0; }

.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 200; background: var(--encre); color: var(--fond);
  padding: 10px 16px; border-radius: 12px; box-shadow: var(--ombre-3); font-weight: 500; display: flex; gap: 10px; align-items: center; animation: monter .2s ease-out;
}
.toast .ico { color: var(--orange); }
@keyframes monter { from { transform: translate(-50%, 10px); opacity: 0; } }

/* ---------- Téléphone et tablette ---------- */
.barre-mobile { display: none; }
@media (max-width: 1280px) {
  .maitre-detail.avec-panneau { grid-template-columns: minmax(0, 1fr) min(var(--largeur-panneau, 520px), 46vw); }
  .masquer-moyen { display: none; }
}
@media (max-width: 899px) {
  .appli, .appli.replie { grid-template-columns: 1fr; }
  .rail { display: none; }
  .entete { padding: 10px 16px; gap: 10px; top: 0; }
  .entete h1 { font-size: 1.2rem; }
  .entete .espace { display: none; }
  .entete-actions { margin-left: auto; }
  .lentille { order: 5; width: 100%; overflow-x: auto; scrollbar-width: none; }
  .lentille kbd { display: none; }
  .periode { order: 6; width: 100%; justify-content: space-between; }
  .periode .libelle { flex: 1; min-width: 0; }
  .contenu, .maitre { padding: 16px 16px 96px; }
  .grille.deux, .grille.trois { grid-template-columns: 1fr; }
  .kpis { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .kpi strong { font-size: 1.25rem; }
  .masquer-mobile { display: none !important; }
  .maitre-detail.avec-panneau { grid-template-columns: 1fr; }
  .panneau { position: fixed; inset: 0; z-index: 50; height: auto; border: 0; animation: monter-panneau .2s ease-out; }
  @keyframes monter-panneau { from { transform: translateY(30px); opacity: 0; } }
  .liste { overflow-x: auto; }
  .liste .tableau th { top: 0; }
  .deux-champs, .trois-champs { grid-template-columns: 1fr; }
  .trois-cols > div { border-right: 0; border-bottom: 1px solid var(--ligne); }
  .notes-grille { grid-template-columns: 1fr; }
  .champ-recherche { max-width: none; }
  .champ-recherche kbd { display: none; }
  .compte { font-size: .8rem; }
  .bandeau-test { bottom: 80px; right: 8px; left: 8px; max-width: none; text-align: center; font-size: .7rem; }
  .graphe-axe span:nth-child(even) { visibility: hidden; }
  .barre-mobile {
    display: grid; grid-template-columns: repeat(5, 1fr); position: fixed; left: 0; right: 0; bottom: 0; z-index: 45;
    background: var(--rail); padding: 6px 6px calc(6px + env(safe-area-inset-bottom));
  }
  .barre-mobile a, .barre-mobile button { display: grid; justify-items: center; gap: 2px; color: var(--rail-discret); font-size: .7rem; padding: 6px 0; border-radius: 10px; text-decoration: none; }
  .barre-mobile .actif { color: #fff; }
  .barre-mobile .actif .ico { color: var(--orange); }
  .toast, .barre-flottante { bottom: 84px; }
}

/* ---------- Impression des notes : 4 notes A6 par feuille A4 (même mise en page que l'ancienne gestion) ---------- */
/* ---------- Factures ---------- */
.puce.bleu { background: color-mix(in srgb, #2c5c8a 14%, var(--carte)); color: color-mix(in srgb, #2c5c8a 75%, var(--encre)); border-color: transparent; }
.nouvelle-facture { margin-bottom: 10px; }
.nouvelle-facture .champ-recherche { max-width: 620px; }
.nouvelle-facture input { height: 44px; font-size: 1rem; border-color: var(--orange); }
.nouvelle-facture .champ-recherche .ico { color: var(--orange-texte); }
.combo { position: relative; }
.combo .champ-recherche { max-width: 620px; min-width: 0; }
.combo-liste { position: absolute; z-index: 40; left: 0; width: min(620px, 100%); top: calc(100% + 4px); background: var(--carte); border: 1px solid var(--ligne-forte);
  border-radius: 12px; box-shadow: var(--ombre-2); max-height: min(340px, 50vh); overflow: auto; padding: 4px; }
.combo-item { display: flex; align-items: baseline; gap: 12px; width: 100%; padding: 8px 10px; border-radius: 8px; text-align: left; }
.combo-item.actif { background: var(--orange-voile); }
.combo-item small { margin-left: auto; color: var(--discret); white-space: nowrap; font-size: .82rem; }
.combo-item small b { color: var(--orange-texte); font-weight: 600; }
.combo-vide { padding: 8px 10px; margin: 0; }
.comptes-mensuels { gap: 10px; }
.mensuels { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 8px; }
.mensuel { display: grid; gap: 2px; text-align: left; padding: 10px 12px; border: 1px solid var(--ligne); border-radius: 10px; background: var(--carte); }
.mensuel:hover { border-color: var(--orange); background: var(--orange-voile); }
.mensuel .lien { color: var(--orange-texte); font-size: .85rem; font-weight: 500; display: inline-flex; align-items: center; gap: 4px; margin-top: 2px; }
.mensuel .lien .ico { width: 14px; height: 14px; }
#zone-factures { display: grid; gap: 18px; }

.facture-resume { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; }
.facture-resume > div:first-child { display: grid; gap: 2px; min-width: 0; }
.facture-resume .montant { font-size: 1.5rem; font-weight: 600; white-space: nowrap; text-align: right; }
.facture-resume .montant small { display: block; font-size: .75rem; color: var(--discret); font-weight: 500; }
.etapes-facture { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.etapes-facture div { border-top: 4px solid var(--ligne); padding-top: 6px; font-size: .85rem; color: var(--discret); text-align: center; }
.etapes-facture div small { display: block; font-size: .75rem; }
.etapes-facture .fait { border-color: var(--vert); color: var(--encre); }
.etapes-facture .encours { border-color: var(--orange); color: var(--encre); font-weight: 600; }
.actions-facture { display: grid; gap: 10px; padding: 12px 14px; border: 1px solid var(--ligne); border-radius: 12px; }
.alerte { margin: 0; padding: 9px 12px; border-radius: 10px; background: var(--rouge-pale); color: var(--rouge); font-size: .88rem; }
.tableau.compact td { padding: 6px 4px; font-size: .88rem; }
.tableau.compact tr.fort td { font-weight: 700; border-top: 1px solid var(--ligne-forte); }
.panneau .actions { display: flex; gap: 8px; flex-wrap: wrap; }
.empreinte { font-size: .75rem; }

.facture-editeur { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 24px; padding: 16px 28px 48px; align-items: start;
  max-width: 1320px; margin: 0 auto; }
.saisie-facture { display: grid; gap: 12px; min-width: 0; max-width: 760px; }
.barre-retour { display: flex; align-items: center; gap: 10px; }
.barre-retour h2 { font-size: 1.3rem; margin: 0; }
.remise-totaux { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 20px; align-items: start; }
.remise-champs { display: grid; gap: 10px; }
.carte.bloc { padding: 16px 18px; display: grid; gap: 12px; }
.carte.bloc h3 { font-size: 1rem; padding: 0; margin: 0; }
.bloc-tete { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.client-infos { display: flex; flex-wrap: wrap; gap: 4px 18px; font-size: .88rem; color: var(--encre-2); padding-left: 46px; }
.client-infos .manque { color: var(--rouge); }
.client-infos .attention { color: var(--ambre); }
.defile { overflow-x: auto; }
.lignes-facture td { padding: 5px 4px; }
.lignes-facture input, .lignes-facture select { padding: .35rem .5rem; }
.lignes-facture .f-libelle { min-width: 130px; }
.lignes-facture .f-prix { width: 80px; text-align: right; }
.lignes-facture input.court { width: 52px; text-align: right; }
.lignes-facture select { width: 76px; }
.lignes-facture th, .lignes-facture .f-total { white-space: nowrap; }
.unite-champ { display: flex; align-items: center; border: 1px solid var(--ligne-forte); border-radius: var(--r-petit); background: var(--carte); white-space: nowrap; }
.unite-champ:focus-within { border-color: var(--orange); box-shadow: 0 0 0 3px var(--orange-voile); }
.unite-champ input { border: 0 !important; box-shadow: none !important; background: transparent; text-align: right; min-width: 0; }
.unite-champ i { font-style: normal; color: var(--discret); padding-right: 10px; font-size: .9rem; }
.unite-champ.petit { display: inline-flex; }
.unite-champ.petit i { padding-right: 6px; }
.resultat-remise { margin: 0; font-size: .92rem; padding: 9px 12px; border: 1px dashed var(--ligne-forte); border-radius: 10px; background: var(--carte-2); }
.resultat-remise b { color: var(--orange-texte); }
.totaux-facture { display: grid; gap: 4px; font-size: .95rem; }
.totaux-facture div { display: flex; justify-content: space-between; gap: 12px; }
.totaux-facture .fort { font-size: 1.2rem; font-weight: 700; border-top: 1px solid var(--ligne); padding-top: 6px; margin-top: 4px; }
.actions-bas { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
/* L'aperçu tient dans la hauteur de l'écran : sa largeur suit la hauteur disponible, le texte suit la largeur. */
.apercu-facture { position: sticky; top: calc(var(--haut-entete) + 12px); display: grid; gap: 6px; container-type: inline-size;
  width: clamp(300px, calc((100vh - var(--haut-entete) - 64px) * 210 / 297), 440px); }
.apercu-cadre { background: #fff; color: #111; border-radius: 4px; box-shadow: var(--ombre-2); aspect-ratio: 210 / 297; overflow: hidden; font-size: 1.75cqw; }
.apercu-cadre .doc-facture { padding: 5.5% 6%; height: 100%; }

/* Le document de la facture : le même pour l'aperçu et l'impression (tailles en em). */
.doc-facture { position: relative; display: flex; flex-direction: column; gap: 1.6em; line-height: 1.4; color: #111; font-family: 'Jost', 'Segoe UI', sans-serif; box-sizing: border-box; }
.doc-facture .filigrane { position: absolute; inset: 0; display: grid; place-items: center; font-size: 7em; font-weight: 700; color: rgba(0,0,0,.06); transform: rotate(-30deg); pointer-events: none; letter-spacing: .1em; }
.doc-tete { display: flex; justify-content: space-between; gap: 2em; padding-bottom: 1.2em; border-bottom: .25em solid #FF6600; }
.doc-vendeur { display: flex; gap: 1.2em; align-items: flex-start; }
.doc-vendeur img { height: 5.5em; width: auto; }
.doc-vendeur strong { font-size: 1.15em; }
.doc-numero { display: grid; justify-items: end; text-align: right; }
.doc-numero strong { font-size: 2em; line-height: 1.1; }
.doc-parties { display: grid; grid-template-columns: 1fr 1fr; gap: 1.6em; }
.doc-parties > div { border: .1em solid #ddd; border-radius: .4em; padding: .9em 1em; }
.doc-parties em { display: block; font-style: normal; font-size: .8em; letter-spacing: .08em; text-transform: uppercase; color: #666; margin-bottom: .2em; }
.doc-parties strong { font-size: 1.15em; }
.doc-lignes { width: 100%; border-collapse: collapse; font-size: 1em; }
.doc-lignes th { text-align: left; font-weight: 600; border-bottom: .15em solid #111; padding: .4em .3em; font-size: .9em; }
.doc-lignes td { padding: .4em .3em; border-bottom: .08em solid #e3e3e3; }
.doc-lignes .nb { text-align: right; white-space: nowrap; }
.doc-lignes tr.remise td { font-style: italic; }
.doc-bas { display: grid; grid-template-columns: 1fr 22em; gap: 2em; align-items: start; }
.doc-paiement { display: grid; gap: .8em; font-size: .92em; }
.doc-qr { display: flex; gap: 1em; align-items: center; }
.doc-qr svg { width: 9em; height: 9em; flex: none; }
.doc-totaux { display: grid; gap: .25em; }
.doc-totaux table { width: 100%; border-collapse: collapse; font-size: .9em; margin-bottom: .4em; }
.doc-totaux td { padding: .15em 0; text-align: right; }
.doc-totaux td:first-child { text-align: left; }
.doc-totaux > div { display: flex; justify-content: space-between; }
.doc-totaux .fort { font-weight: 700; font-size: 1.3em; border-top: .15em solid #111; padding-top: .3em; margin-top: .2em; }
.doc-mentions { margin-top: auto; border-top: .08em solid #ddd; padding-top: .8em; font-size: .8em; color: #555; }

@media (max-width: 1100px) {
  .facture-editeur { grid-template-columns: minmax(0, 1fr); }
  .saisie-facture { max-width: none; }
  .apercu-facture { position: static; width: auto; max-width: 560px; }
}
/* « screen » : à l'impression, la page peut faire moins de 700 px de large, et la facture doit garder sa mise en page A4. */
@media screen and (max-width: 700px) {
  .facture-editeur { padding: 14px 16px 40px; }
  .remise-totaux { grid-template-columns: minmax(0, 1fr); }
  .client-infos { padding-left: 0; }
  .combo-item { flex-wrap: wrap; gap: 2px 12px; }
  .combo-item small { margin-left: 0; white-space: normal; }
  .apercu-cadre { aspect-ratio: auto; font-size: 7px; }
  .apercu-cadre .doc-bas, .apercu-cadre .doc-parties { grid-template-columns: 1fr; }
  #zone-factures .tableau th:nth-child(3), #zone-factures .tableau td:nth-child(3) { display: none; }
  #zone-factures .tableau td:first-child { white-space: nowrap; }
  #zone-factures .tableau td, #zone-factures .tableau th { padding-left: 8px; padding-right: 8px; }
}

#impression { display: none; }
@media print {
  @page { size: A4 portrait; margin: 5mm; }
  html, body { background: #fff !important; margin: 0 !important; }
  body > *:not(#impression) { display: none !important; }
  #impression { display: block; }
  .feuille-a4 { width: 200mm; height: 286mm; overflow: hidden; display: flex; flex-wrap: wrap; align-content: flex-start;
    page-break-after: always; break-after: page; page-break-inside: avoid; break-inside: avoid; }
  .feuille-a4:last-child { page-break-after: auto; break-after: auto; }
  .note-a6 { box-sizing: border-box; width: 100mm; height: 143mm; padding: 8mm 8mm 7mm; border: 0; display: flex; flex-direction: column;
    font: 9.5pt/1.35 'Jost', sans-serif; color: #000; overflow: hidden; }
  .note-a6:nth-child(odd) { border-right: 0.2mm dashed #999; }
  .note-a6:nth-child(-n+2) { border-bottom: 0.2mm dashed #999; }
  .note-a6 header { display: flex; justify-content: space-between; align-items: flex-start; gap: 3mm; padding-bottom: 3mm; border-bottom: 0.4mm solid #FF6600; }
  .note-a6 header img { height: 11mm; }
  .note-a6 .mois { text-align: right; font-size: 8pt; text-transform: uppercase; letter-spacing: .08em; color: #565656; }
  .note-a6 .mois strong { display: block; font-size: 13pt; letter-spacing: 0; text-transform: none; color: #000; }
  .note-a6 .client { font-size: 16pt; font-weight: 700; margin: 4mm 0 3mm; line-height: 1.15; }
  .note-a6 table { width: 100%; border-collapse: collapse; font-size: 10pt; }
  .note-a6 td { padding: 1.2mm 0; border-bottom: 0.1mm solid #ddd; vertical-align: top; }
  .note-a6 td:first-child { width: 10mm; font-weight: 600; }
  .note-a6 td:last-child { text-align: right; white-space: nowrap; padding-left: 2mm; }
  .note-a6 footer { margin-top: auto; display: grid; gap: 1mm; }
  .note-a6 footer div { display: flex; justify-content: space-between; }
  .note-a6 footer .fort { font-size: 13pt; font-weight: 700; border-top: 0.4mm solid #000; padding-top: 2mm; }
  .note-a6 .tampon { justify-content: center; font-weight: 700; color: #2f7a46; }
  .impression-facture { width: 200mm; height: 286mm; box-sizing: border-box; padding: 8mm 9mm; font-size: 9.5pt; }
  .impression-facture .doc-facture { height: 100%; }
  .impression-facture .filigrane { display: none; }
}
