:root {
  --encre: #0f1d2b;
  --texte: #2b3a4a;
  --doux: #66768a;
  --trait: #e3e8ee;
  --fond: #f5f7fa;
  --carte: #ffffff;
  --marine: #16324a;
  --marine-2: #1e4363;
  --laiton: #b8894b;
  --laiton-clair: #f6eedf;
  --bleu: #2b6cb0;
  --bleu-clair: #e8f0fa;
  --vert: #2f855a;
  --vert-clair: #e6f4ec;
  --orange: #c05621;
  --orange-clair: #fcefe4;
  --rouge: #c53030;
  --rouge-clair: #fbeaea;
  --violet: #6b46c1;
  --violet-clair: #f0ebfb;
  --ombre: 0 1px 2px rgba(15, 29, 43, .06), 0 1px 3px rgba(15, 29, 43, .04);
  --rayon: 10px;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { font: 14px/1.5 Inter, system-ui, -apple-system, "Segoe UI", sans-serif; color: var(--texte); background: var(--fond); -webkit-font-smoothing: antialiased; }
[hidden] { display: none !important; }
a { color: var(--bleu); text-decoration: none; }
h1, h2, h3 { color: var(--encre); margin: 0; letter-spacing: -.01em; }
h1 { font-size: 22px; font-weight: 700; }
h2 { font-size: 15px; font-weight: 600; }
h3 { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--doux); }
svg { width: 18px; height: 18px; fill: currentColor; flex: none; }
input, select, textarea, button { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--bleu); outline-offset: 2px; }

