/* Max-Gebot-Rechner. Tokens aus tokens.css, Grundformen aus base.html.
   Gold nur für das Ergebnis und die primäre Aktion, Ampelfarben nur für die
   Gebotsleiter und ihre Zonen, nie als Akzent. Ziffern immer tabellarisch. */

.rechner { --tab: tabular-nums; font-variant-numeric: tabular-nums; }
.rechner-kopf { display: flex; justify-content: space-between; align-items: flex-end; gap: 18px; flex-wrap: wrap; margin-bottom: 18px; }
.rechner-kopf h1 { font-size: 26px; font-weight: 750; letter-spacing: -0.025em; margin: 0 0 6px; }
.rechner-kopf p { margin: 0; color: var(--ink-2); max-width: 62ch; font-size: 14.5px; }

.rechner-spalten { display: grid; grid-template-columns: minmax(0, 3fr) minmax(320px, 2fr); gap: 22px; align-items: start; }

/* ---------- Abschnitte und Felder ---------- */
.abschnitt h2 { font-family: var(--font-display); font-size: 17px; font-weight: 700; text-transform: none; letter-spacing: -0.01em; color: var(--ink); margin-bottom: 16px; }
.abschnitt h2 .nr { display: inline-flex; width: 26px; height: 26px; align-items: center; justify-content: center; border-radius: 999px; background: var(--ink); color: var(--surface); font-size: 13px; font-weight: 700; }
.zeile { display: grid; gap: 14px 16px; margin-bottom: 14px; }
.zeile.zwei { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.zeile.drei { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.feld { min-width: 0; }
.feld > label, .label { display: block; font-size: 12.5px; font-weight: 650; color: var(--ink-2); margin-bottom: 5px; }
.feld input:not([type=radio]):not([type=checkbox]):not([type=range]), .feld select, .vergleich input, .vergleich select {
  width: 100%; min-height: 44px; border-radius: 10px; padding: 9px 13px; font-size: 15px; font-variant-numeric: tabular-nums;
}
.feld input[inputmode], .vergleich .v-preis { text-align: right; }
.einheit { position: relative; }
.einheit input { padding-right: 44px !important; }
.einheit > span { position: absolute; right: 13px; top: 50%; transform: translateY(-50%); color: var(--muted); font-size: 13px; font-weight: 600; pointer-events: none; }
.hilfe { font-size: 12px; color: var(--muted); margin-top: 5px; line-height: 1.4; }
.hilfe .link, .link { background: none; border: 0; padding: 0; color: var(--series-1); font: inherit; font-size: inherit; cursor: pointer; text-decoration: underline; min-height: 0; }
.schalter { display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--ink-2); margin-top: 8px; min-height: 24px; cursor: pointer; }
.schalter input { width: 18px; height: 18px; margin: 0; accent-color: var(--ink); }
.marge-zeile { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; align-items: center; }
.seg label { position: relative; display: inline-flex; }
.seg label input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.seg label span { padding: 7px 16px; border-radius: 999px; font-size: 14px; font-weight: 600; color: var(--ink-2); cursor: pointer; min-height: 38px; display: inline-flex; align-items: center; }
.seg label input:checked + span { background: var(--surface); color: var(--ink); box-shadow: 0 1px 2px rgba(11,11,11,.06); }
.seg label input:focus-visible + span { outline: 2px solid var(--series-1); outline-offset: 2px; }
.seg.klein label span { padding: 6px 12px; min-height: 36px; }
.modus label span { min-height: 44px; padding: 8px 20px; }

.preset-zeile { margin-bottom: 14px; }
.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chips label { position: relative; }
.chips label input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.chips label span { display: inline-flex; align-items: center; min-height: 40px; padding: 7px 14px; border-radius: 999px; border: 1px solid var(--hair); background: var(--surface-sunk); color: var(--ink-2); font-size: 13.5px; font-weight: 600; cursor: pointer; }
.chips label input:checked + span { background: var(--ink); border-color: var(--ink); color: var(--surface); }
.chips label input:focus-visible + span { outline: 2px solid var(--series-1); outline-offset: 2px; }

.erweitert { border-top: 1px solid var(--hair); margin-top: 6px; padding-top: 12px; }
.erweitert summary { cursor: pointer; font-weight: 650; font-size: 14px; color: var(--ink-2); min-height: 44px; display: flex; align-items: center; list-style: none; }
.erweitert summary::before { content: "▸"; margin-right: 8px; font-size: 12px; transition: transform .15s; }
.erweitert[open] summary::before { transform: rotate(90deg); }
.erweitert summary::-webkit-details-marker { display: none; }
.erweitert[open] summary { margin-bottom: 8px; }
.fahrzeug-felder { border-top: 1px dashed var(--hair); padding-top: 14px; }

/* ---------- Vergleiche ---------- */
.vergleiche-kopf { margin: 4px 0 8px; }
.vergleiche-kopf .hilfe { margin-top: 2px; }
.vergleiche-titel, .vergleich { display: grid; grid-template-columns: 110px 150px 130px minmax(0, 1fr) 44px; gap: 8px; align-items: center; }
.vergleiche-titel { font-size: 11.5px; color: var(--muted); font-weight: 650; text-transform: uppercase; letter-spacing: .05em; padding: 0 2px 4px; }
.vergleiche { display: flex; flex-direction: column; gap: 8px; }
.vergleich .v-weg { width: 44px; height: 44px; padding: 0; border-radius: 10px; background: var(--surface-sunk); color: var(--muted); font-size: 20px; line-height: 1; cursor: pointer; }
.vergleich .v-weg:hover { color: var(--critical); }
.vergleich .v-hinweis { grid-column: 1 / -1; font-size: 12px; color: var(--muted); margin-top: -2px; }
.vergleich .v-hinweis:empty { display: none; }
.vergleich.aus input, .vergleich.aus select { color: var(--muted); text-decoration: line-through; }
.vergleich.fehler .v-hinweis { color: var(--critical); }
.vergleiche-fuss { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin: 12px 0 16px; }
.median-streifen { font-size: 13.5px; color: var(--ink-2); font-weight: 600; }
.median-streifen.warnung { color: var(--warning); }

/* ---------- Ergebnis ---------- */
.ergebnis { position: sticky; top: 84px; background: var(--surface); border: 1px solid var(--gold-border); border-radius: 18px; padding: 20px 22px; box-shadow: var(--shadow-card); }
.ergebnis-griff { display: none; }
.status-zeile { min-height: 22px; display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 8px; }
.max-label { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); }
.max-zahl { font-family: var(--font-display); font-size: 64px; font-weight: 800; letter-spacing: -0.035em; line-height: 1; color: var(--gold-text); margin: 4px 0 6px; font-variant-numeric: tabular-nums; }
.ziel-zeile { font-size: 14.5px; color: var(--ink-2); font-weight: 600; }
.ziel-zeile b { color: var(--ink); font-weight: 700; }
.ergebnis-rest { margin-top: 16px; }
.ziel-hilfe { margin: -8px 0 14px; }
.rechner[data-status="unrentabel"] .ziel-hilfe, .rechner[data-status="unvollstaendig"] .ziel-hilfe { display: none; }
.erklaerung { background: var(--surface-sunk); border-radius: 12px; padding: 12px 14px; font-size: 13.5px; color: var(--ink-2); margin-bottom: 14px; line-height: 1.45; }
.erklaerung b { color: var(--ink); }

