*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
a { text-decoration: none; }
ul { list-style: none; }

:root {
  --bg:          #F4F5F7;
  --surface:     #FFFFFF;
  --surface-2:   #F4F5F7;
  --surface-3:   #EBECF0;
  --border:      rgba(9,30,66,.12);
  --border-2:    rgba(9,30,66,.20);
  --text:        #091e42;
  --text-2:      #344563;
  --text-3:      #7a869a;
  --accent:      #7c6af7;
  --accent-dark: #1a1630;
  --accent-bg:   rgba(124,106,247,.08);
  --accent-ring: rgba(124,106,247,.22);
  --green:       #36B37E;
  --green-bg:    rgba(54,179,126,.1);
  --red:         #DE350B;
  --red-bg:      rgba(222,53,11,.07);
  --radius:      6px;
  --radius-sm:   4px;

  /* Header gradient — dark navy with purple tint */
  --header-bg:   #1a1d2e;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, 'system-ui', 'Segoe UI', Roboto, 'Noto Sans', sans-serif;
  font-size: 17px;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
}

/* ─── Header ─────────────────────────────────────────── */
.header {
  position: fixed; top: 0; left: 0; right: 0; height: 56px;
  background: var(--header-bg);
  border-bottom: 1px solid rgba(255,255,255,.08);
  display: flex; align-items: center; gap: 20px;
  padding: 0 28px; z-index: 100;
}
.logo { font-size: 15px; font-weight: 600; letter-spacing: -.2px; color: #fff; white-space: nowrap; }
.logo em { color: var(--accent); font-style: normal; }

.h-search { flex: 1; max-width: 420px; position: relative; }
.h-search input {
  width: 100%; background: rgba(255,255,255,.1); border: 1px solid rgba(255,255,255,.15);
  border-radius: 20px; padding: 7px 16px 7px 36px;
  color: #fff; font-family: inherit; font-size: 13px; outline: none; transition: all .2s;
}
.h-search input:focus { background: rgba(255,255,255,.18); border-color: rgba(255,255,255,.3); }
.h-search input::placeholder { color: rgba(255,255,255,.5); }
.h-search .ico { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: rgba(255,255,255,.5); }

.h-nav { display: flex; align-items: center; gap: 4px; margin-left: auto; }
.h-nav a { font-size: 13px; color: rgba(255,255,255,.75); padding: 6px 12px; border-radius: var(--radius-sm); transition: all .15s; }
.h-nav a:hover { color: #fff; background: rgba(255,255,255,.1); }
.h-nav .btn-accent { color: #fff; background: var(--accent); border: none; }
.h-nav .btn-accent:hover { background: #9181f9; }

.h-staff { display: flex; align-items: center; gap: 8px; font-size: 12px; color: rgba(255,255,255,.6); }
.dot-live { width: 7px; height: 7px; border-radius: 50%; background: var(--green); box-shadow: 0 0 6px var(--green); }

/* ─── Page wrapper ───────────────────────────────────── */
.page-wrap { padding-top: 56px; }

/* ─── Hero ───────────────────────────────────────────── */
.hero {
  background: linear-gradient(135deg, #1a1d2e 0%, #2d2547 50%, #1a1d2e 100%);
  padding: 64px 28px 72px; text-align: center; position: relative;
}
.hero::before {
  content: ''; position: absolute; inset: 0;
  background: radial-gradient(ellipse 80% 60% at 50% 0%, rgba(124,106,247,.25) 0%, transparent 70%);
}
.hero > * { position: relative; }
.hero h1 { font-size: 36px; font-weight: 600; letter-spacing: -.5px; line-height: 1.2; margin-bottom: 10px; color: #fff; }
.hero h1 em { color: #a899f8; font-style: normal; }
.hero p { color: rgba(255,255,255,.65); font-size: 16px; margin-bottom: 36px; }

.hero-search { position: relative; max-width: 560px; margin: 0 auto; }
.hero-search input {
  width: 100%; background: #fff; border: none;
  border-radius: 32px; padding: 16px 52px 16px 52px;
  color: var(--text); font-family: inherit; font-size: 16px; outline: none;
  box-shadow: 0 4px 24px rgba(0,0,0,.25); transition: box-shadow .2s;
}
.hero-search input:focus { box-shadow: 0 4px 32px rgba(124,106,247,.35); }
.hero-search input::placeholder { color: var(--text-3); }
.hero-search .ico { position: absolute; left: 20px; top: 50%; transform: translateY(-50%); color: var(--text-3); }
.kbd {
  position: absolute; right: 18px; top: 50%; transform: translateY(-50%);
  background: var(--surface-3); border: 1px solid var(--border-2);
  border-radius: 4px; padding: 2px 8px; font-size: 11px; color: var(--text-3);
}

/* ─── Search dropdown ────────────────────────────────── */
.search-results {
  position: absolute; top: calc(100% + 6px); left: 0; right: 0;
  background: var(--surface); border: 1px solid var(--border-2); border-radius: var(--radius);
  box-shadow: 0 8px 32px rgba(9,30,66,.15); z-index: 200; display: none;
  text-align: left; max-height: 420px; overflow-y: auto;
}
.search-results.show { display: block; }
.sr-item { display: block; padding: 12px 16px; border-bottom: 1px solid var(--border); transition: background .12s; }
.sr-item:last-child { border-bottom: none; }
.sr-item:hover { background: var(--surface-2); }
.sr-title { font-size: 15px; color: var(--text); margin-bottom: 3px; }
.sr-snippet { font-size: 13px; color: var(--text-3); line-height: 1.4; }
.sr-access { display: inline-block; font-size: 10px; padding: 1px 6px; border-radius: 999px; margin-left: 6px; }
.sr-access.client { background: var(--accent-bg); color: var(--accent); }
.sr-access.staff  { background: rgba(99,102,241,.1); color: #6d63e8; }
.sr-empty { padding: 16px; text-align: center; font-size: 13px; color: var(--text-3); }

/* ─── Content container ──────────────────────────────── */
.content { max-width: 1100px; margin: 0 auto; padding: 0 28px 120px; }
.label { font-size: 11px; font-weight: 600; letter-spacing: 1.2px; text-transform: uppercase; color: var(--text-3); margin-bottom: 16px; }

/* ─── Category grid ──────────────────────────────────── */
.cats {
  display: grid; grid-template-columns: repeat(3, 1fr);
  gap: 12px; margin-bottom: 48px;
}
.cat {
  background: var(--surface); padding: 20px 20px 18px;
  border-radius: var(--radius); transition: box-shadow .15s, transform .15s;
  display: block; box-shadow: 0 1px 2px rgba(9,30,66,.08);
}
.cat:hover { box-shadow: 0 4px 16px rgba(9,30,66,.12); transform: translateY(-1px); }
.cat-icon { width: 32px; height: 32px; border-radius: var(--radius-sm); background: var(--accent-bg); display: flex; align-items: center; justify-content: center; font-size: 14px; margin-bottom: 10px; }
.cat-name { font-size: 14px; font-weight: 600; color: var(--text); margin-bottom: 4px; }
.cat-count { font-size: 12px; color: var(--text-3); }

/* ─── Article lists ──────────────────────────────────── */
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 40px; }
.art-list li { border-bottom: 1px solid var(--border); }
.art-list li:last-child { border-bottom: none; }
.art-list a { display: flex; align-items: center; gap: 10px; padding: 10px 0; color: var(--text); font-size: 14px; transition: color .15s; }
.art-list a:hover { color: var(--accent); }
.art-list a:hover .arr { transform: translateX(3px); color: var(--accent); }
.art-title { flex: 1; }
.art-meta { font-size: 11px; color: var(--text-3); white-space: nowrap; }
.arr { color: var(--text-3); transition: all .15s; }

/* ─── Article layout ─────────────────────────────────── */
.art-layout { max-width: 1440px; margin: 0 auto; padding: 40px 40px 100px; display: grid; grid-template-columns: 280px 1fr 260px; gap: 40px; }
/* №2 (карточка «правки 5»): нет TOC/похожих — правая колонка не рендерится (см. шаблоны),
   схлопываем сетку до 2 колонок, иначе контент остаётся зауженным под пустое место. */
.art-layout.no-rail { grid-template-columns: 280px 1fr; }

.sidebar-left {
  position: sticky; top: 76px;
  max-height: calc(100vh - 96px);
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--border-2) transparent;
}
.sidebar-section { margin-bottom: 24px; }
.sidebar-label { font-size: 11px; font-weight: 600; letter-spacing: 1px; text-transform: uppercase; color: var(--text-3); margin-bottom: 10px; }
.sidebar-nav a { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text-2); padding: 6px 8px; border-radius: var(--radius-sm); margin-bottom: 1px; transition: all .15s; }
.sidebar-nav a:hover { color: var(--text); background: var(--surface-3); }
.sidebar-nav a.active { color: var(--accent); background: var(--accent-bg); font-weight: 500; }
.nav-dot { width: 4px; height: 4px; border-radius: 50%; background: currentColor; opacity: .4; flex-shrink: 0; }

.breadcrumb { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--text-3); margin-bottom: 24px; flex-wrap: wrap; }
.breadcrumb a { color: var(--text-3); transition: color .15s; }
.breadcrumb a:hover { color: var(--accent); }
.breadcrumb span { color: var(--text-3); }

.article-head { margin-bottom: 32px; }
.article-head h1 { font-size: 36px; font-weight: 600; letter-spacing: -.5px; line-height: 1.25; margin-bottom: 14px; color: var(--text); }
.article-meta-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

.badge { display: inline-block; font-size: 11px; font-weight: 500; padding: 3px 8px; border-radius: 3px; }
.badge-client { background: var(--accent-bg); color: var(--accent); }
.badge-staff  { background: rgba(9,30,66,.06); color: var(--text-2); }
.badge-green  { background: var(--green-bg); color: var(--green); }
.article-date { font-size: 12px; color: var(--text-3); }

.article-body { color: var(--text); font-size: 14px; line-height: 1.9; }
/* №4/№13 (баг #799999, правки 3): защита от инлайн-стилей, оставшихся в старых
   статьях (вставка из Word/Google Docs до фикса onPaste) — фон/шрифт/интервал
   не должны перебивать оформление сайта. Цвет текста намеренно не трогаем —
   его осознанно ставит редактор через свою кнопку.
   №? (баг #799999, правки 6): фон ИСКЛЮЧАЕМ у инфоблоков (data-callout/.callout) —
   у них фон инлайновый и осознанный (SunEditor кладёt его так из-за своего whitelist,
   см. комментарий ниже у V4-блока), сбрасывать его тем же правилом, что чистит
   грязные Word/Docs-вставки, было излишне — гасило и намеренный цвет колбаута. */
.article-body [style] { font-family: inherit !important; line-height: inherit !important; }
.article-body [style]:not([data-callout]):not(.callout) { background: transparent !important; }
.article-body h2 { font-size: 24px; font-weight: 600; letter-spacing: -.3px; margin: 40px 0 14px; padding-top: 36px; border-top: 1px solid var(--border); color: var(--text); scroll-margin-top: 76px; }
.article-body h2:first-child { margin-top: 0; padding-top: 0; border-top: none; }
.article-body h3 { font-size: 20px; font-weight: 600; margin: 28px 0 10px; color: var(--text); }
.article-body p { margin-bottom: 16px; color: var(--text); }
.article-body ul { padding-left: 22px; list-style: disc; margin-bottom: 16px; }
.article-body ol { padding-left: 22px; margin-bottom: 16px; }
.article-body ul li, .article-body ol li { margin-bottom: 6px; color: var(--text); }
.article-body strong { color: var(--text); font-weight: 600; }
.article-body a { color: var(--accent); }
.article-body a:hover { text-decoration: underline; }
.article-body code { font-family: 'Menlo', 'Consolas', monospace; font-size: 13px; background: var(--surface-3); border-radius: var(--radius-sm); padding: 2px 6px; color: var(--text); }
.article-body pre { background: var(--surface-3); border-radius: var(--radius); padding: 16px; overflow-x: auto; margin-bottom: 16px; }
.article-body pre code { background: none; padding: 0; font-size: 13px; }
.callout { display: flex !important; flex-direction: row !important; align-items: flex-start; gap: 13px; border-radius: var(--radius-sm); padding: 14px 18px; margin: 20px 0; font-size: 14px; line-height: 1.65; color: var(--text); }
.callout-icon { font-size: 18px; line-height: 1.55; flex-shrink: 0; }
.callout-body { flex: 1; min-width: 0; }
.callout-body > p:last-child { margin-bottom: 0; }
.callout-note    { background: rgba(139,92,246,.16);  border-left: 3px solid #8b5cf6; }
.callout-info    { background: rgba(59,130,246,.14);  border-left: 3px solid #3b82f6; }
.callout-success { background: rgba(34,197,94,.14);   border-left: 3px solid #22c55e; }
.callout-warning { background: rgba(245,158,11,.16);  border-left: 3px solid #f59e0b; }
.callout-error   { background: rgba(239,68,68,.15);   border-left: 3px solid #ef4444; }
.callout-caution { background: rgba(249,115,22,.15);  border-left: 3px solid #f97316; }

/* Аккордеон */
.kb-details {
  border: 1px solid var(--border-2); border-radius: var(--radius-sm);
  margin: 16px 0; overflow: hidden;
}
.kb-details-summary {
  padding: 12px 16px; cursor: pointer; user-select: none;
  font-weight: 500; font-size: 14px; color: var(--text);
  list-style: none; display: flex; align-items: center; gap: 8px;
  background: var(--surface-2); transition: background .15s;
}
.kb-details-summary::-webkit-details-marker { display: none; }
.kb-details-summary::before {
  content: '›'; font-size: 16px; color: var(--text-3);
  transition: transform .2s; flex-shrink: 0;
}
.kb-details[open] > .kb-details-summary::before { transform: rotate(90deg); }
.kb-details-summary:hover { background: var(--surface-3); }
.kb-details-body { padding: 14px 16px; font-size: 14px; line-height: 1.65; color: var(--text-2); }
.kb-details-body > p:last-child { margin-bottom: 0; }
.kb-details-body > p:first-child { margin-top: 0; }

/* Drag and Drop */
[data-doc-id] { cursor: grab; }
[data-doc-id]:active { cursor: grabbing; }
.dnd-ghost  { opacity: .3 !important; }
.dnd-chosen { background: var(--surface-3) !important; outline: 1px dashed var(--border-2); }
.dnd-drag   { box-shadow: 0 6px 20px rgba(0,0,0,.22); opacity: .95; border-radius: var(--radius-sm); }
.tree-items[data-cat-id] { min-height: 6px; border-radius: 4px; }
.tn-section-body[data-cat-id] { min-height: 4px; }
/* Подсветка «положить ВНУТРЬ этого раздела» — жест вложения при перетаскивании
   (баг #799999, правки 2, п.1): курсор на середине заголовка раздела. */
.dnd-nest-target {
  background: var(--accent-bg) !important;
  box-shadow: inset 0 0 0 2px var(--accent);
  border-radius: var(--radius-sm);
}

/* Images */
.article-body img { max-width: 100%; height: auto; border-radius: var(--radius); border: 1px solid var(--border); margin: 16px 0; display: block; box-shadow: 0 2px 8px rgba(9,30,66,.08); cursor: zoom-in; }
/* Картинка внутри ссылки автора — курсор обычный, клик уходит по ссылке (initLightbox её не перехватывает) */
.article-body a img { cursor: pointer; }

/* Лайтбокс (баг #799999, правки 5, Б) — крупный просмотр картинки статьи по клику */
.kb-lightbox-overlay {
  position: fixed; inset: 0; background: rgba(9,30,66,.82); z-index: 9999;
  display: flex; align-items: center; justify-content: center; padding: 32px;
  cursor: zoom-out;
}
.kb-lightbox-img {
  max-width: 100%; max-height: 100%; border-radius: var(--radius);
  box-shadow: 0 12px 48px rgba(0,0,0,.4); cursor: default;
}
.kb-lightbox-close {
  position: absolute; top: 18px; right: 24px; width: 40px; height: 40px;
  border: none; border-radius: 50%; background: rgba(255,255,255,.12);
  color: #fff; font-size: 18px; line-height: 1; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background .15s;
}
.kb-lightbox-close:hover { background: rgba(255,255,255,.22); }
/* №6 (карточка «правки 5»): было display:block — на <table> это ломает табличную
   раскладку (браузер больше не выравнивает ячейки по сетке table-layout), из-за чего
   строки/колонки съезжали и границы ячеек пропадали. overflow-x:auto работает и на
   самом <table> (спека это поддерживает), сохраняя нормальный табличный рендеринг,
   а для очень широких таблиц даёт горизонтальный скролл вместо обрезания контейнером. */
.article-body table { width: 100%; border-collapse: collapse; margin: 16px 0; font-size: 14px; border: 1px solid var(--border-2); border-radius: var(--radius); overflow-x: auto; display: table; table-layout: auto; }
.article-body table + table { margin-top: 28px; }
.article-body th { background: var(--surface-2); color: var(--text); font-size: 13px; font-weight: 600; text-transform: none; letter-spacing: 0; padding: 9px 14px; border: 1px solid var(--border-2); }
.article-body td { padding: 8px 14px; color: var(--text-2); border: 1px solid var(--border-2); vertical-align: top; }
.article-body tr:hover td { background: var(--surface); }
/* №6 (карточка «правки 5», возврат от 03.08): «пустое место» в таблице — это не
   пустая строка, а ИНЛАЙНОВЫЙ height из EvaTeam-экспорта прямо в разметке статьи
   (напр. док 1307: <table style="height:1712.83px"> и <tr>/<td style="height:243.543px">
   при контенте в две строки текста). Инлайновый стиль перебивает наш CSS выше,
   поэтому правка от 03.08 (display:table) на это не влияла. Гасим только height —
   ширины (width: 100.013%, width:10px, data-col-styles) не трогаем, раскладка колонок
   остаётся ровно той, что задал автор таблицы. !important обязателен: побеждаем inline. */
.article-body table,
.article-body thead,
.article-body tbody,
.article-body tfoot,
.article-body tr,
.article-body td,
.article-body th { height: auto !important; }
.kb-video { position: relative; width: 100%; padding-top: 56.25%; margin: 16px 0; border-radius: var(--radius); overflow: hidden; background: #000; }
.kb-video iframe, .kb-video video { position: absolute; top: 0; left: 0; width: 100%; height: 100%; border: 0; }

/* ─── Right sidebar (TOC / related) ─────────────────── */
.toc { position: sticky; top: 76px; max-height: calc(100vh - 96px); overflow-y: auto; scrollbar-width: thin; scrollbar-color: var(--border-2) transparent; }
.toc-label { font-size: 11px; font-weight: 600; letter-spacing: 1px; text-transform: uppercase; color: var(--text-3); margin-bottom: 12px; }
.toc a { display: block; font-size: 13px; color: var(--text-2); padding: 5px 0 5px 12px; border-left: 2px solid var(--border-2); margin-bottom: 2px; transition: all .15s; }
.toc a:hover { color: var(--text); border-left-color: var(--text-3); }
.toc a.active { color: var(--accent); border-left-color: var(--accent); font-weight: 500; }

/* Related articles in right rail */
.related-section { margin-top: 28px; }
.related-section .toc-label { margin-bottom: 10px; }
.related-link { display: block; font-size: 13px; color: var(--accent); padding: 6px 0; border-bottom: 1px solid var(--border); line-height: 1.4; transition: color .15s; }
.related-link:last-child { border-bottom: none; }
.related-link:hover { color: var(--text); }

/* ─── Feedback ───────────────────────────────────────── */
.feedback-block { margin-top: 48px; padding: 20px 24px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); text-align: center; }
.feedback-block p { font-size: 14px; color: var(--text-2); margin-bottom: 14px; }
.fb-btns { display: flex; gap: 10px; justify-content: center; }
.fb-btn { font-family: inherit; font-size: 13px; padding: 8px 20px; border-radius: var(--radius-sm); border: 1px solid var(--border-2); background: var(--surface-2); color: var(--text-2); cursor: pointer; transition: all .15s; }
.fb-btn:hover { color: var(--text); }
.fb-btn.yes:hover { color: var(--green); border-color: rgba(54,179,126,.3); background: var(--green-bg); }
.fb-btn.no:hover  { color: var(--red);  border-color: rgba(222,53,11,.2); background: var(--red-bg); }
.fb-thanks { font-size: 13px; color: var(--text-3); padding: 12px 0; }

/* ─── Staff layout ───────────────────────────────────── */
.staff-layout { max-width: 1300px; margin: 0 auto; padding: 36px 28px 100px; display: grid; grid-template-columns: 220px 1fr; gap: 40px; }
.staff-layout > * { min-width: 0; }

.staff-user { display: flex; align-items: center; gap: 10px; padding: 12px 14px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); margin-bottom: 24px; box-shadow: 0 1px 2px rgba(9,30,66,.06); }
.avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--accent-bg); display: flex; align-items: center; justify-content: center; font-size: 13px; font-weight: 600; color: var(--accent); flex-shrink: 0; }
.user-name { font-size: 13px; font-weight: 500; }
.user-role { font-size: 11px; color: var(--text-3); }

.staff-menu-label { font-size: 11px; font-weight: 600; letter-spacing: 1px; text-transform: uppercase; color: var(--text-3); padding: 0 8px; margin-bottom: 6px; }
.staff-nav { margin-bottom: 20px; }
.staff-nav a { display: flex; align-items: center; gap: 10px; font-size: 13px; color: var(--text-2); padding: 7px 10px; border-radius: var(--radius-sm); margin-bottom: 1px; transition: all .15s; }
.staff-nav a:hover { color: var(--text); background: var(--surface-3); }
.staff-nav a.active { color: var(--accent); background: var(--accent-bg); font-weight: 500; }
.staff-nav a.active .s-dot { background: var(--accent); }
.s-dot { width: 5px; height: 5px; border-radius: 50%; background: var(--text-3); flex-shrink: 0; transition: background .15s; }

/* ─── Stats ──────────────────────────────────────────── */
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 28px; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px; box-shadow: 0 1px 2px rgba(9,30,66,.06); }
.stat-val { font-size: 24px; font-weight: 600; letter-spacing: -.4px; margin-bottom: 2px; }
.stat-label { font-size: 11px; color: var(--text-3); }
.accent-val { color: var(--accent); }

/* ─── Table card ─────────────────────────────────────── */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; margin-bottom: 20px; box-shadow: 0 1px 2px rgba(9,30,66,.06); }
.card-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 20px; border-bottom: 1px solid var(--border); }
.card-head h3 { font-size: 14px; font-weight: 600; }
.card-note { font-size: 12px; color: var(--text-3); }

table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: 11px; font-weight: 600; letter-spacing: .5px; text-transform: uppercase; color: var(--text-3); padding: 10px 20px; border-bottom: 1px solid var(--border); background: var(--surface-2); }
td { padding: 11px 20px; font-size: 13px; border-bottom: 1px solid var(--border); color: var(--text-2); }
tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--surface-2); }
td.t-title { color: var(--text); font-weight: 500; }
td.t-actions { text-align: right; }

.tag { display: inline-block; font-size: 11px; padding: 2px 7px; border-radius: 3px; font-weight: 500; }
.tag-client { background: var(--accent-bg); color: var(--accent); }
.tag-staff  { background: rgba(9,30,66,.06); color: var(--text-2); }

.row-actions { display: flex; gap: 6px; justify-content: flex-end; opacity: 0; transition: opacity .15s; }
tr:hover .row-actions { opacity: 1; }

/* ─── Missed searches ────────────────────────────────── */
.missed-list { padding: 0 20px 8px; }
.missed-item { display: flex; align-items: center; justify-content: space-between; padding: 10px 0; border-bottom: 1px solid var(--border); font-size: 13px; }
.missed-item:last-child { border-bottom: none; }
.missed-q { color: var(--text-2); flex: 1; }
.missed-cnt { font-size: 11px; color: var(--text-3); margin: 0 16px; white-space: nowrap; }
.missed-action { font-size: 12px; color: var(--accent); cursor: pointer; white-space: nowrap; }
.missed-action:hover { text-decoration: underline; }

/* ─── Buttons ────────────────────────────────────────── */
.btn { font-family: inherit; font-size: 13px; font-weight: 500; padding: 8px 16px; border-radius: var(--radius-sm); border: none; cursor: pointer; transition: all .15s; display: inline-flex; align-items: center; gap: 6px; }
.btn-primary { background: var(--accent); color: #fff; box-shadow: 0 2px 6px rgba(124,106,247,.35); }
.btn-primary:hover { background: #9181f9; }
.btn-ghost { background: var(--surface); color: var(--text-2); border: 1px solid var(--border-2); }
.btn-ghost:hover { color: var(--text); background: var(--surface-2); }
.btn-sm { padding: 5px 12px; font-size: 12px; }
.btn-danger { background: rgba(222,53,11,.07); color: var(--red); border: 1px solid rgba(222,53,11,.2); }
.btn-danger:hover { background: rgba(222,53,11,.14); }

/* ─── Top bar ────────────────────────────────────────── */
.topbar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 24px; }
.topbar h2 { font-size: 20px; font-weight: 600; letter-spacing: -.3px; }
.topbar-actions { display: flex; gap: 8px; }

/* ─── Edit form ──────────────────────────────────────── */
.form-grid { display: grid; gap: 20px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.field label { display: block; font-size: 11px; font-weight: 600; letter-spacing: .5px; text-transform: uppercase; color: var(--text-3); margin-bottom: 8px; }
.field input, .field select, .field textarea {
  width: 100%; background: var(--surface); border: 2px solid var(--border-2);
  border-radius: var(--radius-sm); padding: 9px 12px;
  color: var(--text); font-family: inherit; font-size: 14px; outline: none; transition: border-color .15s;
}
.field input:focus, .field textarea:focus { border-color: var(--accent); }
.field select { border-color: var(--border-2); }
.field select option { background: var(--surface); color: var(--text); }
.field textarea { resize: vertical; min-height: 420px; line-height: 1.7; font-size: 13px; font-family: 'Menlo', monospace; }
.field-hint { font-size: 11px; color: var(--text-3); margin-top: 5px; }

.edit-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 28px; box-shadow: 0 1px 4px rgba(9,30,66,.06); }
.edit-footer { display: flex; align-items: center; justify-content: space-between; margin-top: 24px; padding-top: 20px; border-top: 1px solid var(--border); }

.saved-toast { font-size: 13px; color: var(--green); display: none; }
.saved-toast.show { display: inline; }

/* ─── Login ──────────────────────────────────────────── */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: var(--bg); }
.login-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 36px 40px; width: 100%; max-width: 380px; box-shadow: 0 4px 24px rgba(9,30,66,.1); }
.login-logo { font-size: 16px; font-weight: 600; letter-spacing: -.2px; margin-bottom: 28px; }
.login-logo em { color: var(--accent); font-style: normal; }
.login-error { background: var(--red-bg); border: 1px solid rgba(222,53,11,.2); border-radius: var(--radius-sm); padding: 10px 14px; font-size: 13px; color: var(--red); margin-bottom: 20px; }
.login-footer { margin-top: 20px; font-size: 12px; color: var(--text-3); text-align: center; }

