:root {
  --bg: #eef6fb;
  --panel: rgba(255, 255, 255, 0.96);
  --panel-strong: rgba(255, 255, 255, 0.99);
  --ink: #111111;
  --muted: #5d6f7d;
  --line: rgba(17, 17, 17, 0.12);
  --accent: #0f0f0f;
  --danger: #a11212;
  --shadow: 0 18px 55px rgba(27, 57, 79, 0.16);
  --radius-lg: 28px;
  --radius-md: 18px;
}

* { box-sizing: border-box; }

html { min-height: 100%; }

body {
  min-height: 100%;
  margin: 0;
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background:
    radial-gradient(1300px 760px at 85% -15%, rgba(255, 255, 255, 0.92), rgba(255, 255, 255, 0) 70%),
    radial-gradient(980px 560px at -10% 10%, rgba(187, 218, 240, 0.26), rgba(187, 218, 240, 0) 74%),
    var(--bg) url("../img/background.svg") center / cover fixed no-repeat;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  background: linear-gradient(138deg, rgba(239, 247, 252, 0.92), rgba(251, 254, 255, 0.88) 48%, rgba(239, 247, 252, 0.9));
  pointer-events: none;
}

body::after {
  content: "";
  position: fixed;
  inset: 0;
  background: rgba(255, 255, 255, 0.18);
  pointer-events: none;
}

.shell {
  position: relative;
  z-index: 1;
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 54px 0 42px;
}

.hero {
  width: min(820px, 100%);
  color: #0f3658;
  margin-bottom: 28px;
}

.eyebrow {
  margin: 0 0 12px;
  font-size: 0.78rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: rgba(18, 61, 96, 0.74);
}

h1, h2, p { margin-top: 0; }

h1 {
  margin-bottom: 16px;
  font-size: clamp(2.3rem, 6vw, 5.3rem);
  line-height: 0.95;
  letter-spacing: -0.075em;
  max-width: 900px;
}

.intro {
  margin-bottom: 0;
  color: rgba(28, 79, 116, 0.92);
  font-size: clamp(1rem, 2vw, 1.18rem);
  line-height: 1.6;
  max-width: 700px;
}

.panel,
.table-panel {
  border: 1px solid rgba(129, 168, 197, 0.34);
  background: var(--panel);
  backdrop-filter: blur(28px);
  box-shadow: var(--shadow);
  border-radius: var(--radius-lg);
}

.grid {
  display: grid;
  grid-template-columns: minmax(280px, 0.9fr) minmax(360px, 1.35fr);
  gap: 22px;
  padding: 22px;
}

.form,
.results {
  border-radius: var(--radius-md);
}

.form {
  background: var(--panel-strong);
  padding: 24px;
  border: 1px solid var(--line);
}

.form-header,
.table-header,
.chart-title {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
}

.form-header h2,
.table-header h2,
.chart-title h2 {
  font-size: 1.05rem;
  margin-bottom: 18px;
  letter-spacing: -0.03em;
}

.form-header p,
.table-header p,
.chart-title span {
  color: var(--muted);
  font-size: 0.88rem;
  margin-bottom: 18px;
}

fieldset {
  border: 0;
  margin: 0 0 22px;
  padding: 0;
  min-width: 0;
}

legend {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0;
  margin-bottom: 8px;
  font-size: 1.02rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

legend small { color: var(--muted); font-weight: 400; }

.step {
  display: inline-grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: #0f3658;
  color: #fff;
  font-size: 0.8rem;
}

.field {
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
}

.field[hidden] { display: none; }

fieldset .field:last-child { border-bottom: 0; }

label {
  display: block;
  margin-bottom: 6px;
  font-size: 0.95rem;
  font-weight: 600;
  color: #222;
}

.input-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
}

.unit {
  flex: 0 0 auto;
  min-width: 72px;
  font-size: 0.85rem;
  color: var(--muted);
}

.hint {
  margin: 6px 0 0;
  font-size: 0.82rem;
  line-height: 1.45;
  color: var(--muted);
}

