.heater-modal {
  box-sizing: border-box;
  width: min(720px, calc(100vw - 24px));
  max-width: calc(100vw - 24px);
  max-height: calc(100vh - 24px);
  max-height: calc(100dvh - 24px);
  margin: auto;
  padding: 24px;
  border: 1px solid var(--mobile-border, #e4ebe7);
  border-radius: 28px;
  background: var(--mobile-surface, #fff);
  color: var(--mobile-ink, #14221d);
  box-shadow: 0 28px 70px rgba(20,45,35,.28);
  font: inherit;
  overflow: auto;
  overscroll-behavior: contain;
  overflow-wrap: anywhere;
}
.heater-modal *, .heater-modal *::before, .heater-modal *::after { box-sizing: border-box; }
.heater-modal::backdrop { background: rgba(0,20,30,.6); backdrop-filter: blur(6px); }
.heater-modal:not([open]) { display: none; }
.heater-modal > header {
  position: sticky;
  top: -24px;
  z-index: 2;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin: -24px -24px 20px;
  padding: 20px 24px 16px;
  background: var(--mobile-surface, #fff);
  border-bottom: 1px solid var(--mobile-border, #e4ebe7);
}
.heater-modal h2 { min-width: 0; margin: 0; font-size: 1.25rem; line-height: 1.35; color: var(--mobile-ink, #14221d); }
.heater-modal p { margin: 12px 0; line-height: 1.55; font-size: .94rem; }
.heater-modal label { display: block; margin: 16px 0 8px; line-height: 1.45; }
.heater-modal input:not([type="checkbox"]), .heater-modal select {
  width: 100%; min-width: 0; min-height: 44px; margin-top: 6px; padding: 11px 14px;
  border: 1px solid var(--mobile-border, #e4ebe7); border-radius: 16px;
  font: inherit; background: var(--mobile-warm, #fffaf4); color: inherit;
}
.heater-modal button {
  min-height: 44px; padding: 10px 16px; margin: 0; border: 1px solid var(--mobile-border, #e4ebe7);
  border-radius: 22px; font: inherit; color: var(--mobile-ink, #14221d);
  background: var(--mobile-mint, #e9f5ef); cursor: pointer; white-space: normal;
}
.heater-modal button:hover:not(:disabled) { filter: brightness(.96); }
.heater-modal button:disabled { opacity: .45; cursor: default; }
.heater-modal :focus-visible { outline: 3px solid var(--mobile-green, #1f7a5a); outline-offset: 3px; }
.heater-modal button.heater-modal-close { flex: 0 0 44px; width: 44px; padding: 0; font-size: 28px; line-height: 1; border-radius: 50%; background: transparent; }
.heater-modal #pidTeststart, .heater-modal .btn-primary { color: #fff; background: var(--mobile-green, #1f7a5a); border-color: var(--mobile-green, #1f7a5a); }
.heater-modal #pidTestcancel { color: #a82b2b; background: #fff1f1; border-color: #efcaca; }
.heater-modal .heater-ack { display: flex; align-items: flex-start; gap: 10px; margin: 20px 0; padding: 14px; border-radius: 16px; background: var(--mobile-warm, #fffaf4); }
.heater-modal .heater-ack input { flex: 0 0 20px; width: 20px; height: 20px; margin: 2px 0 0; accent-color: var(--mobile-green, #1f7a5a); }
.heater-modal .pid-test-controls { display: flex; flex-wrap: wrap; gap: 8px; margin: 14px 0; }
.heater-modal .pid-test-controls button { flex: 1 1 170px; }
.heater-modal .pid-test-state { margin-top: 18px; padding: 16px; background: var(--mobile-mint, #e9f5ef); border: 1px solid var(--mobile-border, #e4ebe7); border-radius: 18px; white-space: pre-line; }
.heater-modal .pid-test-result { white-space: pre-line; }
.heater-modal table { width: 100%; table-layout: fixed; border-collapse: collapse; margin-top: 18px; font-size: .9rem; }
.heater-modal th, .heater-modal td { text-align: left; vertical-align: top; padding: 10px 8px; border-bottom: 1px solid var(--mobile-border, #e4ebe7); overflow-wrap: anywhere; }
.heater-modal th { color: var(--mobile-muted, #6b7b74); font-weight: 600; }
.heater-modal th:first-child, .heater-modal td:first-child { width: 105px; white-space: nowrap; }
.heater-modal th:nth-child(2), .heater-modal td:nth-child(2) { width: 85px; }
html:has(dialog.heater-modal[open]) { overflow: hidden; }
@media (max-width: 480px) {
  .heater-modal { width: calc(100vw - 16px); max-width: calc(100vw - 16px); max-height: calc(100dvh - 16px); padding: 16px; border-radius: 22px; }
  .heater-modal > header { top: -16px; margin: -16px -16px 16px; padding: 16px; gap: 10px; }
  .heater-modal h2 { font-size: 1.1rem; }
  .heater-modal .pid-test-controls { flex-direction: column; }
  .heater-modal .pid-test-controls button { width: 100%; flex: auto; }
  .heater-modal th, .heater-modal td { padding: 9px 4px; font-size: .82rem; }
  .heater-modal th:first-child, .heater-modal td:first-child { width: 90px; }
  .heater-modal th:nth-child(2), .heater-modal td:nth-child(2) { width: 63px; }
}

.heater-mode-row { display:flex;flex-wrap:wrap;gap:6px;padding:10px 16px; }
.heater-mode-row button { flex:1; min-width:76px; min-height:38px; padding:8px 10px; border:1px solid rgba(255,255,255,.35); border-radius:18px; color:inherit; background:rgba(255,255,255,.1); font:inherit; cursor:pointer; }
.heater-mode-row button.selected { background:var(--mobile-green,#1f7a5a);color:white;border-color:var(--mobile-green,#1f7a5a); }
.heater-mode-row button:disabled { opacity:.5;cursor:default; }
.heater-modal .heater-mode-row { padding:0; margin:14px 0; }
.heater-modal details { margin:16px 0; padding:14px; border:1px solid var(--mobile-border,#e4ebe7);border-radius:18px; }
.heater-modal summary { cursor:pointer;font-weight:600;line-height:1.4;min-height:28px; }
.heater-modal details label { text-transform:none;font-size:.9rem; }
.heater-modal details button { margin:5px 0; }
