/* Farben: Hell ist Standard (Weiß- und Grauabstufungen); Dunkel per Umschalter in der Seitenleiste
   (public/theme.js setzt data-theme auf <html>, ohne gespeicherte Wahl nach der Systemeinstellung). */
:root {
  --bg: #f4f6f9;
  --surface: #ffffff;
  --surface-2: #f9fafb;
  --surface-3: #f1f3f6;
  --border: #e4e7ec;
  --border-strong: #d0d5dd;
  --text: #1d2939;
  --muted: #667085;
  --accent: #0e9f6e;
  --accent-text: #ffffff;
  --danger: #dc2626;
  --warn: #d97706;
  --info: #2563eb;
  --sidebar: #ffffff;
  --sidebar-text: #475467;
  --sidebar-border: #eaecf0;
  --sidebar-hover: #f2f4f7;
  --sidebar-active: color-mix(in srgb, var(--accent) 11%, #ffffff);
  --sidebar-active-text: #08744f;
  --brand-bg: transparent;
  --inverse: #1d2939;
  --inverse-text: #ffffff;
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, .05);
  /* Diagramme: validierte Palette (AC/DC kategorial, Jahresvergleich ordinal, Heatmap sequenziell) */
  --series-ac: #2a78d6;
  --series-dc: #eb6834;
  --year-current: #2a78d6;
  --year-previous: #86b6ef;
  --seq-0: #eef3f9;
  --seq-1: #cde2fb;
  --seq-2: #9ec5f4;
  --seq-3: #6da7ec;
  --seq-4: #3987e5;
  --seq-5: #256abf;
  --seq-6: #104281;
  --seq-ink-light: #0d2a4d;
  --seq-ink-dark: #ffffff;
  --good: #15803d;
  --bad: #c2410c;
  color-scheme: light;
}
:root[data-theme="dark"] {
  --bg: #0b1120;
  --surface: #131c2e;
  --surface-2: #172135;
  --surface-3: #1c283e;
  --border: #263247;
  --border-strong: #34425c;
  --text: #e2e8f0;
  --muted: #94a3b8;
  --sidebar: #070b14;
  --sidebar-text: #cbd5e1;
  --sidebar-border: #070b14;
  --sidebar-hover: rgba(255, 255, 255, .06);
  --sidebar-active: rgba(255, 255, 255, .1);
  --sidebar-active-text: #ffffff;
  /* Logo auf weißer Fläche – der Schriftzug ist für hellen Hintergrund gestaltet */
  --brand-bg: #ffffff;
  --inverse: #e2e8f0;
  --inverse-text: #0b1120;
  --shadow-sm: none;
  --series-ac: #3987e5;
  --series-dc: #d95926;
  --year-current: #6da7ec;
  --year-previous: #1c5cab;
  --seq-0: #1a2538;
  --seq-1: #16335e;
  --seq-2: #184f95;
  --seq-3: #256abf;
  --seq-4: #3987e5;
  --seq-5: #6da7ec;
  --seq-6: #b7d3f6;
  --seq-ink-light: #e2e8f0;
  --seq-ink-dark: #0b1120;
  --good: #4ade80;
  --bad: #fb923c;
  color-scheme: dark;
}

* { box-sizing: border-box; }
body { margin: 0; font: 14px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; background: var(--bg); color: var(--text); }
h1 { font-size: 22px; margin: 0 0 16px; }
h2 { font-size: 16px; margin: 24px 0 12px; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.error { color: var(--danger); min-height: 1.5em; }
a { color: var(--accent); }
code, .mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; }

.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-card { width: 100%; max-width: 360px; display: flex; flex-direction: column; gap: 12px; }

.shell { display: grid; grid-template-columns: 220px 1fr; min-height: 100vh; }
.sidebar { background: var(--sidebar); color: var(--sidebar-text); padding: 20px 12px; display: flex; flex-direction: column; gap: 4px; border-right: 1px solid var(--sidebar-border);
  position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.brand { display: block; margin: 0 0 16px; padding: 8px 10px; background: var(--brand-bg); border-radius: 10px; }
.brand img { display: block; width: 100%; height: auto; }
.login-brand { margin: 0 0 4px; }
.login-brand img { display: block; width: 100%; height: auto; }
#nav a { display: block; padding: 8px 12px; border-radius: 8px; color: var(--sidebar-text); text-decoration: none; font-weight: 500; }
#nav a:hover { background: var(--sidebar-hover); color: var(--text); }
#nav a.active { background: var(--sidebar-active); color: var(--sidebar-active-text); font-weight: 600; }
.sidebar-foot { margin-top: auto; padding: 8px; display: flex; flex-direction: column; gap: 4px; font-size: 12px; }
.content { padding: 24px; overflow-x: auto; min-width: 0; }

@media (max-width: 760px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; padding: 12px 16px; border-right: 0; border-bottom: 1px solid var(--sidebar-border); }
  .brand { margin: 0 12px 0 0; padding: 4px 8px; width: 150px; }
  #nav { display: flex; flex-wrap: wrap; gap: 2px; }
  .sidebar-foot { margin: 0 0 0 auto; flex-direction: row; }
  .content { padding: 16px; }
}