/* Boutons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 36px; padding: 0 14px; border-radius: 8px; border: 1px solid var(--trait); background: var(--carte); color: var(--encre); font-weight: 500; cursor: pointer; white-space: nowrap; transition: background .15s, border-color .15s; }
.btn:hover { background: #f0f3f7; }
.btn-primaire { background: var(--marine); border-color: var(--marine); color: #fff; }
.btn-primaire:hover { background: var(--marine-2); }
.btn-danger { color: var(--rouge); }
.btn-danger:hover { background: var(--rouge-clair); border-color: #f2c4c4; }
.btn-large { height: 44px; width: 100%; font-size: 15px; }
.btn-icone { display: inline-grid; place-items: center; width: 36px; height: 36px; border: 0; background: none; border-radius: 8px; cursor: pointer; color: var(--doux); }
.btn-icone:hover { background: #eef1f5; }
.btn-lien { border: 0; background: none; color: inherit; cursor: pointer; padding: 0; text-decoration: underline; text-underline-offset: 3px; }

/* Connexion */
.connexion { min-height: 100vh; display: grid; place-items: center; padding: 16px; background: linear-gradient(160deg, #16324a 0%, #0f2335 100%); }
.connexion-carte { width: 100%; max-width: 380px; background: var(--carte); border-radius: 14px; padding: 32px 28px; display: grid; gap: 16px; box-shadow: 0 20px 50px rgba(0, 0, 0, .25); }
.connexion-carte h1 { font-size: 20px; margin-top: 8px; }
.connexion-carte label { display: grid; gap: 6px; font-weight: 500; color: var(--encre); }
.erreur { color: var(--rouge); margin: 0; min-height: 1em; }
.discret { color: var(--doux); font-size: 12.5px; margin: 0; text-align: center; }

/* Structure */
.appli { display: grid; grid-template-columns: 240px 1fr; min-height: 100vh; }
.menu { background: var(--marine); color: #c8d4e0; display: flex; flex-direction: column; padding: 18px 12px; position: sticky; top: 0; height: 100vh; }
.marque { display: flex; align-items: center; gap: 10px; padding: 4px 8px 22px; }
.marque strong { display: block; color: #fff; font-size: 15px; }
.marque span { font-size: 12px; color: #9fb2c5; }
.marque-grande strong { color: var(--encre); font-size: 17px; }
.marque-grande span { color: var(--doux); }
.marque-grande { padding: 0; }
.menu nav { display: grid; gap: 2px; }
.menu nav a { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 8px; color: #c8d4e0; font-weight: 500; }
.menu nav a:hover { background: rgba(255, 255, 255, .06); color: #fff; }
.menu nav a.actif { background: rgba(255, 255, 255, .1); color: #fff; box-shadow: inset 3px 0 0 var(--laiton); }
.pastille { margin-left: auto; background: var(--laiton); color: #fff; border-radius: 99px; font-size: 11px; font-weight: 700; padding: 1px 7px; }
.menu-bas { margin-top: auto; display: grid; gap: 12px; padding: 8px; font-size: 12.5px; }
.direct { display: flex; align-items: center; gap: 8px; color: #9fb2c5; }
.point { width: 8px; height: 8px; border-radius: 50%; background: #48bb78; box-shadow: 0 0 0 3px rgba(72, 187, 120, .2); }
.principal { min-width: 0; display: flex; flex-direction: column; }
.barre { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 12px; padding: 12px 28px; background: rgba(245, 247, 250, .92); backdrop-filter: blur(8px); border-bottom: 1px solid var(--trait); }
.ouvrir-menu { display: none; }
.recherche { flex: 1; max-width: 520px; display: flex; align-items: center; gap: 8px; height: 38px; padding: 0 12px; border: 1px solid var(--trait); border-radius: 8px; background: var(--carte); color: var(--doux); }
.recherche input { flex: 1; border: 0; outline: 0; background: none; min-width: 0; }
.barre .btn-primaire { margin-left: auto; }
main { padding: 24px 28px 48px; outline: 0; max-width: 1440px; width: 100%; }
.entete { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.entete p { margin: 4px 0 0; color: var(--doux); }

/* Cartes et grilles */
.carte { background: var(--carte); border: 1px solid var(--trait); border-radius: var(--rayon); box-shadow: var(--ombre); }
.carte-corps { padding: 18px 20px; }
.carte-tete { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 16px 20px 0; }
.carte-tete a { font-size: 13px; font-weight: 500; }
.kpis { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 16px; margin-bottom: 16px; }
.kpi { padding: 16px 18px; color: inherit; display: block; }
a.kpi:hover { border-color: #c6d2df; }
.kpi .libelle { color: var(--doux); font-size: 12.5px; font-weight: 500; }
.kpi .valeur { font-size: 26px; font-weight: 700; color: var(--encre); margin-top: 4px; letter-spacing: -.02em; }
.kpi .detail { font-size: 12.5px; color: var(--doux); margin-top: 2px; }
.kpi .detail b { color: var(--vert); font-weight: 600; }
.kpi .detail b.alerte { color: var(--orange); }
.grille-2 { display: grid; grid-template-columns: 2fr 1fr; gap: 16px; margin-bottom: 16px; }
.grille-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; margin-bottom: 16px; }
.grille-2 > *, .grille-3 > *, .kpis > * { min-width: 0; }
.liste li { min-width: 0; }
.graphe { position: relative; height: 240px; padding: 12px 16px 16px; }
.graphe-petit { height: 210px; }

/* Listes */
.liste { list-style: none; margin: 0; padding: 6px 0; }
.liste li a { display: flex; align-items: center; gap: 12px; padding: 10px 20px; color: inherit; }
.liste li a:hover { background: #f7f9fb; }
.liste .qui { font-weight: 600; color: var(--encre); }
.liste .quoi { color: var(--doux); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.liste .bloc { min-width: 0; flex: 1; }
.liste .droite { margin-left: auto; text-align: right; font-size: 12.5px; color: var(--doux); white-space: nowrap; }
.vide { padding: 24px 20px; color: var(--doux); text-align: center; }
.avatar { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; font-weight: 600; font-size: 12.5px; flex: none; background: var(--bleu-clair); color: var(--bleu); }
.avatar.t-B { background: var(--violet-clair); color: var(--violet); }
.avatar.t-C { background: var(--laiton-clair); color: #8a6430; }
.avatar.t-autre { background: #eef1f5; color: var(--doux); }

/* Badges */
.badge { display: inline-flex; align-items: center; gap: 4px; height: 22px; padding: 0 8px; border-radius: 6px; font-size: 12px; font-weight: 500; white-space: nowrap; background: #eef1f5; color: var(--texte); }
.badge.t-A { background: var(--bleu-clair); color: var(--bleu); }
.badge.t-B { background: var(--violet-clair); color: var(--violet); }
.badge.t-C { background: var(--laiton-clair); color: #8a6430; }
.badge.vocal { background: var(--vert-clair); color: var(--vert); }
.badge.neuf { background: var(--laiton); color: #fff; }
.badge.e-gagne { background: var(--vert-clair); color: var(--vert); }
.badge.e-perdu { background: var(--rouge-clair); color: var(--rouge); }
.badge.retard { background: var(--orange-clair); color: var(--orange); }
.badge.attente { background: var(--orange-clair); color: var(--orange); }
.interet { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 4px; }
.interet.chaud { background: #e53e3e; } .interet.tiède { background: #dd6b20; } .interet.froid { background: #3182ce; }

/* Tableau clients */
.filtres { display: flex; gap: 8px; flex-wrap: wrap; }
.filtres select, .champ input, .champ select, .champ textarea, .connexion-carte input { height: 38px; border: 1px solid var(--trait); border-radius: 8px; background: var(--carte); padding: 0 10px; }
.champ textarea { height: auto; min-height: 76px; padding: 8px 10px; resize: vertical; }
.table-conteneur { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: 12px; font-weight: 600; color: var(--doux); padding: 12px 16px; border-bottom: 1px solid var(--trait); white-space: nowrap; background: #fafbfc; }
td { padding: 12px 16px; border-bottom: 1px solid #eef1f4; vertical-align: middle; }
tbody tr { cursor: pointer; }
tbody tr:hover { background: #f7f9fb; }
tbody tr:last-child td { border-bottom: 0; }
td .qui { font-weight: 600; color: var(--encre); white-space: nowrap; }
.table-conteneur table { min-width: 720px; }
td .sous { color: var(--doux); font-size: 12.5px; }
.nb { font-variant-numeric: tabular-nums; }

/* Pipeline */
.colonnes { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(250px, 1fr); gap: 12px; overflow-x: auto; padding-bottom: 12px; align-items: start; }
.colonne { background: #eceff3; border-radius: var(--rayon); padding: 10px; min-height: 200px; transition: background .15s; }
.colonne.survol { background: #dfe7f1; }
.colonne-tete { display: flex; align-items: center; gap: 8px; padding: 4px 4px 10px; font-weight: 600; color: var(--encre); }
.colonne-tete .compte { color: var(--doux); font-weight: 500; }
.colonne-tete .somme { margin-left: auto; font-size: 12px; color: var(--doux); font-weight: 500; }
.colonne-tete::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--c, var(--doux)); }
.carte-affaire { display: block; background: var(--carte); border: 1px solid var(--trait); border-radius: 8px; padding: 12px; margin-bottom: 8px; color: inherit; box-shadow: var(--ombre); cursor: grab; }
.carte-affaire:hover { border-color: #c6d2df; }
.carte-affaire.glisse { opacity: .5; }
.carte-affaire .qui { font-weight: 600; color: var(--encre); }
.carte-affaire .bien { color: var(--doux); font-size: 12.5px; margin: 2px 0 8px; }
.carte-affaire .pied { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; font-size: 12px; }
.carte-affaire .montant { margin-left: auto; font-weight: 600; color: var(--encre); }

/* Fiche */
.fiche-tete { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; margin-bottom: 16px; }
.fiche-tete .avatar { width: 52px; height: 52px; font-size: 17px; }
.fiche-tete .infos { flex: 1; min-width: 220px; }
.fiche-tete .sous { color: var(--doux); display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-top: 4px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }
.avancement { display: flex; margin-bottom: 16px; overflow-x: auto; }
.avancement button { flex: 1 0 auto; border: 0; background: #e5eaf0; color: var(--doux); height: 40px; padding: 0 18px 0 22px; font-size: 13px; font-weight: 500; cursor: pointer; clip-path: polygon(0 0, calc(100% - 12px) 0, 100% 50%, calc(100% - 12px) 100%, 0 100%, 12px 50%); margin-right: -8px; white-space: nowrap; }
.avancement button:first-child { clip-path: polygon(0 0, calc(100% - 12px) 0, 100% 50%, calc(100% - 12px) 100%, 0 100%); border-radius: 8px 0 0 8px; }
.avancement button.fait { background: #c9d8e8; color: var(--marine); }
.avancement button.courant { background: var(--marine); color: #fff; }
.avancement button.courant.e-gagne { background: var(--vert); }
.avancement button.courant.e-perdu { background: var(--rouge); }
.avancement button:hover:not(.courant) { background: #d5dee8; }
.fiche-grille { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 16px; align-items: start; }
.fiche-grille > div { display: grid; gap: 16px; }
.champs { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 16px; padding: 14px 20px 20px; }
.champ { display: grid; gap: 5px; }
.champ.large { grid-column: 1 / -1; }
.champ > span { font-size: 12.5px; font-weight: 500; color: var(--doux); }
.champ input, .champ select, .champ textarea { width: 100%; }
.champ input:focus, .champ select:focus, .champ textarea:focus { border-color: var(--bleu); outline: 0; box-shadow: 0 0 0 3px rgba(43, 108, 176, .12); }
.manque { padding: 14px 20px; border-left: 3px solid var(--orange); background: var(--orange-clair); border-radius: 0 var(--rayon) var(--rayon) 0; color: #7b3a12; }
.manque strong { display: block; margin-bottom: 2px; }
.histo { list-style: none; margin: 0; padding: 8px 20px 16px; }
.histo li { position: relative; padding: 0 0 14px 20px; border-left: 2px solid var(--trait); margin-left: 4px; }
.histo li:last-child { border-left-color: transparent; }
.histo li::before { content: ""; position: absolute; left: -6px; top: 4px; width: 10px; height: 10px; border-radius: 50%; background: var(--carte); border: 2px solid var(--laiton); }
.histo .quand { font-size: 12px; color: var(--doux); }
.transcription { margin: 0 20px 16px; padding: 12px 14px; background: #f7f9fb; border-radius: 8px; font-size: 13px; color: var(--texte); font-style: italic; border-left: 3px solid var(--vert); }
.resume-ligne { display: flex; justify-content: space-between; gap: 12px; padding: 8px 20px; border-top: 1px solid #eef1f4; }
.resume-ligne span:first-child { color: var(--doux); }
.resume-ligne span:last-child { font-weight: 500; color: var(--encre); text-align: right; }
.barre-enregistrer { position: sticky; bottom: 0; z-index: 4; display: flex; align-items: center; justify-content: flex-end; gap: 10px; margin: 16px -28px -48px; padding: 12px 28px; background: var(--carte); border-top: 1px solid var(--trait); box-shadow: 0 -4px 12px rgba(15, 29, 43, .06); }
.barre-enregistrer span { margin-right: auto; color: var(--doux); }
.impression, .version-pdf { display: none; }

/* Toasts et dialogue */
.toasts { position: fixed; right: 20px; bottom: 20px; display: grid; gap: 8px; z-index: 50; }
.toast { background: var(--encre); color: #fff; padding: 12px 16px; border-radius: 10px; box-shadow: 0 10px 30px rgba(0, 0, 0, .2); max-width: 360px; animation: entree .25s ease-out; }
.toast a { color: #f3d9ae; font-weight: 600; }
@keyframes entree { from { transform: translateY(8px); opacity: 0; } }
dialog { border: 0; border-radius: 14px; padding: 0; width: min(560px, calc(100vw - 32px)); box-shadow: 0 20px 60px rgba(0, 0, 0, .3); color: var(--texte); }
dialog::backdrop { background: rgba(15, 29, 43, .45); }
dialog form { display: grid; gap: 14px; padding: 22px; }
dialog .pied { display: flex; justify-content: flex-end; gap: 8px; }

/* Téléphone et tablette */
@media (max-width: 1180px) { .grille-2 { grid-template-columns: 1fr; } .kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); } .grille-3 { grid-template-columns: 1fr 1fr; } }
@media (max-width: 980px) {
  .grille-2, .fiche-grille { grid-template-columns: 1fr; }
  .appli { grid-template-columns: 1fr; }
  .menu { position: fixed; z-index: 20; left: 0; width: 260px; transform: translateX(-100%); transition: transform .2s; }
  .menu.ouvert { transform: none; box-shadow: 0 0 40px rgba(0, 0, 0, .35); }
  .ouvrir-menu { display: inline-grid; }
}
@media (max-width: 640px) {
  .barre { padding: 10px 16px; gap: 8px; }
  .barre .btn-primaire span { display: none; }
  .barre .btn-primaire { width: 38px; padding: 0; }
  main { padding: 16px 16px 40px; }
  .kpis { grid-template-columns: 1fr 1fr; gap: 10px; }
  .kpi .valeur { font-size: 22px; }
  .grille-3 { grid-template-columns: 1fr; }
  .champs { grid-template-columns: 1fr; padding: 12px 16px 16px; }
  .barre-enregistrer { margin: 16px -16px -40px; padding: 12px 16px; }
  .masquer-mobile { display: none; }
  td, th { padding: 10px 12px; }
}

/* Export PDF : la fiche seule, propre, sur fond blanc */
@media print {
  @page { margin: 14mm; }
  body { background: #fff; font-size: 11pt; }
  .menu, .barre, .actions, .avancement, .barre-enregistrer, .toasts, .pas-imprime { display: none !important; }
  .appli { display: block; }
  main { padding: 0; }
  .impression { display: flex; justify-content: space-between; border-bottom: 2px solid var(--marine); padding-bottom: 8px; margin-bottom: 16px; color: var(--doux); font-size: 10pt; }
  .impression strong { color: var(--marine); font-size: 13pt; }
  .fiche-tete, .fiche-grille, .manque { display: none !important; }
  .version-pdf { display: block; }
  .version-pdf table { width: 100%; border-collapse: collapse; }
  .version-pdf td { border-bottom: 1px solid #e3e8ee; vertical-align: top; }
  .version-pdf h3 { color: var(--marine); }
}
