/* Recensement des assujettis · DGIPK
   Anatomie maison (barre latérale en dégradé de marque, barre supérieure à
   recherche centrale, KPI à pastille ronde, pastilles de statut, tableaux à
   en-tête collant) habillée à la charte DGIPK : navy #050066, Ligne d'État
   bleu #009fe3 / jaune #ffed00 / rouge #e30613, Cooper Hewitt Book et Bold.
   Les neutres sont teintés vers le navy, jamais gris froids.
   Thème sombre conçu (pas inversé) : mêmes rôles, valeurs propres. */

@font-face { font-family: "Cooper Hewitt"; src: url("../fonts/CooperHewitt-Book.otf") format("opentype"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Cooper Hewitt"; src: url("../fonts/CooperHewitt-Bold.otf") format("opentype"); font-weight: 700; font-display: swap; }

/* ------------------------------------------------------------------ jetons */
:root {
  color-scheme: light dark;
  --canvas: 243 245 251;  --surface: 255 255 255;  --ink: 12 14 46;  --muted: 84 90 128;  --line: 224 228 241;
  --navy: 5 0 102;  --navy-700: 3 0 70;  --navy-50: 238 238 251;  --navy-100: 218 218 246;
  --accent: 5 0 102;
  --bleu: 0 159 227;  --rouge: 227 6 19;  --jaune: 255 237 0;
  --ok: 4 120 87;  --warn: 166 77 6;  --danger: 200 12 28;  --info: 0 112 168;  --neutre: 84 90 128;
  --champ: 255 255 255;  --champ-bord: 205 210 230;  --survol: 246 247 252;
  --ombre: 5 0 102;
  --barre: linear-gradient(180deg, #0b0a8f 0%, #050066 48%, #02003d 100%);
  --actif-fond: #ffffff;  --actif-encre: #050066;
  --nav: #d3d4f3;  --nav-ico: #9c9fe0;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --canvas: 6 8 26;  --surface: 13 16 42;  --ink: 233 235 248;  --muted: 163 169 204;  --line: 33 38 78;
    --navy: 92 98 240;  --navy-700: 120 126 250;  --navy-50: 24 27 66;  --navy-100: 38 43 98;
    --accent: 116 204 245;
    --ok: 64 214 160;  --warn: 250 190 70;  --danger: 255 112 118;  --info: 110 196 244;  --neutre: 163 169 204;
    --champ: 9 12 34;  --champ-bord: 46 52 100;  --survol: 19 23 56;
    --ombre: 0 0 0;
    --barre: linear-gradient(180deg, #07065a 0%, #04033e 50%, #020121 100%);
    --actif-fond: #74ccf5;  --actif-encre: #03022a;
    --nav: #c4c6ea;  --nav-ico: #8487c9;
  }
}
:root[data-theme="dark"] {
  --canvas: 6 8 26;  --surface: 13 16 42;  --ink: 233 235 248;  --muted: 163 169 204;  --line: 33 38 78;
  --navy: 92 98 240;  --navy-700: 120 126 250;  --navy-50: 24 27 66;  --navy-100: 38 43 98;
  --accent: 116 204 245;
  --ok: 64 214 160;  --warn: 250 190 70;  --danger: 255 112 118;  --info: 110 196 244;  --neutre: 163 169 204;
  --champ: 9 12 34;  --champ-bord: 46 52 100;  --survol: 19 23 56;
  --ombre: 0 0 0;
  --barre: linear-gradient(180deg, #07065a 0%, #04033e 50%, #020121 100%);
  --actif-fond: #74ccf5;  --actif-encre: #03022a;
  --nav: #c4c6ea;  --nav-ico: #8487c9;
}
:root[data-theme="light"] { color-scheme: light; }
:root[data-theme="dark"] { color-scheme: dark; }

html { scroll-behavior: smooth; }
body { background: rgb(var(--canvas)); color: rgb(var(--ink)); -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility; }
.tnum, table, .mono { font-variant-numeric: tabular-nums; }
:focus-visible { outline: 2px solid rgb(var(--accent)); outline-offset: 2px; border-radius: 4px; }
a, button, input, select, textarea { outline: none; }
::selection { background: rgb(var(--bleu) / .25); }

* { scrollbar-width: thin; scrollbar-color: rgb(var(--navy) / .3) transparent; }
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-thumb { background: rgb(var(--navy) / .28); border-radius: 999px; border: 3px solid transparent; background-clip: content-box; }

/* Ligne d'État : une seule fois par écran (règle de la charte). */
.ligne-etat { display: flex; height: 4px; }
.ligne-etat i { flex: 1; }
.ligne-etat i:nth-child(1) { background: #009fe3; }
.ligne-etat i:nth-child(2) { background: #ffed00; }
.ligne-etat i:nth-child(3) { background: #e30613; }

/* ------------------------------------------------------------------ barre latérale */
.sidebar-bg { background: var(--barre); }
.nav-link { display: flex; align-items: center; gap: .7rem; padding: .55rem .75rem; border-radius: .625rem;
  font-size: .875rem; color: var(--nav); transition: background-color .15s ease, color .15s ease; }
.nav-link:hover { background: rgba(255,255,255,.07); color: #fff; }
.nav-link.is-active { background: var(--actif-fond); color: var(--actif-encre); font-weight: 700;
  box-shadow: 0 4px 14px -4px rgba(0,0,0,.45); }
.nav-ico { width: 18px; height: 18px; flex: none; color: var(--nav-ico); }
.nav-link:hover .nav-ico { color: #fff; }
.nav-link.is-active .nav-ico { color: #e30613; }
.nav-badge { margin-left: auto; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 999px;
  background: #e30613; color: #fff; font-size: 11px; font-weight: 700; line-height: 20px; text-align: center; }

/* ------------------------------------------------------------------ surfaces */
.card { background: rgb(var(--surface)); border: 1px solid rgb(var(--line)); border-radius: .875rem;
  box-shadow: 0 1px 2px rgb(var(--ombre) / .05), 0 1px 3px rgb(var(--ombre) / .04); }
.card-hover { transition: box-shadow .18s ease, transform .18s ease, border-color .18s ease; }
.card-hover:hover { transform: translateY(-2px); box-shadow: 0 12px 28px -10px rgb(var(--ombre) / .22); border-color: rgb(var(--navy) / .35); }
.kpi-ico { width: 44px; height: 44px; border-radius: 999px; display: grid; place-items: center; flex: none;
  background: rgb(var(--t, var(--navy)) / .12); color: rgb(var(--t, var(--navy))); }
.kpi-ico svg { width: 20px; height: 20px; }
.titre-ico { width: 42px; height: 42px; border-radius: .75rem; display: grid; place-items: center; flex: none;
  background: rgb(var(--navy)); color: #fff; box-shadow: 0 6px 16px -6px rgb(var(--navy) / .6); }
.titre-ico svg { width: 20px; height: 20px; }

/* ------------------------------------------------------------------ pastilles */
.pill { display: inline-flex; align-items: center; gap: .35rem; padding: .16rem .55rem; border-radius: 999px;
  font-size: 11px; font-weight: 700; line-height: 1.45; white-space: nowrap;
  color: rgb(var(--p)); background: rgb(var(--p) / .11); border: 1px solid rgb(var(--p) / .28); }
.pill-dot::before { content: ""; width: 7px; height: 7px; border-radius: 999px; background: currentColor; }
.pill-brouillon, .pill-neutre { --p: var(--neutre); }
.pill-soumise, .pill-warn { --p: var(--warn); }
.pill-validee, .pill-ok { --p: var(--ok); }
.pill-rejetee, .pill-danger { --p: var(--danger); }
.pill-info { --p: var(--info); }
.pill-navy { --p: var(--navy); }

/* ------------------------------------------------------------------ boutons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: .5rem; padding: .55rem .95rem;
  border-radius: .625rem; font-size: .875rem; font-weight: 700; cursor: pointer; white-space: nowrap;
  border: 1px solid transparent; transition: background-color .15s ease, border-color .15s ease, color .15s ease, transform .15s ease, box-shadow .15s ease; }
.btn svg { width: 16px; height: 16px; }
.btn-primary { background: rgb(var(--navy)); color: #fff; box-shadow: 0 2px 6px -2px rgb(var(--navy) / .5); }
.btn-primary:hover { background: rgb(var(--navy-700)); transform: translateY(-1px); }
.btn-rouge { background: #e30613; color: #fff; }
.btn-rouge:hover { background: #b90510; transform: translateY(-1px); }
.btn-ok { background: rgb(4 120 87); color: #fff; }
.btn-ok:hover { background: rgb(3 96 70); }
.btn-outline { background: rgb(var(--surface)); color: rgb(var(--ink)); border-color: rgb(var(--champ-bord)); }
.btn-outline:hover { background: rgb(var(--survol)); border-color: rgb(var(--navy) / .45); }
.btn-ghost { background: transparent; color: rgb(var(--muted)); }
.btn-ghost:hover { background: rgb(var(--survol)); color: rgb(var(--ink)); }
.btn[disabled] { opacity: .45; cursor: not-allowed; transform: none; }
.btn-sm { padding: .4rem .65rem; font-size: .8125rem; border-radius: .5rem; }
.btn-lg { padding: .75rem 1.15rem; font-size: .9375rem; }

/* Actions rapides du tableau de bord : boutons pleins teintés. */
.qa { position: relative; display: flex; align-items: center; gap: .7rem; padding: .8rem .85rem; border-radius: .85rem;
  overflow: hidden; border: 1px solid rgb(var(--q) / .22); background: rgb(var(--q) / .08);
  transition: transform .15s ease, box-shadow .18s ease, background-color .15s ease; }
.qa:hover { transform: translateY(-2px); background: rgb(var(--q) / .13); box-shadow: 0 12px 24px -14px rgb(var(--q)); }
.qa-ico { width: 40px; height: 40px; border-radius: .65rem; display: grid; place-items: center; flex: none;
  background: rgb(var(--q)); color: #fff; box-shadow: 0 4px 10px -4px rgb(var(--q)); }
.qa-ico svg { width: 19px; height: 19px; }
.qa-t { font-size: .8125rem; font-weight: 700; line-height: 1.15; color: rgb(var(--ink)); }
.qa-d { font-size: .6875rem; line-height: 1.25; margin-top: .1rem; color: rgb(var(--muted)); }
.qa-go { margin-left: auto; color: rgb(var(--q)); transition: transform .15s ease; }
.qa:hover .qa-go { transform: translateX(3px); }
.qa-go svg { width: 16px; height: 16px; }
.qa-compteur { margin-left: auto; min-width: 26px; height: 26px; padding: 0 8px; border-radius: 999px; background: rgb(var(--q));
  color: #fff; font-size: 12px; font-weight: 700; line-height: 26px; text-align: center; }

/* ------------------------------------------------------------------ formulaires */
.field-label { display: block; font-size: .8125rem; font-weight: 700; color: rgb(var(--ink)); margin-bottom: .35rem; }
.field-req::after { content: " *"; color: rgb(var(--danger)); }
.field-help { font-size: .75rem; color: rgb(var(--muted)); margin-top: .3rem; }
.field-err { font-size: .75rem; color: rgb(var(--danger)); margin-top: .3rem; font-weight: 700; }
.input, .select, .textarea { width: 100%; min-height: 44px; background: rgb(var(--champ)); color: rgb(var(--ink));
  border: 1px solid rgb(var(--champ-bord)); border-radius: .625rem; padding: .6rem .8rem; font-size: .875rem;
  transition: border-color .15s ease, box-shadow .15s ease; }
.input::placeholder, .textarea::placeholder { color: rgb(var(--muted) / .8); }
.input:focus, .select:focus, .textarea:focus { border-color: rgb(var(--accent)); box-shadow: 0 0 0 3px rgb(var(--accent) / .18); }
.input.has-error, .select.has-error { border-color: rgb(var(--danger)); }
.input.avec-icone { padding-left: 2.25rem; }
.select { appearance: none; padding-right: 2.2rem;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%238a8fb8' stroke-width='2'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right .7rem center; }
.seg { display: inline-flex; align-items: center; gap: .5rem; padding: .55rem .85rem; border: 1px solid rgb(var(--champ-bord));
  border-radius: .625rem; font-size: .875rem; font-weight: 700; color: rgb(var(--muted)); cursor: pointer; background: rgb(var(--champ)); }
.seg:has(input:checked) { border-color: rgb(var(--accent)); color: rgb(var(--ink)); background: rgb(var(--navy) / .08);
  box-shadow: inset 0 0 0 1px rgb(var(--accent)); }
.seg input { accent-color: rgb(var(--navy)); }

/* ------------------------------------------------------------------ tableaux */
.tbl { width: 100%; border-collapse: separate; border-spacing: 0; font-size: .875rem; }
.tbl thead th { position: sticky; top: 0; z-index: 1; background: rgb(var(--canvas)); text-align: left; font-size: 11px;
  font-weight: 700; letter-spacing: .05em; text-transform: uppercase; color: rgb(var(--muted));
  padding: .7rem .9rem; border-bottom: 1px solid rgb(var(--line)); }
.tbl tbody td { padding: .75rem .9rem; border-bottom: 1px solid rgb(var(--line) / .7); vertical-align: middle; }
.tbl tbody tr { transition: background-color .12s ease; }
.tbl tbody tr:hover { background: rgb(var(--survol)); }
.tbl tbody tr:last-child td { border-bottom: 0; }
.ref { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .78rem; font-weight: 700; color: rgb(var(--accent)); }

.tabs { display: flex; gap: .25rem; border-bottom: 1px solid rgb(var(--line)); overflow-x: auto; }
.tab { padding: .65rem .2rem; margin: 0 .8rem -1px 0; font-size: .875rem; font-weight: 700; color: rgb(var(--muted));
  border-bottom: 2px solid transparent; white-space: nowrap; }
.tab:hover { color: rgb(var(--ink)); }
.tab.is-on { color: rgb(var(--ink)); border-bottom-color: #e30613; }

.bar { height: 8px; border-radius: 999px; background: rgb(var(--navy) / .1); overflow: hidden; }
.bar > span { display: block; height: 100%; border-radius: 999px; background: rgb(var(--navy)); }

dl.couples > div { padding: .55rem 0; border-bottom: 1px dashed rgb(var(--line)); }
dl.couples > div:last-child { border-bottom: 0; }
dl.couples dt { font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: rgb(var(--muted)); font-weight: 700; }
dl.couples dd { font-size: .875rem; margin-top: .1rem; }

/* Arbre des biens : un enfant se lit sous son parent, filet à gauche. */
.enfants { margin-left: 1.35rem; padding-left: 1rem; border-left: 2px solid rgb(var(--line)); }

.modale { width: min(560px, calc(100vw - 2rem)); border: 1px solid rgb(var(--line)); border-radius: .875rem; padding: 0;
  background: rgb(var(--surface)); color: rgb(var(--ink)); box-shadow: 0 24px 64px -16px rgba(2,0,40,.45); }
.modale::backdrop { background: rgba(3,2,40,.5); backdrop-filter: blur(2px); }

/* Carte Leaflet : suit le thème. */
.leaflet-container { background: rgb(var(--canvas)); font-family: inherit; border-radius: .75rem; }
:root[data-theme="dark"] .leaflet-tile-pane { filter: invert(1) hue-rotate(200deg) brightness(.85) contrast(.9); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .leaflet-tile-pane { filter: invert(1) hue-rotate(200deg) brightness(.85) contrast(.9); } }
.leaflet-popup-content-wrapper, .leaflet-popup-tip { background: rgb(var(--surface)); color: rgb(var(--ink)); }

@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.rise { animation: rise .45s ease both; }
.rise-2 { animation-delay: .06s; } .rise-3 { animation-delay: .12s; } .rise-4 { animation-delay: .18s; }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; transition-duration: .001ms !important; scroll-behavior: auto !important; }
}

@media print {
  #sn-aside, #sn-scrim, .no-print { display: none !important; }
  body { background: #fff !important; color: #000; }
  .card { box-shadow: none !important; }
}

/* Logos : version couleur sur fond clair, version blanche sur fond sombre. */
.si-sombre { display: none; }
:root[data-theme="dark"] .si-clair { display: none; }
:root[data-theme="dark"] .si-sombre { display: block; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .si-clair { display: none; }
  :root:not([data-theme="light"]) .si-sombre { display: block; }
}

/* Colonne de fond de la barre latérale (bureau) : l'aside reste collant à la
   hauteur de l'écran, la colonne descend avec la page. */
.coque-gauche { width: 16rem; flex: none; background: #02003d; }
:root[data-theme="dark"] .coque-gauche { background: #020121; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .coque-gauche { background: #020121; } }
@media (min-width: 1024px) {
  #sn-aside { transform: none; }
  .coque-gauche + #sn-aside { position: fixed; }
}

/* Icône dans une pastille : à la taille du texte. */
.pill svg { width: 12px; height: 12px; flex: none; }

/* Menu d'export : <details> natif, la liste se pose sous le bouton. */
.menu-export { position: relative; }
.menu-export > summary { list-style: none; cursor: pointer; }
.menu-export > summary::-webkit-details-marker { display: none; }
.menu-export[open] > summary { border-color: rgb(var(--accent)); }
.menu-export-liste { position: absolute; right: 0; top: calc(100% + 6px); z-index: 40; width: 280px; padding: 6px;
  background: rgb(var(--surface)); border: 1px solid rgb(var(--line)); border-radius: .875rem;
  box-shadow: 0 18px 40px -18px rgb(var(--ombre) / .45); }
.menu-export-liste a { display: flex; align-items: center; gap: .7rem; padding: .55rem .6rem; border-radius: .6rem; }
.menu-export-liste a:hover, .menu-export-liste a:focus-visible { background: rgb(var(--survol)); }
.menu-export-liste b { display: block; font-size: .875rem; }
.menu-export-liste small { display: block; font-size: .6875rem; color: rgb(var(--muted)); line-height: 1.25; }
/* Téléphone : le bouton n'est pas toujours en bout de ligne, une liste ancrée au bouton
   sortait de l'écran d'un côté ou de l'autre. Elle devient un panneau en bas d'écran. */
@media (max-width: 640px) {
  .menu-export-liste { position: fixed; left: .75rem; right: .75rem; top: auto; bottom: .75rem; width: auto; z-index: 60;
    box-shadow: 0 -10px 40px -10px rgb(var(--ombre) / .5); }
}
/* Le bloc qui porte un menu ouvert passe devant les cartes suivantes : chacune crée
   son propre contexte d'empilement (animation d'apparition), et la suivante gagnait. */
:has(> .menu-export[open]), .card:has(.menu-export[open]), .rise:has(.menu-export[open]) { position: relative; z-index: 45; }