.card { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 16px; box-shadow: var(--shadow-sm); }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; }
.stat .label { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .04em; }
.stat .value { font-size: 24px; font-weight: 650; margin-top: 4px; }

.toolbar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 12px; }
.toolbar .spacer { flex: 1; }

table { width: 100%; border-collapse: collapse; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; overflow: hidden; }
th, td { text-align: left; padding: 8px 12px; border-bottom: 1px solid var(--border); vertical-align: top; }
th { font-size: 12px; color: var(--muted); font-weight: 600; background: var(--surface-2); }
tr:last-child td { border-bottom: 0; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
tr.clickable { cursor: pointer; }
/* Unterzeile, z. B. geplante Preisänderung eines Tarifs */
tr.sub-row td { background: color-mix(in srgb, var(--surface) 92%, var(--info)); font-size: 13px; }
tr.clickable:hover td { background: color-mix(in srgb, var(--surface) 94%, var(--accent)); }
.table-wrap { overflow-x: auto; }

.badge { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 12px; font-weight: 600; background: var(--border); color: var(--text); white-space: nowrap; }
.badge.ok { background: color-mix(in srgb, var(--accent) 18%, transparent); color: var(--accent); }
.badge.warn { background: color-mix(in srgb, var(--warn) 18%, transparent); color: var(--warn); }
.warn-text { color: var(--warn); }
.badge.err { background: color-mix(in srgb, var(--danger) 18%, transparent); color: var(--danger); }
.badge.info { background: color-mix(in srgb, var(--info) 18%, transparent); color: var(--info); }

a.btn { text-decoration: none; display: inline-block; }
button, .btn { font: inherit; padding: 6px 12px; border-radius: 6px; border: 1px solid var(--border); background: var(--surface); color: var(--text); cursor: pointer; }
button:hover { border-color: var(--muted); }
button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
button.danger { color: var(--danger); }
button.link { border: 0; background: none; color: inherit; padding: 0; text-align: left; text-decoration: underline; }
button:disabled { opacity: .5; cursor: default; }

label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); }
input, select, textarea { font: inherit; padding: 7px 10px; border-radius: 6px; border: 1px solid var(--border-strong); background: var(--surface); color: var(--text); }
.form { display: grid; gap: 12px; }
.form-row { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 12px; }
label > input, label > select { min-width: 0; }
.form-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 8px; }
.check { flex-direction: row; align-items: center; gap: 8px; }

dialog { border: 1px solid var(--border); border-radius: 12px; background: var(--surface); color: var(--text); padding: 20px; width: min(560px, calc(100vw - 32px)); }
dialog::backdrop { background: rgba(0,0,0,.45); }

.toast { position: fixed; bottom: 20px; right: 20px; background: var(--inverse); color: var(--inverse-text); padding: 10px 16px; border-radius: 8px; max-width: min(420px, calc(100vw - 40px)); box-shadow: 0 6px 20px rgba(0,0,0,.25); z-index: 10; }
.toast.err { background: var(--danger); color: #fff; }

.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 16px; }
dl.kv { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; margin: 0; }
dl.kv dt { color: var(--muted); }
dl.kv dd { margin: 0; overflow-wrap: anywhere; }
.connectors { display: flex; gap: 6px; flex-wrap: wrap; }
.log { max-height: 420px; overflow: auto; }
.log td { font-family: ui-monospace, monospace; font-size: 12px; }
.secret { padding: 12px; background: var(--bg); border: 1px dashed var(--warn); border-radius: 8px; font-family: ui-monospace, monospace; word-break: break-all; }
svg.chart { width: 100%; height: 160px; }

@media print {
  .sidebar, .no-print { display: none !important; }
  .shell { display: block; }
  .card, table { border: 0; }
}

/* ---------------------------------------------------------------- Insights & Berichte */
.badge.ac { background: color-mix(in srgb, var(--series-ac) 16%, transparent); color: var(--series-ac); }
.badge.dc { background: color-mix(in srgb, var(--series-dc) 16%, transparent); color: var(--series-dc); }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.small { font-size: 12px; }
button.small { padding: 4px 8px; }
.evse-table td, .evse-table th { padding: 6px 8px; }
/* Rechnung im Design der Vorlage (serverseitig gerendert, eingebettet) */
.invoice-frame { display: block; width: 100%; max-width: 860px; height: 1200px; border: 0; border-radius: 8px; background: #e9eef2; }

.ins-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 16px; margin-bottom: 12px; }
.ins-head h1 { margin: 0; }
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); margin-bottom: 16px; overflow-x: auto; }
.tabs button { border: 0; border-radius: 0; background: none; padding: 10px 14px; color: var(--muted); font-weight: 550; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.tabs button:hover { color: var(--text); border-color: var(--border); }
.tabs button.active { color: var(--info); border-bottom-color: var(--info); }

.filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 8px; }
.pill select { appearance: none; -webkit-appearance: none; border-radius: 999px; padding: 7px 34px 7px 14px; font-weight: 550;
  background: var(--inverse) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='M1 1l5 5 5-5' fill='none' stroke='%23cbd5e1' stroke-width='1.6'/%3E%3C/svg%3E") no-repeat right 14px center;
  color: var(--inverse-text); border-color: var(--inverse); max-width: 260px; }
