:root {
  /* Eneron brand */
  --brand-navy: #173346;
  --brand-navy-ink: #0e1f2b;
  --brand-lightblue: #89c1d8;
  --brand-grey: #808080;
  /* Logomanual-Sekundärfarbe (Hellblau #89c1d8), im Hellmodus dunkler
     abgestuft -- reines #89c1d8 fällt auf der fast-weissen Kartenfläche
     unter 3:1 Kontrast (dasselbe Muster wie --series-price unten). */
  --brand-accent: #4a95b8;

  --page: #f9f9f7;
  --surface-1: #fcfcfb;
  --text-primary: #0b0b0b;
  --text-secondary: #52514e;
  --text-muted: #898781;
  --gridline: #e1e0d9;
  --baseline: #c3c2b7;
  --border: rgba(11, 11, 11, 0.10);
  --critical: #d03b3b;
  --status-good: #1a9c4c;
  --status-warning: #e0932a;
  --status-critical: #d03b3b;
  --charge-wash: rgba(26, 156, 76, 0.08);
  --tooltip-surface: #ffffff;
  --series-price: #4a95b8;
  --series-price-wash: rgba(74, 149, 184, 0.10);
  --series-grid: #d03b3b;
  --series-battery: #1a9c4c;
  --series-pv: #eda100;
  --series-load: #2b2b28;
  --series-soc: #2a78d6;
  --series-heater: #8b5cf6;
  --series-sdl: #0d9488;
}

@media (prefers-color-scheme: dark) {
  :root {
    --page: #0d0d0d;
    --surface-1: #1a1a19;
    --text-primary: #ffffff;
    --text-secondary: #c3c2b7;
    --text-muted: #898781;
    --gridline: #2c2c2a;
    --baseline: #383835;
    --border: rgba(255, 255, 255, 0.10);
    --critical: #e66767;
    --status-good: #3fc17a;
    --status-warning: #e8a444;
    --status-critical: #e66767;
    --charge-wash: rgba(63, 193, 122, 0.12);
    --tooltip-surface: #262624;
    --series-price: var(--brand-lightblue);
    --series-price-wash: rgba(137, 193, 216, 0.14);
    --brand-accent: var(--brand-lightblue);
    --series-grid: #e66767;
    --series-battery: #3fc17a;
    --series-pv: #c98500;
    --series-load: #d8d7cf;
    --series-soc: #3987e5;
    --series-heater: #a78bfa;
    --series-sdl: #2dd4bf;
  }
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--page);
  color: var(--text-primary);
  font-family: "Manrope", system-ui, -apple-system, "Segoe UI", sans-serif;
}

.brand-logo {
  display: block;
  height: 28px;
  width: auto;
}

/* The source file is the navy-on-transparent "Positivanwendung" logo.
   Where it sits on a dark surface, flip it to white ("Negativanwendung")
   with a filter instead of needing a second asset. */
.brand-logo.on-dark {
  filter: brightness(0) invert(1);
}

.muted {
  color: var(--text-muted);
}

/* Auth pages: login, register, forgot/reset password, check-email */

.honeypot-field {
  position: absolute;
  left: -9999px;
  top: -9999px;
}

.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.login-card {
  width: 100%;
  max-width: 380px;
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 32px;
}

.login-card .brand-logo {
  margin-bottom: 20px;
}

@media (prefers-color-scheme: dark) {
  .login-card .brand-logo {
    filter: brightness(0) invert(1);
  }
}

.login-card h1 {
  font-size: 1.25rem;
  font-weight: 700;
  margin: 0 0 8px;
}

.login-card p {
  margin: 0 0 20px;
  font-size: 0.9rem;
}

.login-card form {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.login-card label {
  font-size: 0.8rem;
  color: var(--text-secondary);
  margin-top: 10px;
}

.login-card input {
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid var(--baseline);
  background: var(--page);
  color: var(--text-primary);
  font-size: 0.95rem;
}

.checkbox-label {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin-top: 10px;
  font-size: 0.82rem;
  color: var(--text-secondary);
}

.login-card input[type="checkbox"] {
  width: auto;
  margin: 2px 0 0;
  padding: 0;
  border: none;
  background: none;
  flex: none;
}

.login-card button {
  margin-top: 20px;
  padding: 11px;
  border: none;
  border-radius: 8px;
  background: var(--brand-navy);
  color: #ffffff;
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
}

.login-card button:hover {
  background: var(--brand-navy-ink);
}

.form-error {
  color: var(--critical);
  font-size: 0.85rem;
  margin: 0 0 12px;
}

.form-notice {
  color: var(--status-good);
  font-size: 0.85rem;
  margin: 0 0 12px;
}

.resend-verification-form {
  margin: -6px 0 12px;
}

.login-card-links {
  display: flex;
  justify-content: space-between;
  margin-top: 16px;
  font-size: 0.82rem;
}

.login-card-links a {
  color: var(--text-secondary);
}

/* App shell: sidebar + topbar (ported from api-transparency's webapp/static/style.css) */

.app-shell {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  flex: none;
  width: 220px;
  background: var(--brand-navy-ink);
  color: #ffffff;
  display: flex;
  flex-direction: column;
  padding: 20px 14px;
  position: sticky;
  top: 0;
  height: 100vh;
}

.sidebar-nav {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 8px;
  color: rgba(255, 255, 255, 0.72);
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 500;
}

.sidebar-nav a:hover {
  background: rgba(255, 255, 255, 0.06);
  color: #ffffff;
}

.sidebar-nav a.active {
  background: rgba(255, 255, 255, 0.12);
  color: #ffffff;
}

.nav-icon {
  width: 18px;
  height: 18px;
  flex: none;
}

.app-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

/* Same navy as the sidebar (which becomes the bottom tab bar on mobile) --
   the top and bottom bars are meant to read as one matching pair. */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 28px;
  background: var(--brand-navy-ink);
  gap: 16px;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 16px;
  min-width: 0;
}

.topbar .brand-logo {
  height: 22px;
  flex: none;
}

.site-switcher {
  position: relative;
  flex: none;
}

.site-switcher-button {
  display: flex;
  align-items: center;
  gap: 6px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  background: rgba(255, 255, 255, 0.08);
  color: rgba(255, 255, 255, 0.88);
  border-radius: 8px;
  padding: 6px 10px;
  font-size: 0.82rem;
  font-family: inherit;
  cursor: pointer;
  white-space: nowrap;
}

.site-switcher-button:hover {
  background: rgba(255, 255, 255, 0.14);
}

.site-switcher-button .nav-icon {
  width: 15px;
  height: 15px;
  color: rgba(255, 255, 255, 0.6);
}

.chevron-icon {
  width: 13px;
  height: 13px;
  flex: none;
  color: rgba(255, 255, 255, 0.6);
}

.site-switcher-menu {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  min-width: 220px;
  margin: 0;
  padding: 6px;
  list-style: none;
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.16);
  z-index: 30;
}

