/* =============================================================
   SaaS-ресёрч — замороженная дизайн-система (offline / file://)
   Стиль: product dashboard. Светлая тема по умолчанию,
   тёмная через [data-theme="dark"]. Без внешних шрифтов/CDN.
   ============================================================= */

/* ---------- 1. Токены ---------- */
:root {
  /* Нейтральная серая шкала */
  --gray-0:  #ffffff;
  --gray-25: #fafafb;
  --gray-50: #f5f6f8;
  --gray-100:#eceef2;
  --gray-150:#e2e5ea;
  --gray-200:#d6dae1;
  --gray-300:#c0c6d0;
  --gray-400:#98a0ad;
  --gray-500:#6b7280;
  --gray-600:#4b5563;
  --gray-700:#374151;
  --gray-800:#232a36;
  --gray-900:#161b24;
  --gray-950:#0e121a;

  /* Акцент — индиго / сине-фиолетовый */
  --accent:        #4f46e5;
  --accent-hover:  #4338ca;
  --accent-soft:   #eef0fe;
  --accent-border: #c7cbf7;
  --accent-text:   #4338ca;
  --row-hover:     #e4e7fb;

  /* Семантические поверхности (светлая тема) */
  --bg:            var(--gray-50);
  --bg-elevated:   var(--gray-0);
  --surface:       var(--gray-0);
  --surface-2:     var(--gray-25);
  --surface-3:     var(--gray-100);
  --sidebar-bg:    var(--gray-0);
  --topbar-bg:     rgba(255,255,255,0.92);
  --border:        var(--gray-150);
  --border-strong: var(--gray-200);

  --text:          var(--gray-900);
  --text-muted:    var(--gray-500);
  --text-soft:     var(--gray-600);
  --heading:       var(--gray-900);
  --link:          var(--accent-text);
  --link-hover:    var(--accent-hover);

  /* Бейджи уверенности — fg затемнены под AA 4.5:1 для мелкого текста бейджа */
  --c-fact:        #166534;  --c-fact-bg:        #e7f6ec;  --c-fact-bd:        #b6e3c4;
  --c-corroborated:#1d4ed8;  --c-corroborated-bg:#e6edfd;  --c-corroborated-bd:#bcd0fb;
  --c-single:      #92400e;  --c-single-bg:      #fdf0db;  --c-single-bd:      #f4d9a8;
  --c-estimate:    #4b5563;  --c-estimate-bg:    #eceef2;  --c-estimate-bd:    #d6dae1;

  /* Тематические теги — fg затемнены под AA 4.5:1 для мелкого текста тега */
  --t-money:    #4f46e5;  --t-money-bg:    #eef0fe;  --t-money-bd:    #cdd2fb;
  --t-boundary: #0f766e;  --t-boundary-bg: #def7f3;  --t-boundary-bd: #aee9e0;
  --t-acq:      #7c3aed;  --t-acq-bg:      #f1e9fe;  --t-acq-bd:      #ddc8fb;
  --t-ai:       #a8198a;  --t-ai-bg:       #fbe7f6;  --t-ai-bd:       #f3c2e7;
  --t-risk:     #c81e1e;  --t-risk-bg:     #fdeaea;  --t-risk-bd:     #f6c4c4;

  /* Callouts */
  --info:   var(--accent);     --info-bg:   var(--accent-soft);   --info-bd:   var(--accent-border);
  --warn:   #b45309;           --warn-bg:   #fdf0db;              --warn-bd:   #f4d9a8;
  --danger: #dc2626;           --danger-bg: #fdeaea;              --danger-bd: #f6c4c4;

  /* Тени */
  --shadow-sm: 0 1px 2px rgba(16,22,34,.06);
  --shadow:    0 1px 3px rgba(16,22,34,.08), 0 1px 2px rgba(16,22,34,.04);
  --shadow-md: 0 4px 12px rgba(16,22,34,.10), 0 2px 4px rgba(16,22,34,.05);
  --shadow-lg: 0 12px 32px rgba(16,22,34,.14);
  --ring: 0 0 0 3px rgba(79,70,229,.40);

  /* Типографика */
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
  --fs-base: 16px;
  --lh: 1.65;     /* leading для длинной прозы (.main) */
  --lh-ui: 1.5;   /* leading для плотного UI-каркаса (body) */

  /* Геометрия */
  --radius-sm: 6px;
  --radius:    10px;
  --radius-lg: 14px;
  --sidebar-w: 264px;
  --content-max: 880px;
  --topbar-h: 56px;
  --space: 16px;

  --transition: 160ms cubic-bezier(.4,0,.2,1);
}

