/*
 * Charte graphique Humavia, reprise du theme.json du thème humavia-fse.
 * Polices auto-hébergées : aucune requête vers un tiers.
 */
@font-face { font-family: "Neulis Sans"; src: url("fonts/neulis-sans-regular.woff2") format("woff2"); font-weight: 400; font-style: normal; font-display: swap; }
@font-face { font-family: "Neulis Sans"; src: url("fonts/neulis-sans-medium.woff2") format("woff2"); font-weight: 500; font-style: normal; font-display: swap; }
@font-face { font-family: "Neulis Sans"; src: url("fonts/neulis-sans-semi-bold.woff2") format("woff2"); font-weight: 600; font-style: normal; font-display: swap; }
@font-face { font-family: "Final Six"; src: url("fonts/finalsix-extra-bold.woff2") format("woff2"); font-weight: 700; font-style: normal; font-display: swap; }
@font-face { font-family: "Final Six"; src: url("fonts/finalsix-black.woff2") format("woff2"); font-weight: 800; font-style: normal; font-display: swap; }

:root {
    /* Couleurs de la charte, nommées par leur rôle ici */
    --bg: #f4f5f6;              /* gray */
    --surface: #ffffff;         /* white */
    --surface-2: #eaf1f5;       /* accent-8 */
    --text: #233555;            /* contrast, titres */
    --text-2: #5a5a5d;          /* base, texte courant */
    --muted: #5a5a5d;           /* base : gray-2 ne passe pas le contraste en petit texte */
    --line: rgba(0, 0, 0, .1);  /* black-10 */
    --rule: #89898f;            /* gray-2, réservé aux filets et aux axes */
    --accent: #3d709a;          /* accent-2 */
    --accent-hover: #22745c;    /* accent-9 : accent-1 est trop clair pour du texte */
    --good: #22745c;            /* accent-9 */
    --bad: #c4501e;             /* accent-12 assombri pour atteindre 4,5:1 */
    --gradient: linear-gradient(101deg, #3d709a 0.13%, #233555 100%);
    --shadow: 0 0 26px 0 rgba(0, 0, 0, .07);
    --radius: .5rem;

    --font: "Neulis Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
    --font-display: "Final Six", "Neulis Sans", system-ui, sans-serif;
}
* { box-sizing: border-box; }
body { margin: 0; font: 400 .875rem/1.5 var(--font); color: var(--text-2); background: var(--bg); }
a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); text-decoration: underline; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
h1, h2, h3 { font-family: var(--font-display); font-weight: 800; line-height: 1.1; color: var(--text); }
h1 { font-size: 1.563rem; margin: 0 0 .5rem; }
h2 { font-size: 1.25rem; margin: 0 0 1rem; }
code { font-size: .9em; }
.muted { color: var(--muted); }

