/* Aucune police ni ressource externe : piles système uniquement. */
:root {
  color-scheme: light;
  --ink: #18222d;
  --ink-soft: #55636f;
  --paper: #f3f5f7;
  --surface: #ffffff;
  --rule: #d5dbe1;
  --accent: #1b4f7a;      /* bleu lampe à fente */
  --accent-ink: #ffffff;
  --danger-ink: #ffffff;
  --valide: #1d6b45;
  --valide-bg: #e3f2e9;
  --avalider: #7a5a00;
  --avalider-bg: #fbf1d4;
  --arevoir: #a3261c;
  --arevoir-bg: #fbe5e2;
  --focus: #2f7fd1;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
}
@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --ink: #e3e8ed;
    --ink-soft: #9aa7b3;
    --paper: #141a20;
    --surface: #1c242c;
    --rule: #33404b;
    --accent: #7fb3e0;
    --accent-ink: #0f1820;
    --danger-ink: #1f0d0b;
    --valide: #7fd3a3;
    --valide-bg: #183528;
    --avalider: #e9c766;
    --avalider-bg: #362d12;
    --arevoir: #f2958b;
    --arevoir-bg: #3d1c19;
  }
}

* { box-sizing: border-box; }
html { font-size: 15px; }
body { margin: 0; font-family: var(--font); color: var(--ink); background: var(--paper); line-height: 1.5; }
a { color: var(--accent); }
a:hover { text-decoration-thickness: 2px; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
h1 { font-size: 1.6rem; line-height: 1.2; margin: 0 0 .4rem; letter-spacing: -.01em; }
h2 { font-size: 1.1rem; margin: 2rem 0 .6rem; }
main { max-width: 1240px; margin: 0 auto; padding: 1.5rem 1.25rem 3rem; }
footer { max-width: 1240px; margin: 0 auto; padding: 1rem 1.25rem 2rem; color: var(--ink-soft); font-size: .85rem; border-top: 1px solid var(--rule); }
code, .mono-wrap { font-family: var(--mono); font-size: .9em; word-break: break-all; }

/* En-tête */
.top { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem 1.5rem; padding: .7rem 1.25rem; background: var(--surface); border-bottom: 1px solid var(--rule); }
.brand { font-weight: 700; text-decoration: none; color: var(--ink); display: flex; flex-direction: column; line-height: 1.15; }
.brand small { font-weight: 400; color: var(--ink-soft); font-size: .8rem; }
.top nav { display: flex; flex-wrap: wrap; gap: .25rem; flex: 1; }
.top nav a { text-decoration: none; color: var(--ink-soft); padding: .35rem .6rem; border-radius: 4px; }
.top nav a:hover { color: var(--ink); background: var(--paper); }
.top nav a[aria-current="page"] { color: var(--ink); box-shadow: inset 0 -2px 0 var(--accent); border-radius: 0; }
.who { display: flex; align-items: center; gap: .6rem; font-size: .9rem; }
.who form { margin: 0; }
.role { color: var(--ink-soft); font-size: .8rem; }

.banner { margin: 0; padding: .6rem 1.25rem; font-size: .92rem; }
.banner-alerte { background: var(--avalider-bg); color: var(--avalider); }
.banner-erreur { background: var(--arevoir-bg); color: var(--arevoir); }
.banner a { color: inherit; font-weight: 600; }

/* Le sctid : partition et chiffre de contrôle rendus lisibles */
.sctid { font-family: var(--mono); font-variant-numeric: tabular-nums; white-space: nowrap; text-decoration: none; color: var(--ink); letter-spacing: .01em; }
a.sctid:hover .sctid-part, a.sctid:hover { color: var(--accent); }
.sctid-part { color: var(--ink-soft); margin-left: .12em; }
.sctid-chk { color: var(--accent); font-weight: 700; margin-left: .12em; }
.id-block .sctid { font-size: 1.5rem; display: inline-block; padding: .35rem .6rem; border: 1px solid var(--rule); border-radius: 4px; background: var(--surface); }

/* Statuts et états */
.statut { display: inline-block; font-size: .8rem; font-weight: 600; padding: .05rem .5rem; border-radius: 999px; white-space: nowrap; }
.statut-valide { color: var(--valide); background: var(--valide-bg); }
.statut-avalider { color: var(--avalider); background: var(--avalider-bg); }
.statut-arevoir { color: var(--arevoir); background: var(--arevoir-bg); }
.etat { display: inline-block; font-size: .78rem; color: var(--arevoir); border: 1px solid currentColor; border-radius: 3px; padding: 0 .35rem; margin-left: .25rem; }

/* Mise en page */
.head { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; flex-wrap: wrap; margin-bottom: 1rem; }
.lede { color: var(--ink-soft); max-width: 75ch; margin: .2rem 0 1rem; }
.sub, .hint { color: var(--ink-soft); font-size: .86rem; font-weight: 400; }
.crumbs { margin: 0 0 .5rem; font-size: .9rem; }
.empty { padding: 1.25rem; background: var(--surface); border: 1px dashed var(--rule); border-radius: 4px; }
.cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 1rem; align-items: start; }
.panel { background: var(--surface); border: 1px solid var(--rule); border-radius: 6px; padding: 1rem 1.25rem 1.25rem; }
.panel h2 { margin-top: 0; }
.panel.narrow { max-width: 520px; margin-top: 2rem; }

