:root {
  --paper: #f4f5f7;
  --surface: #ffffff;
  --sunk: #eceef2;
  --ink: #16191d;
  --muted: #5b6470;
  --rule: #d9dde3;
  --accent: #1f55b8;
  --accent-soft: #e4ecfa;
  --ok: #276738;
  --ok-soft: #e2f1e5;
  --warn: #8f5a07;
  --warn-soft: #fbf0dc;
  --bad: #a3261b;
  --bad-soft: #fbe5e2;
  --shadow: 0 1px 2px rgba(20, 30, 45, .06), 0 4px 16px rgba(20, 30, 45, .05);
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #0f1216; --surface: #161a20; --sunk: #1d222a; --ink: #e6e9ee; --muted: #9aa3ae; --rule: #2a3039;
    --accent: #8cb0f5; --accent-soft: #1c2940; --ok: #82c592; --ok-soft: #15261a; --warn: #e6ad55; --warn-soft: #2d2413;
    --bad: #f08a80; --bad-soft: #321817; --shadow: 0 1px 2px rgba(0,0,0,.4), 0 6px 20px rgba(0,0,0,.3);
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--paper); color: var(--ink); font: 14px/1.5 var(--sans); -webkit-font-smoothing: antialiased; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.mono { font-family: var(--mono); font-size: 12.5px; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.nowrap { white-space: nowrap; }

.app { display: grid; grid-template-columns: 232px minmax(0, 1fr); min-height: 100vh; }
.side { background: var(--surface); border-right: 1px solid var(--rule); padding: 16px 12px; position: sticky; top: 0; height: 100vh; overflow: auto; }
.brand { display: flex; flex-direction: column; gap: 2px; padding: 4px 8px 16px; }
.brand b { font-size: 17px; letter-spacing: .01em; }
.brand span { color: var(--muted); font-size: 12px; }
.nav { display: flex; flex-direction: column; gap: 1px; }
.nav .group { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); padding: 14px 8px 4px; }
.nav a { display: flex; justify-content: space-between; align-items: center; padding: 6px 8px; border-radius: 6px; color: var(--ink); }
.nav a:hover { background: var(--sunk); text-decoration: none; }
.nav a.on { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.nav .code { font-family: var(--mono); font-size: 11px; color: var(--muted); }
.who { margin-top: 18px; padding: 10px 8px; border-top: 1px solid var(--rule); font-size: 12.5px; color: var(--muted); }
.who button { margin-top: 6px; }

.main { padding: 24px 28px 64px; max-width: 1320px; width: 100%; }
.head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
.head h1 { margin: 0; font-size: 24px; line-height: 1.2; }
.head p { margin: 4px 0 0; color: var(--muted); max-width: 80ch; }
h2 { font-size: 16px; margin: 26px 0 10px; }
h3 { font-size: 14px; margin: 16px 0 8px; }

.card { background: var(--surface); border: 1px solid var(--rule); border-radius: 10px; padding: 16px; box-shadow: var(--shadow); }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.grid3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 1px; background: var(--rule); border: 1px solid var(--rule); border-radius: 10px; overflow: hidden; }
.stats div { background: var(--surface); padding: 12px 14px; }
.stats b { display: block; font-size: 24px; font-variant-numeric: tabular-nums; }
.stats span { color: var(--muted); font-size: 12.5px; }
@media (max-width: 1000px) { .grid2, .grid3 { grid-template-columns: 1fr; } .app { grid-template-columns: 1fr; } .side { position: static; height: auto; } }

.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--rule); border-radius: 10px; }
table { border-collapse: collapse; width: 100%; font-size: 13px; }
th, td { text-align: left; vertical-align: top; padding: 8px 10px; border-bottom: 1px solid var(--rule); }
th { position: sticky; top: 0; background: var(--sunk); font-size: 11.5px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 600; }
tr:last-child td { border-bottom: 0; }
tr.click { cursor: pointer; }
tr.click:hover td { background: var(--sunk); }
td.num { text-align: right; font-variant-numeric: tabular-nums; }

