/* Onglet « Contrôle de gestion ». Couleurs : uniquement les variables d'app.css (modes sombre et clair). */

/* Synthèse : quatre indicateurs phares, le premier plus large. */
.g-phares { display: grid; grid-template-columns: 1.45fr 1fr 1fr 1fr; gap: 14px; }
.g-phare { position: relative; display: grid; gap: 8px; align-content: start; padding: 18px 20px 18px 22px; border-radius: var(--rayon); background-color: var(--carte); border: 1px solid var(--carte-bord); box-shadow: var(--carte-ombre); min-width: 0; overflow: hidden; }
.g-phare::before { content: ""; position: absolute; inset: 0 auto 0 0; width: 4px; background: var(--filet-fort); }
.g-phare.ok::before { background: var(--vert); }
.g-phare.attention::before { background: var(--orange); }
.g-phare.alerte::before { background: var(--rouge); }
.g-phare.principal { background-image: linear-gradient(135deg, var(--ambre-teinte), transparent 60%); }
.g-phare-tete { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 6px 10px; }
.g-etiquette { color: var(--texte-2); font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; }
.g-chiffre { font-family: var(--titre); font-size: clamp(24px, 2.5vw, 34px); line-height: 1.08; font-weight: 700; letter-spacing: -0.03em; font-variant-numeric: tabular-nums; white-space: nowrap; }
.g-phare.principal .g-chiffre { font-size: clamp(34px, 4.4vw, 54px); }
.g-chiffre.absent { font-size: 19px; letter-spacing: -0.01em; color: var(--texte-2); font-weight: 600; }
.g-phare.vide-g { background-image: none; box-shadow: none; border-style: dashed; border-color: var(--filet-fort); }
.g-lecture { color: var(--texte); font-size: 13.5px; line-height: 1.5; text-wrap: pretty; max-width: 62ch; }
.g-phare .g-lecture { color: var(--texte-2); }
.g-tendance { display: inline-flex; align-items: center; gap: 5px; justify-self: start; padding: 2px 9px; border-radius: 999px; background: var(--gris-teinte); color: var(--texte-2); font-size: 12px; font-weight: 600; white-space: nowrap; }

/* Sections */
.g-section { display: grid; gap: 14px; padding-top: 10px; }
.g-section-tete { display: flex; align-items: center; gap: 14px; padding-bottom: 2px; }
.g-no { flex: none; width: 34px; height: 34px; display: grid; place-items: center; border-radius: 50%; border: 1px solid var(--filet-fort); color: var(--ambre); font-family: var(--titre); font-weight: 700; font-size: 16px; }
.g-section-tete h2 { font-size: 21px; line-height: 1.2; letter-spacing: -0.02em; }
.g-section-tete p { color: var(--texte-2); font-size: 14px; margin-top: 2px; }
.g-duo { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; align-items: start; }
.g-figure { display: grid; gap: 10px; align-content: start; }
.g-titre-fig { font-family: var(--titre); font-size: 15px; font-weight: 600; letter-spacing: -0.01em; margin-bottom: 4px; }
.g-attente { border-style: dashed; border-color: var(--filet-fort); box-shadow: none; background-image: none; color: var(--texte-2); justify-items: start; }
.g-decompte { color: var(--texte-2); font-size: 13px; }
.g-decompte b { color: var(--texte); font-family: var(--mono); font-weight: 400; }
.g-sous { display: block; color: var(--texte-3); font-size: 12px; }

/* Indicateurs : un registre de lignes, pas une grille de cartes. */
.g-lignes { padding: 4px 20px; }
.g-ind { display: grid; grid-template-columns: minmax(0, 1fr) minmax(190px, 300px); gap: 8px 28px; align-items: start; padding: 16px 0; border-bottom: 1px solid var(--filet); }
.g-ind:last-child { border-bottom: 0; }
.g-ind-texte { display: grid; gap: 6px; min-width: 0; }
.g-ind h3 { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; font-size: 14.5px; font-weight: 600; }
.g-detail { color: var(--texte-2); font-size: 12.5px; line-height: 1.45; }
.g-ind-valeur { display: grid; gap: 7px; justify-items: end; text-align: right; }
.g-val { font-family: var(--mono); font-size: 21px; line-height: 1.15; font-weight: 700; letter-spacing: -0.03em; font-variant-numeric: tabular-nums; }
.g-ind.alerte .g-val { color: var(--rouge); }
.g-ind.attention .g-val { color: var(--orange); }
.g-ind-valeur .g-tendance { justify-self: end; white-space: normal; text-align: right; }

