/* CoboxArch — feuille de style (clair / sombre automatique) */
:root {
  --bg: #f6f7f9; --bg-elev: #ffffff; --bg-soft: #eef1f5; --fg: #1c2330; --fg-muted: #5b6474; --border: #dbe0e8;
  --accent: #b5382b; --accent-soft: #fbe9e6; --link: #0b63a8; --code-bg: #f0f2f5;
  --ok: #1f7a4d; --warn: #9a6400; --err: #b3261e; --info: #0b63a8;
  --sev-critical: #b3261e; --sev-high: #d35400; --sev-medium: #9a6400; --sev-low: #4b6b8a;
  --sidebar-w: 260px; --toc-w: 220px; --radius: 10px; --shadow: 0 1px 2px rgba(20,30,50,.06), 0 4px 14px rgba(20,30,50,.05);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #12161c; --bg-elev: #1a2029; --bg-soft: #222a35; --fg: #e6e9ee; --fg-muted: #9aa5b5; --border: #2e3745;
    --accent: #e8695a; --accent-soft: #3a2320; --link: #7fb7ee; --code-bg: #0f1319;
    --ok: #5cc48f; --warn: #e0b04a; --err: #f28b82; --info: #7fb7ee;
    --sev-critical: #f28b82; --sev-high: #f5a35c; --sev-medium: #e0b04a; --sev-low: #9db8d2;
    --shadow: 0 1px 2px rgba(0,0,0,.4), 0 4px 14px rgba(0,0,0,.3);
  }
}
* { box-sizing: border-box; }
html { color-scheme: light dark; }
body { margin: 0; font: 15px/1.6 var(--font); color: var(--fg); background: var(--bg); }
a { color: var(--link); text-decoration: none; } a:hover { text-decoration: underline; }
code, pre, .mono { font-family: var(--mono); font-size: .92em; }
code { background: var(--code-bg); padding: .1em .35em; border-radius: 4px; }
pre { background: var(--code-bg); padding: 12px 14px; border-radius: var(--radius); overflow-x: auto; border: 1px solid var(--border); }
pre code { background: none; padding: 0; }
.wrap { white-space: pre-wrap; word-break: break-word; }
.muted { color: var(--fg-muted); } .small { font-size: .88em; } .center { text-align: center; }
.skip { position: absolute; left: -999px; } .skip:focus { left: 8px; top: 8px; background: var(--bg-elev); padding: 6px; z-index: 100; }

/* ---- structure ---- */
.topbar { position: sticky; top: 0; z-index: 30; display: flex; align-items: center; gap: 14px; height: 52px; padding: 0 16px; background: var(--bg-elev); border-bottom: 1px solid var(--border); }
.brand { font-weight: 700; color: var(--fg); white-space: nowrap; }
.topbar .search { flex: 1; max-width: 520px; } .topbar .search input { width: 100%; }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.whoami { white-space: nowrap; } .inline { display: inline; }
.icon-btn { background: none; border: 1px solid transparent; font-size: 18px; cursor: pointer; padding: 4px 8px; border-radius: 6px; color: var(--fg); }
.icon-btn:hover { border-color: var(--border); background: var(--bg-soft); }
.menu-btn { display: none; }
.sidebar { position: fixed; top: 52px; left: 0; bottom: 0; width: var(--sidebar-w); background: var(--bg-elev); border-right: 1px solid var(--border); overflow-y: auto; z-index: 20; }
.sidebar-inner { padding: 12px 10px 24px; display: flex; flex-direction: column; min-height: 100%; }
.nav-group-title { font-size: .74em; text-transform: uppercase; letter-spacing: .08em; color: var(--fg-muted); margin: 14px 10px 4px; }
.nav-item { display: block; padding: 7px 10px; border-radius: 8px; color: var(--fg); }
.nav-item:hover { background: var(--bg-soft); text-decoration: none; } .nav-item.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.nav-item.next { font-weight: 600; }
.sidebar-foot { margin-top: auto; padding: 14px 10px 0; border-top: 1px solid var(--border); }
.lvl { display: inline-block; font-size: .72em; font-weight: 700; padding: 1px 6px; border-radius: 5px; background: var(--bg-soft); color: var(--fg-muted); vertical-align: middle; letter-spacing: .03em; }
.lvl.big { font-size: .55em; padding: 2px 8px; }
.content { padding: 24px 32px 64px; max-width: 1180px; }
body.with-sidebar .content { margin-left: var(--sidebar-w); }
body.no-sidebar .content { margin: 0 auto; }
@media (max-width: 900px) {
  .menu-btn { display: inline-block; } .sidebar { transform: translateX(-100%); transition: transform .2s; } .sidebar.open { transform: none; box-shadow: var(--shadow); }
  body.with-sidebar .content { margin-left: 0; padding: 16px; } .whoami { display: none; } .topbar .search { max-width: none; }
}

