:root {
  --bg: #F6F3EE;
  --card: #FFFFFF;
  --line: #E6E0D6;
  --line-2: #EFEAE2;
  --ink: #1D2826;
  --ink-2: #4F5B58;
  --muted: #7D8784;
  --teal: #0E5A53;
  --teal-2: #2C7A71;
  --teal-3: #86BDB4;
  --teal-4: #D3E9E4;
  --teal-5: #EAF4F1;
  --ochre: #9A6514;
  --ochre-2: #C9892C;
  --ochre-bg: #FAEFD9;
  --gray-bg: #EFEDE8;
  --h1: #0E3F3A;
  --h2: #2F6F67;
  --h3: #6FA9A0;
  --h4: #B5D8D1;
  --h5: #E1F0EC;
  --radius: 10px;
  --font: 'Onest', system-ui, -apple-system, 'Segoe UI', sans-serif;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 15px/1.45 var(--font); font-feature-settings: 'tnum' 1;
}
a { color: var(--teal); }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3 { margin: 0; font-weight: 650; letter-spacing: -0.01em; }
h1 { font-size: 28px; line-height: 1.2; }
h2 { font-size: 18px; }
h3 { font-size: 15px; }
.muted { color: var(--muted); }
.ink2 { color: var(--ink-2); }
.small { font-size: 13px; }
.num { font-variant-numeric: tabular-nums; }

/* ---------- каркас ---------- */
.app { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }
.side {
  border-right: 1px solid var(--line); padding: 20px 12px; position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column; gap: 4px; background: var(--bg);
}
.brand { display: flex; align-items: center; gap: 10px; padding: 0 10px 18px; font-weight: 700; font-size: 18px; color: var(--teal); text-decoration: none; }
.brand-mark { width: 26px; height: 26px; flex: none; }
.nav a {
  display: flex; align-items: center; gap: 12px; padding: 9px 12px; border-radius: 8px;
  color: var(--ink); text-decoration: none; font-weight: 500;
}
.nav a svg { width: 19px; height: 19px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.7; }
.nav a:hover { background: var(--line-2); }
.nav a[aria-current="page"] { background: var(--teal-4); color: var(--teal); font-weight: 650; }
.side-foot { margin-top: auto; padding: 12px; font-size: 12px; color: var(--muted); line-height: 1.5; }