/* ─── Filters ────────────────────────────────────────── */
.filters { display: flex; gap: 10px; align-items: center; margin-bottom: 20px; flex-wrap: wrap; }
.filters input, .filters select {
  background: var(--surface); border: 2px solid var(--border-2); border-radius: var(--radius-sm);
  padding: 7px 12px; color: var(--text); font-family: inherit; font-size: 13px; outline: none;
}
.filters input:focus, .filters select:focus { border-color: var(--accent); }
.filters input { flex: 1; min-width: 200px; }

/* ─── Pagination ─────────────────────────────────────── */
.pagination { display: flex; gap: 4px; justify-content: center; margin-top: 20px; }
.pagination a, .pagination span {
  font-size: 13px; padding: 6px 12px; border-radius: var(--radius-sm);
  background: var(--surface); border: 1px solid var(--border-2); color: var(--text-2);
}
.pagination a:hover { color: var(--text); background: var(--surface-2); }
.pagination .current { color: var(--accent); border-color: var(--accent-ring); background: var(--accent-bg); font-weight: 500; }

/* ─── 404 / Empty ────────────────────────────────────── */
.not-found { text-align: center; padding: 80px 28px; }
.not-found h2 { font-size: 28px; font-weight: 600; margin-bottom: 10px; }
.not-found p { color: var(--text-3); margin-bottom: 24px; }
.empty { padding: 40px; text-align: center; font-size: 14px; color: var(--text-3); }

