/*
 * Q284 – zweistufige Erwerber-/Gesellschaftersektion
 *
 * Exakt eine orange Hauptsektion enthält exakt eine blaue Untersektion.
 * Deren dunkelblaue Personenkopfzeile schließt die Untersektion bündig nach
 * oben ab; Auswahl, Formular und Rechenelemente liegen innerhalb derselben
 * blauen Hülle.
 */

#berechnung {
  --q283-blue-dark: #0b3764;
  --q283-blue-mid: #215f9a;
  --q283-blue-light: #dceaf7;
  --q283-cyan: #00b0f0;
  --q283-orange: #f59d00;
}

/* Die orange Hauptsektion bleibt der einzige übergeordnete Rahmen. */
#berechnung > .section-title {
  position: relative !important;
  z-index: 4 !important;
  margin: 0 !important;
  border-radius: 18px 18px 0 0 !important;
  box-shadow:
    inset 0 2px 0 rgba(255, 255, 255, .72),
    0 5px 10px rgba(0, 0, 0, .18) !important;
}

#berechnung > .content-card {
  margin: 0 !important;
  padding: 14px !important;
  overflow: hidden !important;
  border: 2px solid var(--q283-orange) !important;
  border-top: 0 !important;
  border-radius: 0 0 18px 18px !important;
  background: linear-gradient(180deg, #fff8ef 0%, #fffdf9 100%) !important;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, .95),
    0 8px 18px rgba(103, 64, 10, .14) !important;
}

/* Eine einzige blaue Untersektion enthält alle zugeordneten Elemente. */
#berechnung .q284-subsection {
  width: 100%;
  min-width: 0;
  box-sizing: border-box;
  overflow: hidden;
  border: 2px solid var(--q283-cyan);
  border-radius: 18px;
  background:
    linear-gradient(180deg, #ffffff 0%, #f2f9ff 18%, #dceaf7 100%);
  box-shadow:
    inset 0 2px 0 rgba(255, 255, 255, .94),
    0 7px 14px rgba(11, 55, 100, .24);
}

#berechnung .q283-person-head {
  position: relative;
  z-index: 3;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  width: 100%;
  min-height: 54px;
  box-sizing: border-box;
  margin: 0;
  padding: 10px 20px;
  border-radius: 15px 15px 0 0;
  border-top: 1px solid rgba(255, 255, 255, .38);
  border-bottom: 2px solid var(--q283-cyan);
  background:
    linear-gradient(180deg, #347fbd 0%, var(--q283-blue-mid) 46%, var(--q283-blue-dark) 100%);
  color: #fff;
  font-family: "Nunito", Arial, sans-serif;
  font-size: clamp(.95rem, 1.16vw, 1.12rem);
  font-weight: 950;
  line-height: 1.24;
  text-align: right;
  text-shadow: 0 2px 3px rgba(0, 0, 0, .58);
  box-shadow:
    inset 0 2px 0 rgba(255, 255, 255, .32),
    0 7px 13px rgba(11, 55, 100, .24);
}

#berechnung .q283-person-head:empty::after {
  content: "1. Erwerber";
}

/* Modus und Anzahl stehen kompakt unter der dynamischen Kopfzeile. */
#berechnung .q283-selector-bar {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: flex-end;
  gap: 14px;
  width: 100%;
  box-sizing: border-box;
  padding: 13px 16px 14px;
  border-bottom: 1.5px solid rgba(0, 176, 240, .68);
  background:
    linear-gradient(180deg, #fafdff 0%, #eef7ff 55%, var(--q283-blue-light) 100%);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, .96),
    0 5px 10px rgba(11, 55, 100, .09);
}

#berechnung .q283-selector-bar .tabs {
  display: flex !important;
  flex: 0 1 auto;
  align-items: stretch;
  gap: 10px !important;
  margin: 0 !important;
}

#berechnung .q283-selector-bar .tabs button {
  min-width: 132px;
  min-height: 43px !important;
  padding: 8px 16px !important;
  border: 1.5px solid rgba(33, 95, 154, .22) !important;
  border-radius: 13px !important;
  background: linear-gradient(180deg, #f8fbff 0%, #e7edf7 100%) !important;
  color: #17345e !important;
  font-size: .94rem !important;
  font-weight: 950 !important;
  line-height: 1.1 !important;
  text-shadow: none !important;
  box-shadow:
    inset 0 2px 0 rgba(255, 255, 255, .88),
    0 5px 10px rgba(18, 35, 68, .16) !important;
}

#berechnung .q283-selector-bar .tabs button.active {
  border-color: rgba(0, 176, 240, .72) !important;
  background:
    linear-gradient(180deg, #347fbd 0%, var(--q283-blue-mid) 50%, var(--q283-blue-dark) 100%) !important;
  color: #fff !important;
  text-shadow: 0 2px 3px rgba(0, 0, 0, .50) !important;
  box-shadow:
    inset 0 2px 0 rgba(255, 255, 255, .35),
    0 6px 12px rgba(11, 55, 100, .28) !important;
}

#berechnung .q283-count-control {
  display: grid;
  flex: 0 1 300px;
  gap: 5px;
  min-width: 230px;
}

#berechnung .q283-count-control label {
  color: var(--q283-blue-mid);
  font-size: .76rem;
  font-weight: 950;
  line-height: 1.08;
}

#berechnung .q283-count-control select {
  width: 100%;
  min-height: 43px;
  box-sizing: border-box;
  padding: 7px 38px 7px 11px;
  border: 1.5px solid rgba(0, 176, 240, .92);
  border-radius: 10px;
  background-color: #fff;
  color: var(--q283-blue-mid);
  font-family: "Nunito", Arial, sans-serif;
  font-size: .91rem;
  font-weight: 900;
  box-shadow:
    inset 0 1px 2px rgba(18, 35, 68, .08),
    0 3px 8px rgba(18, 35, 68, .08);
}

