/* ==========================================================================
   Cantine Scolaire V5.0 — Pilotage Financier & Budgétaire (couts.css)
   Grille de calculs, bascule portion/global, effectifs et badges plafond.
   ========================================================================== */

/* Tableau financier */
table.couts {
  width: 100%;
  border-collapse: collapse;
  background-color: var(--carte);
  border: 1px solid var(--bord);
  border-radius: var(--rayon-md);
  box-shadow: var(--ombre-sm);
  table-layout: fixed;
  font-size: 0.9rem;
}

table.couts th,
table.couts td {
  padding: 0.55rem 0.75rem;
  border: 1px solid var(--bord);
  vertical-align: middle;
}

table.couts th {
  background-color: #FAF9F5;
  font-weight: 600;
  text-align: center;
}

/* Cellules calculées en lecture seule */
td.calculee {
  font-weight: 600;
  text-align: right;
  font-variant-numeric: tabular-nums;
  background-color: #FBFBF9;
  color: var(--encre);
}

/* Commutateur de mode de coût (Portion €/convive vs Global € total) */
.mode-cout-toggle {
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--bord);
  border-radius: var(--rayon-sm);
  background-color: #EFECE3;
  padding: 2px;
  cursor: pointer;
  user-select: none;
  font-size: 0.75rem;
}

.mode-cout-toggle span {
  padding: 0.2rem 0.45rem;
  border-radius: 2px;
  color: var(--encre-doux);
  transition: all var(--transition-rapide);
}

.mode-cout-toggle.mode-portion .btn-portion,
.mode-cout-toggle.mode-global .btn-global,
.mode-cout-toggle .actif {
  background-color: var(--carte);
  color: var(--focus);
  font-weight: 700;
  box-shadow: var(--ombre-sm);
}

/* Section de ventilation des effectifs */
.section-effectifs {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 1.5rem;
  margin-bottom: 1rem;
  padding: 0.75rem 1.25rem;
  background-color: var(--carte);
  border: 1px solid var(--bord);
  border-radius: var(--rayon-md);
  box-shadow: var(--ombre-sm);
}

.groupe-effectif {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.9rem;
  font-weight: 500;
}

.input-effectif {
  width: 75px;
  text-align: right;
  font-weight: 600;
  padding: 0.35rem 0.5rem;
}

/* Badges indicateurs du budget et plafond cible */
.badge-budget {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.35rem 0.75rem;
  border-radius: var(--rayon-pill);
  font-size: 0.85rem;
  font-weight: 700;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

/* Conforme : en dessous ou égal au budget cible (Vert) */
.budget-conforme,
.badge-budget.budget-conforme {
  background-color: var(--bio-fond);
  color: var(--budget-conforme);
  border: 1px solid var(--budget-conforme);
}

/* Alerte : dépassement léger < 10% (Orange) */
.budget-alerte,
.badge-budget.budget-alerte {
  background-color: #FFF3E0;
  color: var(--budget-alerte);
  border: 1px solid var(--budget-alerte);
}

/* Dépassé : dépassement important >= 10% (Rouge) */
.budget-depasse,
.badge-budget.budget-depasse {
  background-color: #FFEBEE;
  color: var(--budget-depasse);
  border: 1px solid var(--budget-depasse);
}

/* Lignes de récapitulation et totaux */
tr.ligne-total {
  font-weight: 700;
  background-color: #F5F3EC;
  border-top: 2px solid var(--bord);
}

tr.ligne-total td {
  padding: 0.75rem;
}

tr.ligne-moyenne {
  font-weight: 600;
  background-color: #FAFAF7;
}

/* Correctifs de chevauchement : résumé hebdomadaire, cellules et champs de saisie */
.resume-budget-semaine {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem 2rem;
  margin-bottom: 1rem;
  padding: 0.75rem 1.25rem;
  background-color: var(--carte);
  border: 1px solid var(--bord);
  border-radius: var(--rayon-md);
  box-shadow: var(--ombre-sm);
}

.stat-budget {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.stat-libelle {
  color: var(--encre-doux);
  font-size: 0.85rem;
}

.stat-valeur {
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

table.couts th.col-angle {
  width: 150px;
}

table.couts td {
  overflow: hidden;
}

table.couts input {
  width: 100%;
  min-width: 0;
  max-width: 100%;
}

.controle-cout,
.groupe-supplement {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.3rem;
}

.rappel-plat {
  font-size: 0.8rem;
  margin-bottom: 0.3rem;
  overflow-wrap: anywhere;
}

.cout-converti {
  font-size: 0.75rem;
  color: var(--encre-doux);
  margin-top: 0.2rem;
}

table.couts td.calculee {
  white-space: normal;
}

.badge-cl,
.badge-ferie {
  display: inline-block;
  font-size: 0.75rem;
  font-weight: 600;
}

.couts-defilement {
  max-width: 100%;
  overflow-x: auto;
}

.mode-cout-toggle {
  flex-wrap: wrap;
  max-width: 100%;
}