.field-error {
  margin: 6px 0 0;
  font-size: 0.84rem;
  color: var(--danger);
}

.field.invalid input { border-color: var(--danger); }

.presets {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
  font-size: 0.85rem;
  color: var(--muted);
}

.chip {
  border: 1px solid rgba(15, 54, 88, 0.3);
  background: #fff;
  color: #0f3658;
  border-radius: 999px;
  padding: 6px 12px;
  font: inherit;
  cursor: pointer;
}

.chip:hover, .chip:focus-visible { background: #0f3658; color: #fff; outline: none; }

.how {
  list-style: none;
  padding: 0;
  margin: 18px 0 0;
  display: grid;
  gap: 6px;
  color: rgba(28, 79, 116, 0.92);
  font-size: 0.95rem;
}

.verdict {
  margin: 12px 0 0;
  line-height: 1.5;
  color: #333;
}

.chart-help {
  margin: -8px 0 10px;
  font-size: 0.85rem;
  line-height: 1.45;
  color: var(--muted);
}

.marker {
  stroke: #0f3658;
  stroke-width: 1.5;
  stroke-dasharray: 5 4;
}

details summary {
  cursor: pointer;
  list-style: none;
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 16px;
}

details summary::-webkit-details-marker { display: none; }
details summary::before { content: "▸"; margin-right: 8px; }
details[open] summary::before { content: "▾"; }

.table-title { flex: 1; font-size: 1.05rem; font-weight: 700; }
.table-sub { color: var(--muted); font-size: 0.88rem; }
.table-help { margin: 14px 0; color: var(--muted); font-size: 0.88rem; }

tr.milestone td { background: #eef6fb; font-weight: 600; }

.disclaimer {
  margin: 18px 4px 0;
  font-size: 0.8rem;
  color: var(--muted);
}

input, select {
  width: 100%;
  border: 1px solid rgba(17,17,17,0.14);
  background: #fff;
  color: var(--ink);
  border-radius: 12px;
  padding: 11px 12px;
  font: inherit;
  text-align: right;
  outline: none;
  transition: border-color 160ms ease, box-shadow 160ms ease;
}

select { text-align: left; }

input:focus, select:focus {
  border-color: rgba(17,17,17,0.55);
  box-shadow: 0 0 0 4px rgba(17,17,17,0.08);
}

.results {
  display: grid;
  gap: 16px;
}

.result-card,
.chart-card {
  background: var(--panel-strong);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 20px;
}

.result-card span {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 0.86rem;
}

.result-card strong {
  display: block;
  font-size: clamp(1.45rem, 4vw, 3rem);
  line-height: 1.05;
  letter-spacing: -0.055em;
}

.result-card small {
  display: block;
  color: var(--muted);
  margin-top: 10px;
}

.primary {
  min-height: 150px;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.kpis {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
}

.kpis .result-card strong { font-size: 1.25rem; }

.chart-card { min-height: 330px; }

#balanceChart {
  width: 100%;
  height: 260px;
  overflow: visible;
}

.axis, .grid-line {
  stroke: rgba(17,17,17,0.13);
  stroke-width: 1;
}

.chart-line {
  fill: none;
  stroke: #111;
  stroke-width: 4;
  stroke-linejoin: round;
  stroke-linecap: round;
}

.chart-area {
  fill: rgba(17,17,17,0.06);
}

.chart-label {
  fill: #555;
  font-size: 12px;
}

.error {
  padding: 14px 16px;
  border-radius: 14px;
  background: rgba(161,18,18,0.1);
  color: var(--danger);
  border: 1px solid rgba(161,18,18,0.2);
  font-size: 0.9rem;
}

.hidden { display: none; }

.table-panel {
  margin-top: 22px;
  padding: 22px;
}

.table-wrap {
  overflow: auto;
  border-radius: 18px;
  border: 1px solid var(--line);
  background: #fff;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 820px;
}

th, td {
  padding: 12px 14px;
  border-bottom: 1px solid rgba(17,17,17,0.08);
  text-align: right;
  white-space: nowrap;
}

th:first-child, td:first-child { text-align: left; }

th {
  white-space: normal;
  position: sticky;
  top: 0;
  background: #f5f5f5;
  color: #333;
  font-size: 0.78rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

tbody tr:last-child td { border-bottom: 0; }

tbody tr:hover td { background: #f8f8f8; }

@media (max-width: 900px) {
  .grid { grid-template-columns: 1fr; }
  .kpis { grid-template-columns: 1fr; }
  .shell { width: min(100% - 22px, 1180px); padding-top: 32px; }
}

.text-input { text-align: left; }

.tax-note {
  display: block;
  margin-top: 6px;
  color: var(--muted);
  font-size: 0.82rem;
}

.sticky-bar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 20;
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 14px;
  padding: 10px 16px;
  background: rgba(255, 255, 255, 0.97);
  border-bottom: 1px solid rgba(129, 168, 197, 0.45);
  box-shadow: 0 6px 24px rgba(27, 57, 79, 0.14);
  backdrop-filter: blur(12px);
  cursor: pointer;
}

.sticky-bar[hidden] { display: none; }

.sticky-label { color: var(--muted); font-size: 0.88rem; }

.sticky-bar strong {
  font-size: 1.35rem;
  letter-spacing: -0.04em;
  color: #0f3658;
}

@media (max-width: 600px) {
  .sticky-bar { flex-direction: column; align-items: center; gap: 0; padding: 6px 12px; }
  .sticky-bar strong { font-size: 1.2rem; }
}

.tax-compare { padding: 22px; }
#taxChart { width: 100%; height: auto; overflow: visible; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 18px; margin: 8px 0 4px; font-size: 0.86rem; color: var(--muted); }
.legend .sw { display: inline-block; width: 12px; height: 12px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }
.sw-income, .bar-income { fill: #2f6f9f; background: #2f6f9f; }
.sw-capital, .bar-capital { fill: #e08a2b; background: #e08a2b; }
.sw-wealth, .bar-wealth { fill: #5b9b6a; background: #5b9b6a; }
.bar-outline { fill: none; stroke: #111; stroke-width: 1.5; stroke-dasharray: 4 3; }
.bar-group:hover rect:not(.bar-outline) { opacity: 0.8; }

.results { align-content: start; align-self: start; }
.primary { min-height: 0; }

/* Layout: Eingaben in Spalten, danach Werbung, am Schluss Ergebnis + Chart (.results-top) */
.layout-stack { grid-template-columns: minmax(0, 1fr); }
.results-top {
  grid-template-columns: minmax(280px, 1fr) minmax(0, 1.6fr);
  align-items: start;
}
.res-left { display: grid; gap: 16px; align-content: start; }
.res-left .kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.res-left .kpis .result-card { padding: 14px; }
.res-left .kpis .result-card strong { font-size: 1.05rem; }

.layout-stack .form {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
  align-items: start;
  background: transparent;
  border: 0;
  padding: 0;
}
.layout-stack .form fieldset {
  margin: 0;
  padding: 18px 20px;
  background: var(--panel-strong);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
}
.layout-stack .form .tax-fieldset {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  column-gap: 22px;
  align-items: start;
}
.layout-stack .form .tax-fieldset legend { grid-column: 1 / -1; }
.layout-stack .form .tax-fieldset .field { border-bottom: 0; }

@media (max-width: 1000px) {
  .layout-stack .form { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .layout-stack .form .tax-fieldset { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 900px) {
  .results-top { grid-template-columns: minmax(0, 1fr); }
  .res-left .kpis { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  .layout-stack .form, .layout-stack .form .tax-fieldset { grid-template-columns: minmax(0, 1fr); }
}

@media (min-width: 901px) {
  .results-top { align-items: stretch; }
  .results-top .chart-card { display: flex; flex-direction: column; }
  .results-top #balanceChart { flex: 1 1 0; height: 0; min-height: 260px; }
}

/* Werbebanner (immer als Anzeige gekennzeichnet, Format 970x250, empfohlen 1940x500) */
.ad { position: relative; margin: 0; }
.ad[hidden] { display: none; }
.ad-tag {
  position: absolute; top: 8px; left: 8px; z-index: 1;
  padding: 2px 9px; border-radius: 999px;
  background: rgba(255, 255, 255, 0.92); border: 1px solid rgba(17, 17, 17, 0.25);
  font-size: 0.72rem; color: #333;
}
.ad > a { display: block; border-radius: var(--radius-md); overflow: hidden; border: 1px solid var(--line); background: #fff; line-height: 0; }
.ad img { display: block; width: 100%; height: auto; }
.ad > a:hover { box-shadow: 0 8px 28px rgba(27, 57, 79, 0.2); }
.ad > a:focus-visible { outline: 3px solid #0f3658; outline-offset: 2px; }
.ad-meta { margin: 6px 4px 0; text-align: right; font-size: 0.78rem; }
.ad-meta a { color: var(--muted); }

/* Hinweis unter dem Resultat, Fusszeile, rechtliche Seiten */
.result-note { grid-column: 1 / -1; margin: 0; font-size: 0.82rem; line-height: 1.5; color: var(--muted); }
.result-note a, .footer-links a, .legal a, .back a { color: #0f3658; }
.site-footer { margin: 18px 4px 0; }
.site-footer .disclaimer { margin: 0 0 10px; }
.footer-links { display: flex; flex-wrap: wrap; gap: 6px 18px; font-size: 0.85rem; color: var(--muted); }
.back { margin: 0 0 14px; font-size: 0.92rem; }
.legal { padding: 28px clamp(18px, 4vw, 40px); max-width: 860px; }
.legal h1 { font-size: clamp(1.8rem, 4vw, 2.6rem); letter-spacing: -0.04em; line-height: 1.05; margin-bottom: 14px; color: #0f3658; }
.legal h2 { margin: 26px 0 8px; font-size: 1.1rem; letter-spacing: -0.02em; }
.legal p, .legal li { line-height: 1.6; font-size: 0.97rem; }
.legal ul { padding-left: 20px; margin: 0 0 12px; }
.legal li { margin-bottom: 6px; }
.legal .muted { color: var(--muted); font-size: 0.88rem; }
.status-box { margin: 16px 0 4px; padding: 14px 16px; border-radius: 14px; background: #eef6fb; border: 1px solid rgba(129, 168, 197, 0.45); line-height: 1.55; font-size: 0.95rem; }

/* Einwilligungsabfrage (nur sichtbar, wenn Tags konfiguriert sind) */
.link-button { border: 0; background: none; padding: 0; font: inherit; color: #0f3658; text-decoration: underline; cursor: pointer; }
.consent {
  position: fixed; left: 12px; right: 12px; bottom: 12px; z-index: 30;
  max-width: 760px; margin: 0 auto; padding: 18px 20px;
  background: #fff; border: 1px solid rgba(129, 168, 197, 0.55); border-radius: var(--radius-md);
  box-shadow: 0 12px 40px rgba(27, 57, 79, 0.28);
}
.consent h2 { margin: 0 0 6px; font-size: 1.05rem; }
.consent p { margin: 0 0 12px; font-size: 0.9rem; line-height: 1.5; color: #333; }
.consent a { color: #0f3658; }
.consent-settings { display: grid; gap: 10px; margin: 0 0 14px; }
.consent-settings[hidden] { display: none; }
.consent-option { display: flex; gap: 10px; align-items: flex-start; margin: 0; font-weight: 400; }
.consent-option input { width: auto; margin-top: 4px; }
.consent-option span { display: grid; gap: 2px; }
.consent-option small { color: var(--muted); font-size: 0.82rem; }
.consent-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.consent-btn { flex: 1 1 140px; padding: 11px 14px; border: 1px solid #0f3658; border-radius: 999px; background: #fff; color: #0f3658; font: inherit; font-weight: 600; cursor: pointer; }
.consent-btn:hover, .consent-btn:focus-visible { background: #0f3658; color: #fff; outline: none; }
