/* База знаний СмартАптека — оформление интерфейса.
   Фирменные цвета: зелёный #239353, тёмно-синий #1e3a6e. Шрифт Inter (локальные файлы). */
@font-face { font-family: Inter; font-weight: 400; font-display: swap; src: url(fonts/inter-cyrillic-400-normal.woff2) format("woff2"); unicode-range: U+0400-04FF; }
@font-face { font-family: Inter; font-weight: 400; font-display: swap; src: url(fonts/inter-latin-400-normal.woff2) format("woff2"); unicode-range: U+0000-00FF, U+2000-206F, U+2190-21FF, U+20AC; }
@font-face { font-family: Inter; font-weight: 500; font-display: swap; src: url(fonts/inter-cyrillic-500-normal.woff2) format("woff2"); unicode-range: U+0400-04FF; }
@font-face { font-family: Inter; font-weight: 500; font-display: swap; src: url(fonts/inter-latin-500-normal.woff2) format("woff2"); unicode-range: U+0000-00FF, U+2000-206F, U+2190-21FF; }
@font-face { font-family: Inter; font-weight: 600; font-display: swap; src: url(fonts/inter-cyrillic-600-normal.woff2) format("woff2"); unicode-range: U+0400-04FF; }
@font-face { font-family: Inter; font-weight: 600; font-display: swap; src: url(fonts/inter-latin-600-normal.woff2) format("woff2"); unicode-range: U+0000-00FF, U+2000-206F, U+2190-21FF; }
@font-face { font-family: Inter; font-weight: 700; font-display: swap; src: url(fonts/inter-cyrillic-700-normal.woff2) format("woff2"); unicode-range: U+0400-04FF; }
@font-face { font-family: Inter; font-weight: 700; font-display: swap; src: url(fonts/inter-latin-700-normal.woff2) format("woff2"); unicode-range: U+0000-00FF, U+2000-206F, U+2190-21FF; }

