/* État civil — monde « Tīfaifai » : deux tons, vert uru et coton blanc.
   Le vert ne touche dans la zone de travail que ce qui s'actionne et la couture (acte cousu / brouillon faufilé). */
:root {
  --uru: #0F4C3A; --uru-fonce: #0A3A2C; --uru-voile: #DCE7E1; --sol: #E9EFEB; --coton: #FFFFFF;
  --encre: #16211C; --encre-2: #33433B; --doux: #56665E; --faible: #5F6E66;
  --ligne: #D3DDD7; --ligne-2: #E6ECE8; --entete: #F5F8F6; --faufil: #7F8A84;
  --ambre: #8A5600; --ambre-fond: #FBF1DC; --rouge: #A3312A; --rouge-fond: #FBEAE8;
  --sur-rail: rgba(255, 255, 255, .74);
  --police: "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  --papier: Cambria, Georgia, "Times New Roman", serif;
  --rayon: 8px;
  --ombre: 0 1px 2px rgba(15, 40, 30, .05), 0 8px 24px -12px rgba(15, 40, 30, .18);
  /* Couture serrée (signé) et faufil lâche (brouillon) */
  --couture: repeating-linear-gradient(var(--uru) 0 4px, transparent 4px 8px);
  --faufilage: repeating-linear-gradient(var(--faufil) 0 10px, transparent 10px 22px);
  --couture-h: repeating-linear-gradient(90deg, var(--uru) 0 4px, transparent 4px 8px);
  --faufilage-h: repeating-linear-gradient(90deg, var(--faufil) 0 10px, transparent 10px 22px);
}
* { box-sizing: border-box; }
html { color-scheme: light; }
body { margin: 0; font: 14.5px/1.5 var(--police); color: var(--encre); background: var(--sol); -webkit-font-smoothing: antialiased; caret-color: var(--uru); }
::selection { background: #CBE0D4; color: var(--encre); }
* { scrollbar-width: thin; scrollbar-color: #B9C7BF transparent; }
:focus-visible { outline: 2px dashed var(--uru); outline-offset: 3px; }
a { color: var(--uru); text-underline-offset: 3px; }
.num, td, .chiffres { font-variant-numeric: tabular-nums; }
svg.ic { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.cache { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- Coque ---------- */
.coque { display: grid; grid-template-columns: 256px minmax(0, 1fr); min-height: 100vh; }
.rail { position: sticky; top: 0; height: 100vh; background: var(--uru); color: #fff; display: flex; flex-direction: column; padding: 26px 16px 20px; }
.marque { padding: 0 12px 22px; margin-bottom: 14px; border-bottom: 1px solid rgba(255, 255, 255, .14); }
.marque b { display: block; font-size: 19px; font-weight: 600; letter-spacing: -.01em; }
.marque span { font-size: 13px; color: var(--sur-rail); }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a { display: flex; align-items: center; gap: 12px; min-height: 40px; padding: 0 12px; border-radius: 6px; color: rgba(255, 255, 255, .82); text-decoration: none; transition: background .15s ease-out; }
.nav a:hover { background: rgba(255, 255, 255, .08); color: #fff; }
.nav a[aria-current="page"] { background: rgba(255, 255, 255, .15); color: #fff; font-weight: 600; }
.nav a:focus-visible { outline-color: #fff; }
.pastille { margin-left: auto; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 10px; background: #fff; color: var(--uru); font-size: 12px; font-weight: 700; display: grid; place-items: center; }
.agent { margin-top: auto; display: flex; align-items: center; gap: 12px; padding: 16px 12px 0; border-top: 1px solid rgba(255, 255, 255, .14); }
.initiales { width: 34px; height: 34px; flex: none; border-radius: 50%; background: rgba(255, 255, 255, .15); display: grid; place-items: center; font-size: 12px; font-weight: 600; letter-spacing: .04em; }
.agent b { display: block; font-weight: 600; line-height: 1.3; }
.agent .role { font-size: 12px; color: var(--sur-rail); }
.agent a, .agent button { color: var(--sur-rail); font: inherit; font-size: 12px; background: none; border: 0; padding: 0; cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }
.agent a:hover, .agent button:hover { color: #fff; }
.agent .liens { display: flex; gap: 12px; margin-top: 4px; white-space: nowrap; }

main { padding: 30px 40px 64px; min-width: 0; max-width: 1280px; }
h1 { font-size: 26px; font-weight: 600; letter-spacing: -.01em; line-height: 1.2; margin: 0; }
h2 { font-size: 17px; font-weight: 600; margin: 0; }
h3 { font-size: 14px; font-weight: 600; margin: 0; }
.tete { display: flex; align-items: flex-end; gap: 16px; flex-wrap: wrap; margin-bottom: 22px; }
.tete .sous { color: var(--doux); margin: 4px 0 0; }
.tete .actions { margin-left: auto; }
.pile > * + * { margin-top: 22px; }
.pile-s > * + * { margin-top: 12px; }
.ligne-flex { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.espace { flex: 1; }
.doux { color: var(--doux); }
.faible { color: var(--faible); }
.nom { font-weight: 600; letter-spacing: .02em; }

/* ---------- Contrôles ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 40px; padding: 0 16px; border-radius: var(--rayon); border: 1px solid var(--ligne); background: var(--coton); color: var(--encre); font: 600 14px var(--police); cursor: pointer; text-decoration: none; white-space: nowrap; transition: background .15s ease-out, border-color .15s ease-out; }
.btn:hover { border-color: var(--uru); }
.btn.primaire { background: var(--uru); border-color: var(--uru); color: #fff; }
.btn.primaire:hover { background: var(--uru-fonce); }
.btn.grand { min-height: 48px; padding: 0 22px 0 18px; font-size: 15px; }
.btn.danger { color: var(--rouge); }
.btn.danger:hover { border-color: var(--rouge); }
.btn.lien { border-color: transparent; background: none; color: var(--uru); padding: 0 8px; }
.btn[disabled], .btn[aria-busy="true"] { opacity: .55; cursor: not-allowed; }
.recherche { flex: 1; min-width: 260px; display: flex; align-items: center; gap: 12px; height: 48px; padding: 0 16px; background: var(--coton); border: 1px solid #C6D2CB; border-radius: var(--rayon); color: var(--doux); }
.recherche:focus-within { outline: 2px dashed var(--uru); outline-offset: 3px; }
.recherche input { flex: 1; min-width: 0; border: 0; outline: 0; background: none; font: 15px var(--police); color: var(--encre); }
.recherche input::placeholder { color: #66756D; }
kbd { font: 12px var(--police); padding: 2px 7px; border: 1px solid #D3DDD7; border-radius: 4px; color: var(--faible); }
label.champ { display: flex; flex-direction: column; gap: 5px; font-size: 13px; color: var(--doux); }
label.champ b { color: var(--rouge); font-weight: 400; }
input, select, textarea { font: 14.5px var(--police); color: var(--encre); background: var(--coton); border: 1px solid #C6D2CB; border-radius: 6px; padding: 8px 10px; min-height: 40px; width: 100%; }
input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 2px dashed var(--uru); outline-offset: 2px; border-color: var(--uru); }
input::placeholder, textarea::placeholder { color: #66756D; }
textarea { resize: vertical; line-height: 1.5; }
input[type="checkbox"] { width: 18px; height: 18px; min-height: 0; accent-color: var(--uru); margin: 0; }
input[type="file"] { padding: 6px; }
.case { display: flex; gap: 10px; align-items: center; font-size: 14px; color: var(--encre); min-height: 32px; }

/* ---------- Surfaces ---------- */
.carte { background: var(--coton); border: 1px solid var(--ligne); border-radius: var(--rayon); }
.carte.pad { padding: 20px 22px; }
.carte > h2 { margin-bottom: 14px; }
.bandeau { display: flex; align-items: center; gap: 12px; min-height: 48px; padding: 10px 18px; background: var(--coton); border: 1px solid var(--ligne); border-radius: var(--rayon); }
.bandeau .point { width: 8px; height: 8px; border-radius: 50%; background: #C98A1B; flex: none; }
.bandeau a { margin-left: auto; font-weight: 600; text-decoration: none; white-space: nowrap; }
.bandeau.alerte { background: var(--ambre-fond); border-color: #EBD3A4; color: var(--ambre); }
.bandeau.erreur { background: var(--rouge-fond); border-color: #EFC4BF; color: var(--rouge); }

.onglets { display: flex; gap: 28px; box-shadow: inset 0 -1px 0 #C9D5CE; overflow-x: auto; overflow-y: hidden; scrollbar-width: none; }
.onglets button, .onglets a { padding: 0 0 11px; border: 0; border-bottom: 2px solid transparent; background: none; color: #4A5A52; font: 14.5px var(--police); cursor: pointer; white-space: nowrap; text-decoration: none; }
.onglets button:hover, .onglets a:hover { color: var(--encre); }
.onglets [aria-selected="true"] { color: var(--uru); font-weight: 600; border-color: var(--uru); }
.onglets i { font-style: normal; font-size: 12px; color: var(--faible); margin-left: 6px; }
.onglets [aria-selected="true"] i { color: var(--uru); }

table { width: 100%; border-collapse: collapse; }
.table { background: var(--coton); border: 1px solid var(--ligne); border-radius: var(--rayon); overflow: hidden; }
.table.colle { margin-top: -8px; }
th { height: 40px; padding: 0 16px; text-align: left; font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--doux); background: var(--entete); border-bottom: 1px solid #DCE4DF; white-space: nowrap; }
td { height: 52px; padding: 8px 16px; border-bottom: 1px solid var(--ligne-2); vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
tr[data-href] { cursor: pointer; }
tr[data-href]:hover td { background: #F3F7F5; }
tr[data-href]:focus-visible { outline-offset: -3px; }
td.vide { color: var(--doux); text-align: center; height: 96px; }
td.actions { text-align: right; white-space: nowrap; }

/* Signature du monde : la couture en tête de ligne. */
.cousu td:first-child, .faufile td:first-child { position: relative; padding-left: 42px; }
.table thead th:first-child { padding-left: 42px; }
.cousu td:first-child::before, .faufile td:first-child::before { content: ""; position: absolute; left: 21px; width: 2px; top: 12px; bottom: 12px; }
.cousu td:first-child::before { background: var(--couture); }
.faufile td:first-child::before { top: 10px; bottom: 10px; background: var(--faufilage); }
.etat { display: inline-flex; align-items: center; height: 24px; padding: 0 10px; border-radius: 12px; font-size: 12.5px; font-weight: 600; background: #EEF2EF; color: var(--encre-2); white-space: nowrap; }
.etat.brouillon, .etat.ambre { background: var(--ambre-fond); color: var(--ambre); }
.etat.rouge { background: var(--rouge-fond); color: var(--rouge); }
.etat.vert { background: var(--uru-voile); color: var(--uru); }

/* ---------- Fiche d'acte ---------- */
.fiche-tete { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; margin-bottom: 6px; }
.voisins { margin-left: auto; display: flex; gap: 6px; }
.plaques { display: flex; gap: 12px; flex-wrap: wrap; margin: 18px 0 22px; }
.plaque { background: var(--coton); border: 1px solid var(--ligne); border-radius: var(--rayon); padding: 12px 16px; min-width: 240px; }
.plaque .qui { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--doux); font-weight: 600; }
.plaque .nom-complet { font-size: 16px; margin: 2px 0; }
.plaque .ne { font-size: 13px; color: var(--doux); }
.page-registre { display: grid; grid-template-columns: 250px minmax(0, 1fr); background: var(--coton); border: 1px solid var(--ligne); border-radius: var(--rayon); position: relative; }
.page-registre .marge { padding: 18px 18px 18px 30px; border-right: 1px solid var(--ligne); position: relative; }
.page-registre .marge::before { content: ""; position: absolute; left: 14px; top: 16px; bottom: 16px; width: 2px; background: var(--couture); }
.page-registre.brouillon .marge::before { background: var(--faufilage); }
.page-registre .marge h3 { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--doux); margin-bottom: 10px; }
.page-registre .texte { padding: 18px 28px; font: 16px/1.8 var(--papier); color: var(--encre); max-width: 76ch; }
.page-registre .texte p { margin: 0 0 12px; }
.mention { font-family: var(--papier); font-size: 14px; line-height: 1.5; margin-bottom: 12px; }
.mention small { display: block; font: 11.5px var(--police); color: var(--doux); margin-top: 2px; }
.colonnes { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 20px; }
.liste-simple { margin: 0; padding: 0; list-style: none; }
.liste-simple li { display: flex; gap: 12px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--ligne-2); }
.liste-simple li:last-child { border-bottom: 0; }
.vignette { width: 56px; height: 72px; object-fit: cover; border: 1px solid var(--ligne); border-radius: 4px; background: var(--entete); flex: none; }
.icone-doc { width: 56px; height: 72px; display: grid; place-items: center; border: 1px solid var(--ligne); border-radius: 4px; background: var(--entete); color: var(--doux); font-size: 12px; font-weight: 600; flex: none; }

/* ---------- Formulaires ---------- */
form.saisie fieldset { border: 1px solid var(--ligne); border-radius: var(--rayon); background: var(--coton); margin: 0 0 16px; padding: 14px 20px 20px; }
form.saisie legend { font-weight: 600; padding: 0 6px; }
.grille { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px 16px; }
.grille .large { grid-column: span 2; }
.choix-types { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.choix-types a { display: block; padding: 16px 18px; background: var(--coton); border: 1px solid var(--ligne); border-radius: var(--rayon); text-decoration: none; color: var(--encre); }
.choix-types a:hover { border-color: var(--uru); }
.choix-types b { display: block; color: var(--uru); font-size: 15px; }
.choix-types span { font-size: 13px; color: var(--doux); }
.barre-actions { position: sticky; bottom: 0; display: flex; gap: 10px; padding: 14px 0; background: linear-gradient(transparent, var(--sol) 30%); }

/* Livret à mettre à jour : faufilé, comme un brouillon. */
.a-jour { display: inline-block; width: 28px; height: 2px; background: var(--couture-h); vertical-align: middle; margin-right: 8px; }
.a-reprendre { display: inline-block; width: 28px; height: 2px; background: var(--faufilage-h); vertical-align: middle; margin-right: 8px; }

/* ---------- Connexion ---------- */
.connexion { min-height: 100vh; display: grid; grid-template-columns: minmax(320px, 440px) 1fr; }
.connexion .panneau { background: var(--uru); color: #fff; padding: 48px 44px; display: flex; flex-direction: column; }
.connexion .panneau b { font-size: 24px; font-weight: 600; }
.connexion .panneau p { color: var(--sur-rail); margin: 6px 0 0; }
.connexion .panneau .bas { margin-top: auto; font-size: 13px; color: var(--sur-rail); }
.connexion .cote { display: grid; place-items: center; padding: 40px; }
.connexion form { width: min(380px, 100%); }
.connexion h1 { margin-bottom: 6px; }

/* ---------- Messages et dialogue ---------- */
.messages { position: fixed; right: 24px; bottom: 24px; display: flex; flex-direction: column; gap: 8px; z-index: 20; }
.message { background: var(--encre); color: #fff; padding: 12px 16px; border-radius: var(--rayon); box-shadow: var(--ombre); max-width: 420px; animation: monte .25s cubic-bezier(.22, 1, .36, 1); }
.message.erreur { background: var(--rouge); }
@keyframes monte { from { transform: translateY(8px); opacity: 0; } }
dialog { border: 1px solid var(--ligne); border-radius: 10px; padding: 24px; max-width: 460px; box-shadow: 0 24px 60px -20px rgba(15, 40, 30, .45); color: var(--encre); }
dialog::backdrop { background: rgba(10, 30, 22, .35); }
dialog p { margin: 8px 0 20px; color: var(--encre-2); }
dialog .ligne-flex { justify-content: flex-end; }
.chargement { color: var(--doux); padding: 40px 0; }

/* ---------- Documents imprimables ---------- */
.doc { position: relative; background: var(--coton); border: 1px solid var(--ligne); max-width: 800px; padding: 52px 60px; font-family: var(--papier); overflow: hidden; }
.doc header { text-align: center; font: 600 12px var(--police); text-transform: uppercase; letter-spacing: .1em; color: var(--encre-2); }
.doc header p { margin: 0; }
.doc header .commune { font-size: 14px; color: var(--encre); margin-top: 6px; }
.doc h1 { text-align: center; font: 600 21px/1.3 var(--papier); margin: 30px 0 4px; }
.doc .sous-titre { text-align: center; color: var(--doux); margin: 0 0 28px; font-size: 14px; }
.doc p { line-height: 1.75; }
.doc dl { display: grid; grid-template-columns: 200px 1fr; gap: 8px 18px; margin: 0; }
.doc dt { color: var(--doux); font-size: 14px; }
.doc dd { margin: 0; }
.doc.plurilingue dl { grid-template-columns: 330px 1fr; }
.doc.plurilingue dt { font: 12px/1.4 var(--police); }
.doc h2 { font: 600 15px var(--papier); margin: 30px 0 8px; }
.doc footer { margin-top: 44px; display: flex; justify-content: flex-end; text-align: right; }
.doc .signatures { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 24px; margin-top: 44px; }
.doc .signatures div { border-top: 1px solid var(--encre-2); padding-top: 6px; font: 12px var(--police); color: var(--doux); min-height: 70px; }
.doc .avert { font: 11px var(--police); color: var(--doux); text-align: center; margin-top: 36px; }
.doc table th { background: none; }
.specimen { position: absolute; inset: 0; display: grid; place-items: center; font: 700 120px var(--police); color: rgba(163, 49, 42, .08); transform: rotate(-30deg); pointer-events: none; }
.feuillet { display: grid; grid-template-columns: 170px 1fr; gap: 0; }
.feuillet .marge-f { border-right: 1px solid var(--encre-2); padding-right: 14px; font: 13px var(--police); }
.feuillet .marge-f .numero { font: 600 18px var(--papier); margin-bottom: 12px; }
.feuillet .corps { padding-left: 22px; }
.saut { break-after: page; }
.outils { display: flex; gap: 10px; margin-bottom: 18px; flex-wrap: wrap; }

/* ---------- Adaptation ---------- */
@media (max-width: 1100px) {
  .grille { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .page-registre { grid-template-columns: 1fr; }
  .page-registre .marge { border-right: 0; border-bottom: 1px solid var(--ligne); }
}
@media (max-width: 960px) {
  .coque { grid-template-columns: 72px minmax(0, 1fr); }
  .rail { padding: 20px 10px; align-items: center; }
  .marque span, .marque b span, .nav a span.libelle, .agent > div, .pastille { display: none; }
  .marque { padding: 0 0 16px; text-align: center; }
  .marque b { font-size: 13px; }
  .nav a { justify-content: center; padding: 0; width: 48px; position: relative; }
  .nav a .pastille-mini { position: absolute; top: 6px; right: 6px; width: 8px; height: 8px; border-radius: 50%; background: #fff; }
  .agent { padding: 14px 0 0; justify-content: center; }
  main { padding: 24px 22px 56px; }
  .connexion { grid-template-columns: 1fr; }
  .connexion .panneau { padding: 28px 24px; }
}
@media (min-width: 961px) { .nav a .pastille-mini { display: none; } }
@media (max-width: 640px) {
  .coque { grid-template-columns: 1fr; }
  .rail { position: static; height: auto; flex-direction: row; align-items: center; padding: 8px 10px; gap: 8px; overflow-x: auto; }
  .marque { border: 0; margin: 0; padding: 0 6px; }
  .nav { flex-direction: row; }
  .nav a { width: 44px; min-height: 44px; }
  .agent { margin: 0 0 0 auto; border: 0; padding: 0; }
  .grille { grid-template-columns: 1fr; }
  .grille .large { grid-column: auto; }
  .doc { padding: 28px 20px; }
  .doc dl, .doc.plurilingue dl, .feuillet { grid-template-columns: 1fr; }
  .table { overflow-x: auto; }
  .liste-actes th:nth-child(n+3), .liste-actes td:nth-child(n+3) { display: none; }
  kbd { display: none; }
  .bandeau { flex-wrap: wrap; }
  .bandeau a { margin-left: 0; }
}

@page { size: A4; margin: 18mm 20mm; }
@media print {
  body { background: #fff; }
  .coque { display: block; }
  .rail, .outils, .messages, .ecran { display: none !important; }
  main { padding: 0; max-width: none; }
  .doc { border: 0; max-width: none; padding: 0; }
  .table { border: 0; }
}
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
.etroit { max-width: 560px; }
.moyen { max-width: 720px; }
.haut { margin-top: 16px; }
.agent a.initiales { color: #fff; text-decoration: none; background: rgba(255, 255, 255, .15); display: grid; place-items: center; font-size: 12px; }
/* L'état se détache du fond vert-gris dans l'en-tête de l'acte. */
.fiche-tete .etat:not(.brouillon) { background: var(--coton); border: 1px solid var(--ligne); }
/* Logo de la commune : pastille ronde dans le rail et à la connexion, emblème détouré sur le papier. */
.marque { display: flex; align-items: center; gap: 12px; }
.marque .logo { width: 44px; height: 44px; border-radius: 50%; flex: none; box-shadow: 0 0 0 2px rgba(255, 255, 255, .2); }
.connexion .panneau .logo { width: 96px; height: 96px; border-radius: 50%; margin-bottom: 28px; box-shadow: 0 0 0 3px rgba(255, 255, 255, .2); }
.doc header .embleme { display: block; height: 64px; width: auto; margin: 0 auto 12px; }
@media (max-width: 960px) {
  .marque { justify-content: center; }
  .marque b { display: none; }
  .marque .logo { width: 40px; height: 40px; }
  .connexion .panneau .logo { width: 64px; height: 64px; margin-bottom: 18px; }
}
@media (max-width: 640px) { .marque .logo { width: 34px; height: 34px; } }
