/* ==========================================================================
   prospect-fr — feuille de style unique.
   Outil de travail dense : la densite prime sur l'aeration, un commercial
   doit voir une trentaine de lignes sans defiler.
   ========================================================================== */

:root {
  --bg:        #f6f7f9;
  --surface:   #ffffff;
  --surface-2: #f0f2f5;
  --border:    #dde1e7;
  --border-fort:#c3c9d2;
  --texte:     #12161c;
  --texte-2:   #5a6474;
  --texte-3:   #8a93a1;
  --accent:    #2f5fd8;
  --accent-bg: #e8effc;

  --a: #14804a; --a-bg: #e3f5eb;
  --b: #2f5fd8; --b-bg: #e8effc;
  --c: #9a6209; --c-bg: #fdf1dc;
  --d: #5a6474; --d-bg: #eef0f3;
  --e: #8a93a1; --e-bg: #f2f4f6;
  --x: #b3261e; --x-bg: #fdeceb;

  --ok: #14804a; --alerte: #9a6209; --err: #b3261e;

  --r: 6px;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, sans-serif;
  --ombre: 0 1px 2px rgba(16,24,40,.06), 0 1px 3px rgba(16,24,40,.08);
  --ombre-f: 0 8px 24px rgba(16,24,40,.12), 0 2px 6px rgba(16,24,40,.08);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg:        #0e1116;
    --surface:   #161a21;
    --surface-2: #1d222b;
    --border:    #262c37;
    --border-fort:#39414f;
    --texte:     #e6e9ee;
    --texte-2:   #9aa4b2;
    --texte-3:   #6b7686;
    --accent:    #6f9bff;
    --accent-bg: #16233f;

    --a: #4ade80; --a-bg: #10251a;
    --b: #6f9bff; --b-bg: #16233f;
    --c: #eab308; --c-bg: #2a2207;
    --d: #9aa4b2; --d-bg: #1d222b;
    --e: #6b7686; --e-bg: #191d24;
    --x: #f87171; --x-bg: #2d1414;

    --ok: #4ade80; --alerte: #eab308; --err: #f87171;
    --ombre: 0 1px 2px rgba(0,0,0,.4);
    --ombre-f: 0 8px 24px rgba(0,0,0,.5);
  }
}
:root[data-theme="dark"] {
  --bg:#0e1116; --surface:#161a21; --surface-2:#1d222b; --border:#262c37;
  --border-fort:#39414f; --texte:#e6e9ee; --texte-2:#9aa4b2; --texte-3:#6b7686;
  --accent:#6f9bff; --accent-bg:#16233f;
  --a:#4ade80; --a-bg:#10251a; --b:#6f9bff; --b-bg:#16233f;
  --c:#eab308; --c-bg:#2a2207; --d:#9aa4b2; --d-bg:#1d222b;
  --e:#6b7686; --e-bg:#191d24; --x:#f87171; --x-bg:#2d1414;
  --ok:#4ade80; --alerte:#eab308; --err:#f87171;
  --ombre:0 1px 2px rgba(0,0,0,.4); --ombre-f:0 8px 24px rgba(0,0,0,.5);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--texte);
  font: 13px/1.5 var(--sans);
  -webkit-font-smoothing: antialiased;
}

/* ---------- ossature ---------- */
.app { display: grid; grid-template-rows: auto 1fr; height: 100vh; }

header {
  display: flex; align-items: center; gap: 16px;
  padding: 0 14px; height: 48px;
  background: var(--surface); border-bottom: 1px solid var(--border);
}
.marque { font-weight: 650; letter-spacing: -.01em; font-size: 14px; }
.marque span { color: var(--accent); }

nav { display: flex; gap: 2px; margin-left: 8px; }
nav button {
  background: none; border: 0; padding: 6px 11px; border-radius: var(--r);
  color: var(--texte-2); font: 500 13px var(--sans); cursor: pointer;
}
nav button:hover { background: var(--surface-2); color: var(--texte); }
nav button[aria-current="page"] { background: var(--accent-bg); color: var(--accent); }

