/* ==========================================================================
   Marchand de biens : feuille de style
   Direction : encre + pierre claire, ocre pour les actions, vert pour la marge.
   Les étapes passent du bleu-gris (avant engagement) à l'ocre (argent engagé)
   puis au vert (sortie) : la couleur indique le niveau de risque.
   ========================================================================== */

@font-face {
  font-family: "Bricolage Grotesque";
  src: url("../fonts/BricolageGrotesque-Bold.ttf") format("truetype");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Instrument Sans";
  src: url("../fonts/InstrumentSans-Regular.ttf") format("truetype");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Instrument Sans";
  src: url("../fonts/InstrumentSans-Bold.ttf") format("truetype");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

:root {
  --encre: #121c26;
  --encre-2: #1c2a37;
  --pierre: #eceeea;
  --papier: #ffffff;
  --trait: #dadfd8;
  --trait-fort: #bfc6bd;
  --texte: #18222c;
  --texte-2: #55616c;
  --ocre: #e0a526;
  --ocre-vif: #edb63a;
  --vert: #1c7c54;
  --brique: #b3412e;
  --bleu: #2a5c8a;
  --titre: "Bricolage Grotesque", "Avenir Next", "Segoe UI", system-ui, sans-serif;
  --corps: "Instrument Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --r-champ: 6px;
  --r-panneau: 12px;
}

/* Couleurs d'étape : --c (point), --cf (fond de puce), --ct (texte de puce) */
.st-reperee    { --c: #8a9794; --cf: #e6e9e7; --ct: #3d4846; }
.st-visitee    { --c: #6a8797; --cf: #e1ebf0; --ct: #2b4452; }
.st-offre      { --c: #4b6f8c; --cf: #dce8f2; --ct: #234560; }
.st-promesse   { --c: #35567f; --cf: #d8e3f3; --ct: #1d3c66; }
.st-acte       { --c: #d79b1b; --cf: #fbebc4; --ct: #6b4700; }
.st-travaux    { --c: #c2701a; --cf: #f9ddc0; --ct: #6b3500; }
.st-revente    { --c: #3e9370; --cf: #d6efe3; --ct: #14573c; }
.st-vendue     { --c: #1c7c54; --cf: #bfe6d2; --ct: #0d4a30; }
.st-abandonnee { --c: #b3412e; --cf: #f6d9d3; --ct: #7a2417; }

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--pierre);
  color: var(--texte);
  font: 400 15px/1.5 var(--corps);
  font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3 { font-family: var(--titre); font-weight: 700; letter-spacing: -0.015em; margin: 0; line-height: 1.15; }
h1 { font-size: clamp(26px, 3.2vw, 34px); letter-spacing: -0.025em; }
h2 { font-size: 18px; }
h3 { font-size: 15px; }
p { margin: 0; }
a { color: var(--bleu); text-decoration: none; }
a:hover { text-decoration: underline; }
button { font: inherit; }
:focus-visible { outline: 2px solid var(--bleu); outline-offset: 2px; border-radius: 4px; }
[hidden] { display: none !important; }

.muted { color: var(--texte-2); }
small, .petit { font-size: 13px; }
.positif { color: var(--vert); }
.negatif { color: var(--brique); }
.retard { color: var(--brique); font-weight: 700; }
.erreur { color: var(--brique); min-height: 1.3em; }
svg.ico { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- Structure générale ---------- */
.appli { display: grid; grid-template-columns: 224px minmax(0, 1fr); min-height: 100vh; }
.principal { padding: 30px 40px 72px; max-width: 1280px; width: 100%; }

.lateral {
  position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column; gap: 20px;
  padding: 22px 14px 16px;
  background: var(--encre); color: #aeb9c3;
}
.marque { display: flex; align-items: center; gap: 10px; padding: 0 6px; color: #fff; }
.marque:hover { text-decoration: none; }
.marque svg { width: 44px; height: auto; flex: none; }
.marque span { font-family: var(--titre); font-weight: 700; font-size: 17px; letter-spacing: -0.01em; }

.menu { display: grid; gap: 2px; }
.menu a {
  display: flex; align-items: center; gap: 11px;
  padding: 9px 10px; border-radius: var(--r-champ);
  color: #aeb9c3; font-weight: 700; font-size: 14.5px;
}
.menu a:hover { background: rgba(255, 255, 255, 0.06); color: #fff; text-decoration: none; }
.menu a.actif { background: rgba(255, 255, 255, 0.1); color: #fff; box-shadow: inset 3px 0 0 var(--ocre); }

.lateral-pied { margin-top: auto; display: grid; gap: 6px; padding: 0 6px; font-size: 13px; }
.lateral-pied .utilisateur { color: #8996a2; overflow-wrap: anywhere; }
.lien-pied { display: inline-flex; align-items: center; gap: 8px; padding: 0; background: none; border: 0; color: #c9d1d8; cursor: pointer; font-size: 13px; }
.lien-pied:hover { color: #fff; text-decoration: underline; }

.barre-mobile { display: none; }

/* ---------- Boutons et liens ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 38px; padding: 0 15px;
  border: 1px solid var(--trait-fort); border-radius: var(--r-champ);
  background: var(--papier); color: var(--texte);
  font-weight: 700; font-size: 14px; line-height: 1; cursor: pointer;
  transition: background-color 0.12s, border-color 0.12s;
}
.btn:hover { background: #f4f6f3; text-decoration: none; }
.btn:disabled { opacity: 0.6; cursor: wait; }
.btn-primaire { background: var(--ocre); border-color: #c58f14; color: var(--encre); }
.btn-primaire:hover { background: var(--ocre-vif); }
.btn-danger { border-color: #e2b7af; color: var(--brique); }
.btn-danger:hover { background: #fbefec; }
.lien { padding: 0; background: none; border: 0; color: var(--bleu); cursor: pointer; font-weight: 700; font-size: 13.5px; }
.lien:hover { text-decoration: underline; }
.lien.danger { color: var(--brique); }
.icone-btn { display: inline-grid; place-items: center; width: 38px; height: 38px; border-radius: var(--r-champ); border: 1px solid rgba(255,255,255,.18); background: transparent; color: #fff; cursor: pointer; }

/* ---------- Champs ---------- */
.champ { display: grid; gap: 5px; align-content: start; min-width: 0; }
.champ > span:first-child, .champ-etiquette { font-size: 13px; font-weight: 700; color: var(--texte-2); }
.champ input, .champ select, .champ textarea,
.ligne-saisie input, .ligne-saisie select,
.recherche input, .filtre select {
  width: 100%; min-height: 38px; padding: 8px 11px;
  border: 1px solid var(--trait-fort); border-radius: var(--r-champ);
  background: var(--papier); color: var(--texte);
  font: 400 15px/1.35 var(--corps);
}
.champ textarea { resize: vertical; min-height: 84px; }
.champ input:hover, .champ select:hover, .champ textarea:hover { border-color: #9aa396; }
.champ input:focus, .champ select:focus, .champ textarea:focus,
.ligne-saisie input:focus, .ligne-saisie select:focus,
.recherche input:focus, .filtre select:focus {
  outline: none; border-color: var(--bleu); box-shadow: 0 0 0 3px rgba(42, 92, 138, 0.18);
}
.saisie { position: relative; display: block; }
.saisie input { padding-right: 30px; text-align: right; }
.saisie em { position: absolute; right: 11px; top: 50%; transform: translateY(-50%); font-style: normal; color: var(--texte-2); pointer-events: none; }
.case { display: flex; align-items: flex-start; gap: 10px; font-size: 14px; }
.case input { margin-top: 3px; accent-color: var(--vert); width: 16px; height: 16px; }
input[type="checkbox"] { accent-color: var(--vert); }

.grille { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 16px; }
.grille .large, .large { grid-column: 1 / -1; }
.actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }

.ligne-saisie { display: grid; grid-template-columns: minmax(0, 1.6fr) 150px minmax(0, 1fr) auto; gap: 8px; margin-bottom: 12px; }
.ligne-saisie.sans-resp { grid-template-columns: minmax(0, 1fr) 170px auto; }
.ligne-saisie.compact { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
.ligne-saisie.compact > :first-child, .ligne-saisie.compact > button { grid-column: 1 / -1; }
.ligne-saisie.tache-ajout { grid-template-columns: minmax(0, 2fr) 150px minmax(0, 1fr) minmax(0, 1.2fr) auto; margin-bottom: 0; }

/* ---------- Panneaux ---------- */
.panneau {
  background: var(--papier); border: 1px solid var(--trait);
  border-radius: var(--r-panneau); padding: 22px 24px; margin-bottom: 18px;
}
.panneau-tete { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.panneau-tete small { color: var(--texte-2); }
.panneau-danger { border-color: #e6c4bd; background: #fdf8f7; }
.panneau-danger p { margin: 6px 0 14px; color: var(--texte-2); max-width: 60ch; }
.note { color: var(--texte-2); font-size: 13px; max-width: 70ch; }

.vide-etat { text-align: left; padding: 34px 30px; background: var(--papier); border: 1px dashed var(--trait-fort); border-radius: var(--r-panneau); }
.vide-etat h2 { margin-bottom: 6px; }
.vide-etat p { color: var(--texte-2); max-width: 52ch; margin-bottom: 16px; }
.vide-ligne { color: var(--texte-2); font-size: 14px; padding: 4px 0 0; }

/* ---------- En-tête de page ---------- */
.page-entete { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px 24px; flex-wrap: wrap; margin-bottom: 22px; }
.page-entete p { margin-top: 4px; }
.outils { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.recherche { position: relative; display: block; }
.recherche svg { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--texte-2); width: 16px; height: 16px; }
.recherche input { padding-left: 34px; min-width: 260px; }
.filtre select { width: auto; }
.segmente { display: inline-flex; padding: 3px; gap: 2px; background: #dfe3dc; border-radius: 8px; }
.segmente button { min-height: 32px; padding: 0 14px; border: 0; border-radius: 6px; background: transparent; color: var(--texte-2); font-weight: 700; font-size: 14px; cursor: pointer; }
.segmente button[aria-pressed="true"] { background: var(--papier); color: var(--texte); box-shadow: 0 1px 2px rgba(18, 28, 38, 0.12); }

/* ---------- Tableau de bord ---------- */
.bandeau { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); background: var(--papier); border: 1px solid var(--trait); border-radius: var(--r-panneau); margin-bottom: 20px; }
.bandeau > div { padding: 18px 24px; display: grid; gap: 4px; }
.bandeau > div + div { border-left: 1px solid var(--trait); }
.bandeau span { font-size: 13.5px; color: var(--texte-2); }
.bandeau strong { font-family: var(--titre); font-size: 30px; letter-spacing: -0.02em; line-height: 1.1; }

.etapes { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 14px; }
.etape-filtre {
  display: inline-flex; align-items: center; gap: 8px; min-height: 34px; padding: 0 12px;
  border: 1px solid var(--trait-fort); border-radius: 999px; background: var(--papier);
  color: var(--texte); font-weight: 700; font-size: 13.5px; cursor: pointer;
}
.etape-filtre:hover { border-color: #8f9889; }
.etape-filtre .point { width: 9px; height: 9px; border-radius: 50%; background: var(--c); }
.etape-filtre b { font-weight: 700; color: var(--texte-2); }
.etape-filtre[aria-pressed="true"] { background: var(--encre); border-color: var(--encre); color: #fff; }
.etape-filtre[aria-pressed="true"] b { color: #c9d1d8; }

.puce { display: inline-flex; align-items: center; gap: 7px; padding: 3px 10px 3px 8px; border-radius: 999px; background: var(--cf); color: var(--ct); font-size: 12.5px; font-weight: 700; white-space: nowrap; }
.puce::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--c); }
.puce-neutre { display: inline-block; padding: 2px 9px; border-radius: 999px; background: #e4e7e2; color: #3d4846; font-size: 12.5px; font-weight: 700; }

/* Liste */
.liste-affaires { background: var(--papier); border: 1px solid var(--trait); border-radius: var(--r-panneau); overflow: hidden; }
.tete-liste, .ligne-affaire {
  display: grid; align-items: center; gap: 16px; padding: 0 22px;
  grid-template-columns: minmax(220px, 2.4fr) 150px minmax(110px, 1fr) minmax(110px, 1fr) minmax(150px, 1.3fr) 96px;
}
.tete-liste { min-height: 40px; background: #f5f6f3; border-bottom: 1px solid var(--trait); font-size: 12.5px; font-weight: 700; color: var(--texte-2); }
.tete-liste .droite, .ligne-affaire .droite { text-align: right; }
.ligne-affaire { min-height: 68px; padding-top: 12px; padding-bottom: 12px; color: var(--texte); border-top: 1px solid var(--trait); }
.tete-liste + .ligne-affaire { border-top: 0; }
.ligne-affaire:hover { background: #f8f9f6; text-decoration: none; }
.cel { min-width: 0; }
.cel-titre { display: grid; gap: 1px; }
.cel-titre strong { font-weight: 700; font-size: 15.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cel-titre small { color: var(--texte-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cel-prix { text-align: right; }
.cel-prix small { color: var(--texte-2); }
.cel-marge { display: grid; gap: 6px; justify-items: end; }
.cel-marge b { font-weight: 700; }
.cel-marge .pile { width: 100%; max-width: 150px; }
.cel-date { color: var(--texte-2); font-size: 13.5px; text-align: right; }

/* Pipeline */
.pipeline { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(230px, 1fr); gap: 14px; overflow-x: auto; padding-bottom: 10px; align-items: start; scroll-snap-type: x proximity; }
.col-etape { scroll-snap-align: start; border-top: 3px solid var(--c); padding-top: 12px; display: grid; gap: 10px; align-content: start; }
.col-tete { display: grid; gap: 1px; }
.col-tete h3 { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.col-tete .compte { font-family: var(--corps); font-weight: 700; font-size: 13px; color: var(--texte-2); }
.col-tete .somme { font-size: 13px; color: var(--texte-2); }
.carte-affaire { display: grid; gap: 4px; padding: 13px 14px; background: var(--papier); border: 1px solid var(--trait); border-radius: 9px; color: var(--texte); }
.carte-affaire:hover { border-color: #8f9889; text-decoration: none; }
.carte-affaire strong { font-weight: 700; line-height: 1.3; }
.carte-affaire small { color: var(--texte-2); }
.carte-prix { font-size: 14px; }
.carte-marge { font-weight: 700; font-size: 14px; }
.carte-affaire .pile { margin-top: 4px; }
.col-vide { font-size: 13.5px; color: var(--texte-2); padding: 2px 0; }

/* ---------- Barre de bilan (élément signature) ---------- */
.pile { position: relative; display: flex; height: 14px; border-radius: 3px; background: #e3e6e1; overflow: visible; }
.pile .seg { display: block; height: 100%; min-width: 2px; }
.pile .seg:first-child { border-radius: 3px 0 0 3px; }
.pile .seg:last-child { border-radius: 0 3px 3px 0; }
.pile .seg:only-child { border-radius: 3px; }
.pile .seg + .seg { box-shadow: -2px 0 0 var(--papier); }
.pile.mini { height: 6px; border-radius: 2px; }
.pile.deficit { box-shadow: 0 0 0 1.5px var(--brique); }
.repere { position: absolute; top: -4px; bottom: -4px; width: 2px; background: var(--encre); }
.seg-achat { background: var(--encre); }
.seg-travaux { background: var(--ocre); }
.seg-frais { background: #8995a0; }
.seg-marge { background: var(--vert); }
.seg-deficit { background: var(--brique); }

/* ---------- Fiche affaire ---------- */
.fil { font-size: 13.5px; font-weight: 700; }
.fiche-tete { margin-bottom: 22px; }
.fiche-titre { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; margin: 6px 0 4px; flex-wrap: wrap; }
.fiche-adresse { color: var(--texte-2); }
.faits { display: flex; gap: 8px 32px; flex-wrap: wrap; margin-top: 14px; }
.faits div { display: grid; gap: 1px; }
.faits dt { font-size: 12.5px; color: var(--texte-2); }
.faits dd { margin: 0; font-weight: 700; }
dl.faits { margin-bottom: 0; }

.parcours { display: flex; gap: 4px; margin-top: 18px; overflow-x: auto; padding-bottom: 2px; }
.parcours button {
  flex: 1 1 0; min-width: 104px; min-height: 42px; padding: 0 12px;
  border: 0; border-radius: var(--r-champ); background: #dfe3dc; color: var(--texte-2);
  font-weight: 700; font-size: 13.5px; text-align: left; cursor: pointer;
  transition: background-color 0.12s;
}
.parcours button:hover { background: #d3d8d0; }
.parcours button.passe { background: var(--cf); color: var(--ct); }
.parcours button.passe:hover { filter: brightness(0.97); }
.parcours button.courant { background: var(--c); color: #fff; }
.parcours button.st-acte.courant, .parcours button.st-travaux.courant { color: var(--encre); }
.parcours button.abandon { flex: 0 0 auto; background: transparent; color: var(--brique); border: 1px solid #e2b7af; }
.parcours button.abandon:hover { background: #fbefec; }
.parcours button.abandon.courant { background: var(--brique); color: #fff; border-color: var(--brique); }

.fiche-grille { display: grid; grid-template-columns: minmax(0, 2.2fr) minmax(300px, 1fr); gap: 20px; align-items: start; }

/* Bilan */
.bilan { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(250px, 1fr); gap: 8px 28px; align-items: start; }
.bilan-champs { display: grid; gap: 22px; }
.groupe h3 { margin-bottom: 10px; font-size: 14px; }
.bilan-resultat { position: sticky; top: 18px; display: grid; gap: 12px; padding: 18px; border: 1px solid var(--trait); border-radius: 10px; background: #f6f7f4; }
.res-etiquette { font-size: 13px; color: var(--texte-2); font-weight: 700; }
.res-chiffre { font-family: var(--titre); font-weight: 700; font-size: 40px; letter-spacing: -0.03em; line-height: 1; margin-top: -6px; }
.res-rapports { display: grid; gap: 1px; font-size: 13.5px; color: var(--texte-2); }
.res-rapports strong { color: var(--texte); }
.legende, .totaux { margin: 0; display: grid; gap: 7px; font-size: 14px; }
.legende > div, .totaux > div { display: flex; justify-content: space-between; gap: 10px; }
.legende dt, .totaux dt { display: flex; align-items: center; gap: 8px; color: var(--texte-2); }
.legende dd, .totaux dd { margin: 0; font-weight: 700; }
.totaux { padding-top: 12px; border-top: 1px solid var(--trait); }
.pt { display: inline-block; width: 10px; height: 10px; border-radius: 2px; flex: none; }
.bilan-champs .note { margin-top: 0; }

/* Listes dans les panneaux */
.liste { list-style: none; margin: 0; padding: 0; display: grid; }
.liste > li { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 11px 0; border-top: 1px solid var(--trait); }
.liste > li:first-child { border-top: 0; padding-top: 2px; }
.liste > li.bloc { display: block; }
.boutons { display: flex; gap: 14px; white-space: nowrap; }
.texte { white-space: pre-wrap; margin: 4px 0 6px; }

.document { display: flex; align-items: center; gap: 12px; min-width: 0; }
.document .fichier { flex: none; display: grid; place-items: center; width: 38px; height: 38px; border-radius: 8px; background: #e8ebe6; color: #3d4846; font-size: 11px; font-weight: 700; }
.document div { min-width: 0; }
.document strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.document small { color: var(--texte-2); }
.doc-meta { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 3px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.avatar { display: inline-grid; place-items: center; flex: none; width: 30px; height: 30px; border-radius: 50%; background: var(--encre); color: #fff; font-size: 12px; font-weight: 700; }
.commentaire { display: grid; grid-template-columns: 30px minmax(0, 1fr); gap: 4px 12px; }
.commentaire .avatar { grid-row: 1 / span 2; }
.commentaire .meta { color: var(--texte-2); font-size: 13px; }
.commentaire .texte { margin: 0; grid-column: 2; }
.commentaire .lien { grid-column: 2; justify-self: start; }

.jalons { list-style: none; margin: 0; padding: 0 0 0 4px; display: grid; gap: 14px; }
.jalons li { position: relative; padding-left: 20px; display: grid; gap: 1px; }
.jalons li::before { content: ""; position: absolute; left: 0; top: 7px; width: 9px; height: 9px; border-radius: 50%; background: var(--trait-fort); }
.jalons li:first-child::before { background: var(--ocre); }
.jalons li::after { content: ""; position: absolute; left: 4px; top: 18px; bottom: -14px; width: 1px; background: var(--trait); }
.jalons li:last-child::after { display: none; }

details.ajout { margin-bottom: 14px; }
details.ajout summary { cursor: pointer; font-weight: 700; color: var(--bleu); font-size: 14px; list-style: none; }
details.ajout summary::-webkit-details-marker { display: none; }
details.ajout summary::before { content: "+"; display: inline-block; width: 20px; font-weight: 700; }
details.ajout[open] summary::before { content: "−"; }
details.ajout form { margin-top: 12px; }

/* Tâches */
.tache { flex-wrap: wrap; }
.tache label { display: flex; align-items: center; gap: 10px; flex: 1 1 200px; min-width: 0; cursor: pointer; }
.tache input { width: 17px; height: 17px; flex: none; }
.tache.fait span { text-decoration: line-through; color: var(--texte-2); }
.tache .meta { color: var(--texte-2); font-size: 13px; }
.groupe-taches h2 { display: flex; align-items: baseline; gap: 10px; margin-bottom: 8px; }
.groupe-taches h2 span { font-family: var(--corps); font-size: 13px; color: var(--texte-2); }
details.panneau summary { cursor: pointer; font-family: var(--titre); font-weight: 700; font-size: 18px; }

/* Contacts */
.tableau-simple { padding: 0; overflow-x: auto; margin-bottom: 0; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 13px 18px; border-top: 1px solid var(--trait); vertical-align: middle; }
thead th { border-top: 0; background: #f5f6f3; font-size: 12.5px; font-weight: 700; color: var(--texte-2); }
.contact-nom { display: flex; align-items: center; gap: 12px; }
.contact-nom strong { display: block; }
.contact-nom small { color: var(--texte-2); }
td.boutons { display: table-cell; white-space: nowrap; text-align: right; }
td.boutons .lien + .lien { margin-left: 14px; }
.barre-filtres { margin-bottom: 14px; }

/* ---------- Connexion ---------- */
.connexion { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); min-height: 100vh; }
.connexion-visuel { background: var(--encre); color: #fff; padding: 40px 48px; display: flex; flex-direction: column; justify-content: space-between; gap: 40px; }
.connexion-visuel .marque { padding: 0; }
.connexion-visuel p { font-family: var(--titre); font-weight: 700; font-size: clamp(30px, 3.6vw, 46px); line-height: 1.08; letter-spacing: -0.025em; max-width: 14em; }
.connexion-form { display: grid; align-content: center; gap: 16px; width: min(400px, 100% - 48px); margin: 0 auto; }
.connexion-form h1 { font-size: 26px; }
.connexion-config { max-width: 520px; margin: 12vh auto 0; padding: 0 20px; }

/* ---------- Notifications ---------- */
#toasts { position: fixed; right: 20px; bottom: 20px; display: grid; gap: 8px; z-index: 60; }
.toast { background: var(--encre); color: #fff; padding: 11px 16px; border-radius: 8px; max-width: 360px; box-shadow: 0 6px 20px rgba(18, 28, 38, 0.25); font-weight: 700; font-size: 14px; }
.toast.err { background: var(--brique); }

/* ---------- Écrans étroits ---------- */
@media (max-width: 1100px) {
  .fiche-grille { grid-template-columns: 1fr; }
  .bilan { grid-template-columns: 1fr; }
  .bilan-resultat { position: static; order: -1; }
}

@media (max-width: 820px), (max-height: 500px) and (max-width: 1000px) {
  .appli { display: block; }
  .principal { padding: 18px 16px 100px; }

  .barre-mobile {
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
    position: sticky; top: 0; z-index: 20; padding: 10px 16px; background: var(--encre);
  }
  .barre-mobile .marque { padding: 0; }
  .barre-mobile .droite { display: flex; gap: 8px; }

  .lateral {
    position: fixed; z-index: 30; top: auto; bottom: 0; left: 0; right: 0; height: 62px;
    flex-direction: row; gap: 0; padding: 0 6px; border-top: 1px solid #000;
  }
  .lateral .marque, .lateral .bouton-nouveau, .lateral .lateral-pied { display: none; }
  .menu { display: flex; width: 100%; justify-content: space-around; gap: 0; }
  .menu a { flex: 1; flex-direction: column; gap: 3px; justify-content: center; padding: 6px 4px; font-size: 11.5px; box-shadow: none !important; background: transparent !important; }
  .menu a.actif { color: var(--ocre); }

  .page-entete { align-items: stretch; }
  .outils { width: 100%; }
  .recherche { flex: 1 1 100%; }
  .recherche input { min-width: 0; }
  .bandeau { grid-template-columns: 1fr; }
  .bandeau > div + div { border-left: 0; border-top: 1px solid var(--trait); }
  .bandeau > div { padding: 14px 18px; }
  .bandeau strong { font-size: 26px; }
  .etapes { flex-wrap: nowrap; overflow-x: auto; padding-bottom: 4px; }
  .etape-filtre { flex: none; }

  .tete-liste { display: none; }
  .ligne-affaire {
    grid-template-columns: minmax(0, 1fr) auto; gap: 6px 12px; padding: 14px 16px;
    grid-template-areas: "titre statut" "achat marge";
  }
  .cel-titre { grid-area: titre; }
  .cel-statut { grid-area: statut; justify-self: end; }
  .cel-achat { grid-area: achat; text-align: left; }
  .cel-revente, .cel-date { display: none; }
  .cel-marge { grid-area: marge; }

  .panneau { padding: 18px 16px; border-radius: 10px; }
  .grille { grid-template-columns: 1fr; }
  .grille .large, .large { grid-column: auto; }
  .ligne-saisie, .ligne-saisie.sans-resp, .ligne-saisie.tache-ajout { grid-template-columns: 1fr; }
  .res-chiffre { font-size: 34px; }

  .connexion { grid-template-columns: 1fr; min-height: 100vh; }
  .connexion-visuel { padding: 24px; gap: 28px; }
  .connexion-form { padding: 28px 0 40px; }

  #toasts { bottom: 76px; right: 12px; left: 12px; }
  .toast { max-width: none; }

  th, td { padding: 11px 12px; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; scroll-behavior: auto !important; }
}

.jalons li .lien { justify-self: start; font-size: 12.5px; margin-top: 2px; }

/* Tableau de bord */
.bandeau.quatre { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.bandeau small { font-size: 12.5px; color: var(--texte-2); }
.bandeau strong.negatif { color: var(--brique); }
.tdb { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); gap: 16px; align-items: start; }
.tdb .panneau { margin: 0; }
.lien-voir { font-size: 13px; font-weight: 700; color: var(--bleu); }
.entonnoir, .marges { display: grid; gap: 4px; }
.entonnoir-ligne { display: grid; grid-template-columns: 128px minmax(0, 1fr) 24px 96px; align-items: center; gap: 12px; padding: 7px 8px; margin: 0 -8px; border-radius: 8px; color: var(--texte); }
.entonnoir-ligne:hover, .marge-ligne:hover { background: var(--pierre); text-decoration: none; }
.entonnoir-ligne .lib { font-size: 14px; }
.entonnoir-ligne b { text-align: right; font-variant-numeric: tabular-nums; }
.entonnoir-ligne small { text-align: right; color: var(--texte-2); font-size: 12.5px; font-variant-numeric: tabular-nums; }
.piste { display: block; height: 8px; background: var(--pierre); border-radius: 4px; overflow: hidden; }
.piste i { display: block; height: 100%; border-radius: 4px; background: var(--c, var(--encre)); }
.piste i.pos { background: var(--vert); }
.piste i.neg { background: var(--brique); }
.marge-ligne { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr) 96px; align-items: center; gap: 12px; padding: 7px 8px; margin: 0 -8px; border-radius: 8px; color: var(--texte); }
.marge-ligne .lib { font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.marge-ligne b { text-align: right; font-variant-numeric: tabular-nums; font-size: 13.5px; }
.bloc.alerte { display: grid; gap: 2px; border-left: 3px solid var(--ocre); }
.bloc.alerte.grave { border-left-color: var(--brique); }
@media (max-width: 1100px) {
  .bandeau.quatre { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .bandeau.quatre > div:nth-child(3) { border-left: 0; }
  .bandeau.quatre > div:nth-child(n+3) { border-top: 1px solid var(--trait); }
  .tdb { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 820px), (max-height: 500px) and (max-width: 1000px) {
  .bandeau.quatre { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .bandeau.quatre > div { border: 0; border-top: 1px solid var(--trait); padding: 12px 14px; }
  .bandeau.quatre > div:nth-child(-n+2) { border-top: 0; }
  .bandeau.quatre > div:nth-child(even) { border-left: 1px solid var(--trait); }
  .bandeau.quatre strong { font-size: 22px; }
  .entonnoir-ligne { grid-template-columns: 100px minmax(0, 1fr) 20px; }
  .entonnoir-ligne small { display: none; }
  .marge-ligne { grid-template-columns: minmax(0, 1fr) 84px; }
  .marge-ligne .piste { display: none; }
}
.bloc.alerte .petit { display: block; color: var(--texte-2); }
.bloc.alerte { padding: 4px 0 4px 12px; }

.connexion-visuel { justify-content: center; align-items: center; text-align: center; }
.logo-connexion { width: min(420px, 80%); height: auto; }
.connexion-visuel p { font-size: clamp(16px, 1.6vw, 20px); font-weight: 500; letter-spacing: 0; color: #b9c3cc; max-width: 26em; margin: 0 auto; }
@media (max-width: 820px), (max-height: 500px) and (max-width: 1000px) { .logo-connexion { width: min(300px, 80%); } }

/* ---------- Lots, indicateurs, dates, check-list ---------- */
.fiche-actions { display: flex; align-items: center; gap: 10px; }
.resume-projet { margin: 0 0 16px; padding: 14px 16px; background: #f6f7f4; border: 1px solid var(--trait); border-radius: 10px; gap: 12px 28px; }
.alerte-texte { color: var(--brique); font-size: 13.5px; margin: -6px 0 14px; }
.defile { overflow-x: auto; margin: 0 -4px 12px; padding: 0 4px; }
.table-lots th, .table-lots td { padding: 6px 6px; border-top: 1px solid var(--trait); }
.table-lots thead th { border-top: 0; background: none; padding-bottom: 4px; }
.table-lots input, .table-lots select { width: 100%; min-width: 70px; min-height: 36px; padding: 6px 8px; border: 1px solid transparent; border-radius: var(--r-champ); background: transparent; font: 400 14.5px/1.3 var(--corps); color: var(--texte); }
.table-lots input[type="number"] { text-align: right; }
.table-lots input:hover, .table-lots select:hover { border-color: var(--trait-fort); background: var(--papier); }
.table-lots input:focus, .table-lots select:focus { outline: none; border-color: var(--bleu); background: var(--papier); box-shadow: 0 0 0 3px rgba(42, 92, 138, .18); }
.table-lots td.fin { text-align: right; white-space: nowrap; }
.ligne-lot { display: grid; grid-template-columns: 1.3fr 1.3fr .6fr .8fr 1fr 1fr auto; gap: 8px 10px; align-items: end; }
.grille.trois { grid-template-columns: repeat(3, minmax(0, 1fr)); }

.analyses { grid-column: 1 / -1; display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; align-items: start; }
.analyse { padding: 16px 18px; border: 1px solid var(--trait); border-radius: 10px; background: var(--papier); display: grid; gap: 10px; align-content: start; }
.analyse h3 { font-size: 15px; }
.gros-chiffre { font-family: var(--titre); font-weight: 700; font-size: 32px; letter-spacing: -0.02em; line-height: 1.1; }
.totaux.sans-trait { border-top: 0; padding-top: 0; }
.analyse .note { font-size: 12.5px; }
.treso { display: flex; align-items: flex-end; gap: 2px; height: 72px; padding-top: 4px; border-bottom: 1px solid var(--trait-fort); }
.treso i { flex: 1; min-width: 2px; border-radius: 2px 2px 0 0; }
.treso i.neg { background: var(--brique); opacity: .8; }
.treso i.pos { background: var(--vert); }
table.mini { font-size: 13.5px; }
table.mini th, table.mini td { padding: 6px 4px; border-top: 1px solid var(--trait); text-align: right; }
table.mini thead th { border-top: 0; background: none; font-size: 12px; }
table.mini th:first-child, table.mini td:first-child { text-align: left; }

.echeances { list-style: none; margin: 14px 0 6px; padding: 0; display: grid; }
.echeances li { display: grid; grid-template-columns: minmax(0, 1fr) 96px 130px; gap: 10px; align-items: center; padding: 8px 0 8px 12px; border-top: 1px solid var(--trait); border-left: 3px solid var(--trait-fort); }
.echeances small { text-align: right; color: var(--texte-2); }
.echeances .ech-fait { opacity: .6; border-left-color: var(--vert); }
.echeances .ech-proche { border-left-color: var(--ocre); }
.echeances .ech-retard { border-left-color: var(--brique); }
.echeances .ech-retard small { color: var(--brique); font-weight: 700; }
.echeances .ech-proche small { color: #8a5a00; font-weight: 700; }

.piste.grosse { height: 10px; margin-bottom: 16px; }
.piste.grosse i { background: var(--vert); }
.groupe-check { margin-bottom: 14px; }
.groupe-check h3 small { color: var(--texte-2); font-weight: 400; margin-left: 6px; }
.liste-check { list-style: none; margin: 6px 0 0; padding: 0; }
.liste-check li { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; padding: 7px 0; border-top: 1px solid var(--trait); }
.liste-check label { display: flex; gap: 10px; align-items: flex-start; cursor: pointer; font-size: 14.5px; }
.liste-check input { margin-top: 3px; width: 16px; height: 16px; flex: none; }
.liste-check li.fait span { color: var(--texte-2); text-decoration: line-through; }
.check-ajout { grid-template-columns: minmax(0, 1fr) 190px auto; margin: 14px 0 0; }

@media (max-width: 1100px) { .analyses { grid-template-columns: 1fr; } .ligne-lot { grid-template-columns: repeat(3, minmax(0, 1fr)); } .ligne-lot button { grid-column: 1 / -1; } }
@media (max-width: 820px), (max-height: 500px) and (max-width: 1000px) {
  .grille.trois { grid-template-columns: 1fr; }
  .check-ajout { grid-template-columns: 1fr; }
  .echeances li { grid-template-columns: minmax(0, 1fr) auto; }
  .echeances small { grid-column: 1 / -1; text-align: left; }
  .table-lots { min-width: 0; }
  .table-lots thead { display: none; }
  .table-lots, .table-lots tbody, .table-lots tr, .table-lots td { display: block; width: 100%; }
  .table-lots tr { padding: 10px 0; border-top: 1px solid var(--trait); }
  .table-lots td { border: 0; display: grid; grid-template-columns: 110px minmax(0, 1fr); align-items: center; padding: 2px 0; }
  .table-lots td[data-label]::before { content: attr(data-label); font-size: 12.5px; color: var(--texte-2); font-weight: 700; }
  .table-lots td.fin { display: block; }
}

/* ---------- Impression de la fiche d'affaire ---------- */
#impression { display: none; }
.fiche-impression { font: 400 11pt/1.4 var(--corps); color: #000; max-width: 190mm; margin: 0 auto; }
.fiche-impression header { border-bottom: 2px solid #121c26; padding-bottom: 8px; margin-bottom: 10px; }
.fiche-impression .marque-impr { font-weight: 700; color: #b8862a; font-size: 10pt; }
.fiche-impression h1 { font-size: 20pt; margin: 2px 0 4px; }
.fiche-impression h2 { font-size: 12pt; margin: 14px 0 4px; padding-bottom: 2px; border-bottom: 1px solid #999; }
.fiche-impression table { width: 100%; border-collapse: collapse; }
.fiche-impression th, .fiche-impression td { padding: 3px 6px; border: 0; border-bottom: 1px solid #ddd; text-align: left; background: none; font-size: 10.5pt; }
.fiche-impression .cle-valeur th { font-weight: 400; width: 62%; color: #333; }
.fiche-impression .cle-valeur td { text-align: right; }
.fiche-impression .grille-fiche th { font-size: 9.5pt; font-weight: 700; border-bottom: 1px solid #555; }
.fiche-impression .grille-fiche td:nth-child(n+4) { text-align: right; }
.fiche-impression .grille-fiche th:nth-child(n+4) { text-align: right; }
.fiche-impression .total td { font-weight: 700; border-top: 1px solid #555; }
.fiche-impression .mention { margin-top: 16px; font-size: 9pt; color: #555; }
.fiche-impression table, .fiche-impression h2 { break-inside: avoid; }
@page { size: A4; margin: 14mm; }
@media print {
  body.imprime { background: #fff; }
  body.imprime #app, body.imprime #toasts { display: none !important; }
  body.imprime #impression { display: block; }
}

@media (min-width: 1001px), (min-width: 821px) and (min-height: 501px) { .table-lots { min-width: 700px; } }
.bilan-champs .actions { margin-top: 4px; }

/* Les cases (pas les titres) restent alignées sur une même ligne */
.grille > .champ { align-content: end; }

/* Dates clés et vérifications : tout est aligné à gauche */
#dates .panneau-tete, #checklist .panneau-tete { justify-content: flex-start; gap: 14px; }
.echeances li { grid-template-columns: minmax(200px, 21rem) 6.5rem auto; justify-content: start; }
.echeances small { text-align: left; }
.liste-check li { justify-content: flex-start; }
.liste-check li .lien { margin-left: 6px; opacity: .7; }
.liste-check li .lien:hover { opacity: 1; }
.sous-titre { margin: 22px 0 10px; font-size: 15px; }
@media (max-width: 820px), (max-height: 500px) and (max-width: 1000px) { .echeances li { grid-template-columns: minmax(0, 1fr) auto; } }
.fiche-impression .texte-fiche { margin: 6px 0 0; white-space: pre-wrap; font-size: 10.5pt; }

/* ---------- iPhone et iOS ---------- */
html { -webkit-tap-highlight-color: transparent; }
a, button, summary, label, select, input, textarea { touch-action: manipulation; }
.menu .court { display: none; }
.champ input:not([type="checkbox"]):not([type="file"]):not([type="date"]):not([type="datetime-local"]), .champ textarea, .ligne-saisie input:not([type="file"]), .recherche input {
  -webkit-appearance: none; appearance: none;
}
input[type="date"], input[type="datetime-local"] { -webkit-appearance: none; appearance: none; display: block; min-width: 0; max-width: 100%; min-height: 38px; text-align: left; }
.defile, .etapes, .tableau-simple { -webkit-overflow-scrolling: touch; }
.lateral { height: 100vh; height: 100dvh; }

@media (max-width: 820px), (max-height: 500px) and (max-width: 1000px) {
  .barre-mobile { padding-top: calc(10px + env(safe-area-inset-top)); padding-left: max(16px, env(safe-area-inset-left)); padding-right: max(16px, env(safe-area-inset-right)); }
  .principal { padding-left: max(16px, env(safe-area-inset-left)); padding-right: max(16px, env(safe-area-inset-right)); padding-bottom: calc(96px + env(safe-area-inset-bottom)); }
  .lateral { height: calc(62px + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom); padding-left: max(6px, env(safe-area-inset-left)); padding-right: max(6px, env(safe-area-inset-right)); }
  #toasts { bottom: calc(76px + env(safe-area-inset-bottom)); }
  .connexion { min-height: 100vh; min-height: 100dvh; }
  .menu .long { display: none; }
  .menu .court { display: inline; }
  .menu a { font-size: 11px; }

  /* Pas de zoom automatique d'iOS dans les champs : texte à 16 px minimum */
  input, select, textarea, .table-lots input, .table-lots select { font-size: 16px !important; }
  .champ input, .champ select, .champ textarea, .ligne-saisie input, .ligne-saisie select, .recherche input, .filtre select, .table-lots input, .table-lots select { min-height: 46px; }
  .table-lots input, .table-lots select { border-color: var(--trait); background: var(--papier); }

  /* Cibles tactiles d'au moins 44 px */
  .btn { min-height: 46px; padding: 0 18px; }
  .icone-btn { width: 44px; height: 44px; }
  .menu a { min-height: 54px; }
  .lien { min-height: 40px; padding: 8px 6px; display: inline-flex; align-items: center; }
  .parcours button, .etape-filtre, .segmente button { min-height: 44px; }
  .liste-check li { padding: 4px 0; align-items: center; }
  .liste-check label { padding: 8px 0; align-items: center; }
  .liste-check input, .tache input, .case input { width: 22px; height: 22px; }
  .tache label { padding: 6px 0; }
  details.ajout summary { min-height: 44px; display: flex; align-items: center; }
  .fiche-titre { flex-direction: column; align-items: flex-start; }
  .fiche-actions { width: 100%; justify-content: space-between; }
  .ligne-lot { grid-template-columns: 1fr 1fr; }
  .ligne-lot .champ:first-child, .ligne-lot button { grid-column: 1 / -1; }
  .echeances small { grid-column: 1 / -1; }
}
@media (max-height: 500px) and (max-width: 1000px) and (orientation: landscape) {
  .lateral { height: calc(52px + env(safe-area-inset-bottom)); }
  .menu a { min-height: 44px; flex-direction: row; justify-content: center; }
  .principal { padding-bottom: calc(76px + env(safe-area-inset-bottom)); }
}
@media (max-width: 360px) {
  .principal { padding-left: 12px; padding-right: 12px; }
  .panneau { padding: 16px 12px; }
  .bandeau.quatre strong { font-size: 19px; }
  .res-chiffre { font-size: 30px; }
}

@media (pointer: coarse) {
  input, select, textarea { font-size: 16px; }
  .champ input, .champ select, .champ textarea, .ligne-saisie input, .ligne-saisie select, .recherche input, .filtre select { min-height: 46px; }
  .btn { min-height: 46px; }
  .lien { min-height: 40px; padding: 8px 6px; display: inline-flex; align-items: center; }
  .liste-check input, .tache input, .case input { width: 22px; height: 22px; }
  .segmente button { min-height: 44px; }
  .lien-pied { min-height: 40px; }
}

/* Contacts : une fiche par contact sur téléphone */
@media (max-width: 820px), (max-height: 500px) and (max-width: 1000px) {
  .tableau-simple { overflow: visible; background: none; border: 0; padding: 0; }
  .tableau-simple table, .tableau-simple tbody, .tableau-simple tr, .tableau-simple td { display: block; width: 100%; }
  .tableau-simple thead { display: none; }
  .tableau-simple tr { background: var(--papier); border: 1px solid var(--trait); border-radius: 10px; padding: 12px 14px; margin-bottom: 10px; }
  .tableau-simple td { border: 0; padding: 3px 0; overflow-wrap: anywhere; }
  .tableau-simple td[data-label]:not(:empty)::before { content: attr(data-label) " : "; color: var(--texte-2); font-size: 13px; }
  .tableau-simple td a[href^="tel:"], .tableau-simple td a[href^="mailto:"] { display: inline-block; padding: 8px 0; }
  .tableau-simple td.boutons { display: flex; gap: 10px; padding-top: 6px; }
}

/* Fiche d'affaire : sections nettement séparées */
.fiche-grille .panneau { margin-bottom: 36px; padding: 26px 28px; border-top: 4px solid var(--encre); box-shadow: 0 1px 3px rgba(18, 28, 38, .06); }
.fiche-grille .panneau.panneau-danger { border-top-color: var(--brique); }
.fiche-grille .colonne-laterale .panneau { border-top-width: 3px; }
.fiche-grille .panneau-tete { padding-bottom: 12px; margin-bottom: 20px; border-bottom: 1px solid var(--trait); }
.fiche-grille .panneau-tete h2 { font-size: 20px; }
.lien-annonce { margin: 0; }
@media (max-width: 820px), (max-height: 500px) and (max-width: 1000px) {
  .fiche-grille .panneau { margin-bottom: 26px; padding: 20px 16px; }
  .fiche-actions { flex-wrap: wrap; }
}

/* Lien d'annonce : bouton à côté du champ */
.ligne-lien { display: flex; gap: 10px; align-items: stretch; }
.ligne-lien input { flex: 1; min-width: 0; }
.ligne-lien .btn { flex: none; white-space: nowrap; }

/* Dates clés et vérifications dans la colonne de droite */
.colonne-laterale .grille.trois { grid-template-columns: 1fr; }
.colonne-laterale .echeances li { grid-template-columns: minmax(0, 1fr) auto; }
.colonne-laterale .echeances li small { grid-column: 1 / -1; }
.colonne-laterale .check-ajout { grid-template-columns: 1fr; }
.colonne-laterale .liste-check li { flex-wrap: wrap; }

/* Marge brute dans le panneau de résultat */
.res-brute { margin: 10px 0 14px; padding: 9px 0; border-top: 1px solid var(--bordure, #e3dfd3); border-bottom: 1px solid var(--bordure, #e3dfd3); font-size: 13.5px; color: var(--texte-2); display: flex; flex-wrap: wrap; gap: 2px 8px; align-items: baseline; }
.res-brute strong { color: var(--texte); font-size: 17px; }
.res-brute small { flex-basis: 100%; font-size: 12px; }

/* Indicateur d'enregistrement automatique */
.etat-save { margin: 8px 0 0; min-height: 1.3em; font-size: 12.5px; color: var(--texte-2); grid-column: 1 / -1; }
.etat-save.ok { color: #2f6b3f; }
.etat-save.err { color: #a32a2a; font-weight: 600; }
