:root {
  --page: #f6f6f3; --surface: #ffffff; --surface-2: #f1f0ec; --ink: #0b0b0b; --ink-2: #52514e; --muted: #898781;
  --line: #e1e0d9; --line-2: #c3c2b7; --accent: #2a78d6; --accent-ink: #ffffff; --focus: #2a78d6;
  --s-nouveau: #2a78d6; --s-pas_de_reponse: #c98500; --s-a_rappeler: #4a3aa7; --s-qualifie: #0b7a0b;
  --s-pas_de_projet: #c4532a; --s-numero_incorrect: #d03b3b; --s-injoignable: #6b6a66;
  --radius: 10px; --shadow: 0 1px 2px rgba(0,0,0,.06), 0 4px 16px rgba(0,0,0,.06);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --page: #0d0d0d; --surface: #1a1a19; --surface-2: #242422; --ink: #ffffff; --ink-2: #c3c2b7; --muted: #898781;
    --line: #2c2c2a; --line-2: #383835; --accent: #3987e5; --focus: #6da7ec;
    --s-nouveau: #5598e7; --s-pas_de_reponse: #eda100; --s-a_rappeler: #9085e9; --s-qualifie: #0ca30c;
    --s-pas_de_projet: #ec835a; --s-numero_incorrect: #e66767; --s-injoignable: #a3a29b;
    --shadow: none;
  }
}
:root[data-theme="dark"] {
  --page: #0d0d0d; --surface: #1a1a19; --surface-2: #242422; --ink: #ffffff; --ink-2: #c3c2b7; --muted: #898781;
  --line: #2c2c2a; --line-2: #383835; --accent: #3987e5; --focus: #6da7ec;
  --s-nouveau: #5598e7; --s-pas_de_reponse: #eda100; --s-a_rappeler: #9085e9; --s-qualifie: #0ca30c;
  --s-pas_de_projet: #ec835a; --s-numero_incorrect: #e66767; --s-injoignable: #a3a29b;
  --shadow: none;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--page); color: var(--ink); font: 14px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; }
a { color: var(--accent); }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

/* ── Boutons & champs */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 8px 12px; border-radius: 8px;
  border: 1px solid var(--line-2); background: var(--surface); cursor: pointer; text-decoration: none; color: var(--ink); white-space: nowrap; }
.btn:hover { background: var(--surface-2); }
.btn.primaire { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primaire:hover { filter: brightness(1.08); }
.btn.petit { padding: 4px 8px; font-size: 12px; }
.btn[disabled] { opacity: .5; cursor: default; }
input[type=text], input[type=email], input[type=password], input[type=search], input[type=url], input[type=datetime-local], input[type=date], select, textarea {
  width: 100%; padding: 8px 10px; border: 1px solid var(--line-2); border-radius: 8px; background: var(--surface); }
textarea { resize: vertical; min-height: 64px; }
label.champ { display: block; font-size: 12px; color: var(--ink-2); margin-bottom: 10px; }
label.champ > span { display: block; margin-bottom: 4px; }

/* ── Mise en page */
.entete { display: flex; align-items: center; gap: 4px; padding: 0 16px; height: 52px; background: var(--surface); border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 5; overflow-x: auto; }
.entete .marque { font-weight: 700; margin-right: 12px; white-space: nowrap; }
.entete nav { display: flex; gap: 2px; }
.entete nav a { padding: 8px 10px; border-radius: 8px; color: var(--ink-2); text-decoration: none; white-space: nowrap; }
.entete nav a.actif { background: var(--surface-2); color: var(--ink); font-weight: 600; }
.entete .droite { margin-left: auto; display: flex; align-items: center; gap: 10px; font-size: 12px; color: var(--muted); white-space: nowrap; }
.compteur { display: inline-block; min-width: 20px; padding: 0 6px; margin-left: 4px; border-radius: 10px; background: var(--accent); color: var(--accent-ink); font-size: 11px; text-align: center; }
main { padding: 16px; max-width: 1400px; margin: 0 auto; }

.deux-colonnes { display: grid; grid-template-columns: minmax(280px, 380px) 1fr; gap: 16px; align-items: start; }
.liste { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; max-height: calc(100vh - 120px); overflow-y: auto; }
.liste .titre { padding: 10px 12px; font-size: 12px; color: var(--ink-2); border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--surface); }
.carte { display: block; width: 100%; text-align: left; padding: 10px 12px; border: 0; border-bottom: 1px solid var(--line); background: none; cursor: pointer; }
.carte:hover { background: var(--surface-2); }
.carte.actif { background: color-mix(in srgb, var(--accent) 10%, transparent); box-shadow: inset 3px 0 0 var(--accent); }
.carte .l1 { display: flex; justify-content: space-between; gap: 8px; font-weight: 600; }
.carte .l2, .carte .l3 { font-size: 12px; color: var(--ink-2); display: flex; gap: 6px; flex-wrap: wrap; align-items: center; margin-top: 2px; }
.retard { color: var(--s-numero_incorrect); font-weight: 600; }