.pill-check { color: var(--text); font-size: 13px; }
.custom-range { display: inline-flex; align-items: center; gap: 6px; }
.inline-select { border: 0; background: transparent; font-weight: 600; color: var(--text); padding: 2px 4px; border-radius: 4px; }
.inline-select:hover { background: var(--bg); }

.ins-body h2 { margin-top: 28px; }
.ins-body > h2:first-child { margin-top: 8px; }
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; }
.kpi-grid.small { margin-top: 12px; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); }
.kpi { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 16px 18px; display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.kpi-label { color: var(--muted); font-size: 13px; font-weight: 550; display: flex; align-items: center; gap: 6px; }
.kpi-value { font-size: 30px; font-weight: 700; line-height: 1.15; font-variant-numeric: tabular-nums; letter-spacing: -0.01em; overflow-wrap: anywhere; }
.kpi-value small { font-size: 15px; font-weight: 600; color: var(--muted); margin-left: 4px; }
.kpi-grid.small .kpi { padding: 12px 14px; }
.kpi-grid.small .kpi-value { font-size: 20px; }
.delta { font-size: 12px; font-weight: 600; }
.delta.good { color: var(--good); }
.delta.bad { color: var(--bad); }

.ins-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 380px), 1fr)); gap: 12px; }
.ins-card { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 14px 18px 16px; min-width: 0; display: flex; flex-direction: column; gap: 10px; }
.ins-card.wide { grid-column: 1 / -1; }
.ins-card > header { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; min-height: 28px; }
.ins-card h3 { font-size: 14px; font-weight: 600; margin: 0; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.ins-card header .spacer { flex: 1; }
.info:not(.badge) { display: inline-grid; place-items: center; width: 18px; height: 18px; border-radius: 50%; background: var(--bg); border: 1px solid var(--border); color: var(--muted); font: italic 600 11px/1 Georgia, serif; cursor: help; }
.icon-btn { border: 0; background: none; padding: 4px; color: var(--muted); border-radius: 6px; display: inline-grid; place-items: center; }
.icon-btn:hover { color: var(--text); background: var(--bg); }

.chart { position: relative; width: 100%; min-width: 0; }
.chart svg { display: block; overflow: visible; }
.chart .axis text { font-size: 11px; fill: var(--muted); font-variant-numeric: tabular-nums; }
.chart .grid { stroke: var(--border); stroke-width: 1; }
.chart .baseline { stroke: color-mix(in srgb, var(--muted) 45%, transparent); stroke-width: 1; }
.chart .marker { stroke: var(--surface); stroke-width: 2; }
.chart .crosshair { stroke: var(--muted); stroke-width: 1; }
.chart .hover-band { fill: color-mix(in srgb, var(--text) 6%, transparent); }
.chart-tip { position: absolute; z-index: 5; pointer-events: none; background: var(--surface); color: var(--text); border: 1px solid var(--border);
  border-radius: 8px; padding: 8px 10px; font-size: 12px; box-shadow: 0 6px 18px rgba(15, 23, 42, .14); min-width: 150px; }
.chart-tip strong { display: block; margin-bottom: 4px; }
.chart-tip div { display: flex; align-items: center; gap: 6px; }
.chart-tip b { margin-left: auto; padding-left: 12px; font-variant-numeric: tabular-nums; }
.chart-tip .tip-total { border-top: 1px solid var(--border); margin-top: 4px; padding-top: 4px; }
.sw { display: inline-block; width: 10px; height: 10px; border-radius: 50%; flex: none; }
.chart-legend { display: flex; flex-wrap: wrap; gap: 4px 16px; font-size: 12px; color: var(--muted); }
.chart-legend span { display: inline-flex; align-items: center; gap: 6px; }

.split { display: flex; gap: 2px; height: 34px; border-radius: 6px; overflow: hidden; }
.split-seg { display: grid; place-items: center; min-width: 4px; }
.split-seg span { font-size: 12px; font-weight: 700; color: #fff; font-variant-numeric: tabular-nums; }
.type-figures { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.type-figures strong { display: block; font-size: 28px; line-height: 1.15; font-variant-numeric: tabular-nums; }
.type-figures span { color: var(--muted); font-size: 13px; }

.rank { display: grid; gap: 10px; }
.rank-row { display: grid; grid-template-columns: minmax(0, 2fr) minmax(80px, 3fr) auto; gap: 12px; align-items: center; }
.rank-label { min-width: 0; overflow-wrap: anywhere; font-size: 13px; }
.rank-label .muted { font-size: 12px; display: block; }
.chart-tip em { color: var(--muted); font-style: normal; margin-left: 4px; }
.rank-bar { height: 10px; background: var(--seq-0); border-radius: 0 4px 4px 0; }
.rank-bar span { display: block; height: 100%; background: var(--series-ac); border-radius: 0 4px 4px 0; }
.rank-value { font-variant-numeric: tabular-nums; font-weight: 600; font-size: 13px; white-space: nowrap; }
@media (max-width: 560px) { .rank-row { grid-template-columns: 1fr auto; } .rank-bar { grid-column: 1 / -1; grid-row: 2; } }

.scale { display: flex; align-items: center; gap: 2px; font-size: 11px; color: var(--muted); justify-content: flex-end; }
.scale span { margin: 0 6px; }
.scale i { width: 22px; height: 10px; border-radius: 2px; display: inline-block; }

.bd-table th, .bd-table td { white-space: nowrap; }
.bd-table td:first-child { white-space: normal; min-width: 180px; font-weight: 550; }
.heat { display: inline-block; min-width: 44px; padding: 2px 9px; border-radius: 999px; font-variant-numeric: tabular-nums; font-size: 12px; font-weight: 600; text-align: center; }
.heat.lvl-0 { background: transparent; color: var(--muted); }
.heat.lvl-1 { background: var(--seq-1); color: var(--seq-ink-light); }
.heat.lvl-2 { background: var(--seq-2); color: var(--seq-ink-light); }
.heat.lvl-3 { background: var(--seq-3); color: var(--seq-ink-light); }
.heat.lvl-4 { background: var(--seq-4); color: var(--seq-ink-dark); }
.heat.lvl-5 { background: var(--seq-5); color: var(--seq-ink-dark); }
.heat.lvl-6 { background: var(--seq-6); color: var(--seq-ink-dark); }

.report { margin-top: 20px; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 20px 24px; display: grid; gap: 16px; }
.report-head { display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap; border-bottom: 2px solid var(--text); padding-bottom: 12px; }
.report-head h2 { margin: 2px 0 0; font-size: 22px; }
.report-head > div:last-child { text-align: right; font-size: 13px; }
.report h3 { margin: 4px 0 0; font-size: 15px; }
.report-table { border: 0; }
.report-table th, .report-table td { padding: 6px 8px; }
.ins-foot { margin-top: 24px; }

@media print {
  body.print-report .content > *:not(.ins-body), body.print-report .ins-body > *:not(.report), body.print-report .demo-bar { display: none !important; }
  body.print-report .report { border: 0; padding: 0; }
  .chart-tip { display: none !important; }
}
@media (max-width: 760px) {
  .kpi-value { font-size: 24px; }
  .pill select { max-width: 100%; }
  .type-figures { grid-template-columns: 1fr; }
}

/* ---------------------------------------------------------------- Roaming */
.issues { margin: 0; padding-left: 18px; color: var(--warn); font-size: 13px; }
.steps { margin: 0; padding-left: 20px; display: grid; gap: 8px; }
.steps li { line-height: 1.45; }
.actions-cell { display: flex; flex-wrap: wrap; gap: 4px; justify-content: flex-end; }
.secret-box { margin-bottom: 16px; display: grid; gap: 8px; border-color: var(--warn); }
.fieldset { border: 1px solid var(--border); border-radius: 8px; padding: 10px 14px 12px; display: grid; gap: 10px; margin: 0; min-inline-size: 0; }
.fieldset legend { padding: 0 6px; font-size: 13px; color: var(--muted); font-weight: 600; }
.check-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 6px 12px; }
.form-row.street-row { grid-template-columns: minmax(0, 3fr) minmax(0, 1fr); }

/* Zeitfenster im Tarifformular */
.period-row { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)) auto; gap: 8px; align-items: end; padding: 8px 0; border-top: 1px dashed var(--border); }
.period-row input { min-width: 0; }
.period-row .days { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 4px 12px; }
.period-row .days .check { font-size: 13px; gap: 4px; }
@media (max-width: 560px) { .period-row { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); } .period-row [data-period-remove] { grid-column: 1 / -1; } }

