:root {
  --vert: #2e6b40;
  --vert-fonce: #23533a;
  --vert-clair: #e6f0e8;
  --fond: #f4f2ee;
  --fond-fiche: #f7f1e8;
  --carte: #ffffff;
  --texte: #1f2421;
  --texte-doux: #6b716c;
  --bord: #e3ded5;
  --rouge: #c0392b;
  --rouge-clair: #fbe6e3;
  --orange: #b8651b;
  --orange-clair: #fbeedd;
  --ok: #2e7d4a;
  --ok-clair: #e2f2e6;
  --gris-clair: #eeeeec;
  --rayon: 12px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--texte);
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--fond); display: flex; min-height: 100vh; font-size: 15px; }
h1, h2, h3 { margin: 0; }
button { font: inherit; }
a { color: inherit; }

/* ---------- Menu de gauche ---------- */
.menu {
  width: 240px; flex: none; background: var(--vert); color: #fff; display: flex; flex-direction: column;
  padding: 18px 12px; position: sticky; top: 0; height: 100vh;
}
.marque { font-size: 22px; font-weight: 700; padding: 0 8px 16px; display: flex; align-items: center; gap: 8px; }
.marque-logo { font-size: 22px; }
.choix-entite { display: block; padding: 0 8px 14px; border-bottom: 1px solid rgba(255,255,255,.18); margin-bottom: 10px; }
.choix-entite span { display: block; font-size: 11px; text-transform: uppercase; letter-spacing: .08em; opacity: .75; margin-bottom: 6px; }
.choix-entite select {
  width: 100%; font: inherit; font-weight: 600; padding: 9px 10px; border-radius: 8px; border: 0;
  background: #fff; color: var(--vert-fonce); cursor: pointer;
}
#navigation { display: flex; flex-direction: column; gap: 2px; }
#navigation a { text-decoration: none; padding: 9px 10px; border-radius: 8px; font-size: 14.5px; }
#navigation a:hover { background: rgba(255,255,255,.1); }
#navigation a.actif { background: var(--vert-fonce); font-weight: 600; }
.menu-separateur { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; opacity: .7; padding: 16px 10px 6px; }
.pied-menu { margin-top: auto; padding: 12px 8px 0; border-top: 1px solid rgba(255,255,255,.18); display: flex; flex-direction: column; gap: 4px; font-size: 14px; }
.lien { background: none; border: 0; color: inherit; text-decoration: underline; cursor: pointer; padding: 0; text-align: left; opacity: .85; }

/* ---------- Écran principal ---------- */
.ecran { flex: 1; min-width: 0; display: flex; }
.vide { margin: auto; text-align: center; color: var(--texte-doux); padding: 40px; max-width: 460px; line-height: 1.5; }
.vide h2 { color: var(--texte); margin-bottom: 8px; font-size: 20px; }

