/* Dashboard Bab'in — feuille unique, sans dépendance externe.
   Palette reprise du PowerPoint Nasta. */

:root {
    --bordeaux: #5B1118;
    --teal: #38BED4;
    --pink: #DFA7CF;
    --gold: #D8A511;
    --green: #1B6E22;
    --red: #C5332C;
    --grey: #9A9A9A;
    --light: #E7E3E3;
    --ink: #1F1B1C;
    --muted: #6B6467;
    --paper: #FFFFFF;
    --bg: #F6F4F3;
    --radius: 6px;
    --sans: "Century Gothic", "Avenir Next", "Segoe UI", system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--ink);
    font-family: var(--sans);
    font-size: 14px;
    line-height: 1.45;
}

a { color: var(--bordeaux); }

/* ── Barre de navigation ─────────────────────────────────────────────── */

.topbar {
    background: var(--bordeaux);
    color: #fff;
    padding: 12px 24px;
}

.topbar-inner {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 16px;
    max-width: 1600px;
    margin: 0 auto;
}

.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 17px;
    font-weight: 700;
    letter-spacing: .02em;
    margin: 0;
    white-space: nowrap;
}

.brand-logo {
    height: 26px;
    width: auto;
    display: block;
}

.brand span {
    font-weight: 400;
    opacity: .78;
    padding-left: 10px;
    border-left: 1px solid rgba(255, 255, 255, .3);
}

.nav { display: flex; flex-wrap: wrap; gap: 4px; flex: 1 1 auto; }

.nav a {
    color: #fff;
    text-decoration: none;
    padding: 6px 12px;
    border-radius: var(--radius);
    font-size: 13px;
    opacity: .8;
}

.nav a:hover { background: rgba(255, 255, 255, .12); opacity: 1; }
.nav a.active { background: rgba(255, 255, 255, .2); opacity: 1; font-weight: 700; }

.period-form {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
}

.period-form label { opacity: .8; }

.period-form input[type="date"] {
    font: inherit;
    font-size: 13px;
    padding: 5px 8px;
    border: 0;
    border-radius: var(--radius);
    background: rgba(255, 255, 255, .95);
    color: var(--ink);
}

.btn {
    font: inherit;
    font-size: 13px;
    padding: 6px 14px;
    border: 1px solid rgba(255, 255, 255, .5);
    border-radius: var(--radius);
    background: transparent;
    color: #fff;
    cursor: pointer;
    text-decoration: none;
    white-space: nowrap;
}