/* ═══════════════════════════════════════════════════════
   MOBILE
═══════════════════════════════════════════════════════ */
@media (max-width: 768px) {
  .header { padding: 0 16px; gap: 12px; }
  .h-search { display: none; }
  .h-nav a:not(.btn-accent) { display: none; }
  .h-staff span { display: none; }

  .hero { padding: 40px 16px 52px; }
  .hero h1 { font-size: 28px; }
  .hero p { font-size: 15px; margin-bottom: 28px; }
  .hero-search input { font-size: 16px; padding: 14px 20px 14px 48px; }
  .kbd { display: none; }

  .cats { grid-template-columns: 1fr 1fr; }
  .two-col { grid-template-columns: 1fr; gap: 28px; }
  .content { padding: 0 16px 80px; }

  .art-layout {
    grid-template-columns: 1fr;
    padding: 20px 16px 80px; gap: 0;
  }
  .sidebar-left { display: none; }
  .toc { display: none; }
  .article-head h1 { font-size: 26px; }
  .article-body { font-size: 16px; line-height: 1.8; }
  .article-body h2 { font-size: 20px; }
  .article-body h3 { font-size: 17px; }

  .staff-layout { grid-template-columns: 1fr; padding: 16px 16px 80px; gap: 0; }
  .staff-sidebar { display: flex; align-items: center; gap: 12px; margin-bottom: 20px; flex-wrap: wrap; }
  .staff-user { margin-bottom: 0; flex: 0 0 auto; }
  .staff-menu-label { display: none; }
  .staff-nav { display: flex; flex-direction: row; gap: 4px; margin-bottom: 0; flex-wrap: wrap; }
  .staff-nav a { padding: 5px 10px; font-size: 12px; white-space: nowrap; }
  .s-dot { display: none; }
  .user-role { display: none; }

  .stats { grid-template-columns: 1fr 1fr; }
  .card { overflow-x: auto; }
  table { min-width: 500px; }
  .topbar { flex-direction: column; align-items: flex-start; gap: 12px; }
  .topbar-actions { width: 100%; }
  .filters { flex-direction: column; }
  .filters input { min-width: unset; width: 100%; }
  .filters select { width: 100%; }
  .form-row { grid-template-columns: 1fr; }
  .edit-card { padding: 16px; }
  .login-card { padding: 24px 20px; margin: 16px; }
  .fb-btns { flex-direction: column; align-items: center; }
  .fb-btn { width: 100%; max-width: 220px; }
  .search-results { left: -16px; right: -16px; }
  .pagination { flex-wrap: wrap; }
}

