/* ==========================================================================
   Wallbox Charging Management & Billing - Design System
   Farbschema: Gruen/Blau, Nachhaltigkeit & erneuerbare Energien
   ========================================================================== */

:root {
  --green-900: #063a26;
  --green-800: #0a5334;
  --green-700: #0b6340;
  --green-600: #0e7a4f;
  --green-500: #16a34a;
  --green-400: #34c77b;
  --green-100: #d9f2e4;
  --blue-800: #0d4d80;
  --blue-700: #1266a8;
  --blue-600: #1a76c4;
  --blue-500: #3292dd;
  --blue-100: #dceaf8;
  --amber-500: #d9822b;
  --amber-100: #fdf0dd;
  --red-600: #c0392b;
  --red-100: #fbe4e1;

  --bg: #f2f6f5;
  --bg-accent: radial-gradient(1200px 600px at 12% -8%, #d9f2e4 0%, rgba(217, 242, 228, 0) 60%),
               radial-gradient(900px 500px at 100% 0%, #dceaf8 0%, rgba(220, 234, 248, 0) 55%);
  --surface: #ffffff;
  --surface-2: #f7fbf9;
  --surface-3: #eef4f1;
  --text: #10262c;
  --text-soft: #3b545c;
  --muted: #6a8189;
  --border: #dde8e3;
  --border-strong: #c6d7d1;
  --shadow-sm: 0 1px 2px rgba(14, 60, 45, .06), 0 1px 3px rgba(14, 60, 45, .04);
  --shadow: 0 8px 24px rgba(11, 56, 42, .08), 0 2px 6px rgba(11, 56, 42, .04);
  --shadow-lg: 0 20px 45px rgba(9, 46, 35, .14);
  --radius-sm: 8px;
  --radius: 14px;
  --radius-lg: 20px;
  --primary: var(--green-600);
  --primary-contrast: #ffffff;
  --accent: var(--blue-600);
  --gradient: linear-gradient(135deg, var(--green-700) 0%, var(--green-500) 48%, var(--blue-600) 100%);
  --chart-1: #0e7a4f;
  --chart-2: #1a76c4;
  --chart-3: #34c77b;
  --chart-4: #d9822b;
  --chart-5: #7a5cd6;
  --sidebar-width: 254px;
  --topbar-height: 62px;
}

html[data-theme="dark"] {
  --bg: #071216;
  --bg-accent: radial-gradient(1100px 560px at 10% -10%, rgba(22, 163, 74, .18) 0%, rgba(7, 18, 22, 0) 60%),
               radial-gradient(900px 520px at 100% 0%, rgba(26, 118, 196, .18) 0%, rgba(7, 18, 22, 0) 55%);
  --surface: #0f2027;
  --surface-2: #132a33;
  --surface-3: #17323d;
  --text: #e7f3ef;
  --text-soft: #c2d6d3;
  --muted: #8ba5a4;
  --border: #1e3945;
  --border-strong: #2a4b58;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .4);
  --shadow: 0 10px 30px rgba(0, 0, 0, .45);
  --shadow-lg: 0 24px 55px rgba(0, 0, 0, .55);
  --green-100: #113a2a;
  --blue-100: #102b41;
  --amber-100: #3a2a13;
  --red-100: #3b1b17;
  --primary: #2fb673;
  --primary-contrast: #04140d;
  --accent: #4aa3e6;
  --gradient: linear-gradient(135deg, #0b6340 0%, #16a34a 50%, #1a76c4 100%);
  --chart-1: #2fb673;
  --chart-2: #4aa3e6;
  --chart-3: #7fe0ae;
  --chart-4: #e8a85c;
  --chart-5: #a58bf0;
  color-scheme: dark;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  font-family: "Segoe UI", system-ui, -apple-system, "Inter", Roboto, "Helvetica Neue", Arial, sans-serif;
  background-color: var(--bg);
  background-image: var(--bg-accent);
  background-attachment: fixed;
  color: var(--text);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3, h4 { margin: 0 0 .5rem; line-height: 1.25; font-weight: 650; letter-spacing: -.01em; }
h1 { font-size: 1.55rem; }
h2 { font-size: 1.2rem; }
h3 { font-size: 1.02rem; }
p { margin: 0 0 .85rem; }
small, .small { font-size: .8rem; }
.muted { color: var(--muted); }
.text-soft { color: var(--text-soft); }
.mono { font-family: "JetBrains Mono", ui-monospace, "SFMono-Regular", Consolas, monospace; }
.nowrap { white-space: nowrap; }
.center { text-align: center; }
.right { text-align: right; }
.grow { flex: 1 1 auto; }
.mt-0 { margin-top: 0; } .mt-1 { margin-top: .5rem; } .mt-2 { margin-top: 1rem; } .mt-3 { margin-top: 1.5rem; }
.mb-0 { margin-bottom: 0; } .mb-1 { margin-bottom: .5rem; } .mb-2 { margin-bottom: 1rem; } .mb-3 { margin-bottom: 1.5rem; }
.hidden { display: none !important; }

/* ------------------------------------------------------------------ Layout */
.app { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-width);
  flex: 0 0 var(--sidebar-width);
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  z-index: 40;
}

.brand {
  display: flex; align-items: center; gap: .65rem;
  padding: 1rem 1.1rem; border-bottom: 1px solid var(--border);
  color: var(--text); text-decoration: none;
}
.brand:hover { text-decoration: none; }
.brand-mark {
  width: 38px; height: 38px; border-radius: 11px; background: var(--gradient);
  display: grid; place-items: center; color: #fff; flex: 0 0 38px;
  box-shadow: var(--shadow-sm);
}
.brand-text { min-width: 0; }
.brand-title { font-weight: 700; font-size: .95rem; letter-spacing: -.01em; }
.brand-sub { font-size: .7rem; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; }

.nav { padding: .7rem .6rem; overflow-y: auto; flex: 1 1 auto; }
.nav-group-label {
  font-size: .68rem; text-transform: uppercase; letter-spacing: .1em;
  color: var(--muted); padding: .85rem .75rem .35rem; font-weight: 700;
}
.nav-link {
  display: flex; align-items: center; gap: .7rem; min-height: 42px;
  padding: .55rem .75rem; border-radius: 10px; color: var(--text-soft);
  font-weight: 550; font-size: .9rem; transition: background .15s, color .15s;
}
.nav-link:hover { background: var(--surface-3); color: var(--text); text-decoration: none; }
.nav-link.active { background: linear-gradient(90deg, var(--green-100), transparent); color: var(--primary); }
.nav-link.active svg { color: var(--primary); }
.nav-link svg { width: 19px; height: 19px; flex: 0 0 19px; color: var(--muted); }
.nav-badge {
  margin-left: auto; background: var(--amber-100); color: var(--amber-500);
  border-radius: 999px; font-size: .7rem; padding: .1rem .45rem; font-weight: 700;
}

.sidebar-foot { padding: .8rem 1rem; border-top: 1px solid var(--border); font-size: .75rem; color: var(--muted); }

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

.topbar {
  height: var(--topbar-height); position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; gap: .75rem; padding: 0 1.1rem;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}
.topbar h1 { font-size: 1.05rem; margin: 0; }
.topbar .crumb { font-size: .78rem; color: var(--muted); }
.icon-btn {
  width: 42px; height: 42px; border-radius: 11px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text-soft); display: grid; place-items: center;
  cursor: pointer; transition: background .15s, color .15s;
}
.icon-btn:hover { background: var(--surface-3); color: var(--text); }
.icon-btn svg { width: 19px; height: 19px; }

.user-chip {
  display: flex; align-items: center; gap: .55rem; padding: .35rem .7rem .35rem .4rem;
  border: 1px solid var(--border); border-radius: 999px; background: var(--surface);
  font-size: .85rem; color: var(--text); cursor: pointer; font: inherit;
}
.user-chip:hover { background: var(--surface-3); }
.user-chip .chev { display: grid; place-items: center; color: var(--text-soft); margin-left: .15rem; }
.user-menu { position: relative; }
.user-menu-panel {
  position: absolute; right: 0; top: calc(100% + .45rem); min-width: 258px; z-index: 70;
  background: var(--surface); border: 1px solid var(--border); border-radius: 14px;
  box-shadow: var(--shadow, 0 18px 40px rgba(15, 40, 30, .18)); padding: .45rem;
  display: none;
}
.user-menu.open .user-menu-panel { display: block; }
.user-menu-head {
  display: flex; flex-direction: column; gap: .15rem; padding: .6rem .65rem .55rem;
  border-bottom: 1px solid var(--border); margin-bottom: .35rem;
}
.user-menu-item {
  display: flex; align-items: center; gap: .55rem; padding: .5rem .65rem; border-radius: 10px;
  color: var(--text); text-decoration: none; font-size: .88rem;
}
.user-menu-item:hover { background: var(--surface-3); }
.user-menu-item.danger { color: #b4341f; }
.user-menu-sep { height: 1px; background: var(--border); margin: .35rem .3rem; }
.avatar {
  width: 30px; height: 30px; border-radius: 999px; background: var(--gradient); color: #fff;
  display: grid; place-items: center; font-weight: 700; font-size: .78rem;
}

/* Breite Bildschirme: Inhalt nutzt die Flaeche, Texte bleiben lesbar */
.content { padding: 1.35rem 1.6rem 3rem; max-width: 1900px; width: 100%; }
@media (min-width: 1700px) {
  .content { padding: 1.5rem 2.2rem 3.2rem; }
  .grid.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .grid.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (min-width: 2100px) {
  .content { max-width: 2400px; }
  .grid.cols-4 { grid-template-columns: repeat(6, minmax(0, 1fr)); }
  .card { margin-bottom: 1.25rem; }
}

/* ------------------------------------------------------------------ Cards */
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow-sm); padding: 1.1rem 1.2rem; margin-bottom: 1.1rem;
}
.card.flush { padding: 0; overflow: hidden; }
.card-head {
  display: flex; align-items: center; gap: .6rem; flex-wrap: wrap;
  padding: .9rem 1.1rem; border-bottom: 1px solid var(--border);
}
.card-head h2, .card-head h3 { margin: 0; }
.card-body { padding: 1.05rem 1.1rem; }
.card-actions { margin-left: auto; display: flex; gap: .5rem; flex-wrap: wrap; }
.card-actions.tight { gap: .3rem; align-items: center; }

/* Aktionsleiste: alle Schaltflaechen einer Ansicht an einer Stelle, einheitliche Groesse */
.action-bar {
  display: flex; align-items: center; gap: .6rem; flex-wrap: wrap;
  padding: .45rem .9rem; border-top: 1px solid var(--border); background: var(--surface-2);
}
.action-bar.subtle { background: transparent; }
.action-bar-label {
  font-size: .68rem; text-transform: uppercase; letter-spacing: .07em;
  color: var(--muted); font-weight: 600; min-width: 4.5rem;
}
.action-bar-items { display: flex; align-items: center; gap: .4rem; flex-wrap: wrap; margin: 0; }
.action-bar-items.tight { gap: .3rem; }
select.sm, input.sm, .input-sm {
  min-height: 27px; padding: .16rem .42rem; font-size: .78rem; border-radius: 7px;
}
input.sm { min-width: 12rem; }

.grid { display: grid; gap: 1.1rem; }
.grid.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid.cols-2-1 { grid-template-columns: 2fr 1fr; }
.grid.cols-1-2 { grid-template-columns: 1fr 2fr; }

.kpi {
  position: relative; overflow: hidden;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 1rem 1.1rem; box-shadow: var(--shadow-sm);
}
.kpi::after {
  content: ""; position: absolute; inset: 0 auto 0 0; width: 4px; background: var(--gradient);
}
.kpi.hue-blue::after { background: linear-gradient(180deg, var(--blue-600), var(--blue-500)); }
.kpi.hue-amber::after { background: linear-gradient(180deg, var(--amber-500), #f0b064); }
.kpi.hue-green::after { background: linear-gradient(180deg, var(--green-500), var(--green-400)); }
.kpi-label { font-size: .76rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); font-weight: 700; }
.kpi-value { font-size: 1.6rem; font-weight: 700; letter-spacing: -.02em; margin: .2rem 0 .1rem; }
.kpi-unit { font-size: .85rem; font-weight: 600; color: var(--muted); margin-left: .25rem; }
.kpi-sub { font-size: .8rem; color: var(--muted); }
.trend { font-size: .78rem; font-weight: 700; border-radius: 999px; padding: .05rem .45rem; }
.trend.up { background: var(--green-100); color: var(--green-700); }
.trend.down { background: var(--red-100); color: var(--red-600); }
html[data-theme="dark"] .trend.up { color: var(--green-400); }

/* ------------------------------------------------------------------ Forms */
.form-grid { display: grid; gap: .95rem; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.form-grid.one { grid-template-columns: 1fr; }
.field { display: flex; flex-direction: column; gap: .3rem; }
.field.span-2 { grid-column: 1 / -1; }
label, .label { font-size: .82rem; font-weight: 650; color: var(--text-soft); }
.hint { font-size: .76rem; color: var(--muted); }

/* v26: abgelehnter Einstellungswert — Hinweis direkt am Feld */
.field-error { display: block; margin-top: .3rem; font-size: .78rem; color: var(--red-600); }
input.input-error, textarea.input-error, select.input-error { border-color: var(--red-600); }

input[type="text"], input[type="password"], input[type="number"], input[type="email"],
input[type="search"], input[type="date"], input[type="datetime-local"], input[type="time"],
select, textarea {
  width: 100%; padding: .62rem .7rem; font-size: 16px; font-family: inherit;
  background: var(--surface-2); color: var(--text);
  border: 1px solid var(--border-strong); border-radius: 10px; min-height: 44px;
  transition: border-color .15s, box-shadow .15s;
}
textarea { min-height: 88px; resize: vertical; }
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--primary);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 22%, transparent);
}
input[type="checkbox"] { width: 20px; height: 20px; accent-color: var(--primary); }
.check { display: flex; align-items: center; gap: .55rem; font-size: .88rem; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .45rem;
  min-height: 42px; padding: .55rem .95rem; border-radius: 11px; border: 1px solid transparent;
  background: var(--primary); color: var(--primary-contrast); font-weight: 650; font-size: .88rem;
  cursor: pointer; transition: transform .06s, filter .15s, background .15s; font-family: inherit;
}
.btn:hover { filter: brightness(1.07); text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn svg { width: 17px; height: 17px; }
.btn.secondary { background: var(--surface); color: var(--text); border-color: var(--border-strong); }
.btn.secondary:hover { background: var(--surface-3); }
.btn.accent { background: var(--accent); color: #fff; }
.btn.ghost { background: transparent; color: var(--text-soft); border-color: transparent; }
.btn.ghost:hover { background: var(--surface-3); color: var(--text); }
.btn.danger { background: var(--red-600); color: #fff; }
.btn.warn { background: var(--amber-500); color: #fff; }
.btn.sm { min-height: 34px; padding: .3rem .65rem; font-size: .8rem; border-radius: 9px; }
.btn.xs { min-height: 27px; padding: .18rem .48rem; font-size: .74rem; border-radius: 7px; gap: .3rem; }
.btn.xs svg { width: 13px; height: 13px; }
.btn.block { width: 100%; }
.btn:disabled { opacity: .55; cursor: not-allowed; }

.actions { display: flex; gap: .6rem; flex-wrap: wrap; align-items: center; }

/* ------------------------------------------------------------------ Tables */
.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: .88rem; }
table.data th, table.data td { padding: .6rem .7rem; text-align: left; border-bottom: 1px solid var(--border); }
table.data th {
  font-size: .74rem; text-transform: uppercase; letter-spacing: .07em; color: var(--muted);
  background: var(--surface-2); position: sticky; top: 0; font-weight: 700; white-space: nowrap;
}
table.data tbody tr:hover { background: var(--surface-2); }
table.data td.num, table.data th.num { text-align: right; font-variant-numeric: tabular-nums; }
table.data th a { color: inherit; text-decoration: none; display: inline-flex; align-items: center; gap: .25rem; }
table.data th a:hover { color: var(--blue-600); }
table.data th .sort-ind { opacity: .35; }
table.data th.sort-active .sort-ind { opacity: 1; color: var(--blue-600); }
/* v1.15: sortierbare Tabellen (Klick auf die Kopfzeile) */
table.sortable th.sortable-head { cursor: pointer; user-select: none; white-space: nowrap; }
table.sortable th.sortable-head:hover { color: var(--blue-600); }
table.sortable th.sortable-head::after { content: "\2195"; opacity: .35; margin-left: .3rem; font-size: .85em; }
table.sortable th.sort-asc::after { content: "\2191"; opacity: 1; }
table.sortable th.sort-desc::after { content: "\2193"; opacity: 1; }
table.sortable th.sortable-head:focus-visible { outline: 2px solid var(--blue-600); outline-offset: 2px; }
table.data tfoot td { font-weight: 700; background: var(--surface-2); border-top: 2px solid var(--border-strong); }
.table-empty { padding: 1.6rem; text-align: center; color: var(--muted); }

.badge {
  display: inline-flex; align-items: center; gap: .3rem; padding: .16rem .55rem;
  border-radius: 999px; font-size: .74rem; font-weight: 700; letter-spacing: .01em;
  background: var(--surface-3); color: var(--text-soft); white-space: nowrap;
}
.badge.green { background: var(--green-100); color: var(--green-700); }
.badge.blue { background: var(--blue-100); color: var(--blue-700); }
.badge.amber { background: var(--amber-100); color: var(--amber-500); }
.badge.red { background: var(--red-100); color: var(--red-600); }
html[data-theme="dark"] .badge.green { color: var(--green-400); }
html[data-theme="dark"] .badge.blue { color: var(--blue-500); }

.pill-solar {
  display: inline-flex; align-items: center; gap: .35rem; font-weight: 700; font-size: .8rem;
  font-variant-numeric: tabular-nums;
}
.solar-bar { width: 68px; height: 7px; border-radius: 999px; background: var(--surface-3); overflow: hidden; }
.solar-bar > span { display: block; height: 100%; background: linear-gradient(90deg, var(--blue-500), var(--green-500)); }

/* ------------------------------------------------------------------ Filters */
.filters { display: flex; gap: .6rem; flex-wrap: wrap; align-items: flex-end; }
.filters .field { min-width: 135px; }
.filters .field.grow { flex: 1 1 200px; }

.tabs { display: flex; gap: .35rem; flex-wrap: wrap; margin-bottom: .9rem; }
.tab {
  padding: .45rem .85rem; border-radius: 999px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text-soft); font-size: .84rem; font-weight: 600;
}
.tab.active { background: var(--primary); border-color: var(--primary); color: var(--primary-contrast); }
.tab:hover { text-decoration: none; }

/* ------------------------------------------------------------------ Flash */
.flash-stack { position: fixed; top: 74px; right: 18px; z-index: 60; display: flex; flex-direction: column; gap: .5rem; max-width: 380px; }
.flash {
  display: flex; gap: .55rem; align-items: flex-start; padding: .7rem .85rem; border-radius: 12px;
  background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow);
  font-size: .88rem; animation: slideIn .25s ease;
}
.flash.success { border-left: 4px solid var(--green-500); }
.flash.error { border-left: 4px solid var(--red-600); }
.flash.warning { border-left: 4px solid var(--amber-500); }
.flash.info { border-left: 4px solid var(--blue-600); }
.flash button { background: none; border: none; color: var(--muted); cursor: pointer; font-size: 1rem; line-height: 1; }
@keyframes slideIn { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: none; } }

/* ------------------------------------------------------------------ Charts */
.chart-host { width: 100%; }
.chart-host svg { width: 100%; height: auto; display: block; overflow: visible; }
.chart-legend { display: flex; gap: .9rem; flex-wrap: wrap; font-size: .8rem; color: var(--muted); margin-top: .55rem; }
.chart-legend span { display: inline-flex; align-items: center; gap: .35rem; }
.chart-legend i { width: 11px; height: 11px; border-radius: 3px; display: inline-block; }
.axis-label { font-size: 10px; fill: var(--muted); }
.grid-line { stroke: var(--border); stroke-width: 1; }
.sparkline { height: 46px; }

.bar-list { display: flex; flex-direction: column; gap: .55rem; }
.bar-row { display: grid; grid-template-columns: 120px 1fr auto; gap: .6rem; align-items: center; font-size: .85rem; }
.bar-track { height: 9px; background: var(--surface-3); border-radius: 999px; overflow: hidden; }
.bar-fill { height: 100%; border-radius: 999px; background: var(--gradient); }

.donut-wrap { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; }
.donut-center { font-weight: 700; }

/* ------------------------------------------------------------------ Misc */
.stack { display: flex; flex-direction: column; gap: .7rem; }
.row { display: flex; gap: .7rem; align-items: center; flex-wrap: wrap; }
.divider { height: 1px; background: var(--border); margin: 1rem 0; }
.note {
  background: var(--surface-2); border: 1px dashed var(--border-strong); border-radius: 12px;
  padding: .8rem .95rem; font-size: .85rem; color: var(--text-soft);
}
.note.info { border-left: 4px solid var(--blue-600); border-style: solid; }
.note.warn { border-left: 4px solid var(--amber-500); border-style: solid; }
.code {
  background: var(--surface-3); border: 1px solid var(--border); border-radius: 10px;
  padding: .7rem .85rem; font-size: .82rem; overflow-x: auto; white-space: pre-wrap; word-break: break-word;
}
dl.meta { margin: 0; display: grid; grid-template-columns: minmax(140px, 34%) 1fr; gap: .35rem .8rem; font-size: .88rem; }
dl.meta dt { color: var(--muted); font-weight: 600; }
dl.meta dd { margin: 0; }

.pagination { display: flex; gap: .35rem; align-items: center; justify-content: center; padding: .85rem; flex-wrap: wrap; }
.pagination a, .pagination span {
  min-width: 38px; min-height: 38px; display: grid; place-items: center; border-radius: 10px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text-soft); font-size: .85rem;
}
.pagination .current { background: var(--primary); border-color: var(--primary); color: var(--primary-contrast); font-weight: 700; }