/* Liste des affaires */
.liste {
  width: 340px; flex: none; background: #fff; border-right: 1px solid var(--bord); padding: 18px 14px;
  height: 100vh; overflow-y: auto; position: sticky; top: 0;
}
.liste h1 { font-size: 24px; margin-bottom: 12px; }
.recherche { width: 100%; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--bord); background: #f6f6f4; font: inherit; margin-bottom: 10px; }
.filtres { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin-bottom: 8px; }
.filtre {
  display: flex; align-items: center; justify-content: space-between; gap: 6px; padding: 8px 10px; border: 1px solid var(--bord);
  border-radius: 9px; background: #fff; cursor: pointer; font-size: 13.5px; font-weight: 600; text-align: left;
}
.filtre.actif { border-color: var(--vert); background: var(--vert-clair); }
.filtre .n { color: var(--texte-doux); font-weight: 500; }
.filtre.large { grid-column: span 2; }
.point { width: 8px; height: 8px; border-radius: 50%; display: inline-block; margin-right: 6px; flex: none; }
.point.a_lancer { background: var(--rouge); }
.point.en_cours { background: var(--orange); }
.point.production_terminee, .point.expedie { background: var(--ok); }
.nb-affaires { font-size: 13px; color: var(--texte-doux); margin: 8px 2px; }
.carte-affaire {
  display: block; text-decoration: none; padding: 12px 14px; border-radius: 12px; border: 1px solid transparent; margin-bottom: 4px;
}
.carte-affaire:hover { background: #f7f7f5; }
.carte-affaire.choisie { background: var(--vert-clair); border-color: var(--vert); }
.carte-affaire .haut { display: flex; justify-content: space-between; align-items: center; font-size: 13px; font-weight: 700; color: var(--vert-fonce); }
.carte-affaire .titre { font-weight: 600; margin: 4px 0 2px; }
.carte-affaire .client { font-size: 13px; color: var(--texte-doux); text-transform: uppercase; }
.badge-p { display: inline-grid; place-items: center; width: 18px; height: 18px; border-radius: 50%; background: var(--vert-fonce); color: #fff; font-size: 10.5px; margin-left: 4px; vertical-align: 1px; }
.feu { width: 16px; height: 16px; border-radius: 50%; display: inline-block; flex: none; }
.feu.du { background: radial-gradient(circle at 35% 35%, #f07a6e, var(--rouge)); }
.feu.solde { background: radial-gradient(circle at 35% 35%, #7fd48f, var(--ok)); }
.feu.a_saisir { background: #fff; border: 1px solid #ccc; }

.pastille { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 13px; font-weight: 600; margin-top: 6px; white-space: nowrap; }
.pastille.a_lancer { background: var(--rouge-clair); color: var(--rouge); }
.pastille.en_cours, .pastille.en_production { background: var(--orange-clair); color: var(--orange); }
.pastille.production_terminee, .pastille.pret, .pastille.livre, .pastille.solde { background: var(--ok-clair); color: var(--ok); }
.pastille.expedie { background: var(--gris-clair); color: #555; }
.pastille.acompte { background: var(--orange); color: #fff; }
.pastille.solde-type { background: var(--ok); color: #fff; }
.pastille.stock { background: #f1ede4; color: #6b5a3a; }

/* Fiche affaire */
.fiche { flex: 1; min-width: 0; background: linear-gradient(180deg, var(--fond-fiche), #f9f6f1 300px); padding: 26px 30px 60px; }
.entete-fiche { display: flex; justify-content: space-between; gap: 16px; align-items: flex-start; }
.sur-titre { font-size: 13px; font-weight: 700; letter-spacing: .06em; color: var(--vert-fonce); text-transform: uppercase; }
.sur-titre .date { text-transform: none; letter-spacing: 0; font-weight: 500; color: var(--texte-doux); }
.fiche h1 { font-size: 30px; margin: 6px 0 0; }
.lecture-seule { font-size: 12.5px; background: #fff; border: 1px solid var(--bord); padding: 6px 10px; border-radius: 8px; color: var(--texte-doux); white-space: nowrap; }

.frise { display: grid; grid-template-columns: repeat(4, 1fr); margin: 26px 0 18px; position: relative; }
.frise .etape { text-align: center; position: relative; color: var(--texte-doux); font-size: 14.5px; }
.frise .etape::before {
  content: ""; position: absolute; top: 20px; left: -50%; width: 100%; height: 3px; background: #e2dcd2; z-index: 0;
}
.frise .etape:first-child::before { display: none; }
.frise .etape.passee::before, .frise .etape.actuelle::before { background: #b8792a; }
.frise .rond {
  width: 42px; height: 42px; border-radius: 50%; display: grid; place-items: center; margin: 0 auto 8px; position: relative; z-index: 1;
  background: #fff; border: 2px solid #e2dcd2; font-size: 16px;
}
.frise .passee .rond { background: #b8792a; border-color: #b8792a; color: #fff; }
.frise .actuelle .rond { background: #b8792a; border-color: #b8792a; color: #fff; box-shadow: 0 0 0 6px rgba(184,121,42,.2); }
.frise .actuelle.a_lancer .rond { background: var(--rouge); border-color: var(--rouge); box-shadow: 0 0 0 6px rgba(192,57,43,.18); }
.frise .actuelle { color: #a0621d; font-weight: 700; }
.frise .actuelle.a_lancer { color: var(--rouge); }

.onglets { display: flex; gap: 4px; border-bottom: 1px solid var(--bord); margin-bottom: 20px; overflow-x: auto; }
.onglet {
  background: none; border: 0; text-decoration: none; padding: 10px 14px; cursor: pointer; color: var(--texte-doux); font-size: 15px; border-bottom: 3px solid transparent;
  white-space: nowrap;
}
.onglet.actif { color: var(--vert-fonce); font-weight: 700; border-bottom-color: var(--vert-fonce); }
.onglet .n { display: inline-grid; place-items: center; min-width: 20px; height: 20px; border-radius: 10px; background: #ebe7df; font-size: 12px; margin-left: 6px; padding: 0 6px; }
.onglet.actif .n { background: var(--vert-fonce); color: #fff; }

.cartes { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.carte { background: var(--carte); border-radius: var(--rayon); padding: 20px; box-shadow: 0 1px 3px rgba(0,0,0,.06); border: 1px solid #efebe4; }
.carte.large { grid-column: 1 / -1; }
.carte { min-width: 0; overflow-x: auto; }
.retour-liste { display: none; }
.carte h2 { font-size: 14px; letter-spacing: .08em; text-transform: uppercase; margin-bottom: 14px; display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
.carte h2 .total { font-size: 13px; color: var(--texte-doux); letter-spacing: .06em; }
.carte h2 .total b { font-size: 24px; color: var(--texte); letter-spacing: 0; margin-left: 6px; }
.carte h3 { font-size: 19px; color: var(--vert-fonce); }
.champs { display: grid; grid-template-columns: 140px 1fr; gap: 8px 14px; align-items: start; }
.champs dt { color: var(--texte-doux); padding-top: 9px; }
.champs dd { margin: 0; background: #f4f2ee; border-radius: 8px; padding: 9px 12px; min-height: 38px; white-space: pre-line; }
.champs dd.vide-champ { color: #aaa; }

.barre { height: 38px; background: #ece8e0; border-radius: 8px; overflow: hidden; margin: 6px 0; }
.barre > div { height: 100%; background: var(--vert); color: #fff; font-weight: 700; display: flex; align-items: center; padding: 0 14px; white-space: nowrap; }
.sous-barre { display: flex; justify-content: space-between; font-size: 14px; color: var(--vert-fonce); font-weight: 600; }
.note { color: var(--texte-doux); font-size: 14px; }

table.tableau { width: 100%; border-collapse: collapse; font-size: 14.5px; }
.tableau th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--texte-doux); padding: 10px 12px; background: #f4f2ee; }
.tableau td { padding: 12px; border-top: 1px solid #f0ece5; vertical-align: middle; }
.tableau .nombre { text-align: right; white-space: nowrap; }
.tableau .sous { display: block; font-size: 12.5px; color: var(--texte-doux); margin-top: 2px; }
.montant-ok { color: var(--ok); font-weight: 700; }
.montant-du { color: var(--rouge); font-weight: 700; }

.grille-fournisseurs { display: grid; grid-template-columns: repeat(auto-fill, minmax(460px, 1fr)); gap: 18px; }
.etapes-fournisseur { display: flex; gap: 6px; align-items: center; margin: 8px 0 14px; flex-wrap: wrap; }
.etapes-fournisseur span { padding: 4px 10px; border-radius: 999px; border: 1px solid var(--bord); font-size: 13px; color: var(--texte-doux); }
.etapes-fournisseur span.actuelle.a_lancer { background: var(--rouge); border-color: var(--rouge); color: #fff; font-weight: 700; }
.etapes-fournisseur span.actuelle.en_cours { background: var(--orange); border-color: var(--orange); color: #fff; font-weight: 700; }
.etapes-fournisseur span.actuelle.pret { background: var(--ok); border-color: var(--ok); color: #fff; font-weight: 700; }
.petits-champs { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 12px 0; }
.petits-champs div { font-size: 13px; color: var(--texte-doux); }
.petits-champs b { display: block; font-size: 15px; color: var(--texte); background: #f4f2ee; border-radius: 8px; padding: 8px 10px; margin-top: 4px; font-weight: 500; min-height: 36px; }
.intertitre { font-size: 12.5px; letter-spacing: .08em; text-transform: uppercase; color: var(--texte-doux); font-weight: 700; margin: 16px 0 8px; }
.ligne-total { display: flex; justify-content: flex-end; gap: 10px; margin-top: 10px; align-items: center; }

.documents { display: flex; flex-wrap: wrap; gap: 10px; }
.doc {
  width: 130px; border-radius: 10px; border: 1px solid var(--bord); background: #f6f8f6; text-decoration: none; overflow: hidden;
  display: flex; flex-direction: column; cursor: pointer; padding: 0; text-align: left; font: inherit;
}
.doc .icone { height: 64px; display: grid; place-items: center; font-size: 28px; background: #e9efe9; }
.doc .icone img { width: 100%; height: 64px; object-fit: cover; }
.doc .nom { font-size: 12.5px; font-weight: 600; padding: 8px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.doc.choisi { border-color: var(--vert); box-shadow: 0 0 0 2px var(--vert-clair); }
.apercu { margin-top: 16px; border-radius: 10px; overflow: hidden; border: 1px solid var(--bord); background: #fff; }
.apercu-entete { display: flex; justify-content: space-between; align-items: center; padding: 10px 14px; font-weight: 600; gap: 10px; }
.apercu iframe { width: 100%; height: 75vh; border: 0; display: block; background: #525659; }
.apercu img { max-width: 100%; display: block; margin: 0 auto; }
.bouton {
  display: inline-flex; align-items: center; gap: 6px; padding: 9px 14px; border-radius: 9px; border: 1px solid var(--bord); background: #fff;
  cursor: pointer; font-weight: 600; text-decoration: none; color: var(--texte); font-size: 14px;
}
.bouton-principal { background: var(--vert-fonce); color: #fff; border-color: var(--vert-fonce); }

/* Connexion */
.page-connexion { display: grid; place-items: center; background: var(--vert); }
.carte-connexion { background: #fff; padding: 32px; border-radius: 16px; width: min(360px, 92vw); display: flex; flex-direction: column; gap: 14px; }
.carte-connexion .marque { color: var(--vert-fonce); padding: 0; }
.carte-connexion .sous-titre { margin: -10px 0 4px; color: var(--texte-doux); }
.carte-connexion label { display: flex; flex-direction: column; gap: 6px; font-weight: 600; font-size: 14px; }
.carte-connexion input { font: inherit; padding: 10px 12px; border-radius: 9px; border: 1px solid var(--bord); }
.carte-connexion .erreur { background: var(--rouge-clair); color: var(--rouge); padding: 10px; border-radius: 9px; margin: 0; }
.carte-connexion .bouton { justify-content: center; padding: 11px; }

/* Petits écrans (téléphone, tablette en hauteur) */
@media (max-width: 1100px) {
  .cartes { grid-template-columns: 1fr; }
  .grille-fournisseurs { grid-template-columns: 1fr; }
}
@media (max-width: 860px) {
  body { flex-direction: column; }
  .menu { width: auto; height: auto; position: static; padding: 12px 16px; }
  .marque { padding-bottom: 8px; }
  #navigation { flex-direction: row; overflow-x: auto; }
  #navigation a { white-space: nowrap; }
  .menu-separateur, .pied-menu { display: none; }
  .ecran { flex-direction: column; }
  .liste { width: auto; height: auto; position: static; border-right: 0; }
  .ecran.avec-fiche .liste { display: none; }
  .ecran:not(.avec-fiche) .fiche { display: none; }
  .retour-liste { display: inline-block; margin-bottom: 10px; font-weight: 600; color: var(--vert-fonce); text-decoration: none; }
  .fiche { padding: 18px 16px 40px; }
  .fiche h1 { font-size: 23px; }
  .champs { grid-template-columns: 1fr; }
  .champs dt { padding-top: 0; }
  .frise .etape { font-size: 12px; }
  .tableau { font-size: 13.5px; }
}
