@font-face { font-family: "Draft Natural"; src: url("fonts/DraftNatural-Bold.ttf") format("truetype"); font-weight: 700; font-display: swap; }
:root {
  --marine: #3b3a5e; --nuit: #27273e; --ambre: #eca327; --orange: #ee7b42; --creme: #efede5;
  --fond: #f6f6f4; --carte: #ffffff; --texte: #23223a; --doux: #6b6a80; --trait: #e3e1ea; --trait-fort: #babac8;
  --vert: #1f7a4d; --rouge: #b3261e; --survol: #f3f2f8;
  --police: "Barlow", "Avenir Next", "Helvetica Neue", "Segoe UI", system-ui, -apple-system, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font: 15px/1.45 var(--police); color: var(--texte); background: var(--fond); }
a { color: var(--marine); }
h1, h2, h3 { margin: 0; line-height: 1.2; }
svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; flex: none; }

/* Structure : barre latérale sombre, bandeau blanc, contenu sur fond clair */
.app { display: grid; grid-template-columns: 232px minmax(0, 1fr); min-height: 100%; }
.barre { background: var(--nuit); color: #fff; display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; overflow-y: auto; z-index: 30; }
.marque { display: flex; gap: 11px; align-items: center; padding: 16px 16px 12px; color: #fff; text-decoration: none; }
.marque img { border-radius: 9px; }
.marque strong { display: block; font: 700 21px/1 "Draft Natural", var(--police); letter-spacing: .3px; }
.marque small { display: block; color: #b9b7d6; font-size: 11.5px; margin-top: 4px; letter-spacing: .04em; }
.nouveau-zone { padding: 6px 14px 12px; position: relative; }
.btn-nouveau { width: 100%; display: flex; align-items: center; justify-content: center; gap: 8px; font: 600 15px var(--police); color: var(--nuit); background: var(--ambre); border: 0; border-radius: 99px; padding: 9px 16px; cursor: pointer; }
.btn-nouveau:hover { background: #f4b443; }
.menu-nouveau { position: fixed; left: 222px; top: 62px; z-index: 40; background: #fff; color: var(--texte); border-radius: 10px; box-shadow: 0 12px 40px rgba(30, 28, 60, .28); padding: 18px 22px; display: grid; grid-template-columns: repeat(3, minmax(150px, 1fr)); gap: 6px 26px; }
.menu-nouveau[hidden] { display: none; }
.menu-nouveau h3 { font-size: 12px; text-transform: uppercase; letter-spacing: .07em; color: var(--doux); margin-bottom: 6px; }
.menu-nouveau button { display: block; width: 100%; text-align: left; font: inherit; border: 0; background: none; padding: 7px 8px; margin-left: -8px; border-radius: 6px; cursor: pointer; color: var(--texte); }
.menu-nouveau button:hover { background: var(--survol); color: var(--marine); }
#nav { padding: 2px 0; flex: 1; }
#nav a { display: flex; align-items: center; gap: 12px; padding: 10px 18px; color: #d9d8ea; text-decoration: none; font-weight: 500; border-left: 4px solid transparent; }
#nav a:hover { background: rgba(255, 255, 255, .07); color: #fff; }
#nav a[aria-current="page"] { background: rgba(255, 255, 255, .12); color: #fff; border-left-color: var(--ambre); font-weight: 600; }
.barre-pied { padding: 14px 18px 16px; color: #9e9cbd; font-size: 11.5px; line-height: 1.4; }
.sauvegarde { margin-bottom: 8px; color: #cfe3d2; min-height: 16px; font-size: 12px; }

.page { min-width: 0; display: flex; flex-direction: column; }
.haut { display: flex; align-items: center; gap: 14px; padding: 9px 28px; background: var(--carte); border-bottom: 1px solid var(--trait); position: sticky; top: 0; z-index: 20; min-height: 56px; }
.haut-entite { display: flex; align-items: center; gap: 16px; flex: 1; min-width: 0; }
.haut-entite strong { font-size: 17px; color: var(--marine); }
.champ-exercice { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--doux); }
.champ-exercice select { min-height: 34px; padding: 4px 8px; border-radius: 6px; }
.haut-outils { display: flex; align-items: center; gap: 6px; }
.recherche { display: flex; align-items: center; gap: 6px; border: 1px solid var(--trait-fort); border-radius: 99px; padding: 0 12px; background: #fff; color: var(--doux); }
.recherche input { border: 0; min-height: 34px; padding: 4px 2px; width: 210px; background: none; outline: none; }
.recherche:focus-within { outline: 3px solid rgba(236, 163, 39, .55); }
main { padding: 22px 28px 60px; max-width: 1500px; width: 100%; }
#vue { outline: none; }
.titre-zone { display: flex; align-items: center; gap: 12px; justify-content: space-between; margin-bottom: 18px; flex-wrap: wrap; }
.titre-zone h1 { font: 700 30px/1.1 "Draft Natural", var(--police); color: var(--texte); }
#titre-outils { display: flex; gap: 8px; align-items: center; }
.menu-mobile { display: none; }

/* Champs et boutons */
select, input, textarea { font: inherit; color: inherit; background: #fff; border: 1px solid var(--trait-fort); border-radius: 6px; padding: 7px 10px; min-height: 38px; max-width: 100%; }
textarea { min-height: 84px; width: 100%; resize: vertical; }
select:focus, input:focus, textarea:focus, button:focus-visible, a:focus-visible { outline: 3px solid rgba(236, 163, 39, .55); outline-offset: 1px; }
.btn { display: inline-flex; align-items: center; gap: 8px; font: inherit; font-weight: 600; border: 2px solid var(--marine); background: #fff; color: var(--marine); border-radius: 99px; padding: 5px 16px; min-height: 36px; cursor: pointer; text-decoration: none; white-space: nowrap; }
.btn:hover { background: var(--survol); }
.btn.principal { background: var(--marine); color: #fff; }
.btn.principal:hover { background: var(--nuit); border-color: var(--nuit); }
.btn.danger { color: var(--rouge); border-color: var(--rouge); }
.btn.petit { padding: 2px 12px; min-height: 28px; font-size: 13px; border-width: 1.5px; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.btn-icone { border: 0; background: none; color: var(--doux); padding: 7px; border-radius: 99px; cursor: pointer; display: inline-flex; text-decoration: none; }
.btn-icone:hover { background: var(--survol); color: var(--marine); }
.outils { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 14px; }
.outils .pousse { flex: 1; }
.onglets { display: flex; gap: 2px; flex-wrap: wrap; border-bottom: 1px solid var(--trait); margin-bottom: 18px; align-items: flex-end; }
.onglets a { padding: 8px 14px; text-decoration: none; color: var(--doux); font-weight: 600; border-bottom: 3px solid transparent; margin-bottom: -1px; }
.onglets a:hover { color: var(--marine); }
.onglets a[aria-current="page"] { color: var(--texte); border-color: var(--ambre); }
.onglets .sep { padding: 8px 6px 9px 14px; color: var(--doux); font-size: 11.5px; text-transform: uppercase; letter-spacing: .07em; }
.onglets .sep:first-child { padding-left: 0; }

/* Cartes et tableau de bord */
.carte { background: var(--carte); border: 1px solid var(--trait); border-radius: 8px; padding: 20px 22px; margin-bottom: 18px; box-shadow: 0 1px 2px rgba(35, 34, 58, .04); }
.carte > h2, .carte > h3 { font-size: 17px; margin-bottom: 12px; }
.grille-tb { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px; }
.grille-tb .carte { margin: 0; }
.tuile.large { grid-column: span 2; }
.tuile:last-child.large { grid-column: 1 / -1; }
.tuile header { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; margin-bottom: 14px; }
.tuile header h2 { font-size: 13px; text-transform: uppercase; letter-spacing: .07em; color: var(--doux); font-weight: 700; }
.tuile header a { font-size: 13px; font-weight: 600; }
.trio { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; margin-bottom: 8px; }
.trio .lib { display: block; font-size: 13px; color: var(--doux); }
.trio .val { display: block; font-size: 26px; font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; line-height: 1.2; }
.trio .sous { display: block; font-size: 12px; color: var(--doux); }
.graphe { width: 100%; height: auto; stroke: none; }
.legende { display: flex; gap: 18px; font-size: 13px; color: var(--doux); margin-top: 6px; flex-wrap: wrap; align-items: center; }
.legende i, .donut li i { display: inline-block; width: 11px; height: 11px; border-radius: 3px; margin-right: 6px; flex: none; }
.legende a { margin-left: auto; font-weight: 600; }
.donut { display: flex; gap: 16px; align-items: center; }
.donut svg { width: 140px; height: 140px; stroke-width: 0; }
.donut ul { list-style: none; margin: 0; padding: 0; flex: 1; min-width: 0; font-size: 13px; }
.donut li { display: flex; align-items: baseline; gap: 2px; padding: 3px 0; }
.donut li span { flex: 1; min-width: 0; line-height: 1.25; }
.donut li b { font-variant-numeric: tabular-nums; padding-left: 8px; }
.lignes-tuile { list-style: none; margin: 0; padding: 0; }
.lignes-tuile a { display: flex; justify-content: space-between; gap: 12px; padding: 9px 0; border-bottom: 1px solid var(--trait); text-decoration: none; color: var(--texte); }
.lignes-tuile a:hover span { color: var(--marine); text-decoration: underline; }
.lignes-tuile b:last-child, .total-tuile b { font-variant-numeric: tabular-nums; white-space: nowrap; }
.total-tuile { display: flex; justify-content: space-between; gap: 12px; padding-top: 11px; font-weight: 600; }
.badge { display: inline-block; font-size: 12px; font-weight: 600; padding: 2px 10px; border-radius: 99px; background: #ecebf3; color: var(--marine); white-space: nowrap; text-decoration: none; }
.badge.ok { background: #e2f3ea; color: var(--vert); } .badge.attention { background: #fdf0d6; color: #7a4f00; }
.alerte { background: #fdf6e6; border: 1px solid #f0d9a4; border-left: 5px solid var(--ambre); border-radius: 6px; padding: 12px 16px; margin-bottom: 16px; }
ul.points { margin: 0; padding-left: 20px; } ul.points li { margin-bottom: 8px; }
.rapports { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.rapports .carte { margin: 0; }
.liste-rapports { list-style: none; margin: 0; padding: 0; }
.liste-rapports a { display: flex; gap: 12px; align-items: flex-start; padding: 11px 6px; border-top: 1px solid var(--trait); text-decoration: none; color: var(--texte); border-radius: 4px; }
.liste-rapports a:hover { background: var(--survol); }
.liste-rapports a svg { color: var(--marine); margin-top: 2px; }
.liste-rapports b { display: block; color: var(--marine); } .liste-rapports small { color: var(--doux); font-size: 13px; }

.chiffres { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 14px; margin-bottom: 16px; }
.chiffre { background: var(--carte); border: 1px solid var(--trait); border-radius: 8px; padding: 14px 18px; }
.chiffre .lib { display: block; font-size: 13px; color: var(--doux); } .chiffre .sous { display: block; font-size: 12px; color: var(--doux); }
.chiffre .val { display: block; font-size: 25px; font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1.25; }

/* Listes */
table { border-collapse: collapse; width: 100%; }
.liste th, .liste td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--trait); vertical-align: top; }
.liste th { font-size: 11.5px; text-transform: uppercase; letter-spacing: .06em; color: var(--doux); background: #fff; border-bottom: 2px solid var(--trait-fort); position: sticky; top: 56px; z-index: 2; }
.liste tbody tr:hover { background: #faf9fd; }
.liste tfoot td { border-bottom: 0; background: #faf9fc; }
.liste .lignes { font-size: 13px; color: var(--doux); }
.liste .lignes div { display: flex; gap: 8px; justify-content: space-between; }
.liste .src { font-size: 12px; color: var(--doux); margin-top: 3px; max-width: 520px; }
.num { text-align: right !important; font-variant-numeric: tabular-nums; white-space: nowrap; }
.vide { text-align: center; color: var(--doux); padding: 28px 10px; }
.scroll { overflow-x: auto; }
.petit-texte { font-size: 13px; color: var(--doux); }

/* Rapports : feuille blanche centrée, lignes horizontales, totaux soulignés */
.feuille { background: #fff; border: 1px solid var(--trait); border-radius: 4px; padding: 30px 34px; overflow-x: auto; box-shadow: 0 1px 3px rgba(35, 34, 58, .06); max-width: 1240px; margin: 0 auto 18px; }
.etat-tete { text-align: center; margin-bottom: 18px; }
.etat-entite { font-size: 15px; color: var(--doux); }
.etat-titre { font-size: 22px; font-weight: 700; margin: 4px 0; }
.etat-sous { font-size: 13px; color: var(--doux); }
.etat { font-size: 13.5px; margin-bottom: 14px; }
.etat th, .etat td { border: 0; border-bottom: 1px solid var(--trait); padding: 6px 8px; vertical-align: middle; }
.etat th { font-size: 11.5px; text-transform: uppercase; letter-spacing: .05em; color: var(--doux); text-align: left; border-bottom: 2px solid var(--texte); vertical-align: bottom; }
.etat th.centre { text-align: center; }
.etat .ref { font-weight: 600; width: 44px; white-space: nowrap; color: var(--marine); } .etat .ref a { text-decoration: none; }
.etat .note { width: 52px; text-align: center; color: var(--doux); font-size: 12.5px; }
.etat tbody tr:hover td { background: #faf9fd; }
.etat tr.tot td { font-weight: 700; }
.etat tr.tot.sous td { background: #faf9fc; }
.etat tr.tot.grand td { border-top: 1px solid var(--texte); background: #f3f2f8; }
.etat tr.tot.general td { border-top: 2px solid var(--texte); border-bottom: 3px double var(--texte); background: var(--creme); }
.etat tr.rub td { font-weight: 700; color: var(--marine); padding-top: 12px; }
.etat.serre { font-size: 12px; } .etat.serre th, .etat.serre td { padding: 4px 6px; }
.deux-col { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: 26px; align-items: start; }
.pied { font-size: 12.5px; color: var(--doux); margin: 6px 0; }
.controle { font-size: 13px; font-weight: 600; margin: 8px 0 0; } .controle.ok { color: var(--vert); } .controle.ko { color: var(--rouge); }
ul.notes { padding-left: 18px; font-size: 13.5px; } ul.notes li { margin-bottom: 8px; }
.feuille h3 { font-size: 15px; margin: 20px 0 8px; }

/* Formulaires */
dialog { border: 0; border-radius: 10px; padding: 0; width: min(880px, calc(100vw - 24px)); max-height: calc(100vh - 24px); box-shadow: 0 20px 60px rgba(30, 28, 60, .35); color: var(--texte); }
dialog::backdrop { background: rgba(39, 39, 62, .55); }
.dlg-tete { display: flex; align-items: center; justify-content: space-between; padding: 16px 22px; border-bottom: 1px solid var(--trait); }
.dlg-tete h2 { font-size: 20px; }
.dlg-corps { padding: 18px 22px; overflow-y: auto; max-height: calc(100vh - 190px); }
.dlg-pied { display: flex; justify-content: flex-end; gap: 10px; padding: 14px 22px; border-top: 1px solid var(--trait); background: var(--fond); }
.champs { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 12px 14px; }
.champ { grid-column: span 6; display: flex; flex-direction: column; gap: 4px; }
.champ.c3 { grid-column: span 3; } .champ.c4 { grid-column: span 4; } .champ.c8 { grid-column: span 8; } .champ.c12 { grid-column: span 12; }
.champ label, .champ > span { font-size: 13px; font-weight: 600; color: var(--doux); }
.champ input, .champ select { width: 100%; }
.champ .aide { font-size: 12px; color: var(--doux); font-weight: 400; }
.modes { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 16px; }
.modes button { font: inherit; font-size: 14px; font-weight: 600; padding: 5px 13px; border-radius: 99px; border: 1.5px solid var(--trait-fort); background: #fff; cursor: pointer; color: var(--marine); }
.modes button:hover { border-color: var(--marine); }
.modes button[aria-pressed="true"] { background: var(--marine); color: #fff; border-color: var(--marine); }
.lignes-saisie input, .lignes-saisie select { min-height: 34px; padding: 5px 8px; width: 100%; }
.lignes-saisie td, .lignes-saisie th { padding: 4px; font-size: 13px; text-align: left; }
.erreurs { background: #fbe9e7; border: 1px solid #efb8b2; color: #7d1a14; border-radius: 6px; padding: 10px 14px; margin-top: 14px; }
.erreurs ul { margin: 0; padding-left: 18px; }
.toast { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%) translateY(20px); background: var(--nuit); color: #fff; padding: 10px 18px; border-radius: 99px; opacity: 0; pointer-events: none; transition: .2s; z-index: 50; max-width: calc(100vw - 30px); }
.toast.vu { opacity: 1; transform: translateX(-50%); }

@media (max-width: 1180px) { .deux-col, .rapports { grid-template-columns: minmax(0, 1fr); } .grille-tb { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 820px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .barre { position: fixed; width: 250px; transform: translateX(-100%); transition: transform .2s; }
  .barre.ouvert { transform: none; box-shadow: 0 0 0 100vmax rgba(0, 0, 0, .35); }
  .menu-nouveau { left: 12px; right: 12px; top: 110px; grid-template-columns: minmax(0, 1fr); max-height: 70vh; overflow: auto; }
  .menu-mobile { display: inline-flex; }
  .haut { padding: 8px 12px; gap: 8px; } .recherche { display: none; } .champ-exercice span { display: none; }
  main { padding: 16px 14px 50px; } .titre-zone h1 { font-size: 24px; }
  .grille-tb { grid-template-columns: minmax(0, 1fr); } .tuile.large { grid-column: auto; }
  .trio { grid-template-columns: minmax(0, 1fr); gap: 8px; } .donut { flex-direction: column; align-items: stretch; } .donut svg { align-self: center; }
  .champ, .champ.c3, .champ.c4, .champ.c8 { grid-column: span 12; }
  .liste th { position: static; }
  .feuille { padding: 16px 12px; }
}
@media print {
  @page { size: A4 landscape; margin: 12mm; }
  body { background: #fff; font-size: 11px; }
  .barre, .haut, .outils, .onglets, .toast, .sans-impression, .titre-zone, .chiffres { display: none !important; }
  .app { display: block; } main { padding: 0; max-width: none; }
  .feuille, .carte { border: 0; padding: 0; border-radius: 0; overflow: visible; box-shadow: none; max-width: none; }
  .scroll { overflow: visible; }
  .etat { font-size: 10.5px; } .etat.serre { font-size: 8.5px; }
  .etat tr.tot td, .etat tr.tot.general td { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  tr { break-inside: avoid; } .liste th { position: static; }
  textarea { border: 0; padding: 0; resize: none; }
  a { color: inherit; text-decoration: none; }
}

.grille-tb .carte, .rapports .carte { min-width: 0; }

.est { font-size: 11px; font-weight: 600; color: #7a4f00; background: #fdf0d6; border-radius: 99px; padding: 0 6px; margin-left: 4px; }