/* Formulaires */
label { display: flex; flex-direction: column; gap: .25rem; font-size: .88rem; font-weight: 600; }
label.check, label.radio { flex-direction: row; align-items: center; gap: .4rem; font-weight: 400; }
input, select, textarea { font: inherit; color: var(--ink); background: var(--surface); border: 1px solid var(--rule); border-radius: 4px; padding: .45rem .55rem; min-width: 0; font-weight: 400; }
textarea { resize: vertical; }
input[type="checkbox"], input[type="radio"] { width: 1rem; height: 1rem; accent-color: var(--accent); }
button, .button { font: inherit; font-weight: 600; cursor: pointer; border: 1px solid var(--rule); background: var(--surface); color: var(--ink); border-radius: 4px; padding: .5rem .9rem; text-decoration: none; display: inline-block; }
button:hover, .button:hover { border-color: var(--ink-soft); }
button.primary, .button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
button.danger { background: var(--arevoir); border-color: var(--arevoir); color: var(--danger-ink); }
button.small { padding: .25rem .6rem; font-size: .85rem; }
button.linkish { border: 0; background: none; padding: 0; color: var(--accent); font-weight: 400; text-decoration: underline; }
.danger-text { color: var(--arevoir) !important; }
.stack { display: flex; flex-direction: column; gap: .8rem; }
.filters, .inline-add { display: flex; flex-wrap: wrap; gap: .75rem; align-items: flex-end; margin: 0 0 1.25rem; padding: .9rem 1rem; background: var(--surface); border: 1px solid var(--rule); border-radius: 6px; }
.grow { flex: 1 1 240px; }

/* Tableaux */
.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--rule); border-radius: 6px; }
table { width: 100%; border-collapse: collapse; font-size: .92rem; }
th { text-align: left; font-size: .8rem; font-weight: 600; color: var(--ink-soft); padding: .55rem .75rem; border-bottom: 1px solid var(--rule); white-space: nowrap; }
td { padding: .55rem .75rem; border-bottom: 1px solid var(--rule); vertical-align: top; }
tbody tr:last-child td { border-bottom: 0; }
td.fsn, .fsn-line { color: var(--ink-soft); }
.row-hors-release td { background: var(--arevoir-bg); }
.missing { color: var(--avalider); font-style: italic; }
.res-rejete td { background: var(--arevoir-bg); }
.res-cree td:nth-child(3), .res-reintegre td:nth-child(3), .res-mis-a-jour td:nth-child(3) { color: var(--valide); font-weight: 600; }
.row-form { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; margin: 0; }
.row-form .w-abbr { width: 7rem; font-weight: 700; }
.row-form .w-sctid { width: 9.5rem; font-family: var(--mono); }
.row-form .grow { flex: 1 1 220px; }
.row-label { font-size: .85rem; color: var(--ink-soft); min-width: 9rem; }
.row-delete { margin: .3rem 0 0; }

