:root {
  --bg: #f4f6fa;
  --surface: #ffffff;
  --ink: #16202e;
  --muted: #5c6b80;
  --line: #dde3ec;
  --accent: #2563eb;
  --accent-dark: #1d4ed8;
  --accent-soft: #eaf1ff;
  --good: #0f7a4d;
  --good-soft: #e6f5ee;
  --warn: #9a5b00;
  --warn-soft: #fdf1dd;
  --bad: #b3261e;
  --bad-soft: #fdeceb;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(16, 32, 56, .06), 0 8px 24px rgba(16, 32, 56, .06);
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.55 -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
}

a { color: var(--accent); }
a:hover { color: var(--accent-dark); }

h1, h2, h3 { line-height: 1.25; margin: 0 0 .6rem; }
h1 { font-size: 1.6rem; }
h2 { font-size: 1.25rem; }
h3 { font-size: 1.05rem; }
p { margin: 0 0 .8rem; }

.wrap { max-width: 1040px; margin: 0 auto; padding: 0 16px; }
.wrap-narrow { max-width: 640px; margin: 0 auto; padding: 0 16px; }
.wrap-wide { max-width: 1400px; margin: 0 auto; padding: 0 16px; }

/* ── шапка ─────────────────────────────────────────────── */
.top {
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 40;
}
.top-in {
  display: flex; align-items: center; gap: 18px;
  min-height: 58px; flex-wrap: wrap;
}
.brand {
  font-weight: 700; font-size: 1.05rem; color: var(--ink);
  text-decoration: none; display: flex; align-items: center; gap: 9px;
}
.brand-mark {
  width: 28px; height: 28px; border-radius: 8px; flex: none;
  background: linear-gradient(135deg, var(--accent), #7c3aed);
  color: #fff; display: grid; place-items: center; font-size: .85rem;
}
.nav { display: flex; gap: 4px; margin-left: auto; align-items: center; flex-wrap: wrap; }
.nav a, .nav button {
  color: var(--muted); text-decoration: none; padding: 7px 11px;
  border-radius: 8px; font-size: .93rem; border: 0; background: none;
  cursor: pointer; font-family: inherit;
}
.nav a:hover, .nav button:hover { background: var(--bg); color: var(--ink); }
.nav a.on { background: var(--accent-soft); color: var(--accent-dark); font-weight: 600; }
.pip {
  display: inline-block; min-width: 18px; padding: 0 5px; margin-left: 5px;
  background: var(--bad); color: #fff; border-radius: 9px;
  font-size: .72rem; line-height: 18px; text-align: center; font-weight: 700;
}

main { padding: 26px 0 60px; }

/* ── карточки ──────────────────────────────────────────── */
.card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 18px; margin-bottom: 16px;
}
.card-tight { padding: 14px; }
.card h2:first-child, .card h3:first-child { margin-top: 0; }
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.row-end { justify-content: flex-end; }
.spread { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; flex-wrap: wrap; }
.muted { color: var(--muted); }
.small { font-size: .88rem; }
.tiny { font-size: .8rem; }
.stack > * + * { margin-top: 12px; }

