:root {
  --fond: #f4f6fa;
  --surface: #ffffff;
  --surface-2: #f1f4f9;
  --bord: #e2e7f0;
  --texte: #1b2233;
  --texte-2: #5d6780;
  --accent: #1f4fd8;
  --accent-doux: #e9effd;
  --noir: #0f1629;
  --ok: #1b7f4b;
  --ok-doux: #e3f4ea;
  --alerte: #b35c00;
  --alerte-doux: #fdf0e1;
  --neutre-doux: #eceef2;
  --danger: #c0392b;
  --ombre: 0 1px 2px rgba(20, 30, 50, .05), 0 6px 20px rgba(20, 30, 50, .06);
  --rayon: 10px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --fond: #10131a;
    --surface: #181c25;
    --surface-2: #1f2430;
    --bord: #2b3140;
    --texte: #e6e9ef;
    --texte-2: #9aa3b5;
    --accent: #7c9cff;
    --accent-doux: #222c48;
    --noir: #e6e9ef;
    --ok: #52c98a;
    --ok-doux: #173326;
    --alerte: #f0a94e;
    --alerte-doux: #3a2a15;
    --neutre-doux: #262b36;
    --ombre: none;
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body { font: 14px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; background: var(--fond); color: var(--texte); }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent); }
small, .sec { color: var(--texte-2); }
.sec { font-size: 12px; }
h1 { font-size: 22px; margin: 0 0 4px; }
.sous-titre { margin: 0 0 16px; color: var(--texte-2); max-width: 820px; }
.num { font-variant-numeric: tabular-nums; }
.espace { flex: 1; }

/* ---------- barre du haut */
.haut { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 24px; padding: 0 20px; height: 60px;
  background: var(--surface); border-bottom: 1px solid var(--bord); }