.site-switcher-label {
  padding: 6px 10px 4px;
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-muted);
  cursor: default;
}

.site-switcher-menu li.scope-option {
  padding: 8px 10px;
  border-radius: 6px;
  font-size: 0.85rem;
  color: var(--text-secondary);
  cursor: pointer;
}

.site-switcher-menu li.scope-option:hover {
  background: var(--gridline);
}

.site-switcher-menu li.scope-option.active {
  color: var(--text-primary);
  font-weight: 600;
  background: var(--gridline);
}

.user-menu {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
  flex: none;
}

.user-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--brand-lightblue);
  color: var(--brand-navy-ink);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  flex: none;
  border: none;
  cursor: pointer;
  padding: 0;
  font-family: inherit;
}

.user-avatar:hover {
  filter: brightness(0.95);
}

.user-menu-dropdown {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  min-width: 200px;
  padding: 6px;
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.16);
  z-index: 30;
  display: flex;
  flex-direction: column;
}

/* [hidden] on its own would be enough, but the display:flex above has equal
   specificity and can win on source order -- this pins it down explicitly. */
.user-menu-dropdown[hidden] {
  display: none;
}

.user-menu-name {
  padding: 8px 10px 6px;
  font-size: 0.78rem;
  color: var(--text-muted);
  border-bottom: 1px solid var(--gridline);
  margin-bottom: 4px;
  word-break: break-all;
}

.user-menu-logout {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border-radius: 6px;
  color: var(--text-primary);
  text-decoration: none;
  font-size: 0.88rem;
}

.user-menu-logout:hover {
  background: var(--gridline);
}

.content {
  max-width: 980px;
  padding: 24px 28px 40px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* Für Seiten mit breiten Tabellen (Admin > Anlagen, Admin > Update), denen die
   Standardbreite zu wenig Platz lässt. */
.content-wide {
  max-width: 1320px;
}

.card {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
}

.card h1 {
  font-size: 1.15rem;
  margin: 0 0 12px;
}

.card h2 {
  font-size: 1rem;
  margin: 0 0 6px;
}

.card-hint {
  font-size: 0.85rem;
  margin: 0 0 16px;
}

/* Dashboard: one card per device on the current Anlage */

.dashboard-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}

.device-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 16px;
}

