/* Marktlage – Gestaltung
   Aufbau: schmale Kopfzeile, darunter Haltung (Ergebnis) vor Einzelwerten vor Rohdaten.
   Farben nur über Token, Zustandsfarben getrennt vom Akzent. */
:root {
  --bg: #f2f4f6;
  --flaeche: #ffffff;
  --flaeche-2: #eceff3;
  --tinte: #14202b;
  --tinte-2: #46576a;
  --tinte-3: #758596;
  --linie: #d9e0e7;
  --akzent: #1d5b86;
  --serie-2: #0d7a6b;
  --obergrenze: rgba(29, 91, 134, 0.13);
  --gut: #22784a;
  --gut-bg: #e1f1e7;
  --mittel: #94650a;
  --mittel-bg: #faefd6;
  --schlecht: #b23a30;
  --schlecht-bg: #f8e2df;
  --neutral: #4e5f70;
  --neutral-bg: #e6ebf0;
  --schatten: 0 1px 2px rgba(20, 32, 43, 0.06), 0 1px 1px rgba(20, 32, 43, 0.04);
  --schrift: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", Consolas, "Liberation Mono", monospace;
  --radius: 10px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0d1318;
    --flaeche: #141c23;
    --flaeche-2: #1b252e;
    --tinte: #e3eaf0;
    --tinte-2: #aab8c5;
    --tinte-3: #7c8c9b;
    --linie: #27333e;
    --akzent: #6badda;
    --serie-2: #3cc0ab;
    --obergrenze: rgba(107, 173, 218, 0.16);
    --gut: #5cc88b;
    --gut-bg: #143021;
    --mittel: #e2b354;
    --mittel-bg: #33290f;
    --schlecht: #ee8075;
    --schlecht-bg: #3a1b18;
    --neutral: #a7b5c2;
    --neutral-bg: #1f2a33;
    --schatten: none;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--tinte);
  font: 15px/1.5 var(--schrift);
  font-variant-numeric: tabular-nums;
}
.wrap {
  max-width: 1180px;
  margin: 0 auto;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
}
h1, h2, h3 { margin: 0; line-height: 1.2; text-wrap: balance; }
h2 { font-size: 17px; font-weight: 650; letter-spacing: -0.01em; }
p { margin: 0; }
a { color: var(--akzent); }
:focus-visible { outline: 2px solid var(--akzent); outline-offset: 2px; border-radius: 4px; }

/* Kopfzeile */
.kopf { background: var(--flaeche); border-bottom: 1px solid var(--linie); }
.kopf-in { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 24px; padding-block: 14px; }
.marke { display: flex; align-items: center; gap: 10px; }
.marke svg { width: 28px; height: 28px; flex: none; }
.marke h1 { font-size: 19px; font-weight: 700; letter-spacing: -0.02em; }
.marke .unter { color: var(--tinte-3); font-size: 13px; }
.stand { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px; color: var(--tinte-2); font-size: 13px; }

/* Reiter */
.reiter { display: flex; gap: 4px; overflow-x: auto; max-width: 100%; }
.reiter a {
  display: inline-flex; align-items: center; min-height: 36px; padding: 6px 14px; border-radius: 8px;
  color: var(--tinte-2); font-weight: 600; font-size: 14px; text-decoration: none; white-space: nowrap;
}
.reiter a:hover { color: var(--tinte); background: var(--flaeche-2); }
.reiter a[aria-current="page"] { color: var(--akzent); background: var(--flaeche-2); box-shadow: inset 0 -2px 0 var(--akzent); }

main.wrap { display: grid; gap: 20px; padding-block: 22px 40px; }
.ansicht { display: grid; gap: 20px; min-width: 0; }
.ansicht > * { min-width: 0; }
.rechtliches { color: var(--tinte-3); font-size: 13px; }

/* Flächen */
.karte {
  background: var(--flaeche);
  border: 1px solid var(--linie);
  border-radius: var(--radius);
  box-shadow: var(--schatten);
  padding: 20px;
  min-width: 0;
}
.karte-kopf { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 6px 16px; margin-bottom: 14px; }
.karte-kopf .erkl { color: var(--tinte-3); font-size: 13px; }
.paar { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 440px), 1fr)); gap: 20px; }
.paar > * { min-width: 0; }
.paar.oben { align-items: start; }