.logo { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 18px; color: var(--texte); text-decoration: none; white-space: nowrap; }
.logo-k { display: grid; place-items: center; width: 30px; height: 30px; border-radius: 50%; background: var(--accent); color: #fff; font-size: 15px; }
.menu { display: flex; gap: 4px; }
.menu a { padding: 8px 12px; border-radius: 8px; color: var(--texte-2); text-decoration: none; white-space: nowrap; display: flex; gap: 6px; align-items: center; }
.menu a:hover { background: var(--surface-2); color: var(--texte); }
.menu a.actif { color: var(--accent); background: var(--accent-doux); font-weight: 600; }
.menu a.discret { font-size: 13px; }
.rapide { margin-left: auto; flex: 0 1 420px; }
.rapide input { width: 100%; padding: 9px 14px; border: 1px solid var(--bord); border-radius: 8px; background: var(--surface); }
.pastille { font-size: 11px; background: var(--accent); color: #fff; border-radius: 10px; padding: 0 7px; }
.pastille:empty { display: none; }

.vue { display: none; }
.vue.active { display: block; }
.page { max-width: 1180px; margin: 0 auto; padding: 24px 20px 40px; }
.page-large { max-width: none; }

/* ---------- boutons & champs */
.btn { border: 1px solid var(--bord); background: var(--surface); padding: 7px 13px; border-radius: 8px; cursor: pointer; white-space: nowrap; text-decoration: none; color: var(--texte); display: inline-flex; align-items: center; gap: 6px; }
.btn:hover { border-color: var(--accent); }
.btn:disabled { opacity: .5; cursor: default; }
.btn-primaire { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-noir { background: var(--noir); border-color: var(--noir); color: var(--fond); font-weight: 600; }
.btn-large { width: 100%; justify-content: center; padding: 11px; }
.btn-lien { border: 0; background: none; color: var(--accent); padding: 4px 0; cursor: pointer; }
.btn-petit { padding: 3px 9px; font-size: 12px; }
.btn-danger { color: var(--danger); }
input[type=search], input[type=text], input[type=email], input[type=tel], input[type=date], input:not([type]), select, textarea {
  padding: 8px 10px; border: 1px solid var(--bord); border-radius: 8px; background: var(--surface); }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent-doux); border-color: var(--accent); }
.case { display: inline-flex; align-items: center; gap: 7px; cursor: pointer; }

/* ---------- accueil */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin: 16px 0; }
.kpi { background: var(--surface); border: 1px solid var(--bord); border-radius: var(--rayon); padding: 14px 16px; cursor: pointer; box-shadow: var(--ombre); }
.kpi:hover { border-color: var(--accent); }
.kpi .v { font-size: 26px; font-weight: 700; font-variant-numeric: tabular-nums; }
.kpi .l { color: var(--texte-2); font-size: 13px; }
.kpi.ok .v { color: var(--ok); } .kpi.alerte .v { color: var(--alerte); }
.carte { background: var(--surface); border: 1px solid var(--bord); border-radius: var(--rayon); padding: 18px; box-shadow: var(--ombre); margin-bottom: 16px; }
.carte h2 { font-size: 13px; margin: 0 0 12px; color: var(--texte-2); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.grille-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.grille-2 .carte { margin-bottom: 0; }
.grille-2 + .carte { margin-top: 16px; }
.rapides { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.rapide-lien { display: flex; justify-content: space-between; align-items: center; padding: 9px 12px; border: 1px solid var(--bord); border-radius: 8px; cursor: pointer; background: var(--surface); text-align: left; }
.rapide-lien:hover { border-color: var(--accent); background: var(--accent-doux); }
.rapide-lien .n { color: var(--texte-2); font-variant-numeric: tabular-nums; }
.barres { display: flex; flex-direction: column; gap: 6px; }
.barre { display: grid; grid-template-columns: 160px 1fr 80px; gap: 10px; align-items: center; cursor: pointer; font-size: 13px; }
.barre:hover .barre-nom { color: var(--accent); }
.barre-nom { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.barre-piste { background: var(--surface-2); border-radius: 4px; height: 10px; overflow: hidden; }
.barre-rempli { background: var(--accent); height: 100%; display: block; }
.barre-n { text-align: right; color: var(--texte-2); font-variant-numeric: tabular-nums; }
.histo { display: flex; align-items: flex-end; gap: 3px; height: 150px; }
.histo div { flex: 1; background: var(--accent); border-radius: 3px 3px 0 0; min-height: 2px; }
.histo-axe { display: flex; justify-content: space-between; color: var(--texte-2); font-size: 11px; margin-top: 4px; }

/* ---------- page de recherche (filtres) */
.recherche { display: grid; grid-template-columns: 300px 1fr; min-height: calc(100vh - 60px); }
.categories { background: var(--surface); border-right: 1px solid var(--bord); padding: 16px 14px; display: flex; flex-direction: column; position: sticky; top: 60px; height: calc(100vh - 60px); overflow: auto; }
.cat-titre { font-size: 18px; font-weight: 700; padding: 0 6px 12px; }
.cat { display: flex; align-items: center; gap: 10px; width: 100%; padding: 11px 12px; margin-bottom: 6px; border: 1px solid var(--bord); border-radius: 9px; background: var(--surface-2); cursor: pointer; text-align: left; }
.cat:hover { border-color: var(--accent); }
.cat.actif { background: var(--accent-doux); border-color: var(--accent); color: var(--accent); font-weight: 600; }
.cat .ico { width: 20px; text-align: center; }
.cat .nb { margin-left: auto; background: var(--accent); color: #fff; border-radius: 10px; font-size: 11px; padding: 0 7px; }
.cat-pied { margin-top: auto; padding-top: 14px; display: flex; flex-direction: column; gap: 8px; align-items: center; position: sticky; bottom: 0; background: var(--surface); }
.panneau { padding: 20px 24px 40px; min-width: 0; }
.picker-titre { font-size: 16px; font-weight: 700; margin: 4px 0 12px; }
.picker-outils { display: flex; gap: 8px; margin-bottom: 12px; }
.picker-outils input { flex: 1; }
.info { background: var(--alerte-doux); color: var(--alerte); padding: 8px 12px; border-radius: 8px; font-size: 13px; margin-bottom: 12px; }
.arbre { background: var(--surface); border: 1px solid var(--bord); border-radius: var(--rayon); padding: 8px 12px; }
.noeud { display: grid; grid-template-columns: 22px 1fr auto 26px; align-items: center; gap: 6px; padding: 5px 0; border-bottom: 1px solid var(--surface-2); }
.noeud:last-child { border-bottom: 0; }
.noeud .plus { border: 0; background: none; cursor: pointer; color: var(--texte-2); font-size: 15px; padding: 0; width: 22px; }
.noeud .lib { cursor: pointer; }
.noeud .lib b { font-variant-numeric: tabular-nums; margin-right: 4px; }
.noeud .n { color: var(--texte-2); font-variant-numeric: tabular-nums; font-size: 13px; }
.noeud input[type=checkbox] { width: 16px; height: 16px; cursor: pointer; }
.noeud.partiel .lib { font-weight: 600; }
.noeud .chemin { display: block; font-size: 11px; color: var(--texte-2); }
.enfants { margin-left: 22px; }
.choix-simple { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 8px; }
.choix { display: flex; align-items: center; gap: 10px; padding: 11px 13px; border: 1px solid var(--bord); border-radius: 9px; background: var(--surface); cursor: pointer; }
.choix:hover { border-color: var(--accent); }
.choix.coche { border-color: var(--accent); background: var(--accent-doux); }
.choix .n { margin-left: auto; color: var(--texte-2); font-variant-numeric: tabular-nums; font-size: 13px; }
.choix-note { font-size: 12px; color: var(--texte-2); margin-top: 10px; }
.bloc-champ { margin-top: 16px; display: flex; gap: 12px; align-items: end; flex-wrap: wrap; }
.bloc-champ label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--texte-2); }

.choisis { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 14px; min-height: 8px; }
.choisis-compact { margin: 6px 0 0; }
.puce-choix { display: inline-flex; align-items: center; gap: 4px; background: var(--accent-doux); color: var(--accent); border-radius: 14px; padding: 3px 6px 3px 11px; font-size: 12px; max-width: 360px; }
.puce-choix span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.puce-choix button { border: 0; background: none; color: inherit; cursor: pointer; font-size: 15px; line-height: 1; padding: 0 3px; }
.puce-choix i { font-style: normal; opacity: .7; }

/* ---------- recherche guidée : tiroirs */
.page-tiroirs { max-width: 980px; padding-bottom: 110px; }
.tiroirs { display: flex; flex-direction: column; gap: 10px; }
.etape { background: var(--surface); border: 1px solid var(--bord); border-radius: 12px; box-shadow: var(--ombre); overflow: hidden; }
.etape.ouvert { border-color: var(--accent); }
.etape.a-venir { opacity: .6; }
.etape-tete { display: flex; align-items: center; gap: 14px; width: 100%; padding: 15px 18px; border: 0; background: none; cursor: pointer; text-align: left; }
.etape-tete:hover .etape-modif { text-decoration: underline; }
.etape-num { display: grid; place-items: center; flex: 0 0 30px; height: 30px; border-radius: 50%; background: var(--surface-2); color: var(--texte-2); font-weight: 700; }
.etape.ouvert .etape-num { background: var(--accent); color: #fff; }
.etape.fait .etape-num { background: var(--ok-doux); color: var(--ok); }
.etape-titre { font-weight: 700; font-size: 16px; white-space: nowrap; }
.etape-resume { color: var(--accent); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; min-width: 0; }
.etape-modif { color: var(--texte-2); font-size: 13px; }
.etape-corps { padding: 0 18px 16px 62px; }
.etape-actions { display: flex; gap: 8px; align-items: center; margin-top: 16px; padding-top: 12px; border-top: 1px solid var(--bord); }
.aide { color: var(--texte-2); font-size: 13px; margin: 0 0 10px; }
.sous-etape { font-size: 13px; color: var(--texte-2); margin: 16px 0 8px; font-weight: 600; }
.sous-etape:first-child { margin-top: 0; }
.onglets { display: inline-flex; border: 1px solid var(--bord); border-radius: 9px; overflow: hidden; margin-bottom: 14px; }
.onglets button { border: 0; background: var(--surface); padding: 9px 16px; cursor: pointer; }
.onglets button + button { border-left: 1px solid var(--bord); }
.onglets button.actif { background: var(--accent); color: #fff; font-weight: 600; }
.barre-bas { position: fixed; left: 0; right: 0; bottom: 0; z-index: 15; display: flex; align-items: center; gap: 14px; padding: 12px 24px;
  background: var(--surface); border-top: 1px solid var(--bord); box-shadow: 0 -4px 16px rgba(20,30,50,.06); }
.vue:not(.active) .barre-bas { display: none; }
#compte-live { font-size: 15px; }
@media (max-width: 720px) { .etape-corps { padding-left: 18px; } .etape-resume { display: none; } }

/* ---------- résultats */
.res-entete { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; flex-wrap: wrap; margin-bottom: 12px; }
.res-actions, .menu-export { display: flex; gap: 8px; flex-wrap: wrap; }
.res-barre { display: flex; align-items: center; gap: 16px; margin-bottom: 10px; flex-wrap: wrap; }
.res-barre label { display: inline-flex; gap: 6px; align-items: center; }
.segments { display: inline-flex; border: 1px solid var(--bord); border-radius: 8px; overflow: hidden; }
.segments button { border: 0; background: var(--surface); padding: 6px 12px; cursor: pointer; font-size: 13px; }
.segments button + button { border-left: 1px solid var(--bord); }
.segments button.actif { background: var(--accent); color: #fff; }
.table-cadre { background: var(--surface); border: 1px solid var(--bord); border-radius: var(--rayon); overflow: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th { position: sticky; top: 0; background: var(--surface-2); text-align: left; padding: 9px 10px; font-size: 12px; color: var(--texte-2); white-space: nowrap; border-bottom: 1px solid var(--bord); }
.table td { padding: 9px 10px; border-bottom: 1px solid var(--bord); vertical-align: top; }
.table tbody tr { cursor: pointer; }
.table tbody tr:hover { background: var(--surface-2); }
.table tbody tr.sel { background: var(--accent-doux); }
.nom { font-weight: 600; }
.tronque { max-width: 230px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.vide { padding: 50px; text-align: center; color: var(--texte-2); }
.pagination { display: flex; gap: 8px; justify-content: center; align-items: center; margin: 14px 0; }
.badge { display: inline-block; padding: 1px 8px; border-radius: 10px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.badge-complet { background: var(--ok-doux); color: var(--ok); }
.badge-a_qualifier { background: var(--alerte-doux); color: var(--alerte); }
.badge-hors_cible, .badge-fermee { background: var(--neutre-doux); color: var(--texte-2); }
.badge-nouveau { background: var(--accent-doux); color: var(--accent); }
.deduit { font-style: italic; color: var(--alerte); }
.deduit::after { content: " ?"; }
.manque { font-size: 11px; color: var(--alerte); margin-top: 3px; }
.ajout-tel { border: 1px dashed var(--bord); background: none; color: var(--texte-2); border-radius: 6px; padding: 2px 8px; cursor: pointer; font-size: 12px; }
.ajout-tel:hover { border-color: var(--accent); color: var(--accent); }
.saisie-tel { padding: 4px 6px; font-size: 13px; width: 130px; }

/* ---------- mes recherches & import */
.listes { display: grid; grid-template-columns: repeat(auto-fill, minmax(330px, 1fr)); gap: 14px; }
.liste h3 { margin: 0 0 8px; font-size: 16px; }
.liste .actions { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 12px; }
.alerte-nouv { display: inline-block; background: var(--accent); color: #fff; border-radius: 12px; padding: 1px 9px; font-size: 12px; font-weight: 600; }
.depot { display: flex; justify-content: center; align-items: center; min-height: 120px; border: 2px dashed var(--bord); border-radius: var(--rayon); background: var(--surface); cursor: pointer; color: var(--texte-2); }
.depot:hover, .depot.survol { border-color: var(--accent); color: var(--accent); background: var(--accent-doux); }

/* ---------- fiche (tiroir) */
.tiroir { position: fixed; top: 60px; right: 0; bottom: 0; width: min(540px, 100vw); background: var(--surface); border-left: 1px solid var(--bord); box-shadow: -8px 0 30px rgba(0,0,0,.12); overflow: auto; z-index: 30; }
.tiroir-contenu { padding: 18px 20px 40px; }
.fiche-entete { display: flex; justify-content: space-between; gap: 10px; align-items: flex-start; }
.fiche-entete h2 { margin: 0 0 4px; font-size: 20px; }
.fermer { border: 0; background: none; font-size: 26px; cursor: pointer; color: var(--texte-2); line-height: 1; }
.carte-simple { border: 1px solid var(--bord); border-radius: var(--rayon); padding: 12px 14px; margin: 12px 0; background: var(--surface-2); }
.coord-ligne { font-size: 15px; margin: 3px 0; overflow-wrap: anywhere; }
.coord-ligne .sec { font-size: 11px; margin-left: 4px; }
.dl { display: grid; grid-template-columns: 120px 1fr; gap: 5px 12px; margin: 10px 0 0; font-size: 13px; }
.dl dt { color: var(--texte-2); }
.dl dd { margin: 0; overflow-wrap: anywhere; }
.bloc { border-top: 1px solid var(--bord); padding: 12px 0; }
.bloc h3 { margin: 0 0 8px; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--texte-2); }
details.bloc summary { cursor: pointer; }
.liens { display: flex; flex-wrap: wrap; gap: 6px 14px; margin: 8px 0; font-size: 13px; }
.alerte-bloc { background: var(--alerte-doux); color: var(--alerte); padding: 8px 10px; border-radius: 8px; font-size: 13px; margin-bottom: 10px; }
.form { display: flex; flex-direction: column; gap: 8px; }
.form label { display: flex; flex-direction: column; gap: 3px; font-size: 12px; color: var(--texte-2); }
.form .deux { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.form-actions { display: flex; gap: 8px; align-items: center; margin-top: 8px; flex-wrap: wrap; }

/* ---------- synchro */
.job { display: grid; grid-template-columns: 1fr 210px; gap: 4px 16px; padding: 10px 0; border-bottom: 1px solid var(--bord); font-size: 13px; }
.job:last-child { border-bottom: 0; }
.job .msg { color: var(--texte-2); white-space: pre-wrap; max-height: 80px; overflow: auto; font-size: 12px; }
.job .stats { color: var(--texte-2); font-size: 12px; grid-column: 1 / -1; }
.prog { height: 6px; background: var(--surface-2); border-radius: 3px; overflow: hidden; margin-top: 6px; }
.prog div { height: 100%; background: var(--accent); }
.statut-en_cours { color: var(--accent); font-weight: 600; } .statut-erreur { color: var(--danger); font-weight: 600; } .statut-termine { color: var(--ok); }
.sources { margin: 0; padding-left: 18px; display: flex; flex-direction: column; gap: 6px; font-size: 13px; }

dialog { border: 1px solid var(--bord); border-radius: 12px; padding: 20px; width: min(560px, 94vw); background: var(--surface); color: var(--texte); }
dialog::backdrop { background: rgba(10, 15, 25, .45); }
dialog h2 { margin: 0 0 6px; }
.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--noir); color: var(--fond); padding: 10px 16px; border-radius: 8px; z-index: 50; }

@media (max-width: 1000px) {
  .grille-2 { grid-template-columns: 1fr; }
  .recherche { grid-template-columns: 1fr; }
  .categories { position: static; height: auto; }
  .menu a.discret { display: none; }
}
@media (max-width: 720px) {
  .haut { flex-wrap: wrap; height: auto; padding: 8px 16px; gap: 8px; }
  .menu { overflow-x: auto; width: 100%; }
  .rapide { flex-basis: 100%; }
  .page, .panneau { padding: 16px; }
  .barre { grid-template-columns: 100px 1fr 60px; }
  .tiroir { top: 0; }
}