/* ── кнопки ────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  padding: 10px 16px; border-radius: 9px; border: 1px solid transparent;
  background: var(--accent); color: #fff; font: inherit; font-weight: 600;
  font-size: .95rem; cursor: pointer; text-decoration: none; text-align: center;
}
.btn:hover { background: var(--accent-dark); color: #fff; }
.btn:disabled, .btn[aria-disabled='true'] { opacity: .5; cursor: not-allowed; }
.btn-ghost { background: var(--surface); color: var(--ink); border-color: var(--line); }
.btn-ghost:hover { background: var(--bg); color: var(--ink); }
.btn-quiet { background: none; color: var(--muted); border-color: transparent; padding: 8px 10px; }
.btn-quiet:hover { background: var(--bg); color: var(--ink); }
.btn-bad { background: var(--bad); }
.btn-bad:hover { background: #8f1e17; }
.btn-good { background: var(--good); }
.btn-good:hover { background: #0b5c3a; }
.btn-sm { padding: 6px 11px; font-size: .86rem; }
.btn-wide { width: 100%; }

/* ── метки статусов ────────────────────────────────────── */
.tag {
  display: inline-block; padding: 3px 10px; border-radius: 999px;
  font-size: .8rem; font-weight: 600; background: var(--bg); color: var(--muted);
  border: 1px solid var(--line); white-space: nowrap;
}
.tag-good { background: var(--good-soft); color: var(--good); border-color: #bfe5d3; }
.tag-warn { background: var(--warn-soft); color: var(--warn); border-color: #f2d9ae; }
.tag-bad { background: var(--bad-soft); color: var(--bad); border-color: #f3c9c6; }
.tag-info { background: var(--accent-soft); color: var(--accent-dark); border-color: #c5d9fb; }

/* ── формы ─────────────────────────────────────────────── */
.field { margin-bottom: 14px; }
.choice-radios > div, .choice-checkboxes > div { margin: 8px 0; }
.choice-radios label, .choice-checkboxes label { display: flex; align-items: flex-start; gap: 9px; cursor: pointer; }
.choice-radios input[type=radio], .choice-checkboxes input[type=checkbox] { flex: none; margin: 4px 0 0; }
.field > label {
  display: block; font-weight: 600; font-size: .9rem; margin-bottom: 5px;
}
.field .req { color: var(--bad); }
input[type=text], input[type=email], input[type=password], input[type=date],
input[type=number], input[type=tel], input[type=search], select, textarea {
  width: 100%; padding: 10px 12px; border: 1px solid var(--line);
  border-radius: 9px; font: inherit; background: #fff; color: var(--ink);
}
textarea { resize: vertical; min-height: 44px; }
input:focus, select:focus, textarea:focus {
  outline: 2px solid var(--accent); outline-offset: 0; border-color: var(--accent);
}
.hint { color: var(--muted); font-size: .84rem; margin-top: 4px; }
.err { color: var(--bad); font-size: .86rem; margin-top: 4px; font-weight: 600; }
.check { display: flex; gap: 9px; align-items: flex-start; margin-bottom: 8px; font-size: .95rem; }
.check input { margin-top: 4px; flex: none; }
ul.checklist { list-style: none; padding: 0; margin: 0; }
ul.checklist li { margin-bottom: 8px; }
ul.checklist label { display: flex; gap: 9px; align-items: flex-start; }

/* ── сообщения ─────────────────────────────────────────── */
.flash { border-radius: var(--radius); padding: 12px 15px; margin-bottom: 14px;
  border: 1px solid; font-size: .95rem; }
.flash-success { background: var(--good-soft); border-color: #bfe5d3; color: #0b5c3a; }
.flash-error { background: var(--bad-soft); border-color: #f3c9c6; color: #8f1e17; }
.flash-warning { background: var(--warn-soft); border-color: #f2d9ae; color: #7a4700; }
.flash-info { background: var(--accent-soft); border-color: #c5d9fb; color: var(--accent-dark); }

.note {
  background: var(--accent-soft); border: 1px solid #c5d9fb; color: #17325c;
  border-radius: var(--radius); padding: 13px 15px; font-size: .93rem;
}
.note-warn { background: var(--warn-soft); border-color: #f2d9ae; color: #7a4700; }

/* Release note shown only to administrators until it is acknowledged. */
.staff-update-banner {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 24px;
  margin: 0 0 20px; padding: 22px 24px; border: 1px solid #b9c9f8;
  border-left: 6px solid var(--accent); border-radius: 16px;
  background: linear-gradient(135deg, #f4f7ff 0%, #fff 72%);
  box-shadow: 0 10px 28px #183b7b12;
}
.staff-update-kicker { color: var(--accent-dark); font-size: .8rem; font-weight: 750; letter-spacing: .04em; text-transform: uppercase; }
.staff-update-banner h2 { margin: 5px 0 10px; font-size: 1.25rem; }
.staff-update-banner ul { margin: 0; padding-left: 20px; }
.staff-update-banner li { margin: 5px 0; line-height: 1.45; }
.staff-update-actions { display: flex; flex-direction: column; align-items: stretch; gap: 9px; min-width: 205px; }
.staff-update-actions .btn { width: 100%; justify-content: center; }
.staff-update-actions form { margin: 0; }
@media (max-width: 760px) {
  .staff-update-banner { grid-template-columns: 1fr; padding: 18px; gap: 16px; }
  .staff-update-actions { min-width: 0; }
}

/* ── таблицы и списки ──────────────────────────────────── */
table.list { width: 100%; border-collapse: collapse; font-size: .93rem; }
table.list th {
  text-align: left; color: var(--muted); font-size: .8rem; font-weight: 600;
  text-transform: uppercase; letter-spacing: .04em; padding: 8px 10px;
  border-bottom: 1px solid var(--line);
}
table.list td { padding: 11px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
table.list tr:last-child td { border-bottom: 0; }
table.list tr:hover td { background: #fafbfe; }

dl.kv { display: grid; grid-template-columns: minmax(150px, 38%) 1fr; gap: 1px 14px; margin: 0; font-size: .93rem; }
dl.kv dt { color: var(--muted); padding: 6px 0; }
dl.kv dd { margin: 0; padding: 6px 0; word-break: break-word; }
dl.kv .empty { color: var(--bad); }

.item {
  border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px; background: var(--surface); margin-bottom: 10px;
}
.item-flat { border: 0; border-bottom: 1px solid var(--line); border-radius: 0; margin: 0; }

/* ── шаги ──────────────────────────────────────────────── */
.steps { display: flex; gap: 6px; list-style: none; padding: 0; margin: 16px 0 18px; flex-wrap: wrap; }
.steps li {
  flex: 1 1 0; min-width: 96px; padding: 9px 4px 0 0; font-size: .82rem;
  color: var(--muted); border-top: 3px solid var(--line); line-height: 1.3;
}
.steps li.done { color: var(--good); border-top-color: var(--good); }
.steps li.current { color: var(--accent-dark); border-top-color: var(--accent); font-weight: 600; }

.bar { height: 7px; background: var(--line); border-radius: 4px; overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--accent); }

/* ── документ на экране ────────────────────────────────── */
.paper {
  isolation: isolate;
  background: #fff; border: 1px solid var(--line); border-radius: 8px;
  padding: 40px 48px; box-shadow: var(--shadow);
  font-family: 'Times New Roman', Times, serif; font-size: 12pt; color: #111;
  line-height: 1.45;
}
.paper .dx-p { margin: 0 0 .35em; min-height: 1.1em; text-align: left;
  position: relative; }
/* Печать и подпись висят за текстом: строки их не замечают и не сдвигаются,
   а текст виден поверх оттиска — как на бумаге. */
.paper .dx-float { position: absolute; }
.paper .dx-t, .paper .dx-blank, .paper .dx-token { position: relative; z-index: 100000; }
.paper .dx-float.dragging { opacity: .9; }
/* Взять печать мышью прямо за картинку нельзя — сверху строки. Поэтому у
   неё в разметке есть ручка: кружок у левого верхнего угла. */
.dx-grip {
  position: absolute; z-index: 4; width: 24px; height: 24px; margin: -12px 0 0 -12px;
  border-radius: 50%; border: 1px solid var(--accent); background: #fff;
  color: var(--accent); font-size: 13px; line-height: 22px; text-align: center;
  cursor: grab; user-select: none; box-shadow: 0 1px 4px rgba(0, 0, 0, .25);
}
.dx-grip:hover { background: var(--accent-soft); }
.dx-grip.dragging { cursor: grabbing; }
/* Крестик рядом с ручкой: убрать одну эту картинку, не трогая остальные. */
.dx-grip-x {
  position: absolute; z-index: 4; width: 20px; height: 20px; margin: -10px 0 0 -10px;
  border-radius: 50%; border: 1px solid var(--line); background: #fff;
  color: var(--bad); font-size: 14px; line-height: 16px; padding: 0;
  cursor: pointer; box-shadow: 0 1px 4px rgba(0, 0, 0, .2);
}
.dx-grip-x:hover { background: var(--bad); color: #fff; border-color: var(--bad); }
.dx-grip-clear { position: absolute; z-index: 4; margin-top: -10px; height: 20px;
  border: 1px solid var(--line); border-radius: 4px; background: #fff;
  color: var(--accent); padding: 0 5px; font: 11px/18px var(--font, sans-serif);
  white-space: nowrap; cursor: pointer; }
.dx-grip-clear:hover { background: var(--accent-soft); }
.dx-grip-replace { position: absolute; z-index: 4; margin-top: -10px; height: 20px;
  width: 104px; border: 1px solid var(--line); border-radius: 4px; background: #fff;
  color: var(--accent); padding: 0 3px; font: 11px/18px var(--font, sans-serif); cursor: pointer; }
.dx-outline { position: absolute; z-index: 3; border: 1px dashed var(--accent);
  pointer-events: none; border-radius: 3px; }
.dx-grip, .dx-grip-x, .dx-grip-clear, .dx-grip-replace { z-index: 200001; }
.dx-outline { z-index: 200000; }
.paper .dx-float.layer-selected { outline: 2px solid var(--accent); outline-offset: 3px; }
.paper .dx-tab { display: inline-block; width: 2.4em; }
.paper .dx-img { max-width: 100%; height: auto; vertical-align: middle; }
.paper .dx-obj { color: var(--muted); font-style: italic; font-size: .85em; }
.paper table.dx-table { border-collapse: collapse; width: 100%; margin: .5em 0; }
.paper table.dx-table td { border: 1px solid #999; padding: 4px 7px; vertical-align: top; }
.paper table.dx-table-plain td { border: 0; padding: 2px 6px; }
.paper .dx-empty { display: inline-block; min-width: 1px; }
/* Сноски лежат в документе отдельным файлом — показываем их под текстом,
   иначе спрятанное в сноске (например, цены) для школы просто пропадает. */
.paper .dx-notes {
  margin-top: 22px; padding-top: 10px; border-top: 1px solid var(--line);
  font-size: .85em; color: #333;
}
.paper .dx-notes-title {
  font-size: .78em; text-transform: uppercase; letter-spacing: .04em;
  color: var(--muted); margin-bottom: 6px; font-family: var(--sans, inherit);
}
.paper .dx-note { display: flex; gap: 8px; margin-bottom: 6px; }
.paper .dx-note sup { color: var(--muted); }
/* Значок сноски в тексте: по нему видно, к какому месту она относится. */
.paper .dx-ref {
  color: var(--accent); font-weight: 600; padding: 0 1px; user-select: none;
}

.dx-token {
  display: inline-flex; align-items: center; gap: 4px;
  background: var(--accent-soft); border: 1px solid #b9d0fb; color: #12305e;
  border-radius: 6px; padding: 0 3px 0 6px; font-family: inherit;
  font-size: .82em; font-weight: inherit; white-space: nowrap;
  vertical-align: baseline; line-height: 1.5;
}
.dx-token.hot { background: #d7e5ff; border-color: var(--accent); }
.dx-token-check { gap: 2px; padding-left: 3px; }
.dx-token-x {
  border: 0; background: none; color: #5a7cb8; cursor: pointer;
  font-size: 1.05em; line-height: 1; padding: 0 3px; font-family: inherit;
}
.dx-token-x:hover { color: var(--bad); }
@media (pointer: coarse) {
  /* Пальцем в крестик размером с букву не попасть. Отрицательные поля
     держат строку на месте: растёт только область нажатия. */
  .dx-token-x { padding: 8px 9px; margin: -8px -5px; }
}
.paper.readonly .dx-token { cursor: default; background: #eef3fb; }

/* пустые места в договоре: ________ */
.dx-blank {
  background: #fff6d8; border-bottom: 2px solid #e2b93b; cursor: pointer;
  border-radius: 3px;
  /* Длинную линию прочерков Word переносит посимвольно — делаем так же,
     иначе она целиком прыгает на следующую строку. */
  overflow-wrap: anywhere;
}
.dx-blank:hover { background: #ffe9a8; }
/* Прочерк на несколько строк загорается целиком: видно, что уйдёт в одно поле. */
.dx-blank.dx-group-hover { background: #ffe9a8; box-shadow: 0 0 0 1px #e2b93b; }
.paper.no-blanks .dx-blank { background: none; border-bottom: 0; box-shadow: none; cursor: text; }

/* разрыв страницы, который стоит в самом документе */
.dx-pagebreak {
  display: block; height: 0; border-top: 2px dashed #9aa7bb; margin: 10px 0;
}
.dx-pagebreak::after {
  content: 'разрыв страницы'; display: block; font-family: sans-serif;
  font-size: 9px; color: #7b8798; text-align: right; margin-top: 2px;
}

/* ── листы, как в режиме разметки Word ─────────────────────────── */
.paper-wrap { position: relative; }

/* Разбитый на листы документ: серое поле вокруг, сами листы — белые. */
.paper.paginated {
  background: #e8ebf0; border: 0; box-shadow: none; padding: 20px 0;
  overflow-x: auto;
}
.dx-sheet-holder { margin: 0 auto 22px; width: max-content; }
.dx-sheet-label {
  font-family: sans-serif; font-size: 11px; color: #7b8798;
  text-align: center; padding: 0 0 6px;
}
.dx-sheet {
  position: relative; background: #fff; box-sizing: border-box;
  box-shadow: 0 1px 3px rgba(16, 32, 56, .18), 0 10px 24px rgba(16, 32, 56, .10);
}
/* Границы текста: в Word это «показать границы области текста». */
.dx-sheet-guide {
  position: absolute; border: 1px dashed #c8d0dd; pointer-events: none;
}
.dx-sheet-in { position: relative; }

/* Разрыв страницы в самом файле — виден и когда разбивка выключена. */
.paper.paginated .dx-pagebreak { display: none; }

/* панель над документом */
.editor-bar {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  margin-bottom: 12px;
  /* Панель едет вместе со страницей: печать ставят в конце договора, и
     листать за ней наверх и обратно — та ещё работа. Липнет она не к нулю,
     а под шапку сайта: шапка тоже липкая и выше по слою. Высоту шапки
     подставляет редактор — она разная на узком экране. */
  position: sticky; top: var(--top-h, 58px); z-index: 30;
  background: var(--bg, #f6f7f9); padding: 8px 0;
  border-bottom: 1px solid var(--line);
}
.editor-bar-sep { width: 1px; height: 22px; background: var(--line); }
/* Оформление: кнопки в ряд, как в Word. */
.fmt { display: inline-flex; align-items: center; gap: 4px; }
.fmt .fmt-b { min-width: 30px; padding: 4px 6px; font-size: .95rem; }
.fmt select {
  width: auto; padding: 4px 6px; font-size: .82rem; height: auto;
}
.editor-saving {
  margin-left: auto; font-size: .82rem; color: var(--muted);
}

/* Режим набора: курсор в тексте, поле — неделимый предмет. */
.paper.typing .dx-p { cursor: text; }
.paper.typing .dx-p:focus {
  outline: 0; background: rgba(37, 99, 235, .04);
  box-shadow: -6px 0 0 rgba(37, 99, 235, .28);
}
.paper.typing .dx-token { cursor: default; user-select: none; }
.paper.typing .dx-blank { cursor: text; }
.toggle { display: inline-flex; align-items: center; gap: 6px; font-size: .88rem;
  color: var(--muted); cursor: pointer; }
.toggle input { margin: 0; }
.fieldpick.armed { border-color: var(--accent); background: var(--accent-soft); }

/* ── редактор ──────────────────────────────────────────── */
.editor { display: grid; grid-template-columns: 1fr 330px; gap: 18px; align-items: start; }
.editor-side { position: sticky; top: 74px; max-height: calc(100vh - 96px); display: flex; flex-direction: column; }
.editor-doc { min-width: 0; }
.editor-help { margin: 8px 0 14px; font-size: .88rem; }
.editor-help summary { cursor: pointer; color: var(--muted); }
.editor.editor-workspace { position: relative; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 12px; align-items: stretch; height: max(480px, calc(100dvh - var(--editor-workspace-top, 308px) - 16px)); }
.editor.editor-workspace.editor-pdf-off { grid-template-columns: minmax(0, 1fr); }
.editor-pdf[hidden] { display: none !important; }
.editor-workspace .editor-doc, .editor-pdf { display: flex; flex-direction: column; min-height: 0; min-width: 0; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; background: var(--surface); }
.editor-pane-head { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 6px; padding: 9px 12px; min-height: 60px; border-bottom: 1px solid var(--line); }
.editor-pane-head .row { gap: 6px; }
.editor-pane-head select { display: inline-block; width: auto; font-size: .78rem; padding: 4px; }
.editor-source-scroll { flex: 1; min-height: 0; overflow: auto; padding: 10px; background: #eef0f4; }
.editor-pdf-scroll { flex: 1; min-height: 0; overflow: auto; background: #e4e7ec; padding: 12px; }
.editor-pdf-state { padding: 7px 12px; font-size: .81rem; color: var(--muted); border-bottom: 1px solid var(--line); }
.editor-pdf-state.error { color: var(--bad); background: var(--bad-soft); }
.editor-pdf-pages { display: flex; flex-direction: column; gap: 16px; align-items: center; min-height: 120px; width: max-content; min-width: 100%; }
.editor-pdf-page { background: white; box-shadow: 0 2px 8px #0002; flex: none; }
.editor-pdf-page canvas { display: block; }
.editor-pdf { scroll-margin-top: calc(var(--top-h, 58px) + var(--editor-toolbar-h, 50px) + 12px); }
.editor-pdf-hint { margin: 0; padding: 7px 12px; border-top: 1px solid var(--line); }
.editor-workspace .editor-fields { position: absolute; left: 12px; top: 64px; z-index: 35; width: min(320px, calc(100% - 24px)); max-height: calc(100% - 80px); background: var(--surface); padding: 12px; border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 6px 25px #0003; }
.editor-fields[hidden], #download-pdf[hidden] { display: none !important; }
.editor-layers { position: absolute; right: 12px; top: 64px; z-index: 36; width: min(380px, calc(100% - 24px)); max-height: calc(100% - 80px); display: flex; flex-direction: column; background: var(--surface); padding: 12px; border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 6px 25px #0003; }
.editor-layers[hidden] { display: none !important; }
.layer-group-title { font-size: .85rem; margin: 12px 0 6px; color: var(--muted); }
.layer-text-divider { padding: 8px; border-block: 1px solid var(--line); margin: 12px 0; font-weight: 600; text-align: center; }
.layer-row { padding: 8px 0; border-bottom: 1px solid var(--line); }
.layer-name { display: flex; align-items: center; gap: 8px; width: 100%; background: none; border: 0; padding: 0; color: inherit; text-align: left; cursor: pointer; }
.layer-name img { width: 32px; height: 32px; object-fit: contain; background: white; border: 1px solid var(--line); }
.layer-name span { overflow-wrap: anywhere; }
.layer-controls { display: flex; align-items: center; gap: 6px; margin-top: 7px; }
.layer-controls select { width: auto; flex: 1; padding: 5px; font-size: .8rem; }
.editor-table {
  position: absolute; z-index: 40; top: 10px; right: 10px;
  width: min(350px, calc(100% - 20px)); max-height: calc(100% - 20px);
  display: flex; flex-direction: column; overflow: clip; padding: 14px; background: var(--surface);
  border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 8px 24px #0002;
}
.editor-table[hidden] { display: none; }
.editor-table > .row, .editor-table > p, .editor-table #table-form > p { flex: none; }
.editor-table #table-form { display: flex; flex-direction: column; min-height: 0; flex: 1; }
.editor-table #table-settings { margin: 0; padding: 0 4px 0 0; min-width: 0; overflow-y: auto; min-height: 0; flex: 1; }
.editor-table label { display: block; font-size: .8rem; margin: 8px 0 4px; }
.editor-table select, .editor-table input { font-size: .84rem; padding: 6px; }
.editor-table input[type=color] { width: 100%; height: 34px; padding: 3px; }
.editor-table .table-check { display: flex; align-items: center; gap: 7px; }
.editor-table .table-check input { width: auto; }
.table-settings-grid { display: grid; grid-template-columns: minmax(0,1fr) minmax(0,1fr); gap: 9px; }
.editor-table .btn-wide { margin-top: 12px; }
.editor-table #apply-table { flex: none; }
.paper td.table-selected { outline: 2px solid var(--accent); outline-offset: -2px; }
.editor-workspace.editor-pdf-off.table-open .editor-doc { margin-right: 365px; }
@media (max-width: 850px) {
  .editor-workspace.editor-pdf-off.table-open .editor-doc { margin-right: 0; }
  .editor-table { position: relative; top: auto; right: auto; width: auto; max-height: none; }
  .editor.editor-workspace { grid-template-columns: minmax(0, 1fr); height: auto; }
  .editor-workspace .editor-doc { height: 65dvh; min-height: 420px; }
  .editor-workspace .editor-pdf { height: 65dvh; min-height: 420px; }
  .editor-pane-head { min-height: 54px; }
  .editor-pane-head .btn { padding: 4px 7px; }
  .editor-workspace .editor-fields { max-height: 55dvh; order: initial; }
}
.side-scroll { overflow-y: auto; flex: 1; margin: 0 -4px; padding: 0 4px; }
.fieldpick {
  border: 1px solid var(--line); border-radius: 9px; padding: 9px 11px;
  margin-bottom: 7px; cursor: grab; background: var(--surface); font-size: .9rem;
}
.fieldpick:hover { border-color: var(--accent); background: var(--accent-soft); }
.fieldpick.used { opacity: .55; }
.fieldpick b { display: block; font-weight: 600; }
.fieldpick .scope { color: var(--muted); font-size: .76rem; }
.pickbar {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: 18px;
  background: var(--ink); color: #fff; border-radius: 12px; padding: 12px 16px;
  box-shadow: 0 10px 30px rgba(0,0,0,.28); z-index: 60; max-width: min(560px, 94vw);
  display: none;
}
.pickbar.on { display: block; }
.pickbar .sel { color: #ffd479; font-weight: 600; word-break: break-word; }
.pickbar input[type=search], .pickbar input[type=text] { margin-top: 9px; }
.pickbar-modes { display: flex; gap: 6px; margin-top: 10px; }
.pickbar-modes button {
  flex: 1; background: rgba(255,255,255,.1); border: 0; color: #cbd5e5;
  padding: 7px 10px; border-radius: 8px; cursor: pointer; font: inherit;
  font-size: .86rem; font-weight: 600;
}
.pickbar-modes button.on { background: var(--accent); color: #fff; }
.pickbar .results button.guess { background: rgba(255,212,121,.22); }
.pickbar .results { max-height: 210px; overflow-y: auto; margin-top: 8px; }
.pickbar .results button {
  display: block; width: 100%; text-align: left; background: rgba(255,255,255,.08);
  border: 0; color: #fff; padding: 8px 11px; border-radius: 8px; margin-bottom: 5px;
  cursor: pointer; font: inherit; font-size: .9rem;
}
.pickbar .results button:hover { background: rgba(255,255,255,.2); }
.pickbar .results button small { display: block; color: #b9c4d6; font-size: .78rem; }
.toast {
  position: fixed; bottom: 18px; right: 18px; background: var(--ink); color: #fff;
  padding: 11px 16px; border-radius: 10px; z-index: 70; font-size: .92rem;
  box-shadow: 0 8px 24px rgba(0,0,0,.25); max-width: 80vw;
}
.toast.bad { background: var(--bad); }

dialog {
  border: 0; border-radius: var(--radius); padding: 0; max-width: 460px; width: 94vw;
  box-shadow: 0 20px 60px rgba(0,0,0,.3);
}
dialog::backdrop { background: rgba(16, 32, 56, .45); }
dialog .dlg { padding: 20px; }
#field-dialog .field > label.check { display: flex; align-items: center; gap: 8px; }

/* ── мелочи ────────────────────────────────────────────── */
.application-grid { grid-template-columns: minmax(0,1.3fr) minmax(0,1fr); }
.form-error-summary { border-left: 4px solid var(--bad); }
.pagination { flex-wrap: wrap; }
.empty-state { text-align: center; padding: 34px 18px; color: var(--muted); }
.empty-state .big { font-size: 2rem; margin-bottom: 8px; }
.link-box {
  display: flex; gap: 8px; align-items: center; background: var(--bg);
  border: 1px solid var(--line); border-radius: 9px; padding: 8px 10px;
  font-size: .88rem; word-break: break-all;
}
footer { padding: 26px 0; color: var(--muted); font-size: .85rem; border-top: 1px solid var(--line); background: var(--surface); }

@media (max-width: 880px) {
  .application-grid { grid-template-columns: minmax(0,1fr); }
  .application-grid .row { flex-wrap: wrap; }
  .application-grid form .btn { max-width: 100%; }
  /* Широкие таблицы списков прокручиваются сами, а не растягивают страницу. */
  table.list { display: block; overflow-x: auto; white-space: nowrap; }
  table.list td, table.list th { white-space: nowrap; }
  table.list td .tiny, table.list td .small { white-space: normal; }

  .editor { grid-template-columns: 1fr; }
  .editor-side { position: static; max-height: none; order: -1; }
  .side-scroll { max-height: 240px; }
  .paper { padding: 22px 18px; font-size: 11pt; }

  /* Панель выбора на телефоне — во всю ширину внизу, но так, чтобы список
     полей помещался над экранной клавиатурой, а не уезжал под неё. */
  .pickbar {
    left: 8px; right: 8px; transform: none; max-width: none;
    bottom: calc(8px + env(safe-area-inset-bottom, 0px));
  }
  .pickbar .results { max-height: 32vh; }
  /* Сообщение показываем сверху: внизу уже панель и клавиатура. */
  .toast {
    left: 8px; right: 8px; bottom: auto; top: 64px; max-width: none;
  }
  dl.kv { grid-template-columns: 1fr; gap: 0; }
  dl.kv dt { padding-bottom: 0; font-size: .82rem; }
  dl.kv dd { padding-top: 2px; border-bottom: 1px solid var(--line); padding-bottom: 8px; }
  .top-in { min-height: 52px; }
  h1 { font-size: 1.35rem; }
}

@media print {
  .top, footer, .no-print { display: none !important; }
  .paper { border: 0; box-shadow: none; padding: 0; background: #fff; }
  .dx-sheet { box-shadow: none; break-after: page; }
  .dx-sheet-guide, .dx-sheet-label { display: none; }
  .dx-sheet-holder { margin: 0; transform: none !important; height: auto !important; }
}
.payment-cards-mobile { display: none; }
.payment-card { min-width: 0; border: 1px solid var(--line, #d6dfef); border-radius: 12px; padding: 14px; overflow-wrap: anywhere; }
.payment-card-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; margin-bottom: 10px; }
.payment-card-amount { font-size: 1.15rem; }
.payment-card-person { font-weight: 600; margin-bottom: 4px; }
.payment-card > .small, .payment-card > a { display: block; margin-top: 6px; }
.payment-card-details summary { cursor: pointer; }
.payment-card-details > div { margin-top: 6px; }
@media (max-width: 640px) {
  .payment-table-desktop { display: none; }
  .payment-cards-mobile { display: grid; gap: 12px; }
}

/* The PDF is the only paginated surface; source text remains a flowing editor. */
.editor.editor-workspace.editor-exact {grid-template-columns:minmax(0,1fr)}
.editor-exact .editor-doc {display:none}
.editor-pdf-page-holder {position:relative;flex:none;line-height:0}
.editor-pdf-stamp {position:absolute;pointer-events:none;border:1px solid transparent;box-sizing:border-box;line-height:normal}
.editor-pdf-stamp:has(button:hover),.editor-pdf-stamp.dragging {border:1px dashed #245fea;background:#245fea12}
.editor-pdf-stamp button {position:absolute;left:-10px;top:-10px;width:24px;height:24px;border:1px solid #245fea;border-radius:50%;background:white;color:#174cbb;cursor:move;pointer-events:auto;touch-action:none;padding:0;line-height:20px;font-size:18px}
.editor-pdf-stamp:focus-within {border:1px dashed #245fea}
.editor-exact #close-pdf {display:none}
#view-pages[aria-pressed=true],#view-text[aria-pressed=true] {background:var(--accent);color:white}

/* Collapsible navigation stays at the upper left on every screen. */
.top-in {flex-wrap:nowrap; gap:12px}
.menu-toggle {width:38px;height:38px;border:0;border-radius:9px;background:var(--accent-soft);color:var(--accent-dark);font:24px/1 sans-serif;cursor:pointer;flex:none}
.menu-toggle:focus-visible {outline:2px solid var(--accent);outline-offset:3px}
.site-menu {position:fixed;inset:0 auto 0 0;margin:0;width:min(310px,90vw);height:100dvh;max-height:100dvh;max-width:90vw;border:0;border-right:1px solid var(--line);padding:20px 14px;background:var(--surface);color:var(--ink);box-shadow:12px 0 40px #10203820}
.site-menu::backdrop {background:#14223855}
.site-menu-heading {display:flex;align-items:center;justify-content:space-between;padding:0 10px 18px;font-size:1.15rem}
.site-menu .nav {display:flex;flex-direction:column;align-items:stretch;gap:5px;margin:0}
.site-menu .nav a,.site-menu .nav button {display:block;width:100%;text-align:left;padding:11px 14px}
.site-menu .nav form {border-top:1px solid var(--line);margin-top:16px;padding-top:10px}
body.menu-open {overflow:hidden}
.site-menu {border-radius:0}
#preview-retry[hidden] {display:none}
.document-preview {width:100%;max-height:85dvh;overflow:auto;padding:14px;background:#e4e7ec;border:1px solid var(--line);border-radius:10px}
.document-preview > div {width:max-content;min-width:100%;display:flex;justify-content:center;margin-bottom:16px}
.document-preview canvas {display:block;background:white;box-shadow:0 2px 8px #0002;max-width:none}
.editor-pdf-stamp .editor-pdf-picture-hit {inset:0;width:100%;height:100%;border:1px dashed transparent;border-radius:2px;background:transparent;line-height:normal;z-index:1}
.editor-pdf-picture-hit::before {content:'✥';position:absolute;left:-10px;top:-10px;width:24px;height:24px;border:1px solid #245fea;border-radius:50%;background:white;color:#174cbb;line-height:22px;font-size:18px}
.editor-pdf-stamp .editor-pdf-picture-hit:hover,.editor-pdf-stamp .editor-pdf-picture-hit:focus-visible {border-color:#245fea;background:#245fea08}
.editor-pdf-stamp .editor-pdf-picture-hit:disabled {cursor:wait}
.editor-pdf-drag-ghost {position:absolute;inset:0;width:100%;height:100%;opacity:.8;box-shadow:0 4px 12px #0004;pointer-events:none}
@media(max-width:640px) {.brand {font-size:.9rem}.brand > span:last-child {overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.brand {min-width:0}}

.program-folders-section {margin:18px 0 22px}
.program-folder-grid {display:grid;grid-template-columns:repeat(auto-fit,minmax(min(100%,270px),1fr));gap:12px}
.program-folder {display:flex;align-items:center;gap:12px;min-height:100px;padding:18px;background:var(--surface);border:1px solid var(--line);border-radius:12px;text-decoration:none;color:var(--ink);box-shadow:0 2px 5px #14223805}
.program-folder:hover {border-color:var(--accent);background:var(--accent-soft);color:var(--ink)}
.program-folder:focus-visible {outline:2px solid var(--accent);outline-offset:3px}
.program-folder-icon {font-size:30px;flex:none}.program-folder b,.program-folder .small {display:block}.program-folder-arrow {margin-left:auto;color:var(--muted);font-size:26px}
.folder-breadcrumb {display:flex;align-items:center;flex-wrap:wrap;gap:10px;padding:14px 18px;background:var(--surface);border:1px solid var(--line);border-radius:10px}

/* Filled-document check: the form stays readable beside the actual PDF. */
#application-errors,.application-form .field{scroll-margin-top:90px}
.document-check-layout{display:grid;grid-template-columns:minmax(300px,400px) minmax(0,1fr);gap:24px;align-items:start}.document-check-form .card{padding:22px}.document-check-form h2{margin:0 0 10px}.check-field-group{border-top:1px solid var(--line);margin-top:16px;padding-top:12px}.check-field-group>summary{font-weight:650;cursor:pointer;padding:4px 0 12px}.check-field-group .field{margin-bottom:16px}.check-submit{display:grid;gap:12px;padding-top:20px;border-top:1px solid var(--line)}.document-check-result{position:sticky;top:16px;min-width:0}.document-check-result .document-preview{max-height:calc(100vh - 100px);overflow:auto}.preview-controls{margin-bottom:12px;padding:12px 0;align-items:center}.check-field-group .choice-radios>div{margin:8px 0}.check-field-group .choice-radios label{font-weight:400}.check-field-group input[type=text],.check-field-group textarea{width:100%;box-sizing:border-box}.check-field-group .hint{line-height:1.5}
@media(max-width:900px){.document-check-layout{grid-template-columns:1fr}.document-check-result{position:static}.document-check-result .document-preview{max-height:none}.document-check-form{min-width:0}.document-check-form .card{padding:18px}}
