/* Style commun des maquettes du Baromètre commercial */
:root {
  --fond: #f6f5f1; --carte: #ffffff; --carte-2: #f1efe8; --trait: #e3e0d6; --trait-fort: #c9c5b8;
  --texte: #1f1e1b; --texte-2: #5f5e5a; --texte-3: #888780;
  --accent: #185fa5; --accent-clair: #e6f1fb; --accent-moyen: #85b7eb;
  --hausse: #3b6d11; --hausse-fond: #eaf3de; --baisse: #a32d2d; --baisse-fond: #fcebeb;
  --n1: #b4b2a9;
  --s1: #2a78d6; --s2: #eb6834; --s3: #1baf7a; --s4: #eda100; --s5: #e87ba4; --s6: #008300; --s7: #6250d6; --s-autres: #b4b2a9;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --fond: #1a1a18; --carte: #242422; --carte-2: #2c2c2a; --trait: #3a3a37; --trait-fort: #55554f;
    --texte: #f1efe8; --texte-2: #b4b2a9; --texte-3: #888780;
    --accent: #85b7eb; --accent-clair: #0c447c; --accent-moyen: #378add;
    --hausse: #97c459; --hausse-fond: #27500a; --baisse: #f09595; --baisse-fond: #791f1f;
    --n1: #5f5e5a;
    --s1: #3987e5; --s2: #d95926; --s3: #199e70; --s4: #c98500; --s5: #d55181; --s6: #008300; --s7: #9085e9; --s-autres: #5f5e5a;
  }
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--fond); color: var(--texte); font: 14px/1.5 Inter, system-ui, sans-serif; }
header { background: var(--carte); border-bottom: 1px solid var(--trait); padding: 14px 24px; display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.marque { display: flex; flex-direction: column; }
.marque b { font-size: 17px; font-weight: 600; letter-spacing: -0.01em; }
.marque span { font-size: 12px; color: var(--texte-2); }
.etat { margin-left: auto; font-size: 12px; color: var(--texte-2); display: flex; align-items: center; gap: 6px; }
.pastille { width: 8px; height: 8px; border-radius: 50%; background: var(--hausse); }
nav { background: var(--carte); border-bottom: 1px solid var(--trait); padding: 0 24px; display: flex; gap: 4px; overflow-x: auto; }
nav a { padding: 10px 12px; color: var(--texte-2); text-decoration: none; font-size: 13px; border-bottom: 2px solid transparent; white-space: nowrap; }
nav a.actif { color: var(--texte); border-bottom-color: var(--accent); font-weight: 500; }
nav a.bientot { color: var(--texte-3); cursor: default; }
nav a.bientot small { font-size: 10px; margin-left: 4px; }
main { max-width: 1240px; margin: 0 auto; padding: 20px 24px 48px; }
.filtres { display: flex; gap: 12px; flex-wrap: wrap; align-items: end; margin-bottom: 18px; }
.filtres label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--texte-2); }
select, input[type=date] { font: inherit; font-size: 13px; color: var(--texte); background: var(--carte); border: 1px solid var(--trait-fort); border-radius: 8px; padding: 6px 10px; min-width: 170px; }
select:disabled { opacity: 0.55; }
.reinit { font: inherit; font-size: 13px; background: none; border: none; color: var(--accent); cursor: pointer; padding: 6px 4px; }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; margin-bottom: 16px; }
.kpi { background: var(--carte); border: 1px solid var(--trait); border-radius: 12px; padding: 14px 16px; }
.kpi.second { background: transparent; border-style: dashed; }
.kpi .lib { font-size: 12px; color: var(--texte-2); }
.kpi .val { font-size: 26px; font-weight: 600; letter-spacing: -0.02em; margin: 2px 0 4px; font-variant-numeric: tabular-nums; }
.kpi .cmp { font-size: 12px; color: var(--texte-2); display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.ecart { font-weight: 600; padding: 1px 6px; border-radius: 6px; font-size: 12px; }
.ecart.h { color: var(--hausse); background: var(--hausse-fond); }
.ecart.b { color: var(--baisse); background: var(--baisse-fond); }
.grille { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: 12px; margin-bottom: 12px; }
@media (max-width: 900px) { .grille { grid-template-columns: minmax(0, 1fr); } }
.bloc { background: var(--carte); border: 1px solid var(--trait); border-radius: 12px; padding: 16px; min-width: 0; }
.bloc h2 { font-size: 14px; font-weight: 600; margin: 0 0 2px; }
.bloc .sous { font-size: 12px; color: var(--texte-2); margin: 0 0 12px; }
.legende { display: flex; gap: 14px; font-size: 12px; color: var(--texte-2); margin-bottom: 8px; }
.legende i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 5px; vertical-align: -1px; }
.onglets { display: flex; gap: 4px; margin-bottom: 10px; }
.onglets button { font: inherit; font-size: 12px; border: 1px solid var(--trait-fort); background: none; color: var(--texte-2); border-radius: 999px; padding: 3px 10px; cursor: pointer; }
.onglets button.actif { background: var(--accent-clair); color: var(--accent); border-color: var(--accent-moyen); font-weight: 500; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
#rep { word-break: normal; }
.bloc table:has(#rep) { table-layout: fixed; }
th { text-align: left; font-weight: 500; font-size: 12px; color: var(--texte-2); padding: 6px 8px; border-bottom: 1px solid var(--trait); }
td { padding: 7px 8px; border-bottom: 1px solid var(--trait); vertical-align: middle; }
td.n, th.n { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
tbody tr.clic { cursor: pointer; }
tbody tr.clic:hover { background: var(--carte-2); }
.barre { height: 6px; background: var(--accent-moyen); border-radius: 3px; min-width: 2px; }
.lib-rep { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.lib-rep span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tag { font-size: 11px; color: var(--texte-2); background: var(--carte-2); border-radius: 6px; padding: 1px 6px; white-space: nowrap; }
.vide { color: var(--texte-3); text-align: center; padding: 24px; }
.secteurs { display: grid; grid-template-columns: 240px minmax(0, 1fr); gap: 20px; align-items: center; }
@media (max-width: 700px) { .secteurs { grid-template-columns: minmax(0, 1fr); } }
.pastille-s { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 8px; vertical-align: -1px; flex: none; }
.retour { font: inherit; font-size: 12px; background: none; border: none; color: var(--accent); cursor: pointer; padding: 0; margin-left: 8px; }
.note { font-size: 12px; color: var(--texte-3); margin-top: 18px; }
.trunc { max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@media (max-width: 640px) { header, nav, main { padding-left: 16px; padding-right: 16px; } .masque-mobile { display: none; } }
.etat-f { font-size: 11px; font-weight: 500; border-radius: 6px; padding: 1px 7px; white-space: nowrap; }
.etat-f.payee { color: var(--hausse); background: var(--hausse-fond); }
.etat-f.echue { color: var(--baisse); background: var(--baisse-fond); }
.etat-f.irregulier { color: #854f0b; background: #faeeda; }
.etat-f.neutre, .etat-f.aechoir, .etat-f.avoir { color: var(--texte-2); background: var(--carte-2); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .etat-f.irregulier { color: #fac775; background: #633806; } }

/* Tri des tableaux par colonne (tri.js) */
th.triable { cursor: pointer; user-select: none; }
th.triable:hover { color: var(--texte); }
th.trie-asc::after { content: " ▲"; font-size: 9px; color: var(--accent); }
th.trie-desc::after { content: " ▼"; font-size: 9px; color: var(--accent); }

/* Nombre de résultats, en haut des tableaux */
.compte-haut { font-size: 12px; color: var(--texte-2); margin: 4px 0 8px; }
.compte-haut b { color: var(--texte); font-weight: 600; }
.compte-haut:empty { display: none; }

/* Lien vers BatiBarr (fiche client) */
.lien-batibarr { font-size: 12px; font-weight: 500; color: var(--accent); text-decoration: none; border: 1px solid var(--accent-moyen); border-radius: 6px; padding: 2px 8px; white-space: nowrap; }
.lien-batibarr:hover { background: var(--accent-clair); }

/* Formulaire de retour (site en ligne) */
.fenetre-retour { border: 1px solid var(--trait); border-radius: 12px; padding: 0; width: min(520px, calc(100vw - 32px)); background: var(--carte); color: var(--texte); }
.fenetre-retour::backdrop { background: rgba(20, 20, 18, .35); }
.fenetre-retour form { padding: 22px 22px 18px; }
.fenetre-retour h2 { margin: 0 0 2px; font-size: 17px; }
.retour-types { display: flex; gap: 6px; flex-wrap: wrap; margin: 14px 0; }
.retour-types label { cursor: pointer; }
.retour-types input { position: absolute; opacity: 0; pointer-events: none; }
.retour-types span { display: inline-block; font-size: 13px; padding: 5px 12px; border: 1px solid var(--trait-fort); border-radius: 16px; color: var(--texte-2); }
.retour-types input:checked + span { background: var(--accent); border-color: var(--accent); color: #fff; }
.retour-types input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }
.retour-champ { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--texte-2); margin-bottom: 10px; }
.retour-champ input, .retour-champ textarea { font: inherit; font-size: 14px; color: var(--texte); background: var(--carte); border: 1px solid var(--trait-fort); border-radius: 8px; padding: 8px 10px; resize: vertical; }
.retour-msg { font-size: 13px; min-height: 18px; margin: 4px 0 10px; }
.retour-msg.ok { color: var(--hausse); } .retour-msg.erreur { color: var(--baisse); }
.retour-actions { display: flex; justify-content: flex-end; gap: 8px; }
.fenetre-retour .bouton { font: inherit; font-size: 13px; border: 1px solid var(--trait-fort); background: var(--carte); color: var(--texte); border-radius: 8px; padding: 7px 14px; cursor: pointer; }
.fenetre-retour .bouton.principal { background: var(--accent); border-color: var(--accent); color: #fff; }
.fenetre-retour .bouton:disabled { opacity: .6; cursor: wait; }

/* Accueil : anciens clients à recontacter (Bilan) */
.recontacter { margin-bottom: 12px; border-left: 3px solid var(--accent); }
.cartes-recontacter { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 10px; margin-top: 10px; }
@media (max-width: 1000px) { .cartes-recontacter { grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); } }
.carte-rc { border: 1px solid var(--trait); border-radius: 10px; padding: 10px 12px; display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.rc-nom { font-weight: 600; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rc-nom a { color: var(--texte); text-decoration: none; } .rc-nom a:hover { color: var(--accent); text-decoration: underline; }
.rc-secteur { font-size: 11px; color: var(--texte-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rc-alerte { font-size: 12px; font-weight: 600; color: var(--baisse); }
.carte-rc dl { display: grid; grid-template-columns: auto 1fr; gap: 2px 8px; margin: 2px 0 6px; font-size: 12px; }
.carte-rc dt { color: var(--texte-3); } .carte-rc dd { margin: 0; color: var(--texte-2); min-width: 0; }
.carte-rc .lien-batibarr { align-self: flex-start; margin-top: auto; }
