/* AKILI — feuille de style unique, sans police ni ressource externe (réseaux lents, CSP stricte). */
:root {
  --ink: #0B2A5B;          /* encre marine (logo) */
  --ink-2: #183E78;
  --signal: #0A66C2;       /* bleu signal : actions */
  --field: #2E7D3A;        /* vert terrain : fait, conforme */
  --paper: #F5F7FA;        /* papier froid */
  --surface: #FFFFFF;
  --line: #D6DEE8;
  --text: #16202C;
  --muted: #5A6778;
  --wait: #A86B0C;         /* ambre : en attente */
  --wait-bg: #FFF4DF;
  --stop: #B42318;         /* rouge : rejet, écart */
  --stop-bg: #FDECEA;
  --ok-bg: #E7F4EA;
  --info-bg: #E6F0FB;
  --radius: 6px;
  --gap: 1rem;
  --sidebar: 248px;
  font-size: 15px;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--paper); color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", Ubuntu, sans-serif;
  line-height: 1.5;
}
a { color: var(--signal); text-underline-offset: 2px; }
a:hover { color: var(--ink); }
:focus-visible { outline: 3px solid #F2B705; outline-offset: 2px; }
h1, h2, h3 { color: var(--ink); line-height: 1.2; margin: 0 0 .5rem; }
h1 { font-size: 1.55rem; font-weight: 700; letter-spacing: -.01em; }
h2 { font-size: 1.12rem; font-weight: 650; margin-top: 1.75rem; }
h3 { font-size: .98rem; font-weight: 650; margin-top: 1.25rem; }
p { margin: 0 0 .75rem; max-width: 72ch; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.num, td.num, th.num { font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }
.icon { width: 18px; height: 18px; flex: none; vertical-align: -3px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* ---------- Cadre ---------- */
.shell { display: grid; grid-template-columns: var(--sidebar) 1fr; min-height: 100vh; }
.sidebar { background: var(--ink); color: #DCE6F5; padding: 1rem .75rem; position: sticky; top: 0; height: 100vh;
  overflow-y: auto; }
.brand { display: flex; gap: .6rem; align-items: center; padding: .25rem .5rem 1rem; color: #fff; text-decoration: none; }
.brand img { width: 40px; height: 32px; object-fit: contain; background: #fff; border-radius: 4px; padding: 2px; }
.brand b { font-size: 1.25rem; letter-spacing: .06em; display: block; }
.brand small { font-size: .72rem; color: #AFC2DE; line-height: 1.2; display: block; }
.nav h4 { font-size: .74rem; color: #8FA6C8; font-weight: 600; margin: 1rem .5rem .35rem; }
.nav a { display: flex; gap: .55rem; align-items: center; padding: .45rem .5rem; border-radius: var(--radius);
  color: #DCE6F5; text-decoration: none; font-size: .93rem; }
.nav a:hover { background: var(--ink-2); color: #fff; }
.nav a[aria-current="page"] { background: #fff; color: var(--ink); font-weight: 600; }
.nav .count { margin-left: auto; background: #F2B705; color: var(--ink); border-radius: 999px; padding: 0 .45rem;
  font-size: .75rem; font-weight: 700; }
.main { min-width: 0; display: flex; flex-direction: column; }
.topbar { display: flex; align-items: center; gap: .75rem; padding: .6rem 1.5rem; background: var(--surface);
  border-bottom: 1px solid var(--line); }
.topbar .spacer { flex: 1; }
.topbar form { margin: 0; }
.mobile-nav { display: none; }
.content { padding: 1.5rem; max-width: 1280px; width: 100%; }
.env-banner { background: var(--wait-bg); color: #6B4500; font-size: .82rem; padding: .3rem 1.5rem;
  border-bottom: 1px solid #F1D49B; }
.offline-banner { display: none; background: var(--stop); color: #fff; padding: .4rem 1.5rem; font-size: .88rem; }
body.is-offline .offline-banner { display: block; }
.footer { padding: 1rem 1.5rem 2rem; color: var(--muted); font-size: .8rem; }

/* ---------- En-tête de page et dossier ---------- */
.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; gap: .75rem 1.5rem; margin-bottom: 1.25rem; }
.page-head .grow { flex: 1 1 320px; }
.page-head p { margin: .2rem 0 0; color: var(--muted); }
.ref { font-variant-numeric: tabular-nums; font-weight: 750; color: var(--ink); letter-spacing: .01em;
  font-size: clamp(1.35rem, 2.6vw, 2rem); line-height: 1.1; display: block; }
.ref-sub { color: var(--muted); font-size: .85rem; }
.actions { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }

/* Chaîne du dossier : le seul élément expressif de l'interface */
.chain { list-style: none; display: grid; grid-template-columns: repeat(7, 1fr); gap: 0; padding: 0;
  margin: 0 0 1.5rem; counter-reset: none; }
.chain__step { position: relative; padding: .55rem .4rem 0 0; font-size: .8rem; color: var(--muted); }
.chain__step::before { content: ""; position: absolute; top: 0; left: 0; right: 0; height: 5px; background: var(--line); }
.chain__step:first-child::before { border-radius: 3px 0 0 3px; }
.chain__step:last-child::before { border-radius: 0 3px 3px 0; }
.chain__n { display: inline-block; min-width: 1.4em; font-weight: 700; font-variant-numeric: tabular-nums; }
.chain__step--done::before { background: var(--field); }
.chain__step--done { color: var(--text); }
.chain__step--current::before { background: linear-gradient(90deg, var(--signal) 50%, var(--line) 50%); }
.chain__step--current { color: var(--ink); font-weight: 650; }
.chain__step--failed::before { background: var(--stop); }
.chain__step--failed { color: var(--stop); font-weight: 650; }

/* ---------- Blocs ---------- */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem 1.15rem;
  margin-bottom: var(--gap); }
.panel > h2:first-child, .panel > h3:first-child { margin-top: 0; }
.grid { display: grid; gap: var(--gap); }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.split { display: grid; grid-template-columns: minmax(0, 2fr) minmax(280px, 1fr); gap: 1.25rem; align-items: start; }
dl.facts { display: grid; grid-template-columns: minmax(130px, max-content) 1fr; gap: .35rem 1rem; margin: 0; }
dl.facts dt { color: var(--muted); font-size: .88rem; }
dl.facts dd { margin: 0; }

/* Indicateurs : une ligne de chiffres, pas des cartes */
.figures { display: flex; flex-wrap: wrap; border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--surface); margin-bottom: 1.25rem; }
.figure { flex: 1 1 150px; padding: .8rem 1rem; border-right: 1px solid var(--line); }
.figure:last-child { border-right: 0; }
.figure strong { display: block; font-size: 1.45rem; color: var(--ink); font-variant-numeric: tabular-nums; }
.figure span { color: var(--muted); font-size: .84rem; }
.figure--alert strong { color: var(--stop); }

/* ---------- Tableaux ---------- */
.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  margin-bottom: var(--gap); }
table { width: 100%; border-collapse: collapse; font-size: .92rem; }
th { text-align: left; font-weight: 600; color: var(--muted); font-size: .82rem; padding: .55rem .7rem;
  border-bottom: 1px solid var(--line); background: #FAFBFD; white-space: nowrap; }
td { padding: .55rem .7rem; border-bottom: 1px solid #EDF1F6; vertical-align: top; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: #FAFCFF; }
td a.ref-link { font-weight: 650; font-variant-numeric: tabular-nums; text-decoration: none; }
tfoot td { font-weight: 650; border-top: 1px solid var(--line); }
.empty { padding: 1.5rem; text-align: center; color: var(--muted); }

/* ---------- Statuts ---------- */
.badge { display: inline-block; padding: .1rem .5rem; border-radius: 999px; font-size: .78rem; font-weight: 600;
  white-space: nowrap; border: 1px solid transparent; }
.badge--success { background: var(--ok-bg); color: #1F5E29; border-color: #BFE0C6; }
.badge--warning { background: var(--wait-bg); color: #7A4D05; border-color: #F1D49B; }
.badge--danger { background: var(--stop-bg); color: #8E1B12; border-color: #F5C1BB; }
.badge--info { background: var(--info-bg); color: #0B4F94; border-color: #BCD6F2; }
.badge--neutral { background: #EEF1F5; color: #4A5565; border-color: #DCE2EA; }

/* ---------- Formulaires ---------- */
form p, .field { margin: 0 0 .85rem; }
label { display: block; font-weight: 600; font-size: .88rem; margin-bottom: .25rem; color: #2A3646; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=date],
input[type=datetime-local], input[type=search], input:not([type]), select, textarea {
  width: 100%; padding: .55rem .65rem; border: 1px solid #B8C4D3; border-radius: var(--radius); background: #fff;
  font: inherit; color: inherit; min-height: 42px; }
textarea { min-height: auto; }
input:focus, select:focus, textarea:focus { border-color: var(--signal); outline: 2px solid #CFE2F7; }
input[type=checkbox], input[type=radio] { width: 18px; height: 18px; accent-color: var(--signal); }
.check { display: flex; gap: .5rem; align-items: flex-start; font-weight: 500; }
ul.radio-list, .field ul { list-style: none; padding: 0; margin: 0; }
.field ul li label { display: flex; gap: .5rem; font-weight: 500; }
.helptext, .help { display: block; color: var(--muted); font-size: .8rem; margin-top: .2rem; }
.errorlist { list-style: none; margin: .25rem 0 0; padding: 0; color: var(--stop); font-size: .85rem; font-weight: 600; }
.form-errors { background: var(--stop-bg); border: 1px solid #F5C1BB; color: #8E1B12; padding: .7rem .9rem;
  border-radius: var(--radius); margin-bottom: 1rem; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 0 1rem; }
.form-grid .wide { grid-column: 1 / -1; }
.filters { display: flex; flex-wrap: wrap; gap: .5rem; align-items: flex-end; margin-bottom: 1rem; }
.filters .field { margin: 0; min-width: 150px; flex: 1 1 150px; max-width: 240px; }
.lines-table input, .lines-table select { min-width: 90px; }
.lines-table td { padding: .35rem; }

/* ---------- Boutons ---------- */
.btn { display: inline-flex; align-items: center; gap: .4rem; padding: .5rem .95rem; min-height: 42px;
  border-radius: var(--radius); border: 1px solid var(--signal); background: var(--signal); color: #fff;
  font: inherit; font-weight: 600; text-decoration: none; cursor: pointer; }
.btn:hover { background: #0855A1; color: #fff; }
.btn--quiet { background: #fff; color: var(--ink); border-color: #B8C4D3; }
.btn--quiet:hover { background: #F0F4F9; color: var(--ink); }
.btn--ok { background: var(--field); border-color: var(--field); }
.btn--ok:hover { background: #24642E; }
.btn--danger { background: #fff; color: var(--stop); border-color: #E7A49C; }
.btn--danger:hover { background: var(--stop-bg); color: var(--stop); }
.btn--small { min-height: 32px; padding: .25rem .6rem; font-size: .85rem; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.linkbtn { background: none; border: 0; color: var(--signal); text-decoration: underline; cursor: pointer; font: inherit; padding: 0; }

/* ---------- Messages ---------- */
.messages { list-style: none; padding: 0; margin: 0 0 1rem; }
.messages li { padding: .65rem .9rem; border-radius: var(--radius); margin-bottom: .4rem; border: 1px solid;
  font-size: .93rem; }
.messages .success { background: var(--ok-bg); border-color: #BFE0C6; color: #1F5E29; }
.messages .error { background: var(--stop-bg); border-color: #F5C1BB; color: #8E1B12; }
.messages .warning { background: var(--wait-bg); border-color: #F1D49B; color: #6B4500; }
.messages .info { background: var(--info-bg); border-color: #BCD6F2; color: #0B4F94; }
.note { border-left: 4px solid var(--signal); background: var(--info-bg); padding: .6rem .85rem; border-radius: 0 var(--radius) var(--radius) 0;
  margin-bottom: 1rem; font-size: .92rem; }
.note--warn { border-color: var(--wait); background: var(--wait-bg); }
.note--stop { border-color: var(--stop); background: var(--stop-bg); }

/* ---------- Approbations ---------- */
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { position: relative; padding: 0 0 .9rem 1.5rem; }
.timeline li::before { content: ""; position: absolute; left: 5px; top: .5rem; bottom: -.3rem; width: 2px; background: var(--line); }
.timeline li:last-child::before { display: none; }
.timeline li::after { content: ""; position: absolute; left: 0; top: .3rem; width: 12px; height: 12px; border-radius: 50%;
  background: #fff; border: 2px solid var(--line); }
.timeline .t-APPROVED::after { background: var(--field); border-color: var(--field); }
.timeline .t-PENDING::after { background: var(--signal); border-color: var(--signal); }
.timeline .t-REJECTED::after, .timeline .t-RETURNED::after { background: var(--stop); border-color: var(--stop); }
.timeline .t-title { font-weight: 600; }
.timeline .t-meta { color: var(--muted); font-size: .84rem; }
.decision { border: 2px solid var(--signal); border-radius: var(--radius); padding: 1rem; background: #fff; }

/* ---------- Pagination, graphiques ---------- */
.pager { display: flex; gap: .5rem; align-items: center; justify-content: flex-end; margin: .5rem 0 1rem; font-size: .9rem; }
.chart { width: 100%; height: auto; max-width: 620px; }
.chart .c-bar { fill: var(--signal); }
.chart .c-label { fill: var(--text); font-size: 12px; }
.chart .c-value { fill: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }

/* ---------- Connexion ---------- */
.auth { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1fr) minmax(320px, 460px); background: var(--surface); }
.auth__side { background: var(--ink); color: #DCE6F5; padding: 3rem; display: flex; flex-direction: column; justify-content: space-between; }
.auth__side h1 { color: #fff; font-size: clamp(2.6rem, 6vw, 4.5rem); letter-spacing: .08em; margin: 1.5rem 0 .25rem; }
.auth__side p { max-width: 38ch; color: #C3D2E8; }
.auth__mark { width: 120px; height: auto; background: #fff; border-radius: 10px; padding: 8px; }
.auth__form { padding: 3rem 2.5rem; display: flex; flex-direction: column; justify-content: center; }
.auth__form h2 { margin-top: 0; font-size: 1.3rem; }
.auth__logo-mobile { display: none; }
.qr-img { width: 200px; height: 200px; image-rendering: pixelated; border: 1px solid var(--line); border-radius: 4px; }
.secret { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 1rem; letter-spacing: .08em; }
.codes { columns: 2; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 1.05rem; }

/* ---------- Mobile (Android) ---------- */
@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  .mobile-nav { display: block; }
  .mobile-nav summary { list-style: none; cursor: pointer; display: flex; gap: .4rem; align-items: center;
    font-weight: 600; color: var(--ink); min-height: 42px; }
  .mobile-nav summary::-webkit-details-marker { display: none; }
  .mobile-nav[open] .mobile-nav__panel { display: block; }
  .mobile-nav__panel { position: absolute; left: 0; right: 0; top: 100%; background: var(--ink); padding: .5rem 1rem 1rem;
    z-index: 20; max-height: 80vh; overflow-y: auto; }
  .topbar { position: relative; padding: .5rem 1rem; }
  .content { padding: 1rem; }
  .split { grid-template-columns: 1fr; }
  .chain { grid-template-columns: repeat(7, minmax(44px, 1fr)); overflow-x: auto; }
  .chain__label { display: none; }
  .chain__step--current .chain__label, .chain__step--failed .chain__label { display: inline; }
  .auth { grid-template-columns: 1fr; }
  .auth__side { display: none; }
  .auth__form { padding: 2rem 1.25rem; }
  .auth__logo-mobile { display: block; width: 120px; margin-bottom: 1rem; }
  .figure { flex-basis: 50%; border-bottom: 1px solid var(--line); }
  table.stack thead { display: none; }
  table.stack tr { display: block; border-bottom: 1px solid var(--line); padding: .4rem 0; }
  table.stack td { display: flex; justify-content: space-between; gap: 1rem; border: 0; padding: .2rem .7rem; text-align: right; }
  table.stack td::before { content: attr(data-label); color: var(--muted); font-size: .82rem; text-align: left; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
@media print {
  .sidebar, .topbar, .actions, .no-print, .footer, .env-banner { display: none !important; }
  .shell { display: block; } .content { padding: 0; } body { background: #fff; }
}
.actions .btn[aria-current="page"] { background: var(--ink); color: #fff; border-color: var(--ink); }

/* Logo officiel de Child & Future (statuts art. 5 : utilisé sans modification ni déformation).
   Toujours sur fond blanc, proportions conservées (height:auto), aucune recoloration. */
:root { --cf-blue: #019FEC; --cf-blue-text: #0A6FA8; }
.cf-tile { margin: 0; background: #fff; border-radius: 8px; padding: 10px 14px; display: inline-block; line-height: 0; }
.cf-tile img { display: block; width: 100%; max-width: 240px; height: auto; }
.cf-tile--side { margin: 1.25rem .5rem 0; max-width: 170px; }
.cf-tile--side img { max-width: 150px; }
.motto { color: #C3D2E8; font-style: italic; font-size: .9rem; margin-top: .75rem; }
.auth__side { border-top: 4px solid var(--cf-blue); }
.sidebar { border-top: 3px solid var(--cf-blue); }
.auth__cf-mobile { display: none; width: 120px; height: auto; margin-top: .75rem; }
@media (max-width: 900px) { .auth__cf-mobile { display: block; } }
.inline-form { display: inline-flex; gap: .4rem; align-items: center; flex-wrap: wrap; }
