/* ============================================================
   PILOTAGE — thème clair, dans la lignée de Commandes et Cortexia
   ============================================================ */
@import url('https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@400;500;700&family=IBM+Plex+Mono:wght@400;600&display=swap');

:root {
  --ink: #171a14;
  --paper: #f4f5ef;
  --card: #ffffff;
  --lime: #a8c63c;
  --lime-dark: #74901f;
  --lime-pale: #eef4d6;
  --steel: #5f665a;
  --line: #e1e4d8;
  --amber: #b57708;
  --amber-pale: #fff4e5;
  --red: #b8432f;
  --red-pale: #fdecea;
  --ocean: #0f6e8c;
  --ocean-pale: #e4f1f5;
  --radius: 10px;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font-family: 'Space Grotesk', system-ui, sans-serif; background: var(--paper); color: var(--ink); font-size: 15px; line-height: 1.45; }
.mono { font-family: 'IBM Plex Mono', monospace; }
[hidden] { display: none !important; }
h1, h2, h3 { margin: 0; line-height: 1.25; }
h2 { font-size: 20px; }
h3 { font-size: 16px; }
a { color: var(--lime-dark); }

/* ---------- en-tête ---------- */
.entete { background: var(--ink); color: #fff; padding: 14px 20px 0; }
.entete-haut { display: flex; align-items: baseline; gap: 14px; flex-wrap: wrap; padding-right: 170px; }
.marque { font-weight: 700; font-size: 18px; letter-spacing: .01em; }
.marque span { color: var(--lime); }
.sous-marque { color: #c9ccc2; font-size: 13px; }
.sauvegarde { margin-left: auto; font-size: 12px; color: #c9ccc2; white-space: nowrap; }
.sauvegarde.ok { color: var(--lime); }
.sauvegarde.erreur { color: #ffb4a6; font-weight: 700; }
.onglets { display: flex; gap: 2px; margin-top: 10px; overflow-x: auto; scrollbar-width: none; }
.onglets::-webkit-scrollbar { display: none; }
.onglets a { color: #c9ccc2; text-decoration: none; padding: 9px 14px; border-radius: 8px 8px 0 0; font-weight: 500; white-space: nowrap; }
.onglets a:hover { color: #fff; }
.onglets a.actif { background: var(--paper); color: var(--ink); font-weight: 700; }

/* ---------- page ---------- */
main { max-width: 1240px; margin: 0 auto; padding: 18px 16px 60px; }
.carte { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; margin-bottom: 16px; }
.carte h2 { margin-bottom: 10px; }
.muet { color: var(--steel); font-size: 13px; }
.grille-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 16px; }

/* ---------- boutons ---------- */
.btn { font: inherit; font-weight: 600; padding: 8px 14px; border-radius: 8px; border: 1px solid var(--line); background: var(--card); color: var(--ink); cursor: pointer; }
.btn:hover { border-color: var(--steel); }
.btn:disabled { opacity: .5; cursor: default; }
.btn-primaire { background: var(--lime); border-color: var(--lime); }
.btn-primaire:hover { background: #b6d34a; border-color: #b6d34a; }
.btn-petit { padding: 5px 10px; font-size: 13px; }

/* ---------- messages ---------- */
.alerte { padding: 10px 14px; border-radius: 8px; margin: 8px 0; font-size: 14px; }
.alerte.attention { background: var(--amber-pale); color: var(--amber); border: 1px solid #f0d4a8; }
.alerte.erreur { background: var(--red-pale); color: var(--red); border: 1px solid #f2c5bc; }
.alerte.info { background: var(--ocean-pale); color: #0b566e; border: 1px solid #b9d9e3; }
.alerte ul { margin: 6px 0 0; padding-left: 20px; }
.badge { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 600; padding: 2px 9px; border-radius: 20px; background: var(--paper); border: 1px solid var(--line); color: var(--steel); white-space: nowrap; }
.badge.ok { background: var(--lime-pale); border-color: #d3e39b; color: #4d6314; }
.badge.ocean { background: var(--ocean-pale); border-color: #b9d9e3; color: #0b566e; }
.badge.attention { background: var(--amber-pale); border-color: #f0d4a8; color: var(--amber); }

/* ---------- zone de dépôt ---------- */
.depot { border: 2px dashed #c5c9b9; border-radius: var(--radius); padding: 34px 20px; text-align: center; background: var(--card); cursor: pointer; transition: border-color .15s, background .15s; }
.depot.survol, .depot:hover { border-color: var(--lime-dark); background: var(--lime-pale); }
.depot strong { display: block; font-size: 17px; margin-bottom: 4px; }
.depot input { display: none; }

/* ---------- tableaux ---------- */
.tableau { width: 100%; border-collapse: collapse; font-size: 14px; }
.tableau th, .tableau td { padding: 7px 9px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
.tableau th { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--steel); font-weight: 600; background: var(--paper); position: sticky; top: 0; }
.tableau td.nb, .tableau th.nb { text-align: right; font-family: 'IBM Plex Mono', monospace; font-variant-numeric: tabular-nums; white-space: nowrap; }
.tableau tr.total td { font-weight: 700; background: var(--paper); }
.tableau tr.section td { font-weight: 700; color: var(--steel); text-transform: uppercase; font-size: 12px; letter-spacing: .04em; background: var(--paper); }
.tableau td.neg { color: var(--red); }
.tableau td.sous-seuil { background: var(--amber-pale); }
.defilant { overflow-x: auto; max-height: 70vh; overflow-y: auto; border: 1px solid var(--line); border-radius: 8px; }
.source { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 4px; vertical-align: middle; }
.source.realise { background: var(--lime-dark); }
.source.prevu { background: var(--ocean); }
.source.saison { background: #c9b26b; }
.source.vide, .source.aucune { background: #d6d8cf; }
.source.collecte { background: #6b4c9a; }
.journal { padding: 8px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.journal.erreur strong { color: var(--red); }
.legende { display: flex; gap: 16px; flex-wrap: wrap; font-size: 13px; color: var(--steel); margin: 8px 0; }
select.famille, select.categorie, input.delai { font: inherit; font-size: 13px; padding: 3px 6px; border: 1px solid var(--line); border-radius: 6px; background: var(--card); }
input.delai { width: 58px; }

/* ---------- chiffres clés ---------- */
.chiffres { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin: 10px 0; }
.chiffre { background: var(--paper); border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; }
.chiffre .val { font-size: 22px; font-weight: 700; font-family: 'IBM Plex Mono', monospace; }
.chiffre .lib { font-size: 12px; color: var(--steel); text-transform: uppercase; letter-spacing: .04em; }
.chiffre.attention .val { color: var(--amber); }

/* ---------- fenêtres de dialogue ---------- */
.voile { position: fixed; inset: 0; background: rgba(23, 26, 20, .45); display: flex; align-items: center; justify-content: safe center; padding: 20px; z-index: 50; overflow: auto; }
.fenetre { background: var(--card); border-radius: 12px; padding: 18px 20px; width: min(560px, 100%); max-height: calc(100vh - 40px); overflow: auto; box-shadow: 0 12px 40px rgba(0, 0, 0, .25); }
.fenetre h2 { margin-bottom: 8px; }
.fenetre .pied { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }
.champ { display: block; margin-top: 10px; }
.champ > span { display: block; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--steel); font-weight: 600; margin-bottom: 3px; }
.champ input[type=text], .champ input[type=number], .champ input[type=month], .champ select, .champ textarea { font: inherit; padding: 7px 9px; border: 1px solid var(--line); border-radius: 8px; background: var(--card); width: 300px; max-width: calc(100% - 30px); vertical-align: middle; }
.champ .unite { margin-left: 6px; color: var(--steel); }
.champ .requis { color: var(--red); }
.cible { display: flex; flex-direction: column; gap: 6px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { display: inline-flex; align-items: center; gap: 4px; padding: 4px 10px; border: 1px solid var(--line); border-radius: 20px; background: var(--paper); font-size: 13px; cursor: pointer; }
.parametres { display: flex; gap: 18px; flex-wrap: wrap; }
.parametres .champ { margin-top: 0; }

/* ---------- graphique ---------- */
.graphique-zone { position: relative; margin: 8px 0; }
.graphique { width: 100%; height: auto; display: block; }
.graphique .grille { stroke: var(--line); stroke-width: 1; }
.graphique .zero { stroke: var(--steel); stroke-width: 1; }
.graphique .seuil { stroke: var(--amber); stroke-width: 1.5; stroke-dasharray: 6 4; }
.graphique .axe { font-size: 12px; fill: var(--steel); font-family: 'Space Grotesk', system-ui, sans-serif; }
.graphique .seuil-txt { fill: var(--amber); }
.graphique .serie { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.graphique .serie.reference { stroke-width: 2.5; }
.graphique .nom { font-size: 12px; font-weight: 600; font-family: 'Space Grotesk', system-ui, sans-serif; }
.graphique .curseur { stroke: var(--steel); stroke-width: 1; stroke-dasharray: 3 3; }
.bulle { position: absolute; background: var(--card); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; font-size: 13px; pointer-events: none; box-shadow: 0 4px 14px rgba(0, 0, 0, .12); white-space: nowrap; z-index: 5; }
.bulle i { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 6px; }
.bulle b { font-family: 'IBM Plex Mono', monospace; }
.pastille { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 6px; vertical-align: middle; }

/* ---------- scénarios ---------- */
.cartes-scenarios { display: grid; grid-template-columns: repeat(auto-fit, minmax(290px, 1fr)); gap: 16px; margin-bottom: 16px; }
.scenario-carte h3 a { color: inherit; text-decoration: none; }
.ecart-val { display: block; font-size: 12px; font-weight: 600; font-family: 'IBM Plex Mono', monospace; }
.ecart-val.pos { color: var(--lime-dark); }
.ecart-val.neg { color: var(--red); }
.tableau tr.ecart td { font-size: 12px; border-bottom-width: 2px; }
.deux-colonnes { display: grid; grid-template-columns: 260px 1fr; gap: 16px; align-items: start; }
.liste-scenarios .item { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border-radius: 8px; text-decoration: none; color: var(--ink); margin: 2px 0; }
.liste-scenarios .item:hover { background: var(--paper); }
.liste-scenarios .item.actif { background: var(--lime-pale); font-weight: 700; }
.liste-scenarios .item .nom { flex: 1; }
.entete-scenario { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; align-items: flex-start; margin-bottom: 8px; }
.entete-scenario input.titre { font: inherit; font-size: 20px; font-weight: 700; border: 1px solid transparent; border-radius: 6px; padding: 2px 6px; width: min(420px, 100%); background: transparent; }
.entete-scenario input.description { font: inherit; font-size: 14px; color: var(--steel); border: 1px solid transparent; border-radius: 6px; padding: 2px 6px; width: min(520px, 100%); background: transparent; }
.entete-scenario input:hover, .entete-scenario input:focus { border-color: var(--line); background: var(--card); }
.tableau.leviers tr.inactif td { opacity: .5; }
.tableau tr.inactif td { opacity: .6; }
details > summary { cursor: pointer; list-style: none; }
details > summary::before { content: '▸ '; color: var(--steel); }
details[open] > summary::before { content: '▾ '; }
.btn-danger { color: var(--red); }
.btn-danger:hover { border-color: var(--red); }

/* ---------- comparaison ---------- */
.grille-barres { display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); gap: 14px 24px; }
.bloc-barres { min-width: 0; }
.titre-barres { font-size: 13px; text-transform: uppercase; letter-spacing: .04em; color: var(--steel); margin: 6px 0 2px; }
.graphique.barres .nom-barre { font-size: 12px; fill: var(--ink); }
.graphique.barres .val-barre { font-size: 12px; fill: var(--ink); font-family: 'IBM Plex Mono', monospace; }
.graphique.barres .ecart-txt { fill: var(--steel); font-size: 11px; }
.chip input { margin: 0; }

/* ---------- budget mois par mois ---------- */
.grille-budget { max-height: 75vh; }
.tableau.budget th.fixe, .tableau.budget td.fixe { position: sticky; left: 0; background: var(--card); z-index: 2; min-width: 230px; max-width: 300px; box-shadow: 1px 0 0 var(--line); }
.tableau.budget thead th.fixe { z-index: 3; background: var(--paper); }
.tableau.budget tr.section td.fixe, .tableau.budget tr.total td.fixe { background: var(--paper); }
.tableau.budget tr.resultat td { border-top: 2px solid var(--steel); }
.tableau.budget td.nb { font-size: 13px; }
.btn-icone { padding: 2px 7px; font-size: 13px; line-height: 1.2; }
.tableau.montants input { width: 120px; font: inherit; font-size: 13px; padding: 3px 6px; border: 1px solid var(--line); border-radius: 6px; }
.tableau.montants td, .tableau.montants th { padding: 3px 6px; }

@media (max-width: 860px) {
  .deux-colonnes { grid-template-columns: 1fr; }
}
@media (max-width: 700px) {
  .entete-haut { padding-right: 0; }
  main { padding: 12px 10px 40px; }
  .carte { padding: 12px; }
}