/* ---------- 2. Тёмная тема ---------- */
[data-theme="dark"] {
  --accent:        #818cf8;
  --accent-hover:  #a5b0ff;
  --accent-soft:   #1e2235;
  --accent-border: #3a4170;
  --accent-text:   #a5b0ff;
  --row-hover:     #232a44;

  --bg:            var(--gray-950);
  --bg-elevated:   var(--gray-900);
  --surface:       var(--gray-900);
  --surface-2:     #131822;
  --surface-3:     var(--gray-800);
  --sidebar-bg:    #0f141d;
  --topbar-bg:     rgba(15,20,29,0.92);
  --border:        #232a36;
  --border-strong: #2f3744;

  --text:          #e6e9ef;
  --text-muted:    #8b93a3;
  --text-soft:     #aab2c0;
  --heading:       #f2f4f8;
  --link:          var(--accent-text);
  --link-hover:    #c4ccff;

  --c-fact:        #4ade80;  --c-fact-bg:        #102619;  --c-fact-bd:        #1f4d33;
  --c-corroborated:#7aa2f7;  --c-corroborated-bg:#141d33;  --c-corroborated-bd:#283a63;
  --c-single:      #f0b65b;  --c-single-bg:      #2a2010;  --c-single-bd:      #4d3b1a;
  --c-estimate:    #9aa3b2;  --c-estimate-bg:    #1c222d;  --c-estimate-bd:    #313a48;

  --t-money:    #a5b0ff;  --t-money-bg:    #1b2036;  --t-money-bd:    #333b66;
  --t-boundary: #4dd6c4;  --t-boundary-bg: #0e2623;  --t-boundary-bd: #1d4c46;
  --t-acq:      #b794f6;  --t-acq-bg:      #211a36;  --t-acq-bd:      #3d2f63;
  --t-ai:       #ef8fda;  --t-ai-bg:       #2c142680; --t-ai-bd:       #532047;
  --t-risk:     #f87171;  --t-risk-bg:     #2a1414;  --t-risk-bd:     #4d2222;

  --info:   var(--accent);  --info-bg:   #141d33;  --info-bd:   #283a63;
  --warn:   #f0b65b;        --warn-bg:   #2a2010;  --warn-bd:   #4d3b1a;
  --danger: #f87171;        --danger-bg: #2a1414;  --danger-bd: #4d2222;

  --shadow-sm: 0 1px 2px rgba(0,0,0,.35);
  --shadow:    0 1px 3px rgba(0,0,0,.45), 0 1px 2px rgba(0,0,0,.30);
  --shadow-md: 0 4px 14px rgba(0,0,0,.50);
  --shadow-lg: 0 14px 38px rgba(0,0,0,.60);
  --ring: 0 0 0 3px rgba(129,140,248,.45);
}

/* ---------- 3. Reset / база ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
    scroll-behavior: auto !important;
  }
}

body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: var(--fs-base);
  line-height: var(--lh-ui);
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  transition: background var(--transition), color var(--transition);
}

img, svg { max-width: 100%; height: auto; }

a { color: var(--link); text-decoration: none; }
a:hover { color: var(--link-hover); text-decoration: underline; }

code, pre, kbd, samp { font-family: var(--font-mono); }
code {
  font-size: .88em;
  background: var(--surface-3);
  padding: .12em .4em;
  border-radius: 5px;
  border: 1px solid var(--border);
}
pre {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  overflow-x: auto;
  font-size: .85rem;
  line-height: 1.55;
}
pre code { background: none; border: 0; padding: 0; }

/* ---------- 4. Доступность ---------- */
.skip-link {
  position: absolute;
  left: 8px; top: -100px;
  z-index: 200;
  background: var(--accent);
  color: #fff;
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  font-weight: 600;
  box-shadow: var(--shadow-md);
  transition: top var(--transition);
}
.skip-link:focus { top: 8px; text-decoration: none; outline: none; }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}
:focus:not(:focus-visible) { outline: none; }

