/* ══════════════════════════════════════════════════════════════════════════
   Budget — surcouche applicative sur design-kit.
   Ne jamais restyler les primitives du kit : uniquement des classes métier
   (grille salaires) + le CSS des composants notification-kit (convention de
   la suite : il vit dans l'app, pas dans le kit).
   ══════════════════════════════════════════════════════════════════════════ */

/* ── Grille salaires ─────────────────────────────────────────────────────── */
/* Pas de fenêtre à hauteur fixe : la table occupe toute la page et se
   parcourt avec le défilement de la page. L'en-tête des mois s'épingle
   sous la topbar, la ligne de totaux au bas de la fenêtre. */
.grille-container {
  border: 1px solid var(--line);
  border-radius: var(--r1);
  background: var(--surface);
}

.grille-salaires {
  border-collapse: separate;
  border-spacing: 0;
  min-width: 1420px;
}

/* Coûts ateliers : même pattern pleine page que la grille salaires — la table
   défile avec la page et les lignes GLISSENT SOUS l'en-tête épinglé. */
.grille-couts {
  border-collapse: separate;
  border-spacing: 0;
}
.grille-couts thead th {
  position: sticky;
  top: var(--topbar-h);
  z-index: 3;
  background: var(--surface);
  border-bottom: 1px solid var(--line-strong);
  white-space: nowrap;
}

.grille-salaires thead th {
  position: sticky;
  top: var(--topbar-h); /* épinglé au défilement de la page, sous la topbar fixe */
  z-index: 3;
  background: var(--surface);
  border-bottom: 1px solid var(--line-strong);
  white-space: nowrap;
}

.grille-salaires .cell-nom {
  position: sticky;
  left: 0;
  z-index: 2;
  background: var(--surface);
  min-width: 220px;
  max-width: 260px;
  border-right: 1px solid var(--line-strong);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.grille-salaires thead .cell-nom {
  z-index: 4;
}

.grille-salaires .cell-fonction {
  min-width: 120px;
  white-space: nowrap;
}

.grille-salaires .cell-mois {
  min-width: 84px;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

/* position: relative réservé au corps — surcharger le sticky des th
   de l'en-tête casserait l'épinglage vertical */
.grille-salaires tbody .cell-mois {
  position: relative;
  user-select: none; /* évite la sélection de texte au double-clic (édition rapide) */
}

/* ── Édition rapide (popover au double-clic) ─────────────────────────────── */
.edition-rapide__backdrop {
  position: fixed;
  inset: 0;
  z-index: 299;
}

.edition-rapide {
  position: fixed;
  z-index: 300;
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: var(--r1);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18);
  padding: var(--s12) var(--s16);
  /* Filet : un popover plus haut que la fenêtre défile au lieu de pousser ses
     boutons et ses avertissements de portée sous le pli */
  max-height: calc(100vh - 16px);
  overflow-y: auto;
}

[data-theme="dark"] .edition-rapide {
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.55);
}

.edition-rapide__titre {
  font-size: var(--t-11);
  font-weight: 600;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: var(--s8);
}

.edition-rapide__portee {
  display: flex;
  flex-direction: column;
  gap: var(--s4);
}

.edition-rapide__radio {
  display: flex;
  align-items: center;
  gap: var(--s8);
  font-size: var(--t-12);
  color: var(--ink-2);
  cursor: pointer;
}

.edition-rapide__radio input[type="radio"] {
  accent-color: var(--accent);
  margin: 0;
}

/* Ce que la portée va remplacer (projections ultérieures) ou épargner */
.edition-rapide__impact {
  font-size: var(--t-11);
  line-height: 1.5;
}

.edition-rapide__impact-warn {
  color: var(--warn);
}

.edition-rapide__fiche {
  background: none;
  border: none;
  padding: 0;
  font-size: var(--t-11);
  color: var(--ink-3);
  cursor: pointer;
  white-space: nowrap;
}

.edition-rapide__fiche:hover {
  color: var(--accent);
  text-decoration: underline;
}

.grille-salaires .cell-total {
  min-width: 96px;
  text-align: right;
  font-weight: 600;
  border-left: 1px solid var(--line-strong);
  font-variant-numeric: tabular-nums;
}

.cell-principal {
  display: block;
  font-size: var(--t-12);
  color: var(--ink-1);
}

.cell-secondaire {
  display: block;
  font-size: var(--t-10);
  color: var(--ink-3);
  white-space: nowrap;
}