.btn:hover { background: rgba(255, 255, 255, .15); }
.btn-primary { background: #fff; color: var(--bordeaux); border-color: #fff; font-weight: 700; }
.btn-primary:hover { background: var(--light); }

.session { font-size: 12px; opacity: .8; white-space: nowrap; }

/* ── Structure de page ───────────────────────────────────────────────── */

main { max-width: 1600px; margin: 0 auto; padding: 24px; }

.page-head { margin-bottom: 20px; }
.page-head h1 { font-size: 24px; margin: 0 0 4px; color: var(--bordeaux); }
.page-head p { margin: 0; color: var(--muted); font-size: 13px; }

.card {
    background: var(--paper);
    border: 1px solid var(--light);
    border-radius: var(--radius);
    padding: 18px 20px;
    margin-bottom: 20px;
}

.card > h2 {
    font-size: 16px;
    margin: 0 0 2px;
    color: var(--bordeaux);
}

.card > .card-sub {
    margin: 0 0 16px;
    font-size: 12.5px;
    color: var(--muted);
}

/* Sous-titre d'un second tableau dans la même carte. */
.block-title {
    font-size: 13px;
    margin: 22px 0 8px;
    color: var(--bordeaux);
}

/* Tableau plus large que sa carte : il défile seul, la page ne bouge pas.
   Dompdf ignore la propriété et rend le tableau entier, c'est le comportement
   voulu à l'impression. */
.table-scroll { overflow-x: auto; }

.card-columns { display: flex; flex-wrap: wrap; gap: 20px; }
.card-columns > * { flex: 1 1 380px; min-width: 0; }

/* ── Cartes KPI (en <table> pour rester compatible Dompdf) ───────────── */

table.kpi-row { width: 100%; border-collapse: separate; border-spacing: 10px 0; margin-bottom: 16px; }
table.kpi-row td { width: 25%; vertical-align: top; padding: 0; }

.kpi {
    border: 1px solid var(--light);
    border-top: 3px solid var(--bordeaux);
    border-radius: var(--radius);
    padding: 12px 14px;
    background: var(--paper);
}

.kpi .kpi-label { font-size: 11.5px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.kpi .kpi-value { font-size: 24px; font-weight: 700; line-height: 1.15; margin: 4px 0 2px; }
.kpi .kpi-ref { font-size: 11.5px; color: var(--muted); }
.kpi .kpi-evol { font-size: 13px; font-weight: 700; margin-top: 3px; }

/* ── Tableaux de données ─────────────────────────────────────────────── */

table.data {
    width: 100%;
    border-collapse: collapse;
    font-size: 12.5px;
}

table.data th,
table.data td {
    padding: 6px 8px;
    border-bottom: 1px solid var(--light);
    text-align: right;
    vertical-align: top;
    white-space: nowrap;
}

table.data thead th {
    background: var(--bordeaux);
    color: #fff;
    font-weight: 700;
    font-size: 11.5px;
    border-bottom: 0;
    text-align: right;
}

table.data thead th.left,
table.data td.left,
table.data th.left { text-align: left; }

table.data tbody tr:nth-child(even) { background: #FBFAFA; }
table.data tr.total { font-weight: 700; background: #F2EEEE !important; }
table.data tr.total td { border-top: 2px solid var(--bordeaux); }

table.data tr.section td {
    background: var(--light);
    font-weight: 700;
    font-size: 11.5px;
    text-transform: uppercase;
    letter-spacing: .05em;
    text-align: left;
    color: var(--bordeaux);
}

table.data tr.spacer td { height: 10px; border: 0; background: transparent; }
table.data td.indent { padding-left: 24px; color: var(--muted); }

.sub { display: block; font-size: 10.5px; font-weight: 400; }
.sub.detail { color: var(--grey); }

.up { color: var(--green); }
.down { color: var(--red); }
.flat { color: var(--grey); }

.group-ca { background: var(--bordeaux) !important; }
.group-cmd { background: #7A2A31 !important; }
.group-cli { background: #93454B !important; }

/* ── Barres de répartition, en CSS pur ──────────────────────────────── */

.bars { margin: 0 0 14px; }

.bar-row { margin-bottom: 8px; }

.bar-head {
    display: flex;
    justify-content: space-between;
    font-size: 12px;
    margin-bottom: 3px;
}

.bar-head .bar-label { font-weight: 700; }
.bar-head .bar-value { color: var(--muted); }

.bar-track {
    background: var(--light);
    border-radius: 3px;
    height: 14px;
    overflow: hidden;
}

.bar-fill {
    height: 14px;
    background: var(--bordeaux);
    border-radius: 3px;
}

.bar-fill.c1 { background: var(--bordeaux); }
.bar-fill.c2 { background: var(--teal); }
.bar-fill.c3 { background: var(--gold); }
.bar-fill.c4 { background: var(--pink); }
.bar-fill.c5 { background: var(--grey); }

/* Sparkline en colonnes, sans JS ni SVG. */
.spark { display: flex; align-items: flex-end; gap: 2px; height: 90px; margin: 8px 0 4px; }
.spark-col { flex: 1 1 0; display: flex; flex-direction: column; justify-content: flex-end; height: 100%; }
.spark-bar { background: var(--teal); border-radius: 2px 2px 0 0; min-height: 1px; }
.spark-bar.ref { background: var(--light); }
.spark-legend { font-size: 11px; color: var(--muted); display: flex; justify-content: space-between; }

/* ── Bandeaux de fraîcheur et d'erreur ──────────────────────────────── */

.freshness {
    font-size: 11.5px;
    color: var(--muted);
    margin-top: 12px;
    padding-top: 8px;
    border-top: 1px dotted var(--light);
}

.badge {
    display: inline-block;
    padding: 1px 7px;
    border-radius: 10px;
    font-size: 10.5px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .04em;
}

.badge.live { background: #E4F5E5; color: var(--green); }
.badge.cache { background: #FCF1D8; color: #8A6A00; }

.notice {
    border-left: 3px solid var(--gold);
    background: #FDF8EC;
    padding: 10px 14px;
    font-size: 12.5px;
    border-radius: 0 var(--radius) var(--radius) 0;
    margin-bottom: 14px;
}

.notice.error { border-left-color: var(--red); background: #FBEDEC; }
.notice strong { display: block; margin-bottom: 2px; }

/* ── Connexion ──────────────────────────────────────────────────────── */

body.login-page { background: var(--bordeaux); display: flex; align-items: center; justify-content: center; min-height: 100vh; }

.login-box {
    background: var(--paper);
    border-radius: 10px;
    padding: 32px;
    width: 100%;
    max-width: 380px;
    box-shadow: 0 18px 40px rgba(0, 0, 0, .28);
}

.login-box h1 { margin: 0 0 4px; font-size: 21px; color: var(--bordeaux); }
.login-box p.sub-title { margin: 0 0 22px; color: var(--muted); font-size: 13px; }
.login-box label { display: block; font-size: 12px; font-weight: 700; margin-bottom: 4px; color: var(--muted); }

.login-box input[type="text"],
.login-box input[type="password"] {
    width: 100%;
    font: inherit;
    padding: 9px 11px;
    border: 1px solid var(--light);
    border-radius: var(--radius);
    margin-bottom: 14px;
    background: #FCFBFB;
}

.login-box input:focus { outline: 2px solid var(--teal); outline-offset: 1px; }

.login-box button {
    width: 100%;
    font: inherit;
    font-weight: 700;
    padding: 10px;
    border: 0;
    border-radius: var(--radius);
    background: var(--bordeaux);
    color: #fff;
    cursor: pointer;
}

.login-box button:hover { background: #71171F; }

.login-error {
    background: #FBEDEC;
    color: var(--red);
    border-radius: var(--radius);
    padding: 9px 12px;
    font-size: 12.5px;
    margin-bottom: 14px;
}

.login-remember { display: flex; align-items: center; gap: 7px; font-size: 12.5px; margin-bottom: 16px; color: var(--muted); }
.login-remember input { margin: 0; }

/* ── Impression (Cmd+P) ─────────────────────────────────────────────── */

@media print {
    body { background: #fff; font-size: 10.5px; }
    .topbar, .no-print { display: none !important; }
    main { max-width: none; padding: 0; }
    .card { border: 1px solid #ddd; break-inside: avoid; page-break-inside: avoid; margin-bottom: 12px; }
    table.data { font-size: 9.5px; }
    table.data thead th { background: var(--bordeaux) !important; color: #fff !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
    .kpi { break-inside: avoid; }
    .up { color: #1B6E22 !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
    .down { color: #C5332C !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
    .bar-fill { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
    @page { size: A4 landscape; margin: 10mm; }
}

/* Logo sur la carte de connexion (fond blanc → variante bordeaux). */
.login-logo {
    display: block;
    height: 44px;
    width: auto;
    margin: 0 0 18px;
}
