:root {
  --bg: oklch(0.99 0.006 145);
  --surface: #ffffff;
  --surface-2: oklch(0.985 0.008 145);
  --border: oklch(0.92 0.015 145);
  --border-soft: oklch(0.94 0.015 145);
  --border-softer: oklch(0.96 0.01 145);

  --text: oklch(0.22 0.015 145);
  --text-dim: oklch(0.5 0.02 145);
  --text-dim-2: oklch(0.4 0.02 145);

  --brand: oklch(0.58 0.15 148);
  --brand-hover: oklch(0.5 0.15 148);
  --brand-text: oklch(0.46 0.15 148);
  --brand-text-hover: oklch(0.38 0.15 148);
  --brand-soft: oklch(0.965 0.025 145);

  --ok: oklch(0.42 0.12 148);
  --ok-bg: oklch(0.94 0.05 148);
  --bad: oklch(0.45 0.15 25);
  --bad-bg: oklch(0.94 0.08 25);
  --est: oklch(0.42 0.1 70);
  --est-bg: oklch(0.94 0.09 85);
  --incomp: oklch(0.5 0.02 145);
  --incomp-bg: oklch(0.95 0.01 145);
  --nodata: oklch(0.55 0.015 145);
  --nodata-bg: oklch(0.95 0.01 145);
  --oos: oklch(0.48 0.06 300);
  --oos-bg: oklch(0.94 0.05 300);

  --ink: oklch(0.22 0.02 145);
  --ink-2: oklch(0.28 0.02 145);
  --ink-line: oklch(0.36 0.02 145);
  --ink-dim: oklch(0.62 0.02 145);

  --radius-lg: 14px;
  --radius-md: 10px;
  --radius-sm: 6px;

  --font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --mono: var(--font);
  --disp: var(--font);
  --body: var(--font);
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0; font-family: var(--font); color: var(--text);
  background: var(--bg); line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--brand-text); }
a:hover { color: var(--brand-text-hover); }
h1, h2, h3 { font-family: var(--font); font-weight: 700; letter-spacing: -0.02em; margin: 0; }
.mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }

/* ---------- каркас: сайдбар + шапка (заменяет старый .topbar/.steps) ---------- */
.shell { display: flex; width: 100%; min-height: 100vh; }