/* Aktionen-Menü einer Station */
.menu { position: relative; display: inline-block; }
.menu-list { position: absolute; right: 0; top: calc(100% + 4px); z-index: 20; min-width: 240px; display: flex; flex-direction: column;
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 6px; box-shadow: 0 8px 24px rgba(0,0,0,.18); }
.menu-list button { border: 0; background: none; text-align: left; padding: 8px 10px; border-radius: 6px; }
.menu-list button:hover { background: color-mix(in srgb, var(--text) 8%, transparent); }
.menu-list hr { border: 0; border-top: 1px solid var(--border); margin: 4px 0; width: 100%; }
.danger-text { color: var(--danger); }
dialog.wide { width: min(1100px, calc(100vw - 32px)); max-height: calc(100vh - 48px); }
dialog h3 { font-size: 14px; margin: 20px 0 8px; }
dialog .table-wrap { max-height: 50vh; overflow: auto; }
.config-table { max-height: 60vh; }
.inline-edit { display: flex; gap: 6px; align-items: center; margin: 0; }
.inline-edit input { flex: 1; min-width: 120px; }
.timeline { margin: 4px 0 0; padding-left: 18px; font-size: 12px; }
h3 { font-size: 14px; margin: 18px 0 8px; }

/* ---------------------------------------------------------------- Standorte (Formular mit Karte) */
.site-form .fieldset { gap: 10px; grid-template-columns: minmax(0, 1fr); }
.site-search { display: flex; gap: 8px; }
.site-search input { flex: 1; min-width: 0; }
.site-results ul { margin: 0; padding-left: 18px; display: grid; gap: 4px; font-size: 13px; }
.site-results button.link { color: var(--accent); text-decoration: none; }
.site-results button.link:hover { text-decoration: underline; }
.site-map { height: 320px; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; background: var(--bg); display: grid; place-items: center; }
.site-map.leaflet-container { display: block; }
.site-suggest { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; padding: 8px 10px; border: 1px dashed var(--info); border-radius: 8px; font-size: 13px; }
.site-photo { display: grid; grid-template-columns: 160px minmax(0, 1fr); gap: 12px; align-items: start; }
.site-photo-preview { width: 160px; height: 110px; border: 1px solid var(--border); border-radius: 8px; display: grid; place-items: center; overflow: hidden; background: var(--bg); }
.site-photo-preview img { width: 100%; height: 100%; object-fit: cover; }
.form-row.site-pick { grid-template-columns: minmax(0, 1fr) auto; align-items: end; }
@media (max-width: 560px) {
  .site-photo { grid-template-columns: 1fr; }
  .form-row.site-pick, .site-form .form-row, .site-form .form-row.street-row { grid-template-columns: minmax(0, 1fr); }
}

