:root {
  /* Eneron brand */
  --brand-navy: #173346;
  --brand-navy-ink: #0e1f2b;
  --brand-lightblue: #89c1d8;

  --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;
}

@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);
    --series-grid: #e66767;
    --series-battery: #3fc17a;
    --series-pv: #c98500;
    --series-load: #d8d7cf;
    --series-soc: #3987e5;
  }
}

* {
  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 */

.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;
}

.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;
}

.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;
}

.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-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-card-updated {
  font-size: 0.72rem;
  color: var(--text-muted);
}

.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 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;
}

.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;
}

.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);
}

/* 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;
}

.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;
}

.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);
}

.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-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;
}

@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;
  }
}