:root {
  --green: #239353; --green-dark: #1a6e3e; --green-tint: #e8f4ed; --green-line: #bfe0cc;
  --navy: #1e3a6e; --navy-tint: #e9eef7;
  --red: #c62828; --red-tint: #fdeeee; --amber: #b26a00; --amber-tint: #fff5e1; --grey-tint: #eef1f5;
  --ink: #1d2433; --muted: #5d6677; --line: #dfe3ea; --bg: #f6f8fa; --paper: #ffffff; --code: #f4f6f9;
  --head: var(--navy); --link: var(--green-dark); --shadow: 0 1px 2px rgba(20,30,50,.06), 0 4px 16px rgba(20,30,50,.05);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --green: #3fb672; --green-dark: #5fcf8e; --green-tint: #15301f; --green-line: #2b5a3c;
    --navy: #9db8ea; --navy-tint: #1b2740;
    --red: #ef6b6b; --red-tint: #3a1c1c; --amber: #e0a43a; --amber-tint: #362a12; --grey-tint: #232a36;
    --ink: #e4e8ef; --muted: #9aa4b5; --line: #2c3442; --bg: #11151c; --paper: #171c25; --code: #1f2633;
    --head: #c9d7f2; --link: #6fd69a; --shadow: none; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --green: #3fb672; --green-dark: #5fcf8e; --green-tint: #15301f; --green-line: #2b5a3c;
  --navy: #9db8ea; --navy-tint: #1b2740;
  --red: #ef6b6b; --red-tint: #3a1c1c; --amber: #e0a43a; --amber-tint: #362a12; --grey-tint: #232a36;
  --ink: #e4e8ef; --muted: #9aa4b5; --line: #2c3442; --bg: #11151c; --paper: #171c25; --code: #1f2633;
  --head: #c9d7f2; --link: #6fd69a; --shadow: none; color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 16px/1.6 Inter, system-ui, "Segoe UI", sans-serif; }
a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { color: var(--head); line-height: 1.2; letter-spacing: -.01em; }
img { max-width: 100%; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.nowrap { white-space: nowrap; }

/* ---------- шапка ---------- */
.topbar { position: sticky; top: 0; z-index: 20; background: var(--paper); border-bottom: 1px solid var(--line); }
.topbar .in { max-width: 1240px; margin: 0 auto; padding: 0 16px; height: 60px; display: flex; align-items: center; gap: 18px; }
.brand { display: flex; align-items: center; gap: 10px; color: var(--head); font-weight: 700; white-space: nowrap; }
.brand img { height: 30px; }
:root[data-theme="dark"] .brand img { background: #fff; border-radius: 7px; padding: 2px 5px; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .brand img { background: #fff; border-radius: 7px; padding: 2px 5px; } }
.brand span { font-size: .8rem; color: var(--muted); font-weight: 500; border-left: 1px solid var(--line); padding-left: 10px; }
.topsearch { flex: 1; max-width: 520px; }
.topsearch input { width: 100%; padding: 9px 14px; border-radius: 10px; border: 1px solid var(--line); background: var(--bg); color: var(--ink); font: inherit; }
.nav { display: flex; gap: 4px; align-items: center; margin-left: auto; }
.nav a, .nav button.link { padding: 7px 10px; border-radius: 8px; color: var(--ink); font-size: .92rem; white-space: nowrap; }
.nav a:hover { background: var(--bg); text-decoration: none; }
.nav .menu { position: relative; }
.nav .menu > summary { list-style: none; cursor: pointer; padding: 7px 10px; border-radius: 8px; font-size: .92rem; }
.nav .menu > summary::-webkit-details-marker { display: none; }
.nav .menu[open] > div { position: absolute; right: 0; top: 40px; background: var(--paper); border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow); min-width: 220px; padding: 6px; display: flex; flex-direction: column; }
.nav .menu[open] > div a, .nav .menu[open] > div button { text-align: left; }
.navtoggle { display: none; }
@media (max-width: 900px) {
  .brand span { display: none; }
  .nav { display: none; position: absolute; top: 60px; left: 0; right: 0; background: var(--paper); border-bottom: 1px solid var(--line); flex-direction: column; align-items: stretch; padding: 8px; }
  .nav.open { display: flex; }
  .navtoggle { display: block; margin-left: auto; }
  .nav .menu[open] > div { position: static; box-shadow: none; }
}

/* ---------- раскладка ---------- */
.wrap { max-width: 1240px; margin: 0 auto; padding: 24px 16px 64px; }
.grid { display: grid; grid-template-columns: 260px 1fr; gap: 32px; }
@media (max-width: 900px) { .grid { grid-template-columns: 1fr; } }
.card { background: var(--paper); border: 1px solid var(--line); border-radius: 14px; padding: 20px 22px; box-shadow: var(--shadow); }
.card + .card { margin-top: 16px; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 14px; }
.tile { display: block; background: var(--paper); border: 1px solid var(--line); border-radius: 14px; padding: 16px 18px; color: var(--ink); }
.tile:hover { border-color: var(--green); text-decoration: none; }
.tile b { color: var(--head); display: block; font-size: 1.05rem; }
.flash { background: var(--green-tint); border: 1px solid var(--green-line); color: var(--ink); border-radius: 10px; padding: 10px 14px; margin-bottom: 16px; }
.flash.err { background: var(--red-tint); border-color: var(--red); }
.crumbs { font-size: .85rem; color: var(--muted); margin-bottom: 8px; }
.crumbs a { color: var(--muted); }
.side h4 { margin: 0 0 8px; font-size: .78rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
.side ul { list-style: none; margin: 0; padding: 0; }
.side li a { display: flex; justify-content: space-between; padding: 6px 10px; border-radius: 8px; color: var(--ink); }
.side li a:hover { background: var(--paper); text-decoration: none; }
.side li ul { margin-left: 12px; }

/* ---------- кнопки и формы ---------- */
.btn, button { display: inline-flex; align-items: center; gap: 6px; padding: 8px 14px; border-radius: 9px; border: 1px solid var(--line); background: var(--paper); color: var(--ink); font: inherit; font-size: .92rem; cursor: pointer; text-decoration: none; }
.btn:hover, button:hover { border-color: var(--green); text-decoration: none; }
.btn.primary, button.primary { background: var(--green); border-color: var(--green); color: #fff; font-weight: 600; }
.btn.primary:hover, button.primary:hover { background: var(--green-dark); }
.btn.danger, button.danger { color: var(--red); }
button.link { background: none; border: 0; padding: 0; color: var(--link); }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.spacer { flex: 1; }
label { display: block; font-size: .85rem; color: var(--muted); margin: 10px 0 4px; font-weight: 500; }
input[type=text], input[type=password], input[type=number], input[type=date], input[type=email], input[type=search], select, textarea {
  width: 100%; padding: 9px 12px; border: 1px solid var(--line); border-radius: 9px; background: var(--paper); color: var(--ink); font: inherit; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--green-line); border-color: var(--green); }
.fields { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 0 16px; }
.checks { display: flex; flex-wrap: wrap; gap: 6px 14px; }
.checks label { display: inline-flex; gap: 6px; align-items: center; margin: 0; color: var(--ink); font-size: .9rem; }
table.list { width: 100%; border-collapse: collapse; font-size: .92rem; }
table.list th { text-align: left; font-size: .75rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); padding: 8px 10px; border-bottom: 1px solid var(--line); }
table.list td { padding: 9px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
.tablewrap { overflow-x: auto; }
.pill { display: inline-block; font-size: .72rem; font-weight: 600; padding: 2px 8px; border-radius: 20px; background: var(--grey-tint); color: var(--muted); white-space: nowrap; }
.pill.l1 { background: var(--green-tint); color: var(--green-dark); }
.pill.l2 { background: var(--amber-tint); color: var(--amber); }
.pill.l3 { background: var(--navy-tint); color: var(--navy); }
.pill.draft { background: var(--amber-tint); color: var(--amber); }
.pill.err { background: var(--red-tint); color: var(--red); }

/* ---------- статья: «журнальный» вид ---------- */
.article { max-width: 820px; margin: 0 auto; }
.article-head { margin-bottom: 26px; }
.article-head .eyebrow { font-size: .78rem; letter-spacing: .14em; text-transform: uppercase; color: var(--green); font-weight: 600; }
.article-head h1 { font-size: clamp(1.9rem, 3.4vw, 2.6rem); margin: 6px 0 12px; }
.article-head .lead { font-size: 1.18rem; color: var(--muted); margin: 0 0 16px; }
.meta { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); border: 1px solid var(--green-line); border-radius: 12px; overflow: hidden; background: var(--green-tint); }
.meta div { padding: 9px 14px; border-right: 1px solid var(--green-line); border-bottom: 1px solid var(--green-line); margin: 0 -1px -1px 0; }
.meta .k { display: block; font-size: .7rem; text-transform: uppercase; letter-spacing: .08em; color: var(--green-dark); font-weight: 600; }
.meta .v { font-weight: 600; color: var(--head); font-size: .92rem; }
.prose { font-size: 1.04rem; line-height: 1.7; }
.prose h2 { font-size: 1.55rem; margin: 2.2em 0 .6em; padding-top: .6em; border-top: 1px solid var(--line); }
.prose h3 { font-size: 1.2rem; margin: 1.6em 0 .5em; }
.prose p { margin: 0 0 1em; }
.prose b, .prose strong { color: var(--head); font-weight: 600; }
.prose code, .prose .val { font-family: "JetBrains Mono", Consolas, "DejaVu Sans Mono", monospace; font-size: .88em; background: var(--code); border: 1px solid var(--line); border-radius: 5px; padding: 0 5px; }
.prose pre { font-family: Consolas, "DejaVu Sans Mono", monospace; font-size: .9rem; background: #1f2633; color: #e8edf5; border-radius: 10px; padding: 14px 18px; overflow-x: auto; }
.prose pre code { background: none; border: 0; padding: 0; color: inherit; }
.prose table { width: 100%; border-collapse: collapse; margin: 1em 0 1.4em; font-size: .95rem; display: block; overflow-x: auto; }
.prose th { text-align: left; background: var(--green-tint); color: var(--green-dark); font-size: .78rem; text-transform: uppercase; letter-spacing: .05em; padding: 8px 10px; border-bottom: 2px solid var(--green-line); }
.prose td { padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
.prose figure { margin: 1.6em 0 2em; text-align: center; }
.prose figure img { display: block; margin: 0 auto; max-height: 640px; border: 2px solid #1e3a6e; border-radius: 4px; background: #fff; }
.prose figcaption { font-size: .88rem; color: var(--muted); margin-top: 8px; padding: 0 5%; }
.prose figcaption strong, .prose figcaption b { color: var(--head); }
.prose .path { display: inline-block; background: var(--code); border: 1px solid var(--line); border-radius: 6px; padding: 1px 9px; font-weight: 600; font-size: .94em; color: var(--head); }
.prose .path i { font-style: normal; color: var(--green); padding: 0 4px; }
.prose .copy-l { font-size: .8rem; color: var(--muted); margin: 12px 0 3px; font-weight: 600; }
.prose .copy { position: relative; font-family: Consolas, "DejaVu Sans Mono", monospace; font-size: .92rem; white-space: nowrap; overflow-x: auto; background: var(--paper); border: 1px solid var(--line); border-radius: 6px; padding: 7px 70px 7px 12px; margin-bottom: 10px; }
.prose .copy button.cp { position: absolute; right: 4px; top: 3px; font-size: .75rem; padding: 3px 8px; font-family: Inter, sans-serif; }
.prose .n { display: inline-flex; align-items: center; justify-content: center; width: 1.25em; height: 1.25em; border: 1.5px solid var(--red); color: var(--red); border-radius: 50%; font-size: .75em; font-weight: 700; vertical-align: .1em; }
.prose .status { font-weight: 600; white-space: nowrap; color: var(--head); }
.note { border-radius: 10px; padding: 12px 16px 12px 50px; margin: 1em 0 1.3em; position: relative; }
.note::before { position: absolute; left: 15px; top: 13px; width: 22px; height: 22px; border-radius: 50%; color: #fff; font-weight: 700; font-size: 13px; display: flex; align-items: center; justify-content: center; }
.note .t { display: block; font-weight: 700; font-size: .75rem; text-transform: uppercase; letter-spacing: .06em; margin-bottom: 2px; }
.note.imp { background: var(--red-tint); border-left: 3px solid var(--red); } .note.imp::before { content: "!"; background: var(--red); } .note.imp .t { color: var(--red); }
.note.lim { background: var(--amber-tint); border-left: 3px solid var(--amber); } .note.lim::before { content: "i"; background: var(--amber); } .note.lim .t { color: var(--amber); }
.note.tip { background: var(--green-tint); border-left: 3px solid var(--green); } .note.tip::before { content: "✓"; background: var(--green); } .note.tip .t { color: var(--green-dark); }
.note.uns { background: var(--grey-tint); border-left: 3px solid var(--muted); } .note.uns::before { content: "×"; background: var(--muted); } .note.uns .t { color: var(--muted); }
.note p:last-child { margin-bottom: 0; }
.article-actions { display: flex; gap: 8px; flex-wrap: wrap; margin: 18px 0 0; }
.toc { position: sticky; top: 84px; font-size: .88rem; }
.toc a { display: block; color: var(--muted); padding: 3px 0; }
.article-grid { display: grid; grid-template-columns: minmax(0, 1fr) 220px; gap: 40px; }
@media (max-width: 1100px) { .article-grid { grid-template-columns: 1fr; } .toc { display: none; } }

/* ---------- поиск ---------- */
.result { padding: 14px 0; border-bottom: 1px solid var(--line); }
.result h3 { margin: 0 0 4px; font-size: 1.08rem; }
.result mark, mark { background: #fff1a8; color: #1d2433; border-radius: 3px; padding: 0 2px; }
:root[data-theme="dark"] mark { background: #6b5d12; color: #fff; }

/* ---------- сравнение версий ---------- */
.diff div { padding: 3px 10px; border-left: 3px solid transparent; font-size: .95rem; white-space: pre-wrap; }
.diff .del { background: var(--red-tint); border-left-color: var(--red); }
.diff .ins { background: var(--green-tint); border-left-color: var(--green); }
.diff mark.del { background: rgba(198,40,40,.25); color: inherit; text-decoration: line-through; }
.diff mark.ins { background: rgba(35,147,83,.3); color: inherit; }

/* ---------- редактор ---------- */
.editor-shell { border: 1px solid var(--line); border-radius: 14px; background: var(--paper); }
.toolbar { position: sticky; top: 60px; z-index: 10; display: flex; flex-wrap: wrap; gap: 4px; padding: 8px; border-bottom: 1px solid var(--line); background: var(--paper); border-radius: 14px 14px 0 0; }
.toolbar button { padding: 5px 9px; font-size: .84rem; }
.toolbar button.on { background: var(--green-tint); border-color: var(--green); }
.toolbar .sep { width: 1px; background: var(--line); margin: 0 4px; }
.ProseMirror { min-height: 480px; padding: 24px 32px; outline: none; }
.ProseMirror figure { border: 1px dashed transparent; }
.ProseMirror figure.ProseMirror-selectednode { border-color: var(--green); }
.ProseMirror .note, .ProseMirror .copy { outline: 1px dashed transparent; }
.ProseMirror p.is-editor-empty:first-child::before { content: attr(data-placeholder); color: var(--muted); float: left; height: 0; pointer-events: none; }
.edit-grid { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 24px; }
@media (max-width: 1100px) { .edit-grid { grid-template-columns: 1fr; } }
.savestate { font-size: .82rem; color: var(--muted); }

/* ---------- вход ---------- */
.login { max-width: 400px; margin: 9vh auto; }
.login .brand { justify-content: center; margin-bottom: 22px; }
.login .brand img { height: 46px; }

footer.foot { text-align: center; color: var(--muted); font-size: .8rem; padding: 24px 16px 40px; }
@media print { .topbar, .article-actions, .toc, footer.foot { display: none; } body { background: #fff; } }
.coll-list { padding-left: 22px; }
.coll-list li { display: grid; grid-template-columns: 1fr 1fr auto; gap: 10px; align-items: center; padding: 6px 0; border-bottom: 1px solid var(--line); }
@media (max-width: 800px) { .coll-list li { grid-template-columns: 1fr; } }
details.btn > form { text-align: left; }

/* ---------- блоки готовых инструкций (как в эталонном PDF) ---------- */
.prose h4 { font-size: 1.02rem; margin: 0 0 .4em; color: var(--head); }
.prose h3 { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.prose .chip { font-size: .7rem; font-weight: 600; letter-spacing: .05em; text-transform: uppercase; color: var(--green-dark); background: var(--green-tint); border: 1px solid var(--green-line); border-radius: 20px; padding: 2px 9px; white-space: nowrap; }
.prose .todo, .prose .todo-p { background: #fff3a8; color: #7a5a00; font-weight: 600; font-size: .85em; padding: 0 4px; border-radius: 4px; }
.prose .twocol { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; align-items: start; margin: 1em 0 1.3em; }
@media (max-width: 760px) { .prose .twocol { grid-template-columns: 1fr; } }
.prose .card { border: 1px solid var(--line); border-radius: 12px; padding: 12px 16px; background: var(--paper); }
.prose .card > :last-child { margin-bottom: 0; }
.prose ol.steps { list-style: none; padding-left: 0; counter-reset: s; }
.prose ol.steps > li { counter-increment: s; position: relative; padding-left: 34px; margin-bottom: 8px; }
.prose ol.steps > li::before { content: counter(s); position: absolute; left: 0; top: 2px; width: 22px; height: 22px; border-radius: 50%; border: 1.5px solid var(--green); color: var(--green); font-size: .78rem; font-weight: 700; display: flex; align-items: center; justify-content: center; }
.prose pre .on { color: #7ee2a8; font-weight: 700; }
.prose pre .cm { color: #8a94a8; }
.prose .yes { color: var(--green-dark); font-weight: 600; }
.prose .no { color: var(--muted); }
.prose td.req { white-space: nowrap; }
.prose figure.flow img { border: 0; background: transparent; max-height: none; max-width: 100%; }
:root[data-theme="dark"] .prose figure.flow img { background: #fff; border-radius: 8px; padding: 6px; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .prose figure.flow img { background: #fff; border-radius: 8px; padding: 6px; } }
.prose figcaption:empty { display: none; }
.ProseMirror pre { cursor: pointer; }
.prose .road { list-style: none; margin: 0 0 1em; padding: 0; counter-reset: r; }
.prose .road li { counter-increment: r; position: relative; padding: 6px 0 6px 44px; border-left: 2px solid var(--green-line); margin-left: 14px; }
.prose .road li:last-child { border-left-color: transparent; }
.prose .road li::before { content: counter(r); position: absolute; left: -15px; top: 4px; width: 28px; height: 28px; border-radius: 50%; background: var(--green); color: #fff; font-weight: 700; font-size: .85rem; display: flex; align-items: center; justify-content: center; }
.prose .road .where { color: var(--muted); font-size: .88em; }
.prose .road .goto { float: right; font-size: .82em; color: var(--green-dark); font-weight: 600; }
/* подгонка размеров скриншотов под страницы PDF (max-height в мм) на сайте не действует */
.prose figure img { max-height: 640px !important; }
.prose figure.flow img { max-height: none !important; }

/* абзац внутри пункта списка (так сохраняет редактор) — без лишнего отступа */
.prose li > p:last-child { margin-bottom: 0; }
.note > div > p:last-child, .prose .card p:last-child { margin-bottom: 0; }

.style-issues { list-style: none; padding: 0; margin: 0; font-size: .88rem; }
.style-issues li { padding: 6px 0 6px 12px; border-left: 3px solid var(--amber); margin-bottom: 6px; }
.style-issues li.error { border-left-color: var(--red); }
.bulkbar { position: sticky; bottom: 0; z-index: 5; }
