:root {
  --bg: oklch(0.975 0.006 85);
  --surface: oklch(0.995 0.003 85);
  --panel: oklch(0.955 0.008 85);
  --line: oklch(0.88 0.01 85);
  --line-strong: oklch(0.78 0.012 85);
  --text: oklch(0.24 0.012 85);
  --muted: oklch(0.5 0.012 85);
  --ink: oklch(0.47 0.15 285);
  --ink-hover: oklch(0.41 0.15 285);
  --ink-soft: oklch(0.95 0.025 285);
  --danger: oklch(0.5 0.17 28);
  --radius: 8px;
  --ui: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, system-ui, sans-serif;
  --paper: "Times New Roman", Times, "Liberation Serif", "Nimbus Roman", serif;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 400 1rem/1.55 var(--ui); }
img, svg { display: block; max-width: 100%; }
a { color: var(--ink); text-underline-offset: 0.18em; text-decoration-thickness: 1px; }
a:hover { color: var(--ink-hover); }
h1, h2, h3 { font-weight: 650; letter-spacing: -0.015em; line-height: 1.2; margin: 0; }
h1 { font-size: 2.25rem; }
h2 { font-size: 1.375rem; }
p { margin: 0 0 1em; }
:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; border-radius: 4px; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: -999px; top: 8px; background: var(--surface); padding: 8px 12px; z-index: 10; }
.skip:focus { left: 8px; }
.muted { color: var(--muted); }
.wrap { max-width: 76rem; margin: 0 auto; padding: 0 24px; }
.wrap-narrow { max-width: 44rem; }
.lead { font-size: 1.125rem; color: var(--muted); max-width: 62ch; margin: 12px 0 0; }

/* Шапка */
.topbar { border-bottom: 1px solid var(--line); background: var(--surface); }
.topbar-inner { display: flex; align-items: center; justify-content: space-between; gap: 24px; min-height: 60px; }
.brand { display: inline-flex; align-items: center; gap: 10px; color: var(--text); text-decoration: none; font-weight: 650; letter-spacing: -0.01em; font-size: 1.0625rem; }
.brand:hover { color: var(--text); }
.brand-mark { width: 28px; height: 28px; }
.topbar-search input { width: 15rem; }

/* Поля и кнопки */
input[type=text], input[type=search], input[type=date], input[type=password], textarea {
  width: 100%; min-height: 44px; padding: 10px 12px; font: inherit; color: var(--text);
  background: var(--surface); border: 1px solid var(--line-strong); border-radius: var(--radius);
  transition: border-color 150ms var(--ease), box-shadow 150ms var(--ease);
}
textarea { resize: vertical; line-height: 1.45; }
input:hover, textarea:hover { border-color: var(--muted); }
input:focus, textarea:focus { outline: none; border-color: var(--ink); box-shadow: 0 0 0 3px var(--ink-soft); }
::placeholder { color: oklch(0.62 0.01 85); }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 10px 18px; font: 600 1rem/1.2 var(--ui); border-radius: var(--radius); border: 1px solid transparent; cursor: pointer; text-decoration: none; transition: background-color 150ms var(--ease), border-color 150ms var(--ease); }
.btn svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.btn-primary { background: var(--ink); color: oklch(0.99 0.004 285); }
.btn-primary:hover { background: var(--ink-hover); color: oklch(0.99 0.004 285); }
.btn-quiet { background: var(--surface); color: var(--text); border-color: var(--line-strong); }
.btn-quiet:hover { border-color: var(--text); color: var(--text); }
.notice { color: var(--danger); }

/* Хлебные крошки и заголовки */
.crumbs { display: flex; flex-wrap: wrap; gap: 6px; padding: 20px 0 0; font-size: 0.875rem; color: var(--muted); }
.crumbs a { color: var(--muted); }
.page-head, .doc-head { padding: 20px 0 28px; }
.doc-head h1 { max-width: 30ch; }

