.rules-heading { display:flex; justify-content:space-between; align-items:center; gap:20px; margin-bottom:24px }
.rules-heading h2 { margin:0 0 6px }
.rules-heading p { margin:0; color:var(--dim); font-size:16px; line-height:1.5 }
.rules-label { color:var(--acc2); font-size:12px; font-weight:700; letter-spacing:.12em; text-transform:uppercase; margin-bottom:10px }
.rules-section { margin:30px 0 16px }
.rules-section h2 { font-size:24px; margin:0 }
.rule-grid { display:grid; grid-template-columns:repeat(auto-fit,minmax(min(100%,290px),1fr)); gap:16px }
#boiler-rule-cards { grid-template-columns:repeat(3,minmax(0,1fr)) }
.rule-box { border:1px solid var(--line); border-radius:18px; background:#fff; padding:22px; display:flex; flex-direction:column; gap:12px; box-shadow:0 5px 18px rgba(23,43,77,.04) }
.rule-box.muted { background:#f8fafc }
.rule-box h3 { margin:0; font-size:19px; line-height:1.3; font-weight:650 }
.rule-box p { margin:0; font-size:15px; color:var(--dim); line-height:1.55 }
.rule-box .rule-main { font-size:25px; font-weight:650; color:var(--txt); letter-spacing:-.02em }
.rule-top { display:flex; justify-content:space-between; align-items:center; gap:12px }
.rule-badge { display:inline-flex; padding:5px 10px; border-radius:99px; background:#edf8f0; color:#18743c; font-size:12px; font-weight:600 }
.rule-badge.grey { background:#edf1f5; color:var(--dim) }
.rule-badge.error { background:#fff0ee; color:var(--bad) }
.rule-actions { display:flex; align-items:center; gap:10px; flex-wrap:wrap; margin-top:auto; padding-top:6px }
.rule-link { padding:8px 12px; min-height:42px; border:1px solid var(--line2); border-radius:9px; background:#fff; color:var(--txt); font-size:14px; cursor:pointer }
.rule-link:hover { background:#f0f8f3; border-color:#9ecaae }
.rule-link.remove { margin-left:auto; color:#a44b46; border-color:transparent; background:transparent }
.rule-facts { display:grid; gap:12px; margin:2px 0 8px }
.rule-facts div { display:grid; grid-template-columns:66px 1fr; gap:10px; font-size:14px; line-height:1.5 }
.rule-facts span { color:var(--dim) }
.rule-facts strong { font-weight:500 }
.rule-toggle { display:flex; align-items:center; gap:8px; font-size:13px; color:var(--dim) }
.rule-toggle input { accent-color:var(--acc); width:17px; height:17px; margin:0 }
.rule-editor { margin-top:22px; border-color:#aad7b8; scroll-margin-top:135px }
.rule-editor[hidden] { display:none }
.rule-fields { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:16px; margin:18px 0 }
.rule-fields label { display:flex; flex-direction:column; gap:7px; color:var(--dim); font-size:14px }
.rule-fields input, .rule-fields select, .rule-editor .row input, .rule-editor .row select { width:100%; min-width:0; font-size:16px; padding:11px 12px; border-radius:10px }
.rule-editor .row { display:grid; grid-template-columns:130px repeat(3,minmax(0,1fr)); gap:12px; margin:16px 0 }
.rule-editor .lbl { min-width:0; font-size:14px }
.rule-editor .wide { grid-column:2 / -1 }
.rule-editor .row [hidden] { display:none }
.rule-editor .rule-days { display:flex; gap:7px; flex-wrap:wrap }
.rule-days label { padding:8px 10px; background:#f1f5f9; border-radius:8px; font-size:14px; cursor:pointer }
.rule-days input { width:auto!important; accent-color:var(--acc) }
.rule-editor h3 { font-size:17px; margin:24px 0 8px }
.rule-message { font-size:14px; line-height:1.5; margin-top:14px; color:var(--dim) }
.boiler-card { align-self:start; padding:20px }
.boiler-card .top { flex:0 }
.boiler-card .temp2 { font-size:clamp(48px,7vmin,72px) }
.boiler-card .sub { font-size:16px; margin-top:5px }
.boiler-card .unit { font-size:24px }
.boiler-card h2 { font-size:clamp(18px,2.3vmin,25px); margin-bottom:14px }
.boiler-card .foot { padding-top:12px; margin-top:14px }
.boiler-card .row { margin:6px 0; gap:8px }
.boiler-card .lbl { font-size:15px; min-width:0 }
.boiler-card .hint { font-size:14px }
.boiler-card button.sm { font-size:15px; padding:9px 14px; min-height:42px }
.boiler-card #h-fan { font-size:14px }
.boiler-card #h-fan-mode { margin:9px 0 4px }
.boiler-card .cycle-status { display:inline-flex; align-items:center; gap:8px; white-space:nowrap }
.boiler-card .cycle-count { font-size:14px; font-weight:600; font-variant-numeric:tabular-nums; min-width:2ch; text-align:right }
.boiler-card .cycle-count:empty { display:none }
.boiler-card #h-pump-row { min-height:42px }
.boiler-card #h-return-row { min-height:24px }
.electric-temp-status { display:block; min-height:22px; font-size:14px; line-height:22px; color:var(--dim); font-weight:400 }
.climate-status { min-height:1.5em }
#home-content { display:flow-root }
/* Reserve scrollbar space so status changes cannot change the content width. */
html { scrollbar-gutter:stable }
@media(min-width:1100px) {
  /* Stable, readable sizes. Telemetry never scales the page or clips controls. */
  #home-content { display:grid; gap:16px }
  #home-content > .grid3, #home-content > .grid2 { gap:16px; margin:0 }
  #home-content .card { padding:18px; margin:0 }
  #home-content h2 { font-size:clamp(18px,2.1vh,24px)!important; margin:0 0 12px; line-height:1.3 }
  #home-content .hcard h2 { gap:10px }
  #home-content .hcard h2::before { width:8px; height:8px }
  #home-content .temp2 { font-size:clamp(48px,6.5vh,70px) }
  #home-content .temp2.small { font-size:clamp(48px,6vh,65px) }
  #home-content .unit { font-size:24px }
  #home-content .sub { font-size:16px; margin-top:5px }
  #home-content .hint { font-size:14px; line-height:1.5 }
  #home-content .lbl { min-width:0; font-size:16px }
  #home-content .row { gap:10px; margin:6px 0; font-size:16px }
  #home-content .foot { padding-top:12px; margin-top:12px }
  #home-content button.sm { font-size:15px; padding:9px 12px; min-height:42px }
  #home-content .balrow { gap:10px; margin:10px 0 }
  #home-content .balrow .cap { width:24px; font-size:15px }
  #home-content .balrow .track { flex:1; width:auto; height:12px; min-width:20px }
  #home-content .balrow .val { width:130px; font-size:15px }
  #home-content .accrow { gap:10px; margin-top:12px }
  #home-content .accrow .ac { padding:16px 8px; min-width:0 }
  #home-content .accrow .v, #home-content .clim .v { font-size:clamp(30px,3.4vh,38px) }
  #home-content .accrow .n { font-size:16px }
  #home-content .climgrid { grid-template-columns:repeat(auto-fit,minmax(180px,1fr)); gap:12px }
  #home-content .clim { padding:14px 12px }
  #home-content .clim .n { font-size:16px; line-height:1.4; min-height:2.8em }
  #home-content .clim .meta { margin-top:8px; gap:12px; font-size:14px }
  #home-content .clim .meta svg { width:20px; height:20px }
  #home-content .tag { font-size:13px }
  #h-climate { min-height:175px }
  #h-acc { min-height:145px }
  #h-top-alarm { min-height:24px; line-height:24px; font-size:16px!important; margin:0!important }
}
@media(min-width:1100px) { #pg-home { padding:16px 20px } }
@media(min-width:1400px) and (min-height:700px) {
  body { padding:24px 32px }
  #top { border-radius:16px; overflow:hidden }
  #pg-home { padding-top:18px; padding-bottom:10px }
}
@media(max-width:760px) {
  #boiler-rule-cards { grid-template-columns:repeat(2,minmax(0,1fr)) }
  .rules-heading { align-items:flex-start; flex-direction:column }
  .rule-fields { grid-template-columns:1fr }
  .rule-editor .row { grid-template-columns:1fr 1fr }
  .rule-editor .lbl, .rule-editor .wide { grid-column:1 / -1 }
}
@media(max-width:540px) { #boiler-rule-cards { grid-template-columns:1fr } }