@media (max-width: 480px) {
  .hero h1 { font-size: 24px; }
  .article-head h1 { font-size: 22px; }
  .article-body { font-size: 15px; }
  .cats { grid-template-columns: 1fr; }
  .stat-val { font-size: 20px; }
}

/* === V3 sprint 1: якоря, ширина редактора, дерево === */
.article-body h1, .article-body h2, .article-body h3, .article-body h4 { position: relative; scroll-margin-top: 90px; }
.kb-anchor { opacity: 0; transition: opacity .12s; color: var(--text-3); font-weight: 400; text-decoration: none !important; margin-left: 6px; font-size: 0.8em; vertical-align: middle; }
.article-body h1:hover .kb-anchor, .article-body h2:hover .kb-anchor, .article-body h3:hover .kb-anchor, .article-body h4:hover .kb-anchor { opacity: 1; }
.kb-anchor:hover { color: var(--accent) !important; }
.toc a.toc-l3 { padding-left: 22px; font-size: 12.5px; }
.toc a.toc-l4 { padding-left: 32px; font-size: 12px; opacity: .8; }

/* №1: редактор на всю ширину */
body.staff-edit .staff-layout { max-width: none; padding-left: 24px; padding-right: 24px; grid-template-columns: 220px 1fr; gap: 28px; }
body.staff-edit .edit-card { width: 100%; box-sizing: border-box; }
body.staff-edit .EasyMDEContainer { width: 100% !important; }
body.staff-edit .sun-editor { width: 100% !important; max-width: none !important; }
body.staff-edit .se-wrapper { max-width: none !important; }
/* №7 (баг #799999): тулбар WYSIWYG остаётся на всю ширину (много кнопок), а сам текст —
   читаемой колонкой по центру, а не растянут во всю ширину экрана.
   ⚠️ №7 (правки 3): .se-wrapper-inner — ТОТ ЖЕ элемент, что и .se-wrapper-wysiwyg
   (SunEditor вешает оба класса на editable-div), поэтому раньше он тоже попадал под
   max-width:none !important выше и глушил это правило (у !important всегда приоритет
   над обычным, независимо от порядка) — колонка текста никогда не сужалась. */
