/* Ladebilanz · nordisches Layout
   Farben als Tokens, dunkles Schema als eigene, validierte Stufen (kein Invertieren). */

:root {
  color-scheme: light;
  --page: #f6f4ef;          /* Papier */
  --surface: #fbfaf7;       /* Kartenfläche */
  --surface-2: #efece5;     /* Birke, für Flächen im Diagramm */
  --ink: #1b2430;           /* Polarnacht */
  --ink-2: #4c5664;
  --muted: #858c96;
  --hair: #e2ded5;
  --axis: #c9c4b8;
  --accent: #2a73b8;        /* Fjord */
  --accent-soft: rgba(42, 115, 184, 0.10);
  --focus: #2a73b8;
  --good: #2f7d4f;
  --bad: #a8343f;

  /* Leistungsklassen, Reihenfolge ist Teil der Farbfehlsichtigkeits-Prüfung */
  --c1: #3e9468;  /* Moos     · ≤ 11 kW  */
  --c2: #2a73b8;  /* Fjord    · ≤ 22 kW  */
  --c3: #c98a12;  /* Ocker    · ≤ 50 kW  */
  --c4: #c23e52;  /* Preiselbeere · ≤ 150 kW */
  --c5: #6a55c2;  /* Nordlicht · > 150 kW */
  --c0: #1b2430;  /* alle Klassen */

  /* Sequenzielle Rampe (Fjord), hell -> dunkel */
  --seq-0: #eaeff4;
  --seq-1: #0d366b;

  --radius: 10px;
  --shadow: 0 1px 0 rgba(27, 36, 48, 0.04), 0 8px 24px -18px rgba(27, 36, 48, 0.25);
  --font: "Hanken Grotesk", system-ui, -apple-system, "Segoe UI", sans-serif;
  --serif: "Newsreader", Georgia, serif;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --page: #0f141a;
    --surface: #131a21;
    --surface-2: #1a232c;
    --ink: #e8ebee;
    --ink-2: #b3bbc4;
    --muted: #7d8793;
    --hair: #232d37;
    --axis: #34404c;
    --accent: #5b9be0;
    --accent-soft: rgba(91, 155, 224, 0.14);
    --focus: #7fb2ea;
    --good: #5fbf85;
    --bad: #e0707c;
    --c1: #3c9a6c;
    --c2: #3a84cc;
    --c3: #bf8a1f;
    --c4: #d44c5e;
    --c5: #8b79de;
    --c0: #e8ebee;
    --seq-0: #18222c;
    --seq-1: #9ec5f4;
    --shadow: 0 1px 0 rgba(0, 0, 0, 0.3), 0 10px 30px -20px rgba(0, 0, 0, 0.8);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --page: #0f141a;
  --surface: #131a21;
  --surface-2: #1a232c;
  --ink: #e8ebee;
  --ink-2: #b3bbc4;
  --muted: #7d8793;
  --hair: #232d37;
  --axis: #34404c;
  --accent: #5b9be0;
  --accent-soft: rgba(91, 155, 224, 0.14);
  --focus: #7fb2ea;
  --good: #5fbf85;
  --bad: #e0707c;
  --c1: #3c9a6c;
  --c2: #3a84cc;
  --c3: #bf8a1f;
  --c4: #d44c5e;
  --c5: #8b79de;
  --c0: #e8ebee;
  --seq-0: #18222c;
  --seq-1: #9ec5f4;
  --shadow: 0 1px 0 rgba(0, 0, 0, 0.3), 0 10px 30px -20px rgba(0, 0, 0, 0.8);
}

