/* BAC 360° — charte Actual (DM Sans, rouge #C01E1E), sobre et dense. */
:root {
  --accent: #C01E1E;
  --accent-fonce: #8E1014;
  --accent-lavis: #FBE9E9;
  --encre: #1A1A1A;
  --encre-2: #3A3A3A;
  --encre-3: #6B6B6B;
  --ligne: #E6E6E6;
  --ligne-2: #F0F0F0;
  --fond: #F6F6F4;
  --surface: #FFFFFF;
  --nuit: #161616;
  --ok: #2E6A40; --ok-lavis: #EAF3EC;
  --alerte: #9A5B00; --alerte-lavis: #FFF4E0;
  --serie-1: #C01E1E; --serie-2: #2F3E4E; --serie-3: #B9B9B9;
  --sans: 'DM Sans', system-ui, sans-serif;
  --mono: 'DM Mono', ui-monospace, monospace;
  --r: 12px;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font: 14px/1.45 var(--sans); color: var(--encre); background: var(--fond); -webkit-font-smoothing: antialiased; }
h1, h2, h3, p, figure { margin: 0; }
a { color: inherit; }
.mono, code { font-family: var(--mono); font-size: .92em; }
.conteneur { max-width: 1440px; margin: 0 auto; padding: 0 28px 48px; }
small { color: var(--encre-3); }
[hidden] { display: none !important; }

/* ─── Boutons ─── */
.btn { height: 38px; padding: 0 14px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; border-radius: 9px;
  border: 1px solid var(--ligne); background: var(--surface); color: var(--encre); font: 600 13px var(--sans); text-decoration: none; cursor: pointer; white-space: nowrap; }
