/* ============ FADABA — Plateforme de gestion ============ */
:root {
    --noir: #17150f;
    --noir-2: #23201a;
    --noir-3: #2e2a22;
    --or: #ba841e;
    --or-clair: #d9b25f;
    --or-pale: #f7efe0;
    --fond: #f6f5f1;
    --carte: #ffffff;
    --encre: #1c1a15;
    --encre-2: #5c5850;
    --sourdine: #928d82;
    --ligne: #e8e5de;
    --bleu: #2a78d6;
    --orange: #eb6834;
    --aqua: #1baf7a;
    --jaune: #eda100;
    --bon: #0ca30c;
    --bon-texte: #006300;
    --alerte: #d03b3b;
    --attention: #b07708;
    --r: 14px;
    --ombre: 0 1px 2px rgba(23,21,15,.04), 0 4px 14px rgba(23,21,15,.05);
    --ombre-h: 0 2px 4px rgba(23,21,15,.06), 0 10px 24px rgba(23,21,15,.09);
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
    margin: 0;
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    background: var(--fond);
    color: var(--encre);
    font-size: 15px;
    line-height: 1.45;
}
a { color: var(--encre); text-decoration: none; }

/* ---------- Structure ---------- */
.app { display: flex; min-height: 100vh; }
.sidebar {
    width: 240px; flex-shrink: 0;
    background: linear-gradient(175deg, var(--noir-2) 0%, var(--noir) 60%);
    color: #cfc9bc;
    display: flex; flex-direction: column;
    position: sticky; top: 0; height: 100vh;
}
.marque { display: flex; align-items: center; gap: 11px; padding: 22px 20px 18px; }
.marque-logo {
    width: 38px; height: 38px; flex-shrink: 0;
    display: inline-flex; align-items: center; justify-content: center;
}
.marque-logo img { width: 100%; height: 100%; object-fit: contain;
    filter: drop-shadow(0 1px 2px rgba(0,0,0,.35)); }
