:root{
  --ink:#0F172A;
  --muted:#6b7280;
  --card:#ffffff;
  --line:#d8e0eb;
}
*{
  box-sizing:border-box;
  font-family:'Exo 2', system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, sans-serif;
}

.material-symbols-outlined {
  font-variation-settings: 'FILL' 0, 'wght' 400, 'GRAD' 0, 'opsz' 24;
  display: inline-block;
  vertical-align: middle;
  line-height: 1;
}

body.spcalc{
  margin:0;
  font-size: 16px;
  color:var(--ink);
  background: #4871b9;
  background-attachment:fixed;
  display:flex;
  min-height:100vh;
  align-items: initial;
}

.sidebar{
  width:260px;
  background:transparent;
  padding:24px;
  display:flex;
  flex-direction:column;
  gap:16px;
  color:#fff;
  border-right:none;
}
.logo{display:flex;align-items:center;gap:10px;font-weight:800;font-size:18px;color:#fff;text-decoration:none;height:56px;padding-left:4px}
.nav ul{list-style:none;margin:0;padding:0;display:flex;flex-direction:column;gap:8px}

.nav__link{
  display:flex;
  align-items:center;
  gap: 12px;
  color:#fff;
  text-decoration:none;
  padding:12px 14px;
  border-radius:12px;
  transition:background .25s ease;
  border: none;
  background: transparent;
}
.nav__icon{
  flex-shrink: 0;
}
.nav__link:hover{background:rgba(255,255,255,.12); transform: none;}

.nav__link--active{
  background: #1e488b;
  box-shadow: none;
}
.nav__link--highlight{font-weight:700;color:#fff; background:transparent; box-shadow:none;}

.scrim{position:fixed;inset:0;background:rgba(2,6,23,.4);backdrop-filter:blur(2px);opacity:0;pointer-events:none;transition:opacity .2s ease;z-index:59}
.content{flex:1;display:flex;flex-direction:column;min-width:0}

.topbar{
  position:sticky;
  top:0;
  z-index:60;
  background: #4871b9;
  border-bottom:none;
}
.topbar__inner{height:56px;display:flex;align-items:center;gap:12px;padding:0 12px}
.btn{appearance:none;border:0;border-radius:12px;padding:10px 14px;font-weight:700;cursor:pointer}
.btn--menu{display:none;font-size:18px;line-height:1;background:#fff;border:1px solid #E2E8F0;color:#0F172A;border-radius:10px}
.toolbar{display:flex;align-items:center;gap:8px;flex:1 1 auto}
.toolbar__spacer{flex:1 1 auto}

.btn--tbar{
  background:#214e99;
  color:#fff;
  border:none;
}
.btn--tbar-strong{
  background:#214e99;
  color:#fff;
  border:none;
}

.main{
  background: #f0f2f5;
  border-top-left-radius:36px;
  padding:24px 28px 28px;
  flex:1;
  min-height:0;
  display:flex;
  flex-direction:column;
  gap:20px;
  backdrop-filter:none;
  box-shadow:none;
}

.footer {
  margin-top: auto;
  padding-top: 16px;
  border-top: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px;
}
.footer .disclaimer {
  margin: 0;
  font-size: 12px;
  color: var(--muted);
}
.footer .version {
  margin: 0;
  font-size: 12px;
  color: var(--muted);
  opacity: 0.6;
}

.page-head__title,
.panel__head h2 {
  font-size: 32px;
  font-weight: 700;
  background: none;
  -webkit-background-clip: initial;
  background-clip: initial;
  color: var(--ink);
}
.page-head {
  margin-bottom: 12px;
}
.page-head__title{
  margin: 0 0 6px 0;
  line-height: 1.2;
}
.page-head__subtitle{
  margin: 0;
  font-size: 16px;
  color: var(--muted);
  background: none;
  -webkit-background-clip: initial;
  background-clip: initial;
  opacity: 1;
}

.calc-grid{display:grid;grid-template-columns:1.1fr 1.7fr;grid-template-areas:'main-left main-right' 'results results';gap:20px;align-items:start}
#left-stack{grid-area:main-left;display:flex;flex-direction:column;gap:20px;min-height:0;min-width:0}
.panel{background:var(--card);border-radius:16px;box-shadow:0 6px 18px rgba(0,0,0,.06)}
.panel__head{display:flex;align-items:center;justify-content:space-between;padding:12px 14px;border-bottom:1px solid var(--line)}
.panel__body{padding:12px;min-height:0;display:flex;flex-direction:column;}
.panel__footer{ padding: 6px 12px; border-top: 1px solid var(--line); font-size: 12px; color: #64748b; text-align: center; }
.panel--inputs{padding:14px;display:flex;flex-direction:column;gap:10px}

/* === Стили для ВСЕХ переключателей === */
.tabs, .segmented {
  display: grid;
  grid-template-columns: 1fr 1fr;
  background: #e1eaf7;
  border: 1px solid #E2E8F0;
  border-radius: 10px;
  overflow: hidden;
  padding: 0;
}
.tabs__btn, .seg {
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 10px 10px; 
  background: transparent;
  color: #374151;
  font-weight: 600;
  font-size: 14px;
  border: none;
  cursor: pointer;
  text-align: center;
  transition: background-color 0.2s, color 0.2s;
  min-height: 38px; 
}
.tabs__btn--active, .seg:has(input:checked) {
  background: #214e99;
  color: #fff;
}
.seg input {display: none;}
/* ================================================= */


.form--grid{display:grid;grid-template-columns:1fr 1fr;gap:10px;align-items:start;
  grid-template-areas:
    'method method'
    'diam work'
    'class util'
    'util-calc util-calc'
    'concrete concrete-type'
    'bundle bundle'
    'construct construct'
    'bundle-count bundle-count'
    'advanced advanced'
    'expert expert';
}
.field{display:flex;flex-direction:column;gap:4px;position:relative}

.ank-specific-fields { grid-area: method; }
.lap-specific-fields { grid-area: method; }
#field-bundle-count { grid-area: bundle-count; }

.field label{font-size:13px}

.field input{
  padding: 10px 10px; 
  border:1px solid #E2E8F0;
  border-radius:8px;
  background:#e1eaf7;
  font-size:14px;
  min-height: 38px; 
}
.field .field-value {
  padding: 10px 10px;
  border: 1px solid #E2E8F0;
  border-radius: 8px;
  background: #e1eaf7;
  font-size: 14px;
  font-weight: 600;
  color: #374151;
  min-height: 38px; 
}

.field.ga-diam{grid-area:diam}
.field.ga-work{grid-area:work}
.field.ga-class{grid-area:class}
.field.ga-concrete{grid-area:concrete}
.field.ga-concrete-type{grid-area:concrete-type}
.field.ga-method{grid-area:method}
.field.ga-extra{grid-area:extra}
.field.ga-bundle{grid-area:bundle}
.field.ga-util{grid-area:util}
#util-calc-block{grid-area:util-calc}
.panel--inputs-cta{grid-area:advanced}
.panel--2d{background:var(--card);border-radius:16px;box-shadow:0 6px 18px rgba(0,0,0,.06);padding:4px;flex-shrink:0}

/* Ensure the bottom outline has the same visual offset as the top. */
.fieldset.stretch{grid-area:construct;border:none;border-radius:10px;padding:8px}
.fieldset legend{padding:0 6px;color:#374151;font-size:13px}
#advanced-fieldset-ank,#advanced-fieldset-lap{grid-column:1 / -1}
.check{display:flex;align-items:center;gap:6px;margin:4px 0;font-size:13px}
.check.inline{display:inline-flex;margin-right:10px}
.field.small input{padding:6px;font-size:13px}
.extra-grid{display:grid;grid-template-columns:repeat(auto-fit, minmax(180px, 1fr));gap:8px}

.exp-help{
  margin-top:10px;
  border:1px solid #E2E8F0;
  border-radius:10px;
  background:#FFFFFF;
  padding:10px;
}
.exp-help-title{
  font-weight:700;
  margin-bottom:6px;
}
.exp-help-body{
  font-size:13px;
  line-height:1.45;
}
.exp-help .kv{ display:grid; grid-template-columns:140px 1fr; gap:6px 10px; margin-top:6px }
.exp-help .muted{ color:#64748B; font-size:12px }

.warn-line{ padding:8px 10px; border:1px solid #F59E0B; background:#FFFBEB; border-radius:8px; margin:6px 0; }
.warn-line b{ color:#92400E }

.field[data-help]::after, .check[data-help]::after{content:none !important}
.tooltip{position:fixed;left:0;top:0;transform:translate(-50%,-120%);background:#0F172A;color:#fff;padding:8px 10px;border-radius:8px;box-shadow:0 10px 20px rgba(0,0,0,.15);font-size:12px;line-height:1.35;pointer-events:none;opacity:0;transition:opacity .12s ease, transform .12s ease;z-index:1000;max-width:460px}
.tooltip--show{opacity:1;transform:translate(-50%,-100%)}

.panel--inputs-cta{
  padding:0;
  grid-column: 1 / -1;
}
.cta-wrap{display:flex;gap:8px;align-items:center}

.btn--ghost{
  padding: 10px 10px; 
  background: #214e99;
  color: #fff;
  border: none;
  border-radius: 10px;
  font-size: 14px; 
  font-weight: 700;
  min-height: 38px; 
  width: 100%; 
  box-sizing: border-box; 
}
.btn--wide{width:100%;justify-content:center} 

#advanced-fieldset{
  grid-column:1 / -1;
  grid-area: expert;
  border: 1px dashed #E2E8F0;
  border-radius: 8px;
  padding: 10px;
  background: #fff;
}
#advanced-fieldset .adv-grid{display:grid;grid-template-columns:repeat(2, 1fr);gap:6px}
#advanced-fieldset .adv-grid .field{min-width:0}
#advanced-fieldset .adv-grid .field label{font-size:11px;white-space:normal;flex:1}
#advanced-fieldset .adv-grid .field input{padding:6px 4px;font-size:12px;min-width:0;width:100%;box-sizing:border-box;margin-top:auto}
#advanced-fieldset .adv-group-label{font-size:11px;font-weight:600;color:#64748b;text-transform:uppercase;letter-spacing:.04em;margin:6px 0 2px 0}
#advanced-fieldset .adv-hint{font-size:11px;color:#64748b;margin:0 0 6px 0;line-height:1.4}
/* Embedded expert panel: 4 колонки → 2 строки */
#emb-form #advanced-fieldset .adv-grid{grid-template-columns:repeat(4, 1fr)}
#view-stack{grid-area:main-right;display:flex;flex-direction:column;gap:20px;min-height:0;overflow:hidden}
#view-stack{position:relative}

#viewport3d,#viewport2d{display:flex;flex-direction:column;min-height:390px;flex:1 1 0}

.figure { 
  border: 1px solid #e2e8f0; 
  border-radius: 10px; 
  overflow: hidden; 
  background: #fff; 
  margin: 0;
  height: 100%;
  display: flex;
  flex-direction: column;
}
.svg2d { 
  width: 100%; 
  display: block; 
  flex: 1 1 auto;
  height: 100%;
}
.canvas3d { 
  width: 100%; 
  height: 100%; 
  display: block; 
  background: #f8fafc; 
  border: 1px solid #e2e8f0; 
  border-radius: 10px; 
}
.figure figcaption {
  padding: 8px 12px;
  text-align: center;
  font-size: 13px;
  color: #64748b;
  background: #f8fafc;
  border-top: 1px solid #e2e8f0;
}
.svg2d .dim-text { font-size:14px; fill:#0f172a; font-weight:600; }
.svg2d .note-text { font-size:13px; fill:#334155; }
.svg2d .dim-line { stroke:#4b5563; stroke-width:1; fill:none; shape-rendering:crispEdges; }
.svg2d .bar-main { stroke:#334155; stroke-width:2; stroke-linecap:butt; shape-rendering:crispEdges; }
.svg2d .bar-lap  { fill:#2563eb1f; stroke:#2563EB; stroke-width:1.5; }
.svg2d .lap-overlay { stroke:#334155; stroke-width:2; stroke-linecap:butt; shape-rendering:crispEdges; }
#viewport2d .panel__body svg text{ font-weight:600; fill:#0f172a; }

#results{grid-area:results}
#emb-results{grid-area:results}
.results__wrap{display:grid;grid-template-columns:1.4fr .6fr;gap:14px}
.result-card{width:100%;border:1px solid #E2E8F0;border-radius:14px;padding:16px;background:#fff;box-shadow:0 6px 18px rgba(0,0,0,.06)}
.result-hero{display:flex;align-items:center;gap:12px;padding:16px;border-radius:14px;background:linear-gradient(180deg,#EFF6FF,#ffffff);border:1px solid #DBEAFE}

.result-hero__value,
.results__norms h3,
.formulas h3 {
  font-size: 24px;
  font-weight: 700;
}
.formula-block {
  margin-bottom: 20px;
  padding: 12px;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  background: #fff;
}
.formula-block h4 {
  margin: 0 0 10px;
  font-size: 16px;
  display: flex;
  justify-content: space-between;
  align-items: baseline;
}
.formula-vars {
  list-style: none;
  padding: 0;
  margin: 8px 0;
  font-size: 14px;
  color: #475569;
}
.formula-vars li {
  margin-bottom: 4px;
}
.final-result-block {
    list-style: none;
    padding: 12px;
    margin-top: 16px;
    background: #eff6ff;
    border: 1px solid #dbeafe;
    border-radius: 12px;
    text-align: center;
}
.final-result-block h4 {
  margin: 0 0 8px;
  font-size: 16px;
}

.result-hero__value strong{
  font-size:36px;
  line-height:1;
  background:none;
  -webkit-background-clip: initial;
  background-clip: initial;
  color:var(--ink);
  font-weight: 600;
}

.results__actions{display:flex;gap:12px;margin-top:16px}
.results__actions .btn{flex:1;justify-content:center}

.result-caption{margin:8px 2px 0;color:#64748B;font-size:12px}
.formulas{margin-top:16px}
.formula-list{margin:0 0 8px 18px;padding:0}
.formula-list li{margin:6px 0}
.norm-link{color:#2563EB;text-decoration:none;font-weight:600}
.muted{color:#6b7280}
.footer{color:#6b7280; display: flex; justify-content: space-between; align-items: center;}
.disclaimer{font-size:12px;margin:0}
.version{font-size:12px;margin:0}
.is-hidden{display:none !important}

/* === ACCESSIBILITY: Focus-visible === */
input:focus-visible,
select:focus-visible,
button:focus-visible,
.custom-select__trigger:focus-visible,
.tabs__btn:focus-visible,
.seg:focus-visible,
.control-btn:focus-visible,
.nav__link:focus-visible,
.btn:focus-visible {
  outline: 2px solid #2563eb;
  outline-offset: 2px;
}

/* === СТИЛИ ДЛЯ ВЫПАДАЮЩЕГО СПИСКА === */
.custom-select-wrapper { position: relative; width: 100%; }
.custom-select__trigger {
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px 10px; border: 1px solid #E2E8F0; border-radius: 8px;
  background: #e1eaf7; cursor: pointer; user-select: none;
  font-size: 14px; font-weight: 600; min-height: 38px;
}
.field.small .custom-select__trigger { padding: 8px; }
.custom-select__arrow {
  width: 0; height: 0; border-left: 5px solid transparent;
  border-right: 5px solid transparent; border-top: 5px solid #6b7280;
  transition: transform 0.2s ease;
}
.custom-select-wrapper.is-open .custom-select__arrow { transform: rotate(180deg); }
.custom-select__options {
  position: absolute; top: calc(100% + 4px); left: 0; right: 0;
  background: #fff; border: 1px solid #E2E8F0; border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.1); z-index: 10; max-height: 250px;
  overflow-y: auto; opacity: 0; visibility: hidden;
  transform: translateY(-10px); transition: opacity 0.2s ease, transform 0.2s ease, visibility 0.2s;
}
.custom-select-wrapper.is-open .custom-select__options { opacity: 1; visibility: visible; transform: translateY(0); }
.custom-select__option { padding: 10px 14px; cursor: pointer; margin: 4px; border-radius: 8px; }
.custom-select__option:hover { background-color: #e1eaf7; }
.custom-select__option.is-selected { background-color: #e1eaf7; color: var(--ink); font-weight: 600; }

/* === СТИЛИ ДЛЯ ЧЕКБОКСОВ === */
.check input[type="checkbox"] {
  appearance: none; -webkit-appearance: none; -moz-appearance: none;
  width: 18px; height: 18px; border: 2px solid #6b7280; border-radius: 6px;
  outline: none; cursor: pointer; display: inline-block; vertical-align: middle;
  position: relative; flex-shrink: 0; transition: border-color 0.2s ease, background-color 0.2s ease;
}
.check input[type="checkbox"]:hover { border-color: #214e99; }
.check input[type="checkbox"]:checked { background-color: #214e99; border-color: #214e99; }
.check input[type="checkbox"]:checked::before {
  content: ''; position: absolute; top: 50%; left: 50%;
  width: 5px; height: 9px; border: solid #fff; border-width: 0 2px 2px 0;
  transform: translate(-50%, -60%) rotate(45deg);
}

.help-icon{margin-left:6px;font-size:13px;line-height:1;padding:4px 8px;border:1px solid #E2E8F0;background:#fff;border-radius:50%;cursor:pointer;width:26px;height:26px;display:inline-flex;align-items:center;justify-content:center}
.mu-popover{margin-top:8px;padding:10px;border:1px solid #E2E8F0;border-radius:10px;background:#ffffff}
.mu-grid{display:grid;grid-template-columns:repeat(auto-fit,minmax(130px,1fr));gap:8px}
.mu-grid label{display:flex;flex-direction:column;gap:6px;font-size:12px}
.mu-note{font-size:12px;color:#6b7280;margin-bottom:6px}
.mu-mode{display:flex;gap:10px;font-size:12px;margin-bottom:6px}
.mu-actions{margin-top:6px;display:flex;justify-content:flex-end}

#viewport3d .panel__footer { pointer-events: none; }
#viewport2d .panel__body{padding:14px 14px 40px 14px; display:flex; flex-direction:column; align-items:center; justify-content:center}
#viewport2d .panel__body .figure { height: auto; display: flex; flex-direction: column; width: 100%; }
#viewport2d .panel__body .figure > .svg { flex: 0 0 auto; width: 100%; height: auto; }
#viewport2d .svg2d { max-width: 100%; margin: 0 auto; display:block }
.panel__head--compact { padding: 8px 12px; }
.panel__title--compact { font-size: 16px; line-height: 1.2; margin: 0; }

.required-block, .actual-block { background: none; border: none; }
.required-block {
  background: #e1eaf7; border: 1px solid #E2E8F0; border-radius: 8px;
  padding: 10px; font-size: 14px; color: #374151;
}
.expert-mode {
  border: 1px dashed #E2E8F0; border-radius: 8px; padding: 10px; background: #fff;
}

input { font-size: 14px; }
label { font-size: 14px !important; }

/* Стили для fieldset */
.util-fieldset {
  border: 1px dashed #E2E8F0 !important; border-radius: 8px !important;
  padding: 10px !important; background: #fff !important; margin: 0 !important;
  display: flex; flex-direction: column; gap: 8px;
}
.util-fieldset legend {
  padding: 0 6px !important; color: #0f172a !important; font-size: 13px !important;
  font-weight: 600 !important; text-transform: none !important;
}

.field.ga-util input { font-size: 14px !important; font-weight: 600 !important; color: #0f172a !important; }
#exp-Rs, #exp-Rbt, #exp-eta1, #exp-eta2 {
  font-size: 14px !important; font-weight: 600 !important; color: #0f172a !important;
}
.field.ga-util input::placeholder,
#exp-Rs::placeholder, #exp-Rbt::placeholder, #exp-eta1::placeholder, #exp-eta2::placeholder {
  color: #0f172a !important; opacity: 0.6 !important;
}

#util-calc-block { background: transparent !important; border: none !important; }

.warn-inline {
  padding: 8px 12px; margin-top: 6px; background: #FEF2F2;
  border: 1px solid #FCA5A5; border-radius: 8px; color: #991B1B;
  font-size: 13px; line-height: 1.5;
}
.warn-inline b { color: #7F1D1D; }
.field.invalid input, .field.invalid select {
  border-color: #F87171 !important; background-color: #FEF2F2 !important;
}
.svg-warning {
  margin-top: 12px; padding: 12px 16px; background: #FEF2F2;
  border: 1px solid #FCA5A5; border-radius: 8px; color: #991B1B;
  font-size: 14px; line-height: 1.6; display: none;
}
.svg-warning:not(:empty) { display: block; }
.svg-warning b { color: #7F1D1D; font-weight: 600; }

/* ========================================================== */
/* СТИЛИ ДЛЯ СТРАНИЦЫ EMBEDDED (ЗАКЛАДНАЯ ДЕТАЛЬ)            */
/* ========================================================== */

/* Многоколоночные вкладки (Параметры / Геометрия / Нагрузки) */
.tabs--full {
  display: flex;
  background: #e1eaf7;
  border: 1px solid #E2E8F0;
  border-radius: 10px;
  overflow: hidden;
  margin-bottom: 20px;
}
.tabs--full .tabs__btn {
  flex: 1;
}

/* Переключатель вида графики (3D / Призма / План / Разрез) */
.control-group {
  display: flex;
  background: #e1eaf7;
  border: 1px solid #E2E8F0;
  border-radius: 8px 8px 0 0;
  overflow: hidden;
}
.control-btn {
  flex: 1;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 10px;
  background: transparent;
  color: #374151;
  font-weight: 600;
  font-size: 14px;
  border: none;
  cursor: pointer;
  transition: background-color 0.2s, color 0.2s;
  min-height: 38px;
  font-family: inherit;
}
.control-btn.active {
  background: #214e99;
  color: #fff;
}

/* Поле ввода с выбором единиц (кН / тс / МПа…) */
.input-unit-group {
  display: flex;
  gap: 8px;
}
.input-unit-group input {
  flex: 1;
}
.input-unit-group select {
  width: 85px;
  padding: 6px 4px;
  border: 1px solid #E2E8F0;
  border-radius: 8px;
  background: #e1eaf7;
  font-size: 12px;
  min-height: 38px;
}

/* Заголовки-разделители внутри формы */
.group-divider {
  font-size: 11px;
  font-weight: 700;
  color: #94a3b8;
  text-transform: uppercase;
  border-bottom: 1px solid #e2e8f0;
  padding-bottom: 5px;
  margin: 15px 0;
}
.form-grid-2 .group-divider {
  grid-column: 1 / -1;
}

/* 2-колоночная сетка полей */
.form-grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  align-items: start;
}

/* Анимируемые панели-вкладки внутри формы */
.input-views-wrap {
  display: grid;
}
/* Уходящая вкладка скрывается мгновенно — без перехода */
.input-view {
  grid-area: 1 / 1;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: none;
  min-width: 0;
}
/* Активная вкладка плавно появляется */
.input-view.active {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transition: opacity 0.22s ease;
}

/* Футер сайдбара — всегда прижат к низу */
.sidebar-footer {
  margin-top: auto;
  padding-top: 20px;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
}

/* ========================================================== */
/* MEDIA QUERIES (ВСЕГДА В КОНЦЕ ФАЙЛА, ЧТОБЫ ПЕРЕКРЫВАТЬ) */
/* ========================================================== */

@media (max-width: 1100px) {
  .calc-grid {
    grid-template-columns: 1fr;
    grid-template-areas:
      'main-left'
      'main-right'
      'results';
  }
  .results__wrap { grid-template-columns: 1fr; }
  
  /* На одностолбцном виде сбрасываем выравнивание по высоте — каждая секция самостоятельна */
  #calc-grid { align-items: start !important; }
  #left-stack, #view-stack { height: auto !important; }
  #left-stack .panel--inputs { flex: none !important; overflow-y: visible !important; }
  #view-stack > .panel { flex: none !important; }
  #view-stack .figure { flex: none !important; height: 380px !important; min-height: 0 !important; position: relative !important; }

  #view-stack {
    min-height: 350px !important; 
    display: flex !important;
    margin-bottom: 20px;
  }
  .panel--2d { width: 100%; height: 100%; display: flex; flex-direction: column; }
  .figure { flex: 1; min-height: 300px; }

  .sidebar {
    position: fixed; left: -280px; top: 0; height: 100dvh; z-index: 60;
    transition: left .2s ease; backdrop-filter: saturate(140%);
  }
  body.sidebar-open .sidebar { left: 0; }
  body.sidebar-open .scrim { opacity: 1; pointer-events: auto; }
  .btn--menu { display: inline-flex; }
}

@media (max-width: 640px) {
  /* 1. Уменьшаем заголовки */
  .page-head { margin-bottom: 10px; }
  .page-head__title, .panel__head h2 {
    font-size: 20px;
    line-height: 1.25;
    margin-bottom: 4px;
  }
  .page-head__subtitle { font-size: 13px; }
  .result-hero__value strong { font-size: 32px; }

  .tabs__btn { padding: 8px 10px; }
  .topbar__inner { gap: 8px; }

  /* 2. Общая сетка формы в 1 колонку */
  .form--grid {
    grid-template-columns: 1fr;
    grid-template-areas:
      'method'
      'diam'
      'work'
      'class'
      'util'
      'util-calc' /* Добавлена область для калькулятора */
      'concrete'
      'concrete-type'
      'bundle'
      'construct'
      'bundle-count'
      'advanced'
      'expert';
  }

  /* 3. ИСПРАВЛЕНИЕ: Блок расчета μ */
  /* Переопределяем inline-стили для сетки */
  #util-calc-block > div {
    display: grid !important;
    grid-template-columns: 1fr !important; /* Одна колонка */
    gap: 8px !important;
  }
  /* Убираем отрицательные отступы, ломающие верстку на мобильных */
  #util-calc-block > div > .util-fieldset:first-child,
  #util-calc-block > div > .util-fieldset:last-child {
    margin-left: 0 !important;
    margin-right: 0 !important;
  }

  /* 4. ИСПРАВЛЕНИЕ: Экспертный режим */
  /* Вместо 4 колонок делаем 2, чтобы влезало */
  #advanced-fieldset .adv-grid {
    grid-template-columns: 1fr 1fr;
  }
}

/* ═══════════════════════════════════════════════════════════
   2D-схемы модуля «Закладная деталь»
   ═══════════════════════════════════════════════════════════ */

/* SVG масштабируется по ширине контейнера, не раздувает строку грида */
#emb-svg-plan svg,
#emb-svg-section svg,
#emb-view-prism svg {
    width: 100%;
    height: auto;
    display: block;
}

/* ═══════════════════════════════════════════════════════════
   Карточки результатов модуля «Закладная деталь»
   ═══════════════════════════════════════════════════════════ */

.emb-card {
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  margin-bottom: 10px;
  overflow: hidden;
  font-size: 13px;
}

.emb-card--pass {
  border-color: #86efac;
  background: #f0fdf4;
}

.emb-card--fail {
  border-color: #fca5a5;
  background: #fff1f2;
}

.emb-card__head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 12px;
  font-weight: 600;
  background: rgba(0,0,0,0.04);
  border-bottom: 1px solid inherit;
}

.emb-card--pass .emb-card__head { background: #dcfce7; }
.emb-card--fail .emb-card__head { background: #fee2e2; }

.emb-card__status {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  padding: 2px 7px;
  border-radius: 4px;
  background: rgba(0,0,0,0.08);
}

.emb-card--pass .emb-card__status { color: #14532d; background: #bbf7d0; }
.emb-card--fail .emb-card__status { color: #7f1d1d; background: #fecaca; }

.emb-card__row {
  display: flex;
  justify-content: space-between;
  padding: 4px 12px;
  border-top: 1px solid rgba(0,0,0,0.06);
}

.emb-card__row:first-child { border-top: none; }

.emb-card__util {
  font-weight: 700;
}

.emb-card__det {
  padding: 4px 12px 8px;
  border-top: 1px dashed #cbd5e1;
  font-size: 12px;
}

.emb-card__det summary {
  cursor: pointer;
  color: #3b82f6;
  padding: 4px 0;
  font-size: 12px;
}
.emb-card__reason {
  padding: 4px 12px 6px;
  font-size: 12px;
  color: #991b1b;
  font-style: italic;
  border-top: 1px dashed #fca5a5;
}

.emb-card__det-body {
  padding: 4px 0 2px;
}

.emb-det__row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 2px 0;
  gap: 8px;
}

.emb-det__label {
  color: #475569;
  flex: 1;
}

.emb-det__val {
  font-weight: 600;
  color: #1e293b;
  white-space: nowrap;
}

.emb-det__hint {
  color: #94a3b8;
  font-size: 10px;
  font-weight: 400;
  margin-left: 4px;
}

.emb-det__sep {
  border: none;
  border-top: 1px solid #e2e8f0;
  margin: 4px 0;
}

.emb-card__advice {
  margin-top: 6px;
  padding: 6px 10px;
  background: #eff6ff;
  border-left: 3px solid #3b82f6;
  border-radius: 0 4px 4px 0;
  font-size: 12px;
  color: #1e40af;
  line-height: 1.5;
}

.emb-warns {
  background: #fefce8;
  border: 1px solid #fde68a;
  border-radius: 6px;
  padding: 8px 12px;
  margin-bottom: 10px;
  font-size: 12px;
  color: #92400e;
  line-height: 1.6;
}

.emb-error {
  color: #dc2626;
  font-size: 13px;
}

.emb-checks-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 6px 0 4px;
}

.emb-sum__item {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  border: 1px solid transparent;
}

.emb-sum__item--pass {
  color: #14532d;
  background: #dcfce7;
  border-color: #86efac;
}

.emb-sum__item--fail {
  color: #7f1d1d;
  background: #fee2e2;
  border-color: #fca5a5;
}

/* === New elements for embedded module === */
.emb-det__ref {
  color: #3b82f6;
  font-size: 10px;
  font-weight: 400;
  margin-left: 6px;
  white-space: nowrap;
}

.emb-det__section-title {
  font-size: 11px;
  font-weight: 700;
  color: #64748b;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 4px 0 2px;
  margin-top: 4px;
}

.emb-details-wrap {
  margin-top: 8px;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  overflow: hidden;
}

.emb-details-toggle {
  cursor: pointer;
  padding: 8px 12px;
  font-size: 13px;
  font-weight: 600;
  color: #3b82f6;
  background: #f8fafc;
  list-style: none;
  user-select: none;
}

.emb-details-toggle::-webkit-details-marker { display: none; }

.emb-details-body {
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.emb-caption-fail {
  font-size: 12px;
  color: #991b1b;
  padding: 4px 0;
}

.emb-caption-warn { font-size: 12px; color: #b45309; padding: 4px 0; }

.emb-caption-error {
  font-size: 12px;
  color: #dc2626;
  padding: 4px 0;
  font-weight: 600;
}

/* sync view-stack to match left column height */
#view-stack { display: flex; flex-direction: column; }
#view-stack .panel { flex: 1; min-height: 0; }

