/* Referenz-Marktpreise Strom
   Schweizer Grotesk, kühles Grau, Farbe nur für die Träger. */

:root {
  --bg: #EEF2F4;
  --panel: #FFFFFF;
  --ink: #15232B;
  --muted: #5A6A72;
  --line: #D2DBDF;
  --band: #F2F5F7;
  --focus: #1F5FA8;
  --error: #B3261E;
  --radius-s: 4px;
  --radius-m: 8px;
  --font: "Helvetica Neue", Helvetica, "Nimbus Sans", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0E181D;
    --panel: #152229;
    --ink: #E4ECEF;
    --muted: #94A5AD;
    --line: #2A3B44;
    --band: #1A2A32;
    --focus: #7FB2EA;
    --error: #F2968F;
  }
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 400 1rem/1.5 var(--font);
  font-variant-numeric: tabular-nums;
}

h1, h2, p { margin: 0; }
h2 { font-size: 1.0625rem; line-height: 1.3; font-weight: 700; letter-spacing: -0.005em; }
code { font-family: var(--mono); font-size: 0.875em; }

:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

.visually-hidden {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap;
}

/* ---------- Kopf ---------- */

.masthead {
  border-top: 6px solid var(--ink);
  background: var(--panel);
  border-bottom: 1px solid var(--line);
}
.masthead__inner {
  max-width: 1240px;
  margin: 0 auto;
  padding: 2.25rem 1.5rem 1.75rem;
}
.masthead h1 {
  font-size: clamp(2.1rem, 1.3rem + 3.2vw, 3.6rem);
  line-height: 1;
  font-weight: 700;
  letter-spacing: -0.03em;
  max-width: 14ch;
}
.lede {
  margin-top: 1rem;
  max-width: 62ch;
  font-size: 1.0625rem;
  color: var(--muted);
}
.source { margin-top: 0.75rem; font-size: 0.8125rem; color: var(--muted); }
.source--missing { color: var(--error); }

/* ---------- Raster ---------- */

.layout {
  max-width: 1240px;
  margin: 0 auto;
  padding: 1.75rem 1.5rem 1rem;
  display: grid;
  grid-template-columns: 16.5rem minmax(0, 1fr);
  gap: 2rem;
  align-items: start;
}
.sidebar { position: sticky; top: 1.25rem; }
.content { min-width: 0; }

/* ---------- Träger ---------- */

.hint { font-size: 0.8125rem; color: var(--muted); margin-top: 0.25rem; }
.sidebar .hint { margin-bottom: 1rem; }

.carriers { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.5rem; }

.carrier {
  display: grid;
  grid-template-columns: 0.875rem 1fr auto;
  align-items: center;
  gap: 0.75rem;
  width: 100%;
  padding: 0.75rem 0.875rem 0.75rem 0.75rem;
  background: var(--panel);
  color: var(--ink);
  border: 1px solid var(--line);
  border-left: 5px solid var(--carrier);
  border-radius: var(--radius-s);
  font: inherit;
  text-align: left;
  cursor: pointer;
  transition: background-color 0.15s, color 0.15s, border-color 0.15s;
}
.carrier:hover { border-color: var(--muted); border-left-color: var(--carrier); }
.carrier__swatch {
  width: 0.875rem; height: 0.875rem; border-radius: 50%;
  background: var(--carrier); border: 2px solid var(--carrier);
}
.carrier__name { font-weight: 600; }
.carrier__value { font-weight: 600; }

.carrier[aria-pressed="false"] {
  background: transparent;
  color: var(--muted);
  border-left-color: var(--line);
}
.carrier[aria-pressed="false"] .carrier__swatch { background: transparent; }
.carrier[aria-pressed="false"] .carrier__name { font-weight: 400; }
.carrier[aria-pressed="false"] .carrier__value { font-weight: 400; }

.carriers__bulk { display: flex; gap: 1.25rem; margin-top: 0.75rem; }

.link-button {
  background: none; border: 0; padding: 0.25rem 0;
  font: inherit; font-size: 0.875rem;
  color: var(--focus); text-decoration: underline; text-underline-offset: 3px;
  cursor: pointer;
}
.link-button:disabled { color: var(--muted); text-decoration: none; cursor: default; opacity: 0.6; }

/* ---------- Werkzeugleiste ---------- */

.toolbar {
  display: flex; flex-wrap: wrap; align-items: center;
  gap: 0.75rem 1.5rem;
  margin-bottom: 1rem;
}
.toolbar__group { display: flex; flex-wrap: wrap; align-items: center; gap: 0.75rem 1.5rem; }