.jauges { margin-left: auto; display: flex; gap: 14px; align-items: center; }
.jauge { display: flex; flex-direction: column; line-height: 1.15; }
.jauge b { font: 600 13px var(--mono); }
.jauge span { font-size: 10px; color: var(--texte-3); text-transform: uppercase; letter-spacing: .04em; }

.icone-btn {
  background: none; border: 1px solid var(--border); color: var(--texte-2);
  width: 28px; height: 28px; border-radius: var(--r); cursor: pointer;
  display: grid; place-items: center; font-size: 13px;
}
.icone-btn:hover { background: var(--surface-2); color: var(--texte); }

main { overflow: hidden; }
.vue { display: none; height: 100%; }
.vue.actif { display: grid; }

/* ---------- prospection : filtres | liste | fiche ---------- */
#vue-prospection { grid-template-columns: 252px 1fr; }
#vue-prospection.avec-fiche { grid-template-columns: 252px 1fr 400px; }

aside {
  background: var(--surface); border-right: 1px solid var(--border);
  overflow-y: auto; padding: 12px;
}
.groupe { margin-bottom: 14px; }
.groupe > label, .titre-groupe {
  display: block; font: 600 10px var(--sans); text-transform: uppercase;
  letter-spacing: .06em; color: var(--texte-3); margin-bottom: 5px;
}