/* Главная */
.home-head { padding: 56px 0 40px; }
.home-head h1 { font-size: 2.5rem; max-width: 22ch; }
.home-search { display: flex; gap: 8px; max-width: 40rem; margin-top: 28px; }
.home-search input { flex: 1; font-size: 1.0625rem; }
.steps { display: flex; flex-wrap: wrap; gap: 8px 28px; list-style: none; padding: 0; margin: 24px 0 0; color: var(--muted); font-size: 0.9375rem; }
.steps b { display: inline-grid; place-items: center; width: 22px; height: 22px; margin-right: 6px; border-radius: 50%; background: var(--panel); color: var(--text); font-size: 0.8125rem; }
.cat-block { padding: 8px 0 32px; }
.cat-block h2 a { color: var(--text); text-decoration: none; }
.cat-block h2 a:hover { color: var(--ink); }
.filter-empty { color: var(--muted); }

/* Списки документов: строки, не карточки */
.doc-list { list-style: none; margin: 12px 0 0; padding: 0; border-top: 1px solid var(--line); columns: 2; column-gap: 40px; }
.doc-list li { break-inside: avoid; border-bottom: 1px solid var(--line); }
.doc-list a { display: flex; flex-direction: column; gap: 2px; padding: 12px 2px; text-decoration: none; color: var(--text); }
.doc-list a:hover .doc-name { color: var(--ink); text-decoration: underline; text-underline-offset: 0.18em; }
.doc-name { font-weight: 500; }
.doc-card { font-size: 0.875rem; color: var(--muted); }

/* Инструмент: форма + лист */
.tool { display: grid; grid-template-columns: minmax(0, 25rem) minmax(0, 1fr); gap: 40px; align-items: start; }
.tool-form { display: flex; flex-direction: column; gap: 16px; }
.field { display: flex; flex-direction: column; gap: 6px; margin: 0; padding: 0; border: 0; min-width: 0; }
.field label, .field legend { font-weight: 600; font-size: 0.9375rem; padding: 0; }
.field legend { margin-bottom: 6px; }
.field-hint { margin: 0; font-size: 0.8125rem; color: var(--muted); }
.trows { display: flex; flex-direction: column; gap: 6px; }
.trow { display: grid; gap: 6px; grid-template-columns: repeat(var(--cols, 1), minmax(0, 1fr)); }
.cols-2 .trow { --cols: 2; }
.cols-3 .trow, .cols-4 .trow, .cols-5 .trow, .cols-6 .trow, .cols-7 .trow, .cols-8 .trow { --cols: 2; padding: 10px; background: var(--panel); border-radius: var(--radius); }
.cols-3 .trow input:last-child:nth-child(odd), .cols-5 .trow input:last-child:nth-child(odd), .cols-7 .trow input:last-child:nth-child(odd) { grid-column: 1 / -1; }
.btn-add { align-self: flex-start; margin-top: 4px; min-height: 36px; padding: 6px 10px; font: 500 0.875rem var(--ui); color: var(--ink); background: none; border: 1px dashed var(--line-strong); border-radius: var(--radius); cursor: pointer; }
.btn-add:hover { border-color: var(--ink); }
.tool-actions { display: flex; flex-wrap: wrap; gap: 10px; padding-top: 8px; }
.tool-actions .btn-primary { flex: 1 1 12rem; }
.tool-note { margin: 0; font-size: 0.8125rem; color: var(--muted); }
.hp { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }

.tool-preview { position: sticky; top: 20px; min-width: 0; }
.preview-label { margin: 0 0 10px; font-size: 0.8125rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; }
.sheet {
  background: oklch(0.998 0.002 85); border: 1px solid var(--line); border-radius: 2px;
  box-shadow: 0 1px 2px oklch(0.3 0.02 85 / 0.06), 0 8px 24px oklch(0.3 0.02 85 / 0.08);
  aspect-ratio: 210 / 297; overflow: hidden; padding: 7% 6% 7% 11%;
  font: 400 clamp(9px, 1.05vw, 13.5px)/1.25 var(--paper); color: oklch(0.15 0.005 85);
}
.sheet-landscape { aspect-ratio: 297 / 210; padding: 5%; }
.sheet p { margin: 0; }
.d-title { text-align: center; font-weight: 700; font-size: 1.17em; margin-bottom: 1.2em !important; }
.d-h { font-weight: 700; margin: 0.5em 0 0.25em !important; }
.d-center { text-align: center; }
.d-row { display: flex; justify-content: space-between; gap: 1em; margin-bottom: 1.2em !important; }
.d-p { margin-bottom: 0.5em !important; }
.d-indent { text-indent: 2.5em; }
.d-align-both { text-align: justify; } .d-align-left { text-align: left; } .d-align-center { text-align: center; } .d-align-right { text-align: right; }
.d-lines { white-space: pre-wrap; }
.d-lines.is-empty { min-height: calc(var(--n, 3) * 1.6em); background: repeating-linear-gradient(to bottom, transparent 0, transparent calc(1.6em - 1px), currentColor calc(1.6em - 1px), currentColor 1.6em); }
.lines-1 { --n: 1; } .lines-2 { --n: 2; } .lines-3 { --n: 3; } .lines-4 { --n: 4; } .lines-5 { --n: 5; } .lines-6 { --n: 6; } .lines-7 { --n: 7; } .lines-8 { --n: 8; }
.d-list { margin: 0 0 0.5em; padding-left: 1.6em; }
.d-table { width: 100%; border-collapse: collapse; margin: 0.4em 0 1em; font-size: 0.85em; table-layout: fixed; }
.d-table th, .d-table td { border: 1px solid currentColor; padding: 0.15em 0.3em; height: 1.6em; vertical-align: top; overflow-wrap: anywhere; }
.d-table th { background: oklch(0.95 0.003 85); font-weight: 700; text-align: center; vertical-align: middle; }
.d-sign { margin-top: 1.6em; display: flex; flex-direction: column; gap: 1em; }
.d-sign-row { display: grid; grid-template-columns: 38% 27% 35%; align-items: end; }
.d-sign-line { text-align: center; }
.d-spacer { height: 1em; }
.sheet .v { white-space: pre-wrap; }
.sheet .v.is-sample { color: oklch(0.55 0.02 285); font-style: italic; }
.sheet .v.is-filled { background: var(--ink-soft); color: oklch(0.3 0.12 285); border-radius: 2px; }

/* Текст под инструментом */
.prose, .faq, .related { max-width: 68ch; padding-top: 48px; }
.related { max-width: none; }
.prose h2, .faq h2, .related h2 { margin-bottom: 12px; }
.prose ul { padding-left: 1.2em; margin: 0 0 1em; }
.faq details { border-top: 1px solid var(--line); padding: 12px 0; }
.faq details:last-child { border-bottom: 1px solid var(--line); }
.faq summary { cursor: pointer; font-weight: 600; }
.faq details p { margin: 8px 0 0; }

/* Подвал */
.footer { margin-top: 72px; border-top: 1px solid var(--line); padding: 28px 0 40px; font-size: 0.875rem; }
.footer-inner { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 16px 32px; }
.footer-inner p { margin: 0; max-width: 60ch; }
.footer-links { display: flex; flex-wrap: wrap; gap: 8px 20px; }
.footer-links a { color: var(--muted); }

/* Юридические страницы */
.legal { max-width: 72ch; }
.legal h2 { font-size: 1.125rem; margin: 28px 0 8px; }

/* Кокпит */
.admin section { margin-bottom: 36px; }
.admin h2 { font-size: 1.125rem; margin-bottom: 10px; }
.admin-head { display: flex; justify-content: space-between; align-items: center; }
.admin-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 32px; }
.table-scroll { overflow-x: auto; }
.admin-table { width: 100%; border-collapse: collapse; font-size: 0.875rem; background: var(--surface); }
.admin-table th, .admin-table td { text-align: left; padding: 6px 10px; border-bottom: 1px solid var(--line); }
.admin-table th { font-weight: 600; color: var(--muted); }
.admin-toggle { display: flex; align-items: center; gap: 16px; margin-bottom: 12px; }
.admin-login { display: flex; flex-direction: column; gap: 16px; max-width: 22rem; }

@media (max-width: 960px) {
  .tool { grid-template-columns: 1fr; }
  .tool-preview { position: static; }
  .sheet { font-size: clamp(7px, 2.1vw, 12px); }
  .admin-cols { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  .wrap { padding: 0 16px; }
  h1, .home-head h1 { font-size: 1.75rem; }
  .home-head { padding: 32px 0 28px; }
  .topbar-search { display: none; }
  .doc-list { columns: 1; }
  .home-search .btn { padding: 10px 14px; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