.main { min-width: 0; display: flex; flex-direction: column; }
.top {
  display: flex; align-items: center; gap: 16px; padding: 14px 28px; border-bottom: 1px solid var(--line);
  background: var(--bg); position: sticky; top: 0; z-index: 20;
}
.org { border: 1px solid var(--line); background: var(--card); border-radius: 8px; padding: 7px 12px; font-weight: 500; white-space: nowrap; }
.demo-tag { font-size: 12px; color: var(--ochre); background: var(--ochre-bg); padding: 3px 8px; border-radius: 6px; white-space: nowrap; }
.spacer { flex: 1; }
.role { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; background: var(--card); padding: 3px; }
.role button { border: 0; background: none; padding: 6px 12px; border-radius: 6px; cursor: pointer; font-weight: 500; color: var(--ink-2); }
.role button[aria-pressed="true"] { background: var(--teal); color: #fff; }
.me { display: flex; align-items: center; gap: 10px; }
.me-text { line-height: 1.2; font-size: 13px; }
.me-text b { display: block; font-size: 14px; font-weight: 600; }
.ava {
  width: 36px; height: 36px; border-radius: 50%; display: inline-grid; place-items: center; flex: none;
  background: var(--teal-4); color: var(--teal); font-weight: 650; font-size: 13px;
}
.ava.dark { background: var(--teal); color: #fff; }
.ava.lg { width: 64px; height: 64px; font-size: 22px; }
.ava.sm { width: 28px; height: 28px; font-size: 11px; }

.page { padding: 24px 28px 48px; display: flex; flex-direction: column; gap: 20px; max-width: 1400px; width: 100%; }
.page-head { display: flex; align-items: flex-end; gap: 16px; flex-wrap: wrap; }
.page-head .sub { color: var(--ink-2); margin-top: 4px; }
.crumbs { font-size: 14px; color: var(--muted); }
.crumbs a { text-decoration: none; }

.grid { display: grid; gap: 20px; }
.g-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.g-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g-main { grid-template-columns: minmax(0, 1.65fr) minmax(0, 1fr); }
.g-main-r { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; min-width: 0; }
.card-head { display: flex; align-items: baseline; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.card-head .hint { color: var(--muted); font-size: 13px; }
.card-head .right { margin-left: auto; }
.card-foot { margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line-2); font-size: 13px; color: var(--muted); }

/* ---------- KPI ---------- */
.kpi h3 { font-weight: 600; }
.kpi .val { display: flex; align-items: baseline; gap: 10px; margin: 8px 0 6px; flex-wrap: wrap; }
.kpi .big { font-size: 38px; font-weight: 700; color: var(--teal); line-height: 1; letter-spacing: -0.02em; }
.kpi .unit { font-size: 22px; font-weight: 650; color: var(--teal); }
.delta { font-size: 13px; background: var(--teal-5); color: var(--teal); padding: 3px 8px; border-radius: 6px; font-weight: 500; }
.kpi p { margin: 0; color: var(--ink-2); font-size: 13px; }

/* ---------- бейджи ---------- */
.tag { display: inline-block; font-size: 12.5px; font-weight: 550; padding: 3px 9px; border-radius: 6px; white-space: nowrap; }
.tag.ok { background: var(--teal-4); color: var(--teal); }
.tag.part { background: var(--ochre-bg); color: var(--ochre); }
.tag.none { background: var(--gray-bg); color: var(--ink-2); }
.tag.warn { background: var(--ochre-bg); color: var(--ochre); }
.tag.neutral { background: var(--teal-5); color: var(--teal-2); }

/* ---------- кнопки ---------- */
.btn {
  border: 1px solid var(--teal); background: var(--card); color: var(--teal); padding: 10px 16px; border-radius: 8px;
  font-weight: 600; cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; gap: 8px; white-space: nowrap;
}
.btn:hover { background: var(--teal-5); }
.btn.primary { background: var(--teal); color: #fff; }
.btn.primary:hover { background: #0B4943; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
:focus-visible { outline: 2px solid var(--teal-2); outline-offset: 2px; }

/* ---------- таблицы ---------- */
.tbl-wrap { overflow-x: auto; margin: 0 -4px; padding: 0 4px; }
table { border-collapse: collapse; width: 100%; }
th { text-align: left; font-size: 13px; font-weight: 600; color: var(--ink-2); background: #FAF8F4; padding: 10px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 11px 12px; border-bottom: 1px solid var(--line-2); vertical-align: top; }
tr:last-child td { border-bottom: 0; }
tr.click { cursor: pointer; }
tr.click:hover td { background: #FBFAF7; }
td.c, th.c { text-align: center; }
td.r, th.r { text-align: right; }

/* ---------- воронка ---------- */
.funnel { display: flex; flex-direction: column; gap: 10px; }
.f-row { display: grid; grid-template-columns: 96px 1fr 128px; gap: 14px; align-items: center; }
.f-name { font-weight: 550; font-size: 14px; }
.f-bar { position: relative; height: 26px; }
.f-bar .track { position: absolute; inset: 0; background: var(--line-2); border-radius: 0 4px 4px 0; }
.f-bar .fill { position: absolute; left: 0; top: 0; bottom: 0; background: var(--teal); border-radius: 0 4px 4px 0; min-width: 3px; }
.f-bar .n { position: absolute; left: 8px; top: 50%; transform: translateY(-50%); font-weight: 650; font-size: 14px; }
.f-bar .n.in { color: #fff; }
.f-meta { font-size: 13px; color: var(--ink-2); text-align: right; line-height: 1.3; }
.f-meta b { color: var(--ink); font-weight: 600; }

/* ---------- графики ---------- */
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart text { font-family: var(--font); }
.legend { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 13px; color: var(--ink-2); align-items: center; }
.legend i { display: inline-block; width: 14px; height: 14px; border-radius: 3px; vertical-align: -2px; margin-right: 6px; }

/* теплокарта */
.heat td.cell { text-align: center; font-weight: 600; padding: 0; border: 2px solid var(--card); }
.heat td.cell span { display: block; padding: 10px 6px; border-radius: 4px; }
.heat th { background: none; text-align: center; white-space: normal; font-size: 12.5px; line-height: 1.25; }
.heat th:first-child, .heat td:first-child { text-align: left; }
.heat td { border-bottom: 0; }

/* список «требует внимания» */
.list { display: flex; flex-direction: column; }
.list a, .list .li { display: flex; align-items: center; gap: 12px; padding: 11px 0; border-bottom: 1px solid var(--line-2); text-decoration: none; color: var(--ink); }
.list > :last-child { border-bottom: 0; }
.list .grow { flex: 1; min-width: 0; }
.list .grow b { font-weight: 550; display: block; }
.list .grow span { font-size: 13px; color: var(--muted); }
.list a:hover b { color: var(--teal); }
.chev { color: var(--muted); flex: none; }

/* ---------- вакансия ---------- */
.rubric { display: flex; flex-direction: column; gap: 12px; }
.rub { border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.rub summary { list-style: none; cursor: pointer; display: flex; gap: 14px; align-items: center; padding: 14px 16px; }
.rub summary::-webkit-details-marker { display: none; }
.rub .no { width: 28px; height: 28px; border-radius: 50%; background: var(--teal-5); color: var(--teal); display: grid; place-items: center; font-weight: 700; flex: none; font-size: 13px; }
.rub .t { flex: 1; font-weight: 600; }
.rub .m { font-size: 13px; color: var(--ink-2); }
.rub .plus { color: var(--muted); transition: transform .2s; }
.rub[open] .plus { transform: rotate(45deg); }
.rub-body { padding: 0 16px 16px 58px; display: flex; flex-direction: column; gap: 12px; }
.q { background: #FAF8F4; border-left: 3px solid var(--teal-3); padding: 10px 12px; border-radius: 0 6px 6px 0; }
.scale { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.scale div { border: 1px solid var(--line-2); border-radius: 6px; padding: 10px; font-size: 13.5px; }
.scale b { display: block; color: var(--teal); margin-bottom: 4px; font-size: 13px; }

/* ---------- кандидат ---------- */
.cand-head { display: flex; gap: 18px; align-items: center; flex-wrap: wrap; }
.cand-head .who { flex: 1; min-width: 220px; }
.cand-head .acts { display: flex; gap: 10px; flex-wrap: wrap; }
.summary li { margin-bottom: 14px; }
.summary li:last-child { margin-bottom: 0; }
.summary b { display: block; font-weight: 600; }
.summary q { color: var(--ink-2); }
.tc { font-size: 13px; color: var(--teal); text-decoration: underline; text-underline-offset: 2px; margin-left: 6px; white-space: nowrap; }
.ai-note { display: flex; gap: 8px; align-items: flex-start; font-size: 13px; color: var(--ink-2); background: var(--teal-5); padding: 10px 12px; border-radius: 8px; margin-top: 14px; }
.gap-box { border: 1px solid var(--line); border-radius: 8px; padding: 14px; display: flex; flex-direction: column; gap: 8px; }
.gap-src { display: grid; grid-template-columns: 110px 1fr; gap: 4px 10px; font-size: 14px; }
.gap-src dt { color: var(--muted); }
.gap-src dd { margin: 0; }
.ask { background: var(--ochre-bg); color: #5E3F0C; padding: 10px 12px; border-radius: 6px; font-size: 14px; }
ol.next { margin: 0; padding-left: 20px; }
ol.next li { margin-bottom: 8px; }
.state-banner { background: var(--teal-5); border: 1px solid var(--teal-4); border-radius: var(--radius); padding: 12px 16px; display: flex; gap: 10px; align-items: center; }

/* ---------- команда ---------- */
.matrix td, .matrix th { text-align: center; }
.matrix td:first-child, .matrix th:first-child { text-align: left; }
.matrix tr.gap td { background: var(--ochre-bg); }
.matrix tr.gap td:first-child { box-shadow: inset 3px 0 0 var(--ochre-2); }
.dot { display: inline-block; width: 14px; height: 14px; border-radius: 50%; vertical-align: middle; }
.dot.full { background: var(--teal); }
.dot.ring { border: 2px solid var(--teal); background: var(--card); }
.dot.empty { width: 6px; height: 6px; background: var(--line); }
.cov-gap { color: var(--ochre); font-weight: 650; }
.opts { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)) minmax(240px, .9fr); gap: 16px; align-items: start; }
.opt { display: flex; flex-direction: column; gap: 10px; transition: transform .25s ease; }
.opt .rank { font-size: 12px; font-weight: 650; color: var(--muted); letter-spacing: .02em; }
.opt.lead { border-color: var(--teal-2); box-shadow: inset 0 0 0 1px var(--teal-2); }
.opt.lead .rank { color: var(--teal); }
.opt .closes { background: var(--teal-5); color: var(--teal); font-weight: 600; font-size: 14px; padding: 7px 10px; border-radius: 6px; }
.opt h4 { margin: 0 0 4px; font-size: 13px; font-weight: 650; }
.opt ul { margin: 0; padding-left: 18px; font-size: 13.5px; color: var(--ink-2); }
.opt .sec { border-top: 1px solid var(--line-2); padding-top: 8px; }
.opt .score { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--ink-2); }
.opt .score .bar { flex: 1; height: 6px; background: var(--line-2); border-radius: 3px; overflow: hidden; }
.opt .score .bar i { display: block; height: 100%; background: var(--teal-2); }
.weights label { display: block; font-size: 14px; font-weight: 550; margin-bottom: 2px; }
.weights .w-row { margin-bottom: 14px; }
.weights .w-line { display: flex; align-items: center; gap: 10px; }
.weights output { width: 18px; text-align: right; font-weight: 650; color: var(--teal); }
input[type=range] { flex: 1; accent-color: var(--teal); height: 24px; }
.journal { font-size: 12.5px; color: var(--ink-2); max-height: 150px; overflow: auto; border-top: 1px solid var(--line-2); padding-top: 8px; margin-top: 4px; }
.journal div { padding: 3px 0; }
.style-note { font-size: 13px; color: var(--ochre); background: var(--ochre-bg); padding: 6px 10px; border-radius: 6px; }

/* ---------- благополучие ---------- */
.info { display: flex; gap: 10px; align-items: center; background: var(--teal-5); border: 1px solid var(--teal-4); padding: 12px 16px; border-radius: var(--radius); color: var(--ink-2); font-size: 14px; }
.cbi { display: flex; align-items: center; gap: 10px; min-width: 150px; }
.cbi b { width: 26px; font-weight: 650; }
.cbi .bar { position: relative; flex: 1; height: 8px; background: var(--line-2); border-radius: 0 4px 4px 0; }
.cbi .bar i { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 0 4px 4px 0; background: var(--teal-2); }
.cbi .bar i.over { background: var(--ochre-2); }
.cbi .bar .thr { position: absolute; top: -4px; bottom: -4px; width: 2px; background: var(--ink-2); }
.hidden-row td { color: var(--muted); font-style: italic; }
.causes .c-row { display: grid; grid-template-columns: 170px 1fr 40px; gap: 12px; align-items: center; margin-bottom: 12px; font-size: 14px; }
.causes .c-bar { height: 14px; background: var(--line-2); border-radius: 0 4px 4px 0; position: relative; }
.causes .c-bar i { position: absolute; inset: 0 auto 0 0; background: var(--teal); border-radius: 0 4px 4px 0; }
.act { display: grid; grid-template-columns: 1fr auto; gap: 6px 14px; padding: 12px 0; border-bottom: 1px solid var(--line-2); }
.act:last-child { border-bottom: 0; }
.act .own { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.act .due { font-size: 13px; color: var(--ink-2); grid-column: 2; text-align: right; }

/* ---------- модалка, тост, тултип ---------- */
dialog { border: 0; border-radius: 12px; padding: 0; width: min(520px, calc(100vw - 32px)); color: var(--ink); background: var(--card); box-shadow: 0 20px 60px rgba(20, 40, 36, .22); }
dialog::backdrop { background: rgba(29, 40, 38, .35); }
.dlg { padding: 22px; display: flex; flex-direction: column; gap: 14px; }
.dlg fieldset { border: 0; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.dlg legend { font-weight: 600; margin-bottom: 6px; }
.choice { display: flex; gap: 10px; align-items: flex-start; border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; cursor: pointer; }
.choice:has(input:checked) { border-color: var(--teal); background: var(--teal-5); }
.choice input { accent-color: var(--teal); margin-top: 3px; }
.choice span small { display: block; color: var(--muted); font-size: 13px; }
textarea { width: 100%; min-height: 90px; border: 1px solid var(--line); border-radius: 8px; padding: 10px; resize: vertical; }
.dlg-acts { display: flex; justify-content: flex-end; gap: 10px; flex-wrap: wrap; }
.err { color: var(--ochre); font-size: 13px; }
.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%) translateY(20px); background: var(--ink); color: #fff; padding: 12px 18px; border-radius: 8px; opacity: 0; transition: .25s; z-index: 100; max-width: calc(100vw - 32px); font-size: 14px; pointer-events: none; }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.tip { position: fixed; z-index: 90; pointer-events: none; background: var(--ink); color: #fff; font-size: 13px; padding: 7px 10px; border-radius: 6px; max-width: 260px; opacity: 0; transition: opacity .12s; line-height: 1.35; }
.tip.show { opacity: 1; }
[data-tip] { cursor: default; }

.legal { font-size: 12.5px; color: var(--muted); border-top: 1px solid var(--line); padding-top: 14px; }

/* ---------- адаптив ---------- */
@media (max-width: 1180px) {
  .g-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .opts { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 960px) {
  .g-main, .g-main-r, .g-3, .g-2 { grid-template-columns: minmax(0, 1fr); }
  .me-text { display: none; }
}
@media (max-width: 820px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .side { position: fixed; bottom: 0; top: auto; left: 0; right: 0; height: auto; flex-direction: row; border-right: 0; border-top: 1px solid var(--line); padding: 6px; z-index: 30; background: var(--card); }
  .side .brand, .side-foot { display: none; }
  .nav { display: flex; width: 100%; justify-content: space-between; }
  .nav a { flex-direction: column; gap: 2px; font-size: 10.5px; padding: 6px 2px; flex: 1; text-align: center; min-width: 0; }
  .nav a span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
  .top { padding: 10px 16px; gap: 10px; flex-wrap: wrap; }
  .org { font-size: 13px; padding: 5px 9px; }
  .page { padding: 16px 16px 96px; gap: 16px; }
  h1 { font-size: 22px; }
  .card { padding: 16px; }
  .g-4 { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 12px; }
  .kpi .big { font-size: 30px; }
  .opts { grid-template-columns: minmax(0, 1fr); }
  .f-row { grid-template-columns: 76px 1fr 92px; gap: 8px; }
  .scale { grid-template-columns: minmax(0, 1fr); }
  .rub-body { padding: 0 14px 14px; }
  .causes .c-row { grid-template-columns: 120px 1fr 36px; }
  .gap-src { grid-template-columns: minmax(0, 1fr); }
  .demo-tag { display: none; }
  .ava.lg { width: 48px; height: 48px; font-size: 17px; }
  table.stack thead { display: none; }
  table.stack tr { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 6px 12px; padding: 12px 0; border-bottom: 1px solid var(--line-2); }
  table.stack tr:last-child { border-bottom: 0; }
  table.stack td { padding: 0; border: 0; }
  table.stack td:nth-child(3) { grid-column: 1 / -1; }
  table.cands td:nth-child(2) { grid-column: 1; grid-row: 2; }
  table.cands td:nth-child(3) { grid-column: 1 / -1; grid-row: 3; }
  table.cands td:nth-child(4) { grid-column: 2; grid-row: 1; }
  table.cands td:nth-child(5) { display: none; }
}
@media (max-width: 420px) {
  .g-4 { grid-template-columns: minmax(0, 1fr); }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
