:root {
  --prim: var(--c-principale, #0b5394); --entete: var(--c-entete, #1f3b63); --lignes: var(--c-lignes, #e8f0fa);
  --titres: #1f3b63; --texte: #1d2733; --texte-2: #4a5868; --fond: #f4f6f9; --carte: #fff; --carte-2: #f8fafc; --bord: #d8e0ea;
  --alerte: #8a1c1c; --alerte-fond: #fdeeee; --ok: #1e6b3a; --ok-fond: #ecf7f0; --sur-prim: #fff; --ambre: #b45309;
}
@media (prefers-color-scheme: dark) {
  :root {
    --prim: #7fb0e8; --entete: #12253d; --lignes: #18263a; --titres: #cfe0f5; --texte: #e6ebf1; --texte-2: #a9b6c5;
    --fond: #0f1620; --carte: #161f2b; --carte-2: #1b2635; --bord: #2a3747; --alerte: #f0a3a3; --alerte-fond: #3a1d1d;
    --ok: #8fd3a6; --ok-fond: #15291d; --sur-prim: #0f1620; --ambre: #f5b46a;
  }
}
* { box-sizing: border-box; }
body { margin: 0; font: 15px/1.55 system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif; color: var(--texte); background: var(--fond); min-height: 100vh; display: flex; flex-direction: column; }
a { color: var(--prim); }
.wrap { max-width: 1200px; margin: 0 auto; padding: 0 16px; width: 100%; }
[hidden] { display: none !important; }

/* En-tête */
.entete { background: var(--entete); color: #fff; position: sticky; top: 0; z-index: 20; box-shadow: 0 2px 8px rgba(0,0,0,.15); }
.entete-int { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; justify-content: space-between; padding-top: 14px; padding-bottom: 14px; }
.entete-titre { display: flex; gap: 12px; align-items: center; min-width: 0; }
#logo { max-height: 48px; max-width: 160px; background: #fff; border-radius: 6px; padding: 3px; }
.surtitre { margin: 0; font-size: 12.5px; opacity: .8; letter-spacing: .03em; }
h1 { margin: 2px 0 0; font-size: clamp(18px, 2.6vw, 24px); line-height: 1.2; }
.actions { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.qui { font-size: 13px; opacity: .85; margin-right: 4px; }
.btn { font: inherit; font-size: 13px; font-weight: 600; padding: 7px 12px; border-radius: 6px; border: 1px solid rgba(255,255,255,.25); background: rgba(255,255,255,.1); color: #fff; cursor: pointer; text-decoration: none; }
.btn:hover { background: rgba(255,255,255,.2); }
.btn-ok { background: #15803d; border-color: #15803d; }
.btn-edit[aria-pressed="true"] { background: #d97706; border-color: #d97706; }
.bandeau-edition { background: #fef3c7; color: #78350f; font-size: 13.5px; padding: 8px 0; border-bottom: 1px solid #fcd34d; }
@media (prefers-color-scheme: dark) { .bandeau-edition { background: #3a2a0c; color: #fcd9a0; border-color: #6b4b14; } }

main { padding: 20px 16px 48px; flex: 1; }
.intro p { margin: 0 0 8px; color: var(--texte-2); max-width: 900px; }
h2 { font-size: 15px; text-transform: uppercase; letter-spacing: .05em; color: var(--titres); margin: 0; }
.mentions { background: var(--carte); border: 1px solid var(--bord); border-radius: 10px; padding: 16px 18px; margin: 16px 0; }
.mentions-tete { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 12px; }
.mentions-grille { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 10px; }
.mentions-grille > div { background: var(--carte-2); border: 1px solid var(--bord); border-radius: 8px; padding: 10px 12px; font-size: 14px; }
.lib { display: block; font-size: 12px; font-weight: 700; color: var(--texte-2); margin-bottom: 2px; }
.note { font-size: 13.5px; color: var(--texte-2); margin: 10px 0 0; }

.outils { display: flex; flex-direction: column; gap: 10px; margin: 18px 0 6px; }
.outils input { padding: 10px 12px; font: inherit; border: 1px solid var(--bord); border-radius: 8px; background: var(--carte); color: var(--texte); max-width: 520px; }
.filtres { display: flex; flex-wrap: wrap; gap: 6px; }
.filtres button { font: inherit; font-size: 13px; padding: 6px 12px; border-radius: 999px; border: 1px solid var(--bord); background: var(--carte); color: var(--texte); cursor: pointer; }
.filtres button[aria-pressed="true"] { background: var(--prim); border-color: var(--prim); color: var(--sur-prim); font-weight: 600; }
.filtres .compte { opacity: .75; font-weight: 400; }
.aide { font-size: 13.5px; color: var(--texte-2); margin: 6px 0 14px; }

/* Fiches */
.fiches { display: grid; grid-template-columns: minmax(0, 1fr); gap: 18px; }
.fiche { background: var(--carte); border: 1px solid var(--bord); border-radius: 10px; overflow: hidden; }
.fiche.non-publie { border-style: dashed; opacity: .85; }
.fiche-tete { display: flex; flex-wrap: nowrap; gap: 12px 14px; align-items: center; justify-content: space-between; padding: 16px 18px; background: var(--carte-2); cursor: pointer; list-style: none; user-select: none; }
.fiche-tete::-webkit-details-marker { display: none; }
.fiche[open] > .fiche-tete { border-bottom: 1px solid var(--bord); }
.fiche-tete:hover { background: var(--fond-survol, rgba(11, 83, 148, .07)); }
.fiche-tete:focus-visible { outline: 3px solid var(--prim); outline-offset: -3px; }
.fiche-tete .g { display: flex; flex-wrap: wrap; gap: 6px 10px; align-items: center; min-width: 0; flex: 1 1 auto; }
.fleche { flex: none; width: 30px; height: 30px; border-radius: 50%; background: var(--prim); position: relative; transition: transform .15s; }
.fleche::before { content: ""; position: absolute; left: 50%; top: 50%; width: 8px; height: 8px; margin: -6px 0 0 -7px; border-right: 3px solid var(--sur-prim, #fff); border-bottom: 3px solid var(--sur-prim, #fff); transform: rotate(-45deg); transition: transform .15s; }
.fiche[open] > .fiche-tete .fleche::before { transform: rotate(45deg); margin: -8px 0 0 -4px; }
.fiche-nom { flex: 1 0 100%; font-size: 22px; line-height: 1.25; font-weight: 800; letter-spacing: -.01em; color: var(--titres); margin: 0 0 2px; }
.fiche-nom a { color: inherit; text-decoration: none; }
.fiche-nom a:hover { text-decoration: underline; }
.btn-logiciel { display: inline-flex; align-items: center; gap: 8px; padding: 10px 16px; border-radius: 10px; background: var(--prim); color: var(--sur-prim, #fff); font-size: 14.5px; font-weight: 700; text-decoration: none; white-space: nowrap; margin-left: auto; box-shadow: 0 2px 6px rgba(11, 83, 148, .3); transition: transform .12s, box-shadow .12s, filter .12s; }
.btn-logiciel:hover, .btn-logiciel:focus-visible { filter: brightness(1.12); transform: translateY(-1px); box-shadow: 0 4px 10px rgba(11, 83, 148, .4); outline: none; }
.btn-logiciel + .btn-pdf { margin-left: 0; }
.btn-pdf { display: inline-flex; align-items: center; gap: 10px; padding: 7px 16px 7px 12px; border-radius: 10px; background: #d32f2f; color: #fff; text-decoration: none; box-shadow: 0 2px 6px rgba(211, 47, 47, .35); transition: transform .12s, box-shadow .12s, background .12s; margin-left: auto; }
.btn-pdf:hover, .btn-pdf:focus-visible { background: #b71c1c; transform: translateY(-1px); box-shadow: 0 4px 10px rgba(211, 47, 47, .45); outline: none; }
.btn-pdf .ico-pdf { flex: none; filter: drop-shadow(0 1px 1px rgba(0, 0, 0, .25)); }
.btn-pdf .txt-pdf { display: flex; flex-direction: column; line-height: 1.2; }
.btn-pdf strong { font-size: 14.5px; font-weight: 700; white-space: nowrap; }
.btn-pdf small { font-size: 11.5px; opacity: .9; }
@media (max-width: 700px) { .fiche-tete { flex-wrap: wrap; } .btn-pdf, .btn-logiciel { width: 100%; justify-content: center; margin-left: 0; } }
.pastille { font-size: 12px; padding: 2px 9px; border-radius: 999px; background: var(--lignes); color: var(--titres); }
.pastille.cat { font-weight: 600; }
.pastille.np { background: #fef3c7; color: #92400e; }
.badge-pdf { display: inline-block; margin-left: 6px; padding: 0 5px; font-size: 11px; font-weight: 700; line-height: 17px; border-radius: 4px; background: var(--alerte-fond); color: var(--alerte); vertical-align: 2px; }
.editeur { font-size: 13px; color: var(--texte-2); }
.fiche-corps { padding: 16px 18px; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px 20px; }
@media (max-width: 960px) { .fiche-corps { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 620px) { .fiche-corps { grid-template-columns: minmax(0, 1fr); } }
.bloc .lib { text-transform: uppercase; letter-spacing: .05em; font-size: 11px; color: var(--prim); }
.bloc p { margin: 0 0 6px; font-size: 14px; } .bloc p:last-child { margin: 0; }
.bloc.large { grid-column: span 2; } .bloc.plein { grid-column: 1 / -1; }
@media (max-width: 620px) { .bloc.large { grid-column: auto; } }
.encadre { background: var(--carte-2); border: 1px solid var(--bord); border-radius: 6px; padding: 8px 10px; }
.encadre.secu { background: var(--ok-fond); border-color: color-mix(in srgb, var(--ok) 25%, transparent); }
.pas p { color: var(--ok); }
.liens-doc { margin: 0; padding-left: 18px; font-size: 14px; }
.liens-doc li { margin: 2px 0; }
.tableau { overflow-x: auto; border: 1px solid var(--bord); border-radius: 8px; }
.tableau table { width: 100%; min-width: 640px; border-collapse: collapse; font-size: 13.5px; }
th, td { text-align: left; vertical-align: top; padding: 8px 10px; border-bottom: 1px solid var(--bord); }
thead th { background: var(--prim); color: var(--sur-prim); font-weight: 600; }
tbody tr:nth-child(even) td { background: var(--lignes); }
.sensible { background: var(--alerte-fond); color: var(--alerte); padding: 1px 6px; border-radius: 4px; font-weight: 600; white-space: nowrap; }
.vide { padding: 24px; text-align: center; color: var(--texte-2); background: var(--carte); border: 1px solid var(--bord); border-radius: 10px; }
#sections section { margin-top: 28px; }
#sections h2 { margin-bottom: 10px; }
.encart { background: var(--carte); border: 1px solid var(--bord); border-radius: 10px; padding: 4px 18px; }
footer { border-top: 1px solid var(--bord); padding: 16px 0 28px; color: var(--texte-2); font-size: 13px; background: var(--carte); }
footer p { margin: 0 0 4px; }

/* Édition */
.btn-petit { font: inherit; font-size: 12.5px; font-weight: 600; padding: 5px 10px; border-radius: 6px; border: 1px solid var(--bord); background: var(--carte); color: var(--texte); cursor: pointer; }
.btn-petit:hover { border-color: var(--prim); }
.btn-petit.danger, .btn-sec.danger { color: #b91c1c; }
.outils-fiche { display: flex; gap: 6px; }
dialog.dlg { border: none; border-radius: 12px; padding: 0; width: min(960px, calc(100vw - 24px)); max-height: calc(100vh - 32px); color: var(--texte); background: var(--carte); box-shadow: 0 20px 60px rgba(0,0,0,.35); }
dialog.dlg-petit { width: min(420px, calc(100vw - 24px)); }
dialog::backdrop { background: rgba(15, 23, 42, .55); }
.dlg form { display: flex; flex-direction: column; max-height: calc(100vh - 32px); }
.dlg-tete { display: flex; align-items: center; justify-content: space-between; padding: 12px 18px; background: var(--entete); color: #fff; }
.dlg-tete h3 { margin: 0; font-size: 15px; }
.fermer { background: none; border: none; color: #fff; font-size: 24px; line-height: 1; cursor: pointer; }
.dlg-corps { padding: 16px 18px; overflow-y: auto; display: flex; flex-direction: column; gap: 12px; }
.grille2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 16px; }
@media (max-width: 700px) { .grille2 { grid-template-columns: minmax(0, 1fr); } }
.plein { grid-column: 1 / -1; }
.dlg label { display: flex; flex-direction: column; gap: 4px; font-size: 12.5px; font-weight: 600; color: var(--texte-2); }
.dlg label.case { flex-direction: row; align-items: center; gap: 8px; color: var(--texte); }
.dlg input:not([type=checkbox]):not([type=file]), .dlg textarea, .dlg select { font: inherit; font-size: 14px; font-weight: 400; padding: 7px 9px; border: 1px solid var(--bord); border-radius: 6px; background: var(--carte); color: var(--texte); width: 100%; }
.dlg textarea { resize: vertical; }
fieldset { border: 1px solid var(--bord); border-radius: 8px; padding: 10px 12px; margin: 0; }
legend { font-size: 12.5px; font-weight: 700; color: var(--texte-2); padding: 0 4px; }
.choix { display: flex; flex-wrap: wrap; gap: 6px 16px; }
.choix label { flex-direction: row; align-items: center; gap: 6px; color: var(--texte); font-weight: 400; font-size: 14px; }
.tableau-edit { overflow-x: auto; margin-bottom: 8px; }
.tableau-edit table { width: 100%; min-width: 760px; border-collapse: collapse; }
.tableau-edit td, .tableau-edit th { padding: 4px; border-bottom: 1px solid var(--bord); background: none !important; color: var(--texte); }
.tableau-edit thead th { font-size: 12px; color: var(--texte-2); }
.tableau-edit textarea { min-height: 54px; font-size: 13px !important; }
.dlg-pied { display: flex; gap: 8px; align-items: center; padding: 12px 18px; border-top: 1px solid var(--bord); background: var(--carte-2); }
.espace { flex: 1; }
.btn-prim, .btn-sec { font: inherit; font-size: 13.5px; font-weight: 600; padding: 8px 14px; border-radius: 6px; cursor: pointer; }
.btn-prim { background: var(--prim); color: var(--sur-prim); border: 1px solid var(--prim); }
.btn-sec { background: var(--carte); color: var(--texte); border: 1px solid var(--bord); }
.erreur { color: #b91c1c; background: #fef2f2; border: 1px solid #fecaca; border-radius: 6px; padding: 8px 10px; font-size: 13.5px; margin: 0; }
.toast { position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%); background: #0f172a; color: #fff; padding: 10px 16px; border-radius: 8px; font-size: 14px; z-index: 100; box-shadow: 0 8px 24px rgba(0,0,0,.3); }

@media print {
  .no-print, .edit-only, .outils-fiche, .btn-pdf, .fleche { display: none !important; }
  .fiche:not([open]) > .fiche-corps { display: block; }
  .entete { position: static; background: none; color: #000; box-shadow: none; }
  body { background: #fff; font-size: 11px; } .fiche { break-inside: avoid; margin-bottom: 12px; }
}

/* Affichage dans une iframe : pas de connexion ni d'édition (cookie de session bloqué hors du site), en-tête non collant */
html.embed .entete { position: static; box-shadow: none; }
html.embed #actions { display: none !important; }
