/* Farben und Formen. Die Serienfarben sind für beide Flächen mit dem Palette-Validator geprüft. */
:root {
  color-scheme: dark;
  --bg: #000000;
  --surface: #0c0c0c;
  --surface-2: #161616;
  --surface-3: #262626;
  --line: rgba(255, 255, 255, .09);
  --line-strong: rgba(255, 255, 255, .18);
  --text: #f5f5f5;
  --text-2: #c4c4c4;
  --muted: #8f8f8f;
  --accent: #f5f5f5;
  --accent-ink: #000000;
  --panel-line: rgba(255, 255, 255, .13);
  --panel-busbar: rgba(255, 255, 255, .045);
  --panel-cell: rgba(255, 255, 255, .06);
  --panel-glow: rgba(255, 255, 255, .03);
  --ok: #4cc38a;
  --ok-soft: rgba(76, 195, 138, .13);
  --warn: #f0b64a;
  --warn-soft: rgba(240, 182, 74, .13);
  --danger: #ff6b5e;
  --danger-soft: rgba(255, 107, 94, .13);
  --series-load: #3987e5;
  --series-pv: #d95926;
  --series-battery: #199e70;
  --series-grid: #c98500;
  --series-balcony: #cf4fb0;
  --series-total: #2fc4d6;
  --shadow: none;
  --shadow-float: 0 18px 48px rgba(0, 0, 0, .8);
  --radius: 16px;
  --ease: cubic-bezier(.2, .8, .2, 1);
  --spring: cubic-bezier(.34, 1.56, .64, 1);
  --font: "Segoe UI Variable Text", "Segoe UI", Inter, -apple-system, BlinkMacSystemFont, Roboto, system-ui, sans-serif;
  --font-display: "Segoe UI Variable Display", "Segoe UI", Inter, -apple-system, BlinkMacSystemFont, Roboto, system-ui, sans-serif;
  --mono: "Cascadia Mono", Consolas, ui-monospace, SFMono-Regular, monospace;
}
:root[data-theme="light"] {
  color-scheme: light;
  --bg: #f2f4f7;
  --surface: #ffffff;
  --surface-2: #f3f5f8;
  --surface-3: #e4e8ee;
  --line: rgba(16, 24, 40, .08);
  --line-strong: rgba(16, 24, 40, .18);
  --text: #121720;
  --text-2: #3d4654;
  --muted: #646e7d;
  --accent: #1f68ad;
  --accent-ink: #ffffff;
  --ok: #107c41;
  --ok-soft: #e4f4ea;
  --warn: #8f5500;
  --warn-soft: #fdf3e1;
  --danger: #c42b1c;
  --danger-soft: #fdecea;
  --series-load: #2a78d6;
  --series-pv: #eb6834;
  --series-battery: #1baf7a;
  --series-grid: #eda100;
  --series-balcony: #c2369f;
  --series-total: #0b6f8a;
  --shadow: 0 1px 2px rgba(16, 24, 40, .04), 0 10px 28px rgba(16, 24, 40, .06);
  --shadow-float: 0 18px 44px rgba(16, 24, 40, .18);
  --panel-line: rgba(200, 90, 30, .2);
  --panel-busbar: rgba(200, 90, 30, .07);
  --panel-cell: rgba(235, 104, 52, .08);
  --panel-glow: rgba(235, 150, 60, .1);
}
@media (prefers-color-scheme: light) {
  :root:where(:not([data-theme="dark"])) {
    color-scheme: light;
    --bg: #f2f4f7;
    --surface: #ffffff;
    --surface-2: #f3f5f8;
    --surface-3: #e4e8ee;
    --line: rgba(16, 24, 40, .08);
    --line-strong: rgba(16, 24, 40, .18);
    --text: #121720;
    --text-2: #3d4654;
    --muted: #646e7d;
    --accent: #1f68ad;
    --accent-ink: #ffffff;
    --ok: #107c41;
    --ok-soft: #e4f4ea;
    --warn: #8f5500;
    --warn-soft: #fdf3e1;
    --danger: #c42b1c;
    --danger-soft: #fdecea;
    --series-load: #2a78d6;
    --series-pv: #eb6834;
    --series-battery: #1baf7a;
    --series-grid: #eda100;
    --series-balcony: #c2369f;
    --series-total: #0b6f8a;
    --shadow: 0 1px 2px rgba(16, 24, 40, .04), 0 10px 28px rgba(16, 24, 40, .06);
    --shadow-float: 0 18px 44px rgba(16, 24, 40, .18);
    --panel-line: rgba(200, 90, 30, .2);
    --panel-busbar: rgba(200, 90, 30, .07);
    --panel-cell: rgba(235, 104, 52, .08);
    --panel-glow: rgba(235, 150, 60, .1);
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { scroll-behavior: smooth; scrollbar-gutter: stable; -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.5 var(--font);
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, p { margin: 0; }
h2 { font: 600 16px/1.3 var(--font-display); letter-spacing: -.005em; }
h3 { font-size: 12.5px; font-weight: 600; color: var(--muted); }
code { font-family: var(--mono); font-size: 12px; color: var(--text-2); }
svg { display: block; }
.muted { color: var(--muted); font-weight: 400; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }

/* Kopfzeile */
.topbar {
  position: sticky; top: 0; z-index: 20;
  background: color-mix(in srgb, var(--bg) 78%, transparent);
  backdrop-filter: saturate(160%) blur(14px);
  border-bottom: 1px solid var(--line);
}
.topbar-inner {
  max-width: 1320px; margin: 0 auto; padding: 10px 24px;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.brand { display: flex; align-items: center; gap: 10px; color: inherit; text-decoration: none; min-width: 0; }
.brand-mark { width: 24px; height: 24px; flex: none; }
.brand-mark circle { fill: var(--series-pv); }
.brand-rays { stroke: var(--series-pv); stroke-width: 2.2; stroke-linecap: round; fill: none; transform-origin: 16px 16px; animation: spin 24s linear infinite; }
.brand-name { font: 600 15px var(--font-display); white-space: nowrap; }
.brand-device { color: var(--muted); font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; padding-left: 10px; border-left: 1px solid var(--line-strong); }
.brand-device:empty { display: none; }
.topbar-right { display: flex; align-items: center; gap: 8px; flex: none; }
@keyframes spin { to { transform: rotate(360deg); } }

.status {
  display: inline-flex; align-items: center; gap: 8px; height: 30px; padding: 0 12px;
  border-radius: 15px; font-size: 12.5px; font-variant-numeric: tabular-nums; white-space: nowrap;
  background: var(--surface-2); color: var(--text-2);
  transition: background .3s, color .3s;
}
/* Live-Timer: Der Ring läuft bis zur nächsten Abfrage leer, neue Daten lösen einen Impuls aus. */
.status-ring { position: relative; width: 18px; height: 18px; flex: none; }
.status-ring svg { width: 100%; height: 100%; transform: rotate(-90deg); overflow: visible; }
.status-ring circle { fill: none; stroke-width: 2.2; }
.status-ring .track { stroke: color-mix(in srgb, currentColor 22%, transparent); }
.status-ring .progress { stroke: currentColor; stroke-linecap: round; stroke-dasharray: 0 100; transition: stroke-dasharray 1s linear; }
.status-ring .progress.reset { transition: none; }
.status-ring i { position: absolute; inset: 6px; border-radius: 50%; background: currentColor; }
.status-ring::after { content: ""; position: absolute; inset: 2px; border-radius: 50%; border: 2px solid currentColor; opacity: 0; }
.status.pulse { animation: status-pop .55s var(--spring); }
.status.pulse .status-ring::after { animation: status-burst .8s var(--ease); }
.status.pulse .status-ring i { animation: status-core .55s var(--spring); }
@keyframes status-pop { 35% { transform: scale(1.06); } }
@keyframes status-burst { 0% { transform: scale(.6); opacity: .9; } 100% { transform: scale(2.6); opacity: 0; } }
@keyframes status-core { 40% { transform: scale(1.8); } }
.status[data-kind="ok"] { background: var(--ok-soft); color: var(--ok); }
.status[data-kind="ok"][data-waiting="true"] { background: var(--warn-soft); color: var(--warn); }
.status[data-waiting="true"] .status-ring i { animation: status-breathe 1.2s ease-in-out infinite; }
@keyframes status-breathe { 50% { opacity: .3; transform: scale(.7); } }
.status[data-kind="danger"] { background: var(--danger-soft); color: var(--danger); }
.status-time { display: inline-flex; align-items: baseline; gap: 3px; }
.status-next {
  display: grid; grid-template-columns: 0fr; opacity: 0; color: inherit;
  transition: grid-template-columns .3s var(--ease), opacity .25s, margin .3s var(--ease); margin-left: -8px;
}
.status-next > span { overflow: hidden; white-space: nowrap; min-width: 0; }
.status[data-kind="ok"]:hover .status-next { grid-template-columns: 1fr; opacity: .75; margin-left: 0; }
.roll { position: relative; display: inline-flex; justify-content: flex-end; min-width: .62em; height: 1.2em; overflow: hidden; vertical-align: bottom; line-height: 1.2; }
.roll span { display: block; }
.roll .in { animation: roll-in .32s var(--ease); }
.roll .out { position: absolute; right: 0; top: 0; animation: roll-out .32s var(--ease) forwards; }
@keyframes roll-in { from { transform: translateY(100%); opacity: 0; } }
@keyframes roll-out { to { transform: translateY(-100%); opacity: 0; } }

/* Datenquelle auf dem PC: über den Pi oder direkt vom Wechselrichter */
.source { height: 30px; padding: 0 10px; display: inline-flex; align-items: center; border: 1px solid var(--line-strong); border-radius: 15px; color: var(--text-2); font-size: 12.5px; white-space: nowrap; animation: pop .4s var(--spring); }
.source[data-mode="direct"] { color: var(--warn); border-color: currentColor; }
.notice { padding: 12px 16px; border-radius: 12px; background: var(--warn-soft); color: var(--warn); animation: drop .35s var(--ease); }
@media (max-width: 480px) { .source { display: none; } }

/* Seitennavigation */
.pagenav { position: sticky; top: 51px; z-index: 19; background: color-mix(in srgb, var(--bg) 82%, transparent); backdrop-filter: blur(14px); border-bottom: 1px solid var(--line); }
.pagenav-inner { position: relative; max-width: 1320px; margin: 0 auto; padding: 0 24px; display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none; }
.pagenav button {
  position: relative; display: inline-flex; align-items: center; gap: 7px; height: 42px; padding: 0 12px; border: 0; background: none;
  color: var(--muted); font: 500 13.5px var(--font); cursor: pointer; white-space: nowrap; transition: color .2s;
}
.pagenav button:hover, .pagenav button[aria-current="page"] { color: var(--text); }
.pagenav button::after {
  content: ""; position: absolute; left: 12px; right: 12px; bottom: -1px; height: 2px; border-radius: 1px; background: var(--text);
  transform: scaleX(0); transition: transform .3s var(--ease);
}
.pagenav button[aria-current="page"]::after { transform: scaleX(1); }
.count { min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; font-size: 11.5px; line-height: 18px; text-align: center; background: var(--surface-3); color: var(--text); animation: pop .4s var(--spring); }
.count[data-severity="critical"] { background: var(--danger); color: #000; }
.count[data-severity="warning"] { background: var(--warn); color: #000; }
.page { display: grid; gap: 16px; min-width: 0; animation: page-in .35s var(--ease); }
@keyframes page-in { from { opacity: 0; transform: translateY(6px); } }
.cols-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.cols-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
@media (max-width: 860px) { .cols-2, .cols-3 { grid-template-columns: minmax(0, 1fr); } }
.card > h2 { margin-bottom: 14px; }
.stat { font: 600 34px/1.1 var(--font-display); letter-spacing: -.02em; }
.stat-note { color: var(--muted); font-size: 12.5px; margin-top: 4px; }

/* Einrichtungshinweis */
.setup { display: grid; gap: 8px; padding: 14px; border: 1px dashed var(--line-strong); border-radius: 10px; color: var(--text-2); font-size: 13px; }
.setup strong { color: var(--text); font-weight: 600; }
.setup pre { margin: 0; padding: 10px 12px; border-radius: 8px; background: var(--surface-2); overflow-x: auto; font: 12px/1.5 var(--mono); color: var(--text-2); }

/* Empfehlung */
.advice-list { display: grid; gap: 12px; margin-bottom: 12px; }
.advice { display: grid; gap: 3px; padding-left: 12px; border-left: 2px solid var(--line-strong); font-size: 13px; color: var(--text-2); }
.advice strong { color: var(--text); font-weight: 600; }

/* Einstellungen */
.field-clear { flex: none; margin-right: 6px; padding: 2px 6px; border: 0; border-radius: 6px; background: transparent; color: var(--muted); font: inherit; font-size: 12px; cursor: pointer; }
.field-clear:hover { background: var(--surface-3); color: var(--text); }
#system-password { margin-top: 16px; }
.settings { display: grid; gap: 22px; }
.settings fieldset { display: grid; gap: 10px; min-width: 0; margin: 0; padding: 0; border: 0; }
.settings fieldset + fieldset { padding-top: 22px; border-top: 1px solid var(--line); }
.settings legend { padding: 0; margin-bottom: 8px; font-size: 13.5px; font-weight: 600; }
.settings .btn { justify-self: start; }
.settings-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; }
#tariff-rows, #plane-rows { display: grid; gap: 10px; }
#tariff-rows:empty, #plane-rows:empty { display: none; }
.settings-row { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)) auto; gap: 12px; align-items: end; animation: row-in .28s var(--ease); }
@keyframes row-in { from { opacity: 0; transform: translateY(-4px); } }
@media (max-width: 640px) {
  .settings-row { grid-template-columns: minmax(0, 1fr); padding-bottom: 12px; border-bottom: 1px solid var(--line); }
}
.settings-row[data-row="plane"] { align-items: start; margin-bottom: 12px; }
.settings-row[data-row="plane"] .row-remove { align-self: end; }
.plane-part { display: grid; gap: 8px; min-width: 0; }
.plane-pair { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.plane-help { margin-bottom: 12px; font-size: 13px; color: var(--text-2); }
.plane-help summary { cursor: pointer; }
.plane-help ul { margin: 8px 0 0; padding-left: 18px; display: grid; gap: 6px; }
.field { display: grid; gap: 5px; min-width: 0; color: var(--muted); font-size: 12.5px; }
.field-input { display: flex; align-items: center; height: 34px; border: 1px solid var(--line-strong); border-radius: 9px; background: var(--surface-2); transition: border-color .16s var(--ease); }
.field-input:focus-within { border-color: var(--text); }
.field-input input, .field-input select { flex: 1; width: 100%; min-width: 0; height: 100%; padding: 0 10px; border: 0; outline: 0; background: transparent; color: var(--text); font: inherit; font-size: 13px; }
.field-input select option { background: var(--surface-2); color: var(--text); }
.field-input em { padding-right: 10px; color: var(--muted); font-style: normal; white-space: nowrap; }
.switch { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text-2); cursor: pointer; }
.switch input { width: 16px; height: 16px; margin: 0; accent-color: var(--text); }
.settings-actions { display: flex; align-items: center; justify-content: flex-end; gap: 12px; }
.settings-actions .btn { justify-self: auto; }
.settings-status { font-size: 12.5px; color: var(--muted); }
.settings-status[data-kind="ok"] { color: var(--ok); }
.settings-status[data-kind="error"] { color: var(--danger); }

/* Meldungen */
.alert-list { display: grid; gap: 8px; }
.alert-item {
  display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 4px 12px; align-items: start; padding: 12px 14px;
  border: 1px solid var(--line); border-radius: 10px; animation: rise .35s var(--ease) backwards; animation-delay: calc(var(--i) * 30ms);
  transition: border-color .2s, transform .2s var(--ease);
}
.alert-item:hover { border-color: var(--line-strong); transform: translateX(2px); }
.alert-item.closed { opacity: .62; }
.sev { display: inline-flex; align-items: center; height: 22px; padding: 0 8px; border-radius: 11px; font-size: 12px; font-weight: 600; white-space: nowrap; background: var(--surface-3); color: var(--text-2); }
.sev[data-severity="critical"] { background: var(--danger-soft); color: var(--danger); }
.sev[data-severity="warning"] { background: var(--warn-soft); color: var(--warn); }
.alert-item p { color: var(--muted); font-size: 13px; }
.alert-item time { color: var(--muted); font-size: 12px; white-space: nowrap; text-align: right; }
.empty-state { display: grid; justify-items: center; gap: 6px; padding: 36px 16px; color: var(--muted); text-align: center; }
.empty-state svg { width: 34px; height: 34px; fill: none; stroke: var(--ok); stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }

/* Histogramm, Rangliste, Preise */
.hist { display: grid; grid-template-columns: repeat(10, minmax(0, 1fr)); gap: 3px; align-items: end; height: 130px; }
.hist div { position: relative; height: 100%; display: flex; align-items: flex-end; }
.hist i { display: block; width: 100%; min-height: 2px; height: calc(var(--v) * 100%); border-radius: 4px 4px 0 0; background: var(--series-battery); transform-origin: bottom; animation: grow .6s var(--ease) backwards; animation-delay: calc(var(--i) * 30ms); transition: filter .15s; }
.hist div:hover i { filter: brightness(1.25); }
.hist-axis { display: flex; justify-content: space-between; margin-top: 6px; color: var(--muted); font-size: 11.5px; }
.rank { display: grid; gap: 2px; }
.rank button {
  display: grid; grid-template-columns: 20px minmax(0, 1fr) 90px auto; gap: 10px; align-items: center; padding: 8px 6px; border: 0; border-radius: 8px;
  background: none; color: var(--text); font: 13px var(--font); text-align: left; cursor: pointer; font-variant-numeric: tabular-nums; transition: background .15s;
}
.rank button:hover { background: var(--surface-2); }
.rank span:first-child { color: var(--muted); }
.chart.price-chart { height: 200px; }
.integration { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 2px 12px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.integration small { grid-column: 1 / -1; color: var(--muted); font-size: 12px; overflow-wrap: anywhere; }
.pill { font-size: 12px; font-weight: 600; color: var(--muted); }
.pill[data-state="ok"] { color: var(--ok); }
.pill[data-state="error"] { color: var(--danger); }

/* Schaltflächen */
.btn, .icon-btn {
  position: relative; overflow: hidden;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 34px; border: 1px solid var(--line-strong); border-radius: 9px;
  background: var(--surface); color: var(--text); font: 500 13px var(--font); cursor: pointer; text-decoration: none;
  transition: background .18s, border-color .18s, transform .18s var(--spring), opacity .18s;
}
.btn { padding: 0 12px; white-space: nowrap; }
.icon-btn { width: 34px; flex: none; }
.icon-btn svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.btn:hover:not(:disabled), .icon-btn:hover:not(:disabled) { background: var(--surface-2); border-color: color-mix(in srgb, var(--text) 30%, transparent); }
.btn:active:not(:disabled), .icon-btn:active:not(:disabled) { transform: scale(.95); }
.btn:disabled, .icon-btn:disabled { opacity: .35; cursor: default; }
.btn[aria-pressed="true"] { background: var(--surface-3); }
.btn-primary { background: var(--accent); border-color: transparent; color: var(--accent-ink); }
.btn-primary:hover:not(:disabled) { background: color-mix(in srgb, var(--accent) 88%, var(--text)); border-color: transparent; }
.ripple {
  position: absolute; width: 8px; height: 8px; margin: -4px; border-radius: 50%;
  background: currentColor; opacity: .22; pointer-events: none; animation: ripple .55s var(--ease) forwards;
}
@keyframes ripple { to { transform: scale(26); opacity: 0; } }

#theme .theme-sun, #theme .theme-moon { transform-origin: 12px 12px; transition: transform .5s var(--spring), opacity .25s; }
#theme .theme-moon { transform: rotate(40deg) scale(.4); opacity: 0; }
:root[data-theme="light"] #theme .theme-sun { transform: rotate(-90deg) scale(.4); opacity: 0; }
:root[data-theme="light"] #theme .theme-moon { transform: none; opacity: 1; }
@media (prefers-color-scheme: light) {
  :root:where(:not([data-theme="dark"])) #theme .theme-sun { transform: rotate(-90deg) scale(.4); opacity: 0; }
  :root:where(:not([data-theme="dark"])) #theme .theme-moon { transform: none; opacity: 1; }
}

/* Grundgerüst */
main { max-width: 1320px; margin: 0 auto; padding: 20px 24px 48px; display: grid; gap: 16px; }
.card {
  position: relative; min-width: 0; padding: 20px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow);
}
/* Der Mauszeiger ist die Sonne: Unter ihm wird die Karte zum Solarmodul, die getroffene Zelle leuchtet auf. */
.card::before, .card::after {
  content: ""; position: absolute; inset: 0; border-radius: inherit; pointer-events: none; opacity: 0;
  transition: opacity .35s;
}
.card::before {
  background-image:
    linear-gradient(to right, var(--panel-line) 1px, transparent 1px),
    linear-gradient(to bottom, var(--panel-line) 1px, transparent 1px),
    repeating-linear-gradient(to right, var(--panel-busbar) 0 1px, transparent 1px 12px);
  background-size: 36px 36px, 36px 36px, 36px 36px;
  -webkit-mask-image: radial-gradient(210px circle at var(--mx, 50%) var(--my, 50%), #000, transparent 100%);
  mask-image: radial-gradient(210px circle at var(--mx, 50%) var(--my, 50%), #000, transparent 100%);
}
.card::after {
  background-image:
    linear-gradient(var(--panel-cell), var(--panel-cell)),
    radial-gradient(300px circle at var(--mx, 50%) var(--my, 50%), var(--panel-glow), transparent 75%);
  background-size: 35px 35px, 100% 100%;
  background-position: var(--cx, 0) var(--cy, 0), 0 0;
  background-repeat: no-repeat;
  transition: opacity .35s, background-position .14s var(--ease);
}
.card:hover::before, .card:hover::after { opacity: 1; }
@media (hover: none) { .card::before, .card::after { display: none; } }
.card > * { position: relative; }
.card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }

.reveal { opacity: 0; transform: translateY(14px); }
.reveal.visible { opacity: 1; transform: none; transition: opacity .6s var(--ease), transform .6s var(--ease); transition-delay: var(--delay, 0ms); }

.alert {
  display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-radius: 12px;
  background: var(--danger-soft); color: var(--danger); animation: drop .35s var(--ease);
}
.alert svg { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
@keyframes drop { from { opacity: 0; transform: translateY(-8px); } }

/* Hero */
.hero { display: grid; grid-template-columns: minmax(0, 7fr) minmax(280px, 4fr); gap: 12px; padding: 12px 28px 12px 12px; align-items: center; }
.hero.stale .hero-flow { opacity: .45; filter: saturate(.3); }
.hero-flow { min-width: 0; transition: opacity .5s, filter .5s; }
#flow { width: 100%; height: auto; overflow: visible; }
.hero-side { display: grid; gap: 20px; padding: 12px 0; }
.eyebrow { font-size: 12.5px; font-weight: 600; color: var(--muted); }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } }
.gauges { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.gauge { display: flex; align-items: center; gap: 10px; min-width: 0; }
.gauge svg { width: 52px; height: 52px; flex: none; transform: rotate(-90deg); }
.gauge circle { fill: none; stroke-width: 6; }
.gauge-track { stroke: var(--surface-3); }
.gauge-value { stroke: var(--accent); stroke-linecap: round; stroke-dasharray: 0 100; transition: stroke-dasharray 1.1s var(--ease); }
.gauge strong { display: block; font: 600 18px/1.2 var(--font-display); }
.gauge span { display: block; color: var(--muted); font-size: 12px; line-height: 1.25; }

/* Energiefluss */
.flow-link { fill: none; stroke: var(--surface-3); stroke-width: 1.5; transition: stroke .5s, stroke-width .5s, opacity .5s; }
.flow-link.active { opacity: .55; }
.flow-hit { fill: none; stroke: transparent; stroke-width: 22; pointer-events: stroke; cursor: help; }
.flow-particle { pointer-events: none; }
.flow-node { cursor: default; }
.flow-node-body { transition: transform .35s var(--spring); transform-box: fill-box; transform-origin: center; }
.flow-node:hover .flow-node-body { transform: scale(1.045); }
.flow-node-bg { fill: var(--surface-2); stroke: var(--line); }
.flow-ring-track { fill: none; stroke: var(--surface-3); stroke-width: 4; }
.flow-ring { fill: none; stroke-width: 4; stroke-linecap: round; stroke-dasharray: 0 100; transition: stroke-dasharray 1s var(--ease); transform: rotate(-90deg); transform-box: fill-box; transform-origin: center; }
.flow-icon { fill: none; stroke: var(--text-2); stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; transition: stroke .4s; }
.flow-node.on .flow-icon { stroke: var(--text); }
.flow-value { fill: var(--text); font: 600 17px var(--font-display); text-anchor: middle; font-variant-numeric: tabular-nums; }
.flow-title { fill: var(--text-2); font-size: 13px; font-weight: 600; text-anchor: middle; }
.flow-sub { fill: var(--muted); font-size: 12px; text-anchor: middle; }
.sun-rays { transform-box: fill-box; transform-origin: center; }
.flow-node.on .sun-rays { animation: spin 14s linear infinite; }
.bolt { opacity: 0; transition: opacity .3s; }
.flow-node.charging .bolt { opacity: 1; animation: pulse 1.6s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .35; } }

/* Kennzahlen */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 16px; }
.kpi { display: flex; flex-direction: column; padding: 16px 20px 0; overflow: hidden; transition: transform .3s var(--ease), border-color .3s, opacity .6s var(--ease); }
.kpi.visible:hover { transform: translateY(-2px); border-color: var(--line-strong); }
.kpi header { display: flex; align-items: center; gap: 7px; color: var(--muted); font-size: 12.5px; }
.kpi-dot { width: 8px; height: 8px; border-radius: 2px; background: var(--c); }
.kpi[data-series="pv"] { --c: var(--series-pv); }
.kpi[data-series="load"] { --c: var(--series-load); }
.kpi[data-series="grid"] { --c: var(--series-grid); }
.kpi[data-series="battery"] { --c: var(--series-battery); }
.kpi-value { margin-top: 4px; font: 600 28px/1.15 var(--font-display); letter-spacing: -.02em; white-space: nowrap; }
.kpi-sub { color: var(--muted); font-size: 12.5px; margin-bottom: 8px; }
.sparkline { height: 44px; margin: auto -20px 0; }
.sparkline svg { width: 100%; height: 100%; }
.sparkline path { vector-effect: non-scaling-stroke; }

/* Verlauf */
.range-head { display: flex; justify-content: space-between; gap: 14px; flex-wrap: wrap; margin-bottom: 14px; }
.range-summary { margin-top: 2px; font-size: 12.5px; }
.range-controls { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.stepper { display: flex; align-items: center; gap: 4px; }
.range-label { min-width: 138px; text-align: center; font-weight: 500; font-variant-numeric: tabular-nums; }
.range-label.swap { animation: rise .3s var(--ease); }
.segmented { position: relative; display: inline-flex; padding: 3px; background: var(--surface-2); border-radius: 10px; }
.segmented button {
  position: relative; z-index: 1; height: 28px; padding: 0 14px; border: 0; background: none; border-radius: 7px;
  color: var(--muted); font: 500 13px var(--font); cursor: pointer; transition: color .2s;
}
.segmented button:hover { color: var(--text); }
.segmented button[aria-pressed="true"] { color: var(--text); }
.segmented-thumb {
  position: absolute; top: 3px; bottom: 3px; left: 0; width: 0; border-radius: 7px;
  background: var(--surface); box-shadow: 0 1px 3px rgba(0, 0, 0, .25), 0 0 0 1px var(--line);
  transition: transform .34s var(--ease), width .34s var(--ease);
}
:root[data-theme="dark"] .segmented-thumb { background: var(--surface-3); }
.legend { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 10px; }
.legend button {
  display: inline-flex; align-items: center; gap: 7px; height: 28px; padding: 0 10px; border-radius: 14px;
  border: 1px solid var(--line); background: none; color: var(--text-2); font: 12.5px var(--font); cursor: pointer;
  transition: opacity .2s, background .2s, transform .2s var(--spring);
}
.legend button:hover { background: var(--surface-2); }
.legend button:active { transform: scale(.95); }
.legend button i { width: 10px; height: 10px; border-radius: 3px; background: var(--c); transition: transform .3s var(--spring), border-radius .3s; }
.legend button[aria-pressed="false"] { opacity: .5; text-decoration: line-through; }
.legend button[aria-pressed="false"] i { transform: scale(.55); border-radius: 50%; }
.legend span { display: inline-flex; align-items: center; gap: 7px; height: 28px; padding: 0 2px 0 0; color: var(--text-2); font-size: 12.5px; margin-right: 8px; }
.legend span i { width: 10px; height: 10px; border-radius: 3px; background: var(--c); }
.range-body { transition: opacity .2s; }
.range-body.busy { opacity: .55; }
.chart { position: relative; height: 320px; touch-action: pan-y; }
.chart-small { height: 110px; }
.chart svg { width: 100%; height: 100%; overflow: visible; outline-offset: 4px; }
.soc-wrap h3 { margin: 14px 0 4px; }
.gridline { stroke: var(--line); shape-rendering: crispEdges; }
.zero { stroke: var(--line-strong); shape-rendering: crispEdges; }
.axis { fill: var(--muted); font-size: 11.5px; font-variant-numeric: tabular-nums; }
.crosshair { stroke: var(--line-strong); opacity: 0; transition: opacity .15s; }
.chart-dot { stroke: var(--surface); stroke-width: 2; opacity: 0; transition: opacity .15s; }
.chart-empty { fill: var(--muted); font-size: 14px; text-anchor: middle; }
.tick { transition: opacity .5s; animation: tick-in .5s; }
.tick-out { opacity: 0; }
@keyframes tick-in { from { opacity: 0; } }
.series-group { transition: opacity .35s; }
.series-in { animation: tick-in .35s; }
.series-out { opacity: 0; }
.bar-empty { pointer-events: none; }
.series-line { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.series-line.draw { stroke-dasharray: 1; stroke-dashoffset: 1; animation: draw 1.3s var(--ease) forwards; }
@keyframes draw { to { stroke-dashoffset: 0; } }
.series-area { opacity: 0; transition: opacity .8s .5s; }
.series-area.on { opacity: 1; }
.now-dot { animation: pulse 2s ease-in-out infinite; }

.bar { transform-box: fill-box; transform-origin: bottom; transition: opacity .18s; }
.bar.grow { animation: grow .6s var(--ease) backwards; animation-delay: calc(var(--i) * 14ms); }
@keyframes grow { from { transform: scaleY(0); } }
.bar-group { cursor: pointer; }
.chart.has-hover .bar-group:not(:hover) .bar { opacity: .35; }

.collapse { display: grid; grid-template-rows: 0fr; transition: grid-template-rows .35s var(--ease); }
.collapse.open { grid-template-rows: 1fr; }
.collapse > div { overflow: hidden; min-height: 0; }
.table-wrap { overflow-x: auto; margin-top: 14px; max-height: 340px; overflow-y: auto; border: 1px solid var(--line); border-radius: 10px; }
.table-wrap table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; font-size: 13px; }
.table-wrap th, .table-wrap td { padding: 8px 12px; text-align: right; border-bottom: 1px solid var(--line); white-space: nowrap; }
.table-wrap thead th { position: sticky; top: 0; background: var(--surface-2); color: var(--muted); font-size: 12.5px; font-weight: 600; }
.table-wrap th:first-child, .table-wrap td:first-child { text-align: left; }
.table-wrap tbody tr { transition: background .12s; }
.table-wrap tbody tr:hover { background: var(--surface-2); }
.table-wrap tbody tr:last-child td { border-bottom: 0; }

/* Bilanz und Anlage */
.split { display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 7fr); gap: 16px; }
.balance { margin-top: 18px; }
.balance-title { display: flex; justify-content: space-between; gap: 8px; color: var(--text-2); font-size: 13px; font-weight: 500; margin-bottom: 8px; }
.balance-title span:last-child { color: var(--muted); font-weight: 400; font-variant-numeric: tabular-nums; }
.stack { display: flex; gap: 2px; height: 14px; }
.stack-empty { height: 14px; border-radius: 4px; background: var(--surface-2); }
.stack i { display: block; flex-basis: 0; flex-grow: var(--v); min-width: 3px; background: var(--c); transition: flex-grow .9s var(--ease), filter .2s; }
.stack i:first-child { border-radius: 4px 0 0 4px; }
.stack i:last-child { border-radius: 0 4px 4px 0; }
.stack i:hover { filter: brightness(1.15); }
.stack-legend { display: grid; gap: 4px; margin-top: 10px; font-size: 12.5px; }
.stack-legend div { display: grid; grid-template-columns: 10px 1fr auto 44px; gap: 8px; align-items: center; color: var(--text-2); font-variant-numeric: tabular-nums; }
.stack-legend i { width: 10px; height: 10px; border-radius: 3px; background: var(--c); }
.stack-legend em { font-style: normal; color: var(--muted); text-align: right; }

.tabs { display: flex; gap: 2px; }
.tabs button {
  position: relative; height: 30px; padding: 0 10px; border: 0; background: none; border-radius: 7px;
  color: var(--muted); font: 500 13px var(--font); cursor: pointer; transition: color .2s, background .2s;
}
.tabs button:hover { color: var(--text); background: var(--surface-2); }
.tabs button[aria-selected="true"] { color: var(--text); }
.tabs button::after {
  content: ""; position: absolute; left: 10px; right: 10px; bottom: 0; height: 2px; border-radius: 1px;
  background: var(--accent); transform: scaleX(0); transition: transform .3s var(--ease);
}
.tabs button[aria-selected="true"]::after { transform: scaleX(1); }
.system-panel { min-height: 214px; }
.system-panel.swap > * { animation: rise .35s var(--ease) backwards; }
.meter-row { display: grid; grid-template-columns: 74px minmax(0, 1fr) auto; gap: 12px; align-items: center; padding: 10px 0; }
.meter-row + .meter-row { border-top: 1px solid var(--line); }
.meter-row > span:first-child { color: var(--text-2); font-weight: 500; }
.meter-row > span:last-child { font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }
.meter-row small { display: block; color: var(--muted); font-size: 12px; }
.meter { height: 6px; border-radius: 3px; background: var(--surface-2); overflow: hidden; }
.meter i { display: block; height: 100%; width: 100%; border-radius: 3px; background: var(--c, var(--accent)); transform-origin: left; transform: scaleX(var(--v, 0)); transition: transform .9s var(--ease); }
.facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 2px 24px; }
.fact { display: flex; justify-content: space-between; gap: 12px; padding: 9px 0; border-bottom: 1px solid var(--line); }
.fact span { color: var(--muted); }
.fact strong { font-weight: 500; font-variant-numeric: tabular-nums; text-align: right; }

/* Kalender */
.calendar-scale { display: flex; align-items: center; gap: 3px; color: var(--muted); font-size: 12px; }
.calendar-scale span { margin-inline: 4px; }
.calendar-scale i { width: 12px; height: 12px; border-radius: 3px; }
.calendar-scale i:nth-of-type(1) { background: color-mix(in srgb, var(--series-pv) 18%, var(--surface-2)); }
.calendar-scale i:nth-of-type(2) { background: color-mix(in srgb, var(--series-pv) 38%, var(--surface-2)); }
.calendar-scale i:nth-of-type(3) { background: color-mix(in srgb, var(--series-pv) 58%, var(--surface-2)); }
.calendar-scale i:nth-of-type(4) { background: color-mix(in srgb, var(--series-pv) 78%, var(--surface-2)); }
.calendar-scale i:nth-of-type(5) { background: var(--series-pv); }
.calendar { overflow-x: auto; padding-bottom: 4px; scrollbar-width: thin; }
.calendar svg { display: block; }
.cal-cell { rx: 3px; transition: transform .2s var(--spring), stroke .15s; transform-box: fill-box; transform-origin: center; stroke: transparent; stroke-width: 1.5; }
.cal-cell.empty { fill: var(--surface-2); }
.cal-cell.future { fill: transparent; stroke: var(--line); stroke-width: 1; }
.cal-cell.data { cursor: pointer; transition: fill .8s var(--ease), transform .2s var(--spring), stroke .15s; }
.cal-intro .cal-cell.data { animation: pop .45s var(--spring) backwards; animation-delay: calc(var(--i) * 1.3ms); }
.cal-cell.data:hover { transform: scale(1.3); stroke: var(--text); }
.cal-cell.is-today { stroke: var(--text-2); }
@keyframes pop { from { transform: scale(.2); opacity: 0; } }

.data-card { display: flex; justify-content: space-between; align-items: center; gap: 16px 32px; flex-wrap: wrap; }
.data-card > div:first-child { flex: 1 1 340px; }
.data-card p { margin-top: 4px; font-size: 13px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* Tooltip und Meldungen */
.tooltip {
  position: fixed; left: 0; top: 0; z-index: 30; pointer-events: none; min-width: 168px; padding: 10px 12px;
  background: var(--surface); border: 1px solid var(--line-strong); border-radius: 10px; box-shadow: var(--shadow-float);
  font-size: 12.5px; opacity: 0; transition: opacity .14s, transform .09s linear; will-change: transform;
}
.tooltip.show { opacity: 1; }
.tooltip b { display: block; margin-bottom: 5px; font-weight: 600; }
.tooltip div { display: flex; justify-content: space-between; gap: 18px; color: var(--text-2); font-variant-numeric: tabular-nums; line-height: 1.7; }
.tooltip div strong { color: var(--text); font-weight: 500; }
.tooltip i { display: inline-block; width: 8px; height: 8px; border-radius: 2px; margin-right: 6px; }

.toasts { position: fixed; right: 20px; bottom: 20px; z-index: 40; display: grid; gap: 8px; }
.toast {
  padding: 10px 14px; border-radius: 10px; background: var(--surface); border: 1px solid var(--line-strong);
  box-shadow: var(--shadow-float); font-size: 13px; animation: toast .35s var(--spring);
}
.toast.out { opacity: 0; transform: translateY(8px); transition: .25s; }
@keyframes toast { from { opacity: 0; transform: translateY(14px) scale(.96); } }

.skeleton { display: block; border-radius: 6px; background: linear-gradient(90deg, var(--surface-2), var(--surface-3), var(--surface-2)); background-size: 200% 100%; animation: shimmer 1.4s linear infinite; }
@keyframes shimmer { to { background-position: -200% 0; } }
.value-tick { animation: tick .5s var(--ease); }
@keyframes tick { 40% { color: var(--accent); } }

::view-transition-old(root), ::view-transition-new(root) { animation: none; mix-blend-mode: normal; }

@media (max-width: 1040px) {
  .hero { grid-template-columns: minmax(0, 1fr); padding: 12px 20px 20px; }
  .split { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 640px) {
  .topbar-inner { padding: 8px 16px; }
  .brand-device { display: none; }
  main { padding: 16px 16px 40px; gap: 12px; }
  .card { padding: 16px; }
  .hero { padding: 8px 12px 16px; }
  .hero-side { padding: 0 4px; }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
  .kpi { padding: 12px 14px 0; }
  .kpi-value { font-size: 21px; }
  .sparkline { margin-inline: -14px; }
  .range-controls { width: 100%; }
  .stepper { flex: 1; justify-content: space-between; }
  .range-label { min-width: 0; flex: 1; }
  .chart { height: 260px; }
  .chart-small { height: 96px; }
  .meter-row { grid-template-columns: 54px minmax(0, 1fr) auto; }
  .tabs button { padding: 0 8px; }
  .toasts { left: 16px; right: 16px; bottom: 16px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-delay: 0ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; transition-delay: 0ms !important; scroll-behavior: auto !important; }
}

/* Der Spiegel zeigt nur an, geändert wird auf dem Pi. */
.mirror #planning-settings, .mirror #system-password { display: none; }