.sidebar {
  width: 240px; flex-shrink: 0; background: var(--surface);
  border-right: 1px solid var(--border); display: flex; flex-direction: column;
  padding: 24px 16px; gap: 28px;
}
.sidebar-brand { display: flex; align-items: center; gap: 10px; padding: 0 8px; }
.sidebar-brand .mark {
  width: 32px; height: 32px; border-radius: 9px; background: var(--brand);
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.sidebar-brand .mark i { width: 12px; height: 12px; border-radius: 3px; background: #fff; }
.sidebar-brand .name { font-size: 18px; font-weight: 800; letter-spacing: -0.02em; }

.sidebar-nav { display: flex; flex-direction: column; gap: 4px; }
.sidebar-nav a {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: var(--radius-md);
  font-size: 14px; font-weight: 500; color: var(--text-dim-2); transition: background .12s;
}
.sidebar-nav a .dot { width: 7px; height: 7px; border-radius: 2px; background: oklch(0.7 0.03 145); flex-shrink: 0; }
.sidebar-nav a:hover { background: var(--brand-soft); }
.sidebar-nav a.active { background: var(--brand-soft); color: var(--text); }
.sidebar-nav a.active .dot { background: var(--brand); }

.sidebar-foot {
  margin-top: auto; padding: 12px; border-radius: 12px; background: var(--brand-soft);
  font-size: 12px; color: var(--text-dim); line-height: 1.5;
}

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  height: 64px; flex-shrink: 0; border-bottom: 1px solid var(--border); background: var(--surface);
  display: flex; align-items: center; padding: 0 32px;
}
.topbar .crumb { font-size: 14px; color: var(--text-dim); }

.content { flex: 1; overflow-y: auto; padding: 32px; display: flex; justify-content: center; }
.wrap { width: 100%; max-width: 1080px; }

/* upload */
.hero-upload { max-width: 720px; }
.eyebrow { font-size: 12px; text-transform: uppercase; letter-spacing: 0.14em; color: var(--brand-text); margin-bottom: 18px; font-weight: 600; }
.hero-upload h1 { font-size: clamp(28px, 4vw, 40px); line-height: 1.12; margin-bottom: 18px; }
.hero-upload p.lead { font-size: 16px; color: var(--text-dim); max-width: 56ch; margin-bottom: 32px; }
.drop {
  border: 1.5px dashed var(--border); border-radius: var(--radius-lg); background: var(--surface-2);
  padding: 44px 32px; text-align: center; transition: border-color .15s, background .15s; cursor: pointer; display: block;
}
.drop.hot { border-color: var(--brand); background: var(--brand-soft); }
.drop .icon { font-size: 26px; color: var(--brand); }
.drop .big { font-size: 17px; font-weight: 700; margin: 14px 0 6px; }
.drop .sub { color: var(--text-dim); font-size: 14px; }
.drop input { display: none; }
.chosen { margin-top: 18px; font-size: 13px; color: var(--text); display: none; }
.chosen.show { display: block; }
.chosen b { color: var(--ok); }
.btn {
  font-family: var(--font); font-weight: 600; font-size: 14px; border: none;
  background: var(--brand); color: #fff; padding: 12px 22px; border-radius: var(--radius-md);
  cursor: pointer; transition: background .15s, transform .05s; text-decoration: none; display: inline-block;
}
.btn:hover { background: var(--brand-hover); }
.btn:active { transform: translateY(1px); }
.btn[disabled] { background: var(--nodata); cursor: not-allowed; }
.btn.ghost { background: transparent; color: var(--brand-text); border: 1.5px solid var(--border); }
.btn.ghost:hover { border-color: var(--brand); background: var(--brand-soft); }
.btn.accent { background: var(--brand); box-shadow: 0 2px 10px oklch(0.58 0.15 148 / 0.28); }
.btn.accent:hover { background: var(--brand-hover); }
.row-actions { margin-top: 28px; display: flex; gap: 12px; align-items: center; }
.note-static { margin-top: 24px; font-size: 13px; color: var(--text-dim); border-left: 2px solid var(--border); padding-left: 14px; }

/* work layout */
.work { display: grid; grid-template-columns: 320px 1fr; gap: 28px; align-items: start; }
@media (max-width: 900px) { .work { grid-template-columns: 1fr; } }

/* observer pipeline — намеренно тёмная панель («движок»), контраст с остальным светлым интерфейсом */
.observer {
  background: var(--ink); border-radius: var(--radius-lg); padding: 22px 20px; color: #fff;
  position: sticky; top: 24px;
}
.observer h2 { font-size: 13px; text-transform: uppercase; letter-spacing: 0.12em; color: var(--ink-dim); font-weight: 600; margin-bottom: 18px; }
.pipe { position: relative; padding-left: 30px; }
.pipe::before { content:""; position:absolute; left: 9px; top: 8px; bottom: 8px; width: 2px; background: var(--ink-line); }
.pipe .fill { position:absolute; left: 9px; top: 8px; width: 2px; background: var(--brand); height: 0; transition: height .4s ease; }
.node { position: relative; padding: 12px 0; }
.node .dot {
  position: absolute; left: -30px; top: 14px; width: 20px; height: 20px; border-radius: 50%;
  background: var(--ink-2); border: 2px solid var(--ink-line); display: grid; place-items: center;
  font-size: 10px; color: var(--ink-dim); transition: all .3s;
}
.node .lab { font-weight: 600; font-size: 14.5px; color: var(--ink-dim); transition: color .3s; }
.node .det { font-size: 11.5px; color: var(--ink-line); margin-top: 3px; min-height: 14px; transition: color .3s; }
.node.running .dot { border-color: var(--brand); color: var(--brand); box-shadow: 0 0 0 4px oklch(0.58 0.15 148 / 0.18); animation: pulse 1s infinite; }
.node.running .lab { color: #fff; }
.node.running .det { color: var(--brand); }
.node.done .dot { background: var(--brand); border-color: var(--brand); color: #fff; }
.node.done .lab { color: oklch(0.85 0.02 145); }
.node.done .det { color: var(--ink-dim); }
@keyframes pulse { 0%,100%{ box-shadow: 0 0 0 4px oklch(0.58 0.15 148 / 0.18);} 50%{ box-shadow: 0 0 0 7px oklch(0.58 0.15 148 / 0.06);} }

.obs-foot { margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--ink-line); display: flex; align-items: center; justify-content: space-between; }
.obs-foot .state { font-size: 12px; color: var(--brand); font-weight: 600; }
.toggle { font-size: 11px; color: var(--ink-dim); cursor: pointer; user-select: none; display: inline-flex; align-items: center; gap: 7px; }
.toggle .sw { width: 30px; height: 16px; background: var(--ink-line); border-radius: 10px; position: relative; transition: background .2s; }
.toggle .sw::after { content:""; position:absolute; top:2px; left:2px; width:12px; height:12px; border-radius:50%; background:#fff; transition: transform .2s; }
.toggle.on .sw { background: var(--brand); }
.toggle.on .sw::after { transform: translateX(14px); }

/* content column */
.panel-head { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 6px; }
.panel-head h1 { font-size: 25px; }
.panel-head .sub { font-size: 12px; color: var(--text-dim); }
.doc-meta { font-size: 13px; color: var(--text-dim); margin-bottom: 14px; }
.stat-bar { display: flex; gap: 10px; margin-bottom: 24px; flex-wrap: wrap; }
.qsrc { font-size: 10px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; padding: 1px 8px; border-radius: 999px; margin-left: 8px; }
.qsrc.gigachat { background: var(--brand-soft); color: var(--brand-text); }
.qsrc.template { background: var(--incomp-bg); color: var(--text-dim); }

/* debug */
.debug { background: var(--ink); color: #fff; border-radius: var(--radius-lg); padding: 22px; margin-bottom: 26px; display: none; }
.debug.show { display: block; }
.debug h3 { font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: 0.12em; color: var(--ink-dim); margin-bottom: 14px; }
.debug-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px,1fr)); gap: 18px; }
.dbox { background: var(--ink-2); border: 1px solid var(--ink-line); border-radius: var(--radius-sm); padding: 14px; }
.dbox .k { font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--ink-dim); margin-bottom: 9px; }
.dbox ul { margin: 0; padding: 0; list-style: none; }
.dbox li { font-size: 12.5px; color: oklch(0.88 0.02 145); padding: 3px 0; display: flex; justify-content: space-between; gap: 10px; }
.dbox li span { color: var(--ink-dim); }
.pill { font-size: 11px; padding: 2px 9px; border-radius: 999px; }
.pill.on { background: oklch(0.42 0.12 148 / 0.25); color: oklch(0.78 0.11 148); }
.pill.off { background: oklch(0.62 0.02 145 / 0.2); color: var(--ink-dim); }
.logbox { margin-top: 16px; background: oklch(0.15 0.015 145); border: 1px solid var(--ink-line); border-radius: var(--radius-sm); padding: 12px 14px; max-height: 180px; overflow-y: auto; }
.logbox .line { font-size: 12px; color: oklch(0.75 0.02 145); padding: 2px 0; }
.logbox .line .t { color: var(--ink-dim); }
.logbox .line .s-done { color: oklch(0.78 0.11 148); }
.logbox .line .s-run { color: var(--brand); }