.marque-nom {
    font-family: Georgia, "Times New Roman", serif;
    font-weight: 700; letter-spacing: .14em; color: #f4efe4; font-size: 17px;
}
.nav-lat { flex: 1; padding: 8px 12px; display: flex; flex-direction: column; gap: 3px; }
.nav-lat a {
    display: flex; align-items: center; gap: 12px;
    padding: 10px 13px; border-radius: 10px;
    color: #a9a294; font-weight: 500; font-size: 14.5px;
    border-left: 3px solid transparent;
    transition: background .15s, color .15s;
}
.nav-lat a svg { width: 20px; height: 20px; }
.nav-lat a:hover { background: rgba(255,255,255,.05); color: #f4efe4; }
.nav-lat a.actif {
    background: rgba(217,178,95,.12);
    color: #f4efe4;
    border-left-color: var(--or-clair);
}
.nav-lat a.actif svg { color: var(--or-clair); }
.sidebar-pied { padding: 15px 20px 20px; border-top: 1px solid rgba(255,255,255,.07); font-size: 13px; }
.u-nom { color: #f4efe4; font-weight: 600; }
.u-role { color: var(--or-clair); margin-bottom: 9px; font-size: 12px; letter-spacing: .03em; }
.deconnexion { color: #a9a294; font-size: 13px; }
.deconnexion:hover { color: #f4efe4; }

.principal { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.contenu { flex: 1; padding: 28px 32px 44px; max-width: 1180px; width: 100%; margin: 0 auto; }

.entete-mobile { display: none; }
.nav-bas { display: none; }

/* ---------- Titres & sections ---------- */
.page-titre { display: flex; flex-wrap: wrap; align-items: baseline; gap: 8px 14px; margin: 0 0 4px; }
.page-titre h1 { font-size: 22px; margin: 0; font-weight: 700; letter-spacing: -.01em; }
.page-sous { color: var(--encre-2); margin: 0 0 22px; font-size: 14px; }
.section-titre { font-size: 15px; font-weight: 700; margin: 28px 0 12px; color: var(--encre); display: flex; align-items: center; gap: 8px; }
.section-titre::before { content: ""; width: 4px; height: 15px; border-radius: 2px; background: var(--or); }
.section-titre small { color: var(--sourdine); font-weight: 500; }

/* ---------- Cartes & grilles ---------- */
.grille { display: grid; gap: 14px; }
.g-kpi { grid-template-columns: repeat(4, 1fr); }
.g-2 { grid-template-columns: 1fr 1fr; }
.g-3 { grid-template-columns: repeat(3, 1fr); }
.carte {
    background: var(--carte);
    border: 1px solid var(--ligne);
    border-radius: var(--r);
    padding: 17px 19px;
    box-shadow: var(--ombre);
}
a.carte { transition: box-shadow .18s, transform .18s; }
a.carte:hover { box-shadow: var(--ombre-h); transform: translateY(-1px); }
.carte h3 { margin: 0 0 12px; font-size: 14px; font-weight: 700; }
.carte h3 small { color: var(--sourdine); font-weight: 500; }

/* KPI */
.kpi .lib { font-size: 12.5px; color: var(--encre-2); font-weight: 600; letter-spacing: .01em; }
.kpi .val { font-size: 22px; font-weight: 750; margin-top: 4px; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.kpi .comp { font-size: 12.5px; margin-top: 4px; color: var(--sourdine); }
.kpi .comp .hausse { color: var(--bon-texte); font-weight: 600; }
.kpi .comp .baisse { color: var(--alerte); font-weight: 600; }
.kpi .picto {
    float: right; width: 36px; height: 36px; border-radius: 10px;
    display: inline-flex; align-items: center; justify-content: center;
}
.kpi .picto svg { width: 18px; height: 18px; }
.p-bleu { background: #e8f1fc; color: #1c5cab; }
.p-orange { background: #fdeee7; color: #b34715; }
.p-aqua { background: #e4f6ef; color: #0d7d56; }
.p-marine { background: var(--or-pale); color: #8a5f0e; }

/* Badges */
.badge {
    display: inline-block; padding: 2px 9px; border-radius: 999px;
    font-size: 12px; font-weight: 600; white-space: nowrap;
}
.b-ok { background: #e7f5e7; color: var(--bon-texte); }
.b-retard { background: #fdf3dc; color: var(--attention); }
.b-impaye { background: #fbe9e9; color: #a02c2c; }
.b-neutre { background: #f0eee8; color: var(--encre-2); }
.b-libre { background: #f0eee8; color: var(--sourdine); }
.b-or { background: var(--or-pale); color: #8a5f0e; }

/* ---------- Tableaux ---------- */
.tableau-cadre { background: var(--carte); border: 1px solid var(--ligne); border-radius: var(--r); overflow-x: auto; box-shadow: var(--ombre); }
table.donnees { width: 100%; border-collapse: collapse; font-size: 13.5px; min-width: 560px; }
table.donnees th {
    text-align: left; font-weight: 650; color: var(--encre-2);
    padding: 11px 13px; border-bottom: 1px solid var(--ligne);
    font-size: 12px; white-space: nowrap; background: #fbfaf7;
    text-transform: uppercase; letter-spacing: .04em;
}
table.donnees td { padding: 10px 13px; border-bottom: 1px solid #f0eee8; white-space: nowrap; }
table.donnees tbody tr { transition: background .12s; }
table.donnees tbody tr:hover { background: #fbfaf6; }
table.donnees tr:last-child td { border-bottom: none; }
table.donnees .num { text-align: right; font-variant-numeric: tabular-nums; }
table.donnees th.num { text-align: right; }
table.donnees tfoot td { font-weight: 700; background: #fbfaf7; border-top: 1px solid var(--ligne); }
.negatif { color: var(--alerte); }
.positif { color: var(--bon-texte); }

/* ---------- Alertes / flash ---------- */
.flash { padding: 11px 15px; border-radius: 11px; margin-bottom: 14px; font-size: 14px; font-weight: 500; }
.flash-ok { background: #e7f5e7; color: var(--bon-texte); border: 1px solid #c9e8c9; }
.flash-error { background: #fbe9e9; color: #a02c2c; border: 1px solid #f1cccc; }
.alerte-ligne {
    display: flex; gap: 10px; align-items: flex-start;
    padding: 10px 0; border-bottom: 1px solid #f0eee8; font-size: 13.5px;
}
.alerte-ligne:last-child { border-bottom: none; }
.alerte-point { width: 8px; height: 8px; border-radius: 50%; margin-top: 6px; flex-shrink: 0; }
.pt-rouge { background: var(--alerte); }
.pt-jaune { background: var(--jaune); }
.pt-vert { background: var(--bon); }

/* ---------- Formulaires ---------- */
form.ligne { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; }
.champ { display: flex; flex-direction: column; gap: 4px; }
.champ label { font-size: 12px; font-weight: 600; color: var(--encre-2); }
.champ input, .champ select, .champ textarea {
    padding: 8px 11px; border: 1px solid #ddd8cd; border-radius: 9px;
    font: inherit; font-size: 14px; background: #fff; color: var(--encre);
    min-width: 0;
}
.champ input:focus, .champ select:focus, .champ textarea:focus {
    outline: 2px solid rgba(186,132,30,.30); border-color: var(--or);
}
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 7px;
    background: var(--noir-2); color: #f4efe4; border: none; cursor: pointer;
    padding: 9px 17px; border-radius: 9px; font: inherit; font-size: 14px; font-weight: 600;
    transition: background .15s;
}
.btn:hover { background: var(--noir-3); }
.btn-clair { background: #fff; color: var(--encre); border: 1px solid #ddd8cd; }
.btn-clair:hover { background: var(--fond); }
.btn-petit { padding: 5px 10px; font-size: 12.5px; border-radius: 8px; }
.btn-danger { background: #fff; color: var(--alerte); border: 1px solid #eecfcf; }
.btn-danger:hover { background: #fbe9e9; }

/* Détails repliables (saisie) */
details.panneau { background: var(--carte); border: 1px solid var(--ligne); border-radius: var(--r); margin-bottom: 14px; box-shadow: var(--ombre); }
details.panneau summary {
    cursor: pointer; padding: 14px 19px; font-weight: 650; font-size: 14px;
    list-style: none; display: flex; align-items: center; gap: 9px;
}
details.panneau summary::before { content: "+"; font-weight: 700; color: var(--or); font-size: 17px; }
details.panneau[open] summary::before { content: "−"; }
details.panneau summary::-webkit-details-marker { display: none; }
details.panneau .panneau-corps { padding: 6px 19px 19px; border-top: 1px solid var(--ligne); }

/* Sélecteur de période */
.filtres { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 0 0 18px; }
.filtres .espace { flex: 1; }
.pilule {
    padding: 7px 15px; border-radius: 999px; border: 1px solid #ddd8cd;
    background: #fff; color: var(--encre-2); font-size: 13px; font-weight: 600;
    transition: background .15s;
}
.pilule:hover { background: var(--or-pale); }
.pilule.actif { background: var(--noir-2); border-color: var(--noir-2); color: var(--or-clair); }

/* Graphiques */
.graph-cadre { position: relative; height: 260px; }
.graph-cadre.petit { height: 200px; }

/* Matrice loyers */
.matrice td.cellule { text-align: center; padding: 6px 4px; }
.coche { color: var(--bon-texte); font-weight: 700; }
.croix { color: #cdc8bd; font-weight: 600; }

/* Connexion */
.page-connexion {
    min-height: 100vh; display: flex; align-items: center; justify-content: center;
    background:
        radial-gradient(1000px 500px at 85% -10%, rgba(186,132,30,.16), transparent 60%),
        linear-gradient(165deg, var(--noir-2) 0%, var(--noir) 70%);
    padding: 20px;
}
.boite-connexion {
    width: 100%; max-width: 390px; background: #fff; border-radius: 18px;
    padding: 36px 32px 32px;
    box-shadow: 0 24px 60px rgba(0,0,0,.35);
}
.logo-connexion { display: block; max-width: 230px; margin: 0 auto 6px; }
.boite-connexion h1 { font-size: 16px; margin: 10px 0 2px; text-align: center; font-weight: 600; color: var(--encre-2); }
.boite-connexion p { color: var(--sourdine); font-size: 13px; margin: 0 0 22px; text-align: center; }
.boite-connexion .champ { margin-bottom: 13px; }
.boite-connexion input { width: 100%; padding: 11px 12px; }
.boite-connexion .btn { width: 100%; padding: 12px; margin-top: 4px; }

/* ---------- Mobile ---------- */
@media (max-width: 900px) {
    .sidebar { display: none; }
    .page-titre h1 { display: none; }
    .page-titre { margin-bottom: 0; }
    .entete-mobile {
        display: flex; align-items: center; gap: 11px;
        background: var(--noir);
        color: #f4efe4;
        padding: 12px 16px;
        padding-top: calc(12px + env(safe-area-inset-top));
        position: sticky; top: 0; z-index: 20;
        border-bottom: 2px solid rgba(217,178,95,.35);
    }
    .entete-mobile .marque-logo { width: 30px; height: 30px; }
    .titre-mobile { font-weight: 650; font-size: 16px; flex: 1;
        font-family: Georgia, serif; letter-spacing: .02em; }
    .sortie-mobile { color: #a9a294; display: inline-flex; }
    .sortie-mobile svg { width: 21px; height: 21px; }
    .contenu { padding: 18px 14px calc(86px + env(safe-area-inset-bottom)); }
    .nav-bas {
        display: flex; position: fixed; bottom: 0; left: 0; right: 0; z-index: 20;
        background: rgba(255,255,255,.96);
        backdrop-filter: blur(10px);
        border-top: 1px solid var(--ligne);
        padding-bottom: env(safe-area-inset-bottom);
        box-shadow: 0 -4px 18px rgba(23,21,15,.06);
    }
    .nav-bas a {
        flex: 1; display: flex; flex-direction: column; align-items: center; gap: 3px;
        padding: 8px 2px 7px; color: var(--sourdine); font-size: 10.5px; font-weight: 600;
        border-top: 2px solid transparent;
    }
    .nav-bas a svg { width: 22px; height: 22px; }
    .nav-bas a.actif { color: var(--noir); border-top-color: var(--or); }
    .g-kpi { grid-template-columns: 1fr 1fr; }
    .g-2, .g-3 { grid-template-columns: 1fr; }
    .kpi .val { font-size: 18px; }
    .graph-cadre { height: 220px; }
    form.ligne .champ { flex: 1 1 46%; }
    form.ligne .btn { flex: 1 1 100%; }
}
@media (min-width: 901px) and (max-width: 1100px) {
    .g-kpi { grid-template-columns: 1fr 1fr; }
}