.panneau { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); }
.panneau h2 { margin: 0; font-size: 20px; }
.vide { padding: 40px 16px; text-align: center; color: var(--muted); }
.ligne-infos { display: flex; flex-wrap: wrap; gap: 8px 16px; color: var(--ink-2); margin: 6px 0 14px; }
.grille-infos { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 10px; margin: 12px 0; }
.info { background: var(--surface-2); border-radius: 8px; padding: 8px 10px; }
.info .k { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; }
.info .v { font-weight: 600; word-break: break-word; }
.appeler { font-size: 18px; padding: 10px 16px; }
.alerte { padding: 8px 12px; border-radius: 8px; background: color-mix(in srgb, var(--s-pas_de_reponse) 15%, transparent); margin: 10px 0; font-size: 13px; }

.badge { display: inline-flex; align-items: center; gap: 5px; padding: 1px 8px; border-radius: 10px; font-size: 11px; font-weight: 600;
  border: 1px solid currentColor; white-space: nowrap; }
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge.neutre { color: var(--ink-2); }
.badge.neutre::before { display: none; }
.st-nouveau { color: var(--s-nouveau); } .st-pas_de_reponse { color: var(--s-pas_de_reponse); } .st-a_rappeler { color: var(--s-a_rappeler); }
.st-qualifie { color: var(--s-qualifie); } .st-pas_de_projet { color: var(--s-pas_de_projet); } .st-numero_incorrect { color: var(--s-numero_incorrect); }
.st-injoignable { color: var(--s-injoignable); }