/* ---------- 5. Layout ---------- */
.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: var(--sidebar-w);
  background: var(--sidebar-bg);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 18px 14px;
  overflow: hidden;
  z-index: 60;
  transition: transform var(--transition);
}

.content {
  margin-left: var(--sidebar-w);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.main {
  width: 100%;
  max-width: var(--content-max);
  margin: 0 auto;
  padding: 32px 32px 64px;
  flex: 1 0 auto;
  line-height: var(--lh);
}

/* ---------- 6. Sidebar / навигация ---------- */
.brand {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 1.02rem;
  color: var(--heading);
  padding: 6px 8px 14px;
  letter-spacing: -.01em;
}
.brand__mark {
  flex: 0 0 auto;
  width: 30px; height: 30px;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--accent), #8b5cf6);
  color: #fff;
  display: grid; place-items: center;
  font-size: .9rem; font-weight: 800;
  box-shadow: var(--shadow-sm);
}
.brand__sub { display: block; font-size: .72rem; font-weight: 500; color: var(--text-muted); }

.nav { display: flex; flex-direction: column; gap: 2px; flex: 1 1 auto; overflow-y: auto; min-height: 0; }
.nav a {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 8px 12px;
  min-height: 38px;
  border-radius: var(--radius-sm);
  color: var(--text-soft);
  font-size: .9rem;
  font-weight: 500;
  text-decoration: none;
  transition: background var(--transition), color var(--transition);
}
.nav a:hover { background: var(--surface-3); color: var(--text); text-decoration: none; }
.nav a.active {
  background: var(--accent-soft);
  color: var(--accent-text);
  font-weight: 600;
}
.nav a .nav__ico { flex: 0 0 auto; width: 18px; text-align: center; opacity: .85; font-size: .95rem; }
.nav a .nav__tag {
  flex: 0 0 auto;
  font-family: var(--font-mono);
  font-size: .68rem;
  font-weight: 600;
  color: var(--text-muted);
  background: var(--surface-3);
  border-radius: 4px;
  padding: 1px 5px;
}
.nav a.active .nav__tag { color: var(--accent-text); background: transparent; }

.nav__sep {
  height: 1px;
  background: var(--border);
  margin: 12px 10px;
  border: 0;
}
.nav__label {
  font-size: .68rem;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--text-muted);
  padding: 4px 12px;
  margin-top: 4px;
}

.sidebar__footer { flex: 0 0 auto; margin-top: auto; padding-top: 14px; border-top: 1px solid var(--border); }

.theme-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text-soft);
  font: inherit;
  font-size: .85rem;
  font-weight: 500;
  cursor: pointer;
  transition: background var(--transition), border-color var(--transition), color var(--transition);
}
.theme-toggle:hover { background: var(--surface-3); color: var(--text); border-color: var(--gray-300); }
.theme-toggle .theme-toggle__icon { font-size: 1rem; line-height: 1; }
.theme-toggle .theme-toggle__text { font-weight: 500; letter-spacing: .01em; }
.theme-toggle .theme-toggle__moon { display: none; }
[data-theme="dark"] .theme-toggle .theme-toggle__sun { display: none; }
[data-theme="dark"] .theme-toggle .theme-toggle__moon { display: inline; }