.device-card {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.device-card-clickable {
  cursor: pointer;
  transition: border-color 0.15s ease;
}
.device-card-clickable:hover, .device-card-clickable:focus-visible {
  border-color: var(--brand-accent);
}

.device-card-head {
  display: flex;
  align-items: center;
  gap: 10px;
}

.device-icon {
  flex: none;
  width: 34px;
  height: 34px;
  border-radius: 8px;
  background: var(--page);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
}

.device-icon svg {
  width: 18px;
  height: 18px;
}

.device-card-title {
  font-size: 0.92rem;
  font-weight: 700;
  line-height: 1.3;
}

.device-card-subtitle {
  font-size: 0.76rem;
  color: var(--text-muted);
}

.device-card-body {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.device-stat-value {
  font-size: 1.6rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.device-stat-unit {
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--text-muted);
  margin-left: 3px;
}

.device-stat-empty {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.device-stat-group {
  display: flex;
  flex-direction: row;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 4px 18px;
}

.device-stat-secondary {
  display: flex;
  align-items: baseline;
}

.device-stat-secondary .device-stat-value {
  font-size: 1.6rem;
}

.device-stat-caption {
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-left: 5px;
}

.device-card-updated {
  font-size: 0.72rem;
  color: var(--text-muted);
}

/* Read-only Anzeige der 4 Batterie-Betriebsgrenzen (siehe
   device_battery_settings) -- für jede Rolle gleich, Bearbeiten passiert
   nur auf der separaten Admin-Seite (/admin/sites/<id>/devices). */
.device-battery-limits {
  font-size: 0.72rem;
}

.battery-gauge {
  flex: none;
  width: 34px;
  height: 58px;
  border: 2px solid var(--baseline);
  border-radius: 6px;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.battery-gauge::before {
  content: "";
  position: absolute;
  top: -5px;
  left: 50%;
  transform: translateX(-50%);
  width: 12px;
  height: 4px;
  background: var(--baseline);
  border-radius: 2px 2px 0 0;
}

.battery-gauge-fill {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 0%;
  background: var(--status-good);
  transition: height 0.4s ease;
}

.battery-gauge-label {
  position: relative;
  z-index: 1;
  font-size: 0.68rem;
  font-weight: 700;
  color: var(--text-primary);
  mix-blend-mode: difference;
}

/* Live power-flow card: PV (oben) / Speicher (links) / Netz (unten) around a
   hub, Hausverbrauch (rechts) -- a fixed-size hub-and-spoke cross so each
   spoke's line length is exact geometry (half the wrapper minus the node),
   not something flexbox has to guess at. Ported from api-transparency's
   style.css -- pure geometry/animation, no per-site scoping dependency. */

.flow-card-head {
  margin-bottom: 18px;
}

.flow-cross {
  --flow-wrap: 280px;
  --flow-node: 84px;
  position: relative;
  width: var(--flow-wrap);
  height: var(--flow-wrap);
  margin: 4px auto 8px;
}

.flow-hub-center {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 8px;
  height: 8px;
  margin: -4px 0 0 -4px;
  border-radius: 50%;
  background: var(--baseline);
}

.flow-node {
  position: absolute;
  width: var(--flow-node);
  height: var(--flow-node);
  border-radius: 50%;
  border: 2px solid var(--flow-color, var(--baseline));
  background: var(--surface-1);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  z-index: 1;
  transition: border-color 0.3s ease;
}

.flow-pos-top { top: 0; left: 50%; transform: translateX(-50%); }
.flow-pos-right { top: 50%; right: 0; transform: translateY(-50%); }
.flow-pos-left { top: 50%; left: 0; transform: translateY(-50%); }
.flow-pos-bottom { bottom: 0; left: 50%; transform: translateX(-50%); }

.flow-node-icon {
  color: var(--flow-color, var(--text-muted));
}

.flow-node-icon svg {
  width: 22px;
  height: 22px;
}

.flow-node-value {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
}

.flow-soc-badge {
  position: absolute;
  bottom: -6px;
  right: -10px;
  background: var(--surface-1);
  border: 2px solid var(--series-soc);
  border-radius: 999px;
  padding: 2px 7px;
  font-size: 0.68rem;
  font-weight: 700;
  color: var(--text-primary);
  white-space: nowrap;
  z-index: 2;
}

/* Spokes: length = wrapper/2 - node, i.e. exactly the gap between a node's
   near edge and the hub at the center. Dots animate along the flow axis;
   opacity/animation are dimmed via JS (see home.js renderFlowCard) whenever
   that spoke carries ~no power. */

.flow-spoke {
  position: absolute;
  background-image: radial-gradient(circle, var(--flow-color, var(--baseline)) 1.5px, transparent 1.6px);
  opacity: 0.9;
  transition: opacity 0.3s ease;
}

.flow-spoke.flow-idle {
  animation-play-state: paused;
  opacity: 0.28;
}

.flow-spoke-top,
.flow-spoke-bottom {
  left: 50%;
  width: 3px;
  height: calc(var(--flow-wrap) / 2 - var(--flow-node));
  transform: translateX(-50%);
  background-size: 100% 11px;
  background-repeat: repeat-y;
  animation: flow-dots-v 1s linear infinite;
}

.flow-spoke-top { top: var(--flow-node); }
.flow-spoke-bottom { bottom: var(--flow-node); }

.flow-spoke-left,
.flow-spoke-right {
  top: 50%;
  height: 3px;
  width: calc(var(--flow-wrap) / 2 - var(--flow-node));
  transform: translateY(-50%);
  background-size: 11px 100%;
  background-repeat: repeat-x;
  animation: flow-dots-h 1s linear infinite;
}

.flow-spoke-left { left: var(--flow-node); }
.flow-spoke-right { right: var(--flow-node); }

@keyframes flow-dots-v {
  to { background-position: center 11px; }
}

@keyframes flow-dots-h {
  to { background-position: 11px center; }
}

/* Arrowheads: one at each end of a spoke, shown only via .arrow-in /
   .arrow-out -- so "no flow" (see .flow-idle above) shows neither. */

.flow-spoke::before,
.flow-spoke::after {
  content: "";
  position: absolute;
  width: 0;
  height: 0;
  opacity: 0;
  transition: opacity 0.2s ease;
}

.flow-spoke-top::before,
.flow-spoke-bottom::before {
  left: 50%;
  transform: translateX(-50%);
  border-left: 4px solid transparent;
  border-right: 4px solid transparent;
}

.flow-spoke-top::after,
.flow-spoke-bottom::after {
  left: 50%;
  transform: translateX(-50%);
  border-left: 4px solid transparent;
  border-right: 4px solid transparent;
}

/* top spoke: node above, hub below -- ::before = hub end (bottom), ::after = node end (top) */
.flow-spoke-top::before { bottom: -1px; border-top: 6px solid var(--flow-color, var(--baseline)); }
.flow-spoke-top::after { top: -1px; border-bottom: 6px solid var(--flow-color, var(--baseline)); }
.flow-spoke-top.arrow-in::before { opacity: 1; }
.flow-spoke-top.arrow-out::after { opacity: 1; }

/* bottom spoke: hub above, node below -- ::before = hub end (top), ::after = node end (bottom) */
.flow-spoke-bottom::before { top: -1px; border-bottom: 6px solid var(--flow-color, var(--baseline)); }
.flow-spoke-bottom::after { bottom: -1px; border-top: 6px solid var(--flow-color, var(--baseline)); }
.flow-spoke-bottom.arrow-in::before { opacity: 1; }
.flow-spoke-bottom.arrow-out::after { opacity: 1; }

.flow-spoke-left::before,
.flow-spoke-right::before {
  top: 50%;
  transform: translateY(-50%);
  border-top: 4px solid transparent;
  border-bottom: 4px solid transparent;
}

.flow-spoke-left::after,
.flow-spoke-right::after {
  top: 50%;
  transform: translateY(-50%);
  border-top: 4px solid transparent;
  border-bottom: 4px solid transparent;
}

/* left spoke: node left, hub right -- ::before = hub end (right), ::after = node end (left) */
.flow-spoke-left::before { right: -1px; border-left: 6px solid var(--flow-color, var(--baseline)); }
.flow-spoke-left::after { left: -1px; border-right: 6px solid var(--flow-color, var(--baseline)); }
.flow-spoke-left.arrow-in::before { opacity: 1; }
.flow-spoke-left.arrow-out::after { opacity: 1; }

/* right spoke: hub left, node right -- ::before = hub end (left), ::after = node end (right) */
.flow-spoke-right::before { left: -1px; border-right: 6px solid var(--flow-color, var(--baseline)); }
.flow-spoke-right::after { right: -1px; border-left: 6px solid var(--flow-color, var(--baseline)); }
.flow-spoke-right.arrow-in::before { opacity: 1; }
.flow-spoke-right.arrow-out::after { opacity: 1; }

/* The dot animation (flow-dots-v/-h, see above) always scrolls one fixed
   way -- down for the vertical spokes, right for the horizontal ones. That
   matches each spoke's "in" direction by default (top and left), so only
   the "out" state needs reversing there; for the spokes whose default
   instead matches "out" (bottom, right), it's the "in" state that needs
   reversing. Without this the dots keep drifting the same way regardless
   of arrow-in/-out, e.g. still flowing hub->Speicher while discharging. */
.flow-spoke-top.arrow-out,
.flow-spoke-left.arrow-out,
.flow-spoke-bottom.arrow-in,
.flow-spoke-right.arrow-in {
  animation-direction: reverse;
}

/* Admin overview */

.admin-links {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.admin-link {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 14px 16px;
  border-radius: 8px;
  border: 1px solid var(--border);
  color: var(--text-primary);
  text-decoration: none;
  margin-top: 8px;
}

.admin-link:hover {
  background: var(--page);
}

.admin-subnav {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.admin-subnav a {
  padding: 7px 14px;
  border-radius: 999px;
  border: 1px solid var(--baseline);
  background: var(--surface-1);
  color: var(--text-secondary);
  font-size: 0.85rem;
  text-decoration: none;
}

.admin-subnav a.active {
  background: var(--brand-navy);
  border-color: var(--brand-navy);
  color: #ffffff;
}

.back-button {
  display: inline-block;
  padding: 10px 20px;
  border-radius: 8px;
  background: var(--brand-navy);
  color: #ffffff;
  font-size: 0.9rem;
  font-weight: 700;
  text-decoration: none;
}

.back-button:hover {
  background: var(--brand-navy-ink);
}

/* Admin tables */

.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}

.admin-table th,
.admin-table td {
  text-align: left;
  padding: 10px 8px;
  border-bottom: 1px solid var(--gridline);
  vertical-align: top;
}

.admin-table select {
  padding: 5px 8px;
  border-radius: 6px;
  border: 1px solid var(--baseline);
  background: var(--page);
  color: var(--text-primary);
  font-family: inherit;
}

.soc-pill {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 999px;
  border: 1.5px solid currentColor;
  font-size: 0.82rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.site-checkboxes {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

.site-checkboxes label {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 0.85rem;
  white-space: nowrap;
}

.site-checkboxes button {
  padding: 5px 12px;
  border: none;
  border-radius: 6px;
  background: var(--brand-navy);
  color: #ffffff;
  font-size: 0.8rem;
  cursor: pointer;
}

/* Admin forms (create site, ...) */

.admin-form {
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-width: 420px;
}

.admin-form label {
  font-size: 0.8rem;
  color: var(--text-secondary);
  margin-top: 10px;
}

.admin-form input[type="text"],
.admin-form input[type="password"],
.admin-form input[type="number"],
.admin-form select {
  padding: 9px 11px;
  border-radius: 8px;
  border: 1px solid var(--baseline);
  background: var(--page);
  color: var(--text-primary);
  font-size: 0.92rem;
  font-family: inherit;
}

/* Kompaktes Inline-Formular für die 4 Batterie-Betriebsgrenzen, je Zeile in
   der Geräte-Tabelle (siehe admin_site_devices.html) -- deutlich enger als
   .admin-form, das für eigenständige Formulare unter der Tabelle gedacht
   ist, nicht für eine Tabellenzelle. */
.battery-settings-form {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  gap: 6px 10px;
}

.battery-settings-form label {
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-size: 0.7rem;
  color: var(--text-muted);
  white-space: nowrap;
}

.battery-settings-form input[type="number"] {
  width: 72px;
  padding: 5px 7px;
  border-radius: 6px;
  border: 1px solid var(--baseline);
  background: var(--page);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.85rem;
}

.battery-settings-form button {
  padding: 6px 12px;
  border: none;
  border-radius: 6px;
  background: var(--brand-navy);
  color: #ffffff;
  font-size: 0.78rem;
  cursor: pointer;
  white-space: nowrap;
}

.battery-settings-form button:hover {
  background: var(--brand-navy-ink);
}

.admin-table code {
  font-size: 0.85em;
  background: var(--page);
  padding: 2px 5px;
  border-radius: 4px;
}

.admin-form button {
  margin-top: 20px;
  align-self: flex-start;
  padding: 10px 18px;
  border: none;
  border-radius: 8px;
  background: var(--brand-navy);
  color: #ffffff;
  font-size: 0.9rem;
  font-weight: 700;
  cursor: pointer;
}

.admin-form button:hover {
  background: var(--brand-navy-ink);
}

/* Konto-Seite: löschen-Formular, gleiches Layout wie .admin-form, aber mit
   eigenem (rotem) Button statt .admin-form buttons Navy-Standard. */

.account-delete-form {
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-width: 420px;
}

.account-delete-form label {
  font-size: 0.8rem;
  color: var(--text-secondary);
  margin-top: 10px;
}

.account-delete-form input[type="password"] {
  padding: 9px 11px;
  border-radius: 8px;
  border: 1px solid var(--baseline);
  background: var(--page);
  color: var(--text-primary);
  font-size: 0.92rem;
  font-family: inherit;
}

.danger-button {
  margin-top: 20px;
  align-self: flex-start;
  padding: 10px 18px;
  border: none;
  border-radius: 8px;
  background: var(--critical);
  color: #ffffff;
  font-size: 0.9rem;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
}

.danger-button:hover {
  opacity: 0.88;
}

.link-button {
  padding: 0;
  border: none;
  background: none;
  color: var(--series-price);
  font-size: 0.85rem;
  font-family: inherit;
  text-decoration: underline;
  cursor: pointer;
}

.link-button:hover {
  color: var(--brand-navy);
}

/* Optimierung: priority drag list + charge-mode picker
   (ported from api-transparency's webapp/static/style.css, unchanged) */

.priority-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.priority-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--page);
  user-select: none;
  touch-action: none;
}

.priority-item.dragging {
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.14);
  border-color: var(--brand-lightblue);
  position: relative;
  z-index: 2;
}

.priority-rank {
  flex: none;
  width: 22px;
  text-align: center;
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

.priority-icon {
  flex: none;
  width: 22px;
  height: 22px;
  color: var(--brand-navy);
}

.priority-label {
  flex: 1;
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--text-primary);
}

.priority-handle {
  flex: none;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  border-radius: 6px;
  cursor: grab;
  touch-action: none;
}

.priority-handle:hover {
  background: var(--gridline);
}

.priority-item.dragging .priority-handle {
  cursor: grabbing;
}

.priority-icon-wrap {
  display: flex;
  flex: none;
}

/* Hausverbrauch / Netzeinspeisung: always first/last, not draggable --
   slightly recessed and without a handle, so it visually reads as fixed. */
.priority-item.priority-fixed {
  background: var(--surface-1);
  border-style: dashed;
}

.priority-item.priority-fixed .priority-icon {
  color: var(--text-muted);
}

.priority-soc-field {
  flex: none;
  display: flex;
  align-items: center;
  gap: 3px;
}

.priority-soc-input {
  width: 52px;
  padding: 6px 7px;
  border: 1px solid var(--baseline);
  border-radius: 6px;
  background: var(--surface-1);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.85rem;
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.priority-soc-unit {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.priority-item-invalid .priority-soc-input {
  border-color: var(--status-critical);
}

.priority-remove {
  flex: none;
  width: 26px;
  height: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: 6px;
  background: none;
  color: var(--text-muted);
  font-size: 1.1rem;
  line-height: 1;
  cursor: pointer;
}

.priority-remove:hover {
  background: var(--gridline);
  color: var(--status-critical);
}

.priority-actions {
  margin-top: 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.priority-add-buttons {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.priority-actions .save-button {
  padding: 8px 18px;
}

.priority-add-battery {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border: 1px dashed var(--baseline);
  border-radius: 8px;
  background: none;
  color: var(--text-secondary);
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
}

.priority-add-battery:hover {
  border-color: var(--brand-navy);
  color: var(--brand-navy);
}

.priority-error {
  margin: 10px 0 0;
  font-size: 0.82rem;
  color: var(--status-critical);
}

.charge-mode-options {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px;
  align-items: start;
}

.charge-mode-col {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-width: 0;
}

.charge-mode-option {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--page);
  color: var(--text-primary);
  font-family: inherit;
  text-align: left;
  cursor: pointer;
}

.charge-mode-option:hover {
  border-color: var(--brand-lightblue);
}

.charge-mode-option.active {
  border-color: var(--brand-navy);
  background: var(--charge-wash);
}

.charge-mode-option .nav-icon {
  width: 22px;
  height: 22px;
  color: var(--brand-navy);
}

.charge-mode-title {
  font-size: 0.92rem;
  font-weight: 700;
}

.charge-mode-desc {
  font-size: 0.8rem;
}

.battery-floor-row,
.charge-current-row {
  padding-top: 12px;
  border-top: 1px solid var(--gridline);
}

.battery-floor-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}

.battery-floor-head label {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text-primary);
}

.battery-floor-value {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--brand-navy);
  font-variant-numeric: tabular-nums;
}

.battery-floor-row .card-hint {
  margin: 2px 0 12px;
}

.battery-floor-input {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 4px;
  border-radius: 2px;
  background: var(--gridline);
  outline: none;
}

.battery-floor-input::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--brand-navy);
  border: 3px solid var(--surface-1);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
  cursor: pointer;
}

.battery-floor-input::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--brand-navy);
  border: 3px solid var(--surface-1);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
  cursor: pointer;
}

