/* Резонансное вихревое возбуждение. Переменные темы, кнопка каталога, окно с вырезкой
   нормы и приёмы вывода инженерного результата перенесены из apps/anchor-plate-bearing
   с сохранением имён классов — см. docs/ENGINEERING_UI.md, разделы 3, 4, 7 и 10. */

:root {
  --ink: #14252f;
  --muted: #52646a;
  --paper: #f5f7f6;
  --surface: #ffffff;
  --line: #ccd8d5;
  --teal: #0d6670;
  --teal-dark: #074c53;
  --teal-soft: #e0f1ef;
  --soft: #e0f1ef;
  --green: #17633c;
  --green-soft: #e7f5ec;
  --amber: #8c5200;
  --amber-soft: #fff2dc;
  --red: #a82d3e;
  --red-soft: #fde9ec;
  --radius: 14px;
  --radius-small: 10px;
  --shadow: 0 12px 36px rgba(21, 42, 49, .08);
}

*, *::before, *::after { box-sizing: border-box; }

/* Собственное правило display перебивает браузерное [hidden] { display: none }.
   Блоки, которые приложение прячет атрибутом hidden (поле ручного усилия,
   размеры круглого и прямоугольного анкера, параметры сеток), имеют класс с
   display: grid — без этой строки они остаются на экране, а прямоугольный и
   круглый анкер показываются одновременно. */
[hidden] { display: none !important; }

html {
  /* Полоса прокрутки не должна дёргать вёрстку при смене высоты результата. */
  scrollbar-gutter: stable;
}

body {
  margin: 0;
  /* Страница не качается в стороны: горизонтальный вылет обрезается, но body
     не превращается в собственный контейнер прокрутки. */
  overflow-x: clip;
  overscroll-behavior-x: none;
  padding-bottom: 96px;
  color: var(--ink);
  background: var(--paper);
  font: 400 15px/1.55 Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  -webkit-text-size-adjust: 100%;
}

.skip-link {
  position: absolute;
  left: -9999px;
}
.skip-link:focus {
  left: 12px;
  top: 12px;
  z-index: 50;
  padding: 10px 14px;
  background: var(--surface);
  border: 2px solid var(--teal);
  border-radius: 8px;
}

/* ---- Кнопка возврата в каталог: один вид во всех приложениях КБ ---- */
.catalog-bar { max-width: 1280px; margin: 0 auto; padding: 16px 26px 0; }
.catalog-link {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  padding: 6px 10px;
  border: 1px solid #bfd0cd;
  border-radius: 999px;
  color: var(--teal-dark);
  background: #fff;
  font-size: .84rem;
  font-weight: 720;
  text-decoration: none;
}
.catalog-link::before { content: "←"; margin-right: 7px; font-size: 1rem; line-height: 1; }
.catalog-link:hover { border-color: var(--teal); background: var(--soft); }
.catalog-link:focus-visible { outline: 3px solid rgba(13, 102, 112, .28); outline-offset: 2px; }

.wrap { max-width: 1280px; margin: 0 auto; padding: 18px 26px 32px; }

h1 { margin: 0 0 6px; font-size: 1.42rem; line-height: 1.2; letter-spacing: -.01em; }
.lede { margin: 0 0 14px; max-width: 62ch; color: var(--muted); font-size: .92rem; }

