:root {
  --hintergrund: #f6f7f9;
  --flaeche: #ffffff;
  --flaeche-schwach: #f0f2f5;
  --rand: #dfe3e8;
  --text: #1b1f24;
  --text-schwach: #5b6570;
  --akzent: #2f5d8a;
  --akzent-schwach: #e6eef6;
  --positiv: #1f7a4d;
  --negativ: #b23a3a;
  --warnung: #8a6116;
  --warnung-flaeche: #fdf4e0;
  --fehler-flaeche: #fbeceb;
  --erfolg-flaeche: #e9f5ee;
  --radius: 8px;
  --schatten: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .04);
}

@media (prefers-color-scheme: dark) {
  :root {
    --hintergrund: #14171a;
    --flaeche: #1c2024;
    --flaeche-schwach: #24292e;
    --rand: #333a41;
    --text: #e8eaed;
    --text-schwach: #9aa4ae;
    --akzent: #7fb2e5;
    --akzent-schwach: #1e2c3a;
    --positiv: #5ec48d;
    --negativ: #e88b8b;
    --warnung: #e0b45f;
    --warnung-flaeche: #2e2718;
    --fehler-flaeche: #2f1e1e;
    --erfolg-flaeche: #17281f;
    --schatten: 0 1px 2px rgba(0, 0, 0, .3);
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  color: var(--text);
  background: var(--hintergrund);
}

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

/* --------------------------------------------------- Kopf und Navigation */
header.kopf {
  background: var(--flaeche);
  border-bottom: 1px solid var(--rand);
  position: sticky;
  top: 0;
  z-index: 10;
}
.kopf-innen {
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 20px;
  display: flex;
  align-items: center;
  gap: 24px;
  flex-wrap: wrap;
}
.marke {
  font-weight: 650;
  padding: 14px 0;
  color: var(--text);
  white-space: nowrap;
}
.marke:hover { text-decoration: none; }
nav.haupt { display: flex; gap: 2px; flex-wrap: wrap; flex: 1; }
nav.haupt a {
  padding: 14px 12px;
  color: var(--text-schwach);
  border-bottom: 2px solid transparent;
  white-space: nowrap;
}
nav.haupt a:hover { color: var(--text); text-decoration: none; }
nav.haupt a.aktiv { color: var(--akzent); border-bottom-color: var(--akzent); }
.kopf-rechts { display: flex; align-items: center; gap: 12px; color: var(--text-schwach); font-size: 13px; }

main {
  max-width: 1400px;
  margin: 0 auto;
  padding: 24px 20px 64px;
}

/* --------------------------------------------------- Typografie */
h1 { font-size: 22px; margin: 0 0 4px; font-weight: 620; }
h2 { font-size: 16px; margin: 0 0 12px; font-weight: 600; }
h3 { font-size: 14px; margin: 0 0 8px; font-weight: 600; color: var(--text-schwach); }
.untertitel { color: var(--text-schwach); font-size: 14px; margin: 0 0 20px; }
.seitenkopf { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; flex-wrap: wrap; }

/* --------------------------------------------------- Karten */
.karte {
  background: var(--flaeche);
  border: 1px solid var(--rand);
  border-radius: var(--radius);
  padding: 18px;
  margin-bottom: 18px;
  box-shadow: var(--schatten);
}
.karte > h2:first-child { margin-top: 0; }
.karten-reihe { display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); gap: 18px; }

/* --------------------------------------------------- Kennzahlen */
.kennzahlen { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; margin-bottom: 18px; }
.kennzahl {
  background: var(--flaeche);
  border: 1px solid var(--rand);
  border-radius: var(--radius);
  padding: 14px 16px;
  box-shadow: var(--schatten);
}
.kennzahl .beschriftung { font-size: 12px; color: var(--text-schwach); text-transform: uppercase; letter-spacing: .04em; }
.kennzahl .wert { font-size: 24px; font-weight: 600; font-variant-numeric: tabular-nums; margin-top: 4px; }
.kennzahl .zusatz { font-size: 12px; color: var(--text-schwach); margin-top: 2px; }
.positiv { color: var(--positiv); }
.negativ { color: var(--negativ); }
.neutral { color: var(--text-schwach); }

/* --------------------------------------------------- Tabellen */
.tabelle-huelle { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { padding: 8px 10px; text-align: left; border-bottom: 1px solid var(--rand); white-space: nowrap; }
th {
  font-size: 12px; font-weight: 600; color: var(--text-schwach);
  text-transform: uppercase; letter-spacing: .03em;
  position: sticky; top: 0; background: var(--flaeche); z-index: 1;
}
td.zahl, th.zahl { text-align: right; font-variant-numeric: tabular-nums; }
tbody tr:hover { background: var(--flaeche-schwach); }
tfoot td { font-weight: 600; border-top: 2px solid var(--rand); border-bottom: none; }
td.breit, th.breit { white-space: normal; min-width: 220px; }
.code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; color: var(--text-schwach); }

/* --------------------------------------------------- Meldungen */
.meldung {
  padding: 10px 14px; border-radius: var(--radius); margin-bottom: 12px;
  border: 1px solid var(--rand); background: var(--flaeche-schwach); font-size: 14px;
}
.meldung.erfolg { background: var(--erfolg-flaeche); border-color: var(--positiv); }
.meldung.fehler { background: var(--fehler-flaeche); border-color: var(--negativ); }
.meldung.warnung { background: var(--warnung-flaeche); border-color: var(--warnung); }

