:root {
  --topbar-h: 56px;
  --left-w: 290px;
  --right-w: 230px;
  --text: #1f2937;
  --muted: #6b7280;
  --border: #e5e7eb;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --primary: #4f46e5;
  --primary-soft: #eef2ff;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: Inter, "Segoe UI", system-ui, -apple-system, sans-serif;
  color: var(--text);
  background: #fff;
  line-height: 1.55;
  padding-top: var(--topbar-h);
}

/* ── topbar ── */
.topbar {
  position: fixed; top: 0; left: 0; right: 0;
  height: var(--topbar-h); z-index: 1000;
  border-bottom: 1px solid var(--border);
  background: rgba(255,255,255,.96);
  backdrop-filter: blur(8px);
  display: flex; align-items: center; gap: 12px; padding: 0 14px;
}
.brand { display: inline-flex; align-items: center; gap: 8px; text-decoration: none; color: #111827; font-size: calc(14px + 2pt); font-weight: 700; min-width: 180px; }
.brand img { width: 26px; height: 26px; border-radius: 6px; object-fit: cover; }
.search { flex: 1; max-width: 520px; height: 36px; border: 1px solid var(--border); border-radius: 8px; background: #fff; padding: 0 12px; color: #111827; font-size: calc(13px + 2pt); outline: none; }
.top-actions { margin-left: auto; display: inline-flex; align-items: center; gap: 10px; font-size: calc(12px + 2pt); }
.top-actions a { color: #4b5563; text-decoration: none; font-weight: 600; }
.btn { border: 1px solid var(--border); background: #fff; color: #111827; border-radius: 8px; min-height: 32px; padding: 0 10px; font-size: calc(12px + 2pt); font-weight: 700; text-decoration: none; display: inline-flex; align-items: center; justify-content: center; }

/* ── layout ── */
.layout { display: grid; grid-template-columns: var(--left-w) minmax(0,1fr) var(--right-w); min-height: calc(100vh - var(--topbar-h)); }
.left { border-right: 1px solid var(--border); padding: 14px 10px 24px; position: sticky; top: var(--topbar-h); height: calc(100vh - var(--topbar-h)); overflow: auto; background: #fcfcfd; }
.left-label { font-size: calc(10px + 2pt); color: #9ca3af; letter-spacing: .06em; text-transform: uppercase; font-weight: 700; margin: 10px 8px 6px; }

.left-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 1px; }
.nav-tree { display: flex; flex-direction: column; gap: 4px; margin-top: 4px; }

/* L1 group */
.nav-group { border: none; background: transparent; overflow: visible; }
.nav-group > summary { list-style: none; cursor: pointer; user-select: none; display: flex; align-items: center; gap: 6px; padding: 6px 8px; font-size: calc(12px + 2pt); font-weight: 800; color: #374151; background: transparent; border-radius: 7px; }
.nav-group > summary::-webkit-details-marker { display: none; }
.nav-group > summary:hover { background: #f3f4f6; color: #111827; }
.nav-group > summary::before { content: ""; display: inline-block; width: 14px; height: 14px; flex: 0 0 14px; background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' fill='none'%3E%3Cpath d='M6 9l6 6 6-6' stroke='%239ca3af' stroke-width='1.3' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center/contain no-repeat; transition: background .15s ease; }
.nav-group:not([open]) > summary::before { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' fill='none'%3E%3Cpath d='M9 6l6 6-6 6' stroke='%239ca3af' stroke-width='1.3' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E"); }
/* Вертикальная линия дерева: от родителя вниз по всем дочерним блокам */
.nav-group > .nav-tree-inner {
  padding: 2px 0 4px 14px;
  margin-left: 6px;
  border-left: 1px solid var(--border);
  padding-left: 10px;
}

/* L2 sub-group */
.nav-sub { border: none; background: transparent; overflow: visible; }
.nav-sub > summary { list-style: none; cursor: pointer; user-select: none; display: flex; align-items: center; gap: 6px; padding: 4px 8px; font-size: calc(11.5px + 2pt); font-weight: 700; color: #4b5563; background: transparent; border-radius: 6px; }
.nav-sub > summary::-webkit-details-marker { display: none; }
.nav-sub > summary:hover { background: #f3f4f6; color: #111827; }
.nav-sub > summary::before { content: ""; display: inline-block; width: 12px; height: 12px; flex: 0 0 12px; background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' fill='none'%3E%3Cpath d='M6 9l6 6 6-6' stroke='%23c9cdd5' stroke-width='1.3' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center/contain no-repeat; transition: background .15s ease; }
.nav-sub:not([open]) > summary::before { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' fill='none'%3E%3Cpath d='M9 6l6 6-6 6' stroke='%23c9cdd5' stroke-width='1.3' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E"); }
/* Вертикальная линия для списка ссылок внутри подраздела */
.nav-sub > .left-list {
  padding: 2px 0 4px 16px;
  margin-left: 6px;
  border-left: 1px solid var(--border);
  padding-left: 10px;
}

/* leaf links */
.left-link { display: flex; align-items: center; gap: 7px; text-decoration: none; color: #4b5563; font-size: calc(11.5px + 2pt); font-weight: 600; padding: 4px 8px; border-radius: 6px; }
.left-link:hover { background: #f3f4f6; color: #111827; }
.left-link.active { background: var(--primary-soft); color: #4338ca; }
.left-link::before { content: "✓"; width: 13px; height: 13px; border-radius: 999px; border: 1px solid #d1d5db; color: transparent; font-size: calc(9px + 2pt); font-weight: 800; display: inline-flex; align-items: center; justify-content: center; flex: 0 0 13px; background: #fff; }
.left-link.active::before { border-color: #c7d2fe; background: #e0e7ff; color: #4338ca; }

/* ── main content ── */
.main { padding: 20px 34px 36px; }
.article { max-width: 860px; }
.crumbs { font-size: calc(12px + 2pt); color: #9ca3af; margin-bottom: 10px; }
h1 { margin: 0 0 8px; font-size: clamp(calc(28px + 2pt), calc(3vw + 2pt), calc(34px + 2pt)); line-height: 1.1; letter-spacing: -.02em; }
h2 { margin: 28px 0 10px; font-size: calc(23px + 2pt); border-bottom: 1px solid var(--border); padding-bottom: 10px; }
h3 { margin: 20px 0 8px; font-size: calc(16px + 2pt); }
p { margin: 0 0 12px; font-size: calc(14px + 2pt); color: #374151; }
ul, ol { margin: 0 0 14px; padding-left: 20px; color: #374151; font-size: calc(14px + 2pt); }
li { margin-bottom: 6px; }
.callout { border: 1px solid #dbeafe; background: #eff6ff; color: #1e3a8a; border-radius: 8px; padding: 10px 12px; font-size: calc(13px + 2pt); margin: 14px 0; }

/* ── meta header ── */
.meta { display: flex; flex-wrap: wrap; gap: 14px; color: #6b7280; font-size: calc(12px + 2pt); margin-bottom: 14px; }
.meta-table { width: 100%; border-collapse: collapse; margin: 0 0 20px; font-size: calc(13px + 2pt); }
.meta-table td { border: 1px solid var(--border); padding: 8px 12px; vertical-align: top; }
.meta-table td:first-child { width: 200px; color: #374151; font-weight: 700; background: var(--surface-2); }
.summary { margin: 0 0 18px; color: #374151; font-size: calc(14px + 2pt); }

/* tags */
.tag { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: calc(11px + 2pt); font-weight: 700; margin-right: 4px; }
.tag-free { background: #ecfdf5; color: #065f46; border: 1px solid #a7f3d0; }
.tag-pro { background: #eef2ff; color: #3730a3; border: 1px solid #c7d2fe; }
.tag-ent { background: #fef3c7; color: #92400e; border: 1px solid #fde68a; }
.tag-role { background: #f3f4f6; color: #374151; border: 1px solid #d1d5db; }
.tag-team { background: #f0fdf4; color: #166534; border: 1px solid #86efac; }
.tag-biz { background: #fef9c3; color: #854d0e; border: 1px solid #fde047; }
.tag-corp { background: #fae8ff; color: #6b21a8; border: 1px solid #d8b4fe; }
.tag-platform { background: #f0f9ff; color: #0c4a6e; border: 1px solid #bae6fd; }

/* ── right TOC ── */
.right { border-left: 1px solid var(--border); padding: 16px 10px; position: sticky; top: var(--topbar-h); height: calc(100vh - var(--topbar-h)); overflow: auto; background: #fff; }
.right-title { margin: 2px 6px 8px; font-size: calc(11px + 2pt); color: #9ca3af; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; }
.toc { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.toc a { display: flex; align-items: center; gap: 7px; text-decoration: none; color: #6b7280; font-size: calc(11.5px + 2pt); padding: 5px 8px; border-radius: 6px; font-weight: 600; }
.toc a:hover { background: #f3f4f6; color: #111827; }
.toc a::before { content: "✓"; width: 13px; height: 13px; border-radius: 999px; border: 1px solid #d1d5db; color: transparent; font-size: calc(9px + 2pt); font-weight: 800; display: inline-flex; align-items: center; justify-content: center; flex: 0 0 13px; background: #fff; }
.toc a.active { background: #f3f4f6; color: #111827; }
.toc a.active::before { border-color: #c7d2fe; background: #e0e7ff; color: #4338ca; }

.faq dt { font-weight: 700; color: #111827; margin-top: 14px; }
.faq dd { margin: 6px 0 10px; color: #374151; }
.helpful { margin-top: 26px; border-top: 1px solid var(--border); padding-top: 12px; display: flex; align-items: center; gap: 8px; font-size: calc(13px + 2pt); color: #4b5563; }

/* ── index cards ── */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; margin: 20px 0; }
.card { border: 1px solid var(--border); border-radius: 12px; padding: 16px; background: #fff; transition: box-shadow .2s; }
.card:hover { box-shadow: 0 4px 16px rgba(0,0,0,.06); }
.card h3 { margin: 0 0 6px; font-size: calc(15px + 2pt); }
.card p { margin: 0; font-size: calc(13px + 2pt); color: var(--muted); }
.card a { display: inline-block; margin-top: 10px; font-size: calc(12px + 2pt); font-weight: 700; color: var(--primary); text-decoration: none; }

/* ── embed mode (loaded inside iframe) ── */
body.embed { padding-top: 0; }
body.embed .topbar { display: none; }
body.embed .layout { grid-template-columns: minmax(0,1fr) var(--right-w); min-height: 100vh; }
body.embed .left { display: none; }
@media (max-width: 1200px) { body.embed .layout { grid-template-columns: 1fr; } body.embed .right { display: none; } }

/* ── iframe container ── */
.content-frame { border: none; width: 100%; height: calc(100vh - var(--topbar-h)); grid-column: 2 / -1; }

/* ── nav-sub active state ── */
.nav-sub.nav-sub--active > summary { background: var(--primary-soft); color: #4338ca; }

/* ── реализовано (check icon) ── */
.kb-done { width: 20px; height: 20px; vertical-align: -0.2em; margin-left: 6px; }
.card .kb-done { width: 18px; height: 18px; vertical-align: -0.15em; margin-left: 4px; }
.kb-legend { display: inline-flex; align-items: center; gap: 6px; font-size: calc(12px + 2pt); color: var(--muted); margin-bottom: 16px; }
.kb-legend .kb-done { margin-left: 0; }

/* ── responsive ── */
@media (max-width: 1200px) { .layout { grid-template-columns: var(--left-w) minmax(0,1fr); } .right { display: none; } }
@media (max-width: 980px) { .layout { grid-template-columns: 1fr; } .left { display: none; } .main { padding: 16px 14px 28px; } .top-actions a { display: none; } .search { max-width: none; } }