/* verdicts */
.verdicts { display: grid; gap: 14px; }
.vcard {
  background: var(--surface); border: 1px solid var(--border); border-left-width: 4px;
  border-radius: var(--radius-lg); padding: 18px 20px; opacity: 0; transform: translateY(8px);
  transition: opacity .4s, transform .4s;
}
.vcard.in { opacity: 1; transform: none; }
.vcard .vtop { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-bottom: 10px; }
.vcard .vname { font-weight: 700; font-size: 16px; }
.vstatus { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; padding: 4px 11px; border-radius: 999px; white-space: nowrap; }
.vcard .vnums { font-size: 14px; margin-bottom: 8px; }
.vcard .vnums .arrow { color: var(--text-dim); margin: 0 8px; }
.vcard .vexp { font-size: 14px; color: var(--text-dim); }
.vcard .vprov { font-size: 11.5px; color: var(--text-dim); margin-top: 10px; padding-top: 10px; border-top: 1px dashed var(--border); }
.vcard .vprov a { color: var(--brand-text); }
.corridor { margin: 8px 0; height: 34px; position: relative; }
.corridor .track { position: absolute; top: 15px; left: 0; right: 0; height: 4px; background: var(--border); border-radius: 2px; }
.corridor .band { position: absolute; top: 13px; height: 8px; background: var(--est-bg); border: 1px solid var(--est); border-radius: 3px; }
.corridor .claim { position: absolute; top: 6px; width: 2px; height: 22px; background: var(--text); }
.corridor .claim::after { content: attr(data-lab); position: absolute; top: -16px; left: 50%; transform: translateX(-50%); font-size: 10px; color: var(--text); white-space: nowrap; }