/* Détails repliables */
.g-plus > summary, .g-saisies > summary { cursor: pointer; list-style: none; }
.g-plus > summary::-webkit-details-marker, .g-saisies > summary::-webkit-details-marker { display: none; }
.g-plus > summary { display: inline-flex; align-items: center; gap: 7px; min-height: 28px; color: var(--ambre); font-size: 13px; font-weight: 500; border-radius: 6px; }
.g-plus > summary::before { content: ""; width: 7px; height: 7px; border-right: 2px solid currentColor; border-bottom: 2px solid currentColor; transform: rotate(-45deg); }
.g-plus[open] > summary::before { transform: rotate(45deg); }
.g-plus > p, .g-plus > ul { margin-top: 8px; color: var(--texte-2); font-size: 13px; line-height: 1.55; max-width: 78ch; }
.g-plus b { color: var(--texte); font-weight: 600; }
.g-plus.large { padding: 4px 0; }
.g-adresse { font-family: var(--mono); font-size: 11.5px; color: var(--texte-3); overflow-wrap: anywhere; }
.g-sources ul { padding-left: 18px; display: grid; gap: 8px; }
.g-sources li .g-adresse { display: block; }

/* Indicateurs en attente d'une saisie : discrets. */
.g-manques { padding: 12px 18px; border-radius: 12px; border: 1px dashed var(--filet-fort); color: var(--texte-2); font-size: 13px; }
.g-manques-tete { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; font-weight: 600; }
.g-manques ul { list-style: none; margin: 8px 0 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 8px 24px; }
.g-manques li { display: grid; gap: 1px; }
.g-manques li b { color: var(--texte); font-weight: 500; }

/* Graphiques */
.g-bullet { width: 100%; max-width: 280px; height: auto; display: block; }
.g-bullet .b-fond { fill: var(--gris-teinte); }
.g-bullet .b-zone { fill: var(--vert-teinte); stroke: var(--vert); stroke-width: 1; }
.g-bullet .b-valeur { fill: var(--ambre); }
.g-bullet .b-cible { fill: var(--texte); }
.g-cascade, .g-pareto, .g-courbe { width: 100%; height: auto; display: block; }
.g-cascade text, .g-pareto text, .g-courbe text { fill: var(--texte-2); font-size: 12px; font-family: var(--sans); }
.g-cascade .c-nom { fill: var(--texte); font-size: 13px; font-weight: 500; }
.g-cascade .c-montant { fill: var(--texte); font-family: var(--mono); font-size: 12.5px; }
.g-cascade .c-ca { fill: var(--bleu); }
.g-cascade .c-cout { fill: var(--filet-fort); }
.g-cascade .c-marge { fill: var(--vert); }
.g-cascade .c-fil { stroke: var(--filet-fort); stroke-dasharray: 3 3; }
.g-pareto .p-A { fill: var(--ambre); }
.g-pareto .p-B { fill: var(--bleu); }
.g-pareto .p-C { fill: var(--filet-fort); }
.g-pareto .p-axe { stroke: var(--filet-fort); }
.g-pareto .p-seuil { stroke: var(--filet-fort); stroke-dasharray: 4 4; }
.g-pareto .p-part { font-family: var(--mono); font-size: 11px; fill: var(--texte-3); }
.g-pareto .p-cumul { fill: none; stroke: var(--texte); stroke-width: 2; stroke-linejoin: round; }
.g-pareto .p-point { fill: var(--texte); }
.g-courbe .k-axe { stroke: var(--filet-fort); }
.g-courbe .k-budget { stroke: var(--texte-2); stroke-width: 1.5; }
.g-courbe .k-reel { fill: none; stroke: var(--ambre); stroke-width: 3; stroke-linejoin: round; stroke-linecap: round; }
.g-courbe .k-proj { stroke: var(--ambre); stroke-width: 2.5; stroke-dasharray: 3 7; stroke-linecap: round; }
.g-courbe .k-point { fill: var(--ambre); }
.g-courbe .k-point-proj { fill: var(--fond); stroke: var(--ambre); stroke-width: 2; }
.g-courbe .k-t-reel, .g-courbe .k-t-proj { fill: var(--ambre); font-family: var(--mono); font-size: 11.5px; font-weight: 700; }
.g-courbe .k-t-budget { fill: var(--texte-2); font-family: var(--mono); font-size: 11.5px; }
.legende .l-A { background: var(--ambre); } .legende .l-B { background: var(--bleu); } .legende .l-C { background: var(--filet-fort); }
.legende .l-cumul, .legende .l-budget { height: 2px; width: 16px; border-radius: 1px; background: var(--texte-2); }
.legende .l-reel { height: 3px; width: 16px; border-radius: 2px; background: var(--ambre); }
.legende .l-proj { height: 0; width: 16px; border-top: 3px dotted var(--ambre); border-radius: 0; }