/* ---------------------------------------------------------------- Stationsliste nach Standort */
.station-filters .search { display: flex; gap: 6px; flex: 1 1 280px; max-width: 420px; }
.station-filters .search input { flex: 1; min-width: 0; }
.station-filters select { max-width: 200px; }
.site-group { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; margin: 0 0 16px; }
.site-group.unassigned { border-color: color-mix(in srgb, var(--warn) 55%, var(--border)); }
.site-head { padding: 12px 16px 8px; border-bottom: 1px solid var(--border); }
.site-head p { margin: 2px 0 0; }
.site-title { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; }
.site-title h2 { margin: 0 4px 0 0; font-size: 16px; }
.site-title .spacer { flex: 1; }
.station-block + .station-block { border-top: 1px solid var(--border); }
.station-head { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; padding: 8px 16px; background: var(--surface-3); font-size: 13px; }
.station-head .spacer { flex: 1; }
.station-head a { color: inherit; text-decoration: none; }
.station-head a:hover { text-decoration: underline; }
.evse-row { display: grid; grid-template-columns: 28px minmax(150px, 190px) minmax(140px, 180px) minmax(0, 1fr) minmax(150px, auto) minmax(120px, auto);
  gap: 8px 12px; align-items: center; padding: 8px 16px; border-top: 1px solid var(--border); }
.evse-row.open { background: color-mix(in srgb, var(--surface) 94%, var(--accent)); }
.evse-id { font-size: 15px; font-weight: 650; overflow-wrap: anywhere; }
.evse-tech { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 6px; font-size: 13px; }
.plug-icon { color: var(--muted); flex: none; }
.evse-name { min-width: 0; overflow-wrap: anywhere; }
.evse-name .icon-btn { font-size: 13px; padding: 2px 4px; }
.evse-op { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; }
.evse-live { text-align: right; }
.evse-empty { margin: 0; padding: 10px 16px; }
.evse-details { padding: 8px 16px 12px 56px; display: grid; gap: 10px; justify-items: start; border-top: 1px dashed var(--border); }
.evse-details dl.kv { font-size: 13px; }
.op-btn { display: inline-flex; align-items: center; gap: 6px; border-radius: 999px; padding: 3px 10px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.op-btn.op-ok { color: var(--accent); border-color: color-mix(in srgb, var(--accent) 45%, var(--border)); }
.op-btn.op-warn { color: var(--warn); border-color: color-mix(in srgb, var(--warn) 45%, var(--border)); }
.op-btn.op-err { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 45%, var(--border)); }
.op-btn.op-mixed { color: var(--info); border-color: color-mix(in srgb, var(--info) 45%, var(--border)); }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: currentColor; flex: none; }
.dot.ok { color: var(--accent); } .dot.warn { color: var(--warn); } .dot.err { color: var(--danger); }
.op-menu .menu-list { min-width: 260px; }
.menu-list button { display: flex; align-items: center; gap: 8px; }
.menu-list button.current { font-weight: 650; }
.menu-note { margin: 2px 8px 4px; max-width: 260px; }
@media (max-width: 900px) {
  .evse-row { grid-template-columns: 28px minmax(0, 1fr) auto; }
  .evse-row .evse-tech, .evse-row .evse-name { grid-column: 2 / -1; }
  .evse-row .evse-op { grid-column: 2; }
  .evse-live { text-align: left; }
  .evse-details { padding-left: 16px; }
  .evse-op .op-menu .menu-list { right: auto; left: 0; }
}