body.staff-edit .sun-editor .se-wrapper-wysiwyg { max-width: 860px; margin: 0 auto; }
/* №7 (баг #799999, правки 2): та же читаемая ширина нужна в Markdown/EasyMDE-режиме —
   он по умолчанию, и раньше .CodeMirror растягивался на весь экран без ограничения */
body.staff-edit .CodeMirror { max-width: 860px; margin: 0 auto; width: 100% !important; }

/* №3: свёрнутые разделы по умолчанию */
.cat-children { transition: max-height .2s; }
.cat-toggle { cursor: pointer; user-select: none; display: inline-block; transition: transform .15s; }
.cat-toggle.collapsed { transform: rotate(-90deg); }
.cat-children.collapsed { display: none; }

/* V3: drop-zone для пустых категорий — увеличить min-height.
   Контейнер один на статьи и подразделы (.tree-items, правки 2 п.1). */
.tree-items[data-cat-id] { min-height: 18px; padding: 4px 0; transition: background .12s; border-radius: 4px; }
.tree-items-empty { background: rgba(99,102,241,.04); border: 1px dashed transparent; }
.tree-items-empty:hover, .tree-items.dnd-over { background: rgba(99,102,241,.10); border-color: var(--border-2); }

/* === V4 sprint 1: ширина картинок, sticky-тулбар, TOC h1 === */
/* №1+№8: ограничить широкие img/figure/SunEditor-обёртки, но НЕ сбрасывать осознанный
   ресайз картинки из редактора — только не давать ей вылезти шире колонки текста
   (баг #799999 п.3: width:auto !important топтал сохранённый width) */
