/* ==========================================================================
   master.css — оформление мастера сквозного расчёта
   ========================================================================== */
.mst {
  --mst-muted: #47546a;
  --mst-muted-strong: #3a4658;
  max-width: 1200px;
  margin: 0 auto;
  padding: 20px 16px 60px;
  font-size: 15px;
  line-height: 1.5;
}

.mst__head {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 14px;
}
.mst__h1 {
  margin: 0 0 6px;
  font-size: 26px;
  line-height: 1.2;
}
.mst__lead {
  margin: 0;
  max-width: 70ch;
  color: var(--mst-muted-strong);
}
.mst__toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 10px;
  align-items: center;
  justify-content: space-between;
}
.mst__grp {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}
.mst__grp--l, .mst__grp--r { flex: 0 0 auto; }
.mst__grp--c { flex: 1 1 auto; justify-content: center; }

/* --- выпадающие меню («Загрузить ▾», «Экспорт ▾») --- */
.mdrop { position: relative; display: inline-block; }
.mdrop__m {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  z-index: 80;
  min-width: 230px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 6px;
  border: 1px solid rgba(127, 127, 127, .35);
  border-radius: 10px;
  background: var(--surface, #fff);
  box-shadow: 0 12px 30px rgba(0, 0, 0, .18);
  text-align: left;
}
.mdrop__m[hidden] { display: none; }
.mbtn--mi { width: 100%; text-align: left; }
.mbtn--dd { display: inline-flex; align-items: center; gap: 6px; }
.mbtn__caret { font-size: 11px; opacity: .7; }
.mst__sep {
  width: 1px;
  height: 22px;
  background: rgba(127, 127, 127, .35);
  margin: 0 4px;
}

.mbtn {
  font: inherit;
  font-size: 13px;
  padding: 7px 12px;
  border-radius: 8px;
  border: 1px solid rgba(127, 127, 127, .45);
  background: rgba(127, 127, 127, .10);
  color: inherit;
  cursor: pointer;
  transition: background .15s, border-color .15s;
}
.mbtn:hover { background: rgba(127, 127, 127, .2); }
.mbtn--accent {
  background: #1a6fd4;
  border-color: #1a6fd4;
  color: #fff;
  font-weight: 600;
}
.mbtn--accent:hover { background: #1560ba; }
.mbtn--del { color: #c0392b; }
.mbtn--add { margin-top: 8px; }
.mbtn--big { padding: 9px 14px; font-weight: 600; }

.mst__status {
  min-height: 22px;
  font-size: 13px;
  opacity: 0;
  transition: opacity .2s;
  margin-bottom: 8px;
}
.mst__status.is-on { opacity: 1; color: var(--mst-muted-strong); }

/* заметная плашка-уведомление о незаполненных позициях */
.mst__status.is-warn {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
  margin: 0 0 12px;
  padding: 10px 14px;
  border: 1px solid #e3b341;
  border-left: 4px solid #b7791f;
  border-radius: 8px;
  background: #fff8e6;
  color: #6b4a05;
  font-size: 14px;
  font-weight: 600;
  opacity: 1;
}
html.dark-theme .mst__status.is-warn {
  border-color: #7a5c1c;
  border-left-color: #e0b354;
  background: rgba(224, 179, 84, .12);
  color: #f0d9a6;
}
.mst__status-txt { flex: 1 1 260px; min-width: 200px; }
.mst__status-act { display: flex; flex-wrap: wrap; gap: 8px; }
.mst__status-btn {
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  padding: 6px 12px;
  border: 1px solid #b7791f;
  border-radius: 6px;
  background: #fff;
  color: #7a4f04;
  cursor: pointer;
}
.mst__status-btn:hover { background: #fdf3d9; }
.mst__status-btn:focus-visible { outline: 2px solid #b7791f; outline-offset: 2px; }
html.dark-theme .mst__status-btn {
  background: rgba(0, 0, 0, .35);
  border-color: #a5822f;
  color: #f0d9a6;
}
html.dark-theme .mst__status-btn:hover { background: rgba(224, 179, 84, .18); }

/* обязательные поля: звёздочка и подсветка незаполненных */
.mf__req {
  margin-left: 3px;
  color: #b42318;
  font-weight: 700;
}
html.dark-theme .mf__req { color: #ff9a8f; }
.mf--miss .mf__i {
  border-color: #d92d20;
  background: #fff5f4;
  box-shadow: 0 0 0 2px rgba(217, 45, 32, .12);
}
html.dark-theme .mf--miss .mf__i {
  border-color: #f0685c;
  background: rgba(217, 45, 32, .12);
}
.mf--miss .mf__l { color: #b42318; }
html.dark-theme .mf--miss .mf__l { color: #ff9a8f; }
.mf--flash .mf__i {
  animation: mfFlash 2.2s ease-out 1;
}
@keyframes mfFlash {
  0%, 40% { box-shadow: 0 0 0 4px rgba(217, 45, 32, .28); }
  100% { box-shadow: 0 0 0 0 rgba(217, 45, 32, 0); }
}

/* длинные значения выпадающих списков: шире колонка + подсказка полного значения */
.mf__i--sel { text-overflow: ellipsis; }
@media (min-width: 900px) {
  .mc__grid .mf--wide { grid-column: span 2; }
  .mc__grid .mf--full { grid-column: 1 / -1; }
}

.mtabs {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid rgba(127, 127, 127, .3);
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.mtabs__b {
  font: inherit;
  font-size: 14px;
  padding: 9px 16px;
  border: 0;
  background: none;
  color: var(--mst-muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
}
.mtabs__b.is-active { color: inherit; font-weight: 600; border-bottom-color: #1a6fd4; }

/* --- карточки разделов --- */
.mc {
  border: 1px solid rgba(127, 127, 127, .28);
  border-radius: 12px;
  padding: 14px 16px;
  margin-bottom: 14px;
  background: rgba(127, 127, 127, .05);
}
.mc__h {
  margin: 0 0 12px;
  font-size: 17px;
}
.mc__b { display: block; }
.mc__grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 10px 14px;
}
.mc__hint {
  margin: 12px 0 0;
  font-size: 13px;
  color: var(--mst-muted);
}
.mc__warn {
  margin: 10px 0 0;
  font-size: 13px;
  color: #b7791f;
}
/* поля и разделы методики, которая не применяется к выбранному классу (Ф):
   скрываются, но остаются в DOM и в модели (значения сохраняются) */
[data-meth].is-off { display: none !important; }
html.dark-theme .mc__warn { color: #e0b354; }
html.dark-theme .mst { --mst-muted: #a7b3c4; --mst-muted-strong: #c3cddb; }

/* --- переключатель режима объекта: внутренний / наружный --- */
.msw {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
}
.msw__t { font-size: 13px; color: var(--mst-muted); }
.msw__b {
  font: inherit;
  font-size: 13.5px;
  line-height: 1.2;
  width: auto;
  flex: 0 0 auto;
  padding: 8px 14px;
  border-radius: 999px;
  border: 1px solid rgba(127, 127, 127, .45);
  background: rgba(255, 255, 255, .45);
  color: inherit;
  cursor: pointer;
  transition: background .15s, border-color .15s, color .15s;
}
html.dark-theme .msw__b { background: rgba(255, 255, 255, .06); }
.msw__b:hover { background: rgba(127, 127, 127, .2); }
.msw__b.is-on {
  background: #1a6fd4;
  border-color: #1a6fd4;
  color: #fff;
  font-weight: 600;
}
.msw__b:focus-visible { outline: 2px solid #1a6fd4; outline-offset: 2px; }

/* --- свёрнутый блок «Дополнительно» --- */
.madd {
  margin-top: 14px;
  border: 1px solid rgba(127, 127, 127, .28);
  border-radius: 10px;
  background: rgba(127, 127, 127, .05);
}
.madd__s {
  cursor: pointer;
  padding: 10px 14px;
  font-size: 14px;
  font-weight: 600;
  list-style-position: inside;
}
.madd__b { padding: 0 14px 12px; }
.mbtn--mini {
  font-size: 12px;
  padding: 2px 9px;
  width: auto;
  flex: 0 0 auto;
  vertical-align: baseline;
}

.mf { display: flex; flex-direction: column; gap: 4px; position: relative; }
/* style.css переводит все label в CAPS (uppercase, 11px, mono) — для мастера
   подписи полей оставляем в обычном регистре и на 1–2 px крупнее */
.mf, .mf__l, .mf--chk {
  text-transform: none;
  letter-spacing: normal;
  font-family: inherit;
}
.mf__l { font-size: 13px; color: var(--mst-muted-strong); }
.mf__i {
  font: inherit;
  font-size: 14px;
  padding: 7px 9px;
  border-radius: 7px;
  border: 1px solid rgba(127, 127, 127, .45);
  background: rgba(255, 255, 255, .6);
  color: inherit;
  width: 100%;
}
html.dark-theme .mf__i { background: rgba(0, 0, 0, .25); }
.mf__u { position: absolute; right: 9px; bottom: 8px; font-size: 12px; color: var(--mst-muted); pointer-events: none; }
.mf--chk { flex-direction: row; align-items: center; gap: 8px; font-size: 13.5px; }
.mf--chk span { font-size: 13.5px; }
.mf--chk input { width: auto; }

.mcard {
  border: 1px solid rgba(127, 127, 127, .28);
  border-radius: 10px;
  padding: 12px;
  margin-bottom: 10px;
  background: rgba(255, 255, 255, .35);
}
html.dark-theme .mcard { background: rgba(0, 0, 0, .15); }
.mcard__h {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  margin-bottom: 8px;
}
.mcard__acts { display: flex; gap: 4px; }
.mcard__sub { margin-top: 12px; border-top: 1px dashed rgba(127, 127, 127, .35); padding-top: 10px; }
.mcard__sh { margin: 0 0 8px; font-size: 14px; color: var(--mst-muted-strong); }

.mzone {
  border: 1px solid rgba(127, 127, 127, .25);
  border-radius: 8px;
  padding: 10px;
  margin-bottom: 8px;
}
.mzone__h {
  display: flex; justify-content: space-between; align-items: center;
  font-size: 14px; margin-bottom: 8px; font-weight: 600;
}
.msub { margin-top: 8px; }
.msub__row {
  display: flex; justify-content: space-between; align-items: center; gap: 8px;
  font-size: 13px; padding: 4px 0; border-top: 1px dotted rgba(127, 127, 127, .3);
}
.msub__v { color: var(--mst-muted); }

/* --- результаты --- */
.mres {
  border: 1px solid rgba(127, 127, 127, .28);
  border-radius: 12px;
  padding: 14px 16px;
  margin-bottom: 14px;
  background: rgba(127, 127, 127, .05);
}
.mres__h { margin: 0 0 10px; font-size: 16px; }
.mres__empty, .mres__note { font-size: 13px; color: var(--mst-muted); }
.mres__err { color: #c0392b; font-size: 13px; }
.mres__warn { color: #b7791f; font-size: 13px; }

.mtbl {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
  margin: 8px 0;
}
.mtbl th, .mtbl td {
  border: 1px solid rgba(127, 127, 127, .35);
  padding: 6px 9px;
  text-align: left;
  vertical-align: top;
}
.mtbl th { background: rgba(127, 127, 127, .14); font-weight: 600; }
.mtbl--sm { font-size: 12.5px; }
.merr td { background: rgba(192, 57, 43, .1); }
.mwarn td { background: rgba(183, 121, 31, .12); }
.mnote td { font-size: 12.5px; color: var(--mst-muted); }
.st-ok td:first-child { color: #1e8e3e; }
.st-warn td:first-child { color: #b7791f; }
.st-bad td:first-child { color: #c0392b; }
.mchk__h { margin: 14px 0 6px; font-size: 15px; }

@media (max-width: 720px) {
  .mst { padding: 14px 12px 48px; }
  .mst__h1 { font-size: 21px; }
  .mc__grid { grid-template-columns: 1fr; }
  .mst__toolbar { width: 100%; gap: 8px; justify-content: flex-start; }
  .mbtn { font-size: 12.5px; padding: 6px 10px; }
  /* группы: слева — «Новый»/«Загрузить», справа — «Рассчитать»/«Экспорт»,
     по центру — сохранение (отдельной строкой) */
  .mst__grp--l { order: 1; }
  .mst__grp--c { order: 2; flex: 1 1 100%; }
  .mst__grp--r { order: 3; flex: 1 1 100%; }
  /* выпадающие меню не должны выходить за края экрана */
  .mst__grp--l .mdrop__m { left: 0; right: auto; }
  .mst__grp--r .mdrop__m { right: 0; left: auto; }
  .mst__toolbar .mdrop__m .mbtn { width: 100%; min-height: 44px; }
  .mst__toolbar .mbtn--dd { min-height: 44px; }
  /* в design.css на ширине ≤560px все button растягиваются на всю строку —
     для панели действий мастера это ломает компоновку, возвращаем по кнопке */
  .mst__toolbar .mbtn { width: auto; flex: 0 0 auto; }
  .mst__toolbar .mbtn--accent { flex: 1 1 auto; }
  /* вкладки: не растягивать на всю ширину (style.css на ≤560px делает button на всю строку) */
  .mtabs { flex-wrap: nowrap; overflow-x: auto; }
  .mtabs__b { width: auto; flex: 0 0 auto; font-size: 13px; padding: 9px 12px; }
  /* переключатель режима объекта на узком экране: подпись сверху, кнопки во всю ширину */
  .msw { flex-direction: column; align-items: stretch; }
  .msw__t { margin-bottom: 2px; }
  .msw__b { width: 100%; text-align: center; }
}

/* ============================================================
   Правка 2026-12-04: мобильная адаптация страницы «Мастер».
   Поля ввода были content-box — вылезали за ширину экрана.
   ============================================================ */
.mf__i,
.mf__input,
.mf input{
  box-sizing:border-box;
  max-width:100%;
}
.mf__i{font-size:16px}
.mtabs{overflow-x:auto;-webkit-overflow-scrolling:touch}
@media (max-width:720px){
  .mtabs{padding:6px 8px}
  .mtabs__b{max-width:100%;white-space:normal}
  .mc__grid{grid-template-columns:1fr}
  .mf__i{width:100%}
}