/* Sperre der Einstellungen: Hinweisbalken „Eingefroren“ bzw. „Entsperrt“ mit Restzeit; eingefrorene Felder */
.lock-bar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; max-width: 720px; box-sizing: border-box; padding: 10px 14px; margin-bottom: 16px; border-radius: 8px; border: 1px solid var(--border); background: var(--surface); }
.lock-bar.frozen { border-color: color-mix(in srgb, var(--info) 45%, var(--border)); background: color-mix(in srgb, var(--info) 8%, var(--surface)); }
.lock-bar.unlocked { border-color: color-mix(in srgb, var(--warn) 55%, var(--border)); background: color-mix(in srgb, var(--warn) 10%, var(--surface)); }
.lock-bar .spacer { flex: 1; }
.lock-icon { vertical-align: -2px; flex: none; }
.frozen-fieldset { border: 0; padding: 0; margin: 0; min-inline-size: 0; }
.frozen-fieldset:disabled input, .frozen-fieldset:disabled select, .frozen-fieldset:disabled textarea { opacity: .75; cursor: not-allowed; }
/* Standortpartner: eingefrorene Knöpfe in Zeilen und Werkzeugleisten ohne eigenen Block, Auswahllisten, Mehrfachauswahl */
.actions-cell .frozen-fieldset, .toolbar .frozen-fieldset { display: contents; }
.check-list { display: grid; gap: 4px; max-height: 280px; overflow: auto; padding: 4px 0; }
th.site-select, td.site-select { width: 28px; }
.bulk-bar { gap: 10px; margin: 8px 0; }

/* ---------------------------------------------------------------- Bedienelemente (public/ui.js) */
.ico { flex: none; vertical-align: -4px; }
/* Eigene Auswahlliste statt des Systemmenüs: Knopf wie ein Eingabefeld, Liste als Karte mit Schatten */
.dd { position: relative; display: inline-flex; min-width: 0; }
label > .dd, .form .dd { display: flex; }
.dd-btn { display: flex; align-items: center; gap: 8px; width: 100%; min-width: 0; padding: 7px 10px; border-radius: 8px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text); text-align: left; font: inherit;
  transition: border-color .12s, box-shadow .12s; }
.dd-btn:hover:not(:disabled) { border-color: color-mix(in srgb, var(--text) 30%, var(--border)); }
.dd-btn:focus-visible, .dd.open .dd-btn { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent); }
.dd-btn.placeholder .dd-label { color: var(--muted); }
.dd-btn:disabled { opacity: .7; cursor: not-allowed; }
.dd-label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dd-chev { color: var(--muted); transition: transform .15s; }
.dd.open .dd-chev { transform: rotate(180deg); }
.dd.invalid .dd-btn { border-color: var(--danger); }
.dd-native { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; pointer-events: none; }
.dd-panel { position: fixed; z-index: 1000; max-width: min(420px, calc(100vw - 16px)); overflow: auto; padding: 6px;
  background: var(--surface); color: var(--text); border: 1px solid var(--border); border-radius: 12px;
  box-shadow: 0 12px 32px rgba(15, 23, 42, .16), 0 2px 6px rgba(15, 23, 42, .08); animation: pop-in .12s ease-out; }