#berechnung .q283-count-control select:focus {
  outline: 0;
  border-color: var(--q283-cyan);
  box-shadow:
    0 0 0 3px rgba(0, 176, 240, .18),
    inset 0 1px 2px rgba(18, 35, 68, .08);
}

/* Die bisherigen, tief verschachtelten Auswahlzeilen werden durch die obere
   Werkzeugzeile ersetzt. Ihre echten Selects bleiben im DOM und steuern
   weiterhin unverändert die Berechnungslogik. */
#privatePanel > .v126-toprow,
#berechnung .q283-original-count-field {
  display: none !important;
}

#berechnung .q283-gbr-settings {
  grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  margin-top: 0 !important;
}

/* Der Formularbereich ist Inhalt der blauen Untersektion und nutzt normalen
   Dokumentfluss. Seine Höhe kalibriert sich nach Modus und Personenzahl. */
#berechnung .q284-subsection > .finance-layout {
  display: grid !important;
  height: auto !important;
  min-height: 0 !important;
  box-sizing: border-box;
  padding: 14px 16px 18px !important;
}

/* Nachgelagerte Rechen- und Ausgabeelemente gehören zur selben blauen
   Untersektion, ohne eine weitere äußere Sektionshülle zu erzeugen. */
#berechnung .q284-subsection > .sale-choice-wrap,
#berechnung .q284-subsection > .subpanel {
  width: auto !important;
  margin-left: 16px !important;
  margin-right: 16px !important;
}

#berechnung .q284-subsection > .subpanel:last-child {
  margin-bottom: 16px !important;
}

#berechnung .finance-layout > div:first-child {
  min-width: 0 !important;
  height: auto !important;
  padding: 0 !important;
  border: 0 !important;
  border-radius: 0 !important;
  background: transparent !important;
  color: var(--q283-blue-mid) !important;
  box-shadow: none !important;
}

#privatePanel,
#gbrPanel,
#gbrMembers {
  min-width: 0 !important;
  height: auto !important;
  max-height: none !important;
}

#privatePanel {
  gap: 14px !important;
}

/* Die erste aktive Person gehört bereits zur hochgezogenen blauen Kopfzeile.
   Darum wird nur diese äußere Kartenhülle abgeflacht. Weitere Personen bleiben
   klar getrennte Karten mit eigener Kopfzeile. */
#privatePanel .q283-leading-card,
#gbrMembers .q283-leading-card {
  margin: 0 !important;
  padding: 12px !important;
  border: 0 !important;
  border-radius: 0 !important;
  background: transparent !important;
  box-shadow: none !important;
  overflow: visible !important;
}

#privatePanel .q283-leading-card > .v126-buyer-title,
#gbrMembers .q283-leading-card > h4 {
  display: none !important;
}

#privatePanel .q283-leading-card > .v126-buyer-note,
#gbrMembers .q283-leading-card > .v185-gbr-note {
  margin-top: 0 !important;
}

/* Der ausgeblendete Originaltitel darf die automatische Höhenberechnung nicht
   mehr beeinflussen. */
#privatePanel .q283-leading-card > .v126-buyer-title .v258-headline-layer,
#gbrMembers .q283-leading-card > h4 .v258-headline-layer {
  display: none !important;
}

@media (max-width: 980px) {
  #berechnung .q283-person-head {
    min-height: 50px;
    padding: 9px 14px;
    font-size: .93rem;
  }

  #berechnung .q283-selector-bar {
    gap: 12px;
    padding: 12px;
  }

  #berechnung .q283-selector-bar .tabs {
    flex: 1 1 auto;
  }

  #berechnung .q283-selector-bar .tabs button {
    flex: 1 1 0;
    min-width: 0;
  }

  #berechnung .q283-count-control {
    flex: 0 1 260px;
    min-width: 205px;
  }

  #berechnung > .content-card {
    padding: 11px !important;
  }

  #berechnung .q284-subsection > .finance-layout {
    padding: 12px !important;
  }

  #berechnung .q284-subsection > .sale-choice-wrap,
  #berechnung .q284-subsection > .subpanel {
    margin-left: 12px !important;
    margin-right: 12px !important;
  }
}

@media (max-width: 620px) {
  #berechnung .q283-person-head {
    justify-content: flex-start;
    min-height: 52px;
    padding: 9px 12px;
    font-size: .86rem;
    text-align: left;
  }

  #berechnung .q283-selector-bar {
    display: grid;
    grid-template-columns: 1fr;
    align-items: stretch;
    gap: 10px;
    padding: 11px 10px 12px;
  }

  #berechnung .q283-selector-bar .tabs {
    width: 100%;
  }

  #berechnung .q283-selector-bar .tabs button {
    min-height: 44px !important;
    padding: 7px 9px !important;
    font-size: .87rem !important;
  }

  #berechnung .q283-count-control {
    width: 100%;
    min-width: 0;
  }

  #berechnung > .content-card {
    padding: 7px !important;
  }

  #berechnung .q284-subsection {
    border-radius: 14px;
  }

  #berechnung .q283-person-head {
    border-radius: 11px 11px 0 0;
  }

  #berechnung .q284-subsection > .finance-layout {
    padding: 10px 8px 14px !important;
  }

  #berechnung .q284-subsection > .sale-choice-wrap,
  #berechnung .q284-subsection > .subpanel {
    margin-left: 8px !important;
    margin-right: 8px !important;
  }

  #berechnung .q283-gbr-settings {
    grid-template-columns: 1fr !important;
  }

  #privatePanel .q283-leading-card,
  #gbrMembers .q283-leading-card {
    padding: 8px 4px !important;
  }
}