.rechner[data-status="unrentabel"] .max-zahl, .rechner[data-status="unvollstaendig"] .max-zahl { color: var(--muted); }
.rechner[data-status="unrentabel"] .ergebnis, .rechner[data-status="unvollstaendig"] .ergebnis { border-color: var(--hair); }
.rechner[data-status="unsicher"] .ergebnis { border-style: dashed; }

/* Leiter */
.leiter-block { padding: 14px 0 6px; border-top: 1px solid var(--hair); }
.rechner[data-status="unrentabel"] .leiter-block, .rechner[data-status="unvollstaendig"] .leiter-block { display: none; }
.leiter { position: relative; height: 14px; border-radius: 999px; background: var(--surface-sunk); margin: 44px 0 34px; }
.leiter-zone { position: absolute; top: 0; bottom: 0; }
.leiter-zone.gruen { left: 0; background: color-mix(in srgb, var(--good) 55%, var(--surface)); border-radius: 999px 0 0 999px; }
.leiter-zone.gelb { background: color-mix(in srgb, var(--warning) 60%, var(--surface)); }
.leiter-zone.rot { right: 0; background: color-mix(in srgb, var(--critical) 45%, var(--surface)); border-radius: 0 999px 999px 0; }
.leiter-marke { position: absolute; top: -8px; width: 2px; height: 30px; background: var(--ink); transform: translateX(-1px); }
.leiter-marke span { position: absolute; top: 32px; left: 50%; transform: translateX(-50%); font-size: 11.5px; font-weight: 700; color: var(--ink-2); white-space: nowrap; font-variant-numeric: tabular-nums; }
.leiter-marke.be span { transform: none; left: auto; right: 0; }
.leiter-marke.max { background: var(--gold); width: 3px; }
.leiter-marke.max span { color: var(--gold-text); }
/* Liegen zwei Marken näher als 8 % der Skala, wandert das linke Label über die Leiter,
   rechtsbündig zur Marke, damit sich die Beträge nicht überlagern. */