/* Гамбургер — скрыт на десктопе */
.nav-toggle {
  display: none;
  position: fixed;
  top: calc((var(--topbar-h) - 44px) / 2); left: 12px;
  z-index: 90;
  width: 44px; height: 44px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-sm);
}
.nav-toggle svg { width: 20px; height: 20px; }
.nav-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(16,22,34,.45);
  z-index: 55;
  opacity: 0;
  transition: opacity var(--transition);
}

/* ---------- 7. Topbar / хлебные крошки ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  min-height: var(--topbar-h);
  display: flex;
  align-items: center;
  padding: 0 32px;
  background: var(--topbar-bg);
  backdrop-filter: saturate(180%) blur(10px);
  -webkit-backdrop-filter: saturate(180%) blur(10px);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}
.breadcrumb {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 2px;
  width: 100%;
  max-width: var(--content-max);
  margin: 0 auto;
  padding: 0;
  font-size: .85rem;
  color: var(--text-muted);
}
.breadcrumb li { display: flex; align-items: center; }
.breadcrumb li + li::before {
  content: "/";
  margin: 0 8px;
  color: var(--gray-400);
}
.breadcrumb a { color: var(--text-muted); }
.breadcrumb a:hover { color: var(--text); }
.breadcrumb li[aria-current="page"],
.breadcrumb li:last-child { color: var(--text); font-weight: 600; }

/* ---------- 8. Footer ---------- */
.footer {
  flex-shrink: 0;
  max-width: var(--content-max);
  width: 100%;
  margin: 0 auto;
  padding: 24px 32px 40px;
  border-top: 1px solid var(--border);
  color: var(--text-muted);
  font-size: .82rem;
  line-height: 1.7;
}
.footer a { color: var(--text-soft); }
.footer__row { display: flex; flex-wrap: wrap; gap: 8px 18px; align-items: center; }
.footer__dot { color: var(--gray-400); }

/* ---------- 9. Типографика контента ---------- */
.main h1, .main h2, .main h3, .main h4 {
  color: var(--heading);
  line-height: 1.25;
  letter-spacing: -.012em;
  scroll-margin-top: calc(var(--topbar-h) + 16px);
}
.main h1 { font-size: 2rem; font-weight: 800; margin: 0 0 12px; }
.main h2 {
  font-size: 1.4rem; font-weight: 700;
  margin: 44px 0 14px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}
.main h3 { font-size: 1.12rem; font-weight: 700; margin: 30px 0 10px; }
.main h4 { font-size: .98rem; font-weight: 700; margin: 22px 0 8px; }
.main p { margin: 0 0 14px; }
.main ul, .main ol { margin: 0 0 16px; padding-left: 24px; }
.main li { margin: 5px 0; }
.main li::marker { color: var(--text-muted); }
.main strong { color: var(--heading); font-weight: 600; }
.main hr { border: 0; border-top: 1px solid var(--border); margin: 32px 0; }
.main blockquote {
  margin: 16px 0;
  padding: 4px 16px;
  border-left: 3px solid var(--border-strong);
  color: var(--text-soft);
}

/* Якорная # ссылка к заголовкам */
.heading-anchor {
  margin-left: 8px;
  font-weight: 400;
  color: var(--text-muted);
  opacity: 0;
  text-decoration: none;
  transition: opacity var(--transition);
}
h2:hover .heading-anchor, h3:hover .heading-anchor,
.heading-anchor:focus-visible { opacity: 1; }
.heading-anchor:hover { color: var(--accent-text); text-decoration: none; }

.lede {
  font-size: 1.12rem;
  line-height: 1.6;
  color: var(--text-soft);
  margin: 0 0 24px;
  max-width: 64ch;
}

/* ---------- 10. TL;DR ---------- */
.tldr {
  position: relative;
  background: var(--accent-soft);
  border: 1px solid var(--accent-border);
  border-left: 4px solid var(--accent);
  border-radius: var(--radius);
  padding: 16px 18px 16px 20px;
  margin: 0 0 28px;
}
.tldr__label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: .72rem;
  font-weight: 700;
  letter-spacing: .07em;
  text-transform: uppercase;
  color: var(--accent-text);
  margin-bottom: 6px;
}
.tldr p:last-child, .tldr ul:last-child, .tldr li:last-child { margin-bottom: 0; }
.tldr ul { padding-left: 20px; }