.pill { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 12px; font-weight: 500; white-space: nowrap; background: var(--sunk); color: var(--muted); }
.pill.ok { background: var(--ok-soft); color: var(--ok); }
.pill.warn { background: var(--warn-soft); color: var(--warn); }
.pill.bad { background: var(--bad-soft); color: var(--bad); }
.pill.acc { background: var(--accent-soft); color: var(--accent); }

.check { display: grid; grid-template-columns: 22px minmax(0, 1fr); gap: 8px; padding: 9px 0; border-bottom: 1px solid var(--rule); }
.check:last-child { border-bottom: 0; }
.check .mark { width: 20px; height: 20px; border-radius: 50%; display: grid; place-items: center; font-size: 12px; font-weight: 700; }
.check .mark.ok { background: var(--ok-soft); color: var(--ok); }
.check .mark.no { background: var(--bad-soft); color: var(--bad); }
.check .todo { color: var(--warn); font-size: 12.5px; }
.check .src { color: var(--muted); font-size: 12px; }

.btn { border: 1px solid var(--rule); background: var(--surface); padding: 6px 12px; border-radius: 7px; cursor: pointer; }
.btn:hover { border-color: var(--accent); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { color: var(--bad); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.field { display: flex; flex-direction: column; gap: 4px; margin-bottom: 10px; }
.field label { font-size: 12px; color: var(--muted); }
.field input, .field select, .field textarea, input.search { border: 1px solid var(--rule); background: var(--surface); padding: 7px 10px; border-radius: 7px; }
.field textarea { min-height: 90px; font-family: var(--mono); font-size: 12.5px; }
input.search { width: min(420px, 100%); }
.error { background: var(--bad-soft); color: var(--bad); padding: 8px 12px; border-radius: 8px; margin: 8px 0; white-space: pre-wrap; }
.notice { background: var(--warn-soft); color: var(--warn); padding: 8px 12px; border-radius: 8px; margin: 8px 0; }
.info { background: var(--accent-soft); color: var(--accent); padding: 8px 12px; border-radius: 8px; margin: 8px 0; }
pre.json { background: var(--sunk); padding: 10px 12px; border-radius: 8px; overflow: auto; max-height: 360px; font-family: var(--mono); font-size: 12px; margin: 0; }
.kv { display: grid; grid-template-columns: 170px minmax(0, 1fr); gap: 6px 14px; }
.kv dt { color: var(--muted); font-size: 12.5px; }
.kv dd { margin: 0; }
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--rule); margin: 16px 0 12px; flex-wrap: wrap; }
.tabs button { border: 0; background: transparent; padding: 8px 12px; cursor: pointer; color: var(--muted); border-bottom: 2px solid transparent; }
.tabs button.on { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }

.tree ul { list-style: none; margin: 0; padding-left: 16px; border-left: 1px solid var(--rule); }
.tree > ul { padding-left: 0; border-left: 0; }
.tree li { margin: 2px 0; }
.tree .node { display: inline-flex; gap: 8px; align-items: baseline; cursor: pointer; padding: 2px 6px; border-radius: 5px; }
.tree .node:hover { background: var(--sunk); }
.tree .node.on { background: var(--accent-soft); }
.tree .node .mono { color: var(--muted); }
.tree .toggle { width: 16px; display: inline-block; color: var(--muted); cursor: pointer; }

.matrix td, .matrix th { text-align: center; padding: 6px 4px; }
.matrix th.rowh { text-align: left; }
.cell-yes { background: var(--ok-soft); color: var(--ok); font-weight: 600; }
.cell-derived { background: var(--warn-soft); color: var(--warn); font-weight: 600; }
.cell-no { color: var(--rule); }