*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 132px; }
body {
  margin: 0;
  background: var(--page);
  color: var(--ink);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
a { color: inherit; }
code { font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 0.88em; background: var(--surface-2); padding: 0.1em 0.35em; border-radius: 4px; }
button, select { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

.wrap { max-width: 1240px; margin: 0 auto; padding: 0 28px; }
@media (max-width: 640px) { .wrap { padding: 0 16px; } .card { padding: 16px 14px 12px; } }

/* ---------- Demo-Hinweis */
.demo-banner {
  display: flex; gap: 12px; align-items: center; justify-content: center; flex-wrap: wrap;
  padding: 9px 16px; font-size: 13.5px; color: var(--ink-2);
  background: repeating-linear-gradient(135deg, var(--surface-2) 0 10px, var(--page) 10px 20px);
  border-bottom: 1px solid var(--hair);
  text-align: center;
}
.demo-banner[hidden] { display: none; }
.demo-banner__tag {
  font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; font-size: 11px;
  color: var(--page); background: var(--ink); padding: 3px 8px; border-radius: 3px;
}

/* ---------- Kopf */
.masthead { border-bottom: 1px solid var(--hair); background: var(--page); }
.masthead__inner { display: flex; align-items: center; gap: 28px; height: 60px; }
.masthead__brand { display: flex; align-items: baseline; gap: 10px; white-space: nowrap; }
.brand-mark {
  width: 14px; height: 14px; border-radius: 50%; align-self: center;
  background: conic-gradient(from 200deg, var(--c1), var(--c2), var(--c3), var(--c4), var(--c5), var(--c1));
  box-shadow: inset 0 0 0 3px var(--page);
  outline: 1px solid var(--hair);
}
.brand-name { font-weight: 700; letter-spacing: -0.01em; font-size: 17px; }
.brand-sub { color: var(--muted); font-size: 13px; }
.masthead__nav { display: flex; gap: 20px; margin-left: auto; font-size: 14px; overflow-x: auto; scrollbar-width: none; }
.masthead__nav a { text-decoration: none; color: var(--ink-2); padding: 4px 0; border-bottom: 1px solid transparent; white-space: nowrap; }
.masthead__nav a:hover { color: var(--ink); border-bottom-color: var(--ink); }
.theme-toggle {
  width: 34px; height: 34px; border-radius: 50%; border: 1px solid var(--hair); background: var(--surface);
  display: grid; place-items: center; cursor: pointer; flex: none; color: var(--ink-2);
}
.theme-toggle:hover { color: var(--ink); border-color: var(--axis); }
@media (max-width: 900px) { .masthead__nav { display: none; } .theme-toggle { margin-left: auto; } }

/* ---------- Hero */
.hero { padding: 64px 0 40px; }
.hero__grid { display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); gap: 56px; align-items: end; }
.eyebrow { margin: 0 0 18px; font-size: 13px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted); font-weight: 600; }
.hero__title {
  font-family: var(--serif); font-weight: 400; font-size: clamp(40px, 5.6vw, 72px);
  line-height: 1.02; letter-spacing: -0.02em; margin: 0 0 22px;
}
.hero__title em { font-style: italic; color: var(--accent); }
.hero__lede { font-size: 18px; color: var(--ink-2); max-width: 38em; margin: 0; }
.hero__art { margin: 0; }
.hero__art svg { width: 100%; height: auto; display: block; overflow: visible; }
.hero__art figcaption { font-size: 12.5px; color: var(--muted); margin-top: 6px; text-align: right; }
@media (max-width: 900px) {
  .hero { padding-top: 40px; }
  .hero__grid { grid-template-columns: 1fr; gap: 28px; }
}

.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); margin-top: 48px; border-top: 1px solid var(--ink); }
.kpi { padding: 18px 20px 6px 0; border-right: 1px solid var(--hair); margin-right: 20px; }
.kpi:last-child { border-right: 0; margin-right: 0; }
.kpi__label { font-size: 13px; color: var(--ink-2); margin: 0 0 6px; }
.kpi__value { font-size: clamp(30px, 3.4vw, 44px); font-weight: 600; letter-spacing: -0.02em; line-height: 1.05; margin: 0; }
.kpi__unit { font-size: 0.45em; font-weight: 500; color: var(--ink-2); margin-left: 4px; letter-spacing: 0; }
.kpi__delta { font-size: 13px; color: var(--ink-2); margin: 8px 0 0; display: flex; gap: 6px; align-items: center; }
.kpi__delta b { font-weight: 600; }
.kpi__delta .up { color: var(--good); }
.kpi__delta .down { color: var(--bad); }
.kpi svg { display: block; width: 100%; height: 34px; margin-top: 10px; }
@media (max-width: 900px) {
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kpi:nth-child(2) { border-right: 0; margin-right: 0; }
  .kpi:nth-child(-n+2) { border-bottom: 1px solid var(--hair); }
}