/* Échéancier en barres par tranche */
.g-tranches { display: grid; gap: 9px; }
.g-tranche { display: grid; grid-template-columns: 132px minmax(40px, 1fr) auto; grid-template-areas: "nom barre montant" "nom barre nb"; column-gap: 12px; align-items: center; }
.g-tr-nom { grid-area: nom; color: var(--texte-2); font-size: 13px; }
.g-tr-barre { grid-area: barre; height: 12px; border-radius: 6px; background: var(--gris-teinte); overflow: hidden; }
.g-tr-barre i { display: block; height: 100%; border-radius: 6px; background: var(--bleu); transform-origin: left; }
.g-tranche strong { grid-area: montant; text-align: right; font-size: 14px; }
.g-tr-nb { grid-area: nb; text-align: right; color: var(--texte-3); font-size: 11.5px; }
.g-tranche.echu .g-tr-barre i { background: var(--rouge); }
.g-tranche.echu strong, .g-tranche.echu .g-tr-nom { color: var(--rouge); }

/* Saisies du mois */
.g-saisies > summary { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; min-height: 36px; }
.g-saisies > summary > span:first-child { display: grid; gap: 2px; }
.g-saisies > summary strong { font-family: var(--titre); font-size: 18px; font-weight: 600; letter-spacing: -0.01em; }
.g-saisies[open] > summary { margin-bottom: 14px; }
.g-table-saisies th[scope="row"] { text-transform: none; letter-spacing: 0; font-size: 13.5px; color: var(--texte); white-space: normal; min-width: 240px; }
.g-table-saisies th[scope="row"] span { display: block; }
.g-table-saisies small { color: var(--texte-3); font-weight: 400; }
.g-debloque { color: var(--texte-3); font-size: 12px; font-weight: 400; }
.g-table-saisies td { min-width: 132px; }
.g-groupe th { padding-top: 16px; color: var(--ambre); border-bottom-color: var(--filet-fort); }

@media (max-width: 1180px) {
  .g-phares { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .g-phare.principal { grid-column: 1 / -1; }
  .g-duo { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 760px) {
  .g-phares { grid-template-columns: minmax(0, 1fr); }
  .g-ind { grid-template-columns: minmax(0, 1fr); }
  .g-ind-valeur { justify-items: start; text-align: left; order: -1; }
  .g-ind-valeur .g-tendance { justify-self: start; text-align: left; }
  .g-lignes { padding-inline: 14px; }
}
/* Mouvement : transform et opacité seulement, court, coupé si l'appareil demande moins d'animations. */
@media (prefers-reduced-motion: no-preference) {
  @keyframes g-entree { from { opacity: 0; transform: translateY(10px); } }
  @keyframes g-pousse { from { transform: scaleX(0); } }
  .contenu.arrive .g-phare { animation: g-entree 380ms cubic-bezier(0.22, 1, 0.36, 1) both; }
  .contenu.arrive .g-phare:nth-child(2) { animation-delay: 50ms; }
  .contenu.arrive .g-phare:nth-child(3) { animation-delay: 100ms; }
  .contenu.arrive .g-phare:nth-child(4) { animation-delay: 150ms; }
  .contenu.arrive .g-tr-barre i { animation: g-pousse 520ms cubic-bezier(0.22, 1, 0.36, 1) both; }
  .g-plus > summary, .g-plus > summary::before { transition: transform 140ms ease-out, opacity 140ms ease-out; }
  .g-plus > summary:active, .g-saisies > summary:active .btn { transform: scale(0.97); }
}

/* Tableau des prix d'achat : il tient dans la demi-largeur, sans défilement horizontal. */
.g-prix { width: 100%; table-layout: auto; }
.g-prix td, .g-prix th { padding-left: 8px; padding-right: 8px; }
.g-prix td.num { white-space: nowrap; }
