/* Panneaux de détail des primes (2026-10-19) : « Reste à facturer » (ResteAFacturerPanel) et
   « CA primable » (CaPrimablePanel). Sortis du composant pour être partagés ; préfixe raf-. */
/* ── Boîte de dialogue native : volet à droite, feuille en bas sur téléphone ── */
.raf {
    --raf-rouge: #C61E26; --raf-texte: #111827; --raf-doux: #6b7280; --raf-doux2: #9ca3af;
    --raf-bord: #e5e7eb; --raf-fond: #f5f6f8;
    --raf-entree: .5s cubic-bezier(.16, 1, .3, 1);   /* arrivée : vive puis amortie */
    --raf-sortie: .26s cubic-bezier(.4, 0, 1, 1);    /* départ : franc */
    position: fixed; inset: 0 0 0 auto; margin: 0; padding: 0; border: 0;
    width: min(560px, 100vw); max-width: 100vw;
    height: 100vh; height: 100dvh; max-height: 100vh; max-height: 100dvh;
    background: transparent; color: var(--raf-texte); overflow: visible; outline: none;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}
.raf::backdrop {
    background: linear-gradient(90deg, rgba(17,24,39,.38), rgba(17,24,39,.55));
    -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px);
    animation: rafFondu .35s ease both;
}
.raf--sortie::backdrop { animation: rafFonduSortie var(--raf-sortie) both; }
/* La page derrière ne défile plus pendant que le panneau est ouvert. */
body:has(.raf[open]) { overflow: hidden; }
/* Repli sans showModal : pas de top layer, on passe au-dessus du reste par z-index. */
.raf--sans-modal { z-index: 1300; box-shadow: -16px 0 48px rgba(17,24,39,.35); }

.raf-boite {
    display: flex; flex-direction: column; width: 100%; height: 100%; outline: none;
    background: #fff; box-shadow: -24px 0 64px rgba(17,24,39,.28);
    animation: rafEntree var(--raf-entree) both;
}
/* Sortie : la classe est posée par gfUi.fermerDialogue (et par Blazor) le temps de l'animation. */
.raf--sortie .raf-boite { animation: rafSortie var(--raf-sortie) both; }