/* ---------- Steuerleiste */
.controls {
  position: sticky; top: 0; z-index: 20;
  background: color-mix(in srgb, var(--page) 88%, transparent);
  backdrop-filter: saturate(1.2) blur(10px);
  -webkit-backdrop-filter: saturate(1.2) blur(10px);
  border-top: 1px solid var(--hair); border-bottom: 1px solid var(--hair);
}
.controls__inner { display: flex; gap: 28px; align-items: center; padding-top: 12px; padding-bottom: 12px; flex-wrap: wrap; }
.control { display: flex; flex-direction: column; gap: 5px; }
.control__label { font-size: 11px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); font-weight: 600; }
.control--classes { margin-left: auto; }
.seg { display: inline-flex; border: 1px solid var(--hair); border-radius: 8px; padding: 2px; background: var(--surface); }
.seg button {
  border: 0; background: transparent; padding: 5px 11px; border-radius: 6px; cursor: pointer; font-size: 14px; color: var(--ink-2);
}
.seg button:hover { color: var(--ink); }
.seg button[aria-pressed="true"] { background: var(--ink); color: var(--page); }
.select {
  appearance: none; border: 1px solid var(--hair); border-radius: 8px; background: var(--surface);
  padding: 6px 34px 6px 11px; font-size: 14px; min-width: 210px; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%23858c96' stroke-width='1.4' fill='none'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center;
}
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
  display: inline-flex; align-items: center; gap: 7px; border: 1px solid var(--hair); background: var(--surface);
  border-radius: 999px; padding: 4px 11px 4px 9px; font-size: 13.5px; cursor: pointer; color: var(--ink);
  transition: opacity 0.15s, border-color 0.15s;
}
.chip:hover { border-color: var(--axis); }
.chip__dot { width: 10px; height: 10px; border-radius: 50%; background: var(--c); }
.chip[aria-pressed="false"] { opacity: 0.45; }
.chip[aria-pressed="false"] .chip__dot { background: transparent; box-shadow: inset 0 0 0 1.5px var(--c); }
@media (max-width: 900px) {
  .controls { position: static; }
  .control--classes { margin-left: 0; }
  .controls__inner { gap: 16px; }
  .select { min-width: 0; width: 100%; }
}

/* ---------- Abschnitte */
.section { padding: 84px 0 12px; }
.section__grid { display: grid; grid-template-columns: minmax(0, 300px) minmax(0, 1fr); gap: 48px; align-items: start; }
.section__head { position: sticky; top: 108px; }
.section__grid--stacked { grid-template-columns: minmax(0, 1fr); gap: 24px; }
.section__grid--stacked .section__head { position: static; max-width: 780px; }
.section__no { font-size: 12px; font-weight: 700; letter-spacing: 0.14em; color: var(--muted); display: block; margin-bottom: 12px; }
.section__no::after { content: ""; display: inline-block; width: 28px; height: 1px; background: var(--axis); vertical-align: middle; margin-left: 10px; }
.section__head h2 { font-family: var(--serif); font-weight: 400; font-size: 32px; line-height: 1.1; letter-spacing: -0.015em; margin: 0 0 16px; }
.section__head p { margin: 0 0 12px; color: var(--ink-2); font-size: 15.5px; }
.section__head .note { font-size: 13.5px; color: var(--muted); }
@media (max-width: 1000px) {
  .section { padding-top: 56px; }
  .section__grid { grid-template-columns: 1fr; gap: 20px; }
  .section__head { position: static; }
}

.stack { display: grid; gap: 20px; }
.split { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; }
.split--wide-left { grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); }
.split:has(> .card[hidden]) { grid-template-columns: 1fr; }
.stat-row { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px 24px; }
@media (max-width: 640px) { .stat-row { grid-template-columns: 1fr; } }
.stat { border-left: 2px solid var(--c, var(--hair)); padding: 2px 0 2px 12px; }
.stat__label { font-size: 12.5px; color: var(--ink-2); margin: 0 0 4px; }
.stat__value { font-size: 26px; font-weight: 600; letter-spacing: -0.015em; margin: 0; line-height: 1.1; }
.stat__unit { font-size: 13px; font-weight: 500; color: var(--ink-2); margin-left: 3px; }
.stat__sub { font-size: 12px; color: var(--muted); margin: 4px 0 0; }
@media (max-width: 760px) { .split, .split--wide-left { grid-template-columns: 1fr; } }

