/* ЮИКСИЯ · База знаний продаж */

:root {
  --accent: #5b5bd6;
  --accent-strong: #4a4ac4;
  --accent-soft: #eeeefc;
  --bg: #f7f7fa;
  --surface: #ffffff;
  --text: #1d1d28;
  --text-muted: #6b6b80;
  --border: #e4e4ee;
  --shadow: 0 1px 3px rgba(20, 20, 43, 0.06), 0 8px 24px rgba(20, 20, 43, 0.06);
  --radius: 12px;
  --topbar-h: 56px;
  --ok-bg: #e8f7ee; --ok-text: #16794c;
  --err-bg: #fdeaea; --err-text: #b3261e;
  --code-bg: #f1f1f7;
  --mark: #fff3bf;
}

@media (prefers-color-scheme: dark) {
  :root {
    --accent: #8b8bf0;
    --accent-strong: #a0a0f5;
    --accent-soft: #26264a;
    --bg: #131320;
    --surface: #1c1c2b;
    --text: #e8e8f2;
    --text-muted: #9a9ab0;
    --border: #2d2d42;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.4), 0 8px 24px rgba(0, 0, 0, 0.35);
    --ok-bg: #12301f; --ok-text: #6fd39e;
    --err-bg: #3a1a1a; --err-text: #f2a19c;
    --code-bg: #24243a;
    --mark: #5a4d12;
  }
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }
html { scroll-padding-top: calc(var(--topbar-h) + 16px); }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 16px;
  line-height: 1.65;
  color: var(--text);
  background: var(--bg);
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------- Топбар ---------- */
.topbar {
  position: sticky; top: 0; z-index: 50;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  height: var(--topbar-h);
}
.topbar-inner {
  max-width: 1280px; margin: 0 auto; height: 100%;
  display: flex; align-items: center; gap: 14px; padding: 0 16px;
}
.brand { display: flex; align-items: center; gap: 10px; color: var(--text); font-weight: 700; }
.brand:hover { text-decoration: none; }
.brand-mark {
  display: inline-flex; align-items: center; justify-content: center;
  width: 32px; height: 32px; border-radius: 9px;
  background: var(--accent); color: #fff; font-weight: 800; font-size: 17px;
  flex: 0 0 auto;
}
.brand-mark-lg { width: 52px; height: 52px; font-size: 26px; border-radius: 14px; }
.brand-text { display: flex; flex-direction: column; line-height: 1.15; font-size: 15px; }
.brand-sub { font-size: 11px; font-weight: 500; color: var(--text-muted); }

.search-trigger {
  margin-left: auto;
  display: flex; align-items: center; gap: 8px;
  background: var(--bg); border: 1px solid var(--border);
  color: var(--text-muted); border-radius: 10px;
  padding: 7px 12px; font-size: 14px; cursor: pointer; min-width: 210px;
}
.search-trigger:hover { border-color: var(--accent); }
.search-trigger kbd {
  margin-left: auto; border: 1px solid var(--border); border-radius: 5px;
  padding: 0 6px; font-size: 12px; background: var(--surface);
}
.topbar-actions { display: flex; align-items: center; gap: 10px; }
.topbar-link { font-size: 14px; font-weight: 600; }
.user-chip {
  font-size: 13px; color: var(--text-muted);
  max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  background: none; border: none; color: var(--text-muted);
  width: 34px; height: 34px; border-radius: 8px; cursor: pointer;
}
.icon-btn:hover { background: var(--accent-soft); color: var(--accent); }
.inline-form { display: inline; margin: 0; }
.sidebar-toggle { display: none; }

/* ---------- Поиск ---------- */
.search-overlay[hidden] { display: none; }
.search-overlay {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(15, 15, 30, 0.55);
  backdrop-filter: blur(2px);
  display: flex; align-items: flex-start; justify-content: center;
  padding: 9vh 16px 16px;
}
.search-panel {
  width: 100%; max-width: 640px;
  background: var(--surface); border-radius: 14px; box-shadow: var(--shadow);
  overflow: hidden; border: 1px solid var(--border);
}
.search-input-row {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 14px; border-bottom: 1px solid var(--border); color: var(--text-muted);
}
.search-input-row input {
  flex: 1; border: none; outline: none; background: none;
  font-size: 16px; color: var(--text);
}
.search-results { max-height: 55vh; overflow-y: auto; padding: 8px; }
.search-hint { color: var(--text-muted); font-size: 14px; text-align: center; padding: 18px 8px; margin: 0; }
.search-item {
  display: block; padding: 10px 12px; border-radius: 9px; color: var(--text);
}
.search-item:hover, .search-item.selected { background: var(--accent-soft); text-decoration: none; }
.search-item .si-doc { font-size: 12px; color: var(--accent); font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; }
.search-item .si-heading { font-weight: 600; margin: 1px 0; }
.search-item .si-snippet { font-size: 13px; color: var(--text-muted); }
.search-item mark { background: var(--mark); color: inherit; border-radius: 3px; padding: 0 1px; }