.leiter-marke.oben span { top: -20px; left: auto; right: 0; transform: none; }
.leiter-marker { position: absolute; top: -12px; width: 0; height: 0; border-left: 9px solid transparent; border-right: 9px solid transparent; border-top: 12px solid var(--ink); transform: translateX(-9px); }
.leiter-marker::after { content: ""; position: absolute; left: -2px; top: -13px; width: 4px; height: 26px; background: var(--ink); }
.leiter-marker span { position: absolute; top: -36px; left: 9px; transform: translateX(-50%); font-size: 11.5px; font-weight: 700; color: var(--ink); white-space: nowrap; font-variant-numeric: tabular-nums; }
.leiter-marker.rechts span { transform: translateX(-100%); }
.feld.aktuell { margin-top: 4px; }
.leiter-satz { margin-top: 8px; font-size: 15px; font-weight: 650; line-height: 1.4; min-height: 0; display: flex; gap: 8px; align-items: baseline; }
.leiter-satz:empty { display: none; }
.leiter-satz .zone { display: inline-block; font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; padding: 2px 8px; border-radius: 999px; border: 1px solid transparent; white-space: nowrap; }
.leiter-satz.gruen .zone { color: var(--good-text); background: color-mix(in srgb, var(--good) 13%, transparent); border-color: color-mix(in srgb, var(--good) 30%, transparent); }
.leiter-satz.gelb .zone { color: var(--ink); background: color-mix(in srgb, var(--warning) 20%, transparent); border-color: color-mix(in srgb, var(--warning) 40%, transparent); }
.leiter-satz.rot .zone { color: var(--critical); background: color-mix(in srgb, var(--critical) 12%, transparent); border-color: color-mix(in srgb, var(--critical) 30%, transparent); }
.leiter-satz.rot { color: var(--critical); }

/* Aufschlüsselung */
.aufschluesselung { border-top: 1px solid var(--hair); padding-top: 14px; margin-top: 10px; }
.aufschluesselung h3 { font-family: var(--font-text); font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); margin: 0 0 8px; }
.aufschluesselung ol { list-style: none; margin: 0; padding: 0; }
.aufschluesselung li { display: flex; }
.aufschluesselung button { all: unset; display: flex; justify-content: space-between; align-items: center; gap: 12px; width: 100%; padding: 7px 6px; border-radius: 8px; font-size: 14px; color: var(--ink-2); cursor: pointer; min-height: 36px; box-sizing: border-box; }
.aufschluesselung button:hover { background: var(--surface-sunk); color: var(--ink); }
.aufschluesselung button:focus-visible { outline: 2px solid var(--series-1); outline-offset: -2px; }
.aufschluesselung .op { display: inline-block; width: 16px; color: var(--muted); font-weight: 700; }
.aufschluesselung .wert { font-weight: 650; color: var(--ink); white-space: nowrap; }
.aufschluesselung small { font-size: 12px; color: var(--muted); font-weight: 500; }
.aufschluesselung li.summe button { border-top: 1px solid var(--hair); margin-top: 4px; padding-top: 10px; font-weight: 700; color: var(--ink); cursor: default; }
.aufschluesselung li.summe .wert { color: var(--gold-text); font-family: var(--font-display); font-size: 18px; }
.aufschluesselung li.summe button:hover { background: none; }
.aufschluesselung li.negativ .wert { color: var(--critical); }

/* Sensitivität */
.sensitivitaet { border-top: 1px solid var(--hair); padding-top: 14px; margin-top: 12px; }
.sensitivitaet label { display: block; font-size: 13px; color: var(--ink-2); margin-bottom: 6px; }
.sensitivitaet label strong { color: var(--ink); font-variant-numeric: tabular-nums; }
.sensitivitaet input[type=range] { width: 100%; accent-color: var(--gold); padding: 0; border: 0; background: transparent; min-height: 32px; }
.sens-skala { display: flex; justify-content: space-between; font-size: 11px; color: var(--muted); }

