:root {
  --bg: #f5f6f8;
  --panel: #ffffff;
  --ink: #1f2430;
  --muted: #6b7280;
  --line: #e5e7eb;
  --brand: #2563eb;
  --brand-ink: #ffffff;
  --danger: #dc2626;
  --ok: #15803d;
  --warn: #b45309;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(16, 24, 40, .08), 0 1px 2px rgba(16, 24, 40, .04);
}

* { box-sizing: border-box; }
body { font-family: system-ui, -apple-system, Segoe UI, Roboto, sans-serif; margin: 0;
  background: var(--bg); color: var(--ink); }

header.app {
  position: sticky; top: 0; z-index: 50;
  background: #111827; color: #fff;
  padding: 10px 20px; display: flex; align-items: center; gap: 16px;
  flex-wrap: wrap; box-shadow: var(--shadow);
}
header.app .brand { font-weight: 700; letter-spacing: .2px; white-space: nowrap; }
header.app .brand a { color: #fff; text-decoration: none; }
nav.app-nav { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; }
nav.app-nav a {
  color: #d1d5db; text-decoration: none; padding: 6px 10px; border-radius: 8px;
  font-size: .92rem; transition: background .15s, color .15s;
}
nav.app-nav a:hover { background: rgba(255,255,255,.12); color: #fff; }
nav.app-nav a.active { background: var(--brand); color: #fff; }
header.app .spacer { flex: 1; }

/* мобильное гамбургер-меню */
.nav-toggle {
  display: none; background: rgba(255, 255, 255, .12); color: #fff; border: 0;
  border-radius: 8px; font-size: 1.3rem; line-height: 1; padding: 6px 12px;
  cursor: pointer;
}
.nav-toggle:hover { background: rgba(255, 255, 255, .22); }

@media (max-width: 860px) {
  header.app { gap: 10px; }
  .nav-toggle { display: inline-block; margin-left: auto; }
  header.app .spacer { display: none; }
  .app-nav.collapse { display: none; flex-basis: 100%; }
  .app-nav.collapse.open {
    display: flex; flex-direction: column; align-items: stretch;
    gap: 2px; padding-top: 6px;
  }
  nav.app-nav a { padding: 10px 12px; }
  main { margin-top: 16px; }
}

main { max-width: 1160px; margin: 22px auto; padding: 0 16px; }

h1 { font-size: 1.5rem; margin: 0 0 14px; }
h2 { font-size: 1.15rem; margin: 0 0 10px; }

.card { background: var(--panel); border-radius: var(--radius); padding: 18px 20px;
  margin-bottom: 16px; box-shadow: var(--shadow); border: 1px solid var(--line); }

table { width: 100%; border-collapse: collapse; font-size: .95rem; }
th, td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { background: #f9fafb; font-weight: 600; color: #374151; }
tbody tr:hover, table tr:hover { background: #fafbff; }

input, select, textarea { padding: 8px 10px; border: 1px solid #cbd5e1; border-radius: 8px;
  font: inherit; background: #fff; color: var(--ink); max-width: 100%; }
input:focus, select:focus, textarea:focus { outline: 2px solid rgba(37,99,235,.35); border-color: var(--brand); }
textarea { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: .88rem; }

button, .btn { background: var(--brand); color: var(--brand-ink); border: 0; border-radius: 8px;
  padding: 8px 14px; cursor: pointer; text-decoration: none; display: inline-block;
  font: inherit; transition: filter .15s, background .15s; }
button:hover, .btn:hover { filter: brightness(1.07); }
.btn-danger { background: var(--danger); }
.btn-gray { background: #4b5563; }
.btn-xs { padding: 3px 9px; font-size: .8rem; }

.error { color: #7f1d1d; background: #fee2e2; border: 1px solid #fecaca;
  padding: 10px 12px; border-radius: 8px; margin-bottom: 12px; }
.notice { color: #14532d; background: #dcfce7; border: 1px solid #bbf7d0;
  padding: 10px 12px; border-radius: 8px; margin-bottom: 12px; word-break: break-all; }
.muted { color: var(--muted); font-size: .9em; }
form.inline { display: inline; }
.w-100 { width: 100%; }
.w-60 { width: 60%; }
.w-90 { width: 90px; }
.w-120 { width: 120px; }
.w-160 { width: 160px; }
.w-260 { width: 260px; }
.w-280 { width: 280px; }
.w-340 { width: 340px; }
.w-420 { width: 420px; }
.table-760 { max-width: 760px; }
.table-800 { max-width: 800px; }
.table-820 { max-width: 820px; }
.table-900 { max-width: 900px; }
.auth-card { max-width: 420px; margin: 60px auto; }
.auth-card-wide { max-width: 480px; margin: 60px auto; }
.form-grid { display: grid; gap: 10px; max-width: 520px; }
.mt-10 { margin-top: 10px; }
.mt-14 { margin-top: 14px; }
.mt-24 { margin-top: 24px; }
.inline-gap { margin: 0 8px; }
.notice-error { background: #fee; border-color: #c99; }
.small-muted { font-size: .85em; }
.small-muted-spaced { font-size: .85em; margin: .4em 0 0; }
.details-spaced { margin-top: 1em; }
.summary-pointer { cursor: pointer; }
.table-spaced { max-width: 760px; margin-top: .6em; }
.result-card { border: 1px solid #eee; border-radius: 6px; padding: 10px 14px; margin-bottom: 10px; }
.result-preview { margin-top: 6px; font-size: .9em; white-space: pre-wrap; }
.key-box { background: #fffbe6; border: 1px solid #e0d8a0; padding: 14px; border-radius: 6px; overflow-x: auto; user-select: all; }
.wiki-source { background: #f8f8f8; padding: 12px; overflow-x: auto; border: 1px solid #eee; border-radius: 4px; white-space: pre-wrap; word-break: break-word; }
.wiki-diff { font-size: .85em; font-family: ui-monospace, monospace; }
.wiki-diff pre { margin: 0; white-space: pre-wrap; }
.copy-buffer { position: fixed; opacity: 0; }
.is-hidden { display: none; }
.mono { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; }

.badge { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: .78rem;
  font-weight: 600; background: #eef2ff; color: #3730a3; }
.badge.critical { background: #fee2e2; color: #991b1b; }
.badge.medium { background: #fef3c7; color: #92400e; }
.badge.low { background: #e5e7eb; color: #374151; }

.scroll-y { max-height: 380px; overflow-y: auto; border: 1px solid var(--line); border-radius: 8px; }
.wiki-list { margin: 0 0 12px; padding: 8px 24px; list-style: none; columns: 2; font-size: .9em; }

/* wiki explorer */
.tree { list-style: none; margin: 0; padding-left: 4px; }
.tree .tree { border-left: 1px dashed #d1d5db; margin-left: 8px; padding-left: 16px; }
.tree li { padding: 3px 0; }
.tree .file-name { color: #1d4ed8; text-decoration: none; }
.tree .file-name:hover { text-decoration: underline; }
.tree .actions { margin-left: 10px; opacity: 0; transition: opacity .15s; white-space: nowrap; }
.tree li:hover .actions, .tree .actions:focus-within { opacity: 1; }
.tree summary { cursor: pointer; user-select: none; font-weight: 600; }
.explorer-toolbar { margin-bottom: 10px; }

/* Markdown article */
.md-body { font-size: 16px; line-height: 1.7; color: #24292f; word-wrap: break-word; }
.md-body h1, .md-body h2, .md-body h3, .md-body h4 { margin: 1.6em 0 .6em; font-weight: 600; line-height: 1.25; }
.md-body h1 { font-size: 2em; padding-bottom: .3em; border-bottom: 1px solid #d8dee4; }
.md-body h2 { font-size: 1.5em; padding-bottom: .3em; border-bottom: 1px solid #d8dee4; }
.md-body h3 { font-size: 1.25em; }
.md-body p { margin: 0 0 1em; }
.md-body a { color: #0969da; text-decoration: none; }
.md-body a:hover { text-decoration: underline; }
.md-body ul, .md-body ol { padding-left: 2em; margin: 0 0 1em; }
.md-body blockquote { margin: 0 0 1em; padding: 0 1em; color: #57606a; border-left: 4px solid #d0d7de; }
.md-body code { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: .875em;
  background: #eff1f3; padding: .15em .35em; border-radius: 4px; }
.md-body pre { position: relative; background: #f6f8fa; border: 1px solid #d8dee4; border-radius: 6px;
  padding: 16px; overflow-x: auto; margin: 0 0 1em; font-family: ui-monospace, Consolas, monospace;
  font-size: .875em; line-height: 1.55; }
.md-body pre code { background: transparent; padding: 0; }
.md-body table { border-collapse: collapse; width: 100%; margin: 0 0 1em; display: block; overflow-x: auto; }
.md-body th, .md-body td { border: 1px solid #d8dee4; padding: 6px 13px; }

.copy-btn { position: absolute; top: 8px; right: 8px; z-index: 5; background: #fff; color: #57606a;
  border: 1px solid #d8dee4; border-radius: 6px; padding: 2px 8px; font-size: .75em; cursor: pointer; opacity: 0;
  transition: opacity .15s; }
.md-body pre:hover .copy-btn { opacity: 1; }
.copy-btn.copied { background: #dafbe1; color: #1a7f37; }

.md-toc { background: #f6f8fa; border: 1px solid #d8dee4; border-radius: 8px; padding: 14px 18px;
  margin-bottom: 16px; font-size: .9em; }
.md-toc summary { cursor: pointer; font-weight: 700; }
.md-toc ul { list-style: none; margin: 8px 0 0; padding-left: 0; }
.md-toc ul ul { padding-left: 1.4em; }
.md-toc a { color: #0969da; text-decoration: none; }

.page-layout { display: grid; grid-template-columns: 1fr 280px; gap: 20px; align-items: start; }
.page-layout .page-toc { position: sticky; top: 76px; max-height: calc(100vh - 96px); overflow-y: auto; }
@media (max-width: 900px) {
  .page-layout { grid-template-columns: 1fr; }
  .page-layout .page-toc { position: static; max-height: none; }
  .wiki-list { columns: 1; }
}

/* pygments-friendly syntax colors kept minimal */
.highlight .k { color: #007020; font-weight: bold; }
.highlight .s, .highlight .s1, .highlight .s2 { color: #4070a0; }
.highlight .c, .highlight .c1 { color: #60a0b0; font-style: italic; }
.highlight .nf { color: #06287e; }
.highlight .nc { color: #0e84b5; font-weight: bold; }
