/* =====================================================================================
   RH-1 — TRÉSORERIE DU PERSONNEL.

   ⚠️⚠️ TOUS les sélecteurs sont préfixés « rh- » et AUCUN conteneur partagé n'est stylé.
   La leçon T-UI est fraîche : styler `.btn-filtres` puis `.crud-toolbar-actions` a cassé DEUX
   FOIS des écrans que la tranche ne touchait pas (le bouton « Filtres » de toutes les listes,
   puis l'écran Commissions dont les champs de date se sont recouverts). Un sélecteur partagé
   couple autant qu'un composant partagé.

   ⚠️ `thead { top: 0 }` et JAMAIS 64px : les tables de la fiche vivent dans un conteneur à
   défilement propre, où `position: sticky` se cale sur LUI. Un `top: 64px` y poserait l'en-tête
   64 px sous le haut du tableau, EN PERMANENCE par-dessus la première ligne — c'est le défaut
   qui a masqué une ligne sur deux des états par commercial (retour terrain n°1).
   ===================================================================================== */

.rh-page {
    max-width: 1280px;
    margin: 0 auto;
}

.rh-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
    margin-bottom: 18px;
}

.rh-title {
    font-family: 'Sora', system-ui, sans-serif;
    font-size: 28px;
    font-weight: 700;
    color: var(--ink);
    margin: 2px 0 4px;
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.rh-head-actions {
    display: flex;
    gap: 8px;
    align-items: center;
}

/* ---- Badge « Sans charges » : DISCRET, gris neutre, jamais une alerte -------------
   Ne pas déclarer de charges sociales est le cas MAJORITAIRE du marché cible : le badge
   informe, il ne signale pas une anomalie. Et il n'a pas de pendant « Avec charges » —
   l'autre cas se lit à la fiche. */
.rh-badge-charges {
    display: inline-block;
    font-size: 10.5px;
    font-weight: 600;
    letter-spacing: .04em;
    text-transform: uppercase;
    color: var(--slate);
    background: var(--paper);
    border: 1px solid var(--line);
    border-radius: 999px;
    padding: 2px 8px;
    vertical-align: middle;
    margin-left: 6px;
}

.rh-cin {
    font-size: 11.5px;
    color: var(--slate);
    margin-left: 8px;
}

.rh-lien {
    color: var(--ink);
    font-weight: 600;
    text-decoration: none;
}

.rh-lien:hover {
    color: var(--teal-dark);
    text-decoration: underline;
}

/* ---- Mode de rémunération ---- */
.rh-mode {
    display: inline-block;
    font-size: 10.5px;
    font-weight: 700;
    letter-spacing: .04em;
    text-transform: uppercase;
    border-radius: 999px;
    padding: 2px 8px;
    margin-right: 8px;
}

.rh-mode-mensuel {
    color: var(--blue);
    background: var(--blue-soft);
}

.rh-mode-horaire {
    color: var(--amber);
    background: var(--amber-soft);
}

/* ---- Nature d'un mouvement (avance / crédit) ---- */
.rh-nature {
    display: inline-block;
    font-size: 10.5px;
    font-weight: 700;
    letter-spacing: .04em;
    text-transform: uppercase;
    border-radius: 999px;
    padding: 2px 8px;
}

.rh-nature-avance {
    color: var(--teal-dark);
    background: var(--teal-soft);
}

.rh-nature-credit {
    color: var(--blue);
    background: var(--blue-soft);
}

/* ⚠️ Un compte courant NÉGATIF est NORMAL en RH-1 (le dû des bulletins n'existe pas encore) :
   il est mis en évidence, jamais en ROUGE d'alerte — ce serait dire qu'il y a un problème. */
.rh-negatif {
    color: var(--slate);
    font-weight: 600;
}

/* ---- Compte courant, sur la fiche ---- */
.rh-cc-solde {
    font-family: 'Sora', system-ui, sans-serif;
    font-size: 26px;
    font-weight: 700;
    color: var(--ink);
    font-variant-numeric: tabular-nums;
    margin: 4px 0 2px;
}

.rh-cc-formule {
    font-size: 11.5px;
    color: var(--slate);
    font-variant-numeric: tabular-nums;
    margin-bottom: 8px;
}

.rh-cc-note {
    font-size: 12px;
    line-height: 1.45;
    color: var(--slate);
    background: var(--paper);
    border-left: 3px solid var(--teal);
    border-radius: 6px;
    padding: 8px 10px;
    margin-bottom: 12px;
}

.rh-cc-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

/* ---- Sous-textes explicatifs (doctrine, ce que l'écran ne sait pas encore) ---- */
.rh-sous-texte {
    font-size: 11.5px;
    line-height: 1.45;
    color: var(--slate);
    margin-top: 4px;
}

.rh-check {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-size: 13px;
    color: var(--ink);
}

.rh-mini {
    padding: 3px 10px;
    font-size: 12px;
}

/* ---- Historique de la fiche : conteneur à défilement PROPRE ---- */
.rh-hist-wrap {
    overflow-x: auto;
    max-height: 420px;
    overflow-y: auto;
}

.rh-hist thead th {
    position: sticky;
    top: 0;   /* ⚠️ 0, JAMAIS 64px — voir l'en-tête de ce fichier. */
    background: var(--thead-bg);
    z-index: 1;
}

/* ---- Tuiles de la vue transverse ---- */
.rh-kpis {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 12px;
    margin-bottom: 16px;
}

.rh-kpi {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 12px 14px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.rh-kpi-label {
    font-size: 11px;
    font-weight: 600;
    letter-spacing: .06em;
    text-transform: uppercase;
    color: var(--slate);
}

.rh-kpi-val {
    font-family: 'Sora', system-ui, sans-serif;
    font-size: 20px;
    font-weight: 700;
    color: var(--ink);
    font-variant-numeric: tabular-nums;
}

@media (max-width: 768px) {
    .rh-head {
        flex-direction: column;
        align-items: stretch;
    }

    .rh-head-actions > * {
        flex: 1 1 auto;
    }

    .rh-title {
        font-size: 22px;
    }

    .rh-cc-solde {
        font-size: 22px;
    }
}

/* =====================================================================================
   T-UI BULLETIN — LE BULLETIN DE PAIE (ecran + impression)
   Recopie VERBATIM du bloc [B] de docs/maquettes/maquette_bulletin_paie.html.
   ⚠️ TOUT est prefixe .rh-bul- : aucun selecteur PARTAGE n est style ici. Styler
      .btn-filtres puis .crud-toolbar-actions a casse DEUX FOIS des ecrans que la tranche
      ne touchait pas (dont t75 en timeout de 30 s sur Commissions) — un conteneur partage
      ne se style que sous une condition qui le rattache a SON ecran.
   ⚠️ AUCUNE couleur en dur : uniquement les variables :root d app.css.
   ===================================================================================== */
/* ======================= [B] NOUVEAU — rh.css, borné à .rh-bul- ======================= */
.rh-bul-wrap{padding:22px 20px 60px}
.rh-bul-trac{font-size:12px;color:var(--slate);margin-top:2px}

/* Bandeau d'information (bulletin payé / non modifiable) */
.rh-bul-bandeau{margin:2px 0 16px;border-radius:11px;padding:11px 14px;font-size:13px;
  display:flex;gap:10px;align-items:flex-start;background:var(--amber-soft);
  color:var(--ink);border:1px solid var(--amber-soft)}
.rh-bul-bandeau__ico{flex:0 0 auto;color:var(--amber);font-weight:700}
.rh-bul-bandeau b{font-weight:600}
.rh-bul-lien{color:var(--teal-dark);font-weight:600;text-decoration:underline;
  text-underline-offset:2px}

/* Sous-libellé d'une valeur de carte (la dérivation d'un taux) */
.rh-bul-hint{display:block;font-size:11.5px;color:var(--slate);font-weight:400;
  text-align:right;margin-top:1px}
.rh-bul-sep{height:1px;background:var(--line);margin:10px 0}
.rh-bul-net{display:flex;justify-content:space-between;align-items:baseline;gap:12px;padding:8px 0 4px}
.rh-bul-net__k{font-size:12px;font-weight:700;letter-spacing:.5px;text-transform:uppercase;color:var(--slate)}
.rh-bul-net__v{font-family:'Sora',sans-serif;font-weight:700;font-size:22px;
  color:var(--teal);font-variant-numeric:tabular-nums}
.rh-bul-v-green{color:var(--green)}

/* ---- LE DÉTAIL : un vrai tableau, 4 colonnes ---- */
.rh-bul-detail{background:var(--surface);border:1px solid var(--line);
  border-radius:14px;overflow:clip}
.rh-bul-detail__head{display:flex;justify-content:space-between;align-items:center;
  gap:12px;padding:13px 16px;border-bottom:1px solid var(--line)}
.rh-bul-detail__title{font-family:'Sora',sans-serif;font-weight:700;font-size:15px}
.rh-bul-detail__hint{font-size:12px;color:var(--slate)}
.rh-bul-table{width:100%;border-collapse:collapse}
.rh-bul-table thead th{font-size:10.5px;font-weight:700;letter-spacing:.8px;
  text-transform:uppercase;color:var(--slate);background:var(--thead-bg);
  padding:9px 16px;text-align:left;border-bottom:1px solid var(--line)}
.rh-bul-table tbody td{padding:11px 16px;border-bottom:1px solid var(--line);
  vertical-align:baseline}
.rh-bul-table tbody tr:hover td{background:var(--row-hover)}
.rh-bul-lbl{font-weight:500}
.rh-bul-lbl small{display:block;font-weight:400;font-size:11.5px;color:var(--slate);margin-top:2px}
.rh-bul-unit{color:var(--slate);font-weight:400;font-size:12px;margin-left:3px}
.rh-bul-vide{color:var(--slate)}
.rh-bul-neg{color:var(--red)}

.rh-bul-grp td{padding:7px 16px;background:var(--rh-g-soft);border-bottom:1px solid var(--line)}
.rh-bul-grp__lbl{display:inline-flex;align-items:center;gap:8px;font-size:11.5px;
  font-weight:700;letter-spacing:.7px;text-transform:uppercase;color:var(--rh-g)}
.rh-bul-grp__ico{width:19px;height:19px;border-radius:6px;display:inline-grid;
  place-items:center;background:var(--surface);color:var(--rh-g);font-size:12px;
  font-weight:700;border:1px solid currentColor}
.rh-bul-grp--gains{--rh-g:var(--green);--rh-g-soft:var(--green-soft)}
.rh-bul-grp--ret{--rh-g:var(--red);--rh-g-soft:var(--red-soft)}
.rh-bul-sous td{background:var(--surface);font-weight:600;border-bottom:2px solid var(--line)}
.rh-bul-total td{background:var(--teal-soft);border-bottom:none;padding:14px 16px}
.rh-bul-total__k{font-family:'Sora',sans-serif;font-weight:700;font-size:15px;color:var(--teal-dark)}
.rh-bul-total__v{font-family:'Sora',sans-serif;font-weight:700;font-size:20px;
  color:var(--teal-dark);font-variant-numeric:tabular-nums}

/* ---- Blocs du bas ---- */
.rh-bul-grid2{display:grid;grid-template-columns:1fr 1fr;gap:14px;margin-top:16px}
.rh-bul-blk{background:var(--surface);border:1px solid var(--line);border-radius:14px}
.rh-bul-blk__head{display:flex;align-items:center;gap:9px;padding:12px 14px;
  border-bottom:1px solid var(--line)}
.rh-bul-blk__pill{width:26px;height:26px;border-radius:8px;display:grid;place-items:center;
  font-size:13px;background:var(--rh-b-soft);color:var(--rh-b)}
.rh-bul-blk--av{--rh-b:var(--amber);--rh-b-soft:var(--amber-soft)}
.rh-bul-blk--rg{--rh-b:var(--slate);--rh-b-soft:var(--paper)}
.rh-bul-blk__title{font-size:12px;font-weight:700;text-transform:uppercase;
  letter-spacing:.4px;color:var(--slate)}
.rh-bul-blk__body{padding:6px 14px 14px}
.rh-bul-note{font-size:12px;color:var(--slate);margin:8px 0 10px}
.rh-bul-row{display:flex;align-items:center;gap:10px;padding:9px 0;
  border-bottom:1px dashed var(--line)}
.rh-bul-row:last-child{border-bottom:none}
.rh-bul-row input{width:16px;height:16px;accent-color:var(--teal)}
.rh-bul-row .rh-bul-meta{color:var(--slate);font-size:12.5px}
.rh-bul-row .rh-bul-m{margin-left:auto;font-variant-numeric:tabular-nums;font-weight:600}
.rh-bul-code{font-weight:600;font-variant-numeric:tabular-nums}
.rh-bul-pill{display:inline-flex;align-items:center;padding:2px 8px;border-radius:999px;
  font-size:11px;font-weight:700;background:var(--teal-soft);color:var(--teal-dark)}
.rh-bul-foot{margin-top:18px;font-size:12px;color:var(--slate);text-align:center}

/* ---- MOBILE ---- */
@media (max-width:900px){
  /* ⚠️ BORNE a .rh-bul-wrap : la maquette ecrivait « .doc-cards-row » nu, ce qui aurait
     touche TOUS les ecrans document sous 900px. */
  .rh-bul-wrap .doc-cards-row{grid-template-columns:1fr}
  .rh-bul-grid2{grid-template-columns:1fr}
}
@media (max-width:768px){
  .rh-bul-wrap{padding:16px 12px 48px}
  .rh-bul-wrap .doc-title{font-size:23px}
  .rh-bul-wrap .doc-header-actions{width:100%}
  .rh-bul-wrap .doc-header-actions .btn-filtres,
  .rh-bul-wrap .doc-header-actions .btn-nouveau{flex:1 1 auto;justify-content:center}
  .rh-bul-table thead{display:none}
  .rh-bul-table tbody tr{display:block;border-bottom:1px solid var(--line)}
  .rh-bul-table tbody td{display:flex;justify-content:space-between;gap:12px;
    border:none;padding:5px 14px;text-align:left}
  .rh-bul-table tbody td:first-child{padding-top:11px}
  .rh-bul-table tbody td:last-child{padding-bottom:11px}
  .rh-bul-table tbody td[data-l]::before{content:attr(data-l);color:var(--slate);font-size:12px}
  .rh-bul-grp td,.rh-bul-sous td,.rh-bul-total td{display:flex;justify-content:space-between}
  .rh-bul-grp td::before,.rh-bul-sous td::before,.rh-bul-total td::before{content:none}
  .rh-bul-table tbody td.rh-bul-masque-mobile{display:none}
}

/* La derivation du taux SUR L IMPRESSION du bulletin.
   ⚠️ Prefixe pf- car elle vit dans le gabarit d impression, mais elle est BORNEE au
      bulletin (.rh-bul-print) : les 12 autres impressions du depot ne doivent pas la voir. */
.rh-bul-print .pf-derivation{font-size:9.5px;color:var(--slate);margin-top:1px}

/* =====================================================================================
   T-UI BULLETIN-bis — LA SAISIE ET LA CARTE TOTAUX
   -------------------------------------------------------------------------------------
   ⚠️⚠️ LA CAUSE, MESUREE AVANT DE REECRIRE : les trois symptomes (colonne etroite,
   bouton superpose, aide flottante) n avaient QU UNE seule cause. `.doc-saisie` ne porte
   AUCUN layout ; le `display:flex` du patron vit dans **`.doc-bande`** (app.css:1952), et
   l ecran bulletin ecrivait « doc-saisie doc-saisie--produit rh-saisie » — SANS doc-bande.
   Il heritait donc du fond et du lisere (`.doc-page .doc-saisie--produit`, app.css:1961)
   mais d aucune mise en ligne : le lisere sans la rangee. `.rh-saisie` et `.rh-apercu`
   etaient des classes FANTOMES (0 definition dans tout le CSS).
   ⚠️ Poser un layout par-dessus sans nommer cela l aurait fait ressortir en MOBILE :
   app.css:1631 cible `.doc-saisie` en `flex-direction:column !important` sous 768px, ce qui
   SUPPOSE un flex desktop qui n existait pas ici.
   ⇒ On ne rustine pas `.doc-saisie` (11 ecrans en dependent) : on pose une grille PROPRE,
   bornee au bulletin.
   ===================================================================================== */

/* --- champs : le LABEL TIENT SUR UNE LIGNE, et c est une contrainte --- */
/* ⚠️ min-height + line-height + nowrap : un label sur DEUX lignes decale SON input et la
   rangee cesse d etre alignee (constate sur « Libelle (CNSS, AMO, IR…) »). Si un libelle
   ne tient pas, on raccourcit LE LIBELLE — on n abandonne pas l alignement. */
.rh-bul-lab {
    display: block; font-size: 11px; font-weight: 600; text-transform: uppercase;
    letter-spacing: .4px; color: var(--slate); margin-bottom: 4px;
    min-height: 15px; line-height: 15px;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* ⭐ CORRECTION 1 — CARTE TOTAUX : GRILLE, PAS FLEX.
   `.fpro-kv` est un flex : un libelle long (« Retenues et cotisations ») passe sur deux
   lignes et sa VALEUR reste accrochee a la premiere — decalage visible sur la capture.
   En grid 1fr/auto avec baseline, le libelle wrappe SANS deplacer la valeur.
   ⚠️ NE PAS raccourcir le libelle pour contourner : le prochain libelle long reviendrait.
      C est la grille qui corrige, pas le texte. */
.rh-bul-kv {
    display: grid; grid-template-columns: 1fr auto; align-items: baseline;
    gap: 6px 14px; padding: 7px 0;
}
.rh-bul-kv + .rh-bul-kv { border-top: 1px dashed var(--line); }
.rh-bul-kv__k { color: var(--slate); font-size: 13px; min-width: 0; }
.rh-bul-kv__v {
    font-variant-numeric: tabular-nums; font-weight: 600;
    white-space: nowrap; text-align: right;
}
.rh-bul-kv__v.is-neg { color: var(--red); }
.rh-bul-sep { height: 1px; background: var(--line); margin: 10px 0; }
.rh-bul-net {
    display: grid; grid-template-columns: 1fr auto; align-items: baseline;
    gap: 6px 12px; padding: 8px 0 4px;
}
.rh-bul-net__k {
    font-size: 12px; font-weight: 700; letter-spacing: .5px;
    text-transform: uppercase; color: var(--slate);
}
.rh-bul-net__v {
    font-family: 'Sora', sans-serif; font-weight: 700; font-size: 22px;
    color: var(--teal); font-variant-numeric: tabular-nums;
    white-space: nowrap; text-align: right;
}
.rh-bul-net__v.is-neg { color: var(--red); }
.rh-bul-hint {
    display: block; font-size: 11.5px; color: var(--slate); font-weight: 400;
    text-align: right; margin-top: 1px;
}

/* ⭐ CORRECTION 2 — SECTIONS DE SAISIE : l aide vit DANS L EN-TETE.
   ⚠️ « Aucun taux n est pre-rempli… » flottait a mi-hauteur a cote d un champ. Une
   explication placee loin de ce qu elle explique n est pas lue. */
.rh-bul-sect {
    background: var(--surface); border: 1px solid var(--line);
    border-radius: 14px; margin-bottom: 12px; overflow: clip;
}
.rh-bul-sect__head {
    display: flex; align-items: center; gap: 10px; padding: 12px 16px;
    flex-wrap: wrap;
}
.rh-bul-sect__pill {
    width: 26px; height: 26px; border-radius: 50%; flex: none;
    display: inline-flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 14px;
    background: var(--sect-soft, var(--teal-soft)); color: var(--sect, var(--teal));
}
.rh-bul-sect__t { font-weight: 700; font-size: 14px; flex: none; }
.rh-bul-sect__aide { font-size: 12px; color: var(--slate); flex: 1 1 auto; min-width: 0; }
.rh-bul-sect--gains { --sect: var(--green); --sect-soft: var(--green-soft); }
.rh-bul-sect--ret   { --sect: var(--red);   --sect-soft: var(--red-soft); }
.rh-bul-sect--cot   { --sect: var(--amber); --sect-soft: var(--amber-soft); }
.rh-bul-sect__body { padding: 0 16px 16px; }

/* ⭐ CORRECTION 3 — LA RANGEE DE SAISIE : le patron doc-*, EN LIGNE.
   Fond --paper + lisere gauche 3px, champs cote a cote, bouton AU BOUT.

   ⚠️⚠️ ALIGNEMENT — align-items:START, surtout PAS end (addendum §2 de la maquette).
   « end » aligne le bas de la CELLULE, pas le bas du CHAMP : des qu une colonne porte une
   aide sous son input (« = 269,23 DH · … ») et pas sa voisine, la cellule est plus haute
   et SON INPUT REMONTE — les champs cessent d etre sur la meme ligne.
   Avec « start », ce qui PRECEDE l input a la meme hauteur partout (un label d UNE ligne,
   d ou le min-height ci-dessus), donc tous les inputs partagent la meme ordonnee, et
   l aide, qui vient APRES, ne decale plus rien. */
.rh-bul-saisie {
    display: grid; gap: 10px; align-items: start;
    background: var(--paper);
    border-left: 3px solid var(--sect, var(--teal));
    border-radius: 0 11px 11px 0;
    padding: 12px 14px;
}
.rh-bul-saisie--gains { grid-template-columns: 1.3fr 1.7fr .8fr .9fr auto; }
.rh-bul-saisie--ret   { grid-template-columns: 1.3fr 1.7fr .9fr auto; }
.rh-bul-saisie--cot   { grid-template-columns: 1.7fr .8fr auto; }
/* ⚠️ Une grille par NOMBRE REEL de cellules : on ne cree pas un champ pour remplir une
   colonne. L absence n a qu un champ + le bouton. */
.rh-bul-saisie--abs   { grid-template-columns: 1.3fr auto; }
/* ⚠️ min-width:0 : sans lui, un contenu long empeche la colonne de se retrecir et la
   grille DEBORDE horizontalement (defaut classique des grilles a colonnes fr). */
.rh-bul-f { min-width: 0; }
/* ⭐ Le bouton vit dans une cellule a LABEL INVISIBLE, jamais cale par un margin-top
   calcule a la main : il tombe ainsi EXACTEMENT sur la rangee des inputs, et il suivra
   tout seul si la typographie change. */
.rh-bul-f--btn .rh-bul-lab { visibility: hidden; }
.rh-bul-f--btn .btn-nouveau { width: 100%; }
/* L aide vit SOUS le champ qu elle explique — jamais flottante a droite : elle porte un
   calcul que l utilisateur doit pouvoir refaire. */
.rh-bul-aide {
    display: block; font-size: 11.5px; color: var(--slate); margin-top: 5px;
    font-variant-numeric: tabular-nums;
}
.rh-bul-aide b { font-weight: 600; color: var(--ink); }

/* --- MOBILE : la rangee s empile, le bouton passe pleine largeur — jamais superpose --- */
@media (max-width: 768px) {
    .rh-bul-saisie--gains,
    .rh-bul-saisie--ret,
    .rh-bul-saisie--abs,
    .rh-bul-saisie--cot { grid-template-columns: 1fr; }
    .rh-bul-saisie .btn-nouveau { width: 100%; justify-content: center; }
    .rh-bul-f--btn .rh-bul-lab { display: none; }
}