.save-row {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
}

.save-status {
  font-size: 0.82rem;
}

.save-status.is-saved {
  color: var(--status-good);
}

.save-button {
  padding: 10px 20px;
  border: none;
  border-radius: 8px;
  background: var(--brand-navy);
  color: #ffffff;
  font-size: 0.9rem;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
}

.save-button:hover {
  background: var(--brand-navy-ink);
}

.save-button:disabled {
  opacity: 0.5;
  cursor: default;
}

/* Preise page: range filter + hand-rolled SVG chart chrome (no chart
   library) -- ported from api-transparency's style.css, generic over any
   single time series. */

.filter-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.filter-row button {
  padding: 7px 14px;
  border-radius: 999px;
  border: 1px solid var(--baseline);
  background: var(--surface-1);
  color: var(--text-secondary);
  font-size: 0.85rem;
  font-family: inherit;
  cursor: pointer;
}

.filter-row button.active {
  background: var(--brand-navy);
  border-color: var(--brand-navy);
  color: #ffffff;
}

.unit-label {
  font-weight: 400;
  font-size: 0.8rem;
}

.chart-wrap {
  width: 100%;
  overflow-x: auto;
  position: relative;
}

/* Nur die Leistungsübersicht: zieht bis an den Kartenrand statt den
   normalen Karten-Innenabstand mitzumachen -- auf dem Handy geht sonst
   wertvolle Chart-Breite für Zoom/Pan verloren. Kompensiert den
   .card-Innenabstand (20px, siehe .card) per Negativ-Margin; der
   Mobile-Media-Query unten passt das an den dort kleineren Innenabstand
   (14px) an. */