/* ---- typographie de contenu ---- */
.page-head { margin-bottom: 18px; } .page-head h1 { margin: 4px 0 6px; font-size: 1.8em; line-height: 1.25; }
.crumbs { font-size: .88em; color: var(--fg-muted); } .crumbs a { color: var(--fg-muted); }
.lead { font-size: 1.1em; color: var(--fg-muted); margin-top: 0; }
.prose { max-width: 860px; } .prose h1 { font-size: 1.9em; line-height: 1.25; margin: 6px 0 10px; }
.prose h2 { font-size: 1.45em; margin: 34px 0 10px; padding-bottom: 6px; border-bottom: 1px solid var(--border); }
.prose h3 { font-size: 1.15em; margin: 26px 0 8px; } .prose h4 { margin: 18px 0 6px; }
.prose img { max-width: 100%; border-radius: var(--radius); border: 1px solid var(--border); background: #fff; }
.prose blockquote { margin: 14px 0; padding: 8px 16px; border-left: 4px solid var(--accent); background: var(--bg-elev); border-radius: 0 var(--radius) var(--radius) 0; }
.prose li { margin: 3px 0; } .prose hr { border: 0; border-top: 1px solid var(--border); margin: 28px 0; }
.anchor { opacity: 0; margin-left: -1.1em; width: 1.1em; display: inline-block; color: var(--fg-muted); font-weight: 400; }
h2:hover .anchor, h3:hover .anchor, h4:hover .anchor { opacity: 1; }
.page-layout { display: grid; grid-template-columns: minmax(0, 1fr); gap: 32px; }
.page-layout.has-toc { grid-template-columns: minmax(0, 1fr) var(--toc-w); }
.toc { position: sticky; top: 68px; align-self: start; max-height: calc(100vh - 90px); overflow-y: auto; font-size: .86em; border-left: 1px solid var(--border); padding-left: 14px; }
.toc-title { font-weight: 700; margin-bottom: 6px; color: var(--fg-muted); text-transform: uppercase; font-size: .8em; letter-spacing: .06em; }
.toc ul { list-style: none; margin: 0; padding: 0; } .toc li.d3 { padding-left: 12px; } .toc a { color: var(--fg-muted); display: block; padding: 2px 0; }
.toc a.active { color: var(--accent); font-weight: 600; }
@media (max-width: 1100px) { .page-layout.has-toc { grid-template-columns: minmax(0, 1fr); } .toc { display: none; } }
.pager { display: flex; justify-content: space-between; gap: 12px; margin-top: 40px; padding-top: 16px; border-top: 1px solid var(--border); }

/* tableaux */
.table-wrap { overflow-x: auto; margin: 14px 0; border: 1px solid var(--border); border-radius: var(--radius); background: var(--bg-elev); }
table { border-collapse: collapse; width: 100%; font-size: .93em; }
th, td { padding: 8px 10px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: top; }
th { background: var(--bg-soft); font-weight: 600; } tr:last-child td { border-bottom: 0; }
td.actions { white-space: nowrap; }

/* mermaid */
pre.mermaid { background: var(--bg-elev); text-align: center; cursor: zoom-in; padding: 14px; }
pre.mermaid svg { max-width: 100%; height: auto; }
.diagram-overlay { position: fixed; inset: 0; z-index: 200; background: rgba(10,14,20,.88); display: flex; align-items: center; justify-content: center; cursor: zoom-out; padding: 2vh 2vw; }
.diagram-overlay svg { background: var(--bg-elev); border-radius: var(--radius); padding: 16px; width: auto; height: auto; }

/* liens verrouillés, tips code, encadrés */
.locked { color: var(--fg-muted); border-bottom: 1px dotted var(--fg-muted); cursor: not-allowed; } .lock { font-size: .85em; }
/* Lien vers une page inaccessible au rôle : texte simple ; une puce qui ne contient plus aucun lien est masquée. */
.hidden-link { color: inherit; }
li:has(> .hidden-link):not(:has(a)) { display: none; }
.missing-link { color: var(--err); border-bottom: 1px dashed var(--err); }
.code-ref { display: flex; gap: 10px; align-items: flex-start; margin: 12px 0; padding: 10px 12px; border: 1px solid var(--border); border-left: 4px solid var(--info); border-radius: var(--radius); background: var(--bg-elev); font-size: .92em; }
.code-ref .ref-icon { font-size: 1.1em; } .code-ref .ref-fn { color: var(--accent); } .code-ref .ref-note { color: var(--fg-muted); margin-top: 2px; }
.code-ref code { cursor: copy; } .copied { outline: 2px solid var(--ok); }
.ref-tip { position: relative; display: inline-flex; align-items: center; gap: 3px; cursor: help; border-bottom: 1px dotted var(--info); }
.ref-tip .ref-icon { font-size: .85em; }
.ref-tip::after { content: attr(data-tip); position: absolute; left: 0; bottom: calc(100% + 6px); z-index: 50; background: var(--fg); color: var(--bg); padding: 6px 10px; border-radius: 6px; font: .85em/1.4 var(--mono); white-space: pre-wrap; min-width: 240px; max-width: 520px; opacity: 0; pointer-events: none; transform: translateY(4px); transition: .12s; box-shadow: var(--shadow); }
.ref-tip:hover::after, .ref-tip:focus::after { opacity: 1; transform: none; }
.admonition { display: flex; gap: 10px; margin: 14px 0; padding: 10px 14px; border-radius: var(--radius); border: 1px solid var(--border); background: var(--bg-elev); }
.admonition::before { font-size: 1.1em; }
.admonition.tip { border-left: 4px solid var(--ok); } .admonition.tip::before { content: "💡"; }
.admonition.info, .admonition.note { border-left: 4px solid var(--info); } .admonition.info::before, .admonition.note::before { content: "ℹ️"; }
.admonition.warn { border-left: 4px solid var(--warn); } .admonition.warn::before { content: "⚠️"; }

/* cartes */
.card { background: var(--bg-elev); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); }
.card h3, .card h4 { margin: 6px 0; } .card p { margin: 4px 0; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.card-actions { margin-top: 10px; }
.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 14px; margin: 12px 0 22px; } .card-grid.single { grid-template-columns: minmax(240px, 420px); }
.component-group h3 { margin-top: 22px; }
.levels { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 16px; margin: 18px 0; }
.level-card.locked { opacity: .7; }
.cards-row { display: flex; flex-wrap: wrap; gap: 12px; margin: 16px 0; }
.card.mini { min-width: 130px; text-align: center; padding: 10px 14px; color: inherit; } a.card.mini:hover { text-decoration: none; border-color: var(--accent); }
.kpi { font-size: 1.7em; font-weight: 700; line-height: 1.2; }
.page-list { padding-left: 1.2em; } .page-list.compact { margin: 6px 0; padding-left: 1.1em; } .page-list.tree > li { margin: 6px 0; } .page-list ul { padding-left: 1.2em; }
dl.glossary > div { padding: 8px 0; border-bottom: 1px solid var(--border); } dl.glossary dt { font-weight: 700; } dl.glossary dd { margin: 2px 0 0; color: var(--fg-muted); }
dl.glossary dt + dd { margin-left: 0; }

