:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --text: #1b1f24;
  --muted: #5b6573;
  --line: #d7dce3;
  --accent: #14558f;
  --accent-text: #ffffff;
  --ok: #17663a;
  --ok-bg: #e3f4e9;
  --warn: #8a5a00;
  --warn-bg: #fff2d6;
  --bad: #a52626;
  --bad-bg: #fbe4e4;
  --focus: #1a73e8;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #12161b;
    --surface: #1b2128;
    --text: #e8ebef;
    --muted: #9aa5b3;
    --line: #333c47;
    --accent: #5aa8ee;
    --accent-text: #0b1520;
    --ok: #6ad199;
    --ok-bg: #163425;
    --warn: #f0c36a;
    --warn-bg: #3a2d10;
    --bad: #f08a8a;
    --bad-bg: #3a1a1a;
    --focus: #8ab4f8;
  }
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font: 16px/1.5 system-ui, -apple-system, "Segoe UI", sans-serif; }
.skip { position: absolute; left: -999px; }
.skip:focus { left: 8px; top: 8px; background: var(--surface); padding: 8px 12px; z-index: 10; }
.sr-status { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }

header.top { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; justify-content: space-between; padding: 12px 16px; background: var(--surface); border-bottom: 1px solid var(--line); }
header.top h1 { font-size: 1.1rem; margin: 0; }
header.top .who { color: var(--muted); font-size: 0.9rem; display: flex; gap: 12px; align-items: center; }
nav.tabs { display: flex; gap: 4px; padding: 8px 16px 0; border-bottom: 1px solid var(--line); background: var(--surface); overflow-x: auto; }
nav.tabs button { border: 1px solid transparent; border-bottom: none; background: none; padding: 10px 16px; border-radius: 8px 8px 0 0; color: var(--muted); font: inherit; cursor: pointer; min-height: 44px; }
nav.tabs button[aria-selected="true"] { color: var(--text); background: var(--bg); border-color: var(--line); font-weight: 600; }
main { padding: 16px; max-width: 1200px; margin: 0 auto; }

button, .button { font: inherit; border: 1px solid var(--line); background: var(--surface); color: var(--text); padding: 8px 14px; border-radius: 8px; cursor: pointer; min-height: 40px; text-decoration: none; display: inline-flex; align-items: center; }
button.primary, .button.primary { background: var(--accent); color: var(--accent-text); border-color: var(--accent); font-weight: 600; }
button.danger { color: var(--bad); border-color: var(--bad); }
button:disabled { opacity: 0.5; cursor: not-allowed; }
a, a:visited { color: var(--accent); }
a:hover { text-decoration-thickness: 2px; }
input, select, textarea { font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; width: 100%; }
textarea { min-height: 120px; resize: vertical; }
label { display: block; font-weight: 600; margin-bottom: 4px; font-size: 0.9rem; }
.field { margin-bottom: 12px; }
.row { display: flex; flex-wrap: wrap; gap: 12px; }
.row > * { flex: 1 1 200px; }
.toolbar { display: flex; flex-wrap: wrap; gap: 12px; align-items: end; margin-bottom: 16px; }
.toolbar .field { margin: 0; min-width: 180px; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 16px; margin-bottom: 12px; }
.layout { display: grid; grid-template-columns: minmax(280px, 380px) 1fr; gap: 16px; align-items: start; }
.layout.even { grid-template-columns: 1fr 1fr; }
@media (max-width: 800px) { .layout, .layout.even { grid-template-columns: 1fr; } }
.list { list-style: none; margin: 0; padding: 0; }
.list li { margin: 0 0 8px; }
.list button.item { width: 100%; text-align: left; display: block; padding: 12px; border-radius: 10px; }
.list button.item[aria-current="true"] { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent); }
.item .t { font-weight: 600; }
.item .m { color: var(--muted); font-size: 0.85rem; margin-top: 4px; display: flex; flex-wrap: wrap; gap: 6px; }

.badge { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 0.78rem; border: 1px solid var(--line); }
.badge.ok { color: var(--ok); background: var(--ok-bg); border-color: transparent; }
.badge.warn { color: var(--warn); background: var(--warn-bg); border-color: transparent; }
.badge.bad { color: var(--bad); background: var(--bad-bg); border-color: transparent; }
.muted { color: var(--muted); }
.content { white-space: pre-wrap; background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 12px; }
.blockers { background: var(--warn-bg); color: var(--warn); border-radius: 8px; padding: 10px 12px; margin: 12px 0; }
.blockers ul { margin: 4px 0 0 18px; padding: 0; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; align-items: center; }
.bubble { border-radius: 10px; padding: 8px 12px; margin: 6px 0; white-space: pre-wrap; max-width: 90%; }
.bubble .msg-body { margin-top: 2px; }
.bubble .msg-date { color: var(--muted); font-size: 0.8rem; margin-left: 6px; }
.bubble .msg-title { font-weight: 600; margin-top: 2px; }
.bubble .msg-header { color: var(--muted); font-size: 0.8rem; margin-top: 2px; overflow-wrap: anywhere; }
.bubble details { margin: 6px 0 0; }
.bubble summary { font-weight: 400; color: var(--muted); font-size: 0.85rem; min-height: 28px; }
.msg-fold { color: var(--muted); font-size: 0.9rem; border-left: 3px solid var(--line); padding-left: 8px; overflow-wrap: anywhere; }
.bubble.client { background: var(--bg); border: 1px solid var(--line); }
.bubble.service { background: var(--ok-bg); margin-left: auto; }
details { margin: 12px 0; }
summary { cursor: pointer; font-weight: 600; min-height: 32px; }
.msg { padding: 10px 12px; border-radius: 8px; margin-bottom: 12px; }
.msg.error { background: var(--bad-bg); color: var(--bad); }
.msg.notes { background: var(--warn-bg); color: var(--warn); }
.msg.notes ul { margin: 6px 0 0 18px; padding: 0; }
textarea.draft { min-height: 240px; line-height: 1.5; }
.msg.info { background: var(--ok-bg); color: var(--ok); }
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 16px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 12px; }
.stat .n { font-size: 1.6rem; font-weight: 700; }
table { width: 100%; border-collapse: collapse; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); font-size: 0.9rem; }
.login { max-width: 420px; margin: 10vh auto; }
.noscript { padding: 16px; }