@keyframes rafEntree   { from { transform: translateX(100%); } to { transform: none; } }
@keyframes rafSortie   { from { transform: none; } to { transform: translateX(100%); } }
@keyframes rafMontee   { from { transform: translateY(100%); } to { transform: none; } }
@keyframes rafDescente { from { transform: none; } to { transform: translateY(100%); } }
@keyframes rafFondu       { from { opacity: 0; } to { opacity: 1; } }
@keyframes rafFonduSortie { from { opacity: 1; } to { opacity: 0; } }
@keyframes rafApparition { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes rafReflet { from { background-position: 200% 0; } to { background-position: -200% 0; } }

.raf button:focus-visible, .raf-boite:focus-visible { outline: 2px solid var(--raf-rouge); outline-offset: 2px; }

/* ── En-tête clair : identité et total ── */
.raf-tete {
    position: relative; overflow: hidden; padding: 1.15rem 1.25rem 1.2rem; color: var(--raf-texte);
    background: linear-gradient(180deg, #fff 0%, #f7f8fa 100%); border-bottom: 1px solid var(--raf-bord);
}
/* Liseré de marque en haut, halo rouge très discret à droite. */
.raf-tete::before {
    content: ""; position: absolute; inset: 0 0 auto 0; height: 3px;
    background: linear-gradient(90deg, var(--raf-rouge), rgba(198,30,38,.12));
}
.raf-tete::after {
    content: ""; position: absolute; right: -100px; top: -120px; width: 300px; height: 300px; border-radius: 50%;
    background: radial-gradient(circle, rgba(198,30,38,.13), transparent 70%); pointer-events: none;
}
.raf-poignee { display: none; width: 44px; height: 5px; margin: 0 auto .8rem; border-radius: 999px; background: #d1d5db; }
.raf-tete__haut {
    position: relative; display: flex; align-items: center; gap: .8rem;
    animation: rafApparition .45s ease both .12s;
}
.raf-avatar {
    width: 42px; height: 42px; border-radius: 13px; flex-shrink: 0;
    display: grid; place-items: center; font-weight: 800; font-size: 1.05rem; color: #fff;
    background: linear-gradient(135deg, var(--raf-rouge), #e63946); box-shadow: 0 8px 18px rgba(198,30,38,.28);
}
.raf-ident    { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: .1rem; }
.raf-surtitre { font-size: .64rem; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; color: var(--raf-rouge); }
.raf-nom      { margin: 0; font-size: 1.05rem; font-weight: 700; color: var(--raf-texte); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.raf-matricule {
    font-family: ui-monospace, Consolas, monospace; font-size: .72rem; white-space: nowrap;
    padding: .24rem .6rem; border-radius: 999px; background: #fff; border: 1px solid var(--raf-bord); color: var(--raf-doux);
}
.raf-fermer {
    width: 36px; height: 36px; flex-shrink: 0; border: 1px solid var(--raf-bord); border-radius: 50%; cursor: pointer;
    display: grid; place-items: center; background: #fff; color: var(--raf-doux); font-size: .9rem;
    transition: background .15s, color .15s, border-color .15s, transform .25s, box-shadow .15s;
}
.raf-fermer:hover {
    background: var(--raf-texte); border-color: var(--raf-texte); color: #fff;
    transform: rotate(90deg); box-shadow: 0 6px 16px rgba(17,24,39,.18);
}
.raf-tete__total {
    position: relative; margin-top: 1.05rem; display: flex; flex-direction: column; gap: .35rem;
    animation: rafApparition .45s ease both .2s;
}
.raf-total {
    font-size: 2.35rem; font-weight: 800; letter-spacing: -.035em; line-height: 1; font-variant-numeric: tabular-nums;
}
/* Trait d'accent au-dessus du montant : la couleur de marque sans bandeau sombre. */
.raf-total::before {
    content: ""; display: block; width: 34px; height: 4px; margin-bottom: .65rem; border-radius: 999px;
    background: linear-gradient(90deg, var(--raf-rouge), #ff6b6b);
}
.raf-total__lbl { font-size: .76rem; color: var(--raf-doux); }

/* ── Corps défilant ── */
.raf-corps {
    flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain;
    padding: 1rem 1.25rem 1.25rem; display: flex; flex-direction: column; gap: .9rem; background: var(--raf-fond);
}
/* Les blocs gardent leur hauteur et la zone défile : sans cela, les groupes clients
   (overflow: hidden, donc hauteur minimale nulle) étaient écrasés pour tenir à l'écran. */
.raf-corps > * { flex-shrink: 0; }
/* À l'ouverture, les blocs du corps apparaissent en cascade (les pièces et les groupes
   clients ont déjà leur propre apparition). */
.raf-corps > :not(.raf-liste):not(.raf-groupe) { animation: rafApparition .45s ease both .22s; }
.raf-corps > :nth-child(2):not(.raf-liste):not(.raf-groupe) { animation-delay: .28s; }
.raf-corps > :nth-child(n+3):not(.raf-liste):not(.raf-groupe) { animation-delay: .34s; }

.raf-ecart {
    margin: 0; display: flex; gap: .55rem; align-items: flex-start; padding: .6rem .75rem; border-radius: 12px;
    font-size: .76rem; line-height: 1.45; color: #92400e; background: #fffbeb; border: 1px solid #fde68a;
}
.raf-ecart i { flex-shrink: 0; margin-top: .1rem; }

/* ── Ancienneté : barre et trois tranches-filtres ── */
.raf-anciennete { background: #fff; border: 1px solid var(--raf-bord); border-radius: 16px; padding: .9rem; }
.raf-barre { display: flex; gap: 3px; height: 8px; border-radius: 999px; overflow: hidden; background: #eef0f4; }
.raf-barre__seg { min-width: 6px; transition: flex-grow .3s ease; }
.raf-barre__seg--recent,  .raf-pastille--recent  { background: #16a34a; }
.raf-barre__seg--attente, .raf-pastille--attente { background: #f59e0b; }
.raf-barre__seg--ancien,  .raf-pastille--ancien  { background: var(--raf-rouge); }
.raf-pastille { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.raf-tranches { display: grid; grid-template-columns: repeat(3, 1fr); gap: .5rem; margin-top: .75rem; }
.raf-tranche {
    display: flex; flex-direction: column; gap: .15rem; min-width: 0; padding: .55rem .6rem;
    border: 1.5px solid transparent; border-radius: 12px; background: var(--raf-fond); cursor: pointer;
    font: inherit; text-align: left; color: inherit;
    transition: border-color .15s, background .15s, transform .15s, box-shadow .15s;
}
.raf-tranche:hover:not(:disabled) { transform: translateY(-1px); background: #eef0f4; }
.raf-tranche:disabled { opacity: .45; cursor: default; }
.raf-tranche--actif, .raf-tranche--actif:hover:not(:disabled) { border-color: var(--raf-texte); background: #fff; box-shadow: 0 4px 14px rgba(17,24,39,.1); }
.raf-tranche__lbl { display: flex; align-items: center; gap: .35rem; font-size: .66rem; font-weight: 600; color: var(--raf-doux); white-space: nowrap; }
.raf-tranche__val { font-size: .9rem; font-weight: 800; font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.raf-tranche__nb  { font-size: .66rem; color: var(--raf-doux2); }

/* ── Recherche et présentation ── */
.raf-outils { display: flex; gap: .5rem; flex-wrap: wrap; }
.raf-recherche {
    flex: 1; min-width: 170px; display: flex; align-items: center; gap: .5rem; padding: 0 .8rem;
    background: #fff; border: 1.5px solid var(--raf-bord); border-radius: 12px; transition: border-color .15s, box-shadow .15s;
}
.raf-recherche:focus-within { border-color: var(--raf-rouge); box-shadow: 0 0 0 3px rgba(198,30,38,.10); }
.raf-recherche i { color: var(--raf-doux2); font-size: .85rem; }
.raf-recherche input { flex: 1; min-width: 0; border: 0; outline: 0; padding: .55rem 0; font: inherit; font-size: .85rem; background: transparent; }
.raf-vues { display: inline-flex; padding: 3px; border-radius: 12px; background: #e9ebf0; }
.raf-vues button {
    display: inline-flex; align-items: center; gap: .35rem; padding: .42rem .7rem; border: 0; border-radius: 9px;
    background: none; cursor: pointer; font: inherit; font-size: .76rem; font-weight: 600; color: var(--raf-doux);
    transition: background .15s, color .15s;
}
.raf-vues button.raf-vues--actif { background: #fff; color: var(--raf-texte); box-shadow: 0 1px 4px rgba(0,0,0,.1); }

/* ── Pièces ── */
.raf-liste { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: .5rem; }
.raf-ligne {
    position: relative; display: grid; grid-template-columns: 46px 1fr auto; gap: .75rem; align-items: center;
    padding: .7rem .8rem .7rem .95rem; border: 1px solid var(--raf-bord); border-radius: 14px; background: #fff; overflow: hidden;
    transition: border-color .15s, box-shadow .15s, transform .15s; animation: rafApparition .3s ease both;
}
.raf-ligne::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: var(--raf-bord); }
.raf-ligne--recent::before  { background: #16a34a; }
.raf-ligne--attente::before { background: #f59e0b; }
.raf-ligne--ancien::before  { background: var(--raf-rouge); }
.raf-ligne:hover { border-color: #d9dce3; box-shadow: 0 6px 18px rgba(17,24,39,.08); transform: translateY(-1px); }
.raf-date { display: flex; flex-direction: column; align-items: center; justify-content: center; height: 46px; border-radius: 11px; background: var(--raf-fond); line-height: 1.05; }
.raf-date__j { font-size: 1.05rem; font-weight: 800; }
.raf-date__m { font-size: .58rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--raf-doux); }
.raf-ligne__milieu { min-width: 0; }
.raf-ligne__client { font-size: .86rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.raf-code { margin-left: .35rem; font-family: ui-monospace, Consolas, monospace; font-size: .68rem; font-weight: 400; color: var(--raf-doux2); }
.raf-ligne__refs { display: flex; flex-wrap: wrap; gap: .3rem; margin-top: .3rem; }
.raf-ligne__refs span {
    display: inline-flex; align-items: center; gap: .3rem; padding: .12rem .45rem; border-radius: 6px;
    background: var(--raf-fond); font-family: ui-monospace, Consolas, monospace; font-size: .66rem; color: var(--raf-doux);
}
.raf-ligne__refs i { font-size: .7rem; color: var(--raf-doux2); }
.raf-ligne__droite  { display: flex; flex-direction: column; align-items: flex-end; gap: .3rem; }
.raf-ligne__montant { font-size: .95rem; font-weight: 800; white-space: nowrap; font-variant-numeric: tabular-nums; letter-spacing: -.01em; }
.raf-age { padding: .12rem .5rem; border-radius: 999px; font-size: .66rem; font-weight: 700; white-space: nowrap; }
.raf-age--recent  { background: #dcfce7; color: #166534; }
.raf-age--attente { background: #fef3c7; color: #92400e; }
.raf-age--ancien  { background: #fee2e2; color: #991b1b; }

/* ── Regroupement par client ── */
.raf-groupe { border: 1px solid var(--raf-bord); border-radius: 14px; background: #fff; overflow: hidden; animation: rafApparition .3s ease both; }
.raf-groupe + .raf-groupe { margin-top: .5rem; }
.raf-groupe__tete {
    width: 100%; display: grid; grid-template-columns: auto 1fr auto auto; align-items: center; gap: .5rem .6rem;
    padding: .75rem .9rem; border: 0; background: #fff; cursor: pointer; font: inherit; color: inherit; text-align: left;
    transition: background .15s;
}
.raf-groupe__tete:hover { background: #fafbfc; }
.raf-chevron {
    display: grid; place-items: center; width: 22px; height: 22px; border-radius: 7px;
    background: var(--raf-fond); color: var(--raf-rouge); font-size: .7rem; transition: transform .2s;
}
.raf-groupe__tete[aria-expanded="true"] .raf-chevron { transform: rotate(90deg); }
.raf-groupe__ident { min-width: 0; display: flex; flex-direction: column; gap: .1rem; }
.raf-groupe__nom   { min-width: 0; font-size: .86rem; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.raf-groupe__code  { font-family: ui-monospace, Consolas, monospace; font-size: .7rem; font-weight: 400; color: var(--raf-doux2); }
.raf-groupe__nb    { padding: .08rem .5rem; border-radius: 999px; background: var(--raf-fond); font-size: .68rem; font-weight: 700; color: var(--raf-doux); }
.raf-groupe__total { font-size: .92rem; font-weight: 800; font-variant-numeric: tabular-nums; white-space: nowrap; }
.raf-groupe__part  { grid-column: 1 / -1; height: 4px; border-radius: 999px; background: var(--raf-fond); overflow: hidden; }
.raf-groupe__part > span { display: block; height: 100%; border-radius: 999px; background: linear-gradient(90deg, var(--raf-rouge), #ff6b6b); }
.raf-liste--groupe { padding: .5rem; border-top: 1px solid var(--raf-bord); background: var(--raf-fond); }
.raf-liste--groupe .raf-ligne { animation: none; }

/* ── États ── */
.raf-etat {
    display: flex; gap: .75rem; align-items: flex-start; padding: 1rem 1.1rem; border-radius: 14px;
    background: #fff; border: 1px solid var(--raf-bord); color: var(--raf-doux); font-size: .84rem; line-height: 1.5;
}
.raf-etat > i { flex-shrink: 0; margin-top: .1rem; font-size: 1.25rem; line-height: 1; color: var(--raf-doux2); }
.raf-etat strong { display: block; margin-bottom: .15rem; color: var(--raf-texte); }
.raf-etat--ok { background: #f0fdf4; border-color: #bbf7d0; color: #166534; font-weight: 600; }
.raf-etat--ok > i { color: #16a34a; }
.raf-etat--erreur { background: #fef2f2; border-color: #fecaca; color: #991b1b; }
.raf-etat--erreur > i { color: #dc2626; }
.raf-lien { border: 0; background: none; padding: 0; font: inherit; font-weight: 600; color: var(--raf-rouge); cursor: pointer; text-decoration: underline; }

.raf-squelette { display: flex; flex-direction: column; gap: .6rem; }
.raf-squelette__bloc {
    height: 62px; border-radius: 14px;
    background: linear-gradient(90deg, #eceef2 25%, #f7f8fa 50%, #eceef2 75%);
    background-size: 200% 100%; animation: rafReflet 1.2s ease-in-out infinite;
}
.raf-squelette__bloc--haut { height: 120px; }

.raf-pied {
    display: flex; align-items: center; justify-content: space-between; gap: .75rem; padding: .7rem 1.25rem;
    border-top: 1px solid var(--raf-bord); background: #fff; font-size: .72rem; color: var(--raf-doux2);
}
.raf-pied i { margin-right: .3rem; }
.raf-pied b { font-weight: 600; color: var(--raf-doux); white-space: nowrap; }

@media (prefers-reduced-motion: reduce) {
    .raf-boite, .raf::backdrop, .raf-tete__haut, .raf-tete__total, .raf-corps > *, .raf-ligne, .raf-groupe, .raf-squelette__bloc { animation: none; }
    .raf-ligne:hover, .raf-tranche:hover:not(:disabled), .raf-fermer:hover { transform: none; }
}

/* Téléphone : feuille qui monte du bas, poignée, tranches resserrées. */
@media (max-width: 640px) {
    .raf { inset: auto 0 0 0; width: 100%; height: auto; max-height: 92vh; max-height: 92dvh; }
    .raf-boite {
        height: auto; max-height: 92vh; max-height: 92dvh; border-radius: 22px 22px 0 0;
        box-shadow: 0 -16px 48px rgba(17,24,39,.25); animation-name: rafMontee;
    }
    .raf--sortie .raf-boite { animation-name: rafDescente; }
    .raf-tete { padding-top: .65rem; border-radius: 22px 22px 0 0; }
    .raf-poignee { display: block; }
    .raf-total { font-size: 2rem; }
    .raf-corps, .raf-pied { padding-left: 1rem; padding-right: 1rem; }
    .raf-tranches { gap: .35rem; }
    .raf-tranche { padding: .5rem .45rem; }
    .raf-ligne { grid-template-columns: 42px 1fr; }
    .raf-ligne__droite { grid-column: 2; flex-direction: row; justify-content: space-between; align-items: center; }
}

/* ── Panneau « CA primable » (CaPrimablePanel, 2026-10-19) : 60 à 80 lignes par mois, d'où des
   lignes resserrées (une ligne de texte de plus au plus) dont le détail se déplie à l'appui. ── */
.fac-top { background: #fff; border: 1px solid var(--raf-bord); border-radius: 16px; padding: .75rem .9rem .55rem; }
.fac-top__titre { margin: 0 0 .3rem; font-size: .64rem; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--raf-doux); }
.fac-top__ligne {
    width: 100%; display: grid; grid-template-columns: 1fr auto; gap: .25rem .75rem; align-items: baseline;
    padding: .35rem 0; border: 0; background: none; font: inherit; color: inherit; text-align: left; cursor: pointer;
}
.fac-top__ligne + .fac-top__ligne { border-top: 1px dashed var(--raf-bord); }
.fac-top__ligne:hover .fac-top__nom { color: var(--raf-rouge); }
.fac-top__nom { min-width: 0; font-size: .8rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fac-top__nom small { margin-left: .4rem; font-size: .66rem; font-weight: 400; color: var(--raf-doux2); }
.fac-top__val { font-size: .8rem; font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.fac-top__part { height: 3px; }

.fac-liste {
    list-style: none; margin: 0; padding: 0; border: 1px solid var(--raf-bord); border-radius: 14px;
    background: #fff; overflow: hidden;
}
.fac-liste--groupe { border: 0; border-top: 1px solid var(--raf-bord); border-radius: 0; animation: none; }
.fac-ligne + .fac-ligne { border-top: 1px solid #f0f1f4; }
.fac-ligne__tete {
    width: 100%; display: grid; grid-template-columns: 34px 1fr auto; gap: .65rem; align-items: center;
    padding: .5rem .75rem; border: 0; background: none; font: inherit; color: inherit; text-align: left; cursor: pointer;
    transition: background .15s;
}
.fac-ligne__tete:hover, .fac-ligne--ouverte .fac-ligne__tete { background: #fafbfc; }
.fac-date { display: flex; flex-direction: column; align-items: center; line-height: 1.05; }
.fac-date b { font-size: .92rem; font-weight: 800; }
.fac-date small { font-size: .55rem; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; color: var(--raf-doux); }
.fac-milieu { min-width: 0; display: flex; flex-direction: column; gap: .05rem; }
.fac-client { font-size: .82rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fac-refs { font-family: ui-monospace, Consolas, monospace; font-size: .66rem; color: var(--raf-doux2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fac-montant { display: flex; align-items: center; gap: .35rem; font-size: .86rem; font-weight: 800; font-variant-numeric: tabular-nums; white-space: nowrap; }
.fac-ligne--avoir .fac-montant { color: var(--raf-rouge); }
.fac-badge { padding: .05rem .4rem; border-radius: 999px; background: #fee2e2; color: #991b1b; font-size: .58rem; font-weight: 800; letter-spacing: .04em; text-transform: uppercase; }
.fac-alerte { color: #d97706; font-size: .8rem; }
.fac-plus {
    display: grid; grid-template-columns: auto 1fr; gap: .2rem .9rem; margin: 0;
    padding: .5rem .9rem .7rem calc(.75rem + 34px + .65rem); background: var(--raf-fond); font-size: .74rem;
}
.fac-plus dt { color: var(--raf-doux); white-space: nowrap; }
.fac-plus dd { margin: 0; font-weight: 600; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.fac-plus__alerte { color: #92400e; }
.fac-avoirs { font-family: inherit; font-weight: 600; color: var(--raf-rouge); }

/* Cellule « Montant facturé » cliquable des tableaux de primes (chef de centre, direction). */
.fac-ouvrir {
    display: inline-flex; align-items: center; gap: .3rem; padding: .15rem .45rem; margin: -.15rem -.45rem;
    border: 0; border-radius: 8px; background: none; font: inherit; color: inherit; cursor: pointer;
    text-decoration: underline dotted rgba(198,30,38,.45); text-underline-offset: 3px;
}
.fac-ouvrir:hover, .fac-ouvrir:focus-visible { background: #fdecec; color: #C61E26; outline: none; }
.fac-ouvrir i { font-size: .72rem; color: #C61E26; }

@media (max-width: 640px) {
    .fac-plus { padding-left: 1rem; grid-template-columns: 1fr; gap: 0; }
    .fac-top__ligne:nth-of-type(n+4) { display: none; }   /* téléphone : les trois premiers clients */
    .fac-plus dt { margin-top: .3rem; font-size: .66rem; }
}
