/* ══ НАСТРОЙКИ — вкладки «Общее» / «Датчики» ══ */

#page-settings { flex-direction: column; height: 100%; width: 100%; }

/* ── Шапка ───────────────────────────────────────────────── */
.st-hdr {
  display: flex; align-items: center;
  background: var(--hbar-bg);
  padding: 0 clamp(16px, calc(1.25 * var(--u)), 38px);
  height: clamp(56px, calc(4.58 * var(--u)), 140px);
  flex-shrink: 0;
  gap: clamp(8px, calc(0.63 * var(--u)), 18px);
}
.st-hdr-title {
  font-size: clamp(14px, calc(1.15 * var(--u)), 35px); font-weight: 800;
  color: #fff; text-transform: uppercase; letter-spacing: 0.05em;
}
.st-hdr-spacer { flex: 1; }

/* ── Вкладки (размер как hbar-btn) ────────────────────────── */
.st-tabs {
  display: flex; gap: clamp(4px, calc(0.31 * var(--u)), 10px);
  margin-left: clamp(12px, calc(1 * var(--u)), 28px);
}
.st-tab {
  height: clamp(36px, calc(2.81 * var(--u)), 86px);
  padding: 0 clamp(14px, calc(1.15 * var(--u)), 35px);
  border-radius: clamp(8px, calc(0.63 * var(--u)), 18px);
  border: 1px solid rgba(255,255,255,0.18);
  background: rgba(255,255,255,0.08); color: rgba(255,255,255,0.7);
  font-family: var(--ui); font-weight: 800;
  font-size: clamp(14px, calc(1.15 * var(--u)), 35px);
  display: flex; align-items: center;
  cursor: pointer; transition: 0.15s; text-transform: uppercase; letter-spacing: 0.04em;
}
.st-tab:hover { background: rgba(255,255,255,0.15); color: #fff; }
.st-tab.active { background: var(--accent); border-color: var(--accent); color: #fff; }

/* ── Цветные кнопки действий ──────────────────────────────── */
/* Сохранить — неактивный по умолчанию, зелёный+мигание при dirty */
.st-btn-save { background: rgba(255,255,255,0.08); border-color: rgba(255,255,255,0.18); color: rgba(255,255,255,0.35); pointer-events: none; }
.st-btn-save.dirty { background: var(--green); border-color: var(--green); color: #fff; pointer-events: auto; animation: st-save-pulse 1.5s ease-in-out infinite; }
.st-btn-save.dirty:hover { background: #0fc07a; }
@keyframes st-save-pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.6; } }
.st-btn-save.busy, .hbar-btn.busy { opacity: 0.5; pointer-events: none; animation: none; }
/* Загрузить — синий */
.st-btn-load { background: var(--accent); border-color: var(--accent); color: #fff; }
.st-btn-load:hover { background: #1a7aff; }
/* Резервная копия — фиолетовый */
.st-btn-backup { background: #7c3aed; border-color: #7c3aed; color: #fff; }
.st-btn-backup:hover { background: #6d28d9; }
/* Восстановить — оранжевый */
.st-btn-restore { background: var(--orange); border-color: var(--orange); color: #fff; }
.st-btn-restore:hover { background: #f08830; }

/* ── Скролл ───────────────────────────────────────────────── */
.st-scroll {
  flex: 1; overflow-y: auto; padding: clamp(8px, 0.63vw, 18px); background: var(--bg);
}
.st-scroll::-webkit-scrollbar       { width: clamp(10px, 0.83vw, 24px); }
.st-scroll::-webkit-scrollbar-track { background: var(--bg3); }
.st-scroll::-webkit-scrollbar-thumb { background: var(--border2); border-radius: clamp(2px, 0.2vw, 5px); }

/* ── Сетка: 3 колонки ────────────────────────────────────── */
.st-page {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: clamp(8px, 0.63vw, 18px);
  align-items: start;
}
.st-col {
  display: flex; flex-direction: column;
  gap: clamp(8px, 0.63vw, 18px);
}

/* ── Модуль ──────────────────────────────────────────────── */
.st-mod {
  border-radius: var(--r2);
  padding: clamp(8px, 0.63vw, 18px);
  display: flex; flex-direction: column;
  gap: clamp(6px, 0.47vw, 14px);
}
.st-mod-title {
  font-size: clamp(12px, 0.94vw, 28px); font-weight: 800;
  color: var(--text); text-transform: uppercase; letter-spacing: 0.06em;
}

/* Цвета модулей */
.st-mod-program  { background: #dce8f8; border: 1.5px solid #a8c4e6; }
.st-mod-sensors  { background: #d8f0e4; border: 1.5px solid #9dd4b6; }
.st-mod-prot     { background: #fae8d8; border: 1.5px solid #dfc0a0; }
.st-mod-hydro    { background: #dce8f8; border: 1.5px solid #a8c4e6; }
.st-mod-flow     { background: #fae8d8; border: 1.5px solid #dfc0a0; }
.st-mod-system   { background: #e8e4f0; border: 1.5px solid #c0b4d6; }

/* ── Info row (readonly, без степпера) ───────────────────── */
.st-info-row {
  display: flex; align-items: center;
  gap: clamp(6px, 0.47vw, 14px);
  min-height: clamp(28px, 2.2vw, 66px);
}
.st-info-label {
  flex: 1;
  font-size: clamp(12px, 0.94vw, 28px); font-weight: 600;
  color: var(--text2);
}
.st-info-val {
  font-family: var(--mono); font-weight: 600;
  font-size: clamp(13px, 1.04vw, 30px);
  color: var(--text);
}
.st-bar-pulse {
  animation: st-pulse 1.5s ease-in-out infinite;
}
@keyframes st-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}
.st-update-btn {
  background: none; border: none; cursor: pointer;
  color: var(--orange); margin-left: 8px; padding: 2px;
  vertical-align: middle; opacity: 0.8;
}
.st-update-btn:hover { opacity: 1; transform: scale(1.15);
}
.st-info-unit {
  font-size: clamp(10px, 0.83vw, 24px);
  color: var(--text3); font-weight: 500;
}

/* ── Progress bar ────────────────────────────────────────── */
.st-bar {
  flex: 0 0 clamp(150px, 14vw, 400px);
  height: clamp(24px, 2vw, 56px);
  background: var(--bg3); border-radius: clamp(4px, 0.36vw, 10px);
  position: relative; overflow: hidden;
}
.st-bar-fill {
  position: absolute; left: 0; top: 0; bottom: 0;
  border-radius: inherit;
  transition: width 0.4s, background 0.4s;
}
.st-bar-peak {
  position: absolute; top: 0; bottom: 0;
  width: 2px; background: var(--red);
  z-index: 2; transition: left 0.4s;
}
.st-bar-text {
  position: relative; z-index: 1;
  display: flex; align-items: center; justify-content: center;
  height: 100%;
  font-family: var(--mono); font-weight: 700;
  font-size: clamp(10px, 0.83vw, 24px);
  color: var(--text);
}

/* ── Карточка ────────────────────────────────────────────── */
.st-card {
  background: rgba(255,255,255,0.7); border: 1px solid rgba(0,0,0,0.06);
  border-radius: var(--r);
  padding: clamp(8px, 0.63vw, 18px);
  display: flex; flex-direction: column; gap: clamp(5px, 0.42vw, 12px);
}
.st-card-title {
  font-size: clamp(10px, 0.83vw, 24px); font-weight: 700;
  color: var(--text2); text-transform: uppercase; letter-spacing: 0.04em;
  padding-bottom: clamp(4px, 0.31vw, 10px); border-bottom: 1px solid rgba(0,0,0,0.08);
}

/* ── Ряд: метка | степпер ────────────────────────────────── */
.st-row {
  display: flex; align-items: center;
  gap: clamp(6px, 0.47vw, 14px);
  min-height: clamp(32px, 2.5vw, 76px);
}
.st-row-label {
  flex: 1; min-width: 0;
  font-size: clamp(12px, 0.94vw, 28px); font-weight: 600;
  color: var(--text2); white-space: nowrap;
}
.st-row-hint {
  font-size: clamp(9px, 0.73vw, 20px); color: var(--text3); white-space: nowrap;
}
.st-row .stepper { flex: 0 0 clamp(150px, 12vw, 360px); }

.st-not-loaded {
  display: flex; align-items: center; justify-content: center;
  width: 100%; height: 100%;
  font-family: var(--mono); font-weight: 700;
  font-size: clamp(14px, 1.15vw, 32px); color: var(--text3);
}

.st-sep { height: 0; border-top: 1px dashed rgba(0,0,0,0.1); margin: clamp(2px, 0.16vw, 5px) 0; }

.st-formula {
  font-size: clamp(9px, 0.73vw, 20px); color: var(--text3);
  font-family: var(--mono); padding-top: clamp(2px, 0.16vw, 5px);
  border-top: 1px solid rgba(0,0,0,0.06);
}

/* ── Кнопки канала ───────────────────────────────────────── */
.st-chan-group { display: flex; gap: clamp(4px, 0.31vw, 10px); flex: 0 0 auto; }
.st-chan-btn {
  width: clamp(38px, 2.97vw, 90px); height: clamp(38px, 2.97vw, 90px);
  border-radius: clamp(6px, 0.52vw, 16px);
  border: 2px solid var(--border2); background: var(--bg2);
  color: var(--text3); font-family: var(--mono); font-weight: 700;
  font-size: clamp(13px, 1.04vw, 30px);
  display: flex; align-items: center; justify-content: center;
  transition: 0.15s; cursor: pointer;
}
.st-chan-btn:hover  { border-color: var(--accent); color: var(--accent); background: var(--accent-l); }
.st-chan-btn.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.st-chan-btn.st-chan-text {
  width: auto; padding: 0 clamp(12px, 1vw, 28px);
  font-family: var(--ui); font-size: clamp(11px, 0.88vw, 26px);
}

/* ── Toast ────────────────────────────────────────────────── */
.st-toast {
  position: fixed;
  bottom: clamp(16px, 1.25vw, 38px); right: clamp(16px, 1.25vw, 38px);
  padding: clamp(10px, 0.83vw, 24px) clamp(18px, 1.46vw, 44px);
  border-radius: var(--r2); font-weight: 700; font-size: clamp(12px, 0.94vw, 28px);
  color: #fff; background: #1a2232;
  opacity: 0; transition: opacity 0.25s; pointer-events: none; z-index: 100;
}
.st-toast.ok  { background: var(--green); }
.st-toast.err { background: var(--red); }
.st-toast.show { opacity: 1; }

/* ══ ДИАГНОСТИКА (встроена в «Датчики») ══ */

.dg-thead {
  display: grid; grid-template-columns: 1.2fr 1fr 1fr 1fr;
  gap: clamp(4px, 0.31vw, 10px);
  padding-bottom: clamp(4px, 0.31vw, 10px);
  border-bottom: 1px solid rgba(0,0,0,0.08);
}
.dg-th {
  font-size: clamp(9px, 0.73vw, 20px); font-weight: 700;
  color: var(--text3); text-transform: uppercase; letter-spacing: 0.04em;
  text-align: right;
}
.dg-th:first-child { text-align: left; }

.dg-row {
  display: grid; grid-template-columns: 1.2fr 1fr 1fr 1fr;
  gap: clamp(4px, 0.31vw, 10px);
  align-items: center;
  min-height: clamp(28px, 2.2vw, 66px);
}
.dg-row-label {
  font-size: clamp(12px, 0.94vw, 28px); font-weight: 600;
  color: var(--text2); white-space: nowrap;
}
.dg-val {
  font-family: var(--mono); font-weight: 500;
  font-size: clamp(13px, 1.04vw, 30px);
  color: var(--text);
  text-align: right;
  transition: color 0.2s;
}
.dg-val[data-vs="err"] { color: var(--red); }
.dg-val[data-vs="no"]  { color: var(--text3); }
.dg-unit {
  font-size: clamp(9px, 0.73vw, 20px);
  color: var(--text3); font-weight: 500;
}

/* Расход: 5 колонок */
.dg-thead-5 { grid-template-columns: 1.2fr 1fr 1fr 1fr 1fr; }
.dg-row-5   { grid-template-columns: 1.2fr 1fr 1fr 1fr 1fr; }

/* ── Кнопка калибровки ────────────────────────────────── */
.st-cal-btn {
  padding: clamp(6px, 0.47vw, 14px) clamp(14px, 1.15vw, 34px);
  border-radius: clamp(6px, 0.52vw, 16px);
  border: 1.5px solid var(--accent); background: var(--accent-l);
  color: var(--accent); font-family: var(--ui); font-weight: 700;
  font-size: clamp(11px, 0.88vw, 26px);
  cursor: pointer; transition: 0.15s;
}
.st-cal-btn:hover { background: var(--accent); color: #fff; }

/* ── pH Calibration Wizard Overlay ───────────────────── */
.ph-cal-overlay {
  position: fixed; inset: 0; z-index: 200;
  background: rgba(0,0,0,0.5); backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center;
}
.ph-cal-modal {
  background: #fff; border-radius: var(--r2);
  width: min(90vw, clamp(340px, 30vw, 700px));
  box-shadow: 0 clamp(8px, 0.8vw, 24px) clamp(30px, 3vw, 80px) rgba(0,0,0,0.25);
  overflow: hidden;
}
.ph-cal-title {
  background: var(--accent); color: #fff; padding: clamp(12px, 1vw, 28px) clamp(16px, 1.3vw, 36px);
  font-size: clamp(14px, 1.15vw, 32px); font-weight: 800;
  text-transform: uppercase; letter-spacing: 0.04em;
}
.ph-cal-body {
  padding: clamp(16px, 1.3vw, 36px);
  font-size: clamp(13px, 1.04vw, 30px); color: var(--text2);
  line-height: 1.6;
}
.ph-cal-body p { margin: 0 0 clamp(6px, 0.5vw, 14px); }
.ph-cal-body b { color: var(--text); }
.ph-cal-voltage {
  margin-top: clamp(10px, 0.83vw, 24px);
  padding: clamp(10px, 0.83vw, 24px);
  background: var(--bg2); border-radius: var(--r);
  font-family: var(--mono); font-size: clamp(18px, 1.5vw, 42px); font-weight: 700;
  text-align: center; color: var(--text);
}
.ph-cal-info {
  margin-top: clamp(6px, 0.5vw, 14px);
  font-family: var(--mono); font-size: clamp(11px, 0.88vw, 26px);
  color: var(--text3);
}
.ph-cal-result {
  display: flex; flex-direction: column; gap: clamp(4px, 0.3vw, 10px);
  font-family: var(--mono); font-size: clamp(13px, 1.04vw, 30px);
}
.ph-cal-footer {
  display: flex; justify-content: flex-end; gap: clamp(8px, 0.63vw, 18px);
  padding: clamp(12px, 1vw, 28px) clamp(16px, 1.3vw, 36px);
  border-top: 1px solid rgba(0,0,0,0.08);
}
.ph-cal-btn {
  padding: clamp(8px, 0.63vw, 18px) clamp(18px, 1.5vw, 42px);
  border-radius: clamp(6px, 0.52vw, 16px); border: none;
  font-family: var(--ui); font-weight: 700;
  font-size: clamp(12px, 0.94vw, 28px); cursor: pointer;
}
.ph-cal-cancel { background: var(--bg3); color: var(--text2); }
.ph-cal-ok { background: var(--accent); color: #fff; cursor: pointer; transition: background 0.3s; }
.ph-cal-ok:hover { background: #3a90e0; }
.ph-cal-ok.ph-cal-waiting { background: var(--orange); color: #fff; }
.ph-cal-ok.ph-cal-waiting:hover { background: #d06818; }
.ph-cal-ok.ph-cal-ready { background: var(--green); color: #fff; }
.ph-cal-ok.ph-cal-ready:hover { background: #0fc07a; }
.ph-cal-countdown {
  margin-top: clamp(6px, 0.5vw, 14px);
  font-family: var(--mono); font-size: clamp(14px, 1.15vw, 32px); font-weight: 700;
  color: var(--accent); text-align: center;
}

/* EC RAW: 5 равных колонок, все по центру */
.dg-5col { grid-template-columns: 1fr 1fr 1fr 1fr 1fr; }
.dg-5col .dg-th { text-align: center; }
.dg-5col .dg-val { text-align: center; }

/* ── Toggle switch ─── */
.st-toggle-row { display: flex; align-items: center; gap: 10px; padding: 8px 0; cursor: pointer; }
.st-toggle-row input { display: none; }
.st-toggle-slider { position: relative; width: 40px; height: 22px; border-radius: 11px; background: var(--border2); transition: .2s; flex-shrink: 0; }
.st-toggle-slider::after { content: ''; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: .2s; }
.st-toggle-row input:checked + .st-toggle-slider { background: var(--accent); }
.st-toggle-row input:checked + .st-toggle-slider::after { left: 21px; }
