/* ch.587 — DÉPENSES : en-tête collé (R122), onglet « 📥 Factures reçues » (cartes à colonnes FIXES, motif ch.592),
   fenêtre de détail (R87/R120). Charte claire, ⛔ aucune variable CSS. Adaptations d'écran en @media uniquement. */

/* ── En-tête du module (titre ⊕ onglets) collé en haut de #pageContent — R122 ── */
.dep587-entete { position: sticky; top: -24px; z-index: 20; margin: -24px -24px 0; padding: 24px 24px 0;
  background: #F3F4F6; border-bottom: 1px solid transparent; transition: box-shadow .15s, border-color .15s; }
.dep587-entete.dep587-ombre { border-bottom-color: #E2E8F0; box-shadow: 0 6px 14px -8px rgba(15, 23, 42, .18); }
.dep587-onglets > button { white-space: nowrap; }

/* ── Barre de l'onglet (filtres ⊕ titres de colonnes), collée SOUS l'en-tête (top posé par le JS, hauteur mesurée) ── */
.dep587-barre { position: sticky; top: 0; z-index: 19; background: #F3F4F6; padding: 0 0 8px; }
.dep587-filtres { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 8px; }
.dep587-filtre { display: inline-flex; align-items: center; gap: 6px; min-height: 36px; padding: 0 14px; border: 1px solid #E2E8F0;
  border-radius: 18px; background: #FFFFFF; color: #475569; font-size: 12px; font-weight: 600; cursor: pointer; }
.dep587-filtre.dep587-actif { background: #34D399; border-color: #34D399; color: #0F172A; }
.dep587-nb { display: inline-block; min-width: 20px; padding: 1px 6px; border-radius: 10px; background: #F1F5F9; color: #334155;
  font-size: 11px; font-weight: 700; text-align: center; }
.dep587-filtre.dep587-actif .dep587-nb { background: #FFFFFF; }

/* ── Grille FIXE commune aux titres et aux cartes : seule la colonne fournisseur est flexible ── */
.dep587-entetes, .dep587-carte { display: grid; grid-template-columns: minmax(0, 1fr) 96px 440px 130px; column-gap: 14px; align-items: center; }
.dep587-entetes { padding: 0 13px; font-size: 10px; font-weight: 700; color: #64748B; text-transform: uppercase; letter-spacing: .03em; }
.dep587-droite { text-align: right; }
.dep587-liste { display: flex; flex-direction: column; gap: 6px; padding: 2px 0 12px; }
.dep587-carte { min-height: 64px; box-sizing: border-box; padding: 8px 12px; background: #FFFFFF; border: 1px solid #E2E8F0;
  border-radius: 12px; cursor: pointer; transition: background .15s, box-shadow .15s; }
.dep587-carte:hover { background: #F8FAFC; box-shadow: 0 2px 10px rgba(15, 23, 42, .06); }
.dep587-carte:focus-visible { outline: 2px solid #22D3EE; outline-offset: 1px; }
.dep587-ident { min-width: 0; }
.dep587-fourn { font-size: 13px; font-weight: 700; color: #1E293B; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dep587-num { font-size: 12px; color: #64748B; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 2px; }
.dep587-date { font-size: 12px; color: #475569; white-space: nowrap; }
.dep587-etat { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 6px; min-width: 0; }
.dep587-pastille { display: inline-flex; align-items: center; padding: 3px 9px; border-radius: 12px; font-size: 10px; font-weight: 700;
  white-space: nowrap; border: none; line-height: 1.4; font-family: inherit; }
button.dep587-doublon { background: #FEF3C7; color: #92400E; border: 1px solid #FCD34D; cursor: help; position: relative; }
.dep587-montants { text-align: right; white-space: nowrap; min-width: 0; }
.dep587-ttc { font-size: 13px; font-weight: 700; color: #1E293B; }
.dep587-sous { font-size: 10px; color: #94A3B8; }
.dep587-bulle { position: fixed; z-index: 2000; background: #1E293B; color: #FFFFFF; font-size: 12px; line-height: 1.45;
  padding: 8px 11px; border-radius: 8px; box-shadow: 0 6px 20px rgba(15, 23, 42, .25); box-sizing: border-box; }

/* ── Bandeaux, états vides, blocs ── */
.dep587-bandeau { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 0 0 8px; padding: 9px 12px; border-radius: 10px; font-size: 12px; line-height: 1.45; }
.dep587-info { background: #ECFEFF; border: 1px solid #A5F3FC; color: #0E7490; }
.dep587-ambre { background: #FFFBEB; border: 1px solid #FDE68A; color: #92400E; }
.dep587-rouge { background: #FEF2F2; border: 1px solid #FECACA; color: #991B1B; }
.dep587-lien { min-height: 32px; padding: 0 10px; border: 1px solid #A5F3FC; border-radius: 8px; background: #FFFFFF; color: #0E7490; font-size: 12px; font-weight: 600; cursor: pointer; }
.dep587-vide { padding: 40px 16px; text-align: center; color: #94A3B8; font-size: 13px; }
.dep587-erreur { padding: 14px 16px; border: 1px solid #FECACA; background: #FEF2F2; border-radius: 12px; color: #991B1B; font-size: 13px; }
.dep587-bloc { background: #FFFFFF; border: 1px solid #E2E8F0; border-radius: 12px; padding: 12px 14px; margin-top: 10px; }
.dep587-titre { font-size: 12px; font-weight: 700; color: #1E293B; margin-bottom: 4px; }
.dep587-expl { font-size: 12px; color: #64748B; margin: 0 0 8px; line-height: 1.45; }
.dep587-ligne-abs { display: grid; grid-template-columns: minmax(0, 1fr) 96px 110px 200px; column-gap: 12px; align-items: center; width: 100%;
  min-height: 44px; padding: 6px 10px; border: 1px solid #F1F5F9; border-radius: 10px; background: #F8FAFC; margin-top: 6px;
  font-size: 12px; color: #475569; text-align: left; cursor: pointer; box-sizing: border-box; font-family: inherit; }
.dep587-ligne-abs:hover { background: #F1F5F9; }
.dep587-abs-f { font-weight: 700; color: #1E293B; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dep587-abs-s { color: #1E40AF; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ── Fenêtre de détail (montée au body, z 9400 < 10000, FileViewer 10010 au-dessus) ── */
.dep587-overlay { position: fixed; inset: 0; z-index: 9400; background: rgba(15, 23, 42, .45); display: flex; align-items: center;
  justify-content: center; padding: 16px; box-sizing: border-box; }
.dep587-boite { background: #FFFFFF; border-radius: 16px; width: min(640px, 96vw); max-height: 90vh; display: flex; flex-direction: column;
  overflow: hidden; box-shadow: 0 24px 70px rgba(15, 23, 42, .22); box-sizing: border-box; }
.dep587-tete { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 14px 18px; border-bottom: 1px solid #E2E8F0; background: #F8FAFC; }
.dep587-x { min-width: 44px; min-height: 44px; background: none; border: none; font-size: 20px; cursor: pointer; color: #64748B; border-radius: 8px; }
.dep587-x:hover { background: #F1F5F9; }
.dep587-corps { flex: 1 1 auto; overflow-y: auto; overflow-x: hidden; padding: 14px 18px; }
.dep587-etat-detail { margin-bottom: 12px; }
.dep587-grille { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 10px 14px; margin-bottom: 12px; }
.dep587-kv { min-width: 0; }
.dep587-k { font-size: 10px; color: #94A3B8; font-weight: 700; text-transform: uppercase; letter-spacing: .03em; }
.dep587-v { font-size: 13px; color: #1E293B; overflow-wrap: anywhere; }
.dep587-pied { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; justify-content: flex-end; padding: 12px 18px; border-top: 1px solid #E2E8F0; background: #F8FAFC; }
.dep587-action { display: inline-flex; align-items: center; gap: 7px; min-height: 40px; padding: 0 14px; border-radius: 9px; border: 1px solid #E2E8F0;
  background: #FFFFFF; color: #475569; font-size: 13px; font-weight: 600; cursor: pointer; }
.dep587-principal { background: #34D399; border-color: #34D399; color: #0F172A; }

/* ── ≤ 1024 px : gouttière du hamburger (56 px), cibles tactiles ≥ 44 px ── */
@media (max-width: 1024px) {
  .dep587-entete { top: -56px; margin-top: -56px; padding-top: 56px; }
  .dep587-filtre, .dep587-lien, .dep587-action { min-height: 44px; }
  button.dep587-doublon::after { content: ''; position: absolute; left: 0; right: 0; top: -12px; bottom: -12px; }
  .dep587-onglets.rsp-page-tabs > button[onclick*="switchTab"] { max-width: none; }
}

/* ── ~768 px : pastilles sous l'identité, sur toute la largeur ── */
@media (max-width: 900px) {
  .dep587-entetes { display: none; }
  .dep587-carte { grid-template-columns: minmax(0, 1fr) 90px 120px; grid-template-areas: "ident date montants" "etat etat etat"; row-gap: 6px; }
  .dep587-ident { grid-area: ident; } .dep587-date { grid-area: date; } .dep587-etat { grid-area: etat; } .dep587-montants { grid-area: montants; }
  .dep587-ligne-abs { grid-template-columns: minmax(0, 1fr) 90px 100px; }
  .dep587-abs-s { grid-column: 1 / -1; }
}

/* ── ~375 px : 3 rangées ── */
@media (max-width: 600px) {
  .dep587-carte { grid-template-columns: minmax(0, 1fr) 110px; grid-template-areas: "ident montants" "date date" "etat etat"; column-gap: 8px; row-gap: 4px; padding: 8px 10px; }
  .dep587-grille { grid-template-columns: minmax(0, 1fr); }
  .dep587-overlay { padding: 6px; }
  .dep587-boite { width: 100%; max-height: 96vh; }
  .dep587-tete, .dep587-corps, .dep587-pied { padding-left: 12px; padding-right: 12px; }
  .dep587-ligne-abs { grid-template-columns: minmax(0, 1fr) auto; }
  .dep587-ligne-abs > span:nth-child(2) { grid-column: 1; grid-row: 2; }
}