/* Fiche concept */
.concept-head { display: flex; gap: 1.25rem; align-items: flex-start; flex-wrap: wrap; margin-bottom: 1rem; }
.concept-head h1 { margin-bottom: .1rem; }
.fsn-line { margin: 0 0 .5rem; }
.facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: .75rem 1.5rem; margin: 0 0 1.5rem; padding: .9rem 1rem; background: var(--surface); border: 1px solid var(--rule); border-radius: 6px; }
.facts dt { font-size: .8rem; color: var(--ink-soft); }
.facts dd { margin: 0; }
.callout { border-left: 4px solid var(--arevoir); background: var(--arevoir-bg); padding: .75rem 1rem; border-radius: 0 6px 6px 0; margin-bottom: 1.5rem; }
.callout p { margin: .2rem 0; }
.edit { display: flex; flex-direction: column; gap: .9rem; max-width: 760px; background: var(--surface); border: 1px solid var(--rule); border-radius: 6px; padding: 1rem 1.25rem 1.25rem; }
.edit h2 { margin: 0; }
.statuts { border: 0; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: .5rem 1.25rem; }
.statuts legend { font-weight: 600; font-size: .88rem; margin-bottom: .35rem; }
.statuts .hint { flex-basis: 100%; margin: 0; }
.danger-zone { margin-top: 2rem; max-width: 760px; padding: 1rem 1.25rem; border: 1px solid var(--arevoir); border-radius: 6px; display: flex; flex-direction: column; gap: .7rem; align-items: flex-start; }
.danger-zone h2 { margin: 0; color: var(--arevoir); }
.danger-zone p { margin: 0; }
.danger-zone label { align-self: stretch; }
.abbr-list { padding-left: 1.1rem; }

/* Historique */
.events { list-style: none; padding: 0; margin: 0; background: var(--surface); border: 1px solid var(--rule); border-radius: 6px; }
.events li { display: grid; grid-template-columns: 9.5rem 9rem 1fr; gap: .2rem 1rem; padding: .6rem .9rem; border-bottom: 1px solid var(--rule); font-size: .9rem; }
.events li:last-child { border-bottom: 0; }
.events time { color: var(--ink-soft); font-variant-numeric: tabular-nums; }
.events .who-did { font-weight: 600; }
.events .details { grid-column: 3; font-size: .85rem; color: var(--ink-soft); }
.k { display: inline-block; min-width: 7rem; color: var(--ink-soft); }
del { color: var(--arevoir); text-decoration-thickness: 1px; }
ins { color: var(--valide); text-decoration: none; font-weight: 600; }
.pager { display: flex; gap: 1.5rem; }

/* Messages */
.flash { padding: .65rem 1rem; border-radius: 4px; margin: 0 0 1rem; }
.flash-ok { background: var(--valide-bg); color: var(--valide); }
.flash-erreur { background: var(--arevoir-bg); color: var(--arevoir); }
.flash-alerte { background: var(--avalider-bg); color: var(--avalider); }

/* Connexion */
.login { max-width: 380px; margin: 12vh auto 0; }
.login h1 { font-size: 1.8rem; }

@media (max-width: 720px) {
  .events li { grid-template-columns: 1fr; }
  .events .details { grid-column: 1; }
  .top nav { order: 3; flex: 1 1 100%; flex-wrap: nowrap; overflow-x: auto; }
  .top nav a { white-space: nowrap; }
  .who { margin-left: auto; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