.status-banner {
  margin: 0 0 18px;
  padding: 10px 13px;
  border-left: 3px solid var(--amber);
  border-radius: 0 var(--radius-small) var(--radius-small) 0;
  background: var(--amber-soft);
  color: #5d3800;
  font-size: .84rem;
}
.status-banner b { color: #3f2600; }

/* ---- Сетка страницы: широкое содержимое не распирает ширину ---- */
.layout { display: grid; gap: 18px; grid-template-columns: minmax(0, 1fr); align-items: start; }
.stack { display: grid; gap: 18px; grid-template-columns: minmax(0, 1fr); }
@media (min-width: 1040px) {
  .layout { grid-template-columns: minmax(0, 420px) minmax(0, 1fr); }
}

.panel {
  padding: 15px 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.panel > h2 { margin: 0 0 12px; font-size: 1.02rem; }
.panel > * { min-width: 0; }

fieldset { margin: 0 0 16px; padding: 0; border: 0; }
fieldset:last-of-type { margin-bottom: 0; }
legend {
  padding: 0;
  margin-bottom: 9px;
  color: var(--teal-dark);
  font-size: .76rem;
  font-weight: 750;
  letter-spacing: .06em;
  text-transform: uppercase;
}

.field { display: grid; gap: 4px; margin-bottom: 11px; }
.field > label, .field > .term-help { justify-self: start; }
.field-label { font-size: .84rem; font-weight: 650; }
.hint { color: var(--muted); font-size: .76rem; }

.grid-2 { display: grid; gap: 11px; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
.grid-2 .field { margin-bottom: 0; }

input[type="number"], input[type="text"], select {
  width: 100%;
  min-height: 42px;
  padding: 8px 10px;
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius-small);
  font: inherit;
  font-variant-numeric: tabular-nums;
}
input:focus-visible, select:focus-visible, button:focus-visible, summary:focus-visible, a:focus-visible {
  outline: 3px solid rgba(13, 102, 112, .28);
  outline-offset: 2px;
}
input:invalid { border-color: var(--red); }

/* Числовое поле и его единица — одной строкой, как решил владелец. */
.value-row { display: grid; gap: 8px; grid-template-columns: minmax(0, 1fr) minmax(104px, auto); align-items: start; }

.check-row { display: flex; gap: 9px; align-items: flex-start; margin-bottom: 11px; }
.check-row input { width: 20px; height: 20px; min-height: 0; margin: 2px 0 0; flex: 0 0 auto; }
.check-row label { font-size: .84rem; }

.actions { display: flex; flex-wrap: wrap; gap: 9px; align-items: center; margin-top: 15px; }
button {
  min-height: 44px;
  padding: 10px 17px;
  border: 1px solid transparent;
  border-radius: var(--radius-small);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}
.primary { color: #fff; background: var(--teal); }
.primary:hover { background: var(--teal-dark); }
.secondary { color: var(--teal-dark); background: #fff; border-color: var(--line); }
.secondary:hover { border-color: var(--teal); background: var(--soft); }
.notice { color: var(--muted); font-size: .76rem; }

/* ---- Подсказка поля: заголовок-кнопка и один диалог на страницу ---- */
.term-help {
  min-height: 0;
  padding: 0;
  border: 0;
  background: none;
  color: var(--ink);
  font: 650 .84rem/1.4 inherit;
  text-align: left;
  text-decoration: underline;
  text-decoration-style: dotted;
  text-decoration-color: #9fbcb8;
  text-underline-offset: 3px;
}
.term-help::after {
  content: "?";
  display: inline-grid;
  place-items: center;
  width: 15px;
  height: 15px;
  margin-left: 6px;
  border-radius: 50%;
  background: var(--teal-soft);
  color: var(--teal-dark);
  font-size: .64rem;
  font-weight: 800;
  vertical-align: 1px;
}
.term-help:hover { text-decoration-color: var(--teal); }

.help-dialog {
  width: min(540px, calc(100vw - 32px));
  padding: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 24px 60px rgba(15, 35, 40, .26);
}
.help-dialog::backdrop { background: rgba(14, 37, 47, .44); }
.help-dialog form { padding: 15px 18px 19px; }
.help-dialog__top { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.help-dialog__eyebrow { margin: 0; color: var(--muted); font-size: .7rem; font-weight: 750; letter-spacing: .08em; text-transform: uppercase; }
.help-dialog__close { display: inline-flex; align-items: center; justify-content: center; min-width: 36px; min-height: 36px; padding: 0 10px; border: 1px solid var(--line); border-radius: 8px; background: #fff; color: #0e252f; }
.help-dialog__close svg { display: block; width: 16px; height: 16px; }
.help-dialog h2 { margin: 9px 0 8px; font-size: 1.04rem; }
.help-dialog p { margin: 0; color: #22343c; font-size: .9rem; line-height: 1.62; white-space: pre-line; }

/* Фрагмент норматива внутри диалога.
   ENGINEERING_UI, 3: на узком экране вырезка показывается крупно и листается
   внутри окна, а «Открыть фрагмент отдельно» даёт увеличение жестом. Поэтому
   у картинки задана min-width: вписанная по ширине телефона, она была бы
   нечитаема — текст легенды ушёл бы в 4 px. */
.help-dialog__figure { margin: 14px 0 0; }
/* Рамка ограничена по высоте: при ширине 1100 px фрагмент высотой 805 px
   растягивал диалог так, что текст легенды под ним терялся. Листается в
   обе стороны внутри рамки (ENGINEERING_UI, 1). */
.help-dialog__zoom { overflow: auto; max-height: 56vh; overscroll-behavior: contain; border: 1px solid var(--line); border-radius: 10px; background: #fff; }
.help-dialog__zoom:focus-visible { outline: 3px solid var(--teal); outline-offset: 2px; }
.help-dialog__zoom img { display: block; width: 1100px; max-width: none; height: auto; }
/* Ширина подобрана по читаемости легенды: в исходнике её строка около 33 px
   высотой при 2310 px ширины, при 1100 px это ~16 px на экране. Натуральный
   размер давал бы семикратное листание в окне телефона. */
.help-dialog__zoom-hint { margin: 0 0 6px !important; color: var(--teal-dark); font-size: .74rem !important; font-weight: 720; }
.help-dialog__figure figcaption { margin-top: 8px; color: var(--muted); font-size: .76rem; line-height: 1.45; }
.help-dialog__figure figcaption a { color: var(--teal-dark); font-weight: 700; text-underline-offset: 3px; }

/* ---- Результат ---- */
.verdict { display: grid; gap: 4px; padding: 12px 14px; border-radius: var(--radius-small); margin-bottom: 14px; }
.verdict.ok { background: var(--green-soft); color: #0d4a2c; }
.verdict.bad { background: var(--red-soft); color: #7c1f2d; }
.verdict b { font-size: 1.06rem; }
.verdict span { font-size: .82rem; }

.result-grid { display: grid; gap: 11px; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); margin-bottom: 15px; }
.result-card { padding: 11px 12px; background: #f8fbfa; border: 1px solid #dde7e4; border-radius: var(--radius-small); min-width: 0; }
/* Без uppercase: он превращает η в «Н», φb в «Φв», а Rb,loc в «RB,LOC» —
   обозначение перестаёт быть обозначением. */
.result-card h3 { margin: 0 0 4px; color: var(--muted); font-size: .74rem; font-weight: 700; letter-spacing: .01em; }
.result-card .big { font-size: 1.18rem; font-weight: 750; font-variant-numeric: tabular-nums; }

/* Неразрывная запись «обозначение = значение единица». */
.nw { white-space: nowrap; }
.value-line { display: block; }
.value-note { display: block; color: var(--muted); font-size: .76rem; }

/* ---- Список проверок ---- */
.check-list { display: grid; gap: 0; margin: 0 0 14px; padding: 0; list-style: none; border: 1px solid var(--line); border-radius: var(--radius-small); overflow: hidden; }
.check-list li { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 1px 10px; align-items: center; padding: 8px 10px; background: #fff; }
.check-list li + li { border-top: 1px solid var(--line); }
.check-list .check-name { font-size: .84rem; font-weight: 700; }
.check-list .check-ref { grid-column: 1; font-size: .72rem; color: var(--muted); }
.check-list .check-eta { grid-column: 2; grid-row: 1 / span 2; display: grid; justify-items: end; gap: 2px; font-variant-numeric: tabular-nums; }
.check-pill { padding: 1px 8px; border-radius: 999px; font-size: .7rem; font-weight: 750; white-space: nowrap; }
.check-pill.ok { color: var(--green); background: var(--green-soft); }
.check-pill.bad { color: var(--red); background: var(--red-soft); }
.check-pill.warn { color: var(--amber); background: var(--amber-soft); }

/* ---- Замечания: каждое ведёт к своему полю ---- */
.issues { display: grid; gap: 7px; margin: 0; padding: 0; list-style: none; }
.issue {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 9px;
  width: 100%;
  min-height: 0;
  padding: 9px 11px;
  border: 1px solid #dde7e4;
  border-radius: var(--radius-small);
  background: #fff;
  font: inherit;
  font-size: .83rem;
  font-weight: 450;
  text-align: left;
}
.issue[data-level="error"] { border-left: 3px solid var(--red); }
.issue[data-level="warning"] { border-left: 3px solid var(--amber); }
.issue[data-level="info"] { border-left: 3px solid var(--teal); }
button.issue:hover { border-color: var(--teal); background: #f8fbfa; }
.issue .issue-mark { font-weight: 800; }
.issue[data-level="error"] .issue-mark { color: var(--red); }
.issue[data-level="warning"] .issue-mark { color: var(--amber); }
.issue[data-level="info"] .issue-mark { color: var(--teal); }

@keyframes recalled {
  from { box-shadow: 0 0 0 4px rgba(13, 102, 112, .34); background: #e8f6f4; }
  to { box-shadow: 0 0 0 4px rgba(13, 102, 112, 0); background: #fff; }
}
.is-recalled { animation: recalled 1.9s ease-out; }
@media (prefers-reduced-motion: reduce) {
  .is-recalled { animation: none; outline: 3px solid var(--teal); outline-offset: 2px; }
}

/* ---- Протокол ---- */
details.protocol, details.where {
  border: 1px solid #dde7e4;
  border-radius: 9px;
  background: #fff;
}
details.protocol { margin-top: 14px; }
details.protocol > summary, details.where > summary {
  display: flex;
  gap: 8px;
  align-items: baseline;
  padding: 9px 11px;
  color: var(--teal-dark);
  font-size: .84rem;
  font-weight: 750;
  cursor: pointer;
}
details.where > summary small, details.protocol > summary small { color: var(--muted); font-weight: 550; }
.protocol-body { padding: 2px 11px 13px; }
.where dl { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 8px 12px; margin: 0; padding: 2px 11px 11px; }
.where dt { font: italic 400 1.02rem/1.3 "Times New Roman", Tinos, "Liberation Serif", Times, serif; white-space: nowrap; }
.where dd { margin: 0; font-size: .82rem; }
.where dd b { display: block; font-variant-numeric: tabular-nums; }

.mbox {
  padding: 8px 12px;
  color: var(--ink);
  background: #f8fbfa;
  border-left: 3px solid var(--teal);
  border-radius: 6px;
  font: italic 400 1.08rem/1.25 "Times New Roman", Tinos, "Liberation Serif", "Nimbus Roman", Times, serif;
  overflow-x: auto;
}
.mbox + .mbox { margin-top: 10px; }
.mline { display: block; margin: .38em 0; padding-left: 1.4em; text-indent: -1.4em; }
.mline.subst { color: #34504f; }
.mt { display: inline-block; text-indent: 0; white-space: nowrap; vertical-align: middle; margin-block: .12em; }
.mu { font-style: normal; }
.mbox sub { font-size: .68em; line-height: 0; vertical-align: -.3em; }
.mfr { display: inline-flex; flex-direction: column; align-items: stretch; vertical-align: middle; margin: 0 .12em; text-align: center; line-height: 1.15; }
.mfr > span { display: block; padding: 0 .18em; white-space: nowrap; }
.mfr > span:first-child { padding-bottom: .12em; border-bottom: 1.2px solid currentColor; }
.mfr > span:last-child { padding-top: .14em; }
.mword { color: #3d585d; font: 600 .8rem Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif; }
.mok { color: var(--green); font: 700 .82rem Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif; }
.mbad { color: var(--red); font: 700 .82rem Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif; }
.norm-ref { color: var(--muted); font: 600 .78rem Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif; font-style: normal; }
/* Номер формулы — кнопка: открывает дословную цитату пункта первоисточника. */
button.norm-ref {
  min-height: 0;
  padding: 1px 5px;
  border: 1px solid #cfdedb;
  border-radius: 6px;
  background: #fff;
  color: var(--teal-dark);
  cursor: pointer;
}
button.norm-ref:hover { border-color: var(--teal); background: var(--soft); }
@media print { button.norm-ref { border: 0; padding: 0; background: none; color: #333; } }
.assumption { color: #5d3800; font: 600 .78rem Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif; font-style: normal; }

/* ---- Нормативный рисунок ----
   Имена классов те же, что в apps/punching-shear-ru (ENGINEERING_UI, 10):
   .normative-figure + figcaption. На странице фрагмент масштабируется внутри
   своей рамки (ENGINEERING_UI, 1); крупно он открывается в диалоге. */
.normative-figure { margin: 0; padding: 10px; background: #fff; border: 1px solid var(--line); border-radius: 10px; }
.normative-figure img { display: block; width: 100%; height: auto; max-height: 650px; object-fit: contain; object-position: center; }
.normative-figure figcaption { display: grid; gap: 5px; padding: 10px 2px 1px; color: var(--muted); font-size: .76rem; line-height: 1.45; }
.normative-figure figcaption strong { color: #22343c; }
.normative-figure__actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-top: 3px; }
.normative-figure__actions a { color: var(--teal-dark); font-weight: 700; text-underline-offset: 3px; }

/* ---- Схема рисунка 8.9 ---- */
.scheme-figure { margin: 0; }
.scheme-figure svg { display: block; width: 100%; height: auto; }
.scheme-figure figcaption { margin-top: 9px; color: var(--muted); font-size: .78rem; }
.scheme-legend { display: grid; gap: 4px; margin: 11px 0 0; padding: 0; list-style: none; font-size: .79rem; }
.scheme-legend li { display: grid; grid-template-columns: 15px minmax(0, 1fr); gap: 8px; align-items: center; }
.swatch { display: block; width: 15px; height: 11px; border-radius: 2px; }

/* ---- Закреплённая внизу панель результата ---- */
.dock {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 30;
  visibility: hidden;
  transform: translateY(104%);
  transition: transform .22s ease, visibility .22s;
  background: rgba(255, 255, 255, .97);
  border-top: 1px solid var(--line);
  box-shadow: 0 -10px 30px rgba(20, 37, 47, .13);
  padding-bottom: env(safe-area-inset-bottom);
  backdrop-filter: blur(7px);
}
.dock[data-visible="true"] { visibility: visible; transform: translateY(0); }
.dock__inner { max-width: 1280px; margin: 0 auto; padding: 9px 26px 11px; display: grid; gap: 7px; }
.dock__head { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; justify-content: space-between; }
.dock__context { color: var(--muted); font-size: .76rem; min-width: 0; }
.dock__verdict { padding: 2px 9px; border-radius: 999px; font-size: .74rem; font-weight: 800; }
.dock__verdict.ok { color: var(--green); background: var(--green-soft); }
.dock__verdict.bad { color: var(--red); background: var(--red-soft); }
.dock__values { display: grid; gap: 10px; grid-template-columns: repeat(3, minmax(0, 1fr)); }
.dock__value { min-width: 0; }
.dock__value span { display: block; color: var(--muted); font-size: .7rem; font-weight: 700; letter-spacing: .01em; }
.dock__value b { display: block; font-size: 1.02rem; font-variant-numeric: tabular-nums; white-space: nowrap; }
.dock__issues { min-height: 0; padding: 3px 10px; border: 1px solid var(--line); border-radius: 999px; background: #fff; font-size: .74rem; font-weight: 700; }
.dock__issues[data-level="error"] { color: var(--red); border-color: #efc4cb; }
.dock__issues[data-level="warning"] { color: var(--amber); border-color: #e7cfa4; }
.dock__issues[data-level="ok"] { color: var(--green); border-color: #bcdfc9; }
@media (max-width: 600px) {
  .dock__inner { padding: 8px 15px 10px; }
  .dock__value b { font-size: .96rem; }
}

.app-version { margin: 22px 0 0; color: var(--muted); font-size: .76rem; break-inside: avoid; }
.app-version a { color: var(--teal-dark); }

.sources { margin: 14px 0 0; padding-left: 20px; color: var(--muted); font-size: .79rem; }
.sources li + li { margin-top: 5px; }
.sources a { color: var(--teal-dark); }

@media (max-width: 600px) {
  .catalog-bar { padding: 14px 15px 0; }
  .wrap { padding: 14px 15px 26px; }
  h1 { font-size: 1.24rem; }
  .grid-2 { grid-template-columns: minmax(0, 1fr); }
}

@media print {
  body { padding-bottom: 0; background: #fff; }
  .catalog-bar, .dock, .actions, .help-dialog, .skip-link { display: none !important; }
  .panel { box-shadow: none; border-color: #bbb; break-inside: avoid; }
  details.protocol, details.where { border-color: #bbb; }
  details.protocol[open] > summary, details.where[open] > summary { color: #000; }
  .layout { grid-template-columns: minmax(0, 1fr); }
}

/* ================================================================== */
/* Этого приложения                                                    */
/* ================================================================== */

h3.sub { margin: 20px 0 8px; font-size: .95rem; color: var(--teal-dark); }
.legend-note { margin-left: 6px; color: var(--muted); font-size: .7rem; font-weight: 600; letter-spacing: 0; text-transform: none; }
.empty { padding: 22px 12px; color: var(--muted); font-size: .88rem; text-align: center; border: 1px dashed var(--line); border-radius: var(--radius-small); }
.actions.tight { margin-top: 6px; }
.field select { min-width: 0; }
details.mini { margin-top: 8px; border: 1px solid #dde7e4; border-radius: 9px; background: #fff; }
details.mini > summary { padding: 8px 11px; color: var(--teal-dark); font-size: .82rem; font-weight: 700; cursor: pointer; }
details.mini[open] > .grid-2 { padding: 0 11px 11px; }

/* ---- Карточки направлений ---- */
.dir-list { display: grid; gap: 10px; }
.dir-card { padding: 11px 12px 12px; border: 1px solid var(--line); border-radius: var(--radius-small); background: #fbfdfc; }
.dir-card__head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 8px; }
.dir-card__head b { font-size: .84rem; color: var(--teal-dark); }
.dir-card .grid-2 { margin-bottom: 8px; }
.icon-btn { min-height: 34px; padding: 4px 10px; color: var(--red); background: #fff; border: 1px solid var(--line); border-radius: 8px; font-size: .78rem; font-weight: 700; }
.icon-btn:hover { background: var(--red-soft); border-color: #efc4cb; }
.dir-card .field-label, .dir-card .term-help { font-size: .78rem; }

/* ---- Таблицы: листаются внутри рамки (ENGINEERING_UI, 4) ---- */
.table-wrap { position: relative; overflow-x: auto; max-width: 100%; border: 1px solid var(--line); border-radius: var(--radius-small); background: #fff; }
.table-wrap:focus-visible { outline: 3px solid var(--teal); outline-offset: 2px; }
.table-wrap.has-more-right { box-shadow: inset -14px 0 12px -12px rgba(20, 37, 47, .28); }
.table-wrap.is-scrolled::before { content: ""; position: sticky; left: 0; top: 0; display: block; width: 0; height: 0; }
.data-table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: .82rem; font-variant-numeric: tabular-nums; }
.data-table th, .data-table td { padding: 6px 8px; border-bottom: 1px solid #e3ebe9; text-align: right; white-space: nowrap; vertical-align: middle; }
.data-table th { position: sticky; top: 0; background: var(--teal-soft); color: var(--teal-dark); font-weight: 700; font-size: .76rem; }
.data-table th:first-child, .data-table td:first-child { position: sticky; left: 0; z-index: 1; text-align: left; background: #fff; border-right: 1px solid #e3ebe9; }
.data-table th:first-child { background: var(--teal-soft); z-index: 2; }
.data-table tbody tr:last-child td { border-bottom: 0; }
.data-table tr.total td { font-weight: 750; background: #f3f8f7; }
.data-table td.is-off { color: var(--muted); font-style: italic; }
.data-table td.left, .data-table th.left { text-align: left; }
.data-table sub { font-size: .7em; line-height: 0; }
.levels input { width: 92px; min-height: 34px; padding: 4px 6px; font-size: .82rem; text-align: right; }
.levels input[data-lvl="name"] { width: 84px; text-align: left; }
.levels .cell-btn { min-height: 30px; padding: 2px 8px; color: var(--red); background: #fff; border: 1px solid var(--line); border-radius: 8px; font-size: .9rem; line-height: 1; }
.scroll-hint { margin: 5px 0 0; color: var(--teal-dark); font-weight: 700; }
.import-box { display: grid; gap: 8px; margin: 8px 0 12px; }
.import-box textarea { width: 100%; padding: 8px 10px; border: 1px solid var(--line); border-radius: var(--radius-small); font: .8rem/1.4 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }

/* ---- Итог и схемы ---- */
.verdict.neutral { background: var(--amber-soft); color: #5d3800; }
.verdict.warn { background: var(--amber-soft); color: #5d3800; }
.result-card .sub-note { display: block; margin-top: 2px; color: var(--muted); font-size: .72rem; }
.dir-summary { margin: 0 0 14px; padding: 12px; border: 1px solid #dde7e4; border-radius: var(--radius-small); background: #f8fbfa; }
.dir-summary h3 { margin: 0 0 8px; font-size: .92rem; }
.dir-summary .result-grid { margin-bottom: 0; }
.scheme-controls { display: grid; gap: 11px; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); margin-bottom: 10px; }
.scheme-controls .field { margin-bottom: 0; }
.scheme-grid { display: grid; gap: 14px; grid-template-columns: minmax(0, 1fr); }
@media (min-width: 1760px) { .scheme-grid { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); } }
.scheme-figure { padding: 6px; border: 1px solid var(--line); border-radius: var(--radius-small); background: #fff; }
.scheme-figure svg { display: block; width: 100%; height: auto; max-height: 720px; }

.proto-note { margin: 6px 0; color: var(--muted); font-size: .8rem; line-height: 1.5; }
.protocol h4 { margin: 18px 0 6px; padding-top: 4px; border-top: 1px solid #e3ebe9; color: var(--teal-dark); font-size: .92rem; }
.protocol h4:first-child { margin-top: 6px; border-top: 0; }
.mline.subst { padding-left: 2.4em; }
.assumption-tag { margin-left: 4px; padding: 0 6px; border-radius: 999px; background: var(--amber-soft); color: #5d3800; font: 700 .7rem Inter, system-ui, sans-serif; font-style: normal; white-space: nowrap; }
.accel-box { margin-top: 18px; padding: 12px 14px; border: 1px solid #dde7e4; border-radius: var(--radius-small); background: #f8fbfa; }
.accel-box h3 { margin: 0 0 6px; font-size: .92rem; }

/* ---- Окно с вырезкой: несколько картинок ---- */
.help-dialog__zoom + .help-dialog__zoom { margin-top: 10px; }
.help-dialog__figure { margin-top: 12px; }
.help-dialog__zoom img { width: 980px; }

@media (max-width: 600px) {
  .levels input { width: 80px; }
  .scheme-figure svg { max-height: none; }
}
@media print {
  .scheme-controls, .import-box, #addDirection, #addLevel, #toggleImport, .icon-btn, .cell-btn, #exportWord, #printPage { display: none !important; }
  .table-wrap { overflow: visible; border-color: #bbb; }
  .data-table th:first-child, .data-table td:first-child { position: static; }
  details.protocol > .protocol-body { display: block; }
}

.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.field.is-muted { opacity: .55; }

/* ---- Вычисленное значение видно сразу, формула — под стрелкой ---- */
.auto-value { margin: 0 0 11px; padding: 8px 11px; border: 1px solid #cfe5e1; border-radius: var(--radius-small); background: var(--green-soft); }
.auto-value[hidden] { display: none !important; }
.auto-value__main { display: block; font-size: .9rem; }
.auto-value__main b { font-size: 1.05rem; font-variant-numeric: tabular-nums; }
.auto-value__main small { color: var(--muted); font-size: .74rem; }
.auto-value sub { font-size: .7em; line-height: 0; }
details.calc-more { margin-top: 6px; }
details.calc-more > summary {
  display: inline-flex; align-items: center; gap: 6px; min-height: 28px; padding: 2px 4px; list-style: none;
  color: var(--teal-dark); font-size: .76rem; font-weight: 700; cursor: pointer; border-radius: 6px;
}
details.calc-more > summary::-webkit-details-marker { display: none; }
details.calc-more > summary::before { content: "▸"; display: inline-block; width: 1em; transition: transform .15s; }
details.calc-more[open] > summary::before { transform: rotate(90deg); }
details.calc-more > summary:hover { background: rgba(13, 102, 112, .08); }
.calc-more__body { margin-top: 4px; }
.calc-more__body .mbox { font-size: 1rem; }
.calc-more__body .table-wrap { margin-top: 6px; }
.result-card details.calc-more { margin-top: 8px; }
@media (prefers-reduced-motion: reduce) { details.calc-more > summary::before { transition: none; } }
@media print { details.calc-more > .calc-more__body { display: block; } }

/* Раскрытая формула внутри формы не должна растягивать страницу (ENGINEERING_UI, 5):
   у fieldset по умолчанию min-inline-size: min-content. */
fieldset, .dir-list, .dir-card, .auto-value, .calc-more__body, details.calc-more, .result-card { min-width: 0; max-width: 100%; }
.calc-more__body .mbox { max-width: 100%; }
/* Раскрытая карточка занимает всю строку сетки — формуле нужна ширина. */
.result-card:has(details.calc-more[open]) { grid-column: 1 / -1; }

/* ---- Интерактивные схемы: подсказки, ручка угла, пробный угол ---- */
.scheme-figure { position: relative; }
.scheme-figure svg .hit { fill: transparent; stroke: transparent; pointer-events: all; cursor: help; }
.scheme-figure svg rect.hit:hover { fill: rgba(13, 102, 112, .12); }
.scheme-figure svg .hit-line:hover { stroke: rgba(13, 102, 112, .22); }
.scheme-figure svg .drag-handle { cursor: grab; touch-action: none; }
.scheme-figure svg .drag-handle:active { cursor: grabbing; }
#planFigure { touch-action: pan-y; }
#planFigure svg .drag-handle { touch-action: none; }
.fig-tip {
  position: fixed; z-index: 60; max-width: min(320px, calc(100vw - 16px)); padding: 8px 11px; border-radius: 9px;
  background: #14252f; color: #f5f7f6; font-size: .8rem; line-height: 1.45; white-space: pre-line; pointer-events: none;
  box-shadow: 0 8px 24px rgba(15, 35, 40, .3); font-variant-numeric: tabular-nums;
}
.fig-tip[hidden] { display: none; }
.plan-wrap { display: grid; gap: 10px; min-width: 0; }
.trial { padding: 11px 13px; border: 1px solid var(--line); border-radius: var(--radius-small); background: #f8fbfa; }
.trial__head { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 4px 10px; margin-bottom: 8px; font-size: .88rem; }
.trial__state { color: var(--muted); font-size: .76rem; }
.trial__row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 12px; align-items: center; }
.trial__row input[type="range"] { width: 100%; min-height: 34px; accent-color: var(--teal); }
.trial__num { display: inline-flex; align-items: center; gap: 4px; font-weight: 700; }
.trial__num input { width: 78px; min-height: 38px; text-align: right; }
.trial__out { display: flex; flex-wrap: wrap; gap: 4px 14px; align-items: center; margin: 8px 0 6px; font-size: .84rem; }
.trial__verdict { padding: 1px 9px; border-radius: 999px; font-size: .76rem; font-weight: 750; }
.trial__verdict.ok { color: var(--green); background: var(--green-soft); }
.trial__verdict.bad { color: var(--amber); background: var(--amber-soft); }
.trial .hint { margin: 0 0 6px; }
.trial button:disabled { opacity: .45; cursor: default; }
@media print { .trial, .fig-tip { display: none !important; } }

/* ---- Формы колебаний, файл расчёта ---- */
.mode-card { padding: 11px 12px 12px; border: 1px solid var(--line); border-radius: var(--radius-small); background: #fbfdfc; }
.mode-card details.mini { margin-top: 4px; }
.legend-help { margin-left: 6px; min-height: 0; padding: 0; text-transform: none; letter-spacing: 0; }
.legend-help::after { content: none; }
.file-btn { display: inline-flex; align-items: center; min-height: 44px; padding: 10px 17px; border: 1px solid var(--line); border-radius: var(--radius-small); font-weight: 700; cursor: pointer; }
.file-btn:hover { border-color: var(--teal); background: var(--soft); }
input.is-auto { background: #f1f5f4; color: var(--muted); }
.dir-auto .auto-value + .auto-value { margin-top: 6px; }
.dir-auto[hidden] { display: none; }

.unit-bar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 0 0 10px; font-size: .82rem; color: var(--muted); }
.unit-bar select { min-width: 0; max-width: 100%; }

.rumb-preview { display: flex; justify-content: center; margin: 8px 0 4px; }
.rumb-preview svg { width: 100%; max-width: 300px; height: auto; border: 1px solid var(--line); border-radius: 10px; }

.scheme-demo { margin: 14px 0 0; }
.scheme-demo[hidden] { display: none; }
.symbols { display: grid; gap: 6px; margin: 12px 0 0; }
.symbols div { display: grid; grid-template-columns: minmax(64px, auto) 1fr; gap: 10px; align-items: baseline; }
.symbols dt { font-family: "Times New Roman", Times, serif; font-weight: 700; color: var(--teal-dark); }
.symbols dd { margin: 0; font-size: .84rem; color: #22343c; line-height: 1.45; }

/* таблица с текстом (требования других норм): строки переносятся, на узком экране — карточки */
.text-table th, .text-table td { white-space: normal; vertical-align: top; text-align: left; min-width: 11rem; line-height: 1.45; }
.text-table td:first-child { font-weight: 650; }
@media (max-width: 720px) {
  .text-table, .text-table tbody { display: block; }
  .text-table thead { display: none; }
  .text-table tr { display: block; padding: 8px 4px; border-bottom: 1px solid #e3ebe9; }
  .text-table td { display: block; min-width: 0; padding: 3px 6px; border: 0; }
  .text-table td::before { content: attr(data-label) ": "; display: block; color: var(--muted); font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; }
  .text-table td:first-child::before { display: none; }
}