#power-overview-wrap {
  margin-left: -20px;
  margin-right: -20px;
  width: calc(100% + 40px);
}

.chart-wrap svg {
  width: 100%;
  height: auto;
  display: block;
}

.chart-card-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 6px 16px;
  margin-bottom: 12px;
}

.chart-card-head h2 {
  margin: 0;
}

.energy-totals-row {
  display: flex;
  flex-wrap: wrap;
  gap: 20px 40px;
  margin-bottom: 18px;
}

.energy-total {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.energy-total-value {
  font-size: 1.5rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.energy-total-label {
  font-size: 0.78rem;
  color: var(--text-muted);
}

.donut-row {
  display: flex;
  flex-wrap: wrap;
  gap: 32px;
}

.donut-block {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  flex: none;
}

.donut-title {
  margin: 0;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-secondary);
}

.donut {
  position: relative;
  width: 128px;
  height: 128px;
  flex: none;
}

.donut-ring {
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}

.donut-track {
  fill: none;
  stroke: var(--baseline);
  stroke-width: 10;
}

.donut-segments circle {
  fill: none;
  stroke-width: 10;
  /* 2*pi*r, r=52 -- volle Kreislänge; Segmente werden per JS mit
     stroke-dasharray/-dashoffset aus diesem Umfang herausgeschnitten. */
  transition: stroke-dasharray 0.6s ease, stroke-dashoffset 0.6s ease;
}

.donut-icon {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
}

.donut-icon svg {
  width: 26px;
  height: 26px;
}

.donut-legend {
  flex-direction: column;
  gap: 6px;
}

.donut-legend .legend-item {
  font-size: 0.82rem;
}

.donut-legend b {
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
}

.legend {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.78rem;
  color: var(--text-secondary);
}

.legend-item[data-key] {
  cursor: pointer;
  user-select: none;
  border-radius: 4px;
}
.legend-item[data-key]:hover {
  color: var(--text-primary);
}
.legend-item-hidden {
  opacity: 0.4;
  text-decoration: line-through;
}

.swatch {
  width: 9px;
  height: 9px;
  border-radius: 2px;
  flex: none;
}

.chart-range-row {
  margin-bottom: 14px;
}

.chart-range-row button {
  padding: 5px 12px;
  font-size: 0.78rem;
}

.chart-svg {
  cursor: grab;
}

.chart-svg:active {
  cursor: grabbing;
}

.day-nav-inline {
  display: flex;
  align-items: center;
  gap: 6px;
}

.day-nav-inline[hidden] {
  display: none;
}

/* .day-nav-inline .day-nav-button statt nur .day-nav-button: die generische
   .filter-row button-Regel (Klasse+Element, spezifischer als eine einzelne
   Klasse) sass sonst über Padding/Grösse drüber, weil die Pfeil-Buttons seit
   dem gemeinsamen Layout mit Heute/Letzte-7-Tage Nachfahren von .filter-row
   sind -- die Buttons rutschten dadurch faktisch auf ~2px Innenbreite
   zusammen, das Pfeil-Icon war praktisch unsichtbar. */
.day-nav-inline .day-nav-button {
  flex: none;
  width: 26px;
  height: 26px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--baseline);
  border-radius: 6px;
  background: var(--surface-1);
  color: var(--text-secondary);
  cursor: pointer;
}

.day-nav-button svg {
  width: 14px;
  height: 14px;
}

.day-nav-inline .day-nav-button:hover:not(:disabled) {
  background: var(--page);
}

.day-nav-inline .day-nav-button:disabled {
  opacity: 0.35;
  cursor: default;
}

.day-nav-label {
  font-size: 0.85rem;
  font-weight: 600;
  min-width: 78px;
  text-align: center;
}

/* Icon-only Button, oben rechts über dem Chart selbst (nicht in der
   Filterzeile) -- nur sichtbar, solange tatsächlich gezoomt ist (siehe
   updateZoomResetButton() in home.js). Ohne die explizite [hidden]-Regel
   unten gewinnt die eigene "display: flex" gegen die UA-Stylesheet-Regel
   fürs hidden-Attribut (gleiches Muster wie schon bei
   .user-menu-dropdown[hidden] weiter oben dokumentiert), das Icon bliebe
   dann dauerhaft sichtbar. */
.zoom-reset-button {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--baseline);
  border-radius: 50%;
  background: var(--surface-1);
  color: var(--text-secondary);
  cursor: pointer;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.1);
}

.zoom-reset-button[hidden] {
  display: none;
}

.zoom-reset-button svg {
  width: 14px;
  height: 14px;
  flex: none;
}

.zoom-reset-button:hover {
  background: var(--page);
  color: var(--text-primary);
}

/* (i)-Knopf direkt neben dem Kartentitel "Leistungsübersicht" -- öffnet das
   Bedienungshinweis-Popover (siehe .info-popover unten) statt den Hinweis
   dauerhaft als Fliesstext unter dem Chart zu zeigen. Nur in der
   Tagesansicht sichtbar (siehe updateDayNavUI() in home.js) -- gleicher
   [hidden]-Grund wie bei .zoom-reset-button oben, da auch hier "display"
   explizit gesetzt ist. */