/* badges */
.badge { display: inline-block; font-size: .74em; font-weight: 600; padding: 1px 7px; border-radius: 999px; background: var(--bg-soft); color: var(--fg-muted); vertical-align: middle; white-space: nowrap; }
.badge.layer { background: var(--accent-soft); color: var(--accent); }
.chip { display: inline-block; font-size: .8em; padding: 1px 8px; border: 1px solid var(--border); border-radius: 999px; background: var(--bg-elev); }
.sev-critical { color: var(--sev-critical); } .sev-high { color: var(--sev-high); } .sev-medium { color: var(--sev-medium); } .sev-low { color: var(--sev-low); }
.badge.sev-critical { background: color-mix(in srgb, var(--sev-critical) 15%, transparent); } .badge.sev-high { background: color-mix(in srgb, var(--sev-high) 15%, transparent); }
.badge.sev-medium { background: color-mix(in srgb, var(--sev-medium) 15%, transparent); } .badge.sev-low { background: color-mix(in srgb, var(--sev-low) 15%, transparent); }
.st-done { color: var(--ok); } .st-in_progress { color: var(--info); } .st-wontfix { color: var(--fg-muted); }
.badge.st-done { background: color-mix(in srgb, var(--ok) 15%, transparent); } .badge.st-in_progress { background: color-mix(in srgb, var(--info) 15%, transparent); }

