/* Агрокредит: дерево драйверов, OST и карта процессов. Токены — на :root, тёмная тема — ниже. */
:root {
  color-scheme: light;
  --bg: #f5f4ef;
  --surface: #fcfcfb;
  --surface-2: #f0efea;
  --surface-3: #e7e5de;
  --border: #dfddd5;
  --border-strong: #c9c6bb;
  --text: #1a1a18;
  --text-2: #4f4e4a;
  --muted: #76746d;
  --accent: #1f6b4f;
  --accent-soft: #e2efe8;
  --accent-ink: #ffffff;
  --focus: #2a78d6;
  --shadow: 0 1px 2px rgba(20, 20, 16, .06), 0 4px 14px rgba(20, 20, 16, .06);
  --shadow-lg: 0 10px 40px rgba(20, 20, 16, .18);

  --astra: #2a78d6; --astra-soft: #e3eefb; --astra-ink: #1c5cab;
  --opus: #eb6834; --opus-soft: #fdeae1; --opus-ink: #b0461c;
  --both: #5a5953; --both-soft: #ebeae5;

  --lv-el: #1a1a18; --lv-pd: #4a3aa7; --lv-lgd: #148a60; --lv-ead: #b77c00; --lv-cost: #c2477a; --lv-guard: #d03b3b;
  --lv-pd-soft: #ecebf8; --lv-lgd-soft: #e2f3ec; --lv-ead-soft: #fbf1dc; --lv-cost-soft: #f9e8ef; --lv-guard-soft: #fbe7e7;

  --good: #0ca30c; --good-ink: #0a6e0a; --warn: #fab219; --critical: #d03b3b;
  --conf-high: #148a60; --conf-med: #b77c00; --conf-low: #c2477a;

  --edge: #a9a69b;
  --radius: 10px;
  --radius-sm: 6px;
  --font: "Inter", "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: "JetBrains Mono", "Cascadia Code", Consolas, "SF Mono", Menlo, monospace;
  --header-h: 60px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #141413; --surface: #1c1c1a; --surface-2: #242421; --surface-3: #2e2e2a;
    --border: #353531; --border-strong: #4a4a44; --text: #f2f1ec; --text-2: #c3c2b7; --muted: #9a998f;
    --accent: #4fb389; --accent-soft: #1d3329; --accent-ink: #0c1a13; --focus: #6da7ec;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 4px 14px rgba(0, 0, 0, .35); --shadow-lg: 0 10px 40px rgba(0, 0, 0, .6);
    --astra: #3987e5; --astra-soft: #1b2a3d; --astra-ink: #86b6ef;
    --opus: #d95926; --opus-soft: #3a2419; --opus-ink: #f0a17f;
    --both: #b3b2a8; --both-soft: #2c2c28;
    --lv-el: #f2f1ec; --lv-pd: #9085e9; --lv-lgd: #36c28d; --lv-ead: #e0a82c; --lv-cost: #e27aa3; --lv-guard: #e66767;
    --lv-pd-soft: #26233d; --lv-lgd-soft: #173127; --lv-ead-soft: #33290f; --lv-cost-soft: #36212b; --lv-guard-soft: #3a1f1f;
    --good-ink: #5fd35f; --conf-high: #36c28d; --conf-med: #e0a82c; --conf-low: #e27aa3;
    --edge: #5d5c55;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #141413; --surface: #1c1c1a; --surface-2: #242421; --surface-3: #2e2e2a;
  --border: #353531; --border-strong: #4a4a44; --text: #f2f1ec; --text-2: #c3c2b7; --muted: #9a998f;
  --accent: #4fb389; --accent-soft: #1d3329; --accent-ink: #0c1a13; --focus: #6da7ec;
  --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 4px 14px rgba(0, 0, 0, .35); --shadow-lg: 0 10px 40px rgba(0, 0, 0, .6);
  --astra: #3987e5; --astra-soft: #1b2a3d; --astra-ink: #86b6ef;
  --opus: #d95926; --opus-soft: #3a2419; --opus-ink: #f0a17f;
  --both: #b3b2a8; --both-soft: #2c2c28;
  --lv-el: #f2f1ec; --lv-pd: #9085e9; --lv-lgd: #36c28d; --lv-ead: #e0a82c; --lv-cost: #e27aa3; --lv-guard: #e66767;
  --lv-pd-soft: #26233d; --lv-lgd-soft: #173127; --lv-ead-soft: #33290f; --lv-cost-soft: #36212b; --lv-guard-soft: #3a1f1f;
  --good-ink: #5fd35f; --conf-high: #36c28d; --conf-med: #e0a82c; --conf-low: #e27aa3;
  --edge: #5d5c55;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.55 var(--font); }
a { color: var(--accent); text-underline-offset: 2px; }
a:hover { text-decoration-thickness: 2px; }
button { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 4px; }
h1, h2, h3, h4 { line-height: 1.25; margin: 0 0 .5em; letter-spacing: -.01em; }
h1 { font-size: clamp(26px, 3.4vw, 36px); font-weight: 750; }
h2 { font-size: 22px; font-weight: 700; }
h3 { font-size: 17px; font-weight: 650; }
p { margin: 0 0 .8em; }
strong { font-weight: 650; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.nowrap { white-space: nowrap; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ——— Шапка ——— */
.site-header { position: sticky; top: 0; z-index: 40; height: var(--header-h); background: color-mix(in srgb, var(--surface) 92%, transparent); backdrop-filter: saturate(1.4) blur(10px); border-bottom: 1px solid var(--border); }
.site-header .in { height: 100%; display: flex; align-items: center; gap: 18px; padding: 0 20px; max-width: 1600px; margin: 0 auto; }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--text); font-weight: 700; white-space: nowrap; }
.brand-mark { width: 30px; height: 30px; border-radius: 8px; background: var(--accent); display: grid; place-items: center; color: var(--accent-ink); flex: none; }
.brand small { display: block; font-weight: 500; font-size: 11.5px; color: var(--muted); letter-spacing: .01em; }
.nav { display: flex; gap: 2px; overflow-x: auto; scrollbar-width: none; flex: 1; min-width: 0; }
.nav::-webkit-scrollbar { display: none; }
.nav a { padding: 7px 11px; border-radius: 8px; color: var(--text-2); text-decoration: none; font-size: 14px; font-weight: 550; white-space: nowrap; }
.nav a:hover { background: var(--surface-2); color: var(--text); }
.nav a[aria-current="page"] { background: var(--accent-soft); color: var(--accent); }
.hdr-actions { display: flex; gap: 6px; align-items: center; }
.icon-btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 34px; min-width: 34px; padding: 0 10px; border-radius: 8px; border: 1px solid var(--border); background: var(--surface); cursor: pointer; color: var(--text-2); font-size: 13px; }
.icon-btn:hover { border-color: var(--border-strong); color: var(--text); }
.icon-btn kbd { font: 11px var(--mono); color: var(--muted); border: 1px solid var(--border); border-radius: 4px; padding: 0 4px; }
.icon-btn svg { width: 16px; height: 16px; }
@media (max-width: 760px) {
  :root { --header-h: 96px; }
  .site-header { height: auto; }
  .site-header .in { gap: 6px 10px; padding: 8px 12px 6px; flex-wrap: wrap; height: auto; }
  .brand { flex: 1; }
  .brand-text small { display: none; }
  .nav { order: 3; flex-basis: 100%; -webkit-mask-image: linear-gradient(90deg, #000 88%, transparent); mask-image: linear-gradient(90deg, #000 88%, transparent); }
  .nav a { padding: 6px 9px; font-size: 13.5px; }
  .search-label, .icon-btn kbd { display: none; }
  .toolbar { padding: 8px 12px; gap: 8px; }
  .page, .page-head { padding-left: 16px; padding-right: 16px; }
}
.tag.wrap { white-space: normal; height: auto; padding: 3px 8px; line-height: 1.3; }

/* ——— Разметка страниц ——— */
.page { max-width: 1240px; margin: 0 auto; padding: 28px 20px 64px; }
.page.wide { max-width: none; padding: 0; }
.page-head { max-width: 1240px; margin: 0 auto; padding: 24px 20px 8px; }
.eyebrow { font-size: 12px; font-weight: 650; letter-spacing: .08em; text-transform: uppercase; color: var(--accent); margin-bottom: 6px; }
.lead { font-size: 17px; color: var(--text-2); max-width: 880px; }
.section { margin-top: 44px; }
.section > h2 { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.section-note { color: var(--muted); font-size: 14px; max-width: 880px; }
.grid { display: grid; gap: 16px; }
.grid.c2 { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
.grid.c3 { grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
.grid.c4 { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); }
.card.flat { box-shadow: none; }
.card h3 { margin-bottom: 6px; }
.card-link { display: block; text-decoration: none; color: inherit; transition: border-color .15s, transform .15s; }
.card-link:hover { border-color: var(--accent); transform: translateY(-1px); }
.card-link .go { color: var(--accent); font-weight: 600; font-size: 14px; margin-top: 10px; display: inline-flex; gap: 6px; align-items: center; }
.callout { border-left: 3px solid var(--accent); background: var(--accent-soft); padding: 12px 14px; border-radius: 0 var(--radius-sm) var(--radius-sm) 0; margin: 12px 0; }
.callout.warn { border-color: var(--lv-ead); background: var(--lv-ead-soft); }
.callout.diverge { border-color: var(--opus); background: linear-gradient(90deg, var(--astra-soft), var(--opus-soft)); }
.callout > :last-child { margin-bottom: 0; }

/* ——— Метки ——— */
.tag { display: inline-flex; align-items: center; gap: 4px; height: 22px; padding: 0 8px; border-radius: 999px; font-size: 12px; font-weight: 600; line-height: 1; white-space: nowrap; border: 1px solid transparent; background: var(--surface-2); color: var(--text-2); vertical-align: middle; }
.tag.src-A { background: var(--astra-soft); color: var(--astra-ink); }
.tag.src-O { background: var(--opus-soft); color: var(--opus-ink); }
.tag.src-AO { background: var(--both-soft); color: var(--text); }
.tag .dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.tag.lv-EL, .tag.lv-ROOT { background: var(--surface-3); color: var(--text); }
.tag.lv-PD { background: var(--lv-pd-soft); color: var(--lv-pd); }
.tag.lv-LGD { background: var(--lv-lgd-soft); color: var(--lv-lgd); }
.tag.lv-EAD { background: var(--lv-ead-soft); color: var(--lv-ead); }
.tag.lv-COST { background: var(--lv-cost-soft); color: var(--lv-cost); }
.tag.lv-GUARD { background: var(--lv-guard-soft); color: var(--lv-guard); }
.tag.outline { background: transparent; border-color: var(--border-strong); color: var(--text-2); }
.tag.target { background: var(--text); color: var(--surface); }
.tag.pass { background: color-mix(in srgb, var(--good) 14%, transparent); color: var(--good-ink); }
.tag.fail { background: color-mix(in srgb, var(--critical) 14%, transparent); color: var(--critical); }
.conf { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 600; color: var(--text-2); }
.conf i { display: inline-flex; gap: 2px; }
.conf i b { width: 6px; height: 12px; border-radius: 2px; background: var(--surface-3); }
.conf.high i b { background: var(--conf-high); }
.conf.medium i b:nth-child(-n+2) { background: var(--conf-med); }
.conf.low i b:first-child { background: var(--conf-low); }
.ctag { font-size: 11px; font-weight: 600; padding: 1px 6px; border-radius: 4px; background: var(--surface-3); color: var(--text-2); white-space: nowrap; }
.ctag.t-hyp { background: var(--lv-pd-soft); color: var(--lv-pd); }
.ctag.t-fact { background: var(--lv-lgd-soft); color: var(--lv-lgd); }
.ctag.t-vendor { background: var(--lv-ead-soft); color: var(--lv-ead); }
.ctag.t-emp { background: var(--astra-soft); color: var(--astra-ink); }
.ctag.t-op { background: var(--lv-cost-soft); color: var(--lv-cost); }
.srcref { display: inline; border: 0; padding: 0 2px; margin: 0; background: none; color: var(--accent); font-size: .86em; font-weight: 600; cursor: pointer; text-decoration: underline dotted; text-underline-offset: 3px; }
.srcref:hover { text-decoration-style: solid; }
.lnk { border: 0; padding: 0; background: none; color: var(--accent); cursor: pointer; font-weight: 600; text-decoration: underline; text-decoration-color: color-mix(in srgb, var(--accent) 40%, transparent); text-underline-offset: 2px; }
.lnk:hover { text-decoration-color: var(--accent); }
.chip-btn { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--border); background: var(--surface); border-radius: 8px; padding: 4px 10px; font-size: 13px; cursor: pointer; color: var(--text); text-align: left; }
.chip-btn:hover { border-color: var(--accent); }
.chip-btn .id { font: 600 11px var(--mono); color: var(--muted); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }

/* ——— Панель инструментов и фильтры ——— */
.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; padding: 10px 20px; background: var(--surface); border-bottom: 1px solid var(--border); position: sticky; top: var(--header-h); z-index: 20; }
.toolbar .grp { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.toolbar .lbl { font-size: 12px; color: var(--muted); font-weight: 600; margin-right: 2px; }
.seg { display: inline-flex; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; background: var(--surface-2); }
.seg button { border: 0; background: none; padding: 6px 10px; font-size: 13px; cursor: pointer; color: var(--text-2); white-space: nowrap; }
.seg button + button { border-left: 1px solid var(--border); }
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--text); font-weight: 650; box-shadow: inset 0 -2px 0 var(--accent); }
.fchip { border: 1px solid var(--border); background: var(--surface); border-radius: 999px; padding: 4px 10px; font-size: 13px; cursor: pointer; color: var(--text-2); display: inline-flex; align-items: center; gap: 6px; }
.fchip[aria-pressed="true"] { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.fchip .sw { width: 9px; height: 9px; border-radius: 3px; }
.spacer { flex: 1; }
input[type="search"], input[type="number"], select { font: inherit; font-size: 14px; color: var(--text); background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 6px 10px; }
input[type="number"] { width: 100%; }

/* ——— Дерево ——— */
.tree-shell { position: relative; }
.tree-viewport { position: relative; overflow: auto; height: calc(100vh - var(--header-h) - var(--toolbar-h, 56px)); min-height: 420px; background:
  radial-gradient(circle at 1px 1px, color-mix(in srgb, var(--border-strong) 55%, transparent) 1px, transparent 0) 0 0 / 22px 22px, var(--bg); cursor: grab; }
.tree-viewport.dragging { cursor: grabbing; user-select: none; }
.tree-sizer { position: relative; }
.tree-stage { position: absolute; left: 0; top: 0; transform-origin: 0 0; }
.tree-stage svg.edges { position: absolute; left: 0; top: 0; overflow: visible; pointer-events: none; }
.edges path { fill: none; stroke: var(--edge); stroke-width: 1.6; }
.edges path.influence { stroke-dasharray: 6 4; }
.edges path.ref { stroke-dasharray: 2 4; }
.edges path.dim { opacity: .25; }
.edges .op circle { fill: var(--surface); stroke: var(--edge); stroke-width: 1.2; }
.edges .op text { font: 700 11px var(--font); fill: var(--text-2); text-anchor: middle; dominant-baseline: central; }
.edges .op.dim { opacity: .3; }
.tnode { position: absolute; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; box-shadow: var(--shadow); padding: 9px 11px 9px 14px; cursor: pointer; transition: opacity .15s, border-color .15s, box-shadow .15s; }
.tnode::before { content: ""; position: absolute; left: 0; top: 8px; bottom: 8px; width: 4px; border-radius: 0 3px 3px 0; background: var(--node-accent, var(--border-strong)); }
.tnode:hover { border-color: var(--accent); box-shadow: var(--shadow), 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent); }
.tnode:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.tnode.dim { opacity: .28; }
.tnode.hit { box-shadow: var(--shadow), 0 0 0 3px color-mix(in srgb, var(--focus) 45%, transparent); }
.tnode .t-top { display: flex; align-items: center; gap: 5px; flex-wrap: wrap; margin-bottom: 4px; min-height: 20px; }
.tnode .t-top .tag, .tnode .t-foot .tag { height: 19px; font-size: 11px; padding: 0 7px; }
.tnode .t-title { font-weight: 650; font-size: 13.5px; line-height: 1.3; }
.tnode .t-sub { font-size: 12px; color: var(--muted); margin-top: 3px; line-height: 1.35; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tnode .t-cnt { font-size: 11.5px; color: var(--muted); margin-top: 4px; font-weight: 600; }
.tnode.root .t-cnt { color: color-mix(in srgb, var(--surface) 70%, transparent); }
.tnode .t-foot { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin-top: 6px; }
.tnode .t-id { font: 600 10.5px var(--mono); color: var(--muted); margin-left: auto; }
.tnode .tog { position: absolute; right: -12px; top: 50%; transform: translateY(-50%); width: 24px; height: 24px; border-radius: 50%; border: 1px solid var(--border-strong); background: var(--surface); color: var(--text-2); font: 700 11px var(--font); cursor: pointer; display: grid; place-items: center; padding: 0; z-index: 2; }
.tnode .tog:hover { border-color: var(--accent); color: var(--accent); }
.tnode.root { background: var(--text); color: var(--surface); border-color: var(--text); }
.tnode.root .t-sub, .tnode.root .t-id { color: color-mix(in srgb, var(--surface) 70%, transparent); }
.tnode.root::before { background: var(--accent); }
.tnode.ref { background: var(--surface-2); border-style: dashed; box-shadow: none; }
.tnode.external { background: var(--surface-2); box-shadow: none; }
.tnode.k-opp { background: color-mix(in srgb, var(--lv-pd-soft) 55%, var(--surface)); }
.tnode.k-opp .t-title::before { content: "«"; } .tnode.k-opp .t-title::after { content: "»"; }
.tnode.k-opp.top { background: var(--lv-pd-soft); }
.tnode.k-test { background: var(--surface-2); box-shadow: none; }
.tnode.k-test .t-title { font-weight: 550; font-size: 12.5px; }
.tree-legend { position: absolute; right: 16px; bottom: 16px; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; box-shadow: var(--shadow); font-size: 12px; color: var(--text-2); display: grid; gap: 5px; max-width: 280px; z-index: 5; }
.tree-legend .row { display: flex; align-items: center; gap: 8px; }
.tree-legend svg { width: 34px; height: 10px; flex: none; }
.tree-legend .x { position: absolute; right: 6px; top: 4px; border: 0; background: none; cursor: pointer; color: var(--muted); }
.zoom-ctl { position: absolute; left: 16px; bottom: 16px; display: flex; flex-direction: column; gap: 4px; z-index: 5; }
.zoom-ctl .icon-btn { width: 34px; padding: 0; background: var(--surface); box-shadow: var(--shadow); }

/* Список-представление дерева */
.tree-outline { max-width: 1100px; margin: 0 auto; padding: 18px 20px 60px; }
.tree-outline ul { list-style: none; margin: 0; padding-left: 22px; border-left: 1px dashed var(--border-strong); }
.tree-outline > ul { padding-left: 0; border-left: 0; }
.tree-outline li { margin: 6px 0; }
.tree-outline .row { display: flex; align-items: flex-start; gap: 8px; }
.tree-outline .tw { width: 22px; height: 22px; border: 1px solid var(--border); border-radius: 6px; background: var(--surface); cursor: pointer; flex: none; display: grid; place-items: center; font-size: 11px; color: var(--muted); margin-top: 2px; }
.tree-outline .tw.leaf { visibility: hidden; }
.tree-outline .o-item { flex: 1; text-align: left; background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; cursor: pointer; display: flex; flex-wrap: wrap; gap: 6px 8px; align-items: center; }
.tree-outline .o-item:hover { border-color: var(--accent); }
.tree-outline .o-item .ttl { font-weight: 600; flex: 1 1 260px; }
.tree-outline .dim > .row .o-item { opacity: .35; }

/* ——— Модальное окно ——— */
.modal-backdrop { position: fixed; inset: 0; background: rgba(12, 12, 10, .45); z-index: 80; display: none; align-items: flex-start; justify-content: center; padding: 5vh 16px; overflow-y: auto; }
.modal-backdrop.open { display: flex; }
.modal { width: min(920px, 100%); background: var(--surface); border-radius: 14px; box-shadow: var(--shadow-lg); border: 1px solid var(--border); display: flex; flex-direction: column; max-height: 90vh; animation: pop .16s ease-out; }
@keyframes pop { from { transform: translateY(8px) scale(.99); opacity: 0; } to { transform: none; opacity: 1; } }
.modal-head { padding: 16px 20px 12px; border-bottom: 1px solid var(--border); display: grid; grid-template-columns: auto 1fr auto; gap: 10px; align-items: start; }
.modal-head .kind { font-size: 12px; font-weight: 650; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.modal-head h2 { font-size: 21px; margin: 4px 0 0; }
.modal-head .mh-actions { display: flex; gap: 6px; }
.modal-body { padding: 16px 20px 22px; overflow-y: auto; }
.modal-body h3 { margin-top: 22px; font-size: 15px; text-transform: none; }
.modal-body h3:first-child { margin-top: 4px; }
.modal-body .formula { font: 13px/1.55 var(--mono); background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; white-space: pre-wrap; }
.modal .back { visibility: hidden; }
.modal.has-back .back { visibility: visible; }
@media (max-width: 760px) {
  .modal-backdrop { padding: 0; }
  .modal { max-height: 100vh; height: 100%; border-radius: 0; }
}
.kv { display: grid; grid-template-columns: 180px 1fr; gap: 8px 16px; font-size: 14px; }
.kv > dt { color: var(--muted); font-weight: 600; }
.kv > dd { margin: 0; }
@media (max-width: 600px) { .kv { grid-template-columns: 1fr; gap: 2px; } .kv > dd { margin-bottom: 8px; } }
.ab { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
@media (max-width: 640px) { .ab { grid-template-columns: 1fr; } }
.ab > div { border-radius: 8px; padding: 10px 12px; font-size: 14px; border: 1px solid var(--border); }
.ab .a { border-top: 3px solid var(--astra); }
.ab .o { border-top: 3px solid var(--opus); }
.ab .who { font-size: 12px; font-weight: 700; margin-bottom: 4px; display: flex; align-items: center; gap: 6px; }
.ab .a .who { color: var(--astra-ink); } .ab .o .who { color: var(--opus-ink); }
.linklist { display: grid; gap: 6px; }
.linklist .chip-btn { border-radius: 8px; width: 100%; justify-content: flex-start; padding: 7px 10px; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin: 8px 0 12px; overflow-x: auto; }
.tabs button { border: 0; background: none; padding: 8px 12px; cursor: pointer; font-weight: 600; color: var(--muted); border-bottom: 2px solid transparent; white-space: nowrap; font-size: 14px; }
.tabs button[aria-selected="true"] { color: var(--text); border-bottom-color: var(--accent); }

/* ——— Таблицы ——— */
.tbl-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
table.tbl { width: 100%; border-collapse: collapse; font-size: 14px; }
.tbl th, .tbl td { text-align: left; vertical-align: top; padding: 9px 12px; border-bottom: 1px solid var(--border); }
.tbl thead th { background: var(--surface-2); font-size: 12.5px; color: var(--text-2); font-weight: 650; position: sticky; top: 0; }
.tbl tbody tr:last-child td { border-bottom: 0; }
.tbl tbody tr:hover td { background: color-mix(in srgb, var(--surface-2) 60%, transparent); }
.tbl td.num, .tbl th.num { text-align: right; font-variant-numeric: tabular-nums; }
.tbl .fname { color: var(--muted); font-weight: 600; width: 32%; }
.card-table td { font-size: 13.5px; }

/* ——— Обзор ——— */
.hero { display: grid; grid-template-columns: 1.25fr 1fr; gap: 28px; align-items: center; padding: 34px 0 10px; }
@media (max-width: 900px) { .hero { grid-template-columns: 1fr; } }
.chain { display: flex; flex-wrap: wrap; align-items: stretch; gap: 8px; }
.chain .lnk-step { flex: 1 1 130px; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; position: relative; box-shadow: var(--shadow); }
.chain .lnk-step b { display: block; font-size: 14px; }
.chain .lnk-step span { font-size: 12.5px; color: var(--muted); }
.chain .lnk-step .n { font: 700 11px var(--mono); color: var(--accent); }
.chain .arrow { align-self: center; color: var(--muted); }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; }
.stat .v { font-size: 30px; font-weight: 750; letter-spacing: -.02em; line-height: 1.1; font-variant-numeric: tabular-nums; }
.stat .l { color: var(--text-2); font-size: 13.5px; margin-top: 4px; }
.stat .s { color: var(--muted); font-size: 12px; margin-top: 4px; }
.bar { height: 6px; border-radius: 3px; background: var(--surface-3); overflow: hidden; margin-top: 8px; }
.bar > i { display: block; height: 100%; background: var(--good); border-radius: 3px; }
.find { display: grid; grid-template-columns: auto 1fr; gap: 12px; padding: 14px 0; border-top: 1px solid var(--border); }
.find:first-child { border-top: 0; }
.find .num { width: 30px; height: 30px; border-radius: 50%; background: var(--accent-soft); color: var(--accent); display: grid; place-items: center; font-weight: 750; }

/* График */
.viz { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 16px 10px; position: relative; }
.viz-legend { display: flex; flex-wrap: wrap; gap: 14px; font-size: 13px; color: var(--text-2); margin-bottom: 6px; }
.viz-legend span { display: inline-flex; align-items: center; gap: 6px; }
.viz-legend i { width: 18px; height: 8px; border-radius: 4px; display: inline-block; }
.viz svg { width: 100%; height: auto; display: block; }
.viz .axis text { font: 11px var(--font); fill: var(--muted); }
.viz .axis line { stroke: var(--border); }
.viz .cat text { font: 600 12.5px var(--font); fill: var(--text); }
.viz .lbl { font: 600 11.5px var(--font); fill: var(--text-2); }
.viz .thr line { stroke: var(--text-2); stroke-width: 1.5; stroke-dasharray: 3 3; }
.viz .thr text { font: 600 10.5px var(--font); fill: var(--text-2); }
.viz .hit { fill: transparent; cursor: default; }
.tooltip { position: fixed; z-index: 90; pointer-events: none; background: var(--text); color: var(--surface); font-size: 12.5px; padding: 7px 10px; border-radius: 8px; box-shadow: var(--shadow-lg); max-width: 300px; opacity: 0; transition: opacity .1s; }
.tooltip.on { opacity: 1; }

/* ——— Процессы ——— */
.swim { display: grid; gap: 0; min-width: 1320px; border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; background: var(--surface); }
.swim .hd, .swim .lane-h, .swim .cell { border-right: 1px solid var(--border); border-bottom: 1px solid var(--border); }
.swim .hd { background: var(--surface-2); padding: 10px; font-size: 13px; font-weight: 700; position: sticky; top: 0; }
.swim .hd small { display: block; font-weight: 500; color: var(--muted); font-size: 11.5px; }
.swim .lane-h { background: var(--surface-2); padding: 10px; font-size: 13px; font-weight: 700; position: sticky; left: 0; z-index: 1; }
.swim .lane-h small { display: block; font-weight: 500; color: var(--muted); font-size: 11.5px; line-height: 1.35; margin-top: 2px; }
.swim .cell { padding: 8px; display: flex; flex-direction: column; gap: 6px; min-height: 64px; }
.swim .cell.hl { background: color-mix(in srgb, var(--accent-soft) 60%, transparent); }
.step { text-align: left; background: var(--surface); border: 1px solid var(--border); border-left: 3px solid var(--accent); border-radius: 8px; padding: 7px 9px; font-size: 12.5px; line-height: 1.35; cursor: pointer; box-shadow: var(--shadow); }
.step:hover { border-color: var(--accent); }
.step .sid { font: 600 10px var(--mono); color: var(--muted); display: flex; gap: 6px; align-items: center; margin-bottom: 3px; }
.step .sid .tag { font-family: var(--font); height: 18px; font-size: 10.5px; padding: 0 6px; }
.swim .cell .chip-btn { width: 100%; font-size: 12px; line-height: 1.3; padding: 6px 8px; }
.swim .cell .chip-btn.rf { border-left: 3px solid var(--lv-guard); background: color-mix(in srgb, var(--lv-guard-soft) 45%, var(--surface)); }
.swim .cell .chip-btn.op { border-left: 3px solid var(--lv-pd); background: color-mix(in srgb, var(--lv-pd-soft) 60%, var(--surface)); }
.step.dim { opacity: .3; }
.scroll-x { overflow-x: auto; padding-bottom: 6px; }
.flow { display: flex; flex-wrap: wrap; gap: 10px; align-items: stretch; }
.flow .fs { flex: 1 1 160px; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; position: relative; }
.flow .fs .k { font: 700 11px var(--mono); color: var(--accent); }
.flow .fs b { display: block; font-size: 14px; margin: 2px 0 4px; }
.flow .fs p { font-size: 13px; color: var(--text-2); margin: 0; }
.flow .ar { align-self: center; color: var(--muted); font-size: 20px; }
.calc { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; }
.calc label { font-size: 12.5px; color: var(--text-2); font-weight: 600; display: grid; gap: 4px; }
.result { margin-top: 14px; padding: 14px; border-radius: 10px; background: var(--surface-2); border: 1px solid var(--border); }
.result .big { font-size: 26px; font-weight: 750; font-variant-numeric: tabular-nums; }
.result .verdict { font-weight: 650; display: inline-flex; gap: 6px; align-items: center; }
.verdict.ok { color: var(--good-ink); } .verdict.bad { color: var(--critical); } .verdict.mid { color: var(--lv-ead); }
.dtree ul { list-style: none; margin: 0; padding-left: 20px; border-left: 2px solid var(--border); }
.dtree > ul { padding-left: 0; border-left: 0; }
.dtree li { margin: 8px 0; }
.dtree .q { background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 8px 11px; font-size: 14px; }
.dtree .q .if { color: var(--text-2); }
.dtree .q .then { font-weight: 600; }
.dtree .q .arrow { color: var(--accent); font-weight: 700; margin: 0 4px; }
.timeline { display: grid; gap: 0; position: relative; }
.timeline .ti { display: grid; grid-template-columns: 170px 1fr; gap: 14px; padding: 12px 0; border-top: 1px solid var(--border); }
.timeline .ti:first-child { border-top: 0; }
.timeline .when { font-weight: 700; font-size: 13.5px; }
@media (max-width: 640px) { .timeline .ti { grid-template-columns: 1fr; gap: 4px; } }
.states { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.state { border: 1px solid var(--border); background: var(--surface); border-radius: 999px; padding: 6px 12px; font-size: 13px; font-weight: 600; }
.pre { font: 12.5px/1.6 var(--mono); background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px; padding: 12px 14px; white-space: pre; overflow-x: auto; }

/* ——— Покрытие ——— */
.cov-reg { border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); margin-bottom: 10px; }
.cov-reg > summary { list-style: none; cursor: pointer; padding: 11px 14px; display: grid; grid-template-columns: 1fr auto 140px; gap: 12px; align-items: center; }
.cov-reg > summary::-webkit-details-marker { display: none; }
.cov-reg > summary .nm { font-weight: 600; }
.cov-reg > summary .nm .key { font: 600 11px var(--mono); color: var(--muted); margin-left: 6px; }
.cov-reg .items { border-top: 1px solid var(--border); }
.cov-item { display: grid; grid-template-columns: 110px 1fr 1.1fr; gap: 12px; padding: 9px 14px; border-top: 1px solid var(--border); font-size: 13.5px; align-items: start; }
.cov-item:first-child { border-top: 0; }
.cov-item .iid { font: 600 11px var(--mono); color: var(--muted); padding-top: 3px; }
.cov-item.bad { background: color-mix(in srgb, var(--critical) 8%, transparent); }
@media (max-width: 760px) { .cov-item { grid-template-columns: 1fr; gap: 4px; } .cov-reg > summary { grid-template-columns: 1fr auto; } .cov-reg > summary .bar { display: none; } }
.lint { display: grid; gap: 6px; }
.lint .li { display: grid; grid-template-columns: auto 1fr; gap: 10px; align-items: start; padding: 9px 12px; background: var(--surface); border: 1px solid var(--border); border-radius: 8px; font-size: 14px; }
.lint .li small { display: block; color: var(--muted); }

.foot { border-top: 1px solid var(--border); margin-top: 40px; padding: 22px 20px 40px; color: var(--muted); font-size: 13px; }
.foot .in { max-width: 1240px; margin: 0 auto; display: flex; flex-wrap: wrap; gap: 8px 20px; justify-content: space-between; }

/* ——— Поиск ——— */
.search-dlg .modal { max-width: 680px; }
.search-input { width: 100%; font-size: 17px !important; padding: 12px 14px !important; border-radius: 10px !important; }
.search-res { margin-top: 10px; display: grid; gap: 4px; max-height: 60vh; overflow-y: auto; }
.search-res button { display: grid; grid-template-columns: 110px 1fr; gap: 10px; align-items: baseline; text-align: left; padding: 8px 10px; border-radius: 8px; border: 1px solid transparent; background: none; cursor: pointer; }
.search-res button:hover, .search-res button.sel { background: var(--surface-2); border-color: var(--border); }
.search-res .ty { font-size: 11.5px; color: var(--muted); font-weight: 650; text-transform: uppercase; letter-spacing: .04em; }

@media print {
  .site-header, .toolbar, .zoom-ctl, .tree-legend { display: none !important; }
  body { background: #fff; }
}
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }

/* Узкие экраны: элементы панелей не шире экрана */
.toolbar .grp { min-width: 0; max-width: 100%; }
.seg { max-width: 100%; overflow-x: auto; scrollbar-width: none; }
.seg::-webkit-scrollbar { display: none; }
select { max-width: 100%; text-overflow: ellipsis; }