/* Passé / mois courant / futur */
.grille-salaires td.col-passe,
.grille-salaires th.col-passe {
  background: var(--bg-inset);
}
.grille-salaires td.col-passe .cell-principal {
  color: var(--ink-2);
}
.grille-salaires td.col-courant,
.grille-salaires th.col-courant {
  background: var(--accent-dim);
}
.grille-salaires th.col-courant {
  color: var(--accent);
  border-bottom: 2px solid var(--accent);
}
.marqueur-courant {
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: var(--r-full);
  background: var(--accent);
  margin-left: 4px;
  vertical-align: middle;
}

/* Valeurs projetées (scénario) */
.cell-projete .cell-principal,
span.cell-projete {
  font-style: italic;
  color: var(--warn);
}

.cell-vide .cell-principal {
  color: var(--ink-3);
}

/* Mois futur dont la valeur n'est qu'un report de la dernière valeur en
   vigueur : c'est une prévision mécanique, pas une décision prise ce mois-là.
   Marqué discrètement pour qu'on ne la lise pas comme un chiffre arrêté. */
.cell-report .cell-principal {
  color: var(--ink-2);
  border-bottom: 1px dotted var(--ink-3);
}

/* Cellules dérivées d'une convention (Contrats) — non éditables ici */
.cell-derive {
  background-image: repeating-linear-gradient(
    -45deg,
    transparent,
    transparent 5px,
    color-mix(in srgb, var(--ink-3) 7%, transparent) 5px,
    color-mix(in srgb, var(--ink-3) 7%, transparent) 6px
  );
  cursor: help;
}

/* Point marquant un changement prenant effet ce mois-là */
.cell-flag {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 6px;
  height: 6px;
  border-radius: var(--r-full);
}
.cell-flag--definitif { background: var(--accent); }
.cell-flag--projete { background: var(--warn); }
.cell-flag--demo {
  position: static;
  display: inline-block;
  margin: 0 2px;
}

/* Lignes */
.ligne-employe .nom-employe {
  cursor: pointer;
  font-weight: 500;
}
.ligne-employe .nom-employe:hover {
  color: var(--accent);
}
.ligne-employe:hover td {
  background-color: color-mix(in srgb, var(--accent) 5%, transparent);
}

.btn-deplier {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--ink-3);
  font-size: var(--t-11);
  padding: 0 6px 0 0;
}
.btn-deplier:hover { color: var(--ink-1); }

.icon-repartition {
  color: var(--accent);
  margin-left: 6px;
  vertical-align: middle;
}

.sous-ligne td {
  background: var(--bg);
  border-bottom: 1px dashed var(--line);
}
.sous-ligne .sous-ligne-label {
  padding-left: 28px;
  font-size: var(--t-11);
  color: var(--ink-2);
}
.sous-ligne-ecart td {
  background: var(--err-dim);
}

/* Ligne de totaux (pied collant) */
.grille-salaires tfoot td {
  position: sticky;
  bottom: 0;
  background: var(--surface);
  border-top: 2px solid var(--line-strong);
  font-weight: 600;
  z-index: 2;
}
.grille-salaires tfoot .cell-nom { z-index: 3; }

/* Formulaire « modifier dès… » dans le modal */
.formulaire-changement {
  border: 1.5px solid var(--accent);
  border-radius: var(--r1);
  padding: var(--s12) var(--s16);
  background: var(--surface);
}
.formulaire-changement__titre {
  font-size: var(--t-10);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--accent);
  margin-bottom: var(--s8);
}