.chart-title-info-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  margin-left: 2px;
  padding: 0;
  border: none;
  background: none;
  color: var(--text-muted);
  cursor: pointer;
  vertical-align: -3px;
}

.chart-title-info-button[hidden] {
  display: none;
}

.chart-title-info-button svg {
  width: 16px;
  height: 16px;
  flex: none;
}

.chart-title-info-button:hover {
  color: var(--text-primary);
}

/* Popup mit dem Bedienungshinweis, per Klick auf .chart-title-info-button
   ein-/ausgeblendet (siehe positionInfoPopover() in home.js) -- viewport-
   fixiert wie #power-overview-tooltip weiter unten, damit es unabhängig von
   der Position im Layout "über allem" erscheint. Kein eigenes "display" in
   dieser Regel gesetzt, deshalb reicht die UA-[hidden]-Regel hier aus (siehe
   Kommentar bei .zoom-reset-button[hidden] zum Unterschied). */
.info-popover {
  position: fixed;
  max-width: 280px;
  background: var(--tooltip-surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 0.78rem;
  line-height: 1.4;
  color: var(--text-secondary);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
  z-index: 40;
}

.chart-empty {
  color: var(--text-muted);
  font-size: 0.85rem;
  padding: 40px 0;
  text-align: center;
}

.axis-line {
  stroke: var(--baseline);
  stroke-width: 1;
}

.gridline {
  stroke: var(--gridline);
  stroke-width: 1;
}

.axis-label {
  fill: var(--text-muted);
  font-size: 11px;
  font-family: "Manrope", system-ui, -apple-system, "Segoe UI", sans-serif;
}

.crosshair {
  stroke: var(--baseline);
  stroke-width: 1;
  pointer-events: none;
}

.hover-dot {
  stroke: var(--surface-1);
  stroke-width: 2;
  pointer-events: none;
}

.tooltip {
  position: absolute;
  background: var(--tooltip-surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 0.78rem;
  color: var(--text-primary);
  pointer-events: none;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
  white-space: nowrap;
}

.tooltip .tooltip-value {
  font-weight: 600;
}

/* Nur die Leistungsübersicht-Tooltip: viewport-fixiert statt relativ zu
   .chart-wrap (das overflow-x: auto hat und sie sonst am Rand abschneidet
   statt "über allem" zu liegen) -- preise.js's eigene Tooltip-Instanz bleibt
   bei der .tooltip-Basisklasse (position: absolute, container-relativ),
   deshalb Override nur über die ID, nicht an der Klasse selbst. */
#power-overview-tooltip, #heater-history-tooltip {
  position: fixed;
}

/* EnMelt: 6-Schritte-Assistent zum Abschmelzen von Schnee auf den PV-Modulen. */

.enmelt-progress-track {
  width: 100%;
  height: 6px;
  border-radius: 999px;
  background: var(--baseline);
  overflow: hidden;
  margin-bottom: 20px;
}

.enmelt-progress-fill {
  height: 100%;
  background: var(--brand-navy);
  transition: width 0.4s ease;
}

.enmelt-step h3 {
  margin: 0 0 6px;
}

.enmelt-pin-row {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

.enmelt-pin-row input {
  padding: 9px 11px;
  border-radius: 8px;
  border: 1px solid var(--baseline);
  background: var(--page);
  color: var(--text-primary);
  font-size: 1.1rem;
  letter-spacing: 0.15em;
  font-family: inherit;
  width: 140px;
}

.enmelt-placeholder-hint {
  font-size: 0.76rem;
  margin-top: 10px;
}

.enmelt-busy {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text-secondary);
  font-size: 0.9rem;
}

.enmelt-spinner {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2.5px solid var(--baseline);
  border-top-color: var(--brand-navy);
  animation: enmelt-spin 0.8s linear infinite;
  flex: none;
}

@keyframes enmelt-spin {
  to { transform: rotate(360deg); }
}

.enmelt-timer {
  font-size: 2.6rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  margin: 4px 0 14px;
}

.enmelt-timer-fill {
  background: var(--brand-accent);
}

.enmelt-stop-button {
  padding: 12px 28px;
  border: none;
  border-radius: 8px;
  background: var(--critical);
  color: #ffffff;
  font-size: 1rem;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
}

.enmelt-stop-button:hover {
  opacity: 0.88;
}

.enmelt-stop-confirm {
  margin-top: 14px;
}

.enmelt-stop-confirm-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

/* MQTT-Log: Live-Tail der Firmware-Debug-Logs (nur Admins, siehe /admin/mqtt-log) */

.mqtt-log-status {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.mqtt-log-status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--critical);
  flex: none;
}

.mqtt-log-status-dot.is-connected {
  background: var(--status-good);
}

.mqtt-log-toolbar {
  margin-bottom: 8px;
}

.mqtt-log-output {
  margin: 0;
  padding: 14px;
  border-radius: 8px;
  background: var(--page);
  border: 1px solid var(--border);
  color: var(--text-primary);
  font-family: "Consolas", "Menlo", monospace;
  font-size: 0.8rem;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 60vh;
  overflow-y: auto;
}

@media (max-width: 760px) {
  .app-shell {
    flex-direction: column;
  }

  /* Bottom tab bar, not a top strip -- the standard mobile-app nav
     placement (thumb-reachable). Taken out of flow (fixed), so .content
     gets matching bottom padding below to avoid the bar covering it.
     Unlike api-transparency (6 nav items -> needs a "Menu" overflow tab),
     ems-portal only ever has up to 4 (Dashboard/Optimierung/Preise/Admin),
     so they all just fit directly, no overflow tab needed. */
  .sidebar {
    width: 100%;
    height: auto;
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    top: auto;
    z-index: 20;
    flex-direction: row;
    align-items: center;
    padding: 8px 8px calc(8px + env(safe-area-inset-bottom, 0px));
    gap: 2px;
    border-top: 1px solid rgba(255, 255, 255, 0.10);
  }

  .sidebar-nav {
    flex-direction: row;
    flex: 1;
    justify-content: space-around;
  }

  .sidebar-nav a {
    flex-direction: column;
    gap: 3px;
    padding: 6px 8px;
    font-size: 0.62rem;
  }

  .sidebar-nav span {
    display: block;
  }

  .app-main {
    padding-bottom: calc(58px + env(safe-area-inset-bottom, 0px));
  }

  .topbar {
    padding: 10px 16px;
    flex-wrap: wrap;
    row-gap: 8px;
  }

  .content {
    padding: 14px 14px 28px;
    gap: 14px;
  }

  .card {
    padding: 14px;
  }

  /* Kleinerer Karten-Innenabstand hier -- Breakout entsprechend nachziehen
     (siehe #power-overview-wrap weiter oben). */
  #power-overview-wrap {
    margin-left: -14px;
    margin-right: -14px;
    width: calc(100% + 28px);
  }

  /* Bei zwei Kuchendiagrammen + Legenden nebeneinander reicht die Breite auf
     einem Handy nicht -- .donut-row bricht dank flex-wrap zwar um, bliebe
     ohne dies aber linksbündig statt zentriert untereinander. */
  .donut-row {
    justify-content: center;
  }
}