.article-body img,
.article-body figure,
.article-body .se-component,
.article-body .se-image-container {
  max-width: 100% !important;
  /* баг #799999 правки 4, №7: SunEditor пишет в <img style> фиксированные px
     И width, И height (напр. width:2091px;height:1167px). max-width сжимал
     ширину под колонку, а height оставался буквальным пикселем из инлайн-стиля
     (он бьёт обычный `height:auto` без !important) — картинка растягивалась/
     сплющивалась. !important здесь пересиливает инлайн-height и держит пропорцию. */
  height: auto !important;
  box-sizing: border-box;
}
.article-body { overflow-x: hidden; }

/* №2 (баг #799999, правки 3): та же защита от широких картинок нужна и в самом
   редакторе (.se-wrapper-wysiwyg, колонка 860px) — иначе полноразмерный скриншот
   (до 2792px) вылезает за колонку и раздувает всю форму редактирования */
body.staff-edit .sun-editor .se-wrapper-wysiwyg img,
body.staff-edit .sun-editor .se-wrapper-wysiwyg figure,
body.staff-edit .sun-editor .se-wrapper-wysiwyg .se-component,
body.staff-edit .sun-editor .se-wrapper-wysiwyg .se-image-container {
  max-width: 100% !important;
  height: auto !important; /* см. комментарий выше (правки 4, №7) — та же деформация видна и в самом редакторе */
  box-sizing: border-box;
}
.art-layout { min-width: 0; }
.art-layout > .article-main { min-width: 0; overflow-x: auto; }