/* ── Grille revenus ──────────────────────────────────────────────────────── */
/* Ligne d'en-tête de groupe (DIRIS, OAI…) avec sous-totaux en petit */
.ligne-groupe td {
  background: var(--bg-inset);
  border-bottom: 1px solid var(--line-strong);
  font-size: var(--t-11);
  font-weight: 600;
  color: var(--ink-2);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.ligne-groupe .cell-secondaire {
  font-weight: 500;
  letter-spacing: 0;
  text-transform: none;
}

/* Cartes de risque de rétrocession DGCS */
.retro-row {
  display: flex;
  flex-direction: column;
  gap: var(--s8);
}
.retro-card {
  border: 1px solid var(--line);
  border-left-width: 3px;
  border-radius: var(--r1);
  background: var(--surface);
}
.retro-card--ok { border-left-color: var(--ok); }
.retro-card--risque { border-left-color: var(--err); }
.retro-card--inconnu { border-left-color: var(--line-strong); }
.retro-card__entete {
  display: flex;
  align-items: center;
  gap: var(--s8);
  padding: var(--s8) var(--s12);
  cursor: pointer;
  font-size: var(--t-13);
}
.retro-card__entete:hover { background: var(--bg); }
.retro-card__detail {
  padding: var(--s8) var(--s16) var(--s12) var(--s32);
  border-top: 1px dashed var(--line);
  display: flex;
  flex-direction: column;
  gap: var(--s8);
}

/* ── Compléments partagés (mêmes classes que References/PMO) ─────────────── */
.badge-sm {
  font-size: var(--t-11);
  padding: 2px 6px;
}

.stat-pill {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  font-size: var(--t-11);
  font-weight: 600;
  color: var(--ink-2);
  background: var(--surface);
  border: 1.5px solid var(--line-strong);
  border-radius: var(--r2);
  white-space: nowrap;
}

.sort-select {
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  font-family: var(--font);
  font-size: var(--t-11);
  font-weight: 500;
  color: var(--ink-1);
  background-color: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r1);
  padding: 4px 24px 4px 8px;
  cursor: pointer;
  outline: none;
  min-width: 80px;
  line-height: 1.4;
  background-image: url("data:image/svg+xml,%3Csvg width='8' height='5' viewBox='0 0 8 5' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1L4 4L7 1' stroke='%239a9a96' stroke-width='1.5' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
  transition: border-color var(--dt-fast);
}
.sort-select:focus { border-color: var(--accent); }
.sort-select:hover { border-color: var(--line-strong); }

/* ── KPI Row ─────────────────────────────────────────────────────────────── */
.kpi-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  border: 1px solid var(--line);
  border-radius: var(--r1);
  background: var(--surface);
}
.kpi-card {
  padding: var(--s12) var(--s16);
  display: flex;
  flex-direction: column;
  gap: var(--s4);
  border-right: 1px solid var(--line);
  transition: background-color var(--dt-fast) var(--ease);
}
.kpi-card:last-child { border-right: none; }
.kpi-card:hover { background-color: var(--bg); }
.kpi-card--expanded { background-color: var(--accent-dim); }
.kpi-card__label {
  font-size: var(--t-10);
  font-weight: 600;
  color: var(--ink-3);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  display: flex;
  align-items: center;
  gap: var(--s4);
}
.kpi-card__value {
  font-size: var(--t-20);
  font-weight: 700;
  color: var(--ink-1);
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}
.kpi-card__suffix {
  font-size: var(--t-13);
  color: var(--ink-3);
  font-weight: 400;
  margin-left: var(--s8);
}

@media (max-width: 900px) {
  .kpi-row { grid-template-columns: repeat(2, 1fr); }
}

/* ── Bannière d'impersonation ────────────────────────────────────────────── */
.impersonation-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s12);
  padding: var(--s8) var(--s16);
  background: var(--warn-dim);
  border: 1px solid var(--warn);
  border-radius: var(--r1);
  margin-bottom: var(--s16);
  font-size: var(--t-13);
}

/* ── Cloche de notifications (notification-kit) ──────────────────────────── */
.notification-bell {
  position: relative;
}
.notification-bell-btn {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  color: var(--ink-2);
  cursor: pointer;
  padding: 4px;
  border-radius: var(--r1);
  transition: color 0.15s;
}
.notification-bell-btn:hover {
  color: var(--ink-1);
  background: var(--bg-inset);
}
.notification-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  border-radius: 999px;
  background: var(--err);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  line-height: 16px;
  text-align: center;
}
.notification-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  width: 360px;
  max-height: 480px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r1);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
  z-index: 200;
  display: flex;
  flex-direction: column;
}
[data-theme="dark"] .notification-dropdown {
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
}
.notification-dropdown-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--s12) var(--s16);
  border-bottom: 1px solid var(--line);
}
.notification-dropdown-title {
  font-weight: 600;
  font-size: var(--t-13);
  color: var(--ink-1);
}
.notification-dropdown-list {
  overflow-y: auto;
  flex: 1;
}
.notification-empty {
  padding: var(--s32) var(--s16);
  text-align: center;
  color: var(--ink-3);
  font-size: var(--t-13);
}
.notification-item {
  padding: var(--s12) var(--s16);
  border-bottom: 1px solid var(--line);
  cursor: pointer;
  transition: background 0.1s;
}
.notification-item:last-child { border-bottom: none; }
.notification-item:hover { background: var(--bg-inset); }
.notification-item--unread { background: var(--accent-dim); }
.notification-item--unread:hover {
  background: color-mix(in srgb, var(--accent) 16%, var(--surface));
}
.notification-item-title {
  font-weight: 600;
  font-size: var(--t-13);
  color: var(--ink-1);
  margin-bottom: 2px;
}
.notification-item-body {
  font-size: var(--t-12);
  color: var(--ink-2);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.notification-item-time {
  font-size: var(--t-11);
  color: var(--ink-3);
  margin-top: 4px;
}