/* EnMan-Konfigurationskanal (Admin): Zusammenfassung + Status-Pillen pro Gerät */
.enman-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 32px;
  margin-bottom: 16px;
}

.enman-summary-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.enman-summary-value {
  font-size: 1.5rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.status-pill {
  display: inline-block;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 0.76rem;
  font-weight: 600;
  white-space: nowrap;
  border: 1px solid currentColor;
}

.status-pill-good { color: var(--status-good); }
.status-pill-warn { color: var(--status-warning); }
.status-pill-off { color: var(--text-muted); }

.enman-label-form {
  display: flex;
  gap: 6px;
}

.enman-label-form input[type="text"] {
  min-width: 150px;
  padding: 5px 8px;
  border-radius: 6px;
  border: 1px solid var(--baseline);
  background: var(--page);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.85rem;
}

.enman-label-form button {
  padding: 5px 10px;
  border: none;
  border-radius: 6px;
  background: var(--brand-navy);
  color: #ffffff;
  font-size: 0.78rem;
  cursor: pointer;
}

.table-scroll {
  overflow-x: auto;
}

/* EnMan-Konfiguration senden (Admin) */
.enman-send summary {
  cursor: pointer;
  color: var(--brand-accent);
  font-size: 0.85rem;
  font-weight: 600;
}

.enman-send-form {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 260px;
  margin-top: 8px;
}

.enman-send-form label {
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-size: 0.72rem;
  color: var(--text-muted);
}

.enman-send-form input[type="text"],
.enman-send-form input[type="password"] {
  padding: 6px 8px;
  border-radius: 6px;
  border: 1px solid var(--baseline);
  background: var(--page);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.85rem;
}

.enman-send-form .enman-check {
  flex-direction: row;
  align-items: center;
  gap: 6px;
  font-size: 0.78rem;
}

.enman-send-form .danger-button {
  margin-top: 4px;
}

/* Live-Anzeige der Konfigurationskanal-Seite */
.enman-live {
  font-size: 0.78rem;
  margin: 0 0 12px;
}

.enman-live::before {
  content: "";
  display: inline-block;
  width: 8px;
  height: 8px;
  margin-right: 6px;
  border-radius: 50%;
  background: var(--baseline);
}

.enman-live[data-state="ok"]::before { background: var(--status-good); }
.enman-live[data-state="error"] { color: var(--status-critical); }
.enman-live[data-state="error"]::before { background: var(--status-critical); }

.status-pill-changed {
  animation: status-pill-flash 1.5s ease-out;
}

@keyframes status-pill-flash {
  from { box-shadow: 0 0 0 4px var(--brand-accent); }
  to { box-shadow: 0 0 0 0 transparent; }
}

@media (prefers-reduced-motion: reduce) {
  .status-pill-changed { animation: none; }
}

/* Firmware-Update (Admin > Update) */
.small { font-size: 0.72rem; }

.updates-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 20px;
  margin: 8px 0 12px;
}

.updates-head h2 { margin: 0; }
.updates-head .enman-live { margin: 0; }

.updates-filter {
  margin-left: auto;
  padding: 6px 10px;
  border-radius: 6px;
  border: 1px solid var(--baseline);
  background: var(--page);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.85rem;
  min-width: 180px;
}

.updates-table td { vertical-align: middle; }
.updates-table tr[hidden] { display: none; }

.conn-dot, .job-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  margin-right: 7px;
  border-radius: 50%;
  background: var(--baseline);
}

.conn-online, .job-applied { background: var(--status-good); }
.conn-offline, .job-failed { background: var(--status-critical); }
.job-pending { background: var(--baseline); }
.job-notified, .job-downloaded { background: var(--status-warning); }

.fw-tag {
  display: inline-block;
  padding: 1px 7px;
  border-radius: 999px;
  font-size: 0.68rem;
  font-weight: 600;
  border: 1px solid currentColor;
}

.fw-tag-global { color: var(--brand-accent); }
.fw-tag-individual { color: var(--status-warning); }

.updates-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 10px 12px;
  margin-top: 16px;
}

.updates-select {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.updates-select select {
  min-width: 240px;
  padding: 9px 10px;
  border-radius: 8px;
  border: 1px solid var(--baseline);
  background: var(--page);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.9rem;
}

.updates-toolbar button:disabled { opacity: 0.45; cursor: default; }
.updates-toolbar .save-button,
.updates-toolbar .danger-button { margin-top: 0; }

.updates-dialog {
  width: min(880px, calc(100vw - 32px));
  max-height: calc(100vh - 48px);
  padding: 20px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface-1);
  color: var(--text-primary);
}

.updates-dialog::backdrop { background: rgba(0, 0, 0, 0.45); }

.updates-dialog h3 {
  margin: 20px 0 8px;
  font-size: 0.95rem;
}

.updates-dialog-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.updates-dialog-head h2 { margin: 0; }
.updates-dialog-head .link-button { font-size: 1.6rem; text-decoration: none; }

.updates-upload { max-width: none; }
.updates-upload textarea {
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid var(--baseline);
  background: var(--page);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.88rem;
}