/* ── Tags cumulables */
.tags-zone { border-top: 1px solid var(--line); margin-top: 16px; padding-top: 14px; }
.tags-zone h3 { font-size: 13px; text-transform: uppercase; letter-spacing: .04em; color: var(--ink-2); margin: 0 0 10px; }
.groupe-tags { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-bottom: 8px; }
.groupe-tags .groupe { font-size: 11px; color: var(--muted); width: 60px; text-transform: uppercase; letter-spacing: .03em; }
.tag { padding: 6px 12px; border-radius: 16px; border: 1px solid var(--line-2); background: var(--surface); cursor: pointer; font-size: 13px; }
.tag:hover { border-color: var(--accent); }
.tag.actif { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.tag.actif::before { content: "✓ "; }
.tag-mini { color: var(--accent); }
.tag-mini::before { display: none; }

/* ── SMS + QR code */
.bloc-sms { display: flex; gap: 16px; align-items: flex-start; flex-wrap: wrap; background: var(--surface-2); border-radius: 8px; padding: 12px; margin-top: 4px; }
.bloc-sms .qr { background: #fff; padding: 8px; border-radius: 6px; line-height: 0; }
.bloc-sms .sms-texte { flex: 1; min-width: 220px; }
.bloc-sms .k { font-size: 12px; color: var(--ink-2); margin-bottom: 6px; }
.bloc-sms pre { white-space: pre-wrap; font: inherit; margin: 0 0 10px; }

/* ── Saisie de l'issue d'appel */
.issue { border-top: 1px solid var(--line); margin-top: 16px; padding-top: 14px; }
.issue h3, .historique h3 { font-size: 13px; text-transform: uppercase; letter-spacing: .04em; color: var(--ink-2); margin: 0 0 10px; }
.choix { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 8px; }
.choix button { padding: 12px 8px; border-radius: 8px; border: 2px solid var(--line-2); background: var(--surface); cursor: pointer; font-weight: 600; }
.choix button:hover { border-color: currentColor; }
.choix button.actif { border-color: currentColor; background: color-mix(in srgb, currentColor 12%, var(--surface)); }
.choix kbd { font: 11px ui-monospace, monospace; color: var(--muted); margin-left: 4px; }
.complement { margin-top: 12px; display: grid; gap: 10px; }
.raccourcis { display: flex; flex-wrap: wrap; gap: 6px; }
.raccourcis .btn.actif { border-color: var(--accent); color: var(--accent); }
.actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 12px; flex-wrap: wrap; }

.historique { margin-top: 18px; }
.histo { border-left: 2px solid var(--line); padding: 0 0 12px 12px; position: relative; }
.histo::before { content: ""; position: absolute; left: -5px; top: 4px; width: 8px; height: 8px; border-radius: 50%; background: var(--line-2); }
.histo .meta { font-size: 12px; color: var(--muted); }

/* ── Tableaux */
.filtres { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; align-items: center; }
.filtres > * { width: auto; }
.filtres input[type=search] { min-width: 220px; }
.table-wrap { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
th, td { padding: 8px 10px; border-bottom: 1px solid var(--line); text-align: left; white-space: nowrap; }
th { font-size: 12px; color: var(--ink-2); font-weight: 500; background: var(--surface); position: sticky; top: 0; }
td.n, th.n { text-align: right; }
tbody tr.cliquable { cursor: pointer; }
tbody tr.cliquable:hover { background: var(--surface-2); }
h1 { font-size: 18px; margin: 0 0 12px; }
h2.section { font-size: 15px; margin: 24px 0 10px; }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; margin-bottom: 12px; }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; }
.kpi .k { font-size: 12px; color: var(--ink-2); } .kpi .v { font-size: 22px; font-weight: 700; }

/* ── Fenêtre modale (détail depuis « Tous les leads ») */
.voile { position: fixed; inset: 0; background: rgba(0,0,0,.4); display: flex; justify-content: flex-end; z-index: 20; }
.voile .panneau { width: min(720px, 100%); height: 100%; overflow-y: auto; border-radius: 0; }

/* ── Connexion */
.connexion { max-width: 360px; margin: 12vh auto; }
.connexion h1 { font-size: 22px; }
.erreur { color: var(--s-numero_incorrect); font-size: 13px; margin: 8px 0; }

#toast { position: fixed; bottom: 16px; left: 50%; transform: translateX(-50%); background: var(--ink); color: var(--page); padding: 10px 16px;
  border-radius: 8px; opacity: 0; pointer-events: none; transition: opacity .2s; z-index: 30; max-width: calc(100% - 32px); }
#toast.visible { opacity: 1; }
.retour-liste { display: none; }

@media (max-width: 820px) {
  .deux-colonnes { grid-template-columns: 1fr; }
  .deux-colonnes.lead-ouvert .liste { display: none; }
  .deux-colonnes:not(.lead-ouvert) .panneau { display: none; }
  .retour-liste { display: inline-flex; margin-bottom: 10px; }
  .liste { max-height: none; }
  .entete .droite .qui { display: none; }
}
