/* Cartes, KPI, boutons, badges, barres, tableaux, formulaires */

.carte {
  background: var(--surface);
  border: 1px solid var(--bordure);
  border-radius: var(--rayon);
  box-shadow: var(--ombre);
  padding: 20px;
  min-width: 0;
}
.carte-titre { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 14px; }
.carte-titre h2 { font-size: 15px; }
.carte-titre .petit { color: var(--texte-doux); }

/* ---------- KPI ---------- */
.kpi { display: flex; flex-direction: column; gap: 4px; }
.kpi-libelle { font-size: 13px; color: var(--texte-doux); font-weight: 500; }
.kpi-valeur { font-size: 28px; font-weight: 700; letter-spacing: -.02em; line-height: 1.15; white-space: nowrap; }
.kpi-contexte { font-size: 13px; color: var(--texte-doux); }
.kpi-ok .kpi-valeur { color: var(--ok); }
.kpi-danger .kpi-valeur { color: var(--danger); }
@media (max-width: 1280px) { .kpi-valeur { font-size: 24px; } }

/* ---------- Boutons ---------- */
.bouton {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 14px; border-radius: 10px;
  border: 1px solid var(--bordure); background: var(--surface);
  font-weight: 500; font-size: 14px; cursor: pointer; white-space: nowrap;
}
.bouton:hover { background: var(--surface-2); }
.bouton svg { width: 16px; height: 16px; }
.bouton-principal { background: var(--accent); border-color: var(--accent); color: var(--sur-accent); }
.bouton-principal:hover { background: var(--accent-fort); }
.bouton-danger { color: var(--danger); }
.bouton-icone { padding: 8px; }
.bouton-lien { border: 0; background: none; padding: 0; color: var(--accent); cursor: pointer; font-weight: 500; }
@media (max-width: 640px) { .entete-actions .bouton span { display: none; } .entete-actions .bouton { padding: 8px 10px; } }

/* ---------- Badges ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 2px 9px; border-radius: 999px;
  font-size: 12px; font-weight: 600; white-space: nowrap;
  background: var(--neutre-doux); color: var(--texte-doux);
}
.badge-ok { background: var(--ok-doux); color: var(--ok); }
.badge-attention { background: var(--attention-doux); color: var(--attention); }
.badge-danger { background: var(--danger-doux); color: var(--danger); }
.badge-accent { background: var(--accent-doux); color: var(--accent-fort); }
.pastille { width: 10px; height: 10px; border-radius: 3px; flex: none; display: inline-block; }

/* ---------- Barres et jauges ---------- */
.jauge { display: flex; flex-direction: column; gap: 6px; }
.jauge-entete { display: flex; justify-content: space-between; gap: 8px; font-size: 13px; flex-wrap: wrap; }
.piste {
  display: flex; gap: 2px; height: 10px; border-radius: 999px;
  background: var(--barre-piste); overflow: hidden;
}
.piste-haute { height: 18px; border-radius: 6px; }
.segment { height: 100%; min-width: 0; }
.segment:first-child { border-radius: 999px 0 0 999px; }
.piste-haute .segment:first-child { border-radius: 6px 0 0 6px; }
.seg-paye { background: var(--barre-paye); }
.seg-engage { background: var(--barre-engage); }
.seg-depasse { background: var(--danger); }
.legende { display: flex; gap: 14px; flex-wrap: wrap; font-size: 13px; color: var(--texte-doux); }
.legende span { display: inline-flex; align-items: center; gap: 6px; }

/* Barres horizontales par catégorie */
.barres { display: flex; flex-direction: column; gap: 14px; }
.barre-ligne { display: grid; grid-template-columns: 150px minmax(0, 1fr) 120px; align-items: center; gap: 12px; }
.barre-nom { display: flex; align-items: center; gap: 8px; font-size: 14px; font-weight: 500; min-width: 0; }
.barre-nom span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.barre-valeur { text-align: right; font-size: 13px; }
.barre-zone { position: relative; height: 22px; cursor: default; }
.barre-zone .piste { position: absolute; inset: 6px 0; height: 10px; }
@media (max-width: 640px) {
  .barre-ligne { grid-template-columns: minmax(0, 1fr) auto; row-gap: 4px; }
  .barre-zone { grid-column: 1 / -1; grid-row: 2; }
}

/* Répartition (barre empilée unique) */
.repartition { display: flex; gap: 2px; height: 28px; border-radius: 8px; overflow: hidden; }
.repartition div { height: 100%; }