.dd-opt { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border-radius: 8px; cursor: pointer; font-size: 14px; }
.dd-opt.active { background: color-mix(in srgb, var(--accent) 10%, transparent); }
.dd-opt.selected { font-weight: 600; }
.dd-opt.disabled { opacity: .45; cursor: default; }
.dd-check { width: 16px; display: inline-flex; color: var(--accent); flex: none; }
.dd-text { overflow-wrap: anywhere; }
.dd-group { padding: 8px 10px 4px; font-size: 11px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
@keyframes pop-in { from { opacity: 0; transform: translateY(-4px) scale(.98); } to { opacity: 1; transform: none; } }

/* Aktionsmenüs (⋮) im Stil der Auswahllisten: Symbol + Text, Trennlinien, gesperrte Einträge grau */
.menu-list { border-radius: 12px; padding: 6px; min-width: 260px; gap: 1px;
  box-shadow: 0 12px 32px rgba(15, 23, 42, .16), 0 2px 6px rgba(15, 23, 42, .08); animation: pop-in .12s ease-out; }
.menu-list button, .menu-list a.mi { display: flex; align-items: center; gap: 12px; padding: 9px 12px; border-radius: 8px; font-size: 14px;
  color: var(--text); text-decoration: none; border: 0; background: none; text-align: left; width: 100%; }
.menu-list button:hover:not(:disabled), .menu-list a.mi:hover { background: color-mix(in srgb, var(--accent) 9%, transparent); }
.menu-list button:disabled { opacity: .45; cursor: not-allowed; }
.menu-list .ico { color: var(--muted); }
.menu-list button.danger-item { color: var(--danger); }
.menu-list button.danger-item .ico { color: var(--danger); }
.menu-list hr { margin: 6px 4px; width: auto; }
.menu-list .mi-hint { margin-left: auto; color: var(--muted); display: inline-flex; }
.icon-btn.round { width: 34px; height: 34px; display: inline-grid; place-items: center; padding: 0; border-radius: 50%; border: 1px solid transparent; background: none; color: var(--muted); }
.icon-btn.round:hover, .menu .icon-btn.round[aria-expanded="true"] { background: color-mix(in srgb, var(--text) 7%, transparent); color: var(--text); }
.chev { transition: transform .18s ease; }
.chev.open { transform: rotate(180deg); }
.chev-right { transition: transform .18s ease; }
.chev-right.open { transform: rotate(90deg); }

/* Statischer Kartenausschnitt (OpenStreetMap-Kacheln) */
.static-map { position: relative; display: block; overflow: hidden; height: 220px; border-radius: 10px; background: #e5e3df; border: 1px solid var(--border); }
.static-map img { position: absolute; width: 256px; height: 256px; max-width: none; user-select: none; }
.static-map.empty { display: grid; place-items: center; color: var(--muted); font-size: 13px; }
.static-map-pin { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -92%); color: #fff; filter: drop-shadow(0 2px 3px rgba(0,0,0,.35)); }
.static-map-pin .ico { fill: var(--accent); stroke: #fff; stroke-width: 1.4; }
.static-map-attr { position: absolute; right: 0; bottom: 0; padding: 1px 6px; font-size: 10px; color: #333; background: rgba(255,255,255,.8); border-top-left-radius: 6px; }

/* Standort-Übersicht (aufgeklappt im Kopf eines Standorts) */
.site-overview { display: grid; grid-template-columns: minmax(260px, 1.1fr) minmax(0, 1fr) minmax(0, 1fr); gap: 14px; padding: 14px 16px 16px;
  border-bottom: 1px solid var(--border); background: color-mix(in srgb, var(--surface) 96%, var(--text)); animation: slide-down .18s ease-out; }
.site-overview .ov-col { display: grid; gap: 14px; align-content: start; min-width: 0; }
.ov-card { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 12px 14px; min-width: 0; }
.ov-card h4 { margin: 0 0 8px; font-size: 11px; font-weight: 700; letter-spacing: .07em; text-transform: uppercase; color: var(--info); }
.ov-card dl { display: grid; gap: 8px; margin: 0; }
.ov-card dt { font-size: 12px; color: var(--muted); }
.ov-card dd { margin: 0; overflow-wrap: anywhere; }
.ov-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.ov-actions a, .ov-actions button { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; }
@keyframes slide-down { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }
@media (max-width: 1100px) { .site-overview { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); } }
@media (max-width: 700px) { .site-overview { grid-template-columns: minmax(0, 1fr); } }

.site-title .head-actions { display: inline-flex; align-items: center; gap: 2px; margin-left: auto; }
.site-title .head-partner { color: var(--muted); font-size: 13px; margin-right: 6px; }
.evse-row .expand { display: inline-grid; place-items: center; width: 28px; height: 28px; padding: 0; border: 0; background: none; color: var(--muted); border-radius: 6px; }
.evse-row .expand:hover { background: color-mix(in srgb, var(--text) 7%, transparent); color: var(--text); }
.op-btn .ico { margin-left: -2px; }
.station-filters .dd { max-width: 220px; }
.menu-list.up { top: auto; bottom: calc(100% + 4px); }
.menu-list.align-left { right: auto; left: 0; }

/* Rechnungen und Kunden (public/billing.js) */
.btn.small { padding: 4px 8px; }
.actions-cell .ico, .toolbar .ico { vertical-align: -3px; }
.invoice-filters { align-items: flex-end; }
.invoice-filters .filter.grow { flex: 1 1 240px; max-width: 420px; }
.invoice-filters .dd { min-width: 130px; }
.drafts-card { margin-bottom: 16px; border-color: color-mix(in srgb, var(--warn) 45%, var(--border)); }
.invoice-table td:nth-child(6), .invoice-table td:nth-child(7) { white-space: nowrap; }
.form-row.address-row { grid-template-columns: minmax(0, 1fr) minmax(0, 2fr) minmax(0, .6fr); }
.form-row.bank-row { grid-template-columns: minmax(0, 1.2fr) minmax(0, 2fr) minmax(0, 1fr); }
.user-form { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); align-items: start; }
.user-form > .fieldset, .user-form > .form-actions { grid-column: 1 / -1; }
.customer-fields { display: contents; }
.user-form > .customer-fields > .fieldset:first-child { grid-column: 1 / -1; }
.defaults-table td, .defaults-table th { padding: 6px 8px; }
.defaults-table input { width: 6em; }
@media (max-width: 760px) {
  .user-form { grid-template-columns: minmax(0, 1fr); }
  .form-row.address-row, .form-row.bank-row { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
}
.invoice-table td.mono, .invoice-table .mono { white-space: nowrap; }
.users-table .actions-cell { flex-wrap: nowrap; }
/* Eingefroren: die verborgene Systemliste unter der eigenen Auswahlliste bleibt unsichtbar */
.frozen-fieldset:disabled select.dd-native { opacity: 0; }
/* Schmale Bildschirme: Rechnungen und Ladenachweise als Karten statt breiter Tabelle */
@media (max-width: 560px) {
  .stack-table, .stack-table tbody { display: block; }
  .stack-table tr:first-child { display: none; }
  .stack-table tr { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 4px 12px; padding: 10px 12px; border-bottom: 1px solid var(--border); }
  .stack-table td { display: block; padding: 0; border: 0; text-align: left; }
  .stack-table td[data-label]::before { content: attr(data-label); display: block; font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; }
  .stack-table td.actions-cell { grid-column: 1 / -1; display: flex; justify-content: flex-start; margin-top: 4px; }
}
@media (max-width: 560px) {
  .invoice-filters .filter { flex: 1 1 140px; }
  .invoice-filters .filter.grow { flex-basis: 100%; max-width: none; }
}

/* Umschalter Hell/Dunkel (Seitenleiste und Anmeldung) */
.theme-switch { display: inline-flex; gap: 2px; padding: 3px; border-radius: 999px; background: var(--surface-3); border: 1px solid var(--border); align-self: flex-start; }
.theme-switch button { display: inline-grid; place-items: center; width: 30px; height: 26px; padding: 0; border: 0; border-radius: 999px; background: none; color: var(--muted); }
.theme-switch button:hover { color: var(--text); }
.theme-switch button[aria-pressed="true"] { background: var(--surface); color: var(--text); box-shadow: 0 1px 2px rgba(16, 24, 40, .12); }
.theme-switch svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.login-theme { position: fixed; top: 16px; right: 16px; }

/* Kundenart als deutliche Auswahl (Privatkunde / Geschäftskunde) */
.segmented { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.segmented label { position: relative; flex-direction: row; cursor: pointer; }
.segmented input { position: absolute; opacity: 0; pointer-events: none; }
.segmented span { flex: 1; display: flex; align-items: center; justify-content: center; gap: 8px; padding: 10px 12px; border-radius: 8px;
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--text); font-weight: 600; font-size: 14px; }
.segmented input:checked + span { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 10%, var(--surface)); color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.segmented input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }
/* Ladekarten im Nutzerformular */
.user-form > .cards-fieldset { grid-column: 1 / -1; }
.card-list { display: grid; gap: 6px; }
.card-item { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface-2); }
.card-item .ico { color: var(--accent); }
.card-remove { margin-left: auto; font-size: 12px; }

/* Selbstregistrierung (/registrieren, public/register.js) */
.reg-body { min-height: 100vh; }
.reg { max-width: 600px; margin: 0 auto; padding: 32px 16px 48px; }
.reg-brand { display: block; width: 260px; max-width: 70%; margin: 8px auto 24px; }
.reg-brand img { display: block; width: 100%; height: auto; }
.reg-card { padding: 28px; }
.reg-card h1 { font-size: 24px; margin: 0 0 12px; }
.reg-card h2 { font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 18px 0 2px; }
.reg-card .check { align-items: flex-start; color: var(--text); font-size: 14px; }
.reg-card .check input { margin-top: 3px; flex: none; }
.reg-step { margin: 0 0 6px; }
.reg-progress { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin-bottom: 18px; }
.reg-progress span { height: 4px; border-radius: 4px; background: var(--border); }
.reg-progress span.on { background: var(--accent); }
.reg-points { list-style: none; padding: 0; margin: 0 0 8px; display: grid; gap: 12px; }
.reg-points li { display: grid; gap: 2px; padding-left: 26px; position: relative; }
.reg-points li::before { content: "✓"; position: absolute; left: 0; top: 0; color: var(--accent); font-weight: 700; }
.reg-city { grid-template-columns: minmax(0, 1fr) minmax(0, 2fr); }
.reg-mandate { background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px; padding: 10px 14px; }
.reg-mandate p { margin: 0 0 6px; }
.reg-card-opts, .reg-ship { display: grid; gap: 10px; }
.reg-ship { padding-left: 24px; }
.reg-hp { position: absolute; left: -10000px; width: 1px; height: 1px; overflow: hidden; }
.reg-done { text-align: left; }
.reg-check { width: 48px; height: 48px; border-radius: 50%; display: grid; place-items: center; font-size: 24px; font-weight: 700;
  background: color-mix(in srgb, var(--accent) 14%, var(--surface)); color: var(--accent); margin-bottom: 12px; }
.reg-app { margin-top: 24px; padding-top: 16px; border-top: 1px solid var(--border); }
.reg-app h3 { margin: 0 0 4px; font-size: 16px; }
.store-row { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 10px; }
.store-btn { display: inline-flex; flex-direction: column; justify-content: center; min-width: 150px; padding: 8px 16px; border-radius: 10px;
  background: #111827; color: #fff; text-decoration: none; line-height: 1.2; }
.store-btn strong { font-size: 17px; }
a.btn.primary-link { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.reg-foot { text-align: center; margin-top: 16px; }
.login-links { display: flex; justify-content: space-between; gap: 8px; font-size: 13px; }
@media (max-width: 520px) {
  .reg-card { padding: 20px 16px; }
  .reg-card .form-row:not(.reg-city) { grid-template-columns: minmax(0, 1fr); }
}
.nav-count { display: inline-grid; place-items: center; min-width: 20px; height: 20px; padding: 0 6px; margin-left: 4px; border-radius: 999px;
  background: var(--warn); color: #fff; font-size: 11px; font-weight: 700; vertical-align: 1px; }
.seg-filter { display: inline-flex; gap: 4px; flex-wrap: wrap; }
.seg-filter button.active { background: var(--sidebar-active); color: var(--sidebar-active-text); border-color: color-mix(in srgb, var(--accent) 35%, var(--border)); font-weight: 600; }
.form-row.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
@media (max-width: 760px) { .form-row.three { grid-template-columns: minmax(0, 1fr); } }
/* Nutzer & Karten: Suche */
.user-search input[type=search] { flex: 1; min-width: 240px; max-width: 560px; padding: 9px 12px; border-radius: 8px; }
.users-table td.small .mono, .card td.mono { white-space: nowrap; }
