:root {
  --fond: #f4f4f1; --carte: #ffffff; --ligne: #e7e7e2; --texte: #16181a; --doux: #6b6f72; --tres-doux: #9a9ea1;
  --vert: #b4560a; --vert-clair: #fdf0e4; --vert-vif: #5aa52f; --lime: #9cc943; --jaune: #f1cf3f; --rouge: #c8463d; --rouge-clair: #fbeceb;
  --orange: #f59e0b; --noir: #121314; --ombre: 0 1px 2px rgba(20,20,20,.04), 0 1px 1px rgba(20,20,20,.03);
  --r: 14px; --r-s: 10px;
  font-family: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--texte); background: var(--fond); font-size: 14px;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--fond); }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: inherit; text-decoration: none; }
h1 { font-size: 30px; letter-spacing: -.02em; margin: 0; font-weight: 650; }
h2 { font-size: 16px; margin: 0; font-weight: 600; }
.doux { color: var(--doux); } .petit { font-size: 12px; } .gras { font-weight: 600; }

/* Mise en page */
.cadre { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }
.barre { background: #fbfbf9; border-right: 1px solid var(--ligne); padding: 18px 12px; display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.logo { display: flex; align-items: center; gap: 8px; padding: 2px 8px 18px; border-bottom: 1px solid var(--ligne); margin-bottom: 14px; }
.logo img { width: 34px; height: 34px; }
.logo b { font-size: 21px; color: var(--vert); letter-spacing: -.02em; display: block; line-height: 1; }
.logo small { font-size: 8.5px; letter-spacing: .14em; color: var(--vert); text-transform: uppercase; }
.groupe { font-size: 10.5px; letter-spacing: .12em; color: var(--doux); margin: 14px 10px 6px; text-transform: uppercase; font-weight: 600; }
.lien { display: flex; align-items: center; gap: 11px; padding: 8px 10px; border-radius: 9px; color: #2b2e30; cursor: pointer; margin: 1px 0; }
.lien:hover { background: #f0f0ec; }
.lien.actif { background: var(--vert-clair); color: var(--vert); font-weight: 600; box-shadow: inset 3px 0 0 var(--vert); }
.lien svg { width: 17px; height: 17px; flex: none; stroke: currentColor; }
.lien .pastille { margin-left: auto; font-size: 11px; color: var(--doux); background: #efefea; border-radius: 99px; padding: 1px 7px; }
.lien.actif .pastille { background: #d7ead0; color: var(--vert); }
.moi { margin-top: auto; display: flex; gap: 10px; align-items: center; padding: 14px 8px 2px; border-top: 1px solid var(--ligne); }
.avatar { width: 36px; height: 36px; border-radius: 50%; background: var(--vert); color: #fff; display: grid; place-items: center; font-weight: 600; font-size: 13px; flex: none; }
.avatar.p { width: 30px; height: 30px; font-size: 11px; }
.principal { min-width: 0; }
.haut { display: flex; align-items: center; gap: 8px; padding: 12px 28px; border-bottom: 1px solid var(--ligne); background: #f8f8f5; position: sticky; top: 0; z-index: 5; }
.puce-e { display: inline-flex; align-items: center; gap: 7px; padding: 7px 12px; border-radius: 99px; background: #fff; border: 1px solid var(--ligne); cursor: pointer; font-weight: 600; font-size: 13px; white-space: nowrap; }
.puce-e.actif { background: var(--noir); color: #fff; border-color: var(--noir); }
.puce-e .nb { font-weight: 500; opacity: .7; font-size: 11.5px; }
.point { width: 8px; height: 8px; border-radius: 50%; display: inline-block; flex: none; }
.recherche { margin-left: auto; position: relative; width: min(300px, 32vw); }
.recherche input { width: 100%; padding: 9px 12px 9px 34px; border-radius: 11px; border: 1px solid var(--ligne); background: #fff; }
.recherche svg { position: absolute; left: 11px; top: 10px; width: 15px; stroke: var(--doux); }
.resultats { position: absolute; top: 42px; left: 0; right: 0; background: #fff; border: 1px solid var(--ligne); border-radius: 12px; box-shadow: 0 10px 30px rgba(0,0,0,.08); overflow: hidden; }
.resultats a { display: block; padding: 9px 12px; border-bottom: 1px solid var(--ligne); }
.resultats a:hover { background: #f6f6f2; }
.icone-btn { width: 38px; height: 38px; border-radius: 11px; border: 1px solid var(--ligne); background: #fff; display: grid; place-items: center; cursor: pointer; position: relative; }
.icone-btn svg { width: 17px; stroke: currentColor; }
.icone-btn .notif { position: absolute; top: 7px; right: 8px; width: 7px; height: 7px; background: var(--orange); border-radius: 50%; }
.page { padding: 28px 28px 48px; max-width: 1480px; }
.entete { display: flex; align-items: flex-start; gap: 12px; margin-bottom: 22px; flex-wrap: wrap; }
.entete .titre { flex: 1; min-width: 260px; }
.entete p { margin: 6px 0 0; color: var(--doux); }

/* Composants */
.btn { display: inline-flex; align-items: center; gap: 8px; border-radius: 12px; padding: 10px 16px; border: 1px solid var(--ligne); background: #fff; cursor: pointer; font-weight: 600; white-space: nowrap; }
.btn:hover { background: #f6f6f2; }
.btn.noir { background: var(--noir); color: #fff; border-color: var(--noir); }
.btn.noir:hover { background: #2a2c2e; }
.btn.vert { background: var(--vert-vif); color: #fff; border-color: var(--vert-vif); }
.btn.p { padding: 6px 11px; border-radius: 9px; font-size: 13px; }
.btn svg { width: 15px; stroke: currentColor; }
.onglets { display: inline-flex; gap: 6px; flex-wrap: wrap; }
.onglet { padding: 7px 13px; border-radius: 99px; background: #ececE7; cursor: pointer; font-weight: 500; border: 0; }
.onglet.actif { background: var(--noir); color: #fff; }
.carte { background: var(--carte); border: 1px solid var(--ligne); border-radius: var(--r); box-shadow: var(--ombre); padding: 18px 20px; }
.grille { display: grid; gap: 16px; }
.grille > * { min-width: 0; }
.g4 { grid-template-columns: repeat(4, minmax(0,1fr)); } .g3 { grid-template-columns: repeat(3, minmax(0,1fr)); } .g2 { grid-template-columns: repeat(2, minmax(0,1fr)); }
.kpi .val { font-size: 28px; font-weight: 650; letter-spacing: -.02em; margin: 8px 0 4px; }
.kpi .evo { font-size: 12px; color: var(--vert-vif); }
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 3px 9px; border-radius: 99px; font-size: 12px; font-weight: 600; background: #efefea; color: #555; white-space: nowrap; }
.badge.vert { background: var(--vert-clair); color: var(--vert-vif); } .badge.orange { background: #fdf1dc; color: #b86e00; }
.badge.rouge { background: var(--rouge-clair); color: var(--rouge); } .badge.bleu { background: #e8eefc; color: #3156b8; }
.entreprise { display: inline-flex; align-items: center; gap: 7px; font-weight: 600; font-size: 13px; }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: 11px; letter-spacing: .1em; color: var(--doux); text-transform: uppercase; font-weight: 600; padding: 11px 10px; border-bottom: 1px solid var(--ligne); background: #fafaf7; }
td { padding: 13px 10px; border-bottom: 1px solid var(--ligne); vertical-align: middle; }
tr.cliquable { cursor: pointer; } tr.cliquable:hover td { background: #fafaf6; }
tr.choisi td { background: #f3f8ee; }
.barre-prog { height: 6px; border-radius: 99px; background: #ecece7; overflow: hidden; }
.barre-prog > i { display: block; height: 100%; background: var(--vert-vif); border-radius: 99px; }
.vide { color: var(--tres-doux); text-align: center; padding: 26px; }
label.champ { display: grid; gap: 6px; font-weight: 600; font-size: 13px; margin-bottom: 12px; }
label.champ input, label.champ select, label.champ textarea, .saisie { width: 100%; padding: 10px 12px; border: 1px solid var(--ligne); border-radius: 10px; background: #fff; font-weight: 400; }
textarea { resize: vertical; min-height: 90px; }
.ligne { display: flex; align-items: center; gap: 10px; } .entre { justify-content: space-between; } .col { display: flex; flex-direction: column; gap: 10px; }

/* Pipeline (Kanban) */
.kanban { display: grid; grid-template-columns: repeat(5, minmax(210px, 1fr)); gap: 14px; }
.colonne { background: #ecece7; border-radius: var(--r); padding: 12px; min-height: 300px; display: flex; flex-direction: column; gap: 10px; transition: background .15s; }
.colonne.survol { background: #e2ecd9; }
.colonne.gagne { background: #e8f1dd; } .colonne.perdu { background: #f8e6e4; }
.colonne header { padding: 4px 4px 8px; }
.colonne header .ligne b { font-size: 14px; }
.compte { margin-left: auto; background: #fff; border-radius: 99px; font-size: 11px; padding: 2px 8px; font-weight: 600; }
.colonne .barre-prog { margin-top: 10px; height: 5px; background: #dcdcd5; }
.colonne.perdu .barre-prog > i { background: var(--rouge); }
.opp { background: #fff; border: 1px solid var(--ligne); border-radius: 12px; padding: 12px 13px; cursor: grab; box-shadow: var(--ombre); }
.opp:active { cursor: grabbing; } .opp.glisse { opacity: .4; }
.opp.chaud { border-color: var(--vert-vif); box-shadow: 0 0 0 1px var(--vert-vif); }
.opp .nom { font-weight: 650; } .opp .soc { color: var(--doux); font-size: 12.5px; margin: 2px 0 10px; }
.opp .action { border-top: 1px solid var(--ligne); margin-top: 10px; padding-top: 9px; color: var(--doux); font-size: 12.5px; display: flex; gap: 6px; align-items: center; }
.opp .action svg { width: 14px; stroke: var(--vert-vif); }
.deposer { border: 1.5px dashed #cfcfc7; border-radius: 12px; padding: 18px; text-align: center; color: var(--doux); font-size: 13px; }

/* Messagerie */
.messagerie { display: grid; grid-template-columns: 300px 1fr 280px; gap: 0; height: calc(100vh - 210px); min-height: 520px; }
.messagerie > div { border: 1px solid var(--ligne); background: #fff; overflow-y: auto; }
.messagerie > div:first-child { border-radius: var(--r) 0 0 var(--r); } .messagerie > div:last-child { border-radius: 0 var(--r) var(--r) 0; border-left: 0; }
.messagerie > div:nth-child(2) { border-left: 0; display: flex; flex-direction: column; }
.conv { display: flex; gap: 10px; padding: 12px 14px; border-bottom: 1px solid var(--ligne); cursor: pointer; }
.conv:hover { background: #fafaf6; } .conv.actif { background: #f1f7ec; }
.conv .resume { color: var(--doux); font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bulle { max-width: 78%; border-radius: 14px; padding: 12px 14px; white-space: pre-wrap; line-height: 1.45; }
.bulle.sortant { background: #f4f4f0; border: 1px solid var(--ligne); }
.bulle.entrant { background: var(--vert-clair); border: 1px solid #d4e6c9; margin-left: auto; }
.fil { flex: 1; padding: 18px; display: flex; flex-direction: column; gap: 14px; overflow-y: auto; }
.repondre { border-top: 1px solid var(--ligne); padding: 14px; }

/* Agenda */
.agenda { display: grid; grid-template-columns: 56px repeat(7, 1fr); border: 1px solid var(--ligne); border-radius: var(--r); background: #fff; overflow: hidden; }
.agenda .jour-tete { padding: 10px; text-align: center; border-left: 1px solid var(--ligne); border-bottom: 1px solid var(--ligne); font-size: 12px; color: var(--doux); }
.agenda .jour-tete b { display: block; font-size: 20px; color: var(--texte); }
.agenda .jour-tete.auj { background: #eef6e8; }
.agenda .heure { font-size: 11px; color: var(--doux); text-align: right; padding: 4px 8px 0 0; height: 52px; border-bottom: 1px solid #f0f0ec; }
.agenda .case { border-left: 1px solid var(--ligne); border-bottom: 1px solid #f0f0ec; height: 52px; position: relative; }
.agenda .case.auj { background: #f7fbf3; }
.evt { position: absolute; left: 3px; right: 3px; border-radius: 8px; padding: 5px 7px; font-size: 11.5px; background: #eef5e8; border-left: 3px solid var(--vert-vif); overflow: hidden; cursor: pointer; z-index: 1; }
.evt b { display: block; font-size: 12px; }

/* Fiche lead / chronologie */
.chrono { position: relative; padding-left: 30px; }
.chrono::before { content: ""; position: absolute; left: 11px; top: 6px; bottom: 6px; width: 1px; background: var(--ligne); }
.evenement { position: relative; margin-bottom: 14px; }
.evenement .rond { position: absolute; left: -30px; top: 12px; width: 23px; height: 23px; border-radius: 50%; background: #fff; border: 1px solid var(--ligne); display: grid; place-items: center; }
.evenement .rond svg { width: 12px; stroke: var(--vert-vif); }
.evenement .carte { padding: 13px 15px; } .evenement.reponse .carte { background: #f1f7ec; border-color: #d4e6c9; }
.evenement p { margin: 6px 0 0; white-space: pre-wrap; line-height: 1.45; }
.noir-carte { background: var(--noir); color: #fff; border-radius: var(--r); padding: 18px; }

/* Entonnoir campagne */
.entonnoir { display: grid; grid-template-columns: repeat(5, 1fr); gap: 16px; align-items: end; height: 190px; margin-top: 18px; }
.entonnoir .bloc { border-radius: 10px 10px 4px 4px; background: linear-gradient(180deg, #9cc943, #f1cf3f); min-height: 6px; }
.entonnoir .leg { display: flex; justify-content: space-between; margin-top: 8px; color: var(--doux); font-size: 13px; }
.entonnoir .leg b { color: var(--texte); font-weight: 600; }
.etapes-seq { display: grid; gap: 10px; }
.etape-seq { border: 1px solid var(--ligne); border-radius: 12px; padding: 12px 14px; background: #fff; }
.etape-seq.actif { background: var(--noir); color: #fff; }

/* Connexion, modale, toast */
.connexion { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.connexion .carte { width: min(400px, 100%); padding: 30px; }
.modale-fond { position: fixed; inset: 0; background: rgba(16,18,20,.35); display: grid; place-items: center; z-index: 50; padding: 16px; }
.modale { background: #fff; border-radius: 16px; width: min(520px, 100%); max-height: 90vh; overflow-y: auto; padding: 24px; box-shadow: 0 20px 60px rgba(0,0,0,.2); }
#toast { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%) translateY(20px); background: var(--noir); color: #fff; padding: 11px 18px; border-radius: 12px; opacity: 0; transition: .2s; pointer-events: none; z-index: 60; max-width: 90vw; }
#toast.vu { opacity: 1; transform: translateX(-50%); }
.essai { background: #fdf1dc; color: #8a5300; border-radius: 10px; padding: 8px 12px; font-size: 12.5px; margin-bottom: 16px; }

@media (max-width: 1100px) {
  .g4 { grid-template-columns: repeat(2, minmax(0,1fr)); } .g3 { grid-template-columns: 1fr; }
  .messagerie { grid-template-columns: 260px 1fr; } .messagerie > div:last-child { display: none; }
}
@media (max-width: 760px) {
  .cadre { grid-template-columns: 1fr; }
  .barre { position: static; height: auto; flex-direction: row; overflow-x: auto; padding: 8px; border-right: 0; border-bottom: 1px solid var(--ligne); }
  .barre .groupe, .barre .moi, .logo small { display: none; }
  .logo { border: 0; margin: 0; padding: 0 8px 0 0; } .lien { white-space: nowrap; }
  .haut { padding: 10px 16px; overflow-x: auto; } .recherche { display: none; }
  .page { padding: 18px 16px 40px; } h1 { font-size: 24px; }
  .page .grille { grid-template-columns: 1fr !important; }
  .page .carte { overflow-x: auto; }
  .modale .grille.g2 { grid-template-columns: 1fr 1fr !important; }
  .entete .btn { flex: 1; justify-content: center; }
  .chrono { padding-left: 26px; }
  .evenement .carte .ligne.entre { flex-direction: column; align-items: flex-start; gap: 2px; }
  .barre { position: sticky; top: 0; z-index: 6; }
  .haut { top: 52px; }
  .lien .pastille { display: none; }
  .noir-carte, .carte { padding: 15px 16px; }
  .entonnoir { height: 150px; gap: 8px; } .entonnoir .leg { flex-direction: column; font-size: 11.5px; }
  .ligne.entre { flex-wrap: wrap; }
  .kanban { grid-template-columns: repeat(10, 82vw); overflow-x: auto; }
  .messagerie { grid-template-columns: 1fr; height: auto; } .messagerie > div:first-child { max-height: 260px; }
  .agenda { overflow-x: auto; grid-template-columns: 44px repeat(7, 120px); }
  .tableau-defile { overflow-x: auto; }
}
/* ---- ERP */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 14px; margin-bottom: 16px; }
.kpis .carte { padding: 14px 16px; } .kpis .val { font-size: 22px; font-weight: 650; letter-spacing: -.02em; margin-top: 6px; }
.n { text-align: right; white-space: nowrap; } .rouge-t { color: var(--rouge); } .vert-t { color: var(--vert-vif); }
.histo { display: flex; align-items: flex-end; gap: 6px; height: 140px; margin-top: 14px; }
.histo div { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 4px; height: 100%; justify-content: flex-end; }
.histo i { display: block; width: 100%; background: #e8730c; border-radius: 6px 6px 2px 2px; min-height: 2px; }
.histo span { font-size: 10.5px; color: var(--doux); }
.grille-chantiers { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 14px; }
.planning { overflow-x: auto; } .planning table td, .planning table th { padding: 6px 4px; text-align: center; font-size: 12px; min-width: 54px; }
.planning td.occupe { background: #fdf0e4; font-weight: 600; cursor: pointer; } .planning td.we { background: #f6f6f2; }
.liste-choix { max-height: 340px; overflow: auto; border: 1px solid var(--ligne); border-radius: 10px; }
.liste-choix button { display: block; width: 100%; text-align: left; border: 0; border-bottom: 1px solid var(--ligne); background: #fff; padding: 9px 12px; cursor: pointer; }
.liste-choix button:hover { background: #fafaf6; }
.journal-item { padding: 10px 0; border-bottom: 1px solid var(--ligne); } .journal-item.resolu { opacity: .55; }