.timeline { list-style: none; padding: 0; margin: 0; }
.timeline li { position: relative; padding: 0 0 .9rem 1.35rem; border-left: 2px solid var(--border); }
.timeline li:last-child { border-left-color: transparent; }
.timeline li::before {
  content: ""; position: absolute; left: -6px; top: .3rem; width: 10px; height: 10px;
  border-radius: 999px; background: var(--primary);
}
.timeline .when { font-size: .78rem; color: var(--muted); }

.login-page { display: grid; place-items: center; min-height: 100vh; padding: 1.5rem; }
.login-card { width: min(430px, 100%); background: var(--surface); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); border: 1px solid var(--border); overflow: hidden; }
.login-head { background: var(--gradient); color: #fff; padding: 1.6rem 1.5rem; }
.login-head h1 { font-size: 1.15rem; margin: 0 0 .2rem; color: #fff; }
.login-head p { margin: 0; font-size: .84rem; opacity: .9; }
.login-body { padding: 1.4rem 1.5rem 1.5rem; }

.about-hero { background: var(--gradient); color: #fff; border-radius: var(--radius); padding: 1.4rem 1.5rem; }
.about-hero h1, .about-hero h2 { color: #fff; }
.ver-badge { display: inline-flex; gap: .4rem; align-items: center; background: rgba(255,255,255,.18); border: 1px solid rgba(255,255,255,.3); padding: .2rem .6rem; border-radius: 999px; font-size: .8rem; font-weight: 700; }

.sidebar-toggle { display: none; }
.scrim { display: none; }

/* ------------------------------------------------------------------ Responsive */
@media (max-width: 1180px) {
  .grid.cols-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid.cols-2-1, .grid.cols-1-2 { grid-template-columns: 1fr; }
}

@media (max-width: 980px) {
  .grid.cols-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 860px) {
  .sidebar {
    position: fixed; inset: 0 auto 0 0; transform: translateX(-102%);
    transition: transform .22s ease; box-shadow: var(--shadow-lg);
  }
  body.nav-open .sidebar { transform: none; }
  body.nav-open .scrim { display: block; position: fixed; inset: 0; background: rgba(6, 24, 18, .5); z-index: 35; }
  .sidebar-toggle { display: grid; }
  .content { padding: 1rem .85rem 3rem; }
  .grid.cols-2, .grid.cols-3, .grid.cols-4 { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  .topbar { padding: 0 .7rem; }
  .flash-stack { left: .7rem; right: .7rem; max-width: none; top: 70px; }

  /* Tabellen werden zu Karten */
  table.data.responsive thead { display: none; }
  table.data.responsive, table.data.responsive tbody, table.data.responsive tr, table.data.responsive td { display: block; width: 100%; }
  table.data.responsive tr {
    border: 1px solid var(--border); border-radius: 12px; margin-bottom: .7rem;
    padding: .45rem .6rem; background: var(--surface-2);
  }
  table.data.responsive td {
    display: grid; grid-template-columns: 44% 1fr; gap: .5rem; align-items: center;
    border: none; padding: .35rem 0; text-align: right;
  }
  table.data.responsive td::before {
    content: attr(data-label); text-align: left; font-size: .74rem; text-transform: uppercase;
    letter-spacing: .06em; color: var(--muted); font-weight: 700;
  }
  table.data.responsive td.actions-cell { grid-template-columns: 1fr; justify-items: stretch; }
  table.data.responsive td.actions-cell::before { display: none; }
  table.data.responsive td.num { text-align: right; }
  .btn, .icon-btn, .nav-link, input, select { min-height: 44px; }
  .btn.sm { min-height: 40px; }
  dl.meta { grid-template-columns: 1fr; gap: .1rem; }
  dl.meta dt { margin-top: .5rem; }
}

@media print {
  .sidebar, .topbar, .flash-stack, .no-print { display: none !important; }
  body { background: #fff; }
  .content { padding: 0; max-width: none; }
  .card { box-shadow: none; border-color: #ccc; }
}

/* ---- Versionshistorie (Version & Info) ---- */
.release { border-left: 3px solid var(--border); padding: .1rem 0 .1rem .9rem; margin: 0 0 1.15rem; }
.release:last-of-type { margin-bottom: .8rem; }
.release.current { border-left-color: var(--green-600); }
.release-head { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }
.ver-badge-dark {
  display: inline-flex; align-items: center; gap: .35rem;
  background: var(--surface-2); border: 1px solid var(--border-strong);
  padding: .15rem .6rem; border-radius: 999px;
  font-size: .78rem; font-weight: 700; color: var(--text);
}
.release-title { margin: .45rem 0 .35rem; font-size: .98rem; }
.release-list { margin: 0; padding-left: 1.1rem; }
.release-list li { margin: .18rem 0; font-size: .88rem; color: var(--text-soft); }
.release-list code { font-size: .82rem; }
@media print { .release { break-inside: avoid; } }
/* ---------------------------------------------- v1.11: Markierspalte und Solarfokus */
.select-cell { width: 34px; text-align: center; }
.select-cell input[type="checkbox"] { cursor: pointer; margin: 0; }
.note .pill-solar { font-size: .95rem; }
.note .pill-solar strong { font-size: 1.05rem; }
@media (max-width: 720px) {
  .select-cell { width: auto; }
}
/* ------------------------------------------ v1.13: zwei Werte in einer Kachel */
.kpi-duo { display: flex; gap: .9rem; align-items: flex-start; margin-top: .35rem; }
.kpi-duo > div { flex: 1 1 0; min-width: 0; }
.kpi-duo .kpi-sub { margin: 0; }

/* ------------------------------------------ v1.13: Benutzerfilter «Einsparungen» */
.user-filter { border: 1px solid var(--border); border-radius: 10px; padding: .6rem .8rem; margin: 0; }
.user-filter legend { padding: 0 .35rem; font-weight: 600; font-size: .9rem; }
.user-filter-grid { display: flex; flex-wrap: wrap; gap: .35rem 1.1rem; }
.user-filter .check { display: flex; align-items: center; gap: .35rem; font-size: .92rem; }
.border-bottom { border-bottom: 1px solid var(--border); }

/* ------------------------------------------ v1.13: Profilbild */
.avatar img { width: 100%; height: 100%; object-fit: cover; border-radius: 999px; display: block; }
.avatar-lg { width: 72px; height: 72px; font-size: 1.6rem; }
.avatar-row { display: flex; flex-wrap: wrap; align-items: center; gap: 1rem; }

/* ------------------------------------------ v32: Profilbild ausrichten */
.avatar-editor { display: flex; flex-wrap: wrap; gap: 1rem; align-items: flex-start; }
.avatar-editor-canvas {
  position: relative; width: 220px; height: 220px; border-radius: 12px;
  overflow: hidden; background: var(--gradient); cursor: move;
  box-shadow: inset 0 0 0 1px var(--border); touch-action: none;
}
.avatar-editor-canvas canvas { width: 100%; height: 100%; display: block; }
.avatar-editor-controls {
  flex: 1 1 200px; display: flex; flex-direction: column; gap: .5rem; align-items: flex-start;
}
.avatar-editor-controls input[type="range"] { width: 100%; max-width: 260px; }
.avatar-row .filters { flex: 1 1 320px; margin: 0; }

/* ------------------------------------------ v1.15: «Wallbox Live» */
.live-head .card-body { padding-top: .4rem; }
.live-net { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: .9rem 1.2rem; }
.live-net-item { display: flex; flex-direction: column; gap: .15rem; }
.live-net-item strong { font-size: 1.25rem; font-variant-numeric: tabular-nums; }
.live-battery { display: block; height: 8px; border-radius: 999px; background: var(--surface-3); overflow: hidden; margin-top: .3rem; }
.live-battery > span { display: block; height: 100%; background: var(--green-500); transition: width .4s ease; }
.live-surplus strong { font-size: 1.05rem; }
.live-surplus[data-level="hoch"] strong { color: var(--green-700); }
.live-surplus[data-level="mittel"] strong { color: var(--amber-500); }
.live-surplus[data-level="niedrig"] strong { color: var(--muted); }

.live-gauge-row { display: flex; align-items: center; gap: 1.2rem; flex-wrap: wrap; }
.live-gauge { position: relative; width: 170px; }
.live-gauge-svg { width: 100%; display: block; }
.live-gauge .gauge-track { stroke: var(--surface-3); }
.live-gauge .gauge-value { stroke: var(--muted); transition: stroke-dashoffset .5s ease, stroke .3s ease; stroke-linecap: round; }
.live-gauge-text { text-align: center; margin-top: -.6rem; }
.live-gauge-text strong { font-size: 1.6rem; font-variant-numeric: tabular-nums; display: block; }
.live-box-facts { display: flex; gap: 1.3rem; flex-wrap: wrap; }
.live-box-facts > div { display: flex; flex-direction: column; }
.live-box-facts strong { font-size: 1.15rem; font-variant-numeric: tabular-nums; }
.live-facts { width: 100%; border-collapse: collapse; font-size: .88rem; margin-top: .8rem; }
.live-facts th { text-align: left; font-weight: 500; color: var(--muted); padding: .28rem .6rem .28rem 0; white-space: nowrap; }
.live-facts td { padding: .28rem 0; }
.live-status[data-status="charging"] { background: var(--green-100); color: var(--green-700); }
.live-status[data-status="connected"], .live-status[data-status="ready_to_charge"] { background: var(--blue-100); color: var(--blue-700); }
.live-status[data-status="error"], .live-status[data-status="unavailable"] { background: var(--red-100); color: var(--red-600); }
.inline-form { display: inline-flex; align-items: center; gap: .4rem; margin: 0; }

/* ------------------------------- v1.15: Ladestrom-Balken, Agenda, Zuordnung */
.live-feedbar { display: block; height: 10px; border-radius: 999px; background: var(--surface-3);
  overflow: hidden; margin: .35rem 0 .2rem; position: relative; }
.live-feedbar-fill { display: block; height: 100%; width: 0; background: var(--muted);
  transition: width .4s ease, background .3s ease; }
/* Verfügbarer Strom zum Laden: 100 % = 11 kW (3-phasig, 16 A) */
.live-feedbar[data-level="kein"] .live-feedbar-fill { background: var(--red-500, #c62828); }
.live-feedbar[data-level="einphasig"] .live-feedbar-fill { background: var(--amber-500); }
.live-feedbar[data-level="dreiphasig"] .live-feedbar-fill { background: #7cb342; }
.live-feedbar[data-level="voll"] .live-feedbar-fill { background: var(--green-600, #1b8a3a); }
.live-feedbar[data-level="unbekannt"] .live-feedbar-fill { background: var(--muted); }

.live-mode-form { flex-wrap: wrap; margin-top: .35rem; }
.live-assign-form { flex-wrap: wrap; }
.live-assign-form select { max-width: 12rem; }

/* Diagramm-Agenda: Gitterlinien, Legende und Mauszeiger-Ablesung */
.grid-line-v { stroke: var(--border, #e3e7ee); stroke-width: 1; opacity: .5; }
.chart-guide { stroke: var(--blue-500, #1a76c4); stroke-width: 1.4; stroke-dasharray: 4 3; }
.chart-tip-bg { fill: rgba(23, 32, 48, .92); }
.chart-tip-text { fill: #fff; font-size: 11.5px; font-variant-numeric: tabular-nums; }
.chart-capture { cursor: crosshair; }
.chart-legend { display: flex; flex-wrap: wrap; gap: .5rem 1rem; margin: 0 0 .5rem .2rem; font-size: .82rem; color: var(--muted); }
.chart-legend-item { display: inline-flex; align-items: center; gap: .35rem; }
.chart-legend-swatch { display: inline-block; width: 12px; height: 12px; border-radius: 3px; }
/* ============================================================ v1.16
   (1) Kopfleiste: die Benutzeranzeige oben rechts darf auf schmalen
       Bildschirmen nicht mehr überstehen (iPhone 15 Max u. a.). */
.grow { flex: 1 1 auto; min-width: 0; }
.topbar h1 { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar .crumb { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-chip { max-width: 100%; }
.user-menu-panel { max-width: calc(100vw - 1.4rem); }

@media (max-width: 860px) {
  .topbar { gap: .45rem; }
  /* Name und Rolle wandern ins Kontomenü — in der Leiste bleibt der Avatar. */
  .user-chip .nowrap { display: none; }
  .user-chip { padding: .3rem .45rem .3rem .35rem; }
}

@media (max-width: 560px) {
  .topbar { padding: 0 .55rem; }
  .topbar .crumb { display: none; }
  .user-menu-panel { min-width: 0; width: min(300px, calc(100vw - 1.2rem)); }
}

/* (2) «Wallbox Live»: die beiden Wallboxen sind auf dem Smartphone ein
       Wisch-Karussell — Wallbox 1, nach links wischen → Wallbox 2. */
.live-swipe-hint { display: none; }
@media (max-width: 860px) {
  /* Gleichstand mit «.grid.cols-2» (später im Stylesheet) → Karussell gewinnt. */
  .grid.live-boxes {
    display: flex; flex-wrap: nowrap; gap: .8rem;
    overflow-x: auto; overflow-y: hidden;
    scroll-snap-type: x mandatory; -webkit-overflow-scrolling: touch;
    scrollbar-width: none; padding-bottom: .35rem;
  }
  .grid.live-boxes::-webkit-scrollbar { display: none; }
  .grid.live-boxes > .live-box {
    flex: 0 0 92%; min-width: 0; scroll-snap-align: center;
  }
  .live-swipe-hint {
    display: block; flex: 0 0 100%; scroll-snap-align: start; margin: 0 0 .1rem;
  }
}

/* (7) Abrechnungsabgleich: nach «Ladung übernehmen» bleibt die Seite an der
       bearbeiteten Zeile stehen (Sprungmarke berücksichtigt die Kopfleiste). */
[id^="row-"] { scroll-margin-top: calc(var(--topbar-height) + 14px); }
.report-row-target { outline: 2px solid var(--green-500, #2e9e5b); outline-offset: 2px; }

/* (8) v25: Prüffälle — zeitliche Überlappung farbig markieren (ganze Zeile).
       Bewusst kräftig, damit die Zeile auch in langen Listen sofort auffällt. */
.row-overlap > td { background: #fff6d6; }
[data-theme="dark"] .row-overlap > td { background: rgba(214, 168, 24, .18); }
.row-overlap:hover > td { background: #ffefb8; }
[data-theme="dark"] .row-overlap:hover > td { background: rgba(214, 168, 24, .26); }
.row-overlap > td:first-child { box-shadow: inset 3px 0 0 0 #d6a818; }
.row-overlap-sample {
  background: #fff6d6; border: 1px solid #e6cf85; border-radius: 4px;
  padding: 0 .3rem; white-space: nowrap;
}
[data-theme="dark"] .row-overlap-sample {
  background: rgba(214, 168, 24, .18); border-color: rgba(214, 168, 24, .45);
}
.warn-text { color: #a55b00; font-weight: 600; }
.nav-badge { margin-left: auto; }

/* ---- (9) v27: öffentliche Seiten (Impressum, Rechte, Datenschutz, Nutzung, Kontakt) ----
       Eigener Seitenaufbau auf allen Geräten: Kopfzeile, Verweisliste, Inhalt in voller Breite,
       Fusszeile. Vorher stand der Inhalt in der schmalen Anmeldekarte — auf grossen Bildschirmen
       wirkte das wie eine Handy-Ansicht, und lange Angaben (Adressen, E-Mails) liefen aus der
       Karte heraus. */
.public-shell {
  min-height: 100vh; display: flex; flex-direction: column; color: var(--text);
}
.public-topbar {
  display: flex; align-items: center; gap: .8rem; flex-wrap: wrap;
  padding: .75rem 1.2rem; background: var(--surface); border-bottom: 1px solid var(--border);
}
.public-brand { display: flex; align-items: center; gap: .6rem; min-width: 0; color: inherit; text-decoration: none; }
.public-brand:hover .public-brand-text strong { color: var(--green-600, #0e7a4f); }
.public-brand-text { display: flex; flex-direction: column; min-width: 0; }
.public-brand-text strong { font-size: .98rem; line-height: 1.2; }
.public-topbar-actions { margin-left: auto; display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }
.public-nav {
  display: flex; flex-wrap: wrap; gap: .35rem; padding: .55rem 1.2rem;
  background: var(--surface-2); border-bottom: 1px solid var(--border);
}
.public-nav-link {
  padding: .34rem .7rem; border-radius: 999px; border: 1px solid transparent;
  color: var(--text-soft); text-decoration: none; font-size: .85rem; white-space: nowrap;
}
.public-nav-link:hover { background: var(--surface); color: var(--text); }
.public-nav-link.active {
  background: var(--surface); border-color: var(--border); color: var(--text); font-weight: 700;
}
.public-content {
  flex: 1 1 auto; width: 100%; max-width: 1120px; margin: 0 auto;
  padding: 1.3rem 1.2rem 2.2rem; min-width: 0;
}
.public-content > .card:last-of-type { margin-bottom: 0; }
.public-content a { overflow-wrap: anywhere; }
.public-content dl.meta dd { overflow-wrap: anywhere; }
.public-foot {
  display: flex; flex-wrap: wrap; gap: .35rem .8rem; align-items: center;
  padding: .9rem 1.2rem 1.5rem; border-top: 1px solid var(--border);
  font-size: .8rem; color: var(--muted);
}
.public-foot a { color: inherit; }
@media (max-width: 700px) {
  .public-topbar, .public-nav, .public-content, .public-foot { padding-left: .85rem; padding-right: .85rem; }
  .public-nav-link { font-size: .8rem; padding: .3rem .55rem; }
  .public-content .card { padding: .85rem .8rem; }
}
/* Einstellungen (v27): jeder Bereich ist über seine Karte verlinkt (Sprungmarke). */
[id^="card-"] { scroll-margin-top: calc(var(--topbar-height) + 14px); }