/* ---------- Главная ---------- */
.container { max-width: 1120px; margin: 0 auto; padding: 32px 20px 64px; }
.container-narrow { max-width: 880px; }
.hero { margin: 18px 0 30px; }
.hero h1 { font-size: 30px; margin: 0 0 8px; letter-spacing: -0.02em; }
.hero p { color: var(--text-muted); margin: 0; max-width: 560px; }

.cards {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 16px;
}
.card {
  display: flex; flex-direction: column; gap: 8px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 20px;
  color: var(--text); transition: transform .12s ease, box-shadow .12s ease, border-color .12s ease;
}
.card:hover { text-decoration: none; transform: translateY(-2px); box-shadow: var(--shadow); border-color: var(--accent); }
.card-icon {
  width: 40px; height: 40px; border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  background: var(--accent-soft); color: var(--accent);
}
.card h2 { font-size: 17px; margin: 4px 0 0; }
.card p { font-size: 14px; color: var(--text-muted); margin: 0; flex: 1; }
.card-audience { font-size: 12px; color: var(--accent); font-weight: 600; }

/* ---------- Страница документа ---------- */
.doc-layout {
  display: grid; grid-template-columns: 280px minmax(0, 1fr);
  max-width: 1280px; margin: 0 auto; gap: 0 36px; padding: 0 16px;
}
.sidebar {
  position: sticky; top: var(--topbar-h);
  height: calc(100vh - var(--topbar-h));
  overflow-y: auto; padding: 24px 4px 40px;
  font-size: 14px;
}
.sidebar-title {
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--text-muted); font-weight: 700; margin: 18px 0 6px;
}
.sidebar ul { list-style: none; margin: 0; padding: 0; }
.doc-nav a, .toc a {
  display: block; padding: 5px 10px; border-radius: 7px; color: var(--text);
}
.doc-nav a:hover, .toc a:hover { background: var(--accent-soft); text-decoration: none; }
.doc-nav a.active { background: var(--accent-soft); color: var(--accent); font-weight: 700; }
.toc a { color: var(--text-muted); font-size: 13px; line-height: 1.4; padding: 4px 10px; }
.toc .toc-d3 a { padding-left: 24px; font-size: 12.5px; }
.toc a.toc-active { color: var(--accent); font-weight: 600; }
.sidebar-backdrop { display: none; }

.doc-content { padding: 28px 0 80px; min-width: 0; }

/* ---------- Markdown ---------- */
.markdown { max-width: 820px; }
.markdown h1 { font-size: 28px; letter-spacing: -0.02em; line-height: 1.3; margin: 6px 0 16px; }
.markdown h2 {
  font-size: 21px; margin: 40px 0 12px; padding-top: 14px;
  border-top: 1px solid var(--border); letter-spacing: -0.01em;
}
.markdown h3 { font-size: 17px; margin: 26px 0 8px; }
.markdown h4 { font-size: 15px; margin: 20px 0 6px; }
.markdown p { margin: 10px 0; }
.markdown li { margin: 4px 0; }
.markdown blockquote {
  margin: 16px 0; padding: 10px 16px;
  border-left: 3px solid var(--accent);
  background: var(--accent-soft); border-radius: 0 10px 10px 0;
  color: var(--text);
}
.markdown blockquote p { margin: 6px 0; }
.markdown hr { border: none; border-top: 1px solid var(--border); margin: 28px 0; }
.markdown code {
  background: var(--code-bg); border-radius: 5px; padding: 1px 6px;
  font-size: 0.9em; font-family: ui-monospace, "Cascadia Code", Consolas, monospace;
}
.markdown pre {
  background: var(--code-bg); border-radius: 10px; padding: 14px 16px;
  overflow-x: auto; font-size: 13.5px; line-height: 1.5;
}
.markdown pre code { background: none; padding: 0; }
.markdown .anchor {
  opacity: 0; margin-left: 8px; font-weight: 400; font-size: 0.85em;
}
.markdown h2:hover .anchor, .markdown h3:hover .anchor, .markdown h4:hover .anchor { opacity: 1; }

.table-wrap { overflow-x: auto; margin: 14px 0; border: 1px solid var(--border); border-radius: 10px; }
.markdown table, .admin-table { border-collapse: collapse; width: 100%; font-size: 14px; }
.markdown th, .markdown td, .admin-table th, .admin-table td {
  padding: 9px 12px; text-align: left; vertical-align: top;
  border-bottom: 1px solid var(--border);
}
.markdown thead th, .admin-table thead th {
  background: var(--code-bg); font-size: 12.5px;
  text-transform: uppercase; letter-spacing: 0.03em; color: var(--text-muted);
}
.markdown tbody tr:last-child td, .admin-table tbody tr:last-child td { border-bottom: none; }

.mermaid-wrap {
  margin: 18px 0; padding: 14px; overflow-x: auto;
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px;
}
pre.mermaid { background: none; padding: 0; text-align: center; }