/* №7: TOC для h1 */
.toc a.toc-l1 { font-weight: 500; color: var(--text); }
.toc a.toc-l1 + .toc-l2 { margin-top: 2px; }

/* №3+№6: sticky topbar редактора + sticky SunEditor toolbar */
.topbar-sticky {
  position: sticky; top: 60px; z-index: 40;
  background: var(--bg); border-bottom: 1px solid var(--border);
  padding: 10px 0; margin-bottom: 12px;
}
body.staff-edit .sun-editor .se-toolbar {
  position: sticky !important;
  top: 108px !important;
  z-index: 30;
  background: var(--surface) !important;
}
body.staff-edit .sun-editor .se-toolbar.se-toolbar-shadow {
  position: sticky !important;
  top: 108px !important;
}
/* EasyMDE toolbar тоже sticky */
body.staff-edit .editor-toolbar {
  position: sticky; top: 108px; z-index: 30; background: var(--surface);
}

/* V4: callouts через blockquote[data-callout] (совместимость с SunEditor whitelist).
   №8 (баг #799999): та же раскраска нужна и ВНУТРИ редактора (.se-wrapper-wysiwyg) —
   иначе кнопка «Инфоблок» в WYSIWYG вставляет тег без видимого эффекта, кажется что
   «не получается добавить». */
