:root {
  color-scheme: light;
  --bg: #f3f5f7;
  --white: #fff;
  --ink: #17212d;
  --muted: #505f70;
  --line: #dce3ea;
  --blue: #005eb8;
  --blue-dark: #004b94;
  --blue-light: #e8f3ff;
  --red: #cc2637;
  --orange: #f28b00;
  font: 15px/1.5 "Inter", "Segoe UI", system-ui, sans-serif;
  background: var(--bg);
  color: var(--ink);
}

* { box-sizing: border-box; }
body { margin: 0; }
a { color: inherit; }
button, input, select { font: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 3px solid var(--blue); outline-offset: 3px; }
[hidden] { display: none !important; }

.top { background: var(--white); border-bottom: 1px solid var(--line); }
.top-inner, main, footer { width: min(1192px, 100%); margin-inline: auto; padding-inline: 32px; }
.top-inner { min-height: 74px; display: flex; justify-content: space-between; align-items: center; gap: 16px; }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; line-height: 1.2; }
.brand img { object-fit: contain; border-radius: 7px; }
.brand strong { display: block; font-size: 1.14rem; letter-spacing: -.035em; }
.brand small { display: block; margin-top: 3px; font-size: .73rem; color: var(--muted); }
nav { display: flex; gap: clamp(12px, 3vw, 30px); }
nav a { text-decoration: none; color: var(--muted); font-weight: 650; font-size: .88rem; }
nav a:hover { color: var(--blue); }
.mode { padding: 6px 11px; border: 1px solid #ead8ba; border-radius: 999px; background: #fff7e7; color: #694707; font-size: .75rem; font-weight: 740; white-space: nowrap; }
.mode i { background: #bd7300; border-radius: 50%; display: inline-block; width: 6px; height: 6px; margin-right: 5px; vertical-align: 1px; }

main { padding-top: 28px; }
.hero {
  display: grid;
  grid-template-columns: minmax(0, .93fr) minmax(0, 1.15fr);
  align-items: stretch;
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: 22px;
  padding: 12px;
  overflow: hidden;
}
.hero-copy { align-self: center; padding: clamp(20px, 3.5vw, 42px); }
.eyebrow { display: flex; align-items: center; gap: 8px; margin: 0 0 13px; color: var(--muted); font-size: .76rem; font-weight: 750; letter-spacing: .12em; text-transform: uppercase; }
.eyebrow span { width: 20px; height: 3px; background: var(--red); border-radius: 4px; }
h1 { font-size: clamp(2.15rem, 4.25vw, 4.1rem); line-height: 1.02; letter-spacing: -.07em; margin: 0; font-weight: 790; }
.intro { margin: 16px 0 22px; color: var(--muted); max-width: 34ch; }
.hero-figure { min-width: 0; margin: 0; position: relative; background: #e0e8f2; border-radius: 14px; overflow: hidden; min-height: 320px; aspect-ratio: 1.64; }
.hero-figure img { position: absolute; display: block; width: 100%; height: 100%; object-fit: cover; object-position: center; }
.hero-figure figcaption { position: absolute; left: 50%; bottom: 13px; transform: translateX(-50%); display: flex; align-items: center; gap: 9px; padding: 5px 11px; border-radius: 999px; background: #f7faffeb; color: #293a4c; font-size: .71rem; font-weight: 720; white-space: nowrap; }
.hero-figure i { width: 12px; height: 1px; background: var(--blue); }

section + section { margin-top: 32px; }
section[id] { scroll-margin-top: 18px; }
.section-top { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 13px; }
.section-top p { margin: 3px 0 0; color: var(--muted); line-height: 1.45; }
h2 { font-size: 1.48rem; margin: 0; letter-spacing: -.045em; line-height: 1.25; }
h3 { margin: 0; font-size: 1.06rem; }
.count { white-space: nowrap; font-size: .76rem; font-weight: 720; background: #e8edf3; color: #42536a; padding: 4px 9px; border-radius: 6px; }
.sites { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.site { background: var(--white); border: 1px solid var(--line); border-radius: 13px; padding: 16px 19px; }
.site-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.site-id { display: block; font-size: .77rem; color: var(--muted); margin-top: 2px; }
.site-name-action { border: 0; padding: 0; text-align: left; color: var(--blue-dark); background: transparent;
  font: inherit; text-decoration: underline; text-underline-offset: 3px; overflow-wrap: anywhere; }
.site-name-action[aria-disabled="true"], #refresh-sites[aria-disabled="true"] { cursor: wait; opacity: .65; }
.site-live-status { margin: 8px 0 0; color: var(--muted); font-size: .82rem; }
.site-live-footer { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: baseline; gap: 4px 12px; }
.site-storage-action { border: 0; padding: 0; margin: 8px 0 0; background: transparent; color: var(--blue-dark);
  text-decoration: underline; text-underline-offset: 2px; font-size: .82rem; }
.site-models { font-weight: 650; color: var(--blue-dark); }
.reading { font-size: 2rem; line-height: 1; font-weight: 770; white-space: nowrap; letter-spacing: -.06em; font-variant-numeric: tabular-nums; }
.reading small { font-size: .95rem; margin-left: 4px; letter-spacing: 0; color: var(--muted); }
.site-storage { text-align: right; }
.storage-capacity { margin-top: 5px; color: var(--muted); font-size: .77rem; font-variant-numeric: tabular-nums; }
.sites-header-meta { display: grid; justify-items: end; gap: 5px; }
#site-clock { color: var(--muted); font-size: .85rem; font-variant-numeric: tabular-nums; white-space: nowrap; }
.virtual-plant { margin-top: 14px; border-color: #c5dbf3; border-top: 3px solid var(--blue); background: #f2f7fd; }
.virtual-plant h3 { font-size: 1.25rem; letter-spacing: -.025em; }
.virtual-plant .power-flow, .simulation-flow .power-flow { max-width: 650px; margin-inline: auto; }
.plant-meter { display: block; width: 100%; height: 8px; margin-top: 12px; border: 0; accent-color: var(--blue); }
.demo-charging { margin-top: 13px; color: var(--muted); font-size: .8rem; }
.site .demo-charging input { margin: 2px 0; }
.site input[type=range] { width: 100%; accent-color: var(--blue); margin: 15px 0 9px; display: block; }
.site-controls { display: flex; justify-content: space-between; gap: 8px; align-items: center; color: var(--muted); font-size: .82rem; }
.site-controls select { width: auto; padding-block: 5px; }

button, .primary { border: 1px solid transparent; border-radius: 8px; font-weight: 680; padding: 8px 12px; }
.primary { display: inline-flex; align-items: center; justify-content: center; gap: 6px; color: white; background: var(--blue); text-decoration: none; }
.primary:hover { background: var(--blue-dark); }
.secondary, .icon-button { background: white; border-color: #c9d7e6; color: var(--blue-dark); }
.secondary:hover, .icon-button:hover { background: var(--blue-light); }
.table-wrap { overflow-x: auto; background: white; border: 1px solid var(--line); border-radius: 13px; }
table { border-collapse: collapse; width: 100%; text-align: left; min-width: 635px; }
td, th { padding: 12px 14px; }
th { background: #eaf0f6; color: #405266; font-size: .78rem; }
td { border-top: 1px solid var(--line); font-size: .9rem; }
td:first-child { font-weight: 700; }
td small { display: block; color: var(--muted); margin-top: 2px; }
.rule-actions button + button { margin-top: 5px; }
.switch { padding: 0; width: 36px; height: 22px; border: 0; border-radius: 15px; background: #6d7c8e; position: relative; vertical-align: middle; }
.switch[aria-checked=true] { background: var(--blue); }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: white; }
.switch[aria-checked=true]::after { left: 17px; }
.test { background: var(--blue-light); border: 1px solid #d4e4f4; border-radius: 13px; padding: 17px 19px; }
.test ul { margin: 0; padding-left: 19px; }
.test li + li { margin-top: 5px; }
.simulation-flow { margin-top: 15px; padding-top: 13px; border-top: 1px solid #c5dbf3; }
.flow-note { margin: 9px 0 0; color: var(--muted); font-size: .79rem; }
.empty { color: var(--muted); }

footer { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 12px; margin-top: 23px; padding-bottom: 24px; color: var(--muted); font-size: .8rem; }
footer strong { color: var(--ink); padding-left: 7px; border-left: 3px solid var(--orange); }
footer p { margin: 3px 0 0; }
.footer-links { display: flex; flex-wrap: wrap; gap: 8px 17px; }
.footer-links a { text-underline-offset: 3px; }
.footer-links a:hover { color: var(--blue); }

dialog { width: min(520px, calc(100% - 22px)); border: 1px solid var(--line); border-radius: 16px; background: white; color: var(--ink); padding: 24px; }
dialog::backdrop { background: #142238a6; }
form { display: grid; gap: 14px; }
form .section-top { margin: 0; }
label { font-weight: 650; font-size: .88rem; display: grid; gap: 5px; }
input:not([type=range]):not([type=checkbox]), select { min-width: 0; width: 100%; border: 1px solid #b8c6d5; background: white; color: var(--ink); border-radius: 8px; padding: 8px; }
.fields { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.dialog-actions { display: flex; flex-wrap: wrap; gap: 10px; justify-content: flex-end; margin-top: 6px; }
.danger { color: #9b2731; background: #fff0ee; margin-right: auto; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }

@media (max-width: 850px) {
  .top-inner, main, footer { padding-inline: 20px; }
  .hero { grid-template-columns: minmax(0, 1fr) minmax(0, 1.05fr); }
  .hero-figure { min-height: 290px; }
}
@media (max-width: 650px) {
  nav { display: none; }
  main { padding-top: 16px; }
  .hero { grid-template-columns: 1fr; border-radius: 15px; padding: 8px; }
  .hero-copy { padding: 18px 15px 23px; }
  .hero-figure { aspect-ratio: 1.48; min-height: 0; border-radius: 10px; }
  .sites { grid-template-columns: 1fr; }
  .section-top { align-items: flex-start; }
  .test .section-top { flex-wrap: wrap; }
  .rules-section .primary { flex-shrink: 0; }
  .section-top p { font-size: .87rem; }
  .count { white-space: normal; text-align: right; }
}
@media (max-width: 380px) {
  .top-inner, main, footer { padding-inline: 12px; }
  .top-inner { gap: 7px; }
  .brand img { width: 30px; height: 30px; }
  .mode { font-size: .68rem; }
}

a.mode { text-decoration: none; }
a.mode:hover { background: #d8e8ff; }
button:disabled { cursor: wait; opacity: .65; }
#catalog-status { color: #455669; }
.site-selection-bar { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: start; gap: 8px; margin-bottom: 12px; }
#refresh-sites { margin-top: 6px; font-size: .82rem; }
#site-selection summary { cursor: pointer; font-weight: 700; }
.site-options { display: flex; flex-wrap: wrap; gap: 8px 20px; border: 0; padding: 10px 0 0; }
.site-choice { display: inline-flex; align-items: center; gap: 7px; }
#shelly-search { max-width: 440px; }
#channel-status { margin: 0; color: #455669; font-size: .9rem; }

.inventory-filters { display: grid; gap: 8px; margin-top: 12px; }
.inventory-filters summary { cursor: pointer; font-weight: 700; }
.filter-actions { display: flex; gap: 6px; padding-top: 10px; }
.filter-actions button { padding: 4px 10px; }
#shelly-details-status, #shelly-assignment-status { color: var(--muted); font-size: .88rem; }


.shelly-inventory { list-style: none; margin: 16px 0 0; padding: 0; display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 320px), 1fr)); gap: 10px; }
.shelly-card { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 10px;
  align-items: start; align-content: start; padding: 12px; border: 1px solid #dbe3ed; border-radius: 12px; background: white; }
.shelly-card-content { min-width: 0; }
.shelly-card-content h3 { margin: 0; color: var(--ink); font-size: .99rem; overflow-wrap: anywhere; }
.shelly-card-meta { color: var(--muted); font-size: .73rem; overflow-wrap: anywhere; }
.shelly-card-site { grid-column: 1 / -1; color: var(--muted); font-size: .75rem; }
.shelly-card-site select { padding: 4px 6px; font-size: .85rem; }
.shelly-channel-use { display: grid; gap: 3px;
  margin-top: 5px; color: var(--muted); font-size: .75rem; }
.shelly-channel-use select { padding: 4px 6px; font-size: .8rem; }
.shelly-local-link { color: var(--blue); text-underline-offset: 2px; }
.shelly-readings { grid-column: 1 / -1; list-style: none; margin: 0; padding: 0; }
.shelly-reading { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px;
  border-top: 1px solid #e6edf5; padding: 7px 2px; font-size: .81rem; }
.shelly-reading-name { overflow-wrap: anywhere; }
.shelly-reading-content { min-width: 0; }
.shelly-temperature { align-items: center; }
.shelly-card-values { display: flex; align-items: baseline; flex-wrap: wrap; gap: 5px; margin-top: 4px; }
.shelly-phase { min-width: 1.1em; color: var(--muted); font-weight: 650; }
.shelly-cover { margin-top: 5px; color: var(--blue-dark); }
.shelly-cover-summary { display: flex; flex-wrap: wrap; gap: 3px 10px; }
.shelly-cover meter { width: 100%; min-width: 100px; height: 9px; }
.shelly-firmware { grid-column: 1 / -1; display: flex; align-items: baseline; flex-wrap: wrap; gap: 4px 8px;
  color: var(--muted); font-size: .75rem; overflow-wrap: anywhere; }
.shelly-firmware-status[data-update="available"] { background: #fff1c5; color: #674600;
  border-radius: 5px; padding: 2px 5px; }
.shelly-firmware-link { color: var(--blue-dark); font-weight: 650; text-underline-offset: 2px; }
.shelly-metric, .shelly-state { border-radius: 6px; padding: 3px 7px; font-size: .75rem; font-weight: 650; }
.shelly-metric { color: #163557; background: #eef4fa; font-variant-numeric: tabular-nums; white-space: nowrap; }
.shelly-metric[data-temperature="low"] { color: #195841; background: #e5f5ec; }
.shelly-metric[data-temperature="medium"] { color: #674600; background: #fff1c5; }
.shelly-metric[data-temperature="high"] { color: #92241c; background: #ffe5e2; }
.shelly-state { color: #44576a; background: #eff2f6; }
.shelly-state[data-state="Ein"], .shelly-state[data-state="Online"] { color: #195841; background: #e5f5ec; }
.shelly-card-actions { grid-column: 1 / -1; display: grid; gap: 6px; justify-items: start; }
.shelly-card-action { border: 0; padding: 0; background: transparent;
  color: #114d8e; font-size: .77rem; font-weight: 650; text-align: left; }
.shelly-card-action:hover:not(:disabled) { text-decoration: underline; }
.shelly-card-action:disabled { cursor: default; }

.shelly-toggle { border: 1px solid #c5d2e3; min-width: 48px; }
.shelly-toggle:hover:not(:disabled) { border-color: #2666a4; }
.shelly-toggle:disabled { cursor: default; }
.shelly-toggle[data-state="Schaltet …"] { cursor: wait; }
#shelly-switch-status { color: var(--ink); font-size: .9rem; }

.power-flow { display: grid; grid-template-columns: minmax(0, 1fr) 12px minmax(0, 1fr) 12px minmax(0, 1fr);
  grid-template-rows: auto 12px auto 12px auto; align-items: center; margin-top: 12px; }
.flow-node { border: 1px solid #e0e9f3; border-radius: 8px; padding: 5px 3px; text-align: center; background: #f7fafe; }
.flow-node span, .flow-node strong { display: block; overflow-wrap: anywhere; }
.flow-node span { color: #53677c; font-size: .68rem; }
.flow-node strong { color: #173959; font-size: .88rem; font-variant-numeric: tabular-nums; }
.flow-node-solar { grid-area: 1 / 3; }
.flow-node-grid { grid-area: 3 / 1; }
.flow-node-house { grid-area: 1 / 5; }
.flow-node-total { grid-area: 3 / 5; }
.flow-node-battery { grid-area: 5 / 3; align-self: start; }
.flow-other-loads { grid-area: 5 / 5; display: grid; gap: 5px; }
.flow-node-charging { border-color: #bed8f4; }
.flow-node-heating { border-color: #efcfaf; background: #fff8ef; }
.flow-hub { grid-area: 3 / 3; justify-self: center; display: grid; place-items: center; width: 34px;
  height: 34px; border-radius: 50%; background: #e4effe; color: #1a4c89; font-weight: 750; }
.flow-line { position: relative; display: block; overflow: hidden; background: #d5e1ed; }
.flow-line-solar, .flow-line-battery, .flow-line-house, .flow-line-loads { width: 2px; height: 100%; justify-self: center; }
.flow-line-grid, .flow-line-total { height: 2px; width: 100%; }
.flow-line-solar { grid-area: 2 / 3; }
.flow-line-grid { grid-area: 3 / 2 / 4 / 4; width: calc(50% + 6px); justify-self: start; }
.flow-line-total { grid-area: 3 / 3 / 4 / 5; width: calc(50% + 6px); justify-self: end; }
.flow-line-house { grid-area: 2 / 5; }
.flow-line-battery { grid-area: 4 / 3; }
.flow-line-loads { grid-area: 4 / 5; }
.flow-active { background: #8dbcf7; }
.flow-active::after { content: ''; position: absolute; width: 5px; height: 5px; border-radius: 50%;
  background: #075fc9; animation: flow-horizontal 1.15s linear infinite; }
.flow-line-solar::after, .flow-line-battery::after, .flow-line-house::after, .flow-line-loads::after { animation-name: flow-vertical; }
.flow-reversed::after { animation-direction: reverse; }
@keyframes flow-horizontal { from { left: -5px; } to { left: 100%; } }
@keyframes flow-vertical { from { transform: translateY(-5px); } to { transform: translateY(12px); } }
@media (prefers-reduced-motion: reduce) { .flow-active::after { animation: none; } }