/* tâches */
.tasks { list-style: none; padding: 0; margin: 12px 0; display: flex; flex-direction: column; gap: 10px; }
.task { border-left: 5px solid var(--border); } .sev-border-critical { border-left-color: var(--sev-critical); } .sev-border-high { border-left-color: var(--sev-high); } .sev-border-medium { border-left-color: var(--sev-medium); } .sev-border-low { border-left-color: var(--sev-low); }
.task-head { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; } .task-head h3 { margin: 0; font-size: 1.05em; flex: 1 1 320px; }
.prio { font-weight: 700; color: var(--fg-muted); min-width: 34px; } .task-field { margin: 6px 0 0; font-size: .92em; }
.task .prose.small { font-size: .92em; margin-top: 6px; }
.handle { cursor: grab; color: var(--fg-muted); } .dragging { opacity: .5; } .task-head .right { margin-left: auto; }
.filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 12px 0; }

/* formulaires */
input, select, textarea, button { font: inherit; color: inherit; }
input[type=text], input[type=search], input[type=password], input[type=number], input:not([type]), select, textarea { width: 100%; padding: 7px 10px; border: 1px solid var(--border); border-radius: 8px; background: var(--bg-elev); }
textarea { resize: vertical; } textarea.mono { font-size: .88em; line-height: 1.45; }
.form label { display: block; margin: 10px 0; font-weight: 500; } .form label.check { font-weight: 400; } .form label.check input { width: auto; margin-right: 6px; }
.form.narrow { max-width: 520px; } .form fieldset { border: 1px solid var(--border); border-radius: var(--radius); padding: 8px 14px; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 14px; } .grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0 14px; } .grid-4 { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 0 14px; }
@media (max-width: 700px) { .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; } }
.inline-form { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; } .inline-form input, .inline-form select { width: auto; }
.filters select { width: auto; }
.btn { display: inline-block; padding: 7px 14px; border: 1px solid var(--border); border-radius: 8px; background: var(--bg-elev); cursor: pointer; color: var(--fg); line-height: 1.3; }
.btn:hover { border-color: var(--accent); text-decoration: none; } .btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; } .btn.danger { color: var(--err); }
.btn.ghost { background: transparent; } .btn-sm { padding: 3px 9px; font-size: .86em; } .btn:disabled { opacity: .5; cursor: not-allowed; }
.actions-row { margin: 12px 0; }
.alert { padding: 10px 14px; border-radius: var(--radius); margin: 12px 0; border: 1px solid var(--border); background: var(--bg-elev); }
.alert.error { border-color: var(--err); } .alert.ok { border-color: var(--ok); } .alert.warn { border-color: var(--warn); }
.pw { font-size: 1.1em; user-select: all; }
.help { margin: 8px 0; } details > summary { cursor: pointer; } details { margin: 6px 0; padding: 6px 10px; border: 1px solid var(--border); border-radius: 8px; background: var(--bg-elev); }
details[open] > summary { margin-bottom: 8px; }

/* login */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; }
.login-card { width: 100%; max-width: 400px; background: var(--bg-elev); border: 1px solid var(--border); border-radius: 14px; padding: 28px; box-shadow: var(--shadow); }
.login-card h1 { margin: 0 0 6px; } .login-card label { display: block; margin: 12px 0; font-weight: 500; } .login-card button { width: 100%; margin-top: 10px; }