.updates-scope {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.updates-table td[data-cell="current"],
.updates-table td[data-cell="status"],
.updates-table td[data-cell="notified"],
.updates-table td[data-cell="downloaded"],
.updates-table td[data-cell="completed"] {
  white-space: nowrap;
}

.updates-table td[data-cell="conn"] .small { white-space: nowrap; }

.enman-migrate-all {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  margin: 12px 0;
}

/* Admin > Anlage > Installation */
.install-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px 16px;
  align-items: end;
  margin: 8px 0 16px;
}
.install-grid label { display: flex; flex-direction: column; gap: 4px; font-size: 0.9rem; }
.install-grid .install-wide { grid-column: 1 / -1; }
.install-es { margin: 16px 0; padding: 12px; border: 1px solid var(--border, #d0d5dd); border-radius: 8px; }
.install-es-head { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-bottom: 8px; }
.inline-form { display: inline; }
.install-secret summary, .install-protocol-add summary, .inline-details summary { cursor: pointer; font-size: 0.85rem; }
.inline-details { display: inline; }
.install-protocol { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 4px; }
.install-protocol-edit { margin: 4px 0 8px; }
.install-protocol-edit summary { cursor: pointer; font-size: 0.85rem; }
.install-protocol-edit form { margin-top: 8px; padding: 10px; border: 1px solid var(--border); border-radius: 8px; background: var(--page); max-width: 480px; }
.protocol-form { display: flex; flex-direction: column; gap: 6px; margin-top: 6px; max-width: 260px; }
.protocol-attributes { display: flex; flex-direction: column; gap: 6px; }

/* Geführter Ablauf (Pop-ups) */
.install-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.wizard-dialog {
  width: min(680px, calc(100vw - 32px));
  max-height: calc(100vh - 48px);
  padding: 20px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface-1);
  color: var(--text-primary);
}
.wizard-dialog::backdrop { background: rgba(0, 0, 0, 0.45); }
.wizard-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.wizard-head h2 { margin: 2px 0 0; }
.wizard-step-label { font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--text-secondary, #667085); }
.wizard-close { font-size: 1.6rem; text-decoration: none; }
.wizard-steps { display: flex; flex-wrap: wrap; gap: 6px; list-style: none; padding: 0; margin: 12px 0 16px; font-size: 0.78rem; }
.wizard-steps li { padding: 3px 10px; border-radius: 999px; background: var(--page); color: var(--text-secondary, #667085); border: 1px solid var(--border); }
.wizard-steps li.wizard-step-active { background: var(--text-primary); color: var(--surface-1); border-color: var(--text-primary); }
.wizard-steps li.wizard-step-done { color: var(--text-primary); }
.wizard-form { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 16px; }
.wizard-form .wizard-wide, .wizard-form .wizard-actions, .wizard-form .wizard-error { grid-column: 1 / -1; }
.wizard-field { display: flex; flex-direction: column; gap: 4px; font-size: 0.88rem; }
.wizard-field span { color: var(--text-secondary, #667085); }
.wizard-field input, .wizard-field select, .wizard-field textarea {
  padding: 8px 10px; border-radius: 8px; border: 1px solid var(--baseline); background: var(--page);
  color: var(--text-primary); font-family: inherit; font-size: 0.9rem;
}
.wizard-check { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; font-size: 0.9rem; }
.wizard-limit-row { display: flex; gap: 8px; margin-top: 2px; }
.wizard-limit-field {
  display: flex; flex-direction: column; gap: 2px; flex: 1 1 0; min-width: 0; font-size: 0.76rem;
}
/* Flex-/Grid-Kinder schrumpfen ohne das hier nicht unter ihre intrinsische Inhaltsbreite --
   number-Inputs mit Spinner-Pfeilen sind von Haus aus recht breit, das sprengt sonst schmale
   Spalten (siehe wizard-limit-row) statt sich einzupassen. */
.wizard-limit-field input { min-width: 0; }
.wizard-limit-field input {
  padding: 5px 8px; border-radius: 6px; border: 1px dashed var(--baseline); background: transparent;
  color: var(--text-secondary); font-family: inherit; font-size: 0.8rem;
}
.wizard-limit-field input:not(:placeholder-shown) { color: var(--text-primary); border-style: solid; }
.peakshaving-limits { display: flex; flex-direction: column; gap: 6px; margin: 8px 0; }
.peakshaving-limit-row { display: flex; gap: 8px; align-items: center; }
.peakshaving-limit-row select { flex: 2 1 0; min-width: 0; }
.peakshaving-limit-row input { flex: 1 1 0; min-width: 0; }
.peakshaving-limit-row select, .peakshaving-limit-row input {
  padding: 6px 8px; border-radius: 6px; border: 1px solid var(--baseline); background: var(--page);
  color: var(--text-primary); font-family: inherit; font-size: 0.85rem;
}
.wizard-section { font-size: 0.8rem; font-weight: 600; margin-top: 4px; padding-top: 10px; border-top: 1px dashed var(--border); }
.wizard-hint { margin: 0; }
.wizard-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 10px; margin-top: 8px; }
.wizard-secondary {
  display: inline-block; padding: 8px 14px; border-radius: 8px; border: 1px solid var(--baseline);
  background: var(--page); color: var(--text-primary); font-size: 0.88rem; cursor: pointer; text-decoration: none;
}
.wizard-dialog h3 { margin: 12px 0 4px; font-size: 0.95rem; }
.wizard-protocol { border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; margin-bottom: 8px; }
.wizard-protocol-head { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.wizard-protocol-head .wizard-secondary { margin-left: auto; }
.wizard-protocol-form { display: grid; gap: 8px; margin-top: 10px; }
.wizard-protocol-done { font-size: 0.9rem; padding: 2px 0; }
.wizard-summary-row { display: flex; gap: 12px; padding: 4px 0; border-bottom: 1px solid var(--border); }
.wizard-summary-row span { min-width: 120px; }
.wizard-credential { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; padding: 4px 0; }
.wizard-credential span { min-width: 130px; }
.wizard-credential code { word-break: break-all; flex: 1 1 200px; }
@media (max-width: 560px) { .wizard-form { grid-template-columns: 1fr; } }

.wizard-dialog [hidden] { display: none !important; }

/* Admin > Produktkatalog */
.catalog-head { display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: space-between; gap: 12px; }
.catalog-head h1, .catalog-head h2 { margin: 0 0 4px; }
.catalog-tree { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; }
.catalog-branch { border: 1px solid var(--border); border-radius: 8px; background: var(--surface-1); }
.catalog-branch > .catalog-summary { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; padding: 10px 12px; cursor: pointer; list-style: none; }
.catalog-branch > .catalog-summary::-webkit-details-marker { display: none; }
.catalog-branch > .catalog-summary::before { content: "▸"; color: var(--text-secondary, #667085); }
.catalog-branch[open] > .catalog-summary::before { content: "▾"; }
.catalog-level-manufacturer > .catalog-summary { background: var(--page); font-weight: 600; }
.catalog-name { font-weight: 600; }
.catalog-actions { display: inline-flex; align-items: center; gap: 6px; margin-left: auto; }
.catalog-children { display: flex; flex-direction: column; gap: 8px; padding: 0 12px 12px; }
.catalog-model { padding: 0 12px 12px; }
.catalog-block { border: 1px solid var(--border); border-radius: 8px; padding: 8px 12px; margin-top: 8px; }
.catalog-block-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 4px; }
.catalog-row { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; padding: 4px 0; border-top: 1px solid var(--border); }
.catalog-add { padding: 4px 10px; font-size: 0.8rem; }
.catalog-icon { border: 0; background: transparent; cursor: pointer; font-size: 1rem; color: var(--text-secondary, #667085); padding: 2px 6px; }
.catalog-icon-danger { color: var(--status-critical, #c0392b); }
.catalog-checks { display: flex; flex-direction: column; gap: 4px; }
.catalog-fields { margin-bottom: 8px; }

/* Geräte-Baum: Drag & Drop */
tr[data-device-row] { cursor: grab; }
tr[data-device-row]:active { cursor: grabbing; }
.install-drag-handle { display: inline-block; margin-right: 4px; color: var(--text-secondary, #667085); cursor: grab; }
.device-drop-target { outline: 2px dashed var(--text-primary); outline-offset: -2px; background: var(--page); }

.install-telemetry { display: flex; flex-wrap: wrap; gap: 6px 10px; margin-top: 2px; }

.site-actions { display: flex; flex-wrap: wrap; gap: 6px; }
