:root {
  --fond: #EAF3FB; --carte: #FFFDF2; --encre: #1E2B3C; --doux: #5A6B82; --ligne: #D6E2EF;
  --bleu: #2F5D8A; --bleu-c: #CFE3F7; --vert: #2E8B57; --vert-c: #D8F0E2; --rouge: #B00020; --rouge-c: #FBE1E4;
  --orange: #C26A00; --orange-c: #FFEBCC; --violet: #6B4FA0; --violet-c: #E9E1F6; --gris-c: #ECEFF3;
  --ombre: 0 3px 0 #C3D5E8; --rayon: 16px;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--fond); color: var(--encre); font: 15px/1.4 'Nunito', 'Segoe UI', system-ui, sans-serif; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--bleu); }
.cache { display: none !important; }

/* bandeau */
header.haut { position: sticky; top: 0; z-index: 20; background: var(--fond); padding: 10px 18px 0; }
.ligne-haut { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.marque { font-weight: 900; font-size: 22px; letter-spacing: .2px; }
.marque span { color: var(--bleu); }
.c2 { display: inline-block; font-size: 12px; font-weight: 800; color: var(--rouge); background: var(--rouge-c); border-radius: 999px; padding: 3px 10px; }
.qui { margin-left: auto; display: flex; align-items: center; gap: 8px; color: var(--doux); }
nav.onglets { display: flex; gap: 6px; margin-top: 10px; overflow-x: auto; padding-bottom: 8px; }
nav.onglets button { border: 0; background: #fff; border-radius: 999px; padding: 8px 16px; font-weight: 800; color: var(--doux); box-shadow: var(--ombre); cursor: pointer; white-space: nowrap; }
nav.onglets button.actif { background: var(--bleu); color: #fff; box-shadow: 0 3px 0 #1d3f61; }
main { padding: 8px 18px 40px; }

/* cartes et boutons */
.carte { background: var(--carte); border-radius: var(--rayon); box-shadow: var(--ombre); padding: 16px; margin-bottom: 14px; }
.btn { border: 0; border-radius: 999px; padding: 8px 16px; font-weight: 800; cursor: pointer; background: #fff; box-shadow: var(--ombre); }
.btn:active { transform: translateY(2px); box-shadow: none; }
.btn-acc { background: var(--bleu); color: #fff; box-shadow: 0 3px 0 #1d3f61; }
.btn-vert { background: var(--vert); color: #fff; box-shadow: 0 3px 0 #1d5e3a; }
.btn-rouge { background: var(--rouge); color: #fff; box-shadow: 0 3px 0 #6e0014; }
.btn-petit { padding: 4px 10px; font-size: 13px; }
.btn:disabled { opacity: .5; cursor: default; }
.icone { border: 0; background: transparent; cursor: pointer; font-size: 16px; padding: 3px 5px; border-radius: 8px; }
.icone:hover { background: var(--bleu-c); }

/* filtres */
.filtres { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 8px 10px; align-items: end; }
.champ label { display: block; font-size: 12px; font-weight: 800; color: var(--doux); margin: 0 0 3px 4px; }
.champ input, .champ select, .champ textarea { width: 100%; border: 2px solid var(--ligne); border-radius: 12px; padding: 7px 10px; background: #fff; }
.champ input:focus, .champ select:focus, .champ textarea:focus { outline: 0; border-color: var(--bleu); }
.champ input[type=checkbox] { width: auto; }
.actions-barre { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-top: 12px; }
.actions-barre .espace { flex: 1; }
.chips { display: flex; gap: 8px; flex-wrap: wrap; margin: 6px 0 10px; }
.chip { background: #fff; border-radius: 999px; padding: 5px 12px; box-shadow: var(--ombre); font-size: 13px; }
.chip b { color: var(--bleu); }

/* tableau */
.defile { overflow: auto; max-height: calc(100vh - 330px); border-radius: 12px; background: #fff; }
table.liste { border-collapse: separate; border-spacing: 0; width: 100%; font-size: 13px; }
table.liste th { position: sticky; top: 0; background: var(--bleu); color: #fff; text-align: left; padding: 8px; font-weight: 800; white-space: nowrap; cursor: pointer; z-index: 1; }
table.liste th.tri-asc::after { content: ' ▲'; } table.liste th.tri-desc::after { content: ' ▼'; }
table.liste td { padding: 6px 8px; border-bottom: 1px solid var(--ligne); vertical-align: top; white-space: nowrap; }
table.liste td.lib, table.liste td.long { white-space: normal; min-width: 180px; }
table.liste tr:hover td { background: #F5F9FD; }
table.liste tr.archivee td { color: #8a94a3; font-style: italic; }
td.n, th.n { text-align: right; white-space: nowrap; }
td.lib { max-width: 260px; }
td.act { white-space: nowrap; }
.pastille { display: inline-block; border-radius: 999px; padding: 2px 9px; font-weight: 800; font-size: 12px; white-space: nowrap; background: var(--gris-c); }
.st-Terminée { background: var(--vert-c); color: var(--vert); }
.st-Annulée { background: var(--rouge-c); color: var(--rouge); }
.st-En-consultation, .st-LDC-à-réceptionner, .st-LDC-à-envoyer { background: var(--orange-c); color: var(--orange); }
.st-AO-à-lancer, .st-A_venir { background: var(--violet-c); color: var(--violet); }
.st-Bloquée { background: #333; color: #fff; }
.vide { text-align: center; color: var(--doux); padding: 30px; }
.neg { color: var(--rouge); }

/* diagnostics */
.graphes { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.graphe { background: #fff; border-radius: 12px; padding: 10px; height: 320px; }
@media (max-width: 1000px) { .graphes { grid-template-columns: 1fr; } }
table.diag { border-collapse: collapse; width: 100%; font-size: 13px; background: #fff; }
table.diag th { background: var(--bleu); color: #fff; padding: 6px; font-size: 12px; text-align: right; }
table.diag th:first-child { text-align: left; min-width: 210px; }
table.diag td { padding: 5px 6px; border-bottom: 1px solid var(--ligne); text-align: right; white-space: nowrap; }
table.diag td:first-child { text-align: left; }
table.diag tr.groupe td { background: var(--bleu-c); font-weight: 800; }
table.diag tr.agence td:first-child { padding-left: 22px; }
table.diag tr.total td { font-weight: 900; border-top: 2px solid var(--bleu); background: #F5F9FD; }
table.diag td.zero { color: #b6c0cc; }
table.diag tr.clic { cursor: pointer; } table.diag tr.clic:hover td { background: #FFF6D6; }
h2 { margin: 4px 0 10px; font-size: 19px; }
h3 { margin: 6px 0 8px; font-size: 16px; }
.aide { color: var(--doux); font-size: 13px; }
.note { background: #FFF6D6; border-radius: 12px; padding: 8px 12px; font-size: 13px; margin: 8px 0; }

/* modales */
.overlay { position: fixed; inset: 0; background: rgba(20, 35, 55, .45); display: flex; align-items: flex-start; justify-content: center; z-index: 100; padding: 30px 12px; overflow: auto; }
.modal { background: var(--carte); border-radius: 20px; box-shadow: 0 6px 0 #9fb6cf; width: 100%; max-width: 560px; padding: 20px; animation: entre .15s ease-out; }
.modal.large { max-width: 980px; }
@keyframes entre { from { transform: translateY(12px); opacity: 0; } }
.modal h2 { margin-top: 0; }
.modal .pied { display: flex; gap: 8px; justify-content: flex-end; margin-top: 16px; flex-wrap: wrap; align-items: center; }
.modal .pied .gauche { margin-right: auto; }
.grille { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px 12px; }
.grille .large2 { grid-column: span 2; } .grille .large3 { grid-column: 1 / -1; }
@media (max-width: 760px) { .grille { grid-template-columns: 1fr; } .grille .large2 { grid-column: auto; } }
fieldset { border: 2px solid var(--ligne); border-radius: 14px; margin: 0 0 12px; padding: 10px 12px 12px; }
legend { font-weight: 900; color: var(--bleu); padding: 0 6px; }
.calcule { background: var(--gris-c); border-radius: 12px; padding: 8px 10px; font-weight: 800; min-height: 38px; }
.erreur { color: var(--rouge); font-weight: 700; font-size: 13px; min-height: 18px; margin-top: 6px; }
.toast { position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%); background: var(--encre); color: #fff; padding: 10px 18px; border-radius: 999px; z-index: 200; font-weight: 700; box-shadow: 0 4px 12px rgba(0,0,0,.2); }
.diff { font-size: 13px; } .diff del { color: var(--rouge); } .diff ins { color: var(--vert); text-decoration: none; font-weight: 700; }

/* connexion */
#ecranConnexion { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; }
#ecranConnexion .carte { width: 100%; max-width: 380px; text-align: center; padding: 26px; }
#ecranConnexion .champ { text-align: left; margin-bottom: 12px; }

/* impression : mention C2 en haut et en bas de chaque page */
.c2-impr { display: none; }
@media print {
  @page { size: A4 landscape; margin: 14mm 8mm; }
  body { background: #fff; font-size: 10px; }
  header.haut nav, .filtres, .actions-barre, td.act, th.act, .qui, .no-print { display: none !important; }
  header.haut { position: static; }
  .defile { max-height: none; overflow: visible; }
  .carte { box-shadow: none; background: #fff; padding: 0; }
  .c2-impr { display: block; position: fixed; left: 0; right: 0; text-align: center; font-weight: 800; color: #B00020; font-size: 10px; }
  .c2-impr.h { top: -10mm; } .c2-impr.b { bottom: -10mm; }
  table.liste th { position: static; }
  .graphe { break-inside: avoid; }
}
