:root {
  --bg: #f4f5f7;
  --surface: #ffffff;
  --surface-2: #f8f9fb;
  --border: #dfe2e8;
  --border-strong: #c5cad3;
  --text: #1b1f27;
  --muted: #5d6573;
  --accent: #1f4e8c;
  --accent-hover: #183f72;
  --accent-soft: #e8eff9;
  --danger: #b3261e;
  --ok: #1e7a46;
  --warn-bg: #fff3b0;
  --warn-border: #e6c84a;
  --radius: 8px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 2px 8px rgba(16, 24, 40, .06);
  --page-shadow: 0 1px 3px rgba(16, 24, 40, .12), 0 6px 20px rgba(16, 24, 40, .08);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --topbar-h: 56px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #14171c; --surface: #1c2027; --surface-2: #232830; --border: #313844; --border-strong: #434c5a;
    --text: #e7eaf0; --muted: #9aa3b2; --accent: #7fa8e6; --accent-hover: #9bbcf0; --accent-soft: #233149;
    --danger: #f08b84; --ok: #6ccf98; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #14171c; --surface: #1c2027; --surface-2: #232830; --border: #313844; --border-strong: #434c5a;
  --text: #e7eaf0; --muted: #9aa3b2; --accent: #7fa8e6; --accent-hover: #9bbcf0; --accent-soft: #233149;
  --danger: #f08b84; --ok: #6ccf98; color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--text); font: 15px/1.5 var(--font); -webkit-font-smoothing: antialiased; }
[hidden] { display: none !important; }
button, input, select, textarea { font: inherit; color: inherit; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- Кнопки ---------- */
.btn { display: inline-flex; align-items: center; gap: 6px; height: 36px; padding: 0 14px; border-radius: var(--radius);
  border: 1px solid var(--border-strong); background: var(--surface); cursor: pointer; white-space: nowrap; font-weight: 500;
  transition: background-color .15s ease, border-color .15s ease; }
.btn:hover { background: var(--surface-2); }
a.btn { text-decoration: none; color: var(--text); }
a.btn.primary { color: #fff; }
a.btn.ghost { color: var(--accent); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-hover); }
.btn.ghost { border-color: transparent; background: transparent; color: var(--accent); }
.btn.ghost:hover { background: var(--accent-soft); }
.btn.small { height: 30px; padding: 0 10px; font-size: 13px; }
.btn.danger { color: var(--danger); }
.btn:disabled { opacity: .55; cursor: default; }
.icon-btn { width: 30px; height: 30px; border-radius: 6px; border: 1px solid var(--border); background: var(--surface); cursor: pointer; font-size: 16px; line-height: 1; }
.icon-btn:hover { background: var(--surface-2); }

/* ---------- Верхняя панель ---------- */
.topbar { position: sticky; top: 0; z-index: 20; height: var(--topbar-h); display: flex; align-items: center; gap: 12px;
  padding: 0 16px; background: var(--surface); border-bottom: 1px solid var(--border); }
.brand { display: inline-flex; align-items: center; gap: 8px; color: var(--accent); text-decoration: none; font-weight: 700; font-size: 16px; }
.brand span { color: var(--text); }
.topbar-doc { display: flex; align-items: center; gap: 8px; min-width: 0; flex: 1; }
.crumb-sep { color: var(--border-strong); }
.doc-title { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-actions { display: flex; align-items: center; gap: 8px; margin-left: auto; }
.progress { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); }
.progress-bar { width: 96px; height: 6px; border-radius: 3px; background: var(--border); overflow: hidden; }
.progress-bar span { display: block; height: 100%; width: 0; background: var(--ok); transition: width .2s ease; }

.menu-wrap { position: relative; }
.menu { position: absolute; right: 0; top: calc(100% + 6px); width: 280px; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow); padding: 6px; z-index: 30; }
.menu button { display: flex; flex-direction: column; align-items: flex-start; width: 100%; padding: 8px 10px; border: 0; background: none;
  border-radius: 6px; cursor: pointer; text-align: left; }
.menu button:hover, .menu button:focus-visible { background: var(--surface-2); }
.menu button small { color: var(--muted); font-size: 12px; }
.menu button.danger b { color: var(--danger); }
.menu hr { border: 0; border-top: 1px solid var(--border); margin: 6px 0; }

/* ---------- Каталог ---------- */
.catalog { max-width: 1120px; margin: 0 auto; padding: 32px 16px 64px; }
.catalog-head h1 { font-size: 26px; line-height: 1.25; margin: 0 0 4px; }
.catalog-head p { margin: 0 0 16px; }
.search { display: flex; align-items: center; gap: 8px; height: 44px; padding: 0 12px; background: var(--surface);
  border: 1px solid var(--border-strong); border-radius: var(--radius); color: var(--muted); max-width: 560px; }
.search:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.search input { flex: 1; border: 0; outline: 0; background: transparent; height: 100%; color: var(--text); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 16px 0 24px; }
.chip { height: 32px; padding: 0 12px; border-radius: 16px; border: 1px solid var(--border); background: var(--surface); cursor: pointer; font-size: 14px; }
.chip:hover { border-color: var(--border-strong); }
.chip[aria-selected="true"] { background: var(--accent); border-color: var(--accent); color: #fff; }
.chip .count { opacity: .7; margin-left: 4px; }
.recent { margin-bottom: 24px; }
.recent h2, .cat-title { font-size: 13px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin: 0 0 8px; font-weight: 600; }
.cat-title { margin-top: 24px; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.cards .cat-title { grid-column: 1 / -1; }
.card { display: flex; flex-direction: column; gap: 4px; text-align: left; padding: 14px 16px; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); cursor: pointer; transition: border-color .15s ease, box-shadow .15s ease; }
.card:hover { border-color: var(--accent); box-shadow: var(--shadow); }
.card b { font-weight: 600; line-height: 1.35; }
.card small { color: var(--muted); font-size: 13px; }
.card .draft-badge { align-self: flex-start; font-size: 12px; color: var(--ok); }
.empty { text-align: center; padding: 48px 16px; color: var(--muted); }

/* ---------- Редактор ---------- */
.editor { display: grid; grid-template-columns: minmax(360px, 520px) 1fr; height: calc(100vh - var(--topbar-h)); height: calc(100dvh - var(--topbar-h)); }
.pane-form { overflow-y: auto; border-right: 1px solid var(--border); background: var(--surface); padding: 16px 20px 80px; }
.pane-preview { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.mobile-tabs { display: none; }
.tpl-info { font-size: 13px; color: var(--muted); margin-bottom: 12px; }
.tpl-info b { color: var(--text); }

.section { border: 1px solid var(--border); border-radius: var(--radius); margin-bottom: 12px; background: var(--surface); }
.section > summary { list-style: none; display: flex; align-items: center; gap: 10px; padding: 12px 14px; cursor: pointer; font-weight: 600; }
.section > summary::-webkit-details-marker { display: none; }
.section > summary::after { content: ""; margin-left: auto; width: 8px; height: 8px; border-right: 2px solid var(--muted); border-bottom: 2px solid var(--muted);
  transform: rotate(45deg); transition: transform .15s ease; }
.section[open] > summary::after { transform: rotate(-135deg); }
.section .badge { font-weight: 500; font-size: 12px; color: var(--muted); }
.section .badge.done { color: var(--ok); }
.section-body { padding: 0 14px 14px; }

.seg { display: inline-flex; padding: 3px; gap: 2px; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius); margin-bottom: 12px; }
.seg button { height: 30px; padding: 0 12px; border: 0; border-radius: 6px; background: transparent; cursor: pointer; font-size: 14px; }
.seg button[aria-pressed="true"] { background: var(--surface); box-shadow: 0 1px 2px rgba(0,0,0,.12); font-weight: 600; color: var(--accent); }

.profile-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 12px; }
.profile-row select { flex: 1; min-width: 160px; }

.group-title { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; margin: 14px 0 6px; }
.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 12px; }
.field { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.field.wide { grid-column: 1 / -1; }
.field label { font-size: 13px; font-weight: 500; color: var(--text); }
.field label .req { color: var(--danger); margin-left: 2px; }
.input, .field input, .field select, .field textarea {
  width: 100%; height: 38px; padding: 0 10px; border: 1px solid var(--border-strong); border-radius: 6px; background: var(--surface);
  transition: border-color .15s ease, box-shadow .15s ease; }
.field textarea { height: auto; min-height: 76px; padding: 8px 10px; resize: vertical; line-height: 1.45; }
.field input:focus, .field select:focus, .field textarea:focus, .input:focus { outline: 0; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.field.invalid input { border-color: var(--danger); }
.field .err { font-size: 12px; color: var(--danger); }
.field .help { font-size: 12px; color: var(--muted); }
.field.flash input, .field.flash textarea, .field.flash select { box-shadow: 0 0 0 3px var(--warn-border); }

.items { width: 100%; border-collapse: collapse; font-size: 14px; }
.items th { text-align: left; font-size: 12px; color: var(--muted); font-weight: 600; padding: 4px; }
.items td { padding: 3px; vertical-align: top; }
.items input { width: 100%; height: 34px; padding: 0 8px; border: 1px solid var(--border-strong); border-radius: 6px; background: var(--surface); }
.items .num { width: 76px; }
.items .unit { width: 62px; }
.items .sum { text-align: right; white-space: nowrap; padding-top: 10px; color: var(--muted); }
.items-foot { display: flex; justify-content: space-between; align-items: center; margin-top: 8px; }

/* Печать и подпись */
.stamp-list { display: flex; flex-direction: column; gap: 10px; }
.stamp-item { display: grid; grid-template-columns: 64px 1fr; gap: 10px; align-items: center; padding: 8px; border: 1px solid var(--border); border-radius: var(--radius); }
.stamp-thumb { width: 64px; height: 64px; object-fit: contain; border-radius: 6px;
  background: repeating-conic-gradient(#eee 0% 25%, #fff 0% 50%) 50% / 12px 12px; }
.stamp-item .name { font-weight: 500; font-size: 14px; display: flex; justify-content: space-between; gap: 6px; }
.stamp-item .actions { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
.upload-row { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 8px; }
.check { display: flex; gap: 8px; align-items: center; font-size: 13px; color: var(--muted); margin-bottom: 10px; }

/* ---------- Предпросмотр ---------- */
.preview-tools { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 8px 16px; border-bottom: 1px solid var(--border); background: var(--surface); }
.zoom { display: flex; align-items: center; gap: 6px; font-size: 13px; }
.zoom span { min-width: 42px; text-align: center; }
.pages-scroll { flex: 1; overflow: auto; padding: 24px 16px 64px; }
.pages { display: flex; flex-direction: column; align-items: center; gap: 20px; width: max-content; margin: 0 auto; }

.page { position: relative; width: 210mm; height: 297mm; padding: 20mm 15mm 20mm 30mm; background: #fff; color: #000;
  box-shadow: var(--page-shadow); overflow: hidden; flex: none; }
.page.measuring { position: absolute; left: -10000px; top: 0; height: auto; visibility: hidden; }
.page-content { height: 100%; }
.page.measuring .page-content { height: auto; }
.stamp-layer { position: absolute; inset: 0; pointer-events: none; }

/* Типографика документа */
.doc { font-family: "Times New Roman", Times, "Liberation Serif", serif; font-size: 12pt; line-height: 1.35; color: #000; }
.doc h1 { font-size: 14pt; text-align: center; margin: 0 0 10pt; font-weight: 700; }
.doc h2 { font-size: 12pt; text-align: center; margin: 12pt 0 6pt; font-weight: 700; }
.doc h3 { font-size: 12pt; margin: 10pt 0 4pt; font-weight: 700; }
.doc p { margin: 0 0 6pt; text-align: justify; }
.doc ul, .doc ol { margin: 0 0 6pt; padding-left: 18pt; }
.doc li { margin-bottom: 3pt; text-align: justify; }
.doc table { width: 100%; border-collapse: collapse; margin: 0 0 8pt; }
.doc table.grid th, .doc table.grid td { border: 1px solid #000; padding: 2pt 4pt; font-size: 11pt; }
.doc table.grid th { font-weight: 700; }
.doc table.plain th, .doc table.plain td { border: 0; padding: 2pt 6pt 2pt 0; vertical-align: top; width: 50%; font-weight: normal; }
.doc table.plain th strong { font-weight: 700; }
.doc table.headline { margin-bottom: 10pt; }
.doc .blank { letter-spacing: -.5px; }
.doc .ph { background: var(--warn-bg); border-bottom: 1px dashed var(--warn-border); color: #6b5800; padding: 0 2px; border-radius: 2px;
  font-family: var(--font); font-size: 9.5pt; cursor: pointer; }
.doc .ph:hover { background: #ffe680; }

.stamp { position: absolute; pointer-events: auto; }
.stamp img { display: block; width: 100%; height: auto; mix-blend-mode: multiply; user-select: none; }
.stamp.interactive { cursor: grab; outline: 1px dashed transparent; touch-action: none; }
.stamp.interactive:hover, .stamp.interactive.active { outline-color: var(--accent); }
.stamp.interactive.dragging { cursor: grabbing; }
.stamp-del { position: absolute; top: -10px; right: -10px; width: 22px; height: 22px; border-radius: 11px; border: 0; background: var(--danger); color: #fff;
  font-size: 14px; line-height: 22px; padding: 0; cursor: pointer; opacity: 0; transition: opacity .15s ease; }
.stamp-resize { position: absolute; right: -6px; bottom: -6px; width: 14px; height: 14px; border-radius: 3px; background: var(--accent); cursor: nwse-resize; opacity: 0; transition: opacity .15s ease; }
.stamp.interactive:hover .stamp-del, .stamp.interactive:hover .stamp-resize,
.stamp.interactive.active .stamp-del, .stamp.interactive.active .stamp-resize { opacity: 1; }

#export-root { position: fixed; left: -20000px; top: 0; }
#print-root { display: none; }

.loading { position: fixed; inset: var(--topbar-h) 0 0; display: flex; align-items: center; justify-content: center; color: var(--muted); }
.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: #1b1f27; color: #fff; padding: 10px 16px; border-radius: var(--radius);
  box-shadow: var(--shadow); z-index: 50; max-width: calc(100vw - 32px); font-size: 14px; }
.toast.error { background: var(--danger); }

/* ---------- Навигация ---------- */
.topnav { display: flex; gap: 2px; margin-left: 8px; }
.topnav a { padding: 6px 10px; border-radius: 6px; color: var(--muted); text-decoration: none; font-size: 14px; font-weight: 500; white-space: nowrap; }
.topnav a:hover { background: var(--surface-2); color: var(--text); }
.topnav a[aria-current="page"] { color: var(--accent); background: var(--accent-soft); }

/* ---------- Кабинет ---------- */
.cabinet { max-width: 1000px; margin: 0 auto; padding: 32px 16px 64px; }
.cab-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; flex-wrap: wrap; }
.cab-head h1 { font-size: 26px; line-height: 1.25; margin: 0 0 4px; }
.cab-head p { margin: 0; }
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin: 24px 0; }
.stat { display: flex; flex-direction: column; padding: 14px 16px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); text-decoration: none; color: var(--text); }
.stat:hover { border-color: var(--accent); }
.stat b { font-size: 24px; line-height: 1.2; }
.stat span { color: var(--muted); font-size: 13px; }
.cab-tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 16px; overflow-x: auto; scrollbar-width: none; }
.cab-tab { padding: 10px 12px; color: var(--muted); text-decoration: none; font-weight: 500; white-space: nowrap; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.cab-tab:hover { color: var(--text); }
.cab-tab[aria-current="page"] { color: var(--accent); border-bottom-color: var(--accent); }
.cab-tab .count { margin-left: 6px; font-size: 12px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; padding: 0 6px; color: var(--muted); }
.cab-body > p.muted { margin: 0 0 14px; max-width: 70ch; }
.rows { display: flex; flex-direction: column; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
.row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 14px; }
.row + .row { border-top: 1px solid var(--border); }
.row-main { min-width: 0; }
.row-title { font-weight: 600; color: var(--text); text-decoration: none; }
a.row-title:hover { color: var(--accent); }
.row-actions { display: flex; gap: 6px; flex: none; }
.status { font-size: 13px; padding: 2px 8px; border-radius: 10px; background: var(--accent-soft); color: var(--accent); white-space: nowrap; }
.status-draft, .status-cancelled { background: var(--surface-2); color: var(--muted); }
.status-need_docs { background: var(--warn-bg); color: #6b5800; }
.status-ready, .status-delivered { background: color-mix(in srgb, var(--ok) 14%, transparent); color: var(--ok); }
.status-rejected { background: color-mix(in srgb, var(--danger) 12%, transparent); color: var(--danger); }
.editor-card { margin-bottom: 16px; }
.card-title { margin: 0 0 12px; font-size: 16px; }
.stamp-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.stamp-card { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 12px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
.stamp-thumb.big { width: 120px; height: 120px; }
.danger-zone { margin-top: 32px; padding: 14px 16px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
.danger-zone p { margin: 4px 0 10px; }
.btn.danger { color: var(--danger); }


/* ---------- Новые разделы: реквизиты, реестр, пакеты, аккаунт, подпись, ИИ ---------- */
.err { color: var(--danger); }
.err:empty { display: none; }
.linkish { background: none; border: 0; padding: 4px 0; color: var(--accent); cursor: pointer; text-align: left; text-decoration: underline; text-underline-offset: 2px; }
.inn-fill { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 0 0 12px; }
.inn-fill input { width: 190px; height: 32px; padding: 0 10px; border: 1px solid var(--border-strong); border-radius: var(--radius); background: var(--surface); }
.banner { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; margin: 0 0 16px; padding: 10px 14px; border: 1px solid var(--warn-border); border-radius: var(--radius);
  background: color-mix(in srgb, var(--warn-bg) 55%, var(--surface)); color: var(--text); text-decoration: none; }
.banner.bad { border-color: color-mix(in srgb, var(--danger) 45%, transparent); background: color-mix(in srgb, var(--danger) 8%, var(--surface)); }
.banner.ok { border-color: color-mix(in srgb, var(--ok) 45%, transparent); background: color-mix(in srgb, var(--ok) 10%, var(--surface)); }
.banner.install { border-color: var(--border); background: var(--accent-soft); }
.filters { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 12px; }
.filters input, .filters select, .status-select, .plan select, .card-box select, .card-box input:not([type="checkbox"]), .modal input:not([type="checkbox"]), .modal select, .modal textarea {
  height: 34px; padding: 0 10px; border: 1px solid var(--border-strong); border-radius: var(--radius); background: var(--surface); max-width: 100%; }
.modal textarea, .card-box textarea { height: auto; padding: 8px 10px; width: 100%; }
.modal .field input, .modal .field select, .card-box .field input { width: 100%; }
.filters input[type="search"] { flex: 1 1 220px; }
.reg-num { font-variant-numeric: tabular-nums; margin-right: 4px; }
.status-select { height: 30px; font-size: 13px; }
.status-signed, .status-done, .status-select.status-signed, .status-select.status-done { color: var(--ok); }
.status-signing, .status-sent, .status-viewed { color: var(--accent); }
.status-declined, .status-select.status-cancelled { color: var(--danger); }
.due { font-size: 13px; color: var(--muted); }
.due.warn { color: #8a6d00; font-weight: 600; }
.due.bad { color: var(--danger); font-weight: 600; }
.pkg-cards .card.pkg { border-style: dashed; }
.pkg-nav { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 8px; padding-bottom: 8px; border-bottom: 1px solid var(--border); }
.pkg-nav .btn { margin-left: auto; }
.compose { margin: 0 0 20px; padding: 14px 16px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
.compose-title { display: block; font-weight: 600; margin-bottom: 8px; }
.compose-row { display: flex; gap: 8px; align-items: flex-start; }
.compose-row textarea { flex: 1; min-height: 44px; padding: 8px 10px; border: 1px solid var(--border-strong); border-radius: var(--radius); background: var(--surface); resize: vertical; }
.ai-out { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.ai-out p { flex-basis: 100%; margin: 0; }
dialog.modal { width: min(560px, calc(100vw - 32px)); max-height: calc(100vh - 32px); padding: 0; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); color: var(--text); box-shadow: var(--page-shadow); }
dialog.modal::backdrop { background: rgba(10, 14, 22, .45); }
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 18px; border-bottom: 1px solid var(--border); }
.modal-head h2 { margin: 0; font-size: 17px; }
.modal-body { padding: 14px 18px; overflow: auto; max-height: calc(100vh - 180px); }
.modal-body .field { margin-bottom: 12px; }
.modal-body .field label { display: block; margin-bottom: 4px; font-size: 13px; font-weight: 500; }
.modal-body input[readonly] { width: 100%; }
.modal-foot { display: flex; justify-content: flex-end; flex-wrap: wrap; gap: 8px; padding: 12px 18px; border-top: 1px solid var(--border); }
.modal-foot:empty { display: none; }
.risks { display: flex; flex-direction: column; gap: 8px; }
.risk { padding: 10px 12px; border-left: 3px solid var(--border-strong); border-radius: 4px; background: var(--surface-2); }
.risk p { margin: 4px 0 0; }
.risk-high { border-left-color: var(--danger); }
.risk-medium { border-left-color: var(--warn-border); }
.card-box { margin: 0 0 16px; padding: 16px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
.card-box .field { margin-bottom: 10px; }
.card-box .field label { display: block; margin-bottom: 4px; font-size: 13px; font-weight: 500; }
.acc-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 4px; }
.auth-box { max-width: 460px; }
.auth-form .btn.primary { margin-top: 4px; }
.auth-links { display: flex; gap: 16px; margin-top: 12px; }
.plans { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; }
.plan { display: flex; flex-direction: column; gap: 6px; padding: 14px; border: 1px solid var(--border); border-radius: var(--radius); }
.plan.current { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.plan ul { margin: 4px 0 8px; padding-left: 18px; font-size: 13px; color: var(--muted); flex: 1; }
.plan-price { font-size: 18px; font-weight: 600; }
.cert-btn { display: flex; width: 100%; height: auto; min-height: 36px; padding: 8px 12px; margin-bottom: 6px; white-space: normal; text-align: left; }
.sign-doc { margin-bottom: 16px; }
.sign-frame { width: 100%; height: 70vh; border: 1px solid var(--border); border-radius: var(--radius); background: #fff; }
.hash { font-size: 11px; word-break: break-all; }
.bottom-nav { display: none; }
@media (max-width: 640px) {
  body { padding-bottom: calc(60px + env(safe-area-inset-bottom)); }
  .bottom-nav { display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 40; height: calc(58px + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom);
    background: var(--surface); border-top: 1px solid var(--border); }
  .bottom-nav a { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; color: var(--muted); text-decoration: none; font-size: 11px; font-weight: 500; }
  .bottom-nav a[aria-current="page"] { color: var(--accent); }
  body.editing .bottom-nav { display: none; }
  body.editing { padding-bottom: 0; }
  .topnav { overflow-x: auto; scrollbar-width: none; }
  .topnav a[data-nav="cabinet"] { display: none; }
  .compose-row { flex-direction: column; align-items: stretch; }
  .filters > * { flex: 1 1 140px; }
  .row-actions { flex-wrap: wrap; }
  .sign-frame { height: 60vh; }
  .modal-foot .btn { flex: 1 1 auto; justify-content: center; }
}

/* ---------- Адаптив ---------- */
@media (max-width: 1100px) {
  .progress-bar { display: none; }
  #btn-next-empty { display: none; }
}
@media (max-width: 860px) {
  .stats { grid-template-columns: repeat(2, 1fr); }
  .row { flex-wrap: wrap; }
  .editor { display: block; height: auto; }
  .mobile-tabs { display: flex; position: sticky; top: var(--topbar-h); z-index: 10; background: var(--surface); border-bottom: 1px solid var(--border); }
  .mobile-tabs button { flex: 1; height: 44px; border: 0; background: none; font-weight: 600; color: var(--muted); border-bottom: 2px solid transparent; cursor: pointer; }
  .mobile-tabs button[aria-selected="true"] { color: var(--accent); border-bottom-color: var(--accent); }
  .pane-form { border-right: 0; padding: 16px 16px 80px; overflow: visible; }
  .editor[data-pane="form"] .pane-preview, .editor[data-pane="preview"] .pane-form { display: none; }
  .pages-scroll { padding: 16px 8px 64px; }
  .preview-tools #preview-hint { display: none; }
  .topbar-doc { display: none; }
  .progress { display: none; }
}
@media (max-width: 640px) {
  #view-editor:not([hidden]) ~ * .topnav, body.editing .topnav { display: none; }
  .topnav a { padding: 6px 7px; font-size: 13px; }
}
@media (max-width: 480px) {
  .grid { grid-template-columns: 1fr; }
  .brand span { display: none; }
  .catalog-head h1 { font-size: 22px; }
  .cards { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }

/* ---------- Печать ---------- */
@page { size: A4; margin: 0; }
@media print {
  body > *:not(#print-root) { display: none !important; }
  body { background: #fff; }
  #print-root { display: block; }
  #print-root .page { box-shadow: none; margin: 0; page-break-after: always; break-after: page; }
  #print-root .page:last-child { page-break-after: auto; break-after: auto; }
}

.more-btn { white-space: normal; height: auto; min-height: 30px; padding: 6px 10px; text-align: left; margin-top: 10px; }
.items-wrap { overflow-x: auto; }