/* ---------- 11. Карточки ---------- */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(248px, 1fr));
  gap: 16px;
  margin: 0 0 24px;
}
.card {
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow-sm);
  transition: transform var(--transition), box-shadow var(--transition), border-color var(--transition);
}
a.card, .card--link { text-decoration: none; color: inherit; cursor: pointer; }
a.card:hover, .card--link:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  border-color: var(--accent-border);
  text-decoration: none;
}
.card__title {
  font-size: 1.02rem;
  font-weight: 600;
  color: var(--heading);
  margin: 0 0 4px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.card__title .nav__ico, .card__icon { color: var(--accent-text); }
.card__meta {
  font-family: var(--font-mono);
  font-size: .72rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .04em;
  margin: 0 0 8px;
}
.card__desc { font-size: .9rem; color: var(--text-soft); margin: 0; line-height: 1.55; }
.card__desc:not(:last-child) { margin-bottom: 10px; }

/* ---------- 12. Accordion (нативный disclosure) ---------- */
.accordion {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  margin: 0 0 12px;
  overflow: hidden;
}
.accordion[open] { box-shadow: var(--shadow-sm); }
.accordion__summary {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 18px;
  font-weight: 600;
  color: var(--heading);
  cursor: pointer;
  list-style: none;
  user-select: none;
  transition: background var(--transition);
}
.accordion__summary:hover { background: var(--surface-2); }
.accordion__summary::-webkit-details-marker { display: none; }
.accordion__summary::before {
  content: "";
  flex: 0 0 auto;
  width: 8px; height: 8px;
  border-right: 2px solid var(--text-muted);
  border-bottom: 2px solid var(--text-muted);
  transform: rotate(-45deg);
  transition: transform var(--transition);
  margin-right: 2px;
}
.accordion[open] > .accordion__summary::before { transform: rotate(45deg); }
.accordion__summary .accordion__meta { margin-left: auto; font-weight: 500; }
.accordion__body { padding: 2px 18px 18px; }
.accordion__body > :first-child { margin-top: 0; }
.accordion__body > :last-child { margin-bottom: 0; }

@media (prefers-reduced-motion: no-preference) {
  .accordion[open] > .accordion__body {
    animation: accordion-reveal 220ms cubic-bezier(.4,0,.2,1);
  }
}
@keyframes accordion-reveal {
  from { opacity: 0; transform: translateY(-4px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ---------- 13. Таблицы ---------- */
.table-wrap {
  overflow: auto;
  max-height: 70vh;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin: 0 0 24px;
  -webkit-overflow-scrolling: touch;
}
table.data {
  width: 100%;
  border-collapse: collapse;
  font-size: .88rem;
  line-height: 1.45;
  min-width: 520px;
}
table.data caption {
  caption-side: top;
  text-align: left;
  font-size: .8rem;
  color: var(--text-muted);
  padding: 10px 14px;
}
table.data thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--surface-3);
  color: var(--heading);
  font-weight: 600;
  text-align: left;
  padding: 11px 14px;
  border-bottom: 1px solid var(--border-strong);
  white-space: nowrap;
}
table.data tbody td {
  padding: 11px 14px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
  color: var(--text-soft);
}
table.data tbody tr:nth-child(even) { background: var(--surface-2); }
table.data tbody tr:hover { background: var(--row-hover); }
table.data tbody tr:last-child td { border-bottom: 0; }
table.data td strong, table.data th { color: var(--heading); }

/* ---------- 14. Бейджи уверенности ---------- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: .7rem;
  font-weight: 600;
  line-height: 1.4;
  padding: 2px 8px;
  border-radius: 999px;
  border: 1px solid transparent;
  white-space: nowrap;
  vertical-align: middle;
}
.badge::before {
  content: "";
  width: 6px; height: 6px;
  border-radius: 50%;
  background: currentColor;
}
.badge--fact         { color: var(--c-fact);         background: var(--c-fact-bg);         border-color: var(--c-fact-bd); }
.badge--corroborated { color: var(--c-corroborated); background: var(--c-corroborated-bg); border-color: var(--c-corroborated-bd); }
.badge--single       { color: var(--c-single);       background: var(--c-single-bg);       border-color: var(--c-single-bd); }
.badge--estimate     { color: var(--c-estimate);     background: var(--c-estimate-bg);     border-color: var(--c-estimate-bd); }

/* ---------- 15. Теги тем ---------- */
.tag {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: .72rem;
  font-weight: 600;
  line-height: 1.4;
  padding: 2px 9px;
  border-radius: 6px;
  border: 1px solid transparent;
  white-space: nowrap;
  vertical-align: middle;
}
.tag--money    { color: var(--t-money);    background: var(--t-money-bg);    border-color: var(--t-money-bd); }
.tag--boundary { color: var(--t-boundary); background: var(--t-boundary-bg); border-color: var(--t-boundary-bd); }
.tag--acq      { color: var(--t-acq);      background: var(--t-acq-bg);      border-color: var(--t-acq-bd); }
.tag--ai       { color: var(--t-ai);       background: var(--t-ai-bg);       border-color: var(--t-ai-bd); }
.tag--risk     { color: var(--t-risk);     background: var(--t-risk-bg);     border-color: var(--t-risk-bd); }

/* ---------- 16. Инсайт ---------- */
.insight {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  margin: 0 0 14px;
  box-shadow: var(--shadow-sm);
  transition: border-color var(--transition), box-shadow var(--transition);
}
.insight:hover { border-color: var(--border-strong); box-shadow: var(--shadow); }
.insight__head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}
.insight__id {
  font-family: var(--font-mono);
  font-size: .76rem;
  font-weight: 700;
  color: var(--accent-text);
  background: var(--accent-soft);
  border: 1px solid var(--accent-border);
  border-radius: 6px;
  padding: 1px 7px;
  letter-spacing: .02em;
}
.insight__meta { margin-left: auto; display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.insight__text { font-size: .98rem; color: var(--text); margin: 0 0 8px; line-height: 1.55; }
.insight__text strong { color: var(--heading); }
.insight__why {
  font-size: .86rem;
  color: var(--text-soft);
  margin: 0 0 8px;
  padding-left: 12px;
  border-left: 2px solid var(--border-strong);
}
.insight__why::before {
  content: "Почему важно: ";
  font-weight: 600;
  color: var(--text-muted);
}
.insight__src {
  font-size: .78rem;
  color: var(--text-muted);
  margin: 0;
}
.insight__src::before { content: "Источник: "; font-weight: 600; }
.insight__tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }

/* ---------- 17. Риски / callout ---------- */
.risk {
  display: flex;
  gap: 10px;
  padding: 12px 14px;
  background: var(--warn-bg);
  border: 1px solid var(--warn-bd);
  border-radius: var(--radius);
  margin: 0 0 10px;
  font-size: .9rem;
  color: var(--text);
}
.risk::before { content: "⚠️"; flex: 0 0 auto; font-size: 1rem; line-height: 1.4; }
.risk strong { color: var(--heading); }

.callout {
  display: flex;
  gap: 12px;
  padding: 14px 16px;
  border: 1px solid var(--border-strong);
  border-left-width: 4px;
  border-radius: var(--radius);
  margin: 0 0 18px;
  background: var(--surface-2);
  font-size: .92rem;
  line-height: 1.55;
}
.callout__icon { flex: 0 0 auto; font-size: 1.1rem; line-height: 1.5; }
.callout__body > :first-child { margin-top: 0; }
.callout__body > :last-child { margin-bottom: 0; }
.callout__title { font-weight: 600; color: var(--heading); display: block; margin-bottom: 2px; }
.callout--info   { background: var(--info-bg);   border-color: var(--info-bd);   border-left-color: var(--info); }
.callout--warn   { background: var(--warn-bg);   border-color: var(--warn-bd);   border-left-color: var(--warn); }
.callout--danger { background: var(--danger-bg); border-color: var(--danger-bd); border-left-color: var(--danger); }
.callout--info .callout__icon   { color: var(--info); }
.callout--warn .callout__icon   { color: var(--warn); }
.callout--danger .callout__icon { color: var(--danger); }

/* ---------- 18. Глоссарий-термин + тултип ---------- */
.gloss {
  border-bottom: 1.5px dotted var(--accent);
  cursor: help;
  color: inherit;
  text-decoration: none;
}
.gloss:hover, .gloss:focus-visible { color: var(--accent-text); }

.tooltip {
  position: fixed;
  z-index: 150;
  max-width: 300px;
  background: var(--gray-900);
  color: #fff;
  font-size: .82rem;
  line-height: 1.5;
  font-weight: 400;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg);
  pointer-events: none;
  opacity: 0;
  transform: translateY(4px);
  transition: opacity var(--transition), transform var(--transition);
}
[data-theme="dark"] .tooltip { background: #2a3340; border: 1px solid var(--border-strong); }
.tooltip.is-visible { opacity: 1; transform: translateY(0); pointer-events: auto; }
.tooltip__term { display: block; font-weight: 700; margin-bottom: 2px; color: #fff; }
[data-theme="dark"] .tooltip__term { color: var(--accent-text); }

/* ---------- 19. Источники ---------- */
.source-list { list-style: none; margin: 0 0 20px; padding: 0; }
.source-list li {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 10px;
  align-items: baseline;
  padding: 9px 0;
  border-bottom: 1px solid var(--border);
  font-size: .86rem;
}
.source-list li:last-child { border-bottom: 0; }
.source-list .source-list__title { font-weight: 600; color: var(--text); }
.source-list .source-list__date {
  font-family: var(--font-mono);
  font-size: .74rem;
  color: var(--text-muted);
  white-space: nowrap;
}
.source-list .source-list__url { color: var(--link); font-size: .82rem; word-break: break-all; }

/* ---------- 20. Chip / kbd ---------- */
.chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: .78rem;
  font-weight: 500;
  padding: 3px 10px;
  border-radius: 999px;
  background: var(--surface-3);
  border: 1px solid var(--border);
  color: var(--text-soft);
}
.kbd {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: .76rem;
  line-height: 1;
  padding: 3px 6px;
  border: 1px solid var(--border-strong);
  border-bottom-width: 2px;
  border-radius: 5px;
  background: var(--surface);
  color: var(--text-soft);
  box-shadow: var(--shadow-sm);
}

/* ---------- 21. Фильтры / поиск (insights) ---------- */
.filters {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin: 0 0 20px;
}
.filters__group { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.filters__label {
  font-size: .74rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--text-muted);
  margin-right: 2px;
}
.filter-btn {
  font: inherit;
  font-size: .82rem;
  font-weight: 500;
  padding: 5px 12px;
  min-height: 32px;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text-soft);
  cursor: pointer;
  transition: background var(--transition), border-color var(--transition), color var(--transition);
}
.filter-btn:hover { background: var(--surface-3); color: var(--text); }
@media (pointer: coarse) {
  .filter-btn { min-height: 40px; padding: 7px 14px; }
}
.filter-btn.is-active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
[data-theme="dark"] .filter-btn.is-active {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent-text);
}