/* Infobulle */
.infobulle {
  position: fixed; z-index: 50; pointer-events: none;
  background: var(--surface); color: var(--texte);
  border: 1px solid var(--bordure); border-radius: 10px; box-shadow: var(--ombre-forte);
  padding: 10px 12px; font-size: 13px; max-width: 260px;
  opacity: 0; transition: opacity .1s;
}
.infobulle.visible { opacity: 1; }
.infobulle strong { display: block; margin-bottom: 4px; }
.infobulle-ligne { display: flex; justify-content: space-between; gap: 16px; }

/* ---------- Tableaux ---------- */
.tableau-conteneur { overflow-x: auto; margin: 0 -20px; padding: 0 20px; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th {
  text-align: left; font-weight: 600; font-size: 12px; color: var(--texte-doux);
  text-transform: uppercase; letter-spacing: .03em;
  padding: 8px 10px; border-bottom: 1px solid var(--bordure); white-space: nowrap;
  background: var(--surface); position: sticky; top: 0;
}
th.triable { cursor: pointer; user-select: none; }
th.triable:hover { color: var(--texte); }
td { padding: 10px; border-bottom: 1px solid var(--grille); vertical-align: middle; }
tbody td:first-child { min-width: 190px; }
tbody tr:hover { background: var(--surface-2); }
tr.cliquable { cursor: pointer; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
tfoot td { font-weight: 700; border-bottom: 0; border-top: 2px solid var(--bordure); }
.groupe-ligne td { background: var(--surface-2); font-weight: 600; cursor: pointer; }
.cellule-principale { font-weight: 500; }
.cellule-sous { font-size: 12px; color: var(--texte-doux); }
.vide { padding: 32px; text-align: center; color: var(--texte-doux); }

/* ---------- Filtres et formulaires ---------- */
.filtres { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.champ { display: flex; flex-direction: column; gap: 4px; font-size: 13px; font-weight: 500; }
.champ-ligne { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
input[type="text"], input[type="number"], input[type="date"], input[type="search"], select, textarea {
  padding: 8px 10px; border-radius: 10px; border: 1px solid var(--bordure);
  background: var(--surface); min-width: 0; width: 100%;
}
.filtres input, .filtres select { width: auto; }
.filtres input[type="search"] { flex: 1 1 200px; }
input.saisie-montant { width: 120px; text-align: right; }
input[type="checkbox"] { width: 18px; height: 18px; accent-color: var(--accent); }
@media (max-width: 640px) { .filtres select { flex: 1 1 45%; } }

/* ---------- Panneau latéral (formulaire) ---------- */
.voile { position: fixed; inset: 0; background: rgb(0 0 0 / .35); z-index: 40; }
.panneau {
  position: fixed; top: 0; right: 0; bottom: 0; width: min(440px, 100%); z-index: 41;
  background: var(--surface); box-shadow: var(--ombre-forte);
  display: flex; flex-direction: column;
}
.panneau-entete { display: flex; align-items: center; justify-content: space-between; padding: 18px 20px; border-bottom: 1px solid var(--bordure); }
.panneau-corps { padding: 20px; overflow-y: auto; display: flex; flex-direction: column; gap: 14px; flex: 1; }
.panneau-pied { padding: 14px 20px; border-top: 1px solid var(--bordure); display: flex; gap: 8px; justify-content: space-between; }

/* ---------- Alertes ---------- */
.alertes { display: flex; flex-direction: column; gap: 10px; }
.alerte { display: flex; gap: 10px; align-items: flex-start; font-size: 14px; }
.alerte svg { width: 18px; height: 18px; flex: none; margin-top: 2px; }
.alerte-danger svg { color: var(--danger); }
.alerte-attention svg { color: var(--attention); }
.alerte-info svg { color: var(--texte-doux); }

/* ---------- Divers ---------- */
.liste { display: flex; flex-direction: column; }
.liste-item { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--grille); }
.liste-item:last-child { border-bottom: 0; }
.onglets { display: inline-flex; gap: 4px; padding: 4px; background: var(--surface-2); border-radius: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.onglets button { border: 0; background: none; padding: 7px 14px; border-radius: 9px; cursor: pointer; font-weight: 500; color: var(--texte-doux); }
.onglets button[aria-selected="true"] { background: var(--surface); color: var(--texte); box-shadow: var(--ombre); }
.bandeau { padding: 16px 20px; border-radius: var(--rayon); background: var(--accent-doux); color: var(--accent-fort); font-weight: 600; display: flex; align-items: center; gap: 10px; }
.bandeau svg { width: 22px; height: 22px; flex: none; }
.bandeau-attention { background: var(--attention-doux); color: var(--attention); }
.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 60;
  background: var(--texte); color: var(--fond); padding: 10px 16px; border-radius: 10px; font-size: 14px;
  box-shadow: var(--ombre-forte);
}
@media (max-width: 640px) { .toast { bottom: 88px; } }
.offre-retenue { font-weight: 600; }
.personne { display: flex; flex-direction: column; gap: 10px; }