/* status colors (устаревшая схема .s-<status>, не используется JS, оставлена не мешает) */
.s-подтверждено { border-left-color: var(--ok); } .vstatus.s-подтверждено { background: var(--ok-bg); color: var(--ok); }
.s-противоречие { border-left-color: var(--bad); } .vstatus.s-противоречие { background: var(--bad-bg); color: var(--bad); }
.s-оценка { border-left-color: var(--est); } .vstatus.s-оценка { background: var(--est-bg); color: var(--est); }
.s-не_сопоставимо { border-left-color: var(--incomp); } .vstatus.s-не_сопоставимо { background: var(--incomp-bg); color: var(--incomp); }
.s-не_найдено { border-left-color: var(--nodata); } .vstatus.s-не_найдено { background: var(--nodata-bg); color: var(--nodata); }
.s-не_маршрутизировано { border-left-color: var(--oos); } .vstatus.s-не_маршрутизировано { background: var(--oos-bg); color: var(--oos); }

/* severity — реальная схема классов, которую отдаёт decorate_verdict/work.js */
.vcard.sev-attention { border-left-color: var(--bad); }
.vcard.sev-warn { border-left-color: var(--est); }
.vcard.sev-ok { border-left-color: var(--ok); }
.vstatus.sev-attention { background: var(--bad-bg); color: var(--bad); }
.vstatus.sev-warn { background: var(--est-bg); color: var(--est); }
.vstatus.sev-ok { background: var(--ok-bg); color: var(--ok); }

.vheadline { font-size: 13.5px; margin: -2px 0 10px; color: var(--text-dim); }
.vcard.sev-attention .vheadline { color: var(--bad); }
.vcard.sev-warn .vheadline { color: var(--est); }

/* точечная оценка — клэмп подписи у краёв шкалы */
.corridor .claim.lab-left::after { left: 0; transform: none; }
.corridor .claim.lab-right::after { left: auto; right: 0; transform: none; }
.corridor.point .track { opacity: .5; }

/* позиция в рыночном распределении — сегментированная полоса */
.bucket-bar { display: flex; gap: 2px; height: 20px; margin: 8px 0; border-radius: 4px; overflow: hidden; }
.bucket-seg { background: var(--border); transition: background .15s; }
.bucket-seg.active { background: var(--brand); }

/* свёрнуто/развёрнуто */
.vdetails { max-height: 0; overflow: hidden; transition: max-height .25s ease; }
.vcard.open .vdetails { max-height: 2400px; }
.vexpand {
  display: inline-flex; align-items: center; gap: 6px; margin-top: 10px;
  font-size: 11.5px; color: var(--brand-text); cursor: pointer; user-select: none;
}
.vexpand .chev { display: inline-block; transition: transform .2s; }
.vcard.open .vexpand .chev { transform: rotate(90deg); }
.vreport-add { display: none; }

.vtop-right { display: flex; align-items: center; gap: 12px; }
.vcheck {
  display: flex; align-items: center; gap: 6px; cursor: pointer; user-select: none;
  font-size: 11px; color: var(--text-dim); white-space: nowrap;
}
.vcheck input { accent-color: var(--brand); width: 15px; height: 15px; cursor: pointer; }

.select-all {
  display: inline-flex; align-items: center; gap: 8px; cursor: pointer; user-select: none;
  font-size: 12.5px; color: var(--text-dim); margin-bottom: 14px;
}
.select-all input { accent-color: var(--brand); width: 16px; height: 16px; cursor: pointer; }

/* секции карточек */
.vsection-head {
  font-weight: 700; font-size: 16px; letter-spacing: -0.01em;
  margin: 30px 0 12px; padding-bottom: 8px; border-bottom: 2px solid var(--border);
  display: flex; align-items: baseline; gap: 10px; scroll-margin-top: 20px;
}
.verdicts > .vsection-head:first-child { margin-top: 0; }
.vsection-head .cnt { font-weight: 400; font-size: 12.5px; color: var(--text-dim); }

.stat-summary { font-size: 15.5px; margin-bottom: 12px; color: var(--text); }