.search {
  position: relative;
  flex: 1 1 220px;
  min-width: 180px;
}
.search input {
  width: 100%;
  font: inherit;
  font-size: .9rem;
  padding: 9px 12px 9px 34px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  transition: border-color var(--transition), box-shadow var(--transition);
}
.search input::placeholder { color: var(--text-muted); }
.search input:focus-visible { outline: none; border-color: var(--accent); box-shadow: var(--ring); }
.search::before {
  content: "⌕";
  position: absolute;
  left: 11px; top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  font-size: 1.1rem;
  pointer-events: none;
}
.filter-count { font-size: .82rem; color: var(--text-muted); margin: 0 0 16px; }
.filter-count strong { color: var(--text); }
.filter-empty {
  display: none;
  padding: 28px;
  text-align: center;
  color: var(--text-muted);
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius);
}
.filter-empty.is-visible { display: block; }

/* ---------- 22. TOC / back-to-top ---------- */
.toc {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 18px;
  margin: 0 0 28px;
  font-size: .88rem;
}
.toc__title {
  font-size: .72rem;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin: 0 0 8px;
}
.toc ul { list-style: none; margin: 0; padding: 0; }
.toc li { margin: 3px 0; }
.toc li.toc--h3 { padding-left: 16px; }
.toc a { color: var(--text-soft); }
.toc a:hover, .toc a.is-active { color: var(--accent-text); }
.toc a.is-active { font-weight: 600; }