/* ---------- Karten */
.card {
  background: var(--surface); border: 1px solid var(--hair); border-radius: var(--radius);
  padding: 20px 20px 16px; box-shadow: var(--shadow); min-width: 0; position: relative;
}
.card[hidden] { display: none; }
.card__head { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px 16px; margin-bottom: 4px; flex-wrap: wrap; }
.card__head > div:first-child { flex: 1 1 220px; min-width: 0; }
.card__title { font-size: 15.5px; font-weight: 600; margin: 0; letter-spacing: -0.005em; }
.card__sub { font-size: 13px; color: var(--muted); margin: 2px 0 0; }
.card__tools { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; justify-content: flex-end; margin-left: auto; }
.card__body { margin-top: 12px; }
.card__foot { font-size: 12.5px; color: var(--muted); margin-top: 8px; }
.tool-btn {
  border: 1px solid var(--hair); background: transparent; border-radius: 6px; font-size: 12.5px; padding: 3px 9px;
  color: var(--ink-2); cursor: pointer;
}
.tool-btn:hover, .tool-btn[aria-pressed="true"] { color: var(--ink); border-color: var(--axis); background: var(--surface-2); }
.mini-seg { display: inline-flex; gap: 2px; border: 1px solid var(--hair); border-radius: 6px; padding: 1px; }
.mini-seg button { border: 0; background: transparent; font-size: 12.5px; padding: 2px 8px; border-radius: 5px; cursor: pointer; color: var(--ink-2); }
.mini-seg button[aria-pressed="true"] { background: var(--surface-2); color: var(--ink); font-weight: 600; }
.mini-select { border: 1px solid var(--hair); border-radius: 6px; background: var(--surface); font-size: 12.5px; padding: 3px 6px; }
.empty { padding: 40px 0; text-align: center; color: var(--muted); font-size: 14px; }