fieldset.scope { border: 1px solid var(--line); border-radius: 12px; padding: 12px 16px; margin: 12px 0; background: var(--surface); }
fieldset.scope legend { font-weight: 600; padding: 0 6px; }
.scope-list { columns: 2 240px; margin-bottom: 8px; }
label.check { display: flex; gap: 8px; align-items: center; font-weight: 400; margin: 4px 0; min-height: 32px; break-inside: avoid; }
label.check input { width: auto; }

.diff ins { background: var(--ok-bg); color: var(--ok); text-decoration: underline; }
.diff del { background: var(--bad-bg); color: var(--bad); }
table.history td { vertical-align: top; }
pre.content { overflow-x: auto; font-size: 0.8rem; }

/* Corpus : date lisible, lien vers le PDF à part. */
.corpus td .date { font-weight: 600; }
.corpus td a { font-size: 0.85rem; }
.linklike { background: none; border: 0; padding: 0; color: var(--accent); font: inherit; font-weight: 600; text-align: left; cursor: pointer; min-height: 0; }
.linklike:hover { text-decoration: underline; }
.subtabs { margin: 8px 0 12px; }
.chunk { border-bottom: 1px solid var(--line); padding: 10px 0; }
.chunk .text { white-space: pre-wrap; margin-top: 4px; }
.faq-item { border-bottom: 1px solid var(--line); margin: 0; padding: 6px 0; }
.faq-item .content { margin-top: 6px; }
.history .comment { font-size: 0.85rem; max-width: 260px; white-space: normal; }

/* Connaissances : vues, groupes par étape, prochaine étape */
.views { display: inline-flex; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; background: var(--surface); }
.views button { border: 0; border-radius: 0; border-right: 1px solid var(--line); gap: 8px; }
.views button:last-child { border-right: 0; }
.views button[aria-selected="true"] { background: var(--accent); color: var(--accent-text); font-weight: 600; }
.count { display: inline-block; min-width: 1.6em; padding: 0 6px; border-radius: 999px; background: var(--bg); color: var(--text); font-size: 0.8rem; font-weight: 600; text-align: center; margin-left: 6px; }
.views button[aria-selected="true"] .count { background: var(--accent-text); color: var(--accent); }
.toolbar .field.grow { flex: 1 1 240px; }
.groups .group { margin-bottom: 18px; }
.groups .group h3 { font-size: 0.95rem; margin: 0 0 4px; display: flex; align-items: center; }
.groups .hint { font-size: 0.85rem; margin: 0 0 8px; }
.next { border-radius: 10px; padding: 12px 14px; margin: 12px 0 16px; background: var(--bg); border: 1px solid var(--line); border-left-width: 5px; }
.next h3 { margin: 0 0 6px; font-size: 1rem; }
.next p { margin: 6px 0; }
.next.step-confirm, .next.step-product, .next.step-dismissed { border-left-color: var(--warn); }
.next.step-ready, .next.step-in_service { border-left-color: var(--ok); }
.next.step-gap, .next.step-duplicate { border-left-color: var(--bad); }
.next .why { background: var(--surface); border-radius: 8px; padding: 8px 10px; }
.next .gap { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; margin: 8px 0; }
.next .confirm { margin-top: 12px; padding-top: 8px; border-top: 1px dashed var(--line); }
.card > .m { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.card .kid { margin: 0; font-size: 0.85rem; }
.card h2 { margin: 4px 0 8px; }
.rich { background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 4px 14px; line-height: 1.55; }
.rich h4 { margin: 12px 0 4px; font-size: 0.95rem; }
.rich p { margin: 8px 0; }
.rich ul { margin: 6px 0 6px 20px; padding: 0; }
.events { padding-left: 18px; }
.events li { margin: 4px 0; }
.layout > section.detail { position: sticky; top: 12px; max-height: calc(100vh - 24px); overflow-y: auto; }
.groups .list button.item { padding: 8px 10px; }
.groups .item .t { font-size: 0.92rem; line-height: 1.35; }
.groups .item .m { margin-top: 2px; }
.groups .list li { margin-bottom: 6px; }
.small { font-size: 0.82rem; }
.overview { list-style: none; padding: 0; margin: 0; }
.overview li { padding: 8px 0; border-bottom: 1px solid var(--line); }
.overview li:last-child { border-bottom: 0; }
@media (max-width: 800px) { .layout > section.detail { position: static; max-height: none; } }