/* ---------- Кнопки, формы, алерты ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
  border-radius: 9px; padding: 9px 16px; font-size: 14px; font-weight: 600;
  cursor: pointer; transition: background .12s ease;
}
.btn:hover { background: var(--accent-soft); text-decoration: none; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-strong); }
.btn-danger { color: var(--err-text); border-color: var(--err-text); background: none; }
.btn-danger:hover { background: var(--err-bg); }
.btn-small { padding: 4px 10px; font-size: 12.5px; border-radius: 7px; }
.btn-block { width: 100%; }

.alert { border-radius: 10px; padding: 11px 14px; font-size: 14px; margin: 0 0 16px; }
.alert-error { background: var(--err-bg); color: var(--err-text); }
.alert-ok { background: var(--ok-bg); color: var(--ok-text); }

input[type="text"], input[type="password"], input[type="search"], input[type="email"], select {
  font: inherit; color: var(--text);
  background: var(--bg); border: 1px solid var(--border); border-radius: 9px;
  padding: 9px 12px; width: 100%;
}
/* appearance:none только для текстовых полей: у select он убирает стрелку */
input[type="text"], input[type="password"], input[type="search"], input[type="email"] {
  -webkit-appearance: none; appearance: none;
}
input:focus, select:focus { outline: 2px solid var(--accent); outline-offset: 1px; border-color: transparent; }

/* ---------- Логин ---------- */
.login-body {
  background:
    radial-gradient(700px 400px at 20% 0%, color-mix(in srgb, var(--accent) 14%, transparent), transparent),
    var(--bg);
}
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; }
.login-card {
  width: 100%; max-width: 400px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 18px; box-shadow: var(--shadow); padding: 34px 30px 24px;
}
.login-brand { text-align: center; margin-bottom: 22px; }
.login-brand h1 { font-size: 19px; margin: 14px 0 2px; }
.login-brand p { color: var(--text-muted); margin: 0; font-size: 14px; }
.login-form { display: flex; flex-direction: column; gap: 14px; }
.login-form label { display: flex; flex-direction: column; gap: 5px; font-size: 13.5px; font-weight: 600; }
.login-footnote { text-align: center; color: var(--text-muted); font-size: 12.5px; margin: 18px 0 0; }

/* ---------- Админка ---------- */
.page-title { font-size: 26px; margin: 10px 0 18px; }
.panel {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 20px; margin-bottom: 20px;
}
.panel h2 { font-size: 17px; margin: 0 0 14px; }
.grid-form {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px;
  align-items: end;
}
.grid-form label { display: flex; flex-direction: column; gap: 5px; font-size: 13px; font-weight: 600; }
.grid-form-actions { display: flex; }
.grid-form-actions .btn { width: 100%; min-height: 41px; }
.form-hint { font-size: 13px; color: var(--text-muted); margin: 12px 0 0; }
.form-hint { color: var(--text-muted); font-size: 13px; margin: 12px 0 0; }
.badge {
  background: var(--accent-soft); color: var(--accent);
  border-radius: 6px; font-size: 11px; padding: 1px 6px; font-weight: 700;
}
.muted { color: var(--text-muted); }
.actions-cell { display: flex; gap: 8px; align-items: flex-start; flex-wrap: wrap; }
.reset-pass summary { list-style: none; }
.reset-pass summary::-webkit-details-marker { display: none; }
.reset-form { display: flex !important; gap: 6px; margin-top: 8px; min-width: 220px; }
.admin-table select { width: auto; padding: 4px 8px; font-size: 13px; }

/* ---------- Ошибки, наверх ---------- */
.error-page { min-height: 80vh; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; }
.error-page h1 { font-size: 64px; margin: 0; color: var(--accent); }
.to-top {
  position: fixed; right: 22px; bottom: 22px; z-index: 40;
  width: 42px; height: 42px; border-radius: 50%;
  background: var(--accent); color: #fff; border: none; font-size: 18px;
  cursor: pointer; box-shadow: var(--shadow);
  opacity: 0; pointer-events: none; transition: opacity .15s ease;
}
.to-top.visible { opacity: 1; pointer-events: auto; }

/* ---------- Адаптив ---------- */
@media (max-width: 960px) {
  .doc-layout { grid-template-columns: 1fr; }
  .sidebar-toggle { display: inline-flex; }
  .sidebar {
    position: fixed; left: 0; top: var(--topbar-h); z-index: 60;
    width: min(300px, 82vw); background: var(--surface);
    border-right: 1px solid var(--border);
    transform: translateX(-102%); transition: transform .18s ease;
    padding: 16px 14px 40px;
  }
  .sidebar.open { transform: translateX(0); }
  .sidebar-backdrop {
    display: none; position: fixed; inset: var(--topbar-h) 0 0 0;
    background: rgba(10, 10, 25, 0.4); z-index: 55;
  }
  .sidebar-backdrop.visible { display: block; }
  .brand-sub { display: none; }
  .search-trigger { min-width: 0; }
  .search-trigger span, .search-trigger kbd { display: none; }
  .user-chip { display: none; }
}

@media (max-width: 560px) {
  .container { padding: 20px 14px 48px; }
  .hero h1 { font-size: 24px; }
  .markdown h1 { font-size: 23px; }
  .markdown h2 { font-size: 19px; }
  body { font-size: 15px; }
}