.backtotop {
  position: fixed;
  right: 22px; bottom: 22px;
  z-index: 50;
  width: 44px; height: 44px;
  border-radius: 50%;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  display: grid;
  place-items: center;
  font-size: 1.1rem;
  box-shadow: var(--shadow-md);
  opacity: 0;
  visibility: hidden;
  transform: translateY(8px);
  transition: opacity var(--transition), transform var(--transition), visibility var(--transition);
}
.backtotop.is-visible { opacity: 1; visibility: visible; transform: translateY(0); }
.backtotop:hover { background: var(--surface-3); color: var(--accent-text); }

/* ---------- 23. Утилиты ---------- */
.muted { color: var(--text-muted); }
.small { font-size: .82rem; }
.stack > * + * { margin-top: 16px; }
.stack--sm > * + * { margin-top: 8px; }
.stack--lg > * + * { margin-top: 28px; }
.row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}
.row--between { justify-content: space-between; }
.divider { height: 1px; background: var(--border); border: 0; margin: 28px 0; }
.text-center { text-align: center; }
.nowrap { white-space: nowrap; }
.mono { font-family: var(--font-mono); }

/* ---------- 24. Адаптив ---------- */
@media (max-width: 900px) {
  .nav-toggle { display: inline-flex; }
  .sidebar {
    transform: translateX(-100%);
    box-shadow: var(--shadow-lg);
    width: min(82vw, 300px);
  }
  body.nav-open .sidebar { transform: translateX(0); }
  body.nav-open .nav-overlay { display: block; opacity: 1; }
  .content { margin-left: 0; }
  .topbar { padding-left: 64px; }
  .main { padding: 24px 20px 56px; }
  .footer { padding: 22px 20px 36px; }
}