.article-body blockquote[data-callout],
.sun-editor .se-wrapper-wysiwyg blockquote[data-callout] { display: block; border-radius: var(--radius-sm); padding: 12px 16px; margin: 16px 0; font-size: 14px; line-height: 1.7; color: var(--text); border-left: 3px solid var(--border); }
.article-body blockquote[data-callout=note],    .sun-editor .se-wrapper-wysiwyg blockquote[data-callout=note]    { background: rgba(139,92,246,.14); border-left-color: #8b5cf6; }
.article-body blockquote[data-callout=info],    .sun-editor .se-wrapper-wysiwyg blockquote[data-callout=info]    { background: rgba(59,130,246,.12); border-left-color: #3b82f6; }
.article-body blockquote[data-callout=success], .sun-editor .se-wrapper-wysiwyg blockquote[data-callout=success] { background: rgba(34,197,94,.12);  border-left-color: #22c55e; }
.article-body blockquote[data-callout=warning], .sun-editor .se-wrapper-wysiwyg blockquote[data-callout=warning] { background: rgba(245,158,11,.14); border-left-color: #f59e0b; }
.article-body blockquote[data-callout=error],   .sun-editor .se-wrapper-wysiwyg blockquote[data-callout=error]   { background: rgba(239,68,68,.13);  border-left-color: #ef4444; }
.article-body blockquote[data-callout=caution], .sun-editor .se-wrapper-wysiwyg blockquote[data-callout=caution] { background: rgba(249,115,22,.13); border-left-color: #f97316; }

/* №5 (баг #799999, MVP + правки 1): «Магнит» — колонки для текста/картинок, таблица
   (не div — см. комментарий у injectMagnetButton в edit.html). Рамки ячеек — только
   в редакторе (для ориентации при заполнении), при чтении статьи их нет. */
.article-body table[data-kb-columns] {
  display: table; table-layout: fixed; width: 100%; border-collapse: collapse;
  margin: 16px 0; background: transparent; overflow: visible;
  border: none; border-radius: 0;
}
.article-body table[data-kb-columns] td {
  border: none; background: transparent; padding: 0 10px; vertical-align: top;
}
.article-body table[data-kb-columns] td:first-child { padding-left: 0; }
.article-body table[data-kb-columns] td:last-child { padding-right: 0; }
.article-body table[data-kb-columns] td > :last-child { margin-bottom: 0; }

.sun-editor .se-wrapper-wysiwyg table[data-kb-columns] {
  display: table; table-layout: fixed; width: 100%; border-collapse: collapse;
  margin: 16px 0; background: transparent;
}
.sun-editor .se-wrapper-wysiwyg table[data-kb-columns] td {
  border: 1px dashed var(--border-2); border-radius: var(--radius-sm); padding: 10px; vertical-align: top; background: transparent;
}

/* Аккордеон-details без обязательных классов */
.article-body details { margin: 12px 0; border: 1px solid var(--border-2); border-radius: var(--radius-sm); padding: 4px 12px; background: var(--surface); }
.article-body details[open] { padding-bottom: 10px; }
.article-body details > summary { cursor: pointer; padding: 8px 4px; font-weight: 500; color: var(--text); user-select: none; }
.article-body details > summary::-webkit-details-marker { color: var(--text-3); }

/* №8 (баг #799999, правки 2): модалка ввода заголовка/текста аккордеона —
   обычные поля формы вместо ввода прямо в хрупкий contenteditable <details>/<summary> */
.kb-modal-overlay { position: fixed; inset: 0; background: rgba(9,30,66,.45); z-index: 9999; display: flex; align-items: center; justify-content: center; padding: 20px; }
.kb-modal { background: var(--surface); border-radius: var(--radius); padding: 24px; width: 100%; max-width: 480px; box-shadow: 0 12px 40px rgba(9,30,66,.25); }
.kb-modal h3 { margin: 0 0 16px; font-size: 16px; color: var(--text); }
.kb-modal label { display: block; font-size: 12px; font-weight: 600; color: var(--text-3); text-transform: uppercase; letter-spacing: .3px; margin: 14px 0 6px; }
.kb-modal label:first-of-type { margin-top: 0; }
.kb-modal input[type=text], .kb-modal textarea { width: 100%; box-sizing: border-box; font-family: inherit; font-size: 14px; padding: 9px 12px; border: 1px solid var(--border-2); border-radius: var(--radius-sm); color: var(--text); background: var(--surface); }
.kb-modal textarea { resize: vertical; min-height: 110px; }
.kb-modal input[type=text]:focus, .kb-modal textarea:focus { outline: none; border-color: var(--accent); }
.kb-modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; }