.segmented {
  display: inline-flex;
  border: 1px solid var(--ink);
  border-radius: 6px;
  overflow: hidden;
}
.segmented button {
  padding: 0.5rem 1.1rem;
  background: transparent; color: var(--ink);
  border: 0; font: inherit; font-weight: 600; cursor: pointer;
}
.segmented button + button { border-left: 1px solid var(--ink); }
.segmented button[aria-pressed="true"] { background: var(--ink); color: var(--panel); }
.segmented button:focus-visible { outline-offset: -4px; outline-color: var(--panel); }
.segmented button[aria-pressed="false"]:focus-visible { outline-color: var(--focus); }

.field, .check {
  display: inline-flex; align-items: center; gap: 0.5rem;
  font-size: 0.875rem; color: var(--muted);
}
.check { cursor: pointer; }
.check input { width: 1rem; height: 1rem; accent-color: var(--ink); margin: 0; }
select {
  font: inherit; font-size: 0.9375rem; color: var(--ink);
  background: var(--panel);
  border: 1px solid var(--line); border-radius: var(--radius-s);
  padding: 0.4rem 0.6rem;
}

.button {
  margin-left: auto;
  display: inline-block;
  padding: 0.5rem 0.95rem;
  border: 1px solid var(--line); border-radius: var(--radius-s);
  background: var(--panel); color: var(--ink);
  font-size: 0.875rem; font-weight: 600; text-decoration: none;
}
.button:hover { border-color: var(--muted); }
.button.is-disabled { opacity: 0.45; pointer-events: none; }

/* ---------- Status ---------- */

.status { margin-bottom: 1rem; font-size: 0.9375rem; }
.status:empty { display: none; }
.status.is-busy { color: var(--muted); }
.status.is-error {
  color: var(--error);
  background: var(--panel);
  border-left: 4px solid var(--error);
  padding: 0.65rem 0.9rem;
  border-radius: var(--radius-s);
}

/* ---------- Panels ---------- */

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-m);
  padding: 1.25rem 1.25rem 1.1rem;
  margin: 0 0 1.25rem;
}
.panel__head { display: flex; align-items: baseline; justify-content: space-between; gap: 1rem; margin-bottom: 0.9rem; }
.unit { font-size: 0.8125rem; color: var(--muted); }
.chart-note { margin-top: 0.75rem; font-size: 0.8125rem; color: var(--muted); max-width: 72ch; }

body.is-busy .chart, body.is-busy .table-wrap { opacity: 0.55; transition: opacity 0.2s; }

/* ---------- Grafik ---------- */