.hinweisbox {
  border-left: 3px solid var(--warnung);
  background: var(--warnung-flaeche);
  padding: 12px 16px; border-radius: 0 var(--radius) var(--radius) 0; margin-bottom: 18px;
}
.hinweisbox h2 { margin-bottom: 4px; }
.hinweisbox p { margin: 4px 0; font-size: 14px; }

/* --------------------------------------------------- Formulare */
label { display: block; font-size: 13px; color: var(--text-schwach); margin-bottom: 4px; }
input, select, button, textarea {
  font-family: inherit; font-size: 14px;
  padding: 7px 10px; border: 1px solid var(--rand); border-radius: 6px;
  background: var(--flaeche); color: var(--text);
}
input:focus, select:focus { outline: 2px solid var(--akzent); outline-offset: -1px; }
.formularreihe { display: flex; gap: 12px; align-items: flex-end; flex-wrap: wrap; }
.feld { display: flex; flex-direction: column; }

button, .knopf {
  background: var(--akzent); color: #fff; border: 1px solid transparent;
  cursor: pointer; font-weight: 500; padding: 8px 14px; border-radius: 6px; display: inline-block;
}
button:hover, .knopf:hover { filter: brightness(1.08); text-decoration: none; }
button.sekundaer, .knopf.sekundaer { background: var(--flaeche); color: var(--text); border-color: var(--rand); }
button.gefahr { background: var(--negativ); }
button.klein, .knopf.klein { padding: 4px 9px; font-size: 13px; }

/* --------------------------------------------------- Matrix */
.matrix-huelle { overflow: auto; max-height: 72vh; border: 1px solid var(--rand); border-radius: var(--radius); }
.matrix th, .matrix td { border-right: 1px solid var(--rand); }
.matrix th.produktspalte, .matrix td.produktspalte {
  position: sticky; left: 0; background: var(--flaeche); z-index: 2; min-width: 260px; white-space: normal;
}
.matrix thead th { z-index: 3; }
.matrix thead th.produktspalte { z-index: 4; }
.matrix input[type=text] {
  width: 100px; text-align: right; font-variant-numeric: tabular-nums;
  border-color: transparent; background: transparent; padding: 5px 6px;
}
.matrix input[type=text]:hover { border-color: var(--rand); }
.matrix td.luecke { background: var(--warnung-flaeche); }
.matrix td.luecke input { font-weight: 600; }
.zellmenge { font-size: 11px; color: var(--text-schwach); display: block; text-align: right; padding-right: 6px; }

/* --------------------------------------------------- Diagramme */
.diagramm { width: 100%; height: auto; display: block; overflow: visible; }
.diagramm-leer { color: var(--text-schwach); font-size: 14px; padding: 28px 0; text-align: center; }
.diagramm-label { font-size: 12px; fill: var(--text); }
.diagramm-wert { font-size: 12px; fill: var(--text-schwach); font-variant-numeric: tabular-nums; }
.diagramm-achse { font-size: 11px; fill: var(--text-schwach); }
.diagramm-nulllinie { stroke: var(--rand); stroke-width: 1; }
.balken-positiv { fill: var(--akzent); }
.balken-negativ { fill: var(--negativ); }
.verlauf-linie { fill: none; stroke: var(--akzent); stroke-width: 2; stroke-linejoin: round; }
.verlauf-flaeche { fill: var(--akzent); opacity: .12; }
.verlauf-punkt { fill: var(--akzent); }
.saeule-start { fill: var(--akzent); opacity: .75; }
.saeule-summe { fill: var(--akzent); }
.saeule-ab { fill: var(--negativ); }
.saeule-zu { fill: var(--positiv); }
.wasserfall-verbinder { stroke: var(--text-schwach); stroke-width: 1; stroke-dasharray: 3 3; opacity: .6; }

/* --------------------------------------------------- Anmeldung */
.anmeldeseite { max-width: 380px; margin: 12vh auto; }
.anmeldeseite .karte { padding: 28px; }
.anmeldeseite label { margin-top: 12px; }
.anmeldeseite input { width: 100%; }
.anmeldeseite button { width: 100%; margin-top: 18px; padding: 10px; }

.marke-gross { font-size: 20px; font-weight: 650; margin-bottom: 4px; }

/* --------------------------------------------------- Kleinteile */
.abzeichen {
  display: inline-block; padding: 1px 7px; border-radius: 10px; font-size: 12px;
  background: var(--flaeche-schwach); color: var(--text-schwach); border: 1px solid var(--rand);
}
.abzeichen.warnung { background: var(--warnung-flaeche); color: var(--warnung); border-color: var(--warnung); }
.abzeichen.aktiv { background: var(--erfolg-flaeche); color: var(--positiv); border-color: var(--positiv); }
.werkzeugleiste { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; margin-bottom: 18px; }
.abstand { flex: 1; }
.klein { font-size: 13px; color: var(--text-schwach); }
.trenner { height: 1px; background: var(--rand); margin: 18px 0; border: 0; }
ul.liste { margin: 8px 0; padding-left: 20px; font-size: 14px; }
ul.liste li { margin-bottom: 4px; }