/* левая панель после завершения прогона — компактная навигация вместо лога стадий */
.observer.compact .pipe { display: none; }
.observer.compact h2 { display: none; }
.observer-nav { display: none; }
.observer.compact .observer-nav { display: block; }
.observer-nav a {
  display: flex; justify-content: space-between; gap: 10px; text-decoration: none;
  font-size: 12.5px; color: var(--ink-dim);
  padding: 8px 0; border-bottom: 1px solid var(--ink-line);
}
.observer-nav a:hover { color: #fff; }
.observer-nav a b { color: var(--brand); font-weight: 700; }

.result-actions { margin-top: 28px; display: none; gap: 12px; }
.result-actions.show { display: flex; }

/* report page */
.report-doc { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 40px 44px; max-width: 820px; margin: 0 auto; }
.report-doc h1 { font-size: 27px; margin-bottom: 4px; }
.report-doc .rmeta { font-size: 13px; color: var(--text-dim); margin-bottom: 26px; padding-bottom: 18px; border-bottom: 2px solid var(--border); }
.rsec { font-size: 14px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; color: var(--brand-text); margin: 24px 0 12px; }
.ritem { padding: 12px 0; border-bottom: 1px solid var(--border); }
.ritem .rq { font-size: 15px; }
.ritem .rp { font-size: 11.5px; color: var(--text-dim); margin-top: 5px; }
.disclaimer { margin-top: 24px; font-size: 13px; color: var(--text-dim); font-style: italic; }
.dl-bar { max-width: 820px; margin: 22px auto 0; display: flex; gap: 12px; justify-content: flex-end; }

.empty { text-align: center; padding: 60px 20px; color: var(--text-dim); }
.badge-demo { font-size: 11px; color: var(--est); border: 1px solid var(--est); border-radius: 999px; padding: 2px 9px; text-transform: uppercase; letter-spacing: 0.08em; }

/* уверенность системы */
.vconf { margin-top: 12px; padding-top: 12px; border-top: 1px dashed var(--border); font-size: 13px; }
.vconf b { color: var(--text); font-weight: 600; }
.vconf ul { margin: 8px 0 0; padding: 0; list-style: none; }
.vconf li {
  display: flex; justify-content: space-between; gap: 12px; padding: 3px 0;
  font-size: 12px; color: var(--text-dim);
}
.vconf li span { color: var(--bad); flex-shrink: 0; }
.vconf-clean { margin-top: 6px; font-size: 13px; color: var(--text-dim); }

/* вкладки результатов (Метрики/Обзор/... — см. §17 П2) */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 22px; }
.tabs .tab { padding: 10px 4px; margin-right: 22px; font-size: 14px; font-weight: 600; cursor: pointer; color: var(--text-dim); border-bottom: 2px solid transparent; margin-bottom: -1px; user-select: none; }
.tabs .tab.active { color: var(--text); border-bottom-color: var(--brand); }

/* KPI-карточки (вкладка «Обзор») */
.kpi-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 8px; }
@media (max-width: 900px) { .kpi-grid { grid-template-columns: repeat(2, 1fr); } }
.kpi-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 18px 20px; }
.kpi-card .label { font-size: 12.5px; color: var(--text-dim); font-weight: 500; }
.kpi-card .value { font-size: 24px; font-weight: 800; margin-top: 8px; }

/* общая карточка-панель (воронка, блоки примечаний и т.д.) */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 20px 22px; }

/* воронка TAM/SAM/SOM */
.funnel { display: flex; flex-direction: column; gap: 10px; }
.funnel .step { display: flex; align-items: center; gap: 14px; }
.funnel .step .bar { height: 34px; border-radius: var(--radius-sm); display: flex; align-items: center; padding: 0 12px; color: #fff; font-weight: 700; font-size: 13px; white-space: nowrap; transition: width .3s ease; }
.funnel .step .lab { width: 230px; flex-shrink: 0; font-size: 13.5px; color: var(--text-dim); }
@media (max-width: 700px) { .funnel .step { flex-wrap: wrap; } .funnel .step .lab { width: 100%; } }

/* общий заголовок страницы результатов (титул/бейджи/кнопка отчёта), общий для всех вкладок */
.page-head-row { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 20px; gap: 16px; }
.page-head-row h1 { font-size: 24px; letter-spacing: -0.02em; }
.page-badges { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }

.vstatus.neutral { background: var(--incomp-bg); color: var(--incomp); }

/* сетка карточек в 2 колонки (Тренды/Риски — как в макете, титул + бейдж сверху, описание ниже) */
.cards-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 800px) { .cards-grid-2 { grid-template-columns: 1fr; } }
.fact-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 20px; }
.fact-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; margin-bottom: 8px; }
.fact-title { font-size: 15px; font-weight: 700; }
.fact-desc { font-size: 13.5px; color: var(--text-dim); line-height: 1.55; }
.fact-src { font-size: 12px; color: var(--text-dim); margin-top: 10px; }
.fact-src a { color: var(--brand-text); }

.section-label { font-size: 13px; font-weight: 700; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.03em; margin-bottom: 14px; }