@media (max-width: 560px) {
  :root { --fs-base: 15px; }
  .main h1 { font-size: 1.65rem; }
  .main h2 { font-size: 1.25rem; }
  .main { padding: 20px 16px 48px; }
  .card-grid { grid-template-columns: 1fr; }
  .insight__head { gap: 6px; }
  .insight__id { align-self: flex-start; }
  .insight__meta { margin-left: 0; margin-top: 2px; width: 100%; }
  .backtotop { right: 14px; bottom: 14px; }
}

/* ---------- 25. Печать ---------- */
@media print {
  .sidebar, .nav-toggle, .nav-overlay, .backtotop, .theme-toggle, .topbar { display: none !important; }
  .content { margin-left: 0; }
  .main { max-width: none; padding: 0; }
  .accordion { border: 0; }
  .accordion__body { display: block !important; }
  a { color: inherit; text-decoration: underline; }
  .docnav { display: none !important; }
}

/* ---------- 26. Навигация по соседним документам (prev/next) ---------- */
.docnav { display: flex; gap: 14px; margin-top: 40px; padding-top: 24px; border-top: 1px solid var(--border); }
.docnav .card { flex: 1 1 0; min-width: 0; margin: 0; display: flex; flex-direction: column; gap: 4px; }
.docnav__next { text-align: right; align-items: flex-end; }
@media (max-width: 560px) { .docnav { flex-direction: column; } .docnav__next { text-align: left; align-items: stretch; } }
