:root {
  --rouge: #b3202a; --rouge-clair: #fdecee; --orange: #c46a00; --orange-clair: #fff4e5;
  --bleu: #1d5fa8; --bleu-clair: #e8f1fb; --vert: #1f7a4d; --vert-clair: #e6f4ec;
  --encre: #1f2933; --gris: #52606d; --gris-clair: #9aa5b1; --trait: #e4e7eb; --fond: #f4f5f7; --carte: #fff;
  --ombre: 0 1px 2px rgba(16,24,40,.06), 0 1px 3px rgba(16,24,40,.08);
  --rayon: 12px;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { font: 14px/1.5 "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif; color: var(--encre); background: var(--fond); }
a { color: var(--bleu); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 22px; margin: 0 0 4px; font-weight: 650; letter-spacing: -.01em; }
h2 { font-size: 17px; margin: 0 0 12px; font-weight: 620; }
h3 { font-size: 14px; margin: 16px 0 8px; font-weight: 620; color: var(--gris); text-transform: uppercase; letter-spacing: .04em; }
.sous-titre { color: var(--gris); margin: 0 0 18px; }

/* ---------- structure */
.cadre { display: grid; grid-template-columns: 236px 1fr; min-height: 100vh; background: linear-gradient(to right, #17212b 236px, var(--fond) 236px); }
.menu { background: #17212b; color: #cbd2d9; padding: 18px 12px; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.menu .marque { display: flex; gap: 10px; align-items: center; padding: 4px 8px 18px; color: #fff; font-weight: 650; font-size: 15px; }
.menu .marque img { width: 38px; height: 38px; }
.menu .marque small { display: block; color: #9aa5b1; font-weight: 400; font-size: 11.5px; }
.menu a { display: flex; align-items: center; gap: 10px; color: #cbd2d9; padding: 8px 10px; border-radius: 8px; margin: 1px 0; }
.menu a:hover { background: #222f3c; text-decoration: none; color: #fff; }
.menu a.actif { background: var(--rouge); color: #fff; }
.menu .sep { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: #7b8794; padding: 16px 10px 4px; }
.menu .compte { margin-top: 18px; padding: 12px 10px; border-top: 1px solid #2c3a47; font-size: 12.5px; }
.menu .compte b { color: #fff; display: block; }
.ico { width: 18px; text-align: center; opacity: .9; }
.contenu { padding: 22px 28px 48px; max-width: 1380px; width: 100%; }
.barre-haut { display: flex; align-items: center; gap: 16px; justify-content: space-between; margin-bottom: 18px; flex-wrap: wrap; }

/* ---------- recherche rapide */
.recherche-rapide { display: flex; gap: 8px; flex: 1; max-width: 640px; }
.recherche-rapide input { flex: 1; font-size: 15px; padding: 10px 14px; border-radius: 10px; }

/* ---------- cartes */
.carte { background: var(--carte); border-radius: var(--rayon); box-shadow: var(--ombre); padding: 18px 20px; margin-bottom: 16px; }
.carte.plate { box-shadow: none; border: 1px solid var(--trait); }
.grille { display: grid; gap: 16px; }
.g2 { grid-template-columns: repeat(2, minmax(0,1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0,1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0,1fr)); }
@media (max-width: 1000px) { .g3, .g4 { grid-template-columns: repeat(2, minmax(0,1fr)); } }
@media (max-width: 760px) { .cadre { grid-template-columns: 1fr; background: var(--fond); } .menu { position: static; height: auto; } .g2, .g3, .g4 { grid-template-columns: 1fr; } .contenu { padding: 16px; } }

.chiffre { display: flex; flex-direction: column; gap: 2px; padding: 16px 18px; border-radius: var(--rayon); background: var(--carte); box-shadow: var(--ombre); border-left: 5px solid var(--trait); color: inherit; }
.chiffre:hover { text-decoration: none; transform: translateY(-1px); }
.chiffre b { font-size: 28px; line-height: 1.1; }
.chiffre span { color: var(--gris); }
.chiffre.rouge { border-left-color: var(--rouge); } .chiffre.rouge b { color: var(--rouge); }
.chiffre.orange { border-left-color: var(--orange); } .chiffre.orange b { color: var(--orange); }
.chiffre.info { border-left-color: var(--bleu); } .chiffre.info b { color: var(--bleu); }

/* ---------- tableaux */
table.liste { width: 100%; border-collapse: collapse; }
table.liste th { text-align: left; font-weight: 600; color: var(--gris); font-size: 12.5px; padding: 8px 10px; border-bottom: 1px solid var(--trait); background: #fafbfc; }
table.liste td { padding: 9px 10px; border-bottom: 1px solid var(--trait); vertical-align: top; }
table.liste tr:hover td { background: #fafbfc; }
table.liste tr.cliquable { cursor: pointer; }
.mono { font-family: Consolas, "SFMono-Regular", Menlo, monospace; font-size: 13px; }
.discret { color: var(--gris); }
.petit { font-size: 12.5px; }

/* ---------- pastilles */
.pastille { display: inline-flex; align-items: center; gap: 6px; padding: 2px 9px; border-radius: 99px; font-size: 12px; font-weight: 600; white-space: nowrap; background: #eef0f2; color: var(--gris); }
.pastille::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.pastille.rouge { background: var(--rouge-clair); color: var(--rouge); }
.pastille.orange { background: var(--orange-clair); color: var(--orange); }
.pastille.info { background: var(--bleu-clair); color: var(--bleu); }
.pastille.ok { background: var(--vert-clair); color: var(--vert); }
.pastille.neutre::before { display: none; }

/* ---------- bandeau d'alertes */
.bandeau { border-radius: var(--rayon); padding: 12px 16px; margin-bottom: 14px; display: flex; gap: 12px; align-items: flex-start; }
.bandeau.rouge { background: var(--rouge-clair); border: 1px solid #f3c2c7; color: #7d141c; }
.bandeau.orange { background: var(--orange-clair); border: 1px solid #f5d6a8; color: #7a4200; }
.bandeau.info { background: var(--bleu-clair); border: 1px solid #c6dbf3; color: #123d6b; }
.bandeau.ok { background: var(--vert-clair); border: 1px solid #bfe3cf; color: #11502f; }
.bandeau .titre { font-weight: 700; }
.bandeau ul { margin: 4px 0 0; padding-left: 18px; }

/* ---------- formulaires */
label { display: block; font-size: 12.5px; font-weight: 600; color: var(--gris); margin-bottom: 4px; }
input[type=text], input[type=password], input[type=email], input[type=date], input[type=number], input[type=search], select, textarea {
  width: 100%; padding: 8px 10px; border: 1px solid #cfd5dc; border-radius: 8px; font: inherit; background: #fff; color: inherit; }
input:focus, select:focus, textarea:focus { outline: 2px solid #9cc3ee; border-color: var(--bleu); }
textarea { min-height: 70px; resize: vertical; }
.champ { margin-bottom: 12px; }
.aide { font-size: 12px; color: var(--gris-clair); margin-top: 3px; }
.case { display: flex; gap: 8px; align-items: center; font-weight: 500; color: var(--encre); font-size: 14px; margin: 6px 0; }
.case input { width: 16px; height: 16px; }
.form-grille { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 0 16px; }
.form-grille .large { grid-column: 1 / -1; }
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 8px 14px; border-radius: 8px; border: 1px solid #cfd5dc; background: #fff; color: var(--encre); font: inherit; font-weight: 600; cursor: pointer; white-space: nowrap; }
.btn:hover { background: #f3f4f6; text-decoration: none; }
.btn.principal { background: var(--rouge); border-color: var(--rouge); color: #fff; }
.btn.principal:hover { background: #9a1a23; }
.btn.bleu { background: var(--bleu); border-color: var(--bleu); color: #fff; }
.btn.petit { padding: 4px 10px; font-size: 12.5px; }
.btn.danger { color: var(--rouge); border-color: #f3c2c7; }
.btn.lien { border: 0; background: none; color: var(--bleu); padding: 4px 6px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* ---------- messages */
.messages { margin-bottom: 14px; }
.msg { padding: 10px 14px; border-radius: 10px; margin-bottom: 8px; font-weight: 500; }
.msg.ok { background: var(--vert-clair); color: var(--vert); }
.msg.erreur { background: var(--rouge-clair); color: var(--rouge); }
.msg.attention { background: var(--orange-clair); color: var(--orange); }

/* ---------- fiche */
.entete-fiche { display: grid; grid-template-columns: 132px 1fr auto; gap: 20px; align-items: start; }
.photo { width: 132px; height: 132px; border-radius: 12px; background: #eef0f2 center/cover no-repeat; display: flex; align-items: center; justify-content: center; color: var(--gris-clair); font-size: 12px; text-align: center; overflow: hidden; }
.photo img { width: 100%; height: 100%; object-fit: cover; }
.ident { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 8px 18px; margin-top: 10px; }
.ident div small { display: block; color: var(--gris); font-size: 11.5px; text-transform: uppercase; letter-spacing: .04em; }
.ident div b { font-weight: 600; }
.code-gros { font-family: Consolas, Menlo, monospace; font-size: 20px; font-weight: 700; letter-spacing: .02em; }
.onglets { display: flex; gap: 4px; border-bottom: 1px solid var(--trait); margin: 6px 0 16px; flex-wrap: wrap; }
.onglets a { padding: 10px 14px; color: var(--gris); font-weight: 600; border-bottom: 3px solid transparent; margin-bottom: -1px; }
.onglets a.actif { color: var(--rouge); border-bottom-color: var(--rouge); }
.onglets a:hover { text-decoration: none; color: var(--encre); }
.panneau { display: none; }
.panneau.actif { display: block; }

/* GRAFCET */
.etapes { position: relative; }
.etape { border: 1px solid var(--trait); border-radius: 10px; margin-bottom: 10px; background: #fff; }
.etape > summary { list-style: none; cursor: pointer; display: flex; align-items: center; gap: 12px; padding: 12px 14px; }
.etape > summary::-webkit-details-marker { display: none; }
.etape .num { width: 30px; height: 30px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-weight: 700; background: #eef0f2; color: var(--gris); flex: none; }
.etape.faite .num { background: var(--vert); color: #fff; }
.etape.courante .num { background: var(--rouge); color: #fff; }
.etape .t { font-weight: 600; flex: 1; }
.etape .corps { padding: 4px 16px 16px 56px; border-top: 1px solid var(--trait); }
.etape.masquee { display: none; }
.montrer-masquees .etape.masquee { display: block; opacity: .85; }
.valeurs { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 6px 16px; margin: 10px 0; }
.valeurs small { display: block; color: var(--gris); font-size: 11.5px; }
.pj { display: flex; gap: 8px; flex-wrap: wrap; margin: 8px 0; }
.pj a, .pj span.manque { display: inline-flex; gap: 6px; align-items: center; padding: 4px 10px; border-radius: 8px; background: #f3f4f6; font-size: 12.5px; }
.pj span.manque { background: var(--orange-clair); color: var(--orange); font-weight: 600; }
.vie-blocs .carte h2 { display: flex; justify-content: space-between; align-items: center; }
details.ajout > summary { cursor: pointer; color: var(--bleu); font-weight: 600; margin: 8px 0; list-style: none; }
details.ajout > summary::-webkit-details-marker { display: none; }
details.ajout[open] { background: #fafbfc; border: 1px solid var(--trait); border-radius: 10px; padding: 4px 14px 12px; margin: 8px 0; }

.vide { color: var(--gris-clair); padding: 18px; text-align: center; }
.connexion { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: linear-gradient(135deg, #17212b, #2c3a47 60%, #5a1b20); }
.connexion .carte { width: 380px; padding: 28px; }
.connexion img { width: 72px; display: block; margin: 0 auto 10px; }

/* ---------- impression */
@media print {
  .menu, .barre-haut, .non-imprime, .onglets, .btn, details.ajout { display: none !important; }
  .cadre { display: block; }
  .contenu { padding: 0; max-width: none; }
  body { background: #fff; font-size: 11.5px; }
  .carte { box-shadow: none; border: 1px solid #ccc; break-inside: avoid; }
  .panneau { display: block !important; }
}

/* ---------- v2.3 */
.btn.deconnexion { background: #e8590c; border-color: #e8590c; color: #fff; font-weight: 650; margin-left: auto; }
.btn.deconnexion:hover { background: #c94a06; border-color: #c94a06; color: #fff; }
.coupe { overflow-wrap: anywhere; word-break: break-word; }
.qr-appli svg { width: 260px; height: 260px; display: block; }
.valeurs > div { min-width: 0; }