.etikett { font-size: 12px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--tinte-3); }

/* Zustands-Plaketten */
.plakette {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 10px; border-radius: 999px;
  font-size: 13px; font-weight: 600; line-height: 1.4; white-space: nowrap;
  background: var(--neutral-bg); color: var(--neutral);
}
.plakette::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.plakette.gut { background: var(--gut-bg); color: var(--gut); }
.plakette.mittel { background: var(--mittel-bg); color: var(--mittel); }
.plakette.schlecht { background: var(--schlecht-bg); color: var(--schlecht); }
.plakette.klein { font-size: 12px; padding: 2px 8px; }

/* Haltung */
.haltung { display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 6fr); gap: 28px; padding: 24px; }
.haltung-zahl { display: flex; align-items: baseline; gap: 6px; margin: 6px 0 10px; }
.haltung-zahl .gross { font-size: 56px; font-weight: 700; letter-spacing: -0.035em; line-height: 1; }
.haltung-zahl .einheit { font-size: 24px; font-weight: 600; color: var(--tinte-2); }
.haltung-reihe { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.pegel { position: relative; margin: 22px 0 6px; height: 12px; border-radius: 6px; background: var(--flaeche-2); }
.pegel-fuellung { position: absolute; inset: 0 auto 0 0; border-radius: 6px; background: var(--akzent); }
.pegel-geist { position: absolute; top: -5px; bottom: -5px; width: 2px; margin-left: -1px; background: var(--tinte-3); }
.pegel-achse { display: flex; justify-content: space-between; color: var(--tinte-3); font-size: 12px; }
.pegel-legende { display: flex; flex-wrap: wrap; gap: 4px 16px; margin-top: 10px; font-size: 13px; color: var(--tinte-2); }
.pegel-legende span { display: inline-flex; align-items: center; gap: 6px; }
.muster { display: inline-block; width: 14px; height: 8px; border-radius: 2px; background: var(--akzent); }
.muster.strich { width: 2px; height: 14px; border-radius: 0; background: var(--tinte-3); }
.haltung-text { display: grid; gap: 14px; align-content: start; font-size: 14.5px; color: var(--tinte-2); max-width: 64ch; }
.haltung-text strong { color: var(--tinte); font-weight: 600; }
.rechnung { display: grid; gap: 4px; padding: 12px 14px; border-radius: 8px; background: var(--flaeche-2); font-size: 13.5px; }
.rechnung div { display: flex; justify-content: space-between; gap: 12px; }
.rechnung .summe { border-top: 1px solid var(--linie); padding-top: 4px; margin-top: 2px; font-weight: 600; color: var(--tinte); }
.hinweis-klein { font-size: 13px; color: var(--tinte-3); }

/* Bewertungs-Karten */
.wert { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 14px; margin-bottom: 4px; }
.wert .gross { font-size: 40px; font-weight: 700; letter-spacing: -0.03em; line-height: 1.05; }
.wert .von { font-size: 16px; color: var(--tinte-3); font-weight: 500; }
.richtwert { color: var(--tinte-2); font-size: 13.5px; }
.skala { position: relative; display: flex; gap: 2px; height: 8px; margin: 16px 0 4px; }
.skala span { border-radius: 2px; opacity: 0.85; min-width: 0; }
.skala .z0 { background: var(--schlecht); }
.skala .z1 { background: var(--mittel); }
.skala .z2 { background: var(--neutral); opacity: 0.5; }
.skala .z3 { background: var(--gut); opacity: 0.55; }
.skala .z4 { background: var(--gut); }
.skala-zeiger { position: absolute; top: -6px; width: 0; height: 0; margin-left: -7px; border-left: 7px solid transparent; border-right: 7px solid transparent; border-top: 8px solid var(--tinte); }
.skala-achse-frei { position: relative; height: 16px; font-size: 11px; color: var(--tinte-3); }
.skala-achse-frei span { position: absolute; top: 0; transform: translateX(-50%); }
.skala-achse-frei span:first-child { transform: none; }
.skala-achse-frei span:last-child { transform: translateX(-100%); }
.warnungen { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }

.teile { list-style: none; margin: 18px 0 0; padding: 0; display: grid; }
.teil { display: grid; grid-template-columns: minmax(0, 1fr) 132px; gap: 4px 16px; padding: 10px 0; border-top: 1px solid var(--linie); }
.teil-name { font-weight: 600; font-size: 14px; }
.teil-name .gewicht { font-weight: 500; color: var(--tinte-3); font-size: 12px; margin-left: 6px; }
.teil-detail { grid-column: 1; font-size: 13px; color: var(--tinte-2); }
.teil-balken { grid-column: 2; grid-row: 1 / span 2; display: grid; grid-template-columns: 1fr 34px; align-items: center; gap: 8px; }
.balken { height: 6px; border-radius: 3px; background: var(--flaeche-2); position: relative; overflow: hidden; }
.balken i { position: absolute; inset: 0 auto 0 0; border-radius: 3px; background: var(--neutral); }
.balken i.gut { background: var(--gut); }
.balken i.mittel { background: var(--mittel); }
.balken i.schlecht { background: var(--schlecht); }
.teil-zahl { text-align: right; font-weight: 650; font-size: 14px; }
.teil.fehlt .teil-zahl, .teil.fehlt .teil-name { color: var(--tinte-3); }

/* Zeitraum-Auswahl */
.zeitraum { display: inline-flex; padding: 3px; gap: 2px; border-radius: 8px; background: var(--flaeche-2); }
.zeitraum button {
  font: inherit; font-size: 13px; font-weight: 600; color: var(--tinte-2);
  border: 0; background: transparent; padding: 5px 12px; border-radius: 6px; cursor: pointer; min-height: 32px;
}
.zeitraum button:hover { color: var(--tinte); }
.zeitraum button[aria-pressed="true"] { background: var(--flaeche); color: var(--tinte); box-shadow: var(--schatten); }
.abschnitt-kopf { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px 16px; }
.abschnitt-kopf h2 { font-size: 15px; color: var(--tinte-2); font-weight: 600; }

/* Diagramme */
.diagramm { position: relative; width: 100%; }
.diagramm svg { display: block; width: 100%; height: auto; overflow: visible; }
.diagramm text { fill: var(--tinte-3); font: 11px var(--schrift); font-variant-numeric: tabular-nums; }
.diagramm .gitter { stroke: var(--linie); stroke-width: 1; }
.diagramm .ref { stroke: var(--tinte-3); stroke-width: 1; stroke-dasharray: 3 4; }
.diagramm .ref-text { fill: var(--tinte-3); font-size: 11px; }
.diagramm .fadenkreuz { stroke: var(--tinte-3); stroke-width: 1; }
.legende { display: flex; flex-wrap: wrap; gap: 4px 16px; margin: 0 0 10px; font-size: 13px; color: var(--tinte-2); }
.legende span { display: inline-flex; align-items: center; gap: 6px; }
.legende i { display: inline-block; width: 14px; height: 3px; border-radius: 2px; }
.legende i.flaeche { height: 10px; border-radius: 2px; }
.tip {
  position: fixed; z-index: 20; pointer-events: none;
  background: var(--flaeche); color: var(--tinte);
  border: 1px solid var(--linie); border-radius: 8px; box-shadow: 0 6px 20px rgba(0, 0, 0, 0.16);
  padding: 8px 10px; font-size: 12.5px; min-width: 150px; max-width: 260px;
}
.tip b { display: block; margin-bottom: 4px; font-weight: 600; }
.tip div { display: flex; justify-content: space-between; gap: 14px; }
.tip i { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; }

/* Sektoren */
.tabelle-huelle { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: left; font-size: 12px; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase; color: var(--tinte-3); padding: 0 10px 8px; border-bottom: 1px solid var(--linie); white-space: nowrap; }
td { padding: 9px 10px; border-bottom: 1px solid var(--linie); white-space: nowrap; }
tr:last-child td { border-bottom: 0; }
td.zahl, th.zahl { text-align: right; }
td.quote { min-width: 180px; width: 36%; }
.quote-balken { position: relative; height: 10px; border-radius: 3px; background: var(--flaeche-2); }
.quote-balken i { position: absolute; inset: 0 auto 0 0; border-radius: 3px; background: var(--serie-2); }
.quote-balken b { position: absolute; top: -3px; bottom: -3px; width: 2px; margin-left: -1px; background: var(--tinte); }
.quote-balken u { position: absolute; top: 0; bottom: 0; width: 1px; background: var(--tinte-3); opacity: 0.6; }
.gruppe { color: var(--tinte-3); font-size: 13px; }
.pfeil-auf { color: var(--gut); }
.pfeil-ab { color: var(--schlecht); }

/* Fuss */
.fuss { display: grid; gap: 12px; color: var(--tinte-2); font-size: 13.5px; max-width: 80ch; }
.fuss h2 { font-size: 15px; color: var(--tinte); }
.fuss ul { margin: 0; padding-left: 18px; display: grid; gap: 4px; }
details summary { cursor: pointer; font-weight: 600; color: var(--tinte); }
details[open] summary { margin-bottom: 8px; }

/* Formulare (Rechner) */
.formular { display: grid; gap: 14px; }
.feld { display: grid; gap: 4px; }
.feld label { font-weight: 600; font-size: 14px; }
.feld-hinweis { font-size: 12.5px; color: var(--tinte-3); }
.eingabe { display: flex; align-items: stretch; border: 1px solid var(--linie); border-radius: 8px; background: var(--flaeche); overflow: hidden; }
.eingabe:focus-within { border-color: var(--akzent); box-shadow: 0 0 0 3px var(--obergrenze); }
.eingabe input, .eingabe select {
  font: inherit; font-size: 15px; color: var(--tinte); background: transparent; border: 0; outline: none;
  padding: 9px 12px; min-height: 42px; min-width: 0;
}
.eingabe input { flex: 1; text-align: right; font-variant-numeric: tabular-nums; }
.eingabe select { border-left: 1px solid var(--linie); background: var(--flaeche-2); cursor: pointer; }
.einheit-klein { display: flex; align-items: center; padding: 0 12px; color: var(--tinte-3); background: var(--flaeche-2); border-left: 1px solid var(--linie); min-width: 42px; justify-content: center; }
.haken { display: inline-flex !important; align-items: center; gap: 8px; font-weight: 600; cursor: pointer; }
.haken input { width: 18px; height: 18px; accent-color: var(--akzent); }
.methode { margin-bottom: 8px; }
.methode-erkl { margin-bottom: 16px; max-width: 60ch; }
.grenzen { border-top: 1px solid var(--linie); padding-top: 12px; }
.grenzen .formular { margin-top: 4px; }
.knopf-leise {
  font: inherit; font-size: 13px; font-weight: 600; color: var(--akzent); background: transparent;
  border: 1px solid var(--linie); border-radius: 8px; padding: 6px 12px; cursor: pointer; min-height: 34px;
}
.knopf-leise:hover { background: var(--flaeche-2); }
.rechner { align-items: start; }
.rechner-ergebnis { display: grid; gap: 14px; align-content: start; }
.rechner-ergebnis .karte-kopf { margin-bottom: 0; }
.meldung { padding: 10px 14px; border-radius: 8px; font-size: 14px; background: var(--neutral-bg); }
.meldung.schlecht { background: var(--schlecht-bg); }
.meldung.mittel { background: var(--mittel-bg); }
.meldung ul { margin: 6px 0 0; padding-left: 18px; }
.grenzliste { list-style: none; margin: 0; padding: 0; display: grid; font-size: 13.5px; }
.grenzliste li { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 7px 0; border-top: 1px solid var(--linie); color: var(--tinte-2); }
.grenzliste li span:last-child { display: inline-flex; gap: 8px; align-items: center; white-space: nowrap; color: var(--tinte); }
.grenzliste li.bindend span:first-child { color: var(--tinte); font-weight: 600; }

.fehler { border-color: var(--schlecht); background: var(--schlecht-bg); color: var(--tinte); }
.laden { color: var(--tinte-3); }

@media (max-width: 760px) {
  .haltung { grid-template-columns: 1fr; gap: 20px; padding: 18px; }
  .haltung-zahl .gross { font-size: 48px; }
  .karte { padding: 16px; }
  .teil { grid-template-columns: minmax(0, 1fr) 110px; gap: 4px 10px; }
  td.quote { min-width: 120px; }
}
@media (prefers-reduced-motion: no-preference) {
  .pegel-fuellung, .balken i, .quote-balken i { transition: width 0.4s ease; }
}