.btn:hover { border-color: var(--encre-3); }
.btn-plein { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-plein:hover { background: var(--accent-fonce); border-color: var(--accent-fonce); }
.btn-petit { height: 30px; padding: 0 10px; font-size: 12px; border-radius: 7px; }
.btn-large { height: 48px; padding: 0 22px; font-size: 15px; width: 100%; }
.btn-danger { color: var(--accent-fonce); border-color: #E8BDBD; }
.btn-icone { width: 30px; height: 30px; padding: 0; border-radius: 7px; border: 1px solid transparent; background: transparent; color: var(--encre-3); cursor: pointer; display: inline-flex; align-items: center; justify-content: center; }
.btn-icone:hover { border-color: var(--ligne); background: var(--surface); color: var(--accent); }
.btn-icone svg { width: 16px; height: 16px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ─── En-tête ─── */
.bandeau-voir-comme { background: var(--alerte-lavis); color: var(--alerte); padding: 8px 28px; display: flex; gap: 12px; align-items: center; justify-content: center; font-size: 13px; }
.bandeau-voir-comme button { border: 1px solid currentColor; background: transparent; color: inherit; border-radius: 6px; padding: 3px 10px; font: 600 12px var(--sans); cursor: pointer; }
.tete { background: var(--nuit); color: #fff; position: sticky; top: 0; z-index: 20; }
.tete-in { max-width: 1440px; margin: 0 auto; padding: 0 28px; height: 60px; display: flex; align-items: center; gap: 18px; }
.marque { display: flex; align-items: center; gap: 12px; text-decoration: none; }
.marque img { height: 22px; }
.nom-app { font-size: 17px; letter-spacing: .01em; padding-left: 12px; border-left: 1px solid #444; }
.nom-app b { color: #FF5A5A; font-weight: 700; }
.pastille-poc { font: 500 10px var(--mono); letter-spacing: .08em; border: 1px solid #555; color: #CFCFCF; border-radius: 999px; padding: 2px 8px; }
.onglets { display: flex; gap: 2px; margin-left: 8px; flex: 1; overflow-x: auto; }
.onglets a { padding: 8px 12px; border-radius: 8px; color: #CFCFCF; text-decoration: none; font-weight: 500; white-space: nowrap; }
.onglets a:hover { color: #fff; background: #262626; }
.onglets a[aria-current] { color: #fff; background: #2A2A2A; box-shadow: inset 0 -2px 0 var(--accent); }
.menu-compte { position: relative; }
.menu-compte summary { list-style: none; width: 34px; height: 34px; border-radius: 50%; background: #2A2A2A; display: flex; align-items: center; justify-content: center; font: 600 12px var(--sans); cursor: pointer; }
.menu-compte summary::-webkit-details-marker { display: none; }
.menu-compte > div { position: absolute; right: 0; top: 44px; background: var(--surface); color: var(--encre); border: 1px solid var(--ligne); border-radius: 10px; padding: 14px; min-width: 240px; display: grid; gap: 4px; box-shadow: 0 10px 30px rgba(0,0,0,.12); }
.menu-compte form { margin-top: 10px; }

/* ─── Titres, filtres ─── */
.titre-vue { display: flex; justify-content: space-between; align-items: end; gap: 24px; padding: 26px 0 16px; flex-wrap: wrap; }
.titre-vue h1 { font-size: 26px; font-weight: 700; letter-spacing: -.01em; }
.sous-titre { color: var(--encre-3); margin-top: 4px; max-width: 760px; }
.fraicheur { color: var(--encre-3); font-size: 13px; }
.fraicheur .alerte { color: var(--accent); }
.filtres { position: sticky; top: 60px; z-index: 10; display: flex; flex-wrap: wrap; gap: 10px 18px; align-items: end; background: var(--surface); border: 1px solid var(--ligne); border-radius: var(--r); padding: 12px 16px; margin-bottom: 16px; box-shadow: 0 2px 10px rgba(0,0,0,.03); }
.filtres label { display: grid; gap: 4px; font-size: 11px; font-weight: 600; color: var(--encre-3); text-transform: uppercase; letter-spacing: .04em; }
.filtres select { height: 34px; border: 1px solid var(--ligne); border-radius: 8px; padding: 0 8px; font: 14px var(--sans); color: var(--encre); background: var(--surface); min-width: 120px; text-transform: none; letter-spacing: 0; }
.filtres label.large select { min-width: 280px; max-width: 380px; }
.bascule { border: 0; padding: 0; margin: 0; display: flex; flex-wrap: nowrap; }
.bascule legend { font-size: 11px; font-weight: 600; color: var(--encre-3); text-transform: uppercase; letter-spacing: .04em; padding: 0; margin-bottom: 4px; }
.filtres .bascule label { display: inline-block; text-transform: none; letter-spacing: 0; }
.bascule input { position: absolute; opacity: 0; pointer-events: none; }
.bascule span { display: inline-block; padding: 7px 10px; border: 1px solid var(--ligne); margin-right: -1px; font: 500 13px var(--sans); color: var(--encre-2); cursor: pointer; background: var(--surface); }
.bascule label:first-of-type span { border-radius: 8px 0 0 8px; }
.bascule label:last-of-type span { border-radius: 0 8px 8px 0; }
.bascule input:checked + span { background: var(--encre); border-color: var(--encre); color: #fff; }
.bascule input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 1px; }

/* ─── Indicateurs ─── */
.kpi { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 12px; margin-bottom: 16px; }
.tuile { background: var(--surface); border: 1px solid var(--ligne); border-radius: var(--r); padding: 14px 16px; min-height: 108px; display: flex; flex-direction: column; gap: 4px; }
.tuile .etiquette { font-size: 12px; color: var(--encre-3); font-weight: 600; }
.tuile .valeur { font: 600 25px/1.15 var(--sans); letter-spacing: -.01em; font-variant-numeric: tabular-nums; }
.tuile .detail { font-size: 12px; color: var(--encre-3); margin-top: auto; }
.tuile.accent { border-color: #EBC7C7; background: linear-gradient(180deg, #fff, #FFF8F8); }
.ecart-pos { color: var(--accent); font-weight: 600; }
.ecart-neg { color: var(--ok); font-weight: 600; }
.jauge { height: 6px; background: var(--ligne-2); border-radius: 99px; overflow: hidden; margin-top: 6px; }
.jauge i { display: block; height: 100%; background: var(--encre-2); border-radius: 99px; }
.jauge.depasse i { background: var(--accent); }

/* ─── Cartes, graphiques ─── */
.carte { background: var(--surface); border: 1px solid var(--ligne); border-radius: var(--r); padding: 16px 18px; margin-bottom: 16px; }
.carte h2 { font-size: 16px; font-weight: 700; margin-bottom: 10px; }
.carte h3 { font-size: 13px; font-weight: 700; margin: 4px 0 6px; }
.graphes { display: grid; grid-template-columns: 1.35fr 1fr; gap: 12px; }
.graphes figure { margin-bottom: 16px; }
figcaption { font-size: 13px; font-weight: 700; margin-bottom: 8px; display: flex; justify-content: space-between; gap: 10px; }
.legende { display: flex; gap: 14px; font-size: 12px; color: var(--encre-3); font-weight: 500; }
.legende i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 5px; vertical-align: -1px; }
.legende i.trait { height: 2px; border-radius: 0; vertical-align: 3px; border-top: 2px dashed var(--encre-2); background: none; }
.graphe svg { width: 100%; height: auto; display: block; font: 11px var(--sans); }
.graphe .axe { fill: var(--encre-3); }
.graphe .grille { stroke: var(--ligne-2); }
.graphe .barre { fill: var(--serie-2); }
.graphe .barre.hors { fill: #C9CED4; }
.graphe .budget { stroke: var(--encre-2); stroke-dasharray: 4 3; stroke-width: 1.5; fill: none; }
.graphe .barre-budget { fill: none; stroke: var(--encre-2); stroke-width: 1.2; stroke-dasharray: 3 2; }
.graphe .barre-real { fill: var(--serie-2); }
.graphe .barre-real.depasse { fill: var(--accent); }
.graphe .libelle { fill: var(--encre-2); }
.graphe rect.cible:hover { fill-opacity: .85; }
.bulle { position: fixed; z-index: 50; pointer-events: none; background: var(--nuit); color: #fff; padding: 7px 10px; border-radius: 8px; font-size: 12px; line-height: 1.4; box-shadow: 0 6px 18px rgba(0,0,0,.2); }

/* ─── Tableau des lignes ─── */
.tableau-tete { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 8px; }
.tableau-tete h2 { margin: 0; }
.tableau-tete input { height: 34px; border: 1px solid var(--ligne); border-radius: 8px; padding: 0 10px; font: 14px var(--sans); min-width: 280px; }
.arbre { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.arbre th { position: sticky; top: 132px; background: var(--surface); z-index: 2; text-align: right; font-size: 11px; color: var(--encre-3); font-weight: 600; text-transform: uppercase; letter-spacing: .03em; padding: 8px 10px; border-bottom: 1px solid var(--ligne); white-space: nowrap; }
.arbre th:first-child { text-align: left; }
.arbre td { padding: 7px 10px; border-bottom: 1px solid var(--ligne-2); text-align: right; white-space: nowrap; }
.arbre td:first-child { text-align: left; white-space: normal; }
.arbre tr.groupe td { background: #FAFAF8; font-weight: 700; border-top: 1px solid var(--ligne); cursor: pointer; }
.arbre tr.groupe .sous { font-weight: 500; color: var(--encre-3); margin-left: 8px; font-size: 12px; }
.arbre tr.lb { cursor: pointer; }
.arbre tr.lb:hover td, .arbre tr.four:hover td { background: #FCFAFA; }
.arbre tr.lb td:first-child { padding-left: 28px; }
.arbre tr.four td:first-child { padding-left: 52px; }
.arbre tr.four td { color: var(--encre-2); background: #FDFDFC; cursor: pointer; }
.arbre tr.factures-l > td { padding: 0 10px 10px 52px; background: #FDFDFC; }
.code { font: 12px var(--mono); color: var(--encre-3); margin-right: 8px; }
.arbre .chevron { display: inline-block; width: 14px; color: var(--encre-3); transition: transform .15s; }
.arbre tr[aria-expanded="true"] .chevron { transform: rotate(90deg); }
.etiq { display: inline-block; font: 600 10px var(--sans); text-transform: uppercase; letter-spacing: .04em; padding: 2px 6px; border-radius: 5px; margin-left: 6px; vertical-align: 1px; }
.etiq-auto { background: var(--ligne-2); color: var(--encre-3); }
.etiq-amorce { background: #EEF1F5; color: #2F3E4E; }
.etiq-absent { background: var(--alerte-lavis); color: var(--alerte); }
.etiq-saisie { background: var(--ok-lavis); color: var(--ok); }
.n-vide { color: #B5B5B5; }
.reprevu-saisi { display: inline-flex; align-items: center; gap: 4px; }
.reprevu-saisi button { border: 0; background: none; padding: 2px 4px; cursor: pointer; color: var(--encre-3); border-radius: 5px; font: inherit; border-bottom: 1px dashed #BBB; }
.reprevu-saisi button:hover { color: var(--accent); border-color: var(--accent); }
.reprevu-saisi input { width: 110px; height: 28px; text-align: right; border: 1px solid var(--accent); border-radius: 6px; padding: 0 6px; font: 13px var(--sans); }
.conso { display: inline-block; width: 64px; height: 6px; background: var(--ligne-2); border-radius: 99px; vertical-align: middle; margin-left: 6px; overflow: hidden; }
.conso i { display: block; height: 100%; background: var(--encre-2); }
.conso.depasse i { background: var(--accent); }
.factures { width: 100%; border-collapse: collapse; font-size: 13px; }
.factures th { text-align: left; font-size: 11px; color: var(--encre-3); font-weight: 600; padding: 6px 8px; border-bottom: 1px solid var(--ligne); text-transform: uppercase; letter-spacing: .03em; }
.factures td { padding: 5px 8px; border-bottom: 1px solid var(--ligne-2); text-align: left; white-space: nowrap; }
.factures td.n, .factures th.n { text-align: right; }
.factures td.lib { white-space: normal; max-width: 420px; color: var(--encre-2); }
.source { font-size: 11px; color: var(--encre-3); }
.arbre .natures { display: block; margin-left: 22px; font-size: 11px; color: var(--encre-3); }
.plus-actions { display: flex; gap: 8px; padding: 8px 0 2px; }
.chargement, .vide { color: var(--encre-3); padding: 14px 4px; }

/* ─── Contrôles ─── */
.controles { display: grid; grid-template-columns: 1.3fr 1fr; gap: 24px; }
.controles h2 { grid-column: 1 / -1; margin-bottom: 0; }
.barres-sources { display: grid; gap: 6px; }
.barres-sources div { display: grid; grid-template-columns: 230px 1fr 110px; gap: 10px; align-items: center; font-size: 13px; }
.barres-sources .b { height: 8px; background: var(--ligne-2); border-radius: 99px; overflow: hidden; }
.barres-sources .b i { display: block; height: 100%; background: var(--serie-2); }
.aide { color: var(--encre-3); font-size: 13px; margin-bottom: 10px; max-width: 880px; }

/* ─── Dialogues ─── */
.dlg { border: 0; border-radius: 14px; padding: 0; width: min(640px, 94vw); box-shadow: 0 24px 70px rgba(0,0,0,.25); }
.dlg::backdrop { background: rgba(20,20,20,.45); }
.dlg-tete { display: flex; justify-content: space-between; align-items: start; gap: 12px; padding: 16px 20px; border-bottom: 1px solid var(--ligne); }
.dlg-tete h2 { font-size: 16px; }
.dlg-tete p { color: var(--encre-3); font-size: 13px; margin-top: 2px; }
.dlg-corps { padding: 16px 20px; display: grid; gap: 12px; }
.dlg-pied { padding: 12px 20px 16px; display: flex; justify-content: flex-end; gap: 8px; border-top: 1px solid var(--ligne); }
.dlg-pdf { width: min(1100px, 96vw); height: 92vh; }
.dlg-pdf[open] { display: flex; flex-direction: column; }
.dlg-pdf iframe { flex: 1; border: 0; width: 100%; background: #525659; }
.dlg label { display: grid; gap: 5px; font-size: 13px; font-weight: 600; }
.dlg input[type=text], .dlg input[type=search], .dlg input:not([type]), .dlg select, .dlg textarea { height: 38px; border: 1px solid var(--ligne); border-radius: 8px; padding: 0 10px; font: 14px var(--sans); }
.dlg textarea { height: 64px; padding: 8px 10px; }
.choix { display: grid; gap: 6px; }
.choix label { display: flex; gap: 10px; align-items: start; font-weight: 500; padding: 10px 12px; border: 1px solid var(--ligne); border-radius: 9px; cursor: pointer; }
.choix label:has(input:checked) { border-color: var(--encre); background: #FAFAF8; }
.choix small { display: block; }
.cibles { max-height: 230px; overflow: auto; border: 1px solid var(--ligne); border-radius: 9px; }
.cibles button { display: grid; grid-template-columns: 1fr auto; gap: 2px 10px; width: 100%; text-align: left; border: 0; border-bottom: 1px solid var(--ligne-2); background: var(--surface); padding: 8px 12px; cursor: pointer; font: 13px var(--sans); }
.cibles button:hover, .cibles button[aria-pressed="true"] { background: var(--accent-lavis); }
.cibles small { grid-column: 1 / -1; }
.avis { padding: 10px 12px; border-radius: 9px; font-size: 13px; }
.avis.ok { background: var(--ok-lavis); color: #24552F; }
.avis.compta { background: var(--alerte-lavis); color: var(--alerte); }
.toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); background: var(--nuit); color: #fff; padding: 10px 16px; border-radius: 10px; z-index: 60; font-size: 14px; box-shadow: 0 10px 30px rgba(0,0,0,.25); max-width: 90vw; }

/* ─── Pages simples, admin ─── */
.etat-page { background: var(--ok-lavis); color: #24552F; padding: 10px 14px; border-radius: 10px; margin-bottom: 14px; }
.etat-page.erreur { background: var(--accent-lavis); color: var(--accent-fonce); }
.message { padding-top: 60px; display: grid; gap: 14px; max-width: 640px; }
.sous-menu { display: flex; gap: 4px; margin-bottom: 16px; border-bottom: 1px solid var(--ligne); }
.sous-menu a { padding: 10px 14px; text-decoration: none; font-weight: 600; color: var(--encre-3); border-bottom: 2px solid transparent; margin-bottom: -1px; }
.sous-menu a[aria-current] { color: var(--encre); border-color: var(--accent); }
.grille-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grille-2 > .carte { margin-bottom: 0; }
.grille-2 { margin-bottom: 16px; }
.grille-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 24px; }
.table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.table th { text-align: left; font-size: 11px; color: var(--encre-3); font-weight: 600; padding: 8px; border-bottom: 1px solid var(--ligne); text-transform: uppercase; letter-spacing: .03em; }
.table td { padding: 8px; border-bottom: 1px solid var(--ligne-2); vertical-align: top; }
.table .n { text-align: right; white-space: nowrap; }
.table.compacte td, .table.compacte th { padding: 5px 8px; font-size: 13px; }
.table tr.total td { font-weight: 700; border-top: 1px solid var(--ligne); }
.table .actions { display: flex; gap: 6px; justify-content: flex-end; }
.chiffres { list-style: none; padding: 0; margin: 8px 0; display: grid; gap: 6px; }
.depot { display: flex; gap: 10px; align-items: center; margin: 10px 0 14px; flex-wrap: wrap; }
.parametres { display: grid; gap: 12px; }
.parametres .btn { justify-self: start; }
.interrupteur { display: flex; gap: 12px; align-items: start; padding: 12px; border: 1px solid var(--ligne); border-radius: 10px; }
.interrupteur input { width: 18px; height: 18px; margin-top: 2px; accent-color: var(--accent); }
.formulaire { display: grid; gap: 12px; align-content: start; }
.formulaire label { display: grid; gap: 5px; font-weight: 600; font-size: 13px; }
.formulaire input, .formulaire select, .formulaire textarea { height: 38px; border: 1px solid var(--ligne); border-radius: 8px; padding: 0 10px; font: 14px var(--sans); }
.formulaire textarea { height: auto; padding: 8px 10px; font-family: var(--mono); font-size: 13px; }
.boutons { display: flex; gap: 8px; }
.puces { list-style: none; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: 4px; }
.puce { background: var(--ok-lavis); color: #24552F; border-radius: 999px; padding: 2px 8px; font-size: 12px; }
.liste-codes { list-style: none; margin: 10px 0 0; padding: 0; max-height: 380px; overflow: auto; font-size: 13px; }
.liste-codes li { padding: 4px 0; border-bottom: 1px solid var(--ligne-2); }
.liste-mono { font: 12px var(--mono); max-height: 200px; overflow: auto; }
#filtre-codes { height: 36px; width: 100%; border: 1px solid var(--ligne); border-radius: 8px; padding: 0 10px; font: 14px var(--sans); }
.statut { display: inline-block; padding: 3px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.statut-appliquee { background: var(--ok-lavis); color: #24552F; }
.statut-a_valider { background: var(--alerte-lavis); color: var(--alerte); }
.statut-refusee { background: var(--ligne-2); color: var(--encre-3); }
.en-ligne { display: flex; gap: 6px; align-items: center; }
.en-ligne input { height: 30px; border: 1px solid var(--ligne); border-radius: 7px; padding: 0 8px; font: 13px var(--sans); }

/* ─── Connexion ─── */
.page-connexion { background: radial-gradient(1200px 600px at 80% -10%, #3A1212, transparent), var(--nuit); min-height: 100vh; }
.connexion { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.connexion-carte { background: var(--surface); border-radius: 18px; padding: 36px; width: min(440px, 100%); display: grid; gap: 14px; box-shadow: 0 30px 80px rgba(0,0,0,.4); }
.connexion-logo { height: 28px; justify-self: start; }
.connexion h1 { font-size: 30px; }
.connexion h1 b { color: var(--accent); }
.connexion-sous, .connexion-note, .connexion-poc { color: var(--encre-3); }
.connexion-poc { font-size: 12px; border-top: 1px solid var(--ligne); padding-top: 12px; }
.connexion-locale { display: grid; gap: 8px; }
.connexion-locale select { height: 40px; border: 1px solid var(--ligne); border-radius: 8px; padding: 0 8px; font: 14px var(--sans); }

@media (max-width: 1100px) {
  .kpi { grid-template-columns: repeat(2, 1fr); }
  .graphes, .controles, .grille-2, .grille-3 { grid-template-columns: 1fr; }
  .filtres { position: static; }
  .arbre th { top: 60px; }
}
@media print {
  .tete, .filtres, .tableau-tete input, .btn-icone, .bandeau-voir-comme { display: none !important; }
  body { background: #fff; }
  .carte, .tuile { break-inside: avoid; }
}
.etat-page.attente { background: var(--alerte-lavis); color: var(--alerte); }
.etat-page.attente[data-ecoule]::after { content: " · " attr(data-ecoule); font-family: var(--mono); }

/* Réalisé hors référentiel : rappelé dans la tuile, avec un lien pour l'afficher. */
.tuile .detail .bloc { display: block; margin-top: 2px; }
button.lien { background: none; border: 0; padding: 0; color: var(--accent); font: inherit; text-decoration: underline; cursor: pointer; }
.note-filtres { margin: -6px 0 14px; font-size: 12px; }