.chart { position: relative; }
.chart__svg { display: block; max-width: 100%; height: auto; overflow: visible; }
.chart__svg:focus-visible { outline: 2px solid var(--focus); outline-offset: 4px; border-radius: 2px; }
.chart__band { fill: var(--band); }
.chart__grid line { stroke: var(--line); stroke-width: 1; }
.chart__tick { fill: var(--muted); font-size: 11px; }
.chart__qlabel { fill: var(--muted); font-size: 11px; }
.chart__year { fill: var(--ink); font-size: 12px; font-weight: 700; }
.chart__yearline { stroke: var(--muted); stroke-width: 1; stroke-opacity: 0.45; }
.chart__line { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart__line.is-muted { stroke-width: 1.25; opacity: 0.35; }
.chart__dot { stroke: var(--panel); stroke-width: 1; }
.chart__seg { stroke-width: 4.5; stroke-linecap: butt; }
.chart__seg.is-dashed { stroke-width: 2.5; stroke-dasharray: 6 4; }
.chart__guide { stroke: var(--ink); stroke-width: 1; stroke-dasharray: 2 3; }
.chart__hit { fill: transparent; cursor: crosshair; touch-action: pan-y; }
.chart__empty { padding: 4rem 1rem; text-align: center; color: var(--muted); }

.chart__tip {
  position: absolute; z-index: 2;
  min-width: 12.5rem;
  background: var(--panel);
  border: 1px solid var(--ink);
  border-radius: var(--radius-s);
  padding: 0.6rem 0.75rem;
  font-size: 0.8125rem;
  pointer-events: none;
}
.tip__title { font-weight: 700; margin-bottom: 0.25rem; }
.tip__title--quarter { margin-top: 0.5rem; padding-top: 0.5rem; border-top: 1px solid var(--line); }
.tip__rows { width: 100%; border-collapse: collapse; }
.tip__rows th { font-weight: 400; text-align: left; padding: 0.1rem 1rem 0.1rem 0; white-space: nowrap; }
.tip__rows td { text-align: right; font-weight: 600; }
.tip__unit { margin-top: 0.35rem; color: var(--muted); font-size: 0.75rem; }

.dot {
  display: inline-block; width: 0.6rem; height: 0.6rem; border-radius: 50%;
  background: var(--carrier); margin-right: 0.45rem;
}

/* ---------- Tabellen ---------- */

.table-wrap { overflow: auto; max-height: 34rem; border-radius: var(--radius-s); }
.table-wrap:focus-visible { outline-offset: 0; }

.data { width: 100%; border-collapse: collapse; font-size: 0.9375rem; }
.data th, .data td { padding: 0.55rem 0.75rem; border-bottom: 1px solid var(--line); text-align: left; }
.data .num { text-align: right; white-space: nowrap; }
.data thead th {
  position: sticky; top: 0; z-index: 1;
  background: var(--panel);
  font-size: 0.8125rem; font-weight: 600; color: var(--muted);
  border-bottom: 2px solid var(--ink);
  white-space: nowrap;
}
.data thead tr.sub th { top: 2.3rem; font-weight: 400; border-bottom-width: 1px; }
.data tbody th { font-weight: 400; white-space: nowrap; }
.data tr.q-first > * { border-bottom: 1px solid var(--muted); }
.data td.muted { color: var(--muted); }
.data td.strong { font-weight: 700; }
.data tbody tr:hover > * { background: var(--band); }
.data tr.calc:hover > * { background: var(--bg); }

.expand {
  display: flex; flex-direction: column; align-items: flex-start;
  background: none; border: 0; padding: 0; margin: 0;
  color: var(--ink); font: inherit; text-align: left; cursor: pointer;
}
.expand__label { font-weight: 700; }
.expand__label::before {
  content: ""; display: inline-block; margin-right: 0.55rem; vertical-align: 0.1em;
  border-left: 6px solid currentColor; border-top: 4.5px solid transparent; border-bottom: 4.5px solid transparent;
  transition: transform 0.15s;
}
.expand[aria-expanded="true"] .expand__label::before { transform: rotate(90deg); }
.expand__months { padding-left: 1.05rem; font-size: 0.8125rem; color: var(--muted); }
.badge {
  display: inline-block; margin-left: 0.4rem; padding: 0 0.35rem;
  border: 1px solid var(--muted); border-radius: 3px; font-size: 0.75rem;
}

.data tr.calc td { background: var(--bg); padding: 0.9rem 1rem 1rem; }
.calc__note { font-size: 0.8125rem; color: var(--muted); margin-bottom: 0.5rem; }
.calc__list { list-style: none; margin: 0; padding: 0; }
.calc__list li {
  display: grid; grid-template-columns: 9.5rem minmax(0, 1fr); gap: 0.75rem;
  padding: 0.3rem 0; font-size: 0.875rem;
}
.calc__name { white-space: nowrap; }
.calc__expr { font-family: var(--mono); font-size: 0.8125rem; line-height: 1.6; overflow-wrap: anywhere; }
.calc__mix { margin-top: 0.5rem; font-size: 0.875rem; }

.empty { padding: 2rem 0.5rem; color: var(--muted); }

/* ---------- Methode ---------- */

.method summary { cursor: pointer; font-weight: 700; }
.method p { margin-top: 0.75rem; max-width: 70ch; }
.method .formula { font-family: var(--mono); font-size: 0.9375rem; padding: 0.6rem 0.8rem; background: var(--bg); border-radius: var(--radius-s); display: inline-block; }

/* ---------- Fuss ---------- */

.footer { max-width: 1240px; margin: 0 auto; padding: 0.5rem 1.5rem 2.5rem; font-size: 0.8125rem; color: var(--muted); }
.noscript { max-width: 1240px; margin: 1rem auto; padding: 1rem 1.5rem; color: var(--error); }

/* ---------- Responsiv ---------- */

@media (max-width: 880px) {
  .layout { grid-template-columns: 1fr; gap: 1.25rem; padding-top: 1.25rem; }
  .sidebar { position: static; }
  .carriers { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 520px) {
  .masthead__inner, .layout, .footer { padding-left: 1rem; padding-right: 1rem; }
  .carriers { grid-template-columns: 1fr; }
  .panel { padding: 1rem 0.85rem; }
  .button { margin-left: 0; }
  .calc__list li { grid-template-columns: 1fr; gap: 0.1rem; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; }
}