.login { min-height: 100vh; display: grid; place-items: center; }
.login .card { width: min(380px, 92vw); }
.login h1 { font-size: 20px; margin: 0 0 4px; }
.headline { display: grid; gap: 12px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.headline .card { border-left: 4px solid var(--rule); }
.headline .card.ok { border-left-color: var(--ok); }
.headline .card.no { border-left-color: var(--bad); }
.progress { height: 8px; background: var(--sunk); border-radius: 4px; overflow: hidden; }
.progress i { display: block; height: 100%; background: var(--ok); }
details summary { cursor: pointer; }

/* Материалы ЦРМ (ADR-0005) */
a.ref { font-family: var(--mono); font-size: .92em; background: var(--accent-soft); border-radius: 4px; padding: 0 4px; white-space: nowrap; }
a.ref:hover { text-decoration: none; filter: brightness(.96); }
ul.refs { list-style: none; margin: 4px 0 0; padding: 0; display: grid; gap: 3px; }
.layers .group { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin: 14px 0 4px; }
.layers details { border-bottom: 1px solid var(--rule); padding: 6px 0; }
.layers details:last-child { border-bottom: 0; }
.layers ul { list-style: none; margin: 6px 0 2px; padding: 0 0 0 14px; display: grid; gap: 6px; }
.layers .pill { margin-left: 6px; }
.card.hit { margin-bottom: 8px; padding: 12px 14px; }
.snippet { font-size: 13px; margin-top: 4px; color: var(--ink); }
mark { background: var(--warn-soft); color: inherit; border-radius: 3px; padding: 0 2px; }
.doc-layout { display: grid; grid-template-columns: 250px minmax(0, 1fr); gap: 16px; align-items: start; }
.outline { position: sticky; top: 12px; max-height: calc(100vh - 24px); overflow: auto; display: flex; flex-direction: column; gap: 2px; padding: 12px; }
.outline a { font-size: 12.5px; color: var(--ink); padding: 3px 6px; border-radius: 5px; line-height: 1.35; }
.outline a:hover { background: var(--sunk); text-decoration: none; }
.outline a.on { background: var(--accent-soft); color: var(--accent); }
@media (max-width: 1000px) { .doc-layout { grid-template-columns: 1fr; } .outline { position: static; max-height: 260px; } }
.md { font-size: 14px; line-height: 1.6; overflow-wrap: anywhere; }
.md h2, .md h3, .md h4, .md h5, .md h6 { scroll-margin-top: 16px; line-height: 1.3; }
.md h2 { font-size: 20px; margin: 8px 0 12px; }
.md h3 { font-size: 16px; margin: 22px 0 8px; }
.md h4, .md h5, .md h6 { font-size: 14px; margin: 18px 0 6px; }
.md p { margin: 0 0 10px; }
.md code { font-family: var(--mono); font-size: 12.5px; background: var(--sunk); padding: 0 4px; border-radius: 4px; }
.md pre { background: var(--sunk); padding: 10px 12px; border-radius: 8px; overflow: auto; font-size: 12.5px; }
.md pre code { background: none; padding: 0; }
.md blockquote { margin: 0 0 12px; padding: 6px 12px; border-left: 3px solid var(--accent); background: var(--accent-soft); border-radius: 0 6px 6px 0; white-space: pre-line; }
.md hr { border: 0; border-top: 1px solid var(--rule); margin: 18px 0; }
.md-list { list-style: none; margin: 0 0 10px; padding: 0; }
.md-list li { display: grid; grid-template-columns: 22px minmax(0, 1fr); }
.md-list .bullet { color: var(--muted); font-variant-numeric: tabular-nums; }
.md-table { overflow-x: auto; margin: 0 0 14px; border: 1px solid var(--rule); border-radius: 8px; }
.md-table table { font-size: 12.5px; }
.md-table th, .md-table td { overflow-wrap: normal; word-break: normal; hyphens: auto; }
.md-table td { min-width: 120px; max-width: 520px; }
.md-table td:first-child { min-width: 0; }
.md-table th { position: static; text-transform: none; letter-spacing: 0; font-size: 12px; min-width: 90px; }
.md .hl, .md .hl td { background: var(--warn-soft) !important; }
.md .hl { outline: 2px solid var(--warn); outline-offset: -2px; }
.md > * { scroll-margin-top: 16px; }
.md tr { scroll-margin-top: 16px; }
select.search { border: 1px solid var(--rule); background: var(--surface); padding: 7px 10px; border-radius: 7px; }
.layers details.folder { border-bottom: 0; padding: 2px 0 2px 14px; }
.plain { font-family: var(--mono); font-size: 12.5px; line-height: 1.5; overflow-x: auto; }
.plain > div { display: grid; grid-template-columns: 48px minmax(0, 1fr); scroll-margin-top: 16px; }
.plain .ln { color: var(--muted); text-align: right; padding-right: 12px; user-select: none; }
.plain .lt { white-space: pre-wrap; overflow-wrap: anywhere; }
.plain .hl { background: var(--warn-soft); }
.material-img { max-width: 100%; height: auto; border-radius: 6px; }

/* Материалы LMS (ADR-0006): актуальность документов, схемы, шапка статьи, текст шага */
.statusbar { display: flex; height: 8px; border-radius: 4px; overflow: hidden; background: var(--sunk); }
.statusbar i { display: block; height: 100%; }
.statusbar i.ok, .dot.ok { background: var(--ok); }
.statusbar i.acc, .dot.acc { background: var(--accent); }
.statusbar i.warn, .dot.warn { background: var(--warn); }
.statusbar i.bad, .dot.bad { background: var(--bad); }
.statusbar i.none, .dot.none { background: var(--muted); opacity: .45; }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 5px; }
.stats.compact { grid-template-columns: repeat(3, minmax(0, 1fr)); margin-bottom: 10px; }
.stats.compact b { font-size: 18px; }
.stats.compact div { padding: 8px 10px; }
.docstatus { background: var(--surface); border: 1px solid var(--rule); border-radius: 10px; padding: 10px 14px; margin-bottom: 12px; }
dl.kv.front { background: var(--sunk); border-radius: 8px; padding: 10px 14px; margin: 0 0 14px; }
.md-img { display: block; max-width: 100%; height: auto; margin: 12px auto; background: #fff; border: 1px solid var(--rule); border-radius: 8px; padding: 8px; }
.steptext { margin-top: 16px; padding-top: 12px; border-top: 1px dashed var(--rule); }
.md-table.data { max-height: 75vh; overflow: auto; }
.md-table.data th { position: sticky; top: 0; background: var(--surface); z-index: 1; }

/* ------------------------------------------------------------------ каталог систем */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 10px; margin-bottom: 8px; }
.tile { background: var(--surface); border: 1px solid var(--rule); border-radius: 10px; padding: 12px 14px; border-top: 3px solid var(--rule); }
.tile b { display: block; font-size: 24px; font-variant-numeric: tabular-nums; line-height: 1.2; }
.tile span { display: block; font-size: 12.5px; color: var(--ink); }
.tile small { display: block; color: var(--muted); font-size: 11.5px; margin-top: 2px; }
.tile.ok { border-top-color: var(--ok); } .tile.warn { border-top-color: var(--warn); } .tile.bad { border-top-color: var(--bad); }
a.ent { display: inline-flex; gap: 6px; align-items: baseline; max-width: 100%; }
a.ent .kind, .kind-badge, .picker .kind { font-size: 10.5px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); background: var(--sunk); border-radius: 4px; padding: 0 5px; white-space: nowrap; }
a.ent.missing { color: var(--bad); }
.chip { display: inline-flex; align-items: center; gap: 4px; background: var(--sunk); border-radius: 6px; padding: 1px 7px; margin: 2px 4px 2px 0; font-size: 12.5px; }
.chip.link { cursor: pointer; } .chip.link:hover { background: var(--accent-soft); }
.pre { white-space: pre-wrap; }
.vlist > div { padding: 2px 0; border-bottom: 1px dashed var(--rule); } .vlist > div:last-child { border-bottom: 0; }
.kv.mini { grid-template-columns: minmax(80px, max-content) minmax(0, 1fr); gap: 2px 10px; font-size: 12.5px; }
.stale { color: var(--warn); }
.line { padding: 5px 0; border-bottom: 1px solid var(--rule); } .line:last-child { border-bottom: 0; }
.row.between { justify-content: space-between; }
.rel-group { margin: 8px 0; }
.crumbs { margin-bottom: 6px; color: var(--muted); }
.meta-row { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 14px; margin-bottom: 12px; }
@media (max-width: 1000px) { .meta-row { grid-template-columns: 1fr 1fr; } }
table.fields td { vertical-align: top; }
.filters { margin-bottom: 8px; }
.filters input, .filters select, .row select { border: 1px solid var(--rule); background: var(--surface); padding: 6px 8px; border-radius: 7px; }
.picker { position: relative; }
.picker-list { position: absolute; z-index: 5; left: 0; right: 0; max-width: 620px; background: var(--surface); border: 1px solid var(--rule); border-radius: 8px; box-shadow: var(--shadow); margin-top: 4px; }
.picker-list button { display: block; width: 100%; text-align: left; border: 0; background: transparent; padding: 7px 10px; cursor: pointer; }
.picker-list button:hover { background: var(--sunk); }
.path-line { font-family: var(--mono); font-size: 12.5px; padding: 4px 0; }
.steps { display: flex; flex-wrap: wrap; gap: 8px; align-items: stretch; }
.step { position: relative; background: var(--sunk); border-radius: 8px; padding: 8px 10px; min-width: 160px; max-width: 280px; }
.step:not(:last-child)::after { content: "→"; position: absolute; right: -9px; top: 40%; color: var(--muted); }
.step.missing { background: var(--bad-soft); }
.graph-wrap { overflow: auto; background: var(--surface); border: 1px solid var(--rule); border-radius: 10px; max-height: 72vh; }
.g-node rect { fill: var(--surface); stroke: var(--rule); stroke-width: 1.2; }
.g-node:hover rect { stroke: var(--accent); }
.g-node.center rect { fill: var(--accent-soft); stroke: var(--accent); stroke-width: 2; }
.g-kind { font-size: 9.5px; fill: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.g-title { font-size: 12px; fill: var(--ink); }
.g-edge path { fill: none; stroke: var(--muted); stroke-width: 1.3; opacity: .75; }
.g-edge.s-soft path { stroke-dasharray: 5 4; }
.g-edge.s-info path { opacity: .3; }
.g-arrow { fill: var(--muted); }
.g-node.k-system rect { stroke: var(--accent); } .g-node.k-host rect { stroke: var(--warn); } .g-node.k-resource rect { stroke: var(--ok); }
.calendar { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 10px; }
.month { background: var(--surface); border: 1px solid var(--rule); border-radius: 10px; padding: 10px; min-height: 80px; }
.month.overdue { border-color: var(--bad); background: var(--bad-soft); }
.month-title { font-weight: 600; text-transform: capitalize; margin-bottom: 4px; }
.cal-item { font-size: 12.5px; padding: 2px 0; }
.matrix .vert { writing-mode: vertical-rl; transform: rotate(180deg); max-height: 170px; font-size: 11.5px; text-transform: none; letter-spacing: 0; }
.cell-fail { background: var(--bad-soft); color: var(--bad); font-weight: 600; }
.error-text { color: var(--bad); }
tr.on td { background: var(--accent-soft); }
.docs .md { max-height: 70vh; overflow: auto; }
@media (max-width: 700px) {
  .main { padding: 14px 16px 48px; }
  .head h1 { font-size: 20px; }
  .tiles { grid-template-columns: 1fr 1fr; }
  .step { min-width: 0; max-width: 100%; flex: 1 1 100%; }
  .step:not(:last-child)::after { content: "↓"; right: 12px; top: auto; bottom: -14px; }
  input.search { width: 100%; }
}