.topbar { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: .85rem 1.5rem; background: var(--gradient); color: #fff; }
.topbar .brand { display: flex; align-items: center; }
.topbar .brand img { display: block; height: 26px; width: auto; }
.topbar a { color: #fff; }
.topbar a:hover { color: #fff; text-decoration: underline; }
.topbar nav { display: flex; gap: 1.25rem; align-items: center; }
.topbar .muted { color: rgba(255, 255, 255, .7); }
main { max-width: 1234px; margin: 0 auto; padding: 1.5rem; }
footer { padding: 1rem; text-align: center; color: var(--muted); font-size: .75rem; }
footer span { margin: 0 .5rem; }
footer p { margin: .5rem 0 0; }
.prose { max-width: 50rem; margin-inline: auto; line-height: 1.6; }
.prose h2 { margin-top: 1.75rem; }
.prose h3 { font-size: 1rem; margin: 1.25rem 0 .25rem; }
.sync-ok { color: var(--good); }
.sync-error { color: var(--bad); }

select, input, button { font: inherit; padding: .45rem .65rem; border: 1px solid var(--line); border-radius: 6px; background: #fff; color: var(--text-2); }
button { cursor: pointer; }
button.primary, .btn { font-weight: 600; background: var(--accent); color: #fff; border: 1px solid var(--accent); padding: .5rem 1rem; border-radius: 6px; }
button.primary:hover, .btn:hover { background: var(--text); border-color: var(--text); color: #fff; text-decoration: none; }
button.link { border: 0; background: none; color: var(--bad); padding: 0; text-decoration: underline; }
form.inline { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: 1rem; }
form.inline input, form.inline select { flex: 1 1 140px; }

.filters { position: sticky; top: 0; z-index: 5; display: flex; flex-wrap: wrap; align-items: center; gap: .75rem; padding: .75rem 1rem; margin-bottom: 1.25rem; background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); }
.filters label { display: flex; align-items: center; gap: .4rem; }
.reset { color: var(--muted); }
.loading main { opacity: .5; pointer-events: none; transition: opacity .15s .1s; } /* filtre appliqué, page en cours de rechargement */
.period-label { margin-left: auto; color: var(--muted); }
.chip { padding: .35rem .75rem; font-weight: 500; color: var(--text); background: var(--surface-2); border-radius: 999px; }
.dropdown { position: relative; }
.dropdown summary { list-style: none; cursor: pointer; padding: .45rem .65rem; border: 1px solid var(--line); border-radius: 6px; background: #fff; white-space: nowrap; }
.dropdown summary::-webkit-details-marker { display: none; }
.dropdown summary::after { content: "▾"; margin-left: .6rem; color: var(--muted); }
.dropdown > div { position: absolute; top: 100%; left: 0; z-index: 10; width: max-content; min-width: 100%; max-width: calc(100vw - 2rem); max-height: 320px; overflow: auto; margin-top: .25rem; padding: .5rem; background: #fff; border-radius: var(--radius); box-shadow: 0 4px 20px rgba(0, 0, 0, .12); }
.dropdown label { display: flex; gap: .4rem; padding: .25rem .3rem; }
.dropdown-actions { margin: 0 0 .35rem; padding: 0 .3rem .4rem; border-bottom: 1px solid var(--line); color: var(--muted); }
.dropdown-actions button { padding: 0; border: 0; background: none; color: var(--accent); cursor: pointer; }
.dropdown-actions button:hover { color: var(--accent-hover); text-decoration: underline; }

.tabs { display: flex; gap: .25rem; margin-bottom: 1.25rem; border-bottom: 1px solid var(--line); }
.tabs a { padding: .6rem 1rem; font-weight: 500; color: var(--text-2); border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs a:hover { color: var(--text); text-decoration: none; background: var(--surface-2); border-radius: var(--radius) var(--radius) 0 0; }
.tabs a[aria-current="page"] { color: var(--text); font-weight: 600; border-bottom-color: var(--accent); }

.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: .75rem; margin-bottom: 1.25rem; }
.kpi { display: flex; flex-direction: column; gap: .15rem; padding: 1rem; background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); }
.kpi-label { color: var(--text-2); font-size: .75rem; }
.kpi-value { font-size: 1.563rem; font-weight: 600; color: var(--text); }
.kpi-note { font-size: .75rem; color: var(--muted); }
.delta { font-size: .75rem; color: var(--muted); }
tfoot td { font-weight: 600; color: var(--text); border-top: 2px solid var(--line); }
.delta.good { color: var(--good); }
.delta.bad { color: var(--bad); }
td .delta { display: block; white-space: nowrap; }
.nowrap { white-space: nowrap; }
.log { margin-bottom: .5rem; }
.log summary { cursor: pointer; }
.log pre { max-height: 360px; overflow: auto; margin: .5rem 0 0; padding: .75rem; font-size: .75rem; background: var(--surface-2); border-radius: var(--radius); white-space: pre-wrap; overflow-wrap: anywhere; }
.notice { margin-top: 1rem; padding: .75rem 1rem; background: var(--surface-2); border-radius: var(--radius); }
.notice summary { cursor: pointer; font-weight: 600; color: var(--text); }
.notice ul { padding-left: 1.25rem; }
.notice table { max-width: 40rem; }
.notice code { user-select: all; } /* un clic sélectionne tout le préfixe */
.movers { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 1.5rem; }
.movers h3 { font-size: 1rem; margin: 0 0 .5rem; }
.movers ol { margin: 0; padding-left: 1.25rem; }
.movers li { padding: .2rem 0; }
.movers li .delta { margin: 0 .4rem; font-size: .8125rem; font-weight: 600; }
.movers + .muted { margin: .75rem 0 1.25rem; }

.card { padding: 1.25rem 1.5rem; margin-bottom: 1.25rem; background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); }
.section-head { display: flex; justify-content: space-between; align-items: center; gap: 1rem; margin-bottom: 1rem; }
.section-head h2 { margin: 0; }
.chart { position: relative; height: 280px; margin-bottom: 1rem; }
.cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 1.5rem; align-items: start; }
.table-wrap { overflow-x: auto; }

table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
th, td { padding: .5rem; text-align: left; border-bottom: 1px solid var(--line); vertical-align: middle; }
.pages a { display: block; font-size: .8125rem; overflow-wrap: anywhere; }
.avatar { border-radius: 50%; vertical-align: middle; margin-right: .6rem; }
th { color: var(--text); font-weight: 600; font-size: .75rem; text-transform: uppercase; letter-spacing: .03em; }
th a { color: inherit; }
.sort { all: unset; cursor: pointer; }
.sort:hover { text-decoration: underline; }
.sort:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
th[aria-sort="descending"] .sort::after { content: " ▾"; }
th[aria-sort="ascending"] .sort::after { content: " ▴"; }
tbody tr:hover { background: var(--surface-2); }
.num { text-align: right; }
.actions { text-align: right; }
.empty { color: var(--muted); font-style: italic; }
.empty:hover, tbody tr:hover .empty { background: none; }
.bar { display: inline-block; width: calc(var(--w, 0) * 1.2px); height: .6em; margin-right: .4rem; background: var(--accent); border-radius: 2px; vertical-align: middle; }

.settings fieldset { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: .75rem 1.25rem; margin: 0 0 1.25rem; padding: 1rem 1.25rem; border: 1px solid var(--line); border-radius: var(--radius); }
.settings legend { font-weight: 600; color: var(--text); padding: 0 .4rem; }
.settings label { display: flex; flex-direction: column; gap: .25rem; font-size: .75rem; color: var(--text-2); }
.settings input { font-size: .875rem; }
.settings .card > p.muted { margin: -.5rem 0 1rem; }
.settings fieldset:last-child { margin-bottom: 0; }
.settings-actions { position: sticky; bottom: 0; padding: .75rem 0; background: var(--bg); } /* le bouton reste accessible sur un long formulaire */
.test-results { list-style: none; padding: 0; margin: 0; }
.test-results li { padding: .3rem 0; }

.login { max-width: 380px; margin: 4rem auto; display: flex; flex-direction: column; gap: .85rem; }
.login label { display: flex; flex-direction: column; gap: .3rem; }
.error { color: var(--bad); font-weight: 500; }
.warn { color: var(--bad); font-weight: 600; }

@media (max-width: 640px) {
    main { padding: 1rem; }
    .period-label { margin-left: 0; width: 100%; }
    .topbar { flex-direction: column; align-items: flex-start; }
    .topbar nav { flex-wrap: wrap; gap: .75rem; }
}
