:root { --bleu: #1f4e79; --clair: #dde9f4; --gris: #f4f5f7; --bord: #d0d5dd; --texte: #1d2433; }
* { box-sizing: border-box; }
body { margin: 0; font: 14px/1.4 system-ui, sans-serif; color: var(--texte); background: #fff; }
header { background: var(--bleu); color: #fff; padding: .6rem 1rem; }
header h1 { margin: 0 0 .4rem; font-size: 1.1rem; }
nav { display: flex; flex-wrap: wrap; gap: .25rem; }
nav a { color: #fff; text-decoration: none; padding: .3rem .7rem; border-radius: 4px; background: #ffffff22; }
nav a.actif { background: #fff; color: var(--bleu); font-weight: 600; }
main { padding: 1rem; }
h2 { margin: 0 0 .75rem; font-size: 1.15rem; }

/* Filtres de rapport et segments */
.zone-haute { display: grid; gap: .8rem; margin-bottom: .8rem; }
.filtres-rapport { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: .6rem; }
.filtres-rapport .nom { display: block; font-weight: 600; font-size: .8rem; margin-bottom: .15rem; }
.filtre-page { position: relative; }
.filtre-page > button { width: 100%; text-align: left; background: #fff; border: 1px solid var(--bord); border-radius: 4px; padding: .3rem .5rem; font: inherit; cursor: pointer; display: flex; justify-content: space-between; }
.filtre-page .panneau { display: none; position: absolute; z-index: 20; top: 100%; left: 0; width: 280px; max-height: 320px; overflow: auto; background: #fff; border: 1px solid var(--bord); border-radius: 4px; box-shadow: 0 4px 12px #0002; padding: .4rem; }
.filtre-page.ouvert .panneau { display: block; }
.filtre-page .panneau input[type=search] { width: 100%; margin-bottom: .3rem; }
.filtre-page .panneau label { display: block; white-space: nowrap; cursor: pointer; }
.filtre-page .panneau .actions { margin-top: .3rem; display: flex; gap: .4rem; position: sticky; bottom: 0; background: #fff; padding-top: .3rem; }
.segments { display: flex; gap: .6rem; overflow-x: auto; padding-bottom: .3rem; }
.segment { flex: none; width: 210px; border: 1px solid var(--bord); border-radius: 4px; background: #fff; display: flex; flex-direction: column; height: 180px; }
.segment header { display: flex; justify-content: space-between; align-items: center; gap: .3rem; padding: .25rem .5rem; background: var(--gris); border-bottom: 1px solid var(--bord); font-size: .8rem; font-weight: 600; color: var(--texte); }
.segment header .titre-segment { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.segment header > span:last-child { display: flex; flex: none; white-space: nowrap; }
.segment header button { border: 0; background: none; cursor: pointer; font-size: 1rem; line-height: 1; padding: 0 .2rem; }
.segment ul { list-style: none; margin: 0; padding: .3rem; overflow: auto; flex: 1; }
.segment li { margin-bottom: .2rem; }
.segment li button { width: 100%; text-align: left; border: 1px solid var(--bord); border-radius: 3px; background: var(--clair); padding: .2rem .5rem; font: inherit; font-size: .85rem; cursor: pointer; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.segment li button.selectionne { background: var(--bleu); color: #fff; border-color: var(--bleu); }
.segment li button.indisponible { background: var(--gris); color: #9aa1ad; }

/* Barre d'actions */
.barre-outils { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; margin-bottom: 1rem; }
.barre-outils a, .barre-outils button, .bouton { background: var(--bleu); color: #fff; border: 0; padding: .4rem .9rem; border-radius: 4px; cursor: pointer; text-decoration: none; font: inherit; font-size: .9rem; }
.barre-outils a.secondaire, .barre-outils button.secondaire, .bouton.secondaire { background: var(--gris); color: var(--texte); border: 1px solid var(--bord); }
.barre-outils .info { color: #5b6478; margin-left: auto; }

/* Tableaux croisés */
.tableau { overflow: auto; max-height: 75vh; border: 1px solid var(--bord); }
table.tcd { border-collapse: collapse; width: 100%; }
table.tcd th { background: var(--bleu); color: #fff; padding: .3rem .6rem; text-align: right; white-space: nowrap; position: sticky; top: 0; z-index: 2; }
table.tcd th.gauche { text-align: left; }
table.tcd th a { color: #fff; text-decoration: none; }
table.tcd td { padding: .3rem .6rem; border-bottom: 1px solid #eceef2; white-space: nowrap; }
table.tcd td.nombre { text-align: right; font-variant-numeric: tabular-nums; }
table.tcd tr.sous-total td { font-weight: 600; background: var(--gris); }
table.tcd tfoot td { position: sticky; bottom: 0; background: var(--clair); font-weight: 700; }
table.tcd tbody tr:hover td { background: #f0f6fc; }
table.tcd tr[data-detail] { cursor: default; }
table.tcd button.bascule { border: 1px solid var(--bord); background: #fff; width: 18px; height: 18px; line-height: 14px; font-size: .8rem; padding: 0; margin-right: .4rem; cursor: pointer; border-radius: 3px; }
.vide { color: #8a93a5; font-style: italic; }

/* Messages */
.message { padding: .6rem .8rem; border-radius: 4px; margin-bottom: 1rem; border: 1px solid; }
.succes { background: #e3f6e8; border-color: #9bd5aa; }
.erreur { background: #fde8e8; border-color: #f1a9a9; }
.info-msg { background: #fff6dd; border-color: #ecd48b; }

/* Feuilles source et détails */
table.source { border-collapse: collapse; }
table.source th { background: var(--bleu); color: #fff; padding: .3rem .6rem; text-align: left; position: sticky; top: 0; z-index: 2; white-space: nowrap; }
table.source th a { color: #fff; text-decoration: none; }
table.source tr.filtre th { top: 28px; background: var(--clair); padding: .15rem .3rem; }
table.source tr.filtre input { width: 100%; min-width: 80px; font: inherit; font-size: .8rem; }
table.source td { padding: .3rem .6rem; border-bottom: 1px solid #eceef2; white-space: nowrap; }
table.source td.nombre { text-align: right; font-variant-numeric: tabular-nums; }
.pagination { margin: .8rem 0; }
.pagination nav { display: block; }
.pagination svg { width: 14px; height: 14px; }
.pagination a, .pagination span { text-decoration: none; }
table.volumes { width: auto; margin: 1rem 0; }
@media print { header nav, .segments, .barre-outils { display: none; } }