input[type=text], input[type=number], select, textarea {
  width: 100%; padding: 6px 8px; border: 1px solid var(--border);
  border-radius: var(--r); background: var(--surface); color: var(--texte);
  font: 13px var(--sans); outline: none;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-bg);
}
.duo { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.trio { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 6px; }

.puces { display: flex; flex-wrap: wrap; gap: 4px; }
.puce {
  padding: 3px 8px; border: 1px solid var(--border); border-radius: 20px;
  font-size: 11px; cursor: pointer; user-select: none; color: var(--texte-2);
  background: var(--surface);
}
.puce:hover { border-color: var(--border-fort); }
.puce[aria-pressed="true"] { background: var(--accent-bg); border-color: var(--accent); color: var(--accent); font-weight: 550; }

.coche { display: flex; align-items: center; gap: 7px; padding: 3px 0; cursor: pointer; color: var(--texte-2); }
.coche input { accent-color: var(--accent); margin: 0; }

button.principal, button.secondaire, button.danger {
  padding: 7px 12px; border-radius: var(--r); font: 550 13px var(--sans);
  cursor: pointer; border: 1px solid transparent;
}
button.principal { background: var(--accent); color: #fff; }
button.principal:hover { filter: brightness(1.08); }
button.secondaire { background: var(--surface); border-color: var(--border); color: var(--texte); }
button.secondaire:hover { background: var(--surface-2); }
button.danger { background: var(--x-bg); color: var(--x); border-color: transparent; }
button:disabled { opacity: .5; cursor: not-allowed; }
.plein { width: 100%; }

/* ---------- tableau ---------- */
.zone-liste { display: grid; grid-template-rows: auto 1fr auto; overflow: hidden; }
.barre {
  display: flex; align-items: center; gap: 10px; padding: 8px 12px;
  border-bottom: 1px solid var(--border); background: var(--surface);
}
.compte { font: 600 13px var(--mono); }
.compte em { font: 400 12px var(--sans); color: var(--texte-3); font-style: normal; }
.pousse { margin-left: auto; }

.defile { overflow: auto; }
table { width: 100%; border-collapse: collapse; }
thead th {
  position: sticky; top: 0; z-index: 1; background: var(--surface);
  text-align: left; font: 600 10px var(--sans); text-transform: uppercase;
  letter-spacing: .05em; color: var(--texte-3);
  padding: 7px 10px; border-bottom: 1px solid var(--border); white-space: nowrap;
}
tbody td { padding: 7px 10px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tbody tr { cursor: pointer; }
tbody tr:hover { background: var(--surface-2); }
tbody tr[aria-selected="true"] { background: var(--accent-bg); }
.num { font: 500 12px var(--mono); text-align: right; }
.faible { color: var(--texte-3); }
.tronque { max-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.grade {
  display: inline-grid; place-items: center; width: 20px; height: 20px;
  border-radius: 5px; font: 700 11px var(--mono);
}
.grade.A { background: var(--a-bg); color: var(--a); }
.grade.B { background: var(--b-bg); color: var(--b); }
.grade.C { background: var(--c-bg); color: var(--c); }
.grade.D { background: var(--d-bg); color: var(--d); }
.grade.E { background: var(--e-bg); color: var(--e); }
.grade.X { background: var(--x-bg); color: var(--x); }

.etiq {
  display: inline-block; padding: 1px 6px; border-radius: 4px;
  font: 500 11px var(--sans); background: var(--surface-2); color: var(--texte-2);
}
.etiq.vert  { background: var(--a-bg); color: var(--a); }
.etiq.bleu  { background: var(--b-bg); color: var(--b); }
.etiq.ambre { background: var(--c-bg); color: var(--c); }
.etiq.rouge { background: var(--x-bg); color: var(--x); }

.pagination { display: flex; align-items: center; gap: 8px; padding: 7px 12px; border-top: 1px solid var(--border); background: var(--surface); }

/* ---------- fiche lead ---------- */
.fiche { background: var(--surface); border-left: 1px solid var(--border); overflow-y: auto; }
.fiche-tete { position: sticky; top: 0; background: var(--surface); border-bottom: 1px solid var(--border); padding: 12px 14px; z-index: 2; }
.fiche-tete h2 { margin: 0 0 3px; font-size: 15px; font-weight: 650; }
.fiche-tete .siren { font: 12px var(--mono); color: var(--texte-3); }
.fiche section { padding: 12px 14px; border-bottom: 1px solid var(--border); }
.fiche h3 {
  margin: 0 0 8px; font: 600 10px var(--sans); text-transform: uppercase;
  letter-spacing: .06em; color: var(--texte-3);
}
.paires { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; font-size: 12px; }
.paires dt { color: var(--texte-3); }
.paires dd { margin: 0; }

/* barre de score empilee : rend le calcul lisible d'un coup d'oeil */
.score-tete { display: flex; align-items: baseline; gap: 8px; margin-bottom: 8px; }
.score-tete b { font: 700 24px var(--mono); line-height: 1; }
.barre-score { display: flex; height: 8px; border-radius: 4px; overflow: hidden; background: var(--surface-2); margin-bottom: 8px; }
.barre-score i { display: block; }
.seg-signaux { background: var(--accent); }
.seg-taille { background: var(--a); }
.seg-joign { background: var(--c); }
.seg-fit { background: var(--e); }
.legende { display: flex; flex-wrap: wrap; gap: 10px; font-size: 11px; color: var(--texte-2); }
.legende i { display: inline-block; width: 8px; height: 8px; border-radius: 2px; margin-right: 4px; vertical-align: baseline; }

.liste-sec { display: flex; flex-direction: column; gap: 6px; }
.item-sig { display: grid; grid-template-columns: auto 1fr auto; gap: 8px; align-items: baseline; font-size: 12px; }
.item-sig .date { font: 11px var(--mono); color: var(--texte-3); white-space: nowrap; }
.item-sig .poids { font: 600 11px var(--mono); }
.item-sig .poids.pos { color: var(--ok); }
.item-sig .poids.neg { color: var(--err); }

.contact-ligne { display: flex; align-items: center; gap: 8px; font-size: 12px; padding: 3px 0; }
.contact-ligne .val { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-family: var(--mono); font-size: 11.5px; }

/* ---------- vues simples ---------- */
.page { overflow-y: auto; padding: 18px 20px; }
.page h1 { margin: 0 0 4px; font-size: 18px; font-weight: 650; }
.page .sous { color: var(--texte-2); margin: 0 0 18px; max-width: 760px; }
.grille { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(305px, 1fr)); }
.carte { background: var(--surface); border: 1px solid var(--border); border-radius: 9px; padding: 14px; box-shadow: var(--ombre); }
.carte h3 { margin: 0 0 3px; font-size: 13.5px; font-weight: 620; text-transform: none; letter-spacing: 0; color: var(--texte); }
.carte p.aide { margin: 0 0 11px; font-size: 12px; color: var(--texte-2); }
.carte .champs { display: flex; flex-direction: column; gap: 7px; margin-bottom: 11px; }
.carte label { font-size: 11px; color: var(--texte-2); display: block; margin-bottom: 2px; }

.avis { border-radius: var(--r); padding: 9px 11px; font-size: 12px; margin-bottom: 12px; border: 1px solid transparent; }
.avis.info { background: var(--accent-bg); color: var(--accent); }
.avis.attention { background: var(--c-bg); color: var(--c); }
.avis.erreur { background: var(--x-bg); color: var(--x); }
.avis.succes { background: var(--a-bg); color: var(--a); }

.vide { padding: 40px 20px; text-align: center; color: var(--texte-3); }
.vide b { display: block; color: var(--texte-2); margin-bottom: 4px; font-weight: 550; }

pre.json {
  background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--r);
  padding: 9px; font: 11px/1.45 var(--mono); overflow-x: auto; margin: 0;
  max-height: 260px; color: var(--texte-2);
}

/* ---------- etats ---------- */
.spin {
  width: 13px; height: 13px; border: 2px solid var(--border-fort);
  border-top-color: var(--accent); border-radius: 50%;
  animation: tourne .7s linear infinite; display: inline-block; vertical-align: -2px;
}
@keyframes tourne { to { transform: rotate(360deg); } }
.pastille { width: 7px; height: 7px; border-radius: 50%; display: inline-block; }
.pastille.ok { background: var(--ok); }
.pastille.en_cours { background: var(--alerte); animation: pulse 1.3s ease-in-out infinite; }
.pastille.erreur { background: var(--err); }
@keyframes pulse { 50% { opacity: .3; } }

/* ---------- toasts ---------- */
#toasts { position: fixed; right: 14px; bottom: 14px; display: flex; flex-direction: column; gap: 8px; z-index: 50; }
.toast {
  background: var(--surface); border: 1px solid var(--border); border-left: 3px solid var(--accent);
  border-radius: var(--r); padding: 9px 12px; box-shadow: var(--ombre-f);
  font-size: 12px; max-width: 380px; animation: entre .18s ease-out;
}
.toast.succes { border-left-color: var(--ok); }
.toast.erreur { border-left-color: var(--err); }
.toast b { display: block; margin-bottom: 1px; }
@keyframes entre { from { opacity: 0; transform: translateY(6px); } }

/* ---------- modale ---------- */
dialog {
  border: 1px solid var(--border); border-radius: 10px; padding: 0;
  background: var(--surface); color: var(--texte); box-shadow: var(--ombre-f);
  max-width: 560px; width: calc(100vw - 32px);
}
dialog::backdrop { background: rgba(8,11,16,.5); }
dialog .tete { padding: 14px 16px; border-bottom: 1px solid var(--border); }
dialog .tete h3 { margin: 0; font-size: 14.5px; font-weight: 620; text-transform: none; letter-spacing: 0; color: var(--texte); }
dialog .corps { padding: 16px; display: flex; flex-direction: column; gap: 10px; max-height: 62vh; overflow-y: auto; }
dialog .pied { padding: 12px 16px; border-top: 1px solid var(--border); display: flex; gap: 8px; justify-content: flex-end; }

@media (max-width: 1100px) {
  #vue-prospection, #vue-prospection.avec-fiche { grid-template-columns: 1fr; }
  aside { display: none; }
  .fiche { position: fixed; inset: 48px 0 0 auto; width: min(430px, 100vw); z-index: 20; }
}

/* ==========================================================================
   Onglet Créations — compteur hebdomadaire et histogramme journalier
   ========================================================================== */

.tuiles { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); margin-bottom: 16px; }
.tuile {
  background: var(--surface); border: 1px solid var(--border); border-radius: 9px;
  padding: 13px 15px; box-shadow: var(--ombre);
}
.tuile .valeur { font: 700 30px/1 var(--mono); letter-spacing: -.02em; }
.tuile .etiquette {
  font: 600 10px var(--sans); text-transform: uppercase; letter-spacing: .06em;
  color: var(--texte-3); margin-top: 5px;
}
.tuile .note { font-size: 11.5px; color: var(--texte-2); margin-top: 5px; }
.tuile.accent { border-color: var(--accent); }
.tuile.accent .valeur { color: var(--accent); }
.tuile.alerte { border-color: var(--c); }
.tuile.alerte .valeur { color: var(--c); }

/* Histogramme : une colonne par jour, hauteur proportionnelle au maximum.
   Assez pour lire une tendance hebdomadaire, sans librairie. */
.histo {
  background: var(--surface); border: 1px solid var(--border); border-radius: 9px;
  padding: 14px 16px 10px; box-shadow: var(--ombre); margin-bottom: 16px;
}
.histo-titre {
  font: 600 10px var(--sans); text-transform: uppercase; letter-spacing: .06em;
  color: var(--texte-3); margin-bottom: 12px;
}
.histo-barres { display: flex; align-items: flex-end; gap: 4px; height: 118px; }
.histo-col { flex: 1; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; gap: 4px; min-width: 0; }
.histo-col .n { font: 600 10.5px var(--mono); color: var(--texte-2); }
.histo-col .bar {
  width: 100%; background: var(--accent); border-radius: 3px 3px 0 0;
  min-height: 2px; transition: height .25s ease;
}
.histo-col.weekend .bar { background: var(--border-fort); }
.histo-col.max .bar { background: var(--a); }
.histo-jours { display: flex; gap: 4px; margin-top: 7px; }
.histo-jours div {
  flex: 1; text-align: center; font: 10px var(--mono); color: var(--texte-3);
  min-width: 0; overflow: hidden; white-space: nowrap;
}

.barre-outils {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  background: var(--surface); border: 1px solid var(--border); border-radius: 9px;
  padding: 10px 12px; margin-bottom: 14px; box-shadow: var(--ombre);
}
.barre-outils label { font-size: 11px; color: var(--texte-2); }
.barre-outils input, .barre-outils select { width: auto; min-width: 84px; }

/* ==========================================================================
   Sélecteurs cherchables, recettes, repli — la couche « intuitivité »
   ========================================================================== */

.aide-champ { font-size: 11px; color: var(--texte-3); margin-top: 4px; line-height: 1.35; }

/* Sélecteur : jetons choisis + saisie + liste filtrée */
.selecteur { position: relative; }
.jetons { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 5px; }
.jetons:empty { display: none; }
.jeton {
  display: inline-flex; align-items: center; gap: 5px;
  background: var(--accent-bg); color: var(--accent); border: 1px solid var(--accent);
  border-radius: 5px; padding: 2px 5px 2px 7px; font-size: 11.5px; font-weight: 500;
  max-width: 100%;
}
.jeton span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.jeton button {
  background: none; border: 0; color: inherit; cursor: pointer;
  font-size: 14px; line-height: 1; padding: 0 1px; opacity: .65;
}
.jeton button:hover { opacity: 1; }

.sel-liste {
  position: absolute; z-index: 30; left: 0; right: 0; top: 100%; margin-top: 3px;
  background: var(--surface); border: 1px solid var(--border-fort); border-radius: var(--r);
  box-shadow: var(--ombre-f); max-height: 290px; overflow-y: auto; padding: 3px;
}
.sel-option {
  padding: 5px 8px; border-radius: 4px; cursor: pointer; font-size: 12.5px; line-height: 1.3;
}
.sel-option:hover, .sel-option[aria-selected="true"] { background: var(--accent-bg); }
.sel-option .officiel { display: block; font-size: 10.5px; color: var(--texte-3); margin-top: 1px; }
.sel-option mark { background: transparent; color: var(--accent); font-weight: 650; }
.sel-groupe {
  padding: 6px 8px 3px; font: 600 9.5px var(--sans); text-transform: uppercase;
  letter-spacing: .06em; color: var(--texte-3);
}
.sel-vide { padding: 10px 8px; font-size: 12px; color: var(--texte-3); }

/* Repli des critères avancés : la densité ne doit pas accueillir le débutant */
.repli { border-top: 1px solid var(--border); padding-top: 10px; margin-top: 4px; }
.repli summary {
  cursor: pointer; font: 600 10px var(--sans); text-transform: uppercase;
  letter-spacing: .06em; color: var(--texte-2); list-style: none; padding: 3px 0;
  display: flex; align-items: center; gap: 5px;
}
.repli summary::-webkit-details-marker { display: none; }
.repli summary::before { content: '▸'; font-size: 10px; transition: transform .15s; }
.repli[open] summary::before { transform: rotate(90deg); }
.repli summary:hover { color: var(--texte); }
.repli-corps { padding-top: 8px; }

/* Recettes : entrées en un clic, pour ne pas affronter douze champs vides */
.recettes { border-bottom: 1px solid var(--border); background: var(--surface); padding: 10px 12px; }
.recettes-tete { display: flex; align-items: center; margin-bottom: 8px; }
.recettes-tete .titre-groupe { flex: 1; }
.recettes-liste { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 2px; }
.recette {
  flex: 0 0 auto; min-width: 176px; max-width: 220px; text-align: left;
  background: var(--surface); border: 1px solid var(--border); border-radius: 8px;
  padding: 8px 10px; cursor: pointer; transition: border-color .12s, background .12s;
}
.recette:hover { border-color: var(--accent); background: var(--accent-bg); }
.recette b { display: block; font-size: 12.5px; font-weight: 580; margin-bottom: 2px; color: var(--texte); }
.recette span { display: block; font-size: 11px; color: var(--texte-2); line-height: 1.35; }

button.lien {
  background: none; border: 0; color: var(--accent); cursor: pointer;
  font: 500 11.5px var(--sans); padding: 2px 4px; border-radius: 4px;
}
button.lien:hover { background: var(--accent-bg); }

/* Le clic sur une ligne ouvre la fiche : le signaler plutôt que l'espérer */
tbody tr { position: relative; }
tbody tr:hover td:last-child::after {
  content: '›'; position: absolute; right: 9px; top: 50%; transform: translateY(-50%);
  color: var(--accent); font-size: 15px; font-weight: 600;
}

/* Actions directes sur la fiche : appeler, écrire, ouvrir le site */
.actions-contact { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 9px; }
.action-contact {
  display: inline-flex; align-items: center; gap: 5px; text-decoration: none;
  background: var(--accent); color: #fff; border-radius: var(--r);
  padding: 6px 11px; font: 550 12px var(--sans);
}
.action-contact:hover { filter: brightness(1.08); }
.action-contact.pale { background: var(--surface-2); color: var(--texte); border: 1px solid var(--border); }

/* État du pipeline : dire où on en est et quoi faire ensuite */
.etat-pipeline {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 10px;
  margin-bottom: 16px;
}
.etape {
  background: var(--surface); border: 1px solid var(--border); border-left: 3px solid var(--border-fort);
  border-radius: 8px; padding: 10px 12px;
}
.etape.faite { border-left-color: var(--ok); }
.etape.requise { border-left-color: var(--c); background: var(--c-bg); }
.etape .n { font: 600 10px var(--sans); text-transform: uppercase; letter-spacing: .05em; color: var(--texte-3); }
.etape .v { font: 700 19px/1.15 var(--mono); margin: 3px 0; }
.etape .m { font-size: 11.5px; color: var(--texte-2); line-height: 1.35; }
