/* ===== Gestion Cyber : feuille de style ===== */
:root {
    --fond: #f1f5f9;
    --carte: #ffffff;
    --texte: #0f172a;
    --doux: #64748b;
    --bord: #e2e8f0;
    --bord-fort: #cbd5e1;
    --primaire: #4f46e5;
    --primaire-fonce: #4338ca;
    --primaire-clair: #eef2ff;
    --orange: #f97316;
    --vert: #16a34a;
    --vert-clair: #dcfce7;
    --rouge: #dc2626;
    --rouge-clair: #fee2e2;
    --jaune: #b45309;
    --jaune-clair: #fef3c7;
    --bleu-clair: #e0f2fe;
    --bleu: #0369a1;
    --sidebar: #0f172a;
    --sidebar-texte: #94a3b8;
    --rayon: 12px;
    --ombre: 0 1px 2px rgba(15, 23, 42, .04), 0 2px 8px rgba(15, 23, 42, .05);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font-family: "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif; background: var(--fond); color: var(--texte); font-size: 14.5px; line-height: 1.45; }
a { color: var(--primaire); text-decoration: none; }
a:hover { text-decoration: underline; }
h2 { font-size: 15px; margin: 26px 0 12px; color: var(--doux); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
h3 { margin: 0 0 14px; font-size: 16px; display: flex; align-items: center; gap: 8px; }
.ic { width: 18px; height: 18px; flex-shrink: 0; }

/* ----- Structure ----- */
.app { display: flex; min-height: 100vh; }
.sidebar { width: 248px; background: var(--sidebar); color: var(--sidebar-texte); position: fixed; inset: 0 auto 0 0; overflow-y: auto; z-index: 30; transition: transform .2s; }
.contenu { flex: 1; margin-left: 248px; min-width: 0; display: flex; flex-direction: column; }
main { padding: 22px 26px 40px; max-width: 1400px; width: 100%; }
.pied { margin-top: auto; padding: 16px 26px; color: var(--doux); font-size: 12px; }

.marque { display: flex; align-items: center; gap: 12px; padding: 20px 18px; color: #fff; text-decoration: none !important; border-bottom: 1px solid rgba(255,255,255,.06); }
.marque-logo { width: 38px; height: 38px; border-radius: 10px; background: linear-gradient(135deg, var(--orange), #fb923c); display: grid; place-items: center; color: #fff; }
.marque-logo .ic { width: 20px; height: 20px; }
.marque-texte { display: flex; flex-direction: column; min-width: 0; }
.marque-texte b { font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.marque-texte small { color: var(--sidebar-texte); font-size: 12px; }
.sidebar nav { padding: 10px 12px 24px; }
.nav-groupe { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: #475569; padding: 16px 10px 6px; font-weight: 600; }
.nav-lien { display: flex; align-items: center; gap: 12px; padding: 9px 12px; border-radius: 8px; color: var(--sidebar-texte); font-weight: 500; text-decoration: none !important; margin-bottom: 2px; }
.nav-lien:hover { background: rgba(255,255,255,.06); color: #fff; }
.nav-lien.actif { background: var(--primaire); color: #fff; box-shadow: 0 4px 12px rgba(79,70,229,.35); }

.topbar { position: sticky; top: 0; z-index: 20; background: rgba(255,255,255,.92); backdrop-filter: blur(8px); border-bottom: 1px solid var(--bord); display: flex; align-items: center; gap: 16px; padding: 12px 26px; }
.topbar-titre { flex: 1; min-width: 0; }
.topbar-titre h1 { margin: 0; font-size: 20px; line-height: 1.2; }
.topbar-titre small { color: var(--doux); font-size: 12.5px; }
.topbar-actions { display: flex; align-items: center; gap: 14px; }
.pointage { margin: 0; }
.cloche { position: relative; color: var(--doux); display: grid; place-items: center; width: 38px; height: 38px; border-radius: 10px; }
.cloche:hover { background: var(--fond); color: var(--texte); }
.cloche .ic { width: 20px; height: 20px; }
.pastille-nb { position: absolute; top: 3px; right: 2px; background: var(--rouge); color: #fff; font-size: 10.5px; font-weight: 700; border-radius: 10px; padding: 0 5px; min-width: 17px; text-align: center; line-height: 17px; }
.profil { display: flex; align-items: center; gap: 10px; padding-left: 14px; border-left: 1px solid var(--bord); }
.profil form { margin: 0; }
.avatar { width: 36px; height: 36px; border-radius: 50%; background: var(--primaire-clair); color: var(--primaire); font-weight: 700; display: grid; place-items: center; font-size: 13px; text-decoration: none !important; }
.profil-texte { display: flex; flex-direction: column; line-height: 1.2; }
.profil-texte small { color: var(--doux); font-size: 12px; }
.burger { display: none; }
.voile { display: none; }

/* ----- Cartes ----- */
.carte { background: var(--carte); border: 1px solid var(--bord); border-radius: var(--rayon); padding: 18px 20px; margin-bottom: 18px; box-shadow: var(--ombre); }
.carte-tableau { padding: 0; overflow: hidden; }
.carte-tableau > h3, .carte-tableau > .entete-carte { padding: 16px 20px 0; }
.carte-tableau .defile { padding: 0; }
.entete-carte { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px 16px; margin-bottom: 14px; }
.entete-carte h3 { margin: 0; }
.grille-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.grille-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px; }
.grille-2 > .carte, .grille-3 > .carte { margin-bottom: 0; }
.grille-2 + *, .grille-3 + * { margin-top: 18px; }
.defile { overflow-x: auto; }

/* ----- Indicateurs ----- */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 14px; margin-bottom: 18px; }
.kpi { background: var(--carte); border: 1px solid var(--bord); border-radius: var(--rayon); padding: 16px; display: flex; gap: 14px; align-items: flex-start; box-shadow: var(--ombre); position: relative; overflow: hidden; }
.kpi-icone { width: 42px; height: 42px; border-radius: 11px; display: grid; place-items: center; background: var(--primaire-clair); color: var(--primaire); flex-shrink: 0; }
.kpi-icone .ic { width: 21px; height: 21px; }
.kpi-corps { display: flex; flex-direction: column; min-width: 0; }
.kpi-corps span { color: var(--doux); font-size: 12.5px; font-weight: 500; }
.kpi-corps b { font-size: 21px; font-weight: 700; letter-spacing: -.01em; white-space: nowrap; }
.kpi-corps small { color: var(--doux); font-size: 12px; }
.kpi.vert .kpi-icone { background: var(--vert-clair); color: var(--vert); }
.kpi.rouge .kpi-icone { background: var(--rouge-clair); color: var(--rouge); }
.kpi.orange .kpi-icone { background: #ffedd5; color: var(--orange); }
.kpi.bleu .kpi-icone { background: var(--bleu-clair); color: var(--bleu); }
.kpi-puce { border-left: 4px solid var(--couleur, var(--primaire)); }
.kpi-puce .kpi-icone { background: color-mix(in srgb, var(--couleur) 14%, white); color: var(--couleur); }
.kpi-grand b { font-size: 28px; }
.negatif { color: var(--rouge) !important; }
.positif { color: var(--vert) !important; }

/* ----- Alertes ----- */
.alerte { display: flex; align-items: center; gap: 10px; padding: 11px 14px; border-radius: 10px; margin-bottom: 12px; border: 1px solid transparent; font-weight: 500; }
.alerte-succes { background: var(--vert-clair); color: #166534; border-color: #bbf7d0; }
.alerte-erreur, .alerte-danger { background: var(--rouge-clair); color: #991b1b; border-color: #fecaca; }
.alerte-attention { background: var(--jaune-clair); color: #92400e; border-color: #fde68a; }
.alerte-info { background: var(--bleu-clair); color: #075985; border-color: #bae6fd; }
.liste-alertes { display: grid; gap: 8px; }
.liste-alertes a { display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-radius: 10px; text-decoration: none !important; font-weight: 500; }
.liste-alertes .danger { background: var(--rouge-clair); color: #991b1b; }
.liste-alertes .attention { background: var(--jaune-clair); color: #92400e; }
.liste-alertes .info { background: var(--bleu-clair); color: #075985; }

/* ----- Tableaux ----- */
table { width: 100%; border-collapse: collapse; }
th, td { padding: 10px 14px; border-bottom: 1px solid var(--bord); text-align: left; vertical-align: middle; }
th { background: #f8fafc; font-size: 12px; color: var(--doux); font-weight: 600; text-transform: uppercase; letter-spacing: .03em; white-space: nowrap; }
tbody tr:hover td, table tr:hover td { background: #fafbff; }
tr:last-child td { border-bottom: 0; }
.num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.vide { text-align: center; color: var(--doux); padding: 28px; }
td form { margin: 0; display: inline; }
.actions { white-space: nowrap; display: flex; gap: 10px; align-items: center; justify-content: flex-end; }
tfoot td { font-weight: 700; background: #f8fafc; }

/* ----- Formulaires ----- */
label { display: flex; flex-direction: column; gap: 5px; font-size: 12.5px; color: var(--doux); font-weight: 500; }
input, select, textarea { font: inherit; font-size: 14.5px; padding: 9px 11px; border: 1px solid var(--bord-fort); border-radius: 8px; background: #fff; color: var(--texte); min-width: 0; width: 100%; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primaire); box-shadow: 0 0 0 3px rgba(79,70,229,.15); }
input[type=checkbox] { width: 18px; height: 18px; accent-color: var(--primaire); }
input[type=color] { padding: 3px; height: 40px; width: 64px; }
input.petit { width: 120px; }
.case { flex-direction: row; align-items: center; gap: 8px; color: var(--texte); font-size: 14px; }
.formulaire { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 14px; align-items: end; }
.formulaire .large { grid-column: span 2; }
.formulaire .plein { grid-column: 1 / -1; }
.formulaire-actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.filtre { display: flex; flex-wrap: wrap; gap: 12px 18px; align-items: end; }
.filtre label { min-width: 150px; }
.raccourcis { display: flex; flex-wrap: wrap; gap: 6px; }
.raccourcis a { padding: 6px 11px; border-radius: 20px; background: var(--fond); color: var(--texte); font-size: 13px; text-decoration: none; }
.raccourcis a:hover { background: var(--primaire-clair); color: var(--primaire); }
.aide { color: var(--doux); font-size: 13px; margin: 6px 0; }
.total-live { font-size: 22px; font-weight: 700; color: var(--primaire); }

/* ----- Boutons ----- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; background: var(--primaire); color: #fff; border: 1px solid var(--primaire); border-radius: 8px; padding: 9px 16px; font: inherit; font-weight: 600; cursor: pointer; text-decoration: none !important; white-space: nowrap; transition: background .15s, box-shadow .15s; }
.btn:hover { background: var(--primaire-fonce); box-shadow: 0 4px 12px rgba(79,70,229,.25); }
.btn-secondaire { background: #fff; color: var(--texte); border-color: var(--bord-fort); }
.btn-secondaire:hover { background: var(--fond); box-shadow: none; }
.btn-succes { background: var(--vert); border-color: var(--vert); }
.btn-succes:hover { background: #15803d; box-shadow: 0 4px 12px rgba(22,163,74,.25); }
.btn-danger { background: var(--rouge); border-color: var(--rouge); }
.btn-danger:hover { background: #b91c1c; }
.btn-whatsapp { background: #25d366; border-color: #25d366; }
.btn-whatsapp:hover { background: #1ebe5b; }
.btn-petit { padding: 6px 11px; font-size: 13px; }
.btn-grand { padding: 12px 22px; font-size: 15.5px; }
.btn-lien { background: none; border: 0; color: var(--primaire); cursor: pointer; font: inherit; font-size: 13px; padding: 0; font-weight: 600; }
.btn-lien:hover { text-decoration: underline; }
.btn-lien.danger { color: var(--rouge); }
.btn-icone { background: none; border: 0; color: var(--doux); cursor: pointer; padding: 7px; border-radius: 8px; display: grid; place-items: center; }
.btn-icone:hover { background: var(--fond); color: var(--rouge); }

/* ----- Étiquettes ----- */
.badge { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 600; padding: 3px 9px; border-radius: 20px; white-space: nowrap; background: var(--fond); color: var(--doux); }
.badge-vert { background: var(--vert-clair); color: #166534; }
.badge-rouge { background: var(--rouge-clair); color: #991b1b; }
.badge-jaune { background: var(--jaune-clair); color: #92400e; }
.badge-bleu { background: var(--bleu-clair); color: #075985; }
.badge-violet { background: var(--primaire-clair); color: var(--primaire); }
.pastille { display: inline-block; width: 10px; height: 10px; border-radius: 50%; vertical-align: middle; margin-right: 4px; }

/* ----- Onglets ----- */
.onglets { display: flex; gap: 4px; flex-wrap: wrap; border-bottom: 1px solid var(--bord); margin-bottom: 18px; }
.onglets a { padding: 10px 16px; color: var(--doux); font-weight: 600; border-bottom: 2px solid transparent; margin-bottom: -1px; text-decoration: none !important; }
.onglets a:hover { color: var(--texte); }
.onglets a.actif { color: var(--primaire); border-bottom-color: var(--primaire); }

/* ----- Opérations ----- */
.cache { display: none !important; }
.recap { padding: 0 20px 14px; display: flex; flex-wrap: wrap; gap: 8px; }
tr.annulee td { color: var(--doux); text-decoration: line-through; text-decoration-color: rgba(220,38,38,.5); }
tr.annulee td .badge, tr.annulee td.actions { text-decoration: none; }
.bloc-piece.requis { color: var(--rouge); }
.bloc-piece.requis select, .bloc-piece.requis input { border-color: var(--rouge); }
.droits td:not(:first-child), .droits th:not(:first-child) { text-align: center; color: var(--vert); font-weight: 700; }

/* ----- Comptage des billets ----- */
.billetage { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 8px; margin: 4px 0 14px; }
.billetage label { font-size: 12px; }
.billetage input { padding: 7px 8px; }

/* ----- Graphe ----- */
.graphe { display: flex; align-items: flex-end; gap: 6px; height: 210px; padding-top: 10px; }
.graphe-col { flex: 1; display: flex; flex-direction: column; align-items: center; height: 100%; min-width: 0; }
.graphe-col small { font-size: 10.5px; color: var(--doux); margin-top: 6px; }
.barres { flex: 1; width: 100%; display: flex; align-items: flex-end; justify-content: center; gap: 2px; }
.barres div { width: 42%; min-height: 2px; border-radius: 4px 4px 0 0; }
.barre-e { background: var(--primaire); }
.barre-s { background: #fca5a5; }
.legende { font-size: 13px; color: var(--doux); display: flex; gap: 16px; align-items: center; margin: 12px 0 0; }
.legende span { display: inline-flex; align-items: center; gap: 6px; }
.legende i { width: 12px; height: 12px; border-radius: 3px; display: inline-block; }

/* ----- Jauges ----- */
.jauge { margin-bottom: 12px; }
.jauge-lib { display: flex; justify-content: space-between; font-size: 14px; margin-bottom: 5px; }
.jauge-fond { background: var(--fond); border-radius: 6px; height: 8px; overflow: hidden; }
.jauge-val { background: var(--primaire); height: 100%; border-radius: 6px; }
.jauge-val.rouge { background: var(--rouge); }


/* ----- Caisse ----- */
.cash { font-size: 34px; font-weight: 800; letter-spacing: -.02em; }
.detail-flux td { padding: 8px 0; border-bottom: 1px dashed var(--bord); }
.detail-flux tr:hover td { background: none; }
.ecart-live { font-size: 18px; font-weight: 700; }

/* ----- Résumé ----- */
.resume-texte { white-space: pre-wrap; background: #f8fafc; border: 1px solid var(--bord); border-radius: 10px; padding: 16px; font-family: Consolas, "Courier New", monospace; font-size: 14px; margin: 0 0 14px; }

/* ----- Connexion / installation ----- */
.page-login { min-height: 100vh; display: grid; place-items: center; padding: 16px; background: radial-gradient(circle at 20% 10%, #312e81 0, transparent 45%), radial-gradient(circle at 90% 90%, #7c2d12 0, transparent 40%), var(--sidebar); }
.boite-login { width: 100%; max-width: 400px; background: #fff; border-radius: 16px; padding: 32px; box-shadow: 0 20px 60px rgba(0,0,0,.35); display: flex; flex-direction: column; gap: 16px; }
.boite-login .marque-logo { width: 52px; height: 52px; margin: 0 auto; border-radius: 14px; }
.boite-login .marque-logo .ic { width: 26px; height: 26px; }
.boite-login h1 { text-align: center; margin: 0; font-size: 22px; }
.boite-login p.sous-titre { text-align: center; color: var(--doux); margin: -8px 0 4px; }
.boite-login .btn { width: 100%; padding: 12px; }

/* ----- Reçu ----- */
.page-recu { background: var(--fond); padding: 24px 12px; }
.recu { max-width: 380px; margin: 0 auto; background: #fff; border-radius: 12px; padding: 24px; box-shadow: var(--ombre); font-size: 14px; }
.recu-tete { text-align: center; border-bottom: 1px dashed var(--bord-fort); padding-bottom: 12px; margin-bottom: 12px; }
.recu-tete b { font-size: 18px; display: block; }
.recu table td { padding: 5px 0; border: 0; }
.recu .total { font-size: 18px; font-weight: 800; border-top: 1px dashed var(--bord-fort); }
.recu-pied { text-align: center; color: var(--doux); font-size: 12.5px; border-top: 1px dashed var(--bord-fort); margin-top: 12px; padding-top: 12px; }
.recu-actions { max-width: 380px; margin: 16px auto 0; display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }

/* ----- Responsive ----- */
@media (max-width: 1100px) {
    .grille-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 900px) {
    .sidebar { transform: translateX(-100%); }
    .menu-ouvert .sidebar { transform: none; box-shadow: 0 0 40px rgba(0,0,0,.4); }
    .menu-ouvert .voile { display: block; position: fixed; inset: 0; background: rgba(15,23,42,.45); z-index: 25; }
    .contenu { margin-left: 0; }
    .burger { display: grid; place-items: center; background: none; border: 1px solid var(--bord); border-radius: 9px; width: 40px; height: 40px; cursor: pointer; color: var(--texte); }
    .grille-2, .grille-3 { grid-template-columns: minmax(0, 1fr); }
    .profil-texte, .pointage span { display: none; }
    main { padding: 16px; }
    .topbar { padding: 10px 16px; gap: 10px; }
}
@media (max-width: 560px) {
    .topbar-titre small { display: none; }
    .topbar { gap: 8px; }
    .topbar-titre h1 { font-size: 16px; overflow-wrap: anywhere; }
    .topbar-actions { gap: 6px; }
    .formulaire .large { grid-column: auto; }
    .kpi-corps b { font-size: 19px; }
    .graphe { gap: 3px; }
    .graphe-col small { white-space: nowrap; }
    .graphe-col:nth-child(even) small { visibility: hidden; }
    .profil { padding-left: 8px; gap: 6px; }
}

/* ----- Impression ----- */
@media print {
    body { background: #fff; }
    .sidebar, .topbar, .pied, form, .btn, .recu-actions, .onglets, .raccourcis, .burger { display: none !important; }
    .contenu { margin: 0; }
    main { padding: 0; }
    .carte, .kpi { box-shadow: none; break-inside: avoid; }
    .page-recu { padding: 0; background: #fff; }
    .recu { box-shadow: none; max-width: 80mm; padding: 0; }
}

/* ----- Bilan des fonds (disposition du fichier Excel) ----- */
.tableau-bilan th.groupe-sources { background: var(--bleu-clair); color: var(--bleu); text-align: center; }
.tableau-bilan th.groupe-utilisation { background: #ffedd5; color: #9a3412; text-align: center; }
.tableau-bilan td, .tableau-bilan th { white-space: nowrap; }
details summary { cursor: pointer; }
.kpi-corps b.kpi-texte { font-size: 16px; white-space: normal; }

/* ----- Feuille du bilan, présentée comme le fichier Excel ----- */
table.feuille-excel { width: auto; border-collapse: collapse; font-family: Calibri, "Segoe UI", Arial, sans-serif; font-size: 13.5px; }
table.feuille-excel th, table.feuille-excel td { border: 1px solid #d4d4d8; padding: 5px 9px; text-align: right; white-space: nowrap; text-transform: none; letter-spacing: 0; }
table.feuille-excel tr.f-groupes th { background: #fff2cc; color: #000; font-weight: 700; font-size: 13.5px; text-align: left; }
table.feuille-excel tr.f-titres th { background: #e2efda; color: #000; font-weight: 700; font-size: 12.5px; text-align: center; }
table.feuille-excel td.f-date { text-align: left; }
table.feuille-excel td.f-date small { display: block; color: var(--doux); font-size: 11px; }
table.feuille-excel td.f-total { font-weight: 700; }
table.feuille-excel td.f-texte { text-align: left; }
table.feuille-excel .f-neg { color: var(--rouge); }
table.feuille-excel td.f-ecart { background: #fde2e2; font-weight: 700; }
table.feuille-excel tr:hover td { background: #f8fafc; }
table.feuille-excel tr.f-jour td { background: #fffbea; border-top: 2px solid var(--primaire); }
table.feuille-excel tr.f-jour td.f-calc { background: #f1f5f9; }
table.feuille-excel tr.f-jour td.f-ecart { background: #fde2e2; }
table.feuille-excel td input { width: 110px; padding: 4px 6px; border-radius: 4px; text-align: right; font-size: 13.5px; border-color: #cbd5e1; }
table.feuille-excel td input.modifie { background: #fef08a; border-color: #ca8a04; font-weight: 700; }
.feuille-pied { display: flex; gap: 16px; align-items: center; flex-wrap: wrap; padding: 14px 20px 0; }
p.feuille-pied { padding-bottom: 16px; }
.zone-danger { border-color: #fca5a5; }
.zone-danger h3 { color: var(--rouge); }
table.tableau-utilisation td input { width: 190px; }
table.feuille-excel td.f-plus { color: var(--vert); font-weight: 700; }
table.feuille-excel td.f-juste { color: var(--vert); }

/* ----- Sources des fonds : une ligne par partenaire avec ses boutons ----- */
table.tableau-sources tr.groupe td { background: #fff2cc; font-weight: 700; font-size: 12px; letter-spacing: .04em; padding: 6px 14px; }
table.tableau-sources tr.sous-total td { font-weight: 700; background: #f8fafc; }
table.tableau-sources tr.total-general td { background: #e2efda; font-size: 15px; }
table.tableau-sources td small { display: block; }
table.tableau-sources td.part { min-width: 120px; }
table.tableau-sources td.part .jauge-fond { height: 7px; }
table.tableau-sources .jauge-val { background: var(--primaire); }
table.tableau-sources .boutons-source { display: flex; gap: 6px; justify-content: flex-end; flex-wrap: nowrap; }
table.tableau-sources .boutons-source .btn { white-space: nowrap; }
table.tableau-sources tr.ligne-saisie td { background: #fffbea; border-left: 3px solid var(--primaire); }
table.tableau-sources .detail-propres { display: flex; flex-wrap: wrap; gap: 6px 18px; font-size: 12.5px; color: var(--doux); background: #fcfcfd; }
table.tableau-sources td.activite small { margin-top: 2px; }
table.tableau-sources td.part { min-width: 90px; width: 110px; }
table.tableau-sources td.activite, table.tableau-sources td.activite small { white-space: nowrap; }
table.tableau-utilisation td.f-date small, table.tableau-utilisation td.activite small { display: block; }
table.tableau-utilisation td input { width: 160px; }
table.tableau-utilisation .boutons-source { justify-content: flex-start; }
table.tableau-utilisation tr.groupe td, table.tableau-utilisation tr.ligne-saisie td, table.tableau-utilisation tr.sous-total td:first-child { text-align: left; }
table.tableau-utilisation tr.ligne-saisie label { text-align: left; }
table.tableau-utilisation .boutons-source { flex-wrap: wrap; max-width: 300px; }
table.tableau-utilisation td input { width: 140px; }

/* ----- Historique : un jour par ligne, détail au clic ----- */
.raccourcis-periode { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; padding: 12px 20px 14px; }
table.tableau-historique td small { display: block; font-size: 12px; }
table.tableau-historique tr.ligne-jour { cursor: pointer; }
table.tableau-historique tr.ligne-jour:hover td { background: var(--primaire-clair); }
table.tableau-historique tr.ligne-detail > td { background: #fcfcfd; border-left: 3px solid var(--primaire); }
.detail-jour { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.detail-jour h4 { margin: 4px 0 8px; font-size: 13px; text-transform: uppercase; letter-spacing: .04em; color: var(--doux); }
.detail-jour table th, .detail-jour table td { padding: 5px 10px; }
.detail-jour table tr.sous-total td { font-weight: 700; background: #f1f5f9; }
@media (max-width: 760px) { .detail-jour { grid-template-columns: minmax(0, 1fr); } }
/* Feuille : la colonne DATE reste visible quand on fait défiler vers la droite */
table.feuille-excel tr > :first-child { position: sticky; left: 0; z-index: 1; }
table.feuille-excel tr > td:first-child { background: #fff; }
table.feuille-excel tr.f-jour > td:first-child { background: #fffbea; }

/* ----- Historique : saisie de lignes ----- */
.ajout-jours { margin: 0 20px 16px; padding: 14px 16px; background: #fffbea; border: 1px solid #fde68a; border-radius: 10px; }
table.grille-saisie td input { width: 105px; padding: 4px 6px; font-size: 13px; }
table.grille-saisie td input[type=date] { width: 140px; }
.formulaire .ligne-champ, label.ligne-champ { display: flex !important; flex-direction: row !important; justify-content: space-between; align-items: center; gap: 10px; padding: 3px 0; font-size: 13.5px; color: var(--texte); max-width: 380px; }
.ligne-champ input { width: 150px; text-align: right; padding: 5px 8px; }

/* =====================================================================
   Thème « cahier de comptes »
   Encre bleue pour la structure, rouge pour les manques, vert pour ce qui
   est juste, lignes réglées et totaux soulignés deux fois comme dans un
   livre de caisse. Police IBM Plex Sans (fichiers locaux : fonctionne sans
   internet), chiffres alignés en colonnes.
   ===================================================================== */
@font-face { font-family: "Plex"; src: url("fonts/ibm-plex-sans-latin-400-normal.woff2") format("woff2"); font-weight: 400; font-style: normal; font-display: swap; }
@font-face { font-family: "Plex"; src: url("fonts/ibm-plex-sans-latin-500-normal.woff2") format("woff2"); font-weight: 500; font-style: normal; font-display: swap; }
@font-face { font-family: "Plex"; src: url("fonts/ibm-plex-sans-latin-600-normal.woff2") format("woff2"); font-weight: 600; font-style: normal; font-display: swap; }
@font-face { font-family: "Plex"; src: url("fonts/ibm-plex-sans-latin-700-normal.woff2") format("woff2"); font-weight: 700; font-style: normal; font-display: swap; }

:root {
    --fond: #f2f4f8;            /* papier */
    --carte: #ffffff;
    --texte: #17203a;           /* encre */
    --doux: #5a6478;
    --bord: #dde2ea;            /* filet */
    --bord-fort: #c4cbd7;
    --primaire: #2447a8;        /* encre bleue */
    --primaire-fonce: #1a3684;
    --primaire-clair: #e9eef9;
    --reglure: #d5dff0;         /* lignes du cahier */
    --marge: #e7a9a3;           /* trait rouge de la marge */
    --rouge: #b42318;           /* encre rouge : manques */
    --rouge-clair: #fdecea;
    --vert: #1f7a4d;
    --vert-clair: #e4f3ea;
    --jaune: #a15c07;
    --jaune-clair: #fdf3dc;
    --bleu: #1d5c8f;
    --bleu-clair: #e6f0f8;
    --sidebar: #15244a;         /* encre de nuit */
    --sidebar-texte: #aab5cf;
    --rayon: 10px;
    --ombre: 0 1px 0 rgba(21, 36, 74, .04);
}

body { font-family: "Plex", "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif; font-size: 14.5px; line-height: 1.5;
       font-variant-numeric: tabular-nums lining-nums; -webkit-font-smoothing: antialiased; }
h2 { text-transform: none; letter-spacing: 0; color: var(--texte); font-size: 16px; font-weight: 600; margin: 28px 0 12px; }
h3 { font-weight: 600; letter-spacing: -.005em; }
h3 .ic { color: var(--primaire); }
::selection { background: #c9d6f5; }

/* Focus clavier toujours visible */
a:focus-visible, button:focus-visible, .btn:focus-visible, summary:focus-visible { outline: 2px solid var(--primaire); outline-offset: 2px; border-radius: 6px; }
input:focus, select:focus, textarea:focus { border-color: var(--primaire); box-shadow: 0 0 0 3px rgba(36, 71, 168, .16); }
input[type=checkbox], input[type=radio] { accent-color: var(--primaire); }

/* ----- Menu ----- */
.sidebar { background: var(--sidebar); }
.marque { border-bottom-color: rgba(255,255,255,.08); }
.marque-logo { background: #e8742a; border-radius: 9px; }
.nav-groupe { text-transform: none; letter-spacing: 0; font-size: 12px; color: #7d89a8; font-weight: 500; padding: 18px 12px 6px; }
.nav-lien { border-radius: 7px; padding: 8px 12px; font-weight: 500; }
.nav-lien:hover { background: rgba(255,255,255,.07); }
.nav-lien.actif { background: rgba(255,255,255,.11); color: #fff; box-shadow: inset 3px 0 0 #8fb0ff; }
.nav-lien.actif .ic { color: #8fb0ff; }

/* ----- Barre du haut ----- */
.topbar { background: rgba(255,255,255,.94); }
.topbar-titre h1 { font-weight: 600; letter-spacing: -.01em; font-size: 21px; }
.avatar { background: var(--primaire-clair); color: var(--primaire); }

/* ----- Cartes et indicateurs ----- */
.carte, .kpi { box-shadow: var(--ombre); border-color: var(--bord); }
.kpi { padding: 15px 16px; }
.kpi-icone { border-radius: 8px; width: 40px; height: 40px; }
.kpi-corps span { font-size: 13px; }
.kpi-corps b { font-weight: 600; font-size: 22px; letter-spacing: -.015em; }
.kpi-grand b { font-size: 30px; }
a.kpi { color: inherit; text-decoration: none !important; transition: border-color .15s; }
a.kpi:hover { border-color: var(--bord-fort); }
.kpi.rouge b:not(.kpi-texte) { color: var(--rouge); }
.cash { font-weight: 700; letter-spacing: -.025em; }

/* ----- Tableaux : lignes réglées ----- */
th { text-transform: none; letter-spacing: 0; font-size: 12.5px; color: #4a5468; background: #f6f8fb; font-weight: 600; }
th, td { border-bottom-color: #e6eaf1; }
tbody tr:hover td, table tr:hover td { background: #f7f9fd; }
.num, td.num b { font-variant-numeric: tabular-nums; }
.vide { padding: 32px; }

/* ----- Boutons ----- */
.btn { border-radius: 7px; font-weight: 600; transition: background .15s, border-color .15s; }
.btn:hover, .btn-succes:hover { box-shadow: none; }
.btn-succes { background: var(--vert); border-color: var(--vert); }
.btn-succes:hover { background: #18633e; }
.btn-danger { background: var(--rouge); border-color: var(--rouge); }
.btn-danger:hover { background: #921c13; }
.btn-secondaire { color: var(--texte); }
.btn-secondaire:hover { border-color: var(--primaire); color: var(--primaire); background: #fff; }
.btn-lien { color: var(--primaire); }

/* ----- Étiquettes et alertes ----- */
.badge { border-radius: 6px; font-weight: 600; padding: 2px 8px; }
.badge-vert { background: var(--vert-clair); color: #17603c; }
.badge-rouge { background: var(--rouge-clair); color: #8f1c13; }
.badge-jaune { background: var(--jaune-clair); color: #7c4505; }
.badge-bleu { background: var(--primaire-clair); color: var(--primaire-fonce); }
.alerte { border-radius: 8px; }
.alerte-succes { background: var(--vert-clair); color: #17603c; border-color: #bfe3cd; }
.alerte-erreur, .alerte-danger { background: var(--rouge-clair); color: #8f1c13; border-color: #f4c3bd; }
.alerte-info { background: var(--primaire-clair); color: var(--primaire-fonce); border-color: #ccd8f2; }
.liste-alertes .info { background: var(--primaire-clair); color: var(--primaire-fonce); }
.liste-alertes .danger { background: var(--rouge-clair); color: #8f1c13; }

/* ----- Onglets ----- */
.onglets { gap: 2px; }
.onglets a { padding: 10px 14px; font-weight: 500; }
.onglets a.actif { font-weight: 600; color: var(--primaire); border-bottom-color: var(--primaire); }

/* ----- La feuille du bilan : un vrai livre de caisse ----- */
table.feuille-excel { font-family: "Plex", "Segoe UI", Arial, sans-serif; font-size: 13.5px; background: #fff; }
table.feuille-excel th, table.feuille-excel td { border: 0; border-bottom: 1px solid var(--reglure); padding: 6px 10px; }
table.feuille-excel tr.f-groupes th { background: var(--primaire); color: #fff; font-weight: 600; font-size: 13px; border-right: 1px solid rgba(255,255,255,.25); }
table.feuille-excel tr.f-titres th { background: var(--primaire-clair); color: var(--primaire-fonce); font-weight: 600; font-size: 12px; border-bottom: 2px solid var(--primaire); }
/* Le trait rouge de la marge, après la date */
table.feuille-excel tr > :first-child { border-right: 2px solid var(--marge); }
table.feuille-excel td.f-date { color: var(--texte); font-weight: 500; }
/* Les colonnes de total : séparées, en encre forte */
table.feuille-excel td.f-total { font-weight: 600; color: var(--primaire-fonce); background: #f5f7fc; border-left: 1px solid var(--reglure); border-right: 1px solid var(--reglure); }
table.feuille-excel .f-neg { color: var(--rouge); }
table.feuille-excel td.f-ecart { background: var(--rouge-clair); color: var(--rouge); font-weight: 700; }
table.feuille-excel tr:hover td { background: #f7f9fd; }
table.feuille-excel tr:hover td.f-total { background: #eef2fa; }
/* La ligne du jour : à remplir, totaux soulignés deux fois */
table.feuille-excel tr.f-jour td { background: #fffdf5; border-top: 2px solid var(--primaire); border-bottom: 3px double var(--primaire); }
table.feuille-excel tr.f-jour td.f-calc { background: #f5f7fc; }
table.feuille-excel tr.f-jour td.f-ecart { background: var(--rouge-clair); }
table.feuille-excel td input { border-color: var(--reglure); background: #fff; font-variant-numeric: tabular-nums; }
table.feuille-excel td input:focus { border-color: var(--primaire); }
table.feuille-excel td input.modifie { background: #fff4c2; border-color: #c98a06; }
table.feuille-excel tr > td:first-child { background: #fff; }
table.feuille-excel tr.f-jour > td:first-child { background: #fffdf5; }

/* Sources et utilisation : groupes en encre, total général souligné deux fois */
table.tableau-sources tr.groupe td { background: var(--primaire-clair); color: var(--primaire-fonce); letter-spacing: 0; font-size: 12.5px; font-weight: 600; }
table.tableau-sources tr.sous-total td { background: #f6f8fb; border-top: 1px solid var(--bord-fort); }
table.tableau-sources tr.total-general td { background: #fff; color: var(--primaire-fonce); border-top: 1px solid var(--primaire); border-bottom: 3px double var(--primaire); font-size: 15px; }
table.tableau-sources tr.ligne-saisie td { background: #fffdf5; border-left: 3px solid var(--primaire); }
table.tableau-sources .jauge-val { background: var(--primaire); }
.ajout-jours { background: #fffdf5; border-color: #ead9a6; }
table.tableau-historique tr.ligne-jour:hover td { background: #f3f6fc; }
table.tableau-historique tr.ligne-detail > td { background: #fbfcfe; border-left-color: var(--primaire); }
.detail-jour table tr.sous-total td { background: #fff; border-top: 1px solid var(--primaire); border-bottom: 3px double var(--primaire); }

/* Le détail d'une caisse : lignes réglées, total souligné */
.detail-flux td { border-bottom: 1px solid var(--reglure); }

/* ----- Connexion : une page de cahier ----- */
/* ----- Connexion : blanc en haut, bleu encre (comme le menu) en bas, liseré aux couleurs des
         opérateurs au milieu, boîte blanche à cheval sur les deux ----- */
.page-login {
    --bandeau: 50vh;            /* le passage du bleu au gris se fait au milieu de l'écran */
    place-items: center; padding: 32px 16px;
    background:
        linear-gradient(90deg, #f26f21 0 25%, #1f5fbf 25% 50%, #19bfe6 50% 75%, #d8232a 75% 100%) 0 var(--bandeau) / 100% 4px no-repeat,
        linear-gradient(180deg, #ffffff 0 var(--bandeau), var(--sidebar) var(--bandeau)) no-repeat;
    background-color: var(--sidebar);   /* blanc en haut, bleu encre en bas */
}
.page-login > .boite-login { border-radius: 12px; border: 1px solid var(--bord); border-top: 4px solid var(--primaire);
    box-shadow: 0 22px 48px rgba(21, 36, 74, .18), 0 2px 6px rgba(21, 36, 74, .06); }
.boite-login .boite-login { border: 0; box-shadow: none; }

.boite-login h1, .boite-login h2 { letter-spacing: -.01em; }

/* ----- Graphe ----- */
.barre-e { background: var(--primaire); }
.barre-s { background: #e9a29b; }

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { transition: none !important; animation: none !important; scroll-behavior: auto !important; }
}
.kpi.kpi-puce { border-left: 4px solid var(--couleur, var(--primaire)); }

/* ----- Logo GES-3TC ----- */
img.logo-geskati { background: none; padding: 0; display: block; border-radius: 9px; }
.marque { transition: background .2s; }
.marque:hover { background: rgba(255,255,255,.04); }
.marque img.logo-geskati { width: 44px; height: 44px; flex: none; border-radius: 11px; box-shadow: 0 0 0 1px rgba(255,255,255,.18), 0 6px 16px rgba(47,107,234,.45); transition: transform .2s; }
.marque:hover img.logo-geskati { transform: translateY(-1px) scale(1.04); }
.marque-texte b { font-size: 17px; font-weight: 800; letter-spacing: .03em; }
.page-login { background: radial-gradient(circle at 15% 10%, rgba(47,107,234,.60) 0, transparent 48%), radial-gradient(circle at 88% 90%, rgba(242,89,29,.42) 0, transparent 42%), #101c44; }
.page-login > .boite-login { border: 0; border-top: 4px solid #f2591d; border-radius: 16px; box-shadow: 0 24px 60px rgba(5,10,30,.5); }
.boite-login img.logo-geskati { width: 96px; height: 96px; border-radius: 23px; margin: 0 auto 4px; box-shadow: 0 12px 28px rgba(47,107,234,.42); }
.boite-login h1 { font-size: 28px; font-weight: 800; letter-spacing: .02em; color: #15244a; }
.page-login .btn { background: linear-gradient(135deg, #2f6bea, #1a3a8f); border-color: #1a3a8f; color: #fff; }
.page-login .btn:hover { background: linear-gradient(135deg, #3a76f2, #1f459f); }

/* ----- Bouton « Payer » des crédits clients ----- */
details.payer { display: inline-block; }
details.payer > summary { list-style: none; cursor: pointer; }
details.payer > summary::-webkit-details-marker { display: none; }
details.payer[open] > summary { background: #15803d; }
.payer-form { display: flex; gap: 8px; align-items: flex-end; margin-top: 8px; flex-wrap: wrap; }
.payer-form label { display: flex; flex-direction: column; font-size: 12px; gap: 3px; }
.payer-form input { width: 100px; }
details.payer[open] { min-width: 120px; }

/* =====================================================================
   Mise en page : rien ne déborde, écrans plus compacts et lisibles
   (ajouté le 25/11/2026 ; ne change que l'affichage)
   ===================================================================== */
main { padding: 18px 22px 32px; }
.carte { padding: 16px 18px; margin-bottom: 16px; min-width: 0; }
.carte-tableau { padding: 0; }
.carte-tableau > h3, .carte-tableau > .entete-carte { padding: 14px 18px 0; }
.grille-2, .grille-3 { gap: 16px; }
.grille-2 > *, .grille-3 > * { min-width: 0; }
h2 { margin: 22px 0 10px; }
h3 { margin-bottom: 12px; }

/* ----- Onglets : une barre claire, qui défile sur petit écran au lieu de s'empiler ----- */
.onglets { position: relative; background: var(--carte); border: 1px solid var(--bord); border-radius: var(--rayon); padding: 4px; gap: 4px; margin-bottom: 16px; }
.onglets a { border-bottom: 0; margin: 0; border-radius: 7px; padding: 8px 14px; white-space: nowrap; color: var(--doux); }
.onglets a:hover { background: var(--fond); color: var(--texte); }
.onglets a.actif { background: var(--primaire); color: #fff; }

/* ----- Indicateurs : le montant tient toujours dans sa case ----- */
.kpis { grid-template-columns: repeat(auto-fit, minmax(min(220px, 100%), 1fr)); gap: 12px; margin-bottom: 16px; }
.kpi { padding: 13px 14px; gap: 12px; min-width: 0; }
.kpi-icone { width: 36px; height: 36px; }
.kpi-corps { flex: 1; min-width: 0; container-type: inline-size; }
.kpi-corps span, .kpi-corps small { overflow-wrap: anywhere; }
.kpi-corps b { font-size: 20px; font-size: min(22px, 11cqi); }
.kpi-grand b { font-size: 26px; font-size: min(30px, 12cqi); }
.kpi-corps b.kpi-texte { font-size: 15px; }

/* ----- Tableaux : plus serrés, ombre sur le côté quand il reste des colonnes à voir ----- */
th, td { padding: 8px 12px; }
td { overflow-wrap: break-word; }
.defile { max-width: 100%; overflow-x: auto; overscroll-behavior-x: contain; scrollbar-width: thin;
    background:
        linear-gradient(to right, #fff 30%, rgba(255,255,255,0)) 0 0 / 40px 100% no-repeat local,
        linear-gradient(to left, #fff 30%, rgba(255,255,255,0)) 100% 0 / 40px 100% no-repeat local,
        radial-gradient(farthest-side at 0 50%, rgba(21,36,74,.16), transparent) 0 0 / 12px 100% no-repeat scroll,
        radial-gradient(farthest-side at 100% 50%, rgba(21,36,74,.16), transparent) 100% 0 / 12px 100% no-repeat scroll; }
/* La colonne des boutons reste une vraie cellule (avant, elle sortait de la ligne) */
td.actions { display: table-cell; text-align: right; white-space: nowrap; }
td.actions > * + * { margin-left: 10px; }
td.actions form { display: inline; }
td.actions details { display: inline-block; text-align: left; white-space: normal; }

/* ----- Formulaires : les champs ne débordent jamais de la carte ----- */
.formulaire { grid-template-columns: repeat(auto-fill, minmax(min(170px, 100%), 1fr)); gap: 12px; }
.formulaire-actions { min-width: 0; }
input, select, textarea { padding: 8px 10px; }
.filtre { gap: 10px 12px; }
.filtre label { min-width: 0; flex: 0 1 165px; }
.entete-carte { margin-bottom: 12px; }
.entete-carte > .filtre { flex: 0 1 auto; margin-left: auto; }
.ligne-champ input { max-width: 50%; }

/* ----- Tablette ----- */
@media (max-width: 900px) {
    main { padding: 14px; }
    .onglets { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
    .onglets::-webkit-scrollbar { display: none; }
    .entete-carte > .filtre { margin-left: 0; flex: 1 1 100%; }
}
/* ----- Téléphone ----- */
@media (max-width: 560px) {
    body { font-size: 14px; }
    main { padding: 10px; }
    .carte { padding: 14px; border-radius: 9px; }
    .carte-tableau { padding: 0; }
    .carte-tableau > h3, .carte-tableau > .entete-carte { padding: 12px 14px 0; }
    .grille-2, .grille-3, .kpis { gap: 10px; }
    th, td { padding: 7px 9px; font-size: 13.5px; }
    .formulaire .large { grid-column: 1 / -1; }
    .filtre label { flex: 1 1 140px; }
    .formulaire-actions .btn, .feuille-pied .btn { flex: 1 1 auto; }
    .btn-grand { padding: 11px 16px; font-size: 15px; }
    .cash { font-size: 28px; }
    .detail-jour { gap: 12px; }
    .ajout-jours { margin: 0 10px 12px; padding: 12px; }
    .feuille-pied { padding: 12px 14px 0; }
    p.feuille-pied { padding-bottom: 12px; }
}

/* Cellules sur une seule ligne (le tableau défile sur le côté au lieu d'empiler les mots) ;
   seules les colonnes de texte libre (motif, note, détail) passent à la ligne */
td { white-space: nowrap; }
td.texte { white-space: normal; min-width: 160px; max-width: 380px; }
td details, td .aide, td p, .detail-flux td, .detail-jour td, td.detail-propres, tr.ligne-detail > td { white-space: normal; }

/* ----- Bilan : les jours passés de la feuille sont modifiables, sans perdre l'aspect du cahier ----- */
table.feuille-excel tr.f-passee td input { width: 100px; border-color: var(--reglure); background: #fff; cursor: text; }
table.feuille-excel tr.f-passee td input:hover { border-color: var(--reglure); background: #fff; }
table.feuille-excel tr.f-passee td input:focus { border-color: var(--primaire); background: #fff; }
table.feuille-excel tr.f-passee td input.modifie { background: #fff4c2; border-color: #c98a06; font-weight: 700; }
table.feuille-excel tr.f-modifiee > td { background: #fffdf5; }
table.feuille-excel tr.f-modifiee > td:first-child { box-shadow: inset 3px 0 0 #c98a06; }
.feuille-pied .motif-feuille { flex: 1 1 280px; max-width: 420px; }

/* ----- Crédits clients ----- */
details.liste-debiteurs > summary { list-style: none; padding: 14px 18px; }
details.liste-debiteurs > summary::-webkit-details-marker { display: none; }
details.liste-debiteurs > summary h3 { margin: 0; }
details.liste-debiteurs > summary h3::after { content: "▸ afficher"; margin-left: auto; font-size: 12.5px; font-weight: 500; color: var(--primaire); }
details.liste-debiteurs[open] > summary h3::after { content: "▾ masquer"; }
td small.aide { display: inline; }

/* =====================================================================
   Bilan des fonds : volets figés comme dans Excel
   Le tableau défile dans sa propre zone : les titres restent en haut,
   la première colonne (date, partenaire) reste à gauche.
   ===================================================================== */
.defile.fige { max-height: calc(100vh - 150px); max-height: calc(100dvh - 150px); overflow: auto; overscroll-behavior: contain; position: relative; }
.defile.fige > table { border-collapse: separate; border-spacing: 0; }
/* Ligne(s) de titres figée(s) en haut */
.defile.fige > table > tbody > tr:first-child > th,
.defile.fige > table > thead > tr:first-child > th { position: sticky; top: 0; z-index: 3; }
.defile.fige > table.feuille-excel > tbody > tr.f-groupes + tr.f-titres > th { position: sticky; top: var(--haut-titres, 30px); z-index: 3; }
/* Première colonne figée à gauche */
.defile.fige > table > tbody > tr > :first-child { position: sticky; left: 0; z-index: 2; }
.defile.fige > table > tbody > tr > td:first-child { background: #fff; box-shadow: 1px 0 0 var(--bord); }
.defile.fige > table > tbody > tr:first-child > th:first-child,
.defile.fige > table.feuille-excel > tbody > tr.f-groupes + tr.f-titres > th:first-child { z-index: 5; }
.defile.fige > table.feuille-excel tr.f-jour > td:first-child { background: #fffdf5; }
.defile.fige > table.feuille-excel tr.f-modifiee > td:first-child { background: #fffdf5; }
/* Les lignes de groupe (PARTENAIRES, FONDS PROPRES…) gardent leur libellé visible */
.defile.fige > table.tableau-sources tr.groupe > td:first-child { background: var(--primaire-clair); }
.defile.fige > table.tableau-sources tr.sous-total > td:first-child { background: #f6f8fb; }
.defile.fige > table.tableau-sources tr.total-general > td:first-child { background: #fff; }
.defile.fige > table.tableau-sources tr.ligne-saisie > td:first-child { background: #fffdf5; }
/* Ligne du jour : toujours sous les yeux en bas de la feuille */
.defile.fige > table.feuille-excel tr.f-jour > td { position: sticky; bottom: 0; z-index: 2; box-shadow: 0 -2px 0 var(--primaire); }
.defile.fige > table.feuille-excel tr.f-jour > td:first-child { z-index: 3; left: 0; }

/* Feuille plus serrée : on voit plus de colonnes d'un coup */
table.feuille-excel th, table.feuille-excel td { padding: 4px 6px; }
table.feuille-excel tr.f-titres th { white-space: normal; min-width: 70px; max-width: 110px; line-height: 1.2; vertical-align: bottom; }
table.feuille-excel td input, table.feuille-excel tr.f-passee td input { width: 92px; padding: 3px 5px; font-size: 13px; }
table.feuille-excel td.f-date { font-size: 12.5px; }

@media (max-width: 560px) {
    .defile.fige { max-height: calc(100vh - 110px); max-height: calc(100dvh - 110px); }
    table.feuille-excel { font-size: 12.5px; }
    table.feuille-excel td input, table.feuille-excel tr.f-passee td input { width: 78px; font-size: 12.5px; }
    table.feuille-excel td.f-date { font-size: 11.5px; }
    table.feuille-excel td.f-date small { display: none; }
}

/* ----- Bilan : feuille compacte (au moins 25 lignes visibles) ----- */
.onglets a { padding: 6px 12px; font-size: 13.5px; }
.onglets { margin-bottom: 10px; }
.carte-feuille { margin-bottom: 10px; }
.entete-feuille { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 6px 12px; padding: 8px 12px; border-bottom: 1px solid var(--bord); }
.filtre-ligne { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; margin: 0; }
.filtre-ligne label { flex-direction: row; align-items: center; gap: 6px; font-size: 13px; }
.filtre-ligne input[type=date] { width: 140px; padding: 4px 8px; font-size: 13px; }
.outils-feuille { display: flex; gap: 6px; }
.carte-feuille .defile.fige { max-height: calc(100vh - 205px); max-height: calc(100dvh - 205px); }
table.feuille-excel th, table.feuille-excel td { padding: 2px 5px; line-height: 1.25; }
table.feuille-excel td input, table.feuille-excel tr.f-passee td input { height: 23px; padding: 1px 5px; font-size: 12.5px; border-radius: 4px; }
table.feuille-excel tr.f-groupes th { padding: 4px 6px; font-size: 12px; }
table.feuille-excel tr.f-titres th { font-size: 11px; padding: 3px 5px; }
.carte-feuille .feuille-pied { padding: 8px 12px; gap: 8px 14px; }
.carte-feuille .feuille-pied .btn { padding: 7px 14px; }
.aide-feuille { padding: 0 12px 10px; font-size: 13px; }
.aide-feuille summary { color: var(--primaire); font-weight: 500; }
.aide-feuille p { margin: 6px 0 0; }

/* Plein écran : la feuille occupe toute la fenêtre (touche Échap pour sortir) */
body.feuille-plein { overflow: hidden; }
body.feuille-plein .carte-feuille { position: fixed; inset: 0; z-index: 60; margin: 0; border-radius: 0; border: 0; display: flex; flex-direction: column; }
body.feuille-plein .carte-feuille > form { display: flex; flex-direction: column; flex: 1; min-height: 0; }
body.feuille-plein .carte-feuille .defile.fige { max-height: none; flex: 1; min-height: 0; }
body.feuille-plein .aide-feuille { display: none; }

@media (max-width: 560px) {
    .entete-feuille { padding: 6px 8px; }
    .filtre-ligne input[type=date] { width: 128px; }
    .outils-feuille .btn span { display: none; }
    .carte-feuille .defile.fige { max-height: calc(100dvh - 160px); }
}
/* Lignes de 22 px : 25 lignes et plus sur un écran de PC ordinaire */
table.feuille-excel th, table.feuille-excel td { padding: 1px 4px; }
table.feuille-excel td input, table.feuille-excel tr.f-passee td input { height: 20px; padding: 0 4px; line-height: 18px; }
.carte-feuille .defile.fige { max-height: calc(100vh - 285px); max-height: calc(100dvh - 285px); min-height: 300px; }
.carte-feuille .feuille-pied { padding: 6px 12px; }
.aide-feuille { padding: 0 12px 6px; }

/* =====================================================================
   Bilan des fonds : tous les onglets compacts (vue d'ensemble sans trop défiler)
   ===================================================================== */
.page-bilan { font-size: 13.5px; }
.page-bilan .kpis { grid-template-columns: repeat(auto-fit, minmax(min(190px, 100%), 1fr)); gap: 8px; margin-bottom: 10px; }
.page-bilan .kpi { padding: 7px 10px; gap: 9px; align-items: center; }
.page-bilan .kpi-icone { width: 28px; height: 28px; border-radius: 7px; }
.page-bilan .kpi-icone .ic { width: 16px; height: 16px; }
.page-bilan .kpi-corps span { font-size: 11.5px; }
.page-bilan .kpi-corps b { font-size: 17px; font-size: min(18px, 10cqi); line-height: 1.2; }
.page-bilan .kpi-corps b.kpi-texte { font-size: 13.5px; }
.page-bilan .kpi-corps small { font-size: 11px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.page-bilan .carte { padding: 10px 12px; margin-bottom: 10px; }
.page-bilan .carte-tableau { padding: 0; }
.page-bilan .carte-tableau > h3, .page-bilan .carte-tableau > .entete-carte { padding: 8px 12px 0; }
.page-bilan h3 { font-size: 14.5px; margin-bottom: 8px; }
.page-bilan .entete-carte { margin-bottom: 6px; gap: 6px 12px; }
.page-bilan .grille-2, .page-bilan .grille-3 { gap: 10px; }
.page-bilan .grille-2 + *, .page-bilan .grille-3 + * { margin-top: 10px; }

/* Tableaux serrés */
.page-bilan th, .page-bilan td { padding: 3px 8px; font-size: 13px; }
.page-bilan th { font-size: 11.5px; }
.page-bilan td small, .page-bilan td .aide { font-size: 11.5px; }
.page-bilan .vide { padding: 14px; }
.page-bilan .btn-petit { padding: 3px 8px; font-size: 12px; gap: 4px; }
.page-bilan .btn-petit .ic { width: 14px; height: 14px; }
.page-bilan .boutons-source { gap: 4px; }
.page-bilan table.tableau-sources tr.groupe td { padding: 3px 8px; font-size: 11.5px; }
.page-bilan table.tableau-sources tr.total-general td { font-size: 14px; }
.page-bilan table.tableau-sources td.part { width: 90px; }
.page-bilan .jauge-fond { height: 5px; }
.page-bilan .defile.fige { max-height: calc(100vh - 230px); max-height: calc(100dvh - 230px); }

/* Formulaires et filtres serrés */
.page-bilan .formulaire { gap: 8px; grid-template-columns: repeat(auto-fill, minmax(min(150px, 100%), 1fr)); }
.page-bilan input, .page-bilan select, .page-bilan textarea { padding: 4px 8px; font-size: 13px; border-radius: 6px; }
.page-bilan label { font-size: 12px; gap: 3px; }
.page-bilan .btn { padding: 6px 12px; font-size: 13px; }
.page-bilan .btn.btn-petit { padding: 3px 8px; font-size: 12px; }
.page-bilan .carte-tableau > form.formulaire, .page-bilan .carte-tableau .ligne-saisie form.formulaire { padding: 8px 12px 10px !important; }
.page-bilan .entete-carte .filtre { gap: 6px 10px; }
.page-bilan .entete-carte .filtre label { flex-direction: row; align-items: center; gap: 6px; flex: 0 0 auto; }
.page-bilan .entete-carte .filtre input[type=date] { width: 140px; }
.page-bilan .raccourcis-periode { padding: 6px 12px 8px; gap: 6px; }
.page-bilan .ajout-jours { margin: 0 12px 8px; padding: 8px 10px; }
.page-bilan .feuille-pied { padding: 6px 12px; gap: 8px 12px; }
.page-bilan p.feuille-pied { padding-bottom: 8px; }
.page-bilan p.aide { margin: 4px 0; font-size: 12.5px; }
.page-bilan .carte-tableau > p.aide { padding: 0 12px 6px !important; }
.page-bilan .alerte { padding: 7px 10px; margin-bottom: 8px; font-size: 13px; }
.page-bilan .detail-jour { gap: 10px; }
.page-bilan table.tableau-historique td small { font-size: 11px; }

/* Textes d'aide repliés */
.aide-pliee { padding: 0 12px 6px; font-size: 12.5px; }
.carte:not(.carte-tableau) > .aide-pliee { padding: 0; }
.aide-pliee > summary { color: var(--primaire); font-weight: 500; cursor: pointer; width: max-content; }
.aide-pliee > p { margin: 4px 0 0; }

@media (max-width: 560px) {
    .page-bilan .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .page-bilan .kpi-icone { display: none; }
    .page-bilan .kpi-corps b { font-size: min(16px, 11cqi); }
    .page-bilan .defile.fige { max-height: calc(100dvh - 170px); }
    .page-bilan .entete-carte .filtre input[type=date] { width: 128px; }
}
.page-bilan .carte-feuille .defile.fige { max-height: calc(100vh - 285px); max-height: calc(100dvh - 285px); }
@media (max-width: 560px) { .page-bilan .carte-feuille .defile.fige { max-height: calc(100dvh - 160px); } }
/* Sources des fonds : une ligne par partenaire, sur une seule hauteur */
.page-bilan table.tableau-sources td.activite small { display: inline; margin: 0 0 0 8px; }
.page-bilan table.tableau-sources td.part { white-space: nowrap; }
.page-bilan table.tableau-sources td.part .jauge-fond { display: inline-block; width: 50px; vertical-align: middle; margin-right: 6px; }
.page-bilan table.tableau-sources td.part small { display: inline; }
.page-bilan table.tableau-sources td.part { width: 110px; }

/* Bilan : indicateurs sur une seule ligne fine « libellé : montant » */
.page-bilan .kpis { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.page-bilan .kpi { flex: 1 1 auto; padding: 4px 10px; gap: 6px; border-radius: 7px; min-height: 0; }
.page-bilan .kpi-icone, .page-bilan .kpi-corps small { display: none; }
.page-bilan .kpi-corps { flex-direction: row; align-items: baseline; gap: 6px; container-type: normal; white-space: nowrap; }
.page-bilan .kpi-corps span { font-size: 12px; }
.page-bilan .kpi-corps span::after { content: " :"; }
.page-bilan .kpi-corps b, .page-bilan .kpi-corps b.kpi-texte { font-size: 14.5px; line-height: 1.3; }
.page-bilan .kpi.bleu { border-left: 3px solid var(--bleu); }
.page-bilan .kpi.orange { border-left: 3px solid var(--orange); }
.page-bilan .kpi.vert { border-left: 3px solid var(--vert); }
.page-bilan .kpi.rouge { border-left: 3px solid var(--rouge); }
.page-bilan .kpi.rouge b.kpi-texte { color: var(--rouge); }
@media (max-width: 560px) {
    .page-bilan .kpis { display: grid; grid-template-columns: 1fr; gap: 4px; }
    .page-bilan .kpi-corps { justify-content: space-between; width: 100%; }
}

/* Les lignes de TOTAL restent visibles en bas du tableau, sans défiler */
.defile.fige > table > tbody > tr.total-general > td { position: sticky; bottom: 0; z-index: 2; box-shadow: 0 -2px 0 var(--primaire); }
.defile.fige > table > tbody > tr.total-general > td:first-child { z-index: 3; }