/* ---------- Diagramme */
.chart { position: relative; width: 100%; }
.chart svg { display: block; width: 100%; overflow: visible; }
.chart text { font-family: var(--font); }
.axis text, .tick-label { fill: var(--muted); font-size: 11.5px; font-variant-numeric: tabular-nums; }
.axis-title { fill: var(--muted); font-size: 11.5px; }
.grid line { stroke: var(--hair); stroke-width: 1; shape-rendering: crispEdges; }
.baseline { stroke: var(--axis); stroke-width: 1; shape-rendering: crispEdges; }
.series-line { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.series-band { opacity: 0.12; }
.end-label { font-size: 12px; fill: var(--ink-2); font-weight: 500; }
.end-label--value { fill: var(--ink); font-weight: 600; font-variant-numeric: tabular-nums; }
.leader { stroke: var(--axis); stroke-width: 1; }
.crosshair { stroke: var(--ink); stroke-width: 1; opacity: 0.35; shape-rendering: crispEdges; }
.hover-dot { stroke: var(--surface); stroke-width: 2; }
.shade { fill: var(--surface-2); }
.shade-label { fill: var(--muted); font-size: 11px; }
.bar-label { font-size: 11.5px; fill: var(--ink-2); font-variant-numeric: tabular-nums; }
.cat-label { font-size: 12.5px; fill: var(--ink); }

.legend { display: flex; flex-wrap: wrap; gap: 4px 16px; font-size: 12.5px; color: var(--ink-2); margin-top: 10px; }
.legend__item { display: inline-flex; align-items: center; gap: 6px; }
.legend__key { width: 14px; height: 3px; border-radius: 2px; background: var(--c); }
.legend__key--box { width: 10px; height: 10px; border-radius: 2px; }

.tooltip {
  position: fixed; z-index: 50; pointer-events: none; min-width: 160px; max-width: 300px;
  background: var(--surface); color: var(--ink); border: 1px solid var(--hair); border-radius: 8px;
  box-shadow: 0 12px 32px -12px rgba(0, 0, 0, 0.35); padding: 10px 12px; font-size: 12.5px; line-height: 1.4;
}
.tooltip__title { font-weight: 600; margin-bottom: 6px; font-size: 13px; }
.tooltip__row { display: grid; grid-template-columns: 12px 1fr auto; gap: 8px; align-items: center; padding: 1px 0; }
.tooltip__row b { font-weight: 600; font-variant-numeric: tabular-nums; text-align: right; }
.tooltip__key { width: 10px; height: 3px; border-radius: 2px; background: var(--c); }
.tooltip__muted { color: var(--muted); font-size: 11.5px; margin-top: 6px; }

/* Tabellenansicht */
.table-wrap { max-height: 360px; overflow: auto; border-top: 1px solid var(--hair); margin-top: 8px; }
.data-table { width: 100%; border-collapse: collapse; font-size: 12.5px; font-variant-numeric: tabular-nums; }
.data-table th, .data-table td { padding: 6px 8px; text-align: right; border-bottom: 1px solid var(--hair); white-space: nowrap; }
.data-table th:first-child, .data-table td:first-child { text-align: left; }
.data-table thead th { position: sticky; top: 0; background: var(--surface); color: var(--muted); font-weight: 600; }

/* Lage-Tabelle mit Zellbalken */
.lage-wrap { overflow-x: auto; }
.lage-table td { vertical-align: middle; }
.lage-table td:first-child { font-size: 13px; color: var(--ink); padding-right: 16px; }
.lage-table th { text-align: left; }
.cellbar { display: flex; flex-direction: column; gap: 4px; min-width: 92px; padding: 2px 0; }
.cellbar__val { color: var(--ink); order: 1; }
.cellbar__bar { order: 2; display: block; height: 3px; border-radius: 2px; background: var(--accent); opacity: 0.75; min-width: 2px; }
.lage-table td { text-align: left; }

.cell-sub { display: block; font-size: 11.5px; color: var(--muted); margin-top: 2px; }
.top-table td, .top-table th { padding-left: 6px; padding-right: 6px; }
.top-table .cellbar { min-width: 84px; }

/* Kachelkarte Bundesländer */
.tile rect { stroke: var(--surface); stroke-width: 2; }
.tile text { pointer-events: none; }
.tile__abbr { font-size: 13px; font-weight: 700; }
.tile__val { font-size: 11.5px; font-variant-numeric: tabular-nums; }
.tile:hover rect { stroke: var(--ink); }

/* Karte */
.map-canvas { width: 100%; display: block; }
.map-controls { display: flex; align-items: center; gap: 10px; margin-top: 10px; font-size: 12.5px; color: var(--ink-2); }
.map-controls input[type="range"] { flex: 1; accent-color: var(--accent); }
.play-btn { width: 30px; height: 30px; border-radius: 50%; border: 1px solid var(--hair); background: var(--surface); cursor: pointer; display: grid; place-items: center; color: var(--ink); }
.map-year { font-weight: 600; font-variant-numeric: tabular-nums; min-width: 3.2em; color: var(--ink); }
.seq-legend { display: flex; align-items: center; gap: 8px; font-size: 11.5px; color: var(--muted); margin-top: 8px; }
.seq-legend__bar { height: 8px; flex: 0 1 180px; border-radius: 2px; }

/* Methodik */
.method { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px 32px; font-size: 14.5px; color: var(--ink-2); }
.method h3 { font-size: 14px; color: var(--ink); margin: 0 0 6px; font-weight: 600; }
.method p, .method ul { margin: 0 0 6px; }
.method ul { padding-left: 18px; }
.method li { margin-bottom: 3px; }
@media (max-width: 760px) { .method { grid-template-columns: 1fr; } }

.footer { margin-top: 96px; border-top: 1px solid var(--hair); padding: 28px 0 48px; font-size: 13px; color: var(--muted); }
.footer__inner { display: flex; justify-content: space-between; gap: 24px; flex-wrap: wrap; }
.footer p { margin: 0; max-width: 60em; }

@media (forced-colors: active) {
  .series-line { stroke: CanvasText; }
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  * { transition: none !important; animation: none !important; }
}