.aktionen { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; border-top: 1px solid var(--hair); padding-top: 14px; margin-top: 14px; }
.aktionen .btn { min-height: 40px; }
.toast { font-size: 12.5px; color: var(--good-text); font-weight: 600; }
.rechner-fuss { margin-top: 18px; font-size: 12.5px; color: var(--muted); max-width: 80ch; }

/* ---------- Mobil: Ergebnis als Bottom-Sheet ---------- */
@media (max-width: 900px) {
  .rechner-spalten { grid-template-columns: 1fr; }
  .rechner { padding-bottom: 150px; }
  .ergebnis {
    position: fixed; left: 0; right: 0; bottom: 0; top: auto; z-index: 40;
    border-radius: 18px 18px 0 0; border-bottom: 0; padding: 6px 18px 18px;
    box-shadow: 0 -8px 30px rgba(11,11,11,.14);
    max-height: 84vh; overflow-y: auto; overscroll-behavior: contain;
  }
  .ergebnis:not(.offen) { overflow: hidden; }
  .ergebnis-griff { display: flex; flex-direction: column; align-items: center; gap: 3px; width: 100%; min-height: 44px; background: none; border: 0; padding: 4px 0 0; color: var(--ink-2); font-size: 13px; font-weight: 650; cursor: pointer; }
  .griff-balken { width: 42px; height: 4px; border-radius: 999px; background: var(--axis); }
  .griff-pfeil { display: inline-block; transform: rotate(-90deg); transition: transform .15s; }
  .ergebnis.offen .griff-pfeil { transform: rotate(90deg); }
  .ergebnis-kopf { display: grid; grid-template-columns: 1fr auto; grid-template-areas: "status status" "label ziel" "zahl ziel"; align-items: end; column-gap: 12px; }
  .status-zeile { grid-area: status; margin-bottom: 4px; }
  .max-label { grid-area: label; }
  .max-zahl { grid-area: zahl; font-size: 44px; margin: 2px 0 0; }
  .ziel-zeile { grid-area: ziel; text-align: right; font-size: 13px; line-height: 1.35; }
  .ziel-zeile > span { display: block; }
  .ziel-zeile .sep { display: none; }
  .ergebnis-rest { display: none; }
  .ergebnis.offen .ergebnis-rest { display: block; }
  .ergebnis.offen .ergebnis-kopf { grid-template-areas: "status status" "label label" "zahl ziel"; }
  .ergebnis.offen .max-zahl { font-size: 52px; }
}
@media (max-width: 620px) {
  .rechner-kopf h1 { font-size: 22px; }
  .zeile.zwei, .zeile.drei { grid-template-columns: 1fr; gap: 12px; }
  .marge-zeile { grid-template-columns: minmax(0, 1fr) auto; }
  .vergleiche-titel { display: none; }
  .vergleich { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) 44px; grid-template-areas: "preis datum weg" "zustand plattform plattform" "hinweis hinweis hinweis"; }
  .vergleich .einheit { grid-area: preis; }
  .vergleich .v-datum { grid-area: datum; }
  .vergleich .v-zustand { grid-area: zustand; }
  .vergleich .v-plattform { grid-area: plattform; }
  .vergleich .v-weg { grid-area: weg; }
  .vergleich .v-hinweis { grid-area: hinweis; }
  .vergleich { padding-bottom: 10px; border-bottom: 1px dashed var(--hair); }
  .vergleich:last-child { border-bottom: 0; }
  .vergleich input, .vergleich select { font-size: 16px; }
  .modus { width: 100%; }
  .modus label { flex: 1; }
  .modus label span { width: 100%; justify-content: center; }
  .leiter-marke span { font-size: 10.5px; }
}

/* ---------- Druck ---------- */
@media print {
  header.top, .ergebnis-griff, .aktionen, .sensitivitaet, .vergleich .v-weg, #vergleich-plus, .rechner-fuss { display: none !important; }
  .rechner-spalten { grid-template-columns: 1fr; gap: 12px; }
  .ergebnis { position: static; max-height: none; overflow: visible; box-shadow: none; border: 1px solid #999; }
  .ergebnis-rest { display: block !important; }
  .card { box-shadow: none; border: 1px solid #ccc; break-inside: avoid; }
  .erweitert { display: block; }
  .erweitert:not([open]) > *:not(summary) { display: block; }
  .rechner { padding-bottom: 0; }
}
