:root {
  --navy: #163a63;
  --navy-deep: #0f2b4c;
  --blue: #1f5f9e;
  --blue-soft: #e8f0f9;
  --teal: #2a9d97;
  --teal-soft: #e4f4f2;
  --surface: #f2f5f9;
  --card: #ffffff;
  --border: #dce4ee;
  --text: #1b2a3a;
  --muted: #5a6b7e;
  --warn-bg: #fff6e5;
  --warn-text: #7a4b00;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(16, 42, 76, .05), 0 4px 16px rgba(16, 42, 76, .05);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.5;
  color: var(--text);
  background: var(--surface);
}

.wrap { max-width: 1200px; margin: 0 auto; padding: 0 16px; }

/* ---------- Kopf ---------- */
.site-header {
  background: linear-gradient(160deg, var(--navy-deep), var(--navy) 60%, #1d4a7a);
  color: #fff;
  padding: 20px 0 30px;
}
.brand { display: flex; align-items: center; gap: 8px; font-weight: 650; letter-spacing: .02em; opacity: .95; }
.brand-mark { width: 26px; height: 26px; }
.brand-mark rect { fill: rgba(255, 255, 255, .12); }
.brand-mark path { stroke: #7fd3cd; stroke-width: 3; fill: none; stroke-linecap: round; stroke-linejoin: round; }
.site-header h1 {
  font-size: clamp(1.6rem, 5vw, 2.4rem);
  line-height: 1.2;
  margin: 22px 0 10px;
  font-weight: 700;
  letter-spacing: -.01em;
  max-width: 22em;
}
.lead { margin: 0; max-width: 46em; color: #d6e2f0; font-size: 1.02rem; }

/* ---------- Layout ---------- */
.layout {
  display: grid;
  gap: 20px;
  margin-top: -14px;
  padding-bottom: 32px;
}
@media (min-width: 960px) {
  .layout { grid-template-columns: 370px minmax(0, 1fr); align-items: start; gap: 24px; }
  .inputs { position: sticky; top: 16px; max-height: calc(100vh - 32px); overflow-y: auto; padding-right: 2px; scrollbar-width: thin; }
}

.inputs, .results { display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; align-content: start; min-width: 0; }

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
}
.card h2 { font-size: 1.08rem; margin: 0 0 14px; color: var(--navy); display: flex; align-items: center; gap: 10px; }
.step {
  display: inline-grid; place-items: center;
  width: 26px; height: 26px; border-radius: 50%;
  background: var(--navy); color: #fff; font-size: .85rem;
}

/* ---------- Felder ---------- */
.field { margin-bottom: 16px; }
.field:last-child { margin-bottom: 0; }
label { display: block; font-weight: 600; font-size: .95rem; margin-bottom: 6px; }
.hint { margin: 6px 0 0; font-size: .84rem; color: var(--muted); line-height: 1.4; }

input[type="text"], select {
  width: 100%;
  font: inherit;
  font-size: 16px; /* verhindert Zoom auf iOS */
  color: var(--text);
  background: #fff;
  border: 1px solid #c9d4e2;
  border-radius: 10px;
  padding: 10px 12px;
  min-height: 44px;
  transition: border-color .15s, box-shadow .15s;
}
select { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%235a6b7e' stroke-width='1.6' fill='none' stroke-linecap='round'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; padding-right: 34px; }
input[type="text"]:focus, select:focus { outline: none; border-color: var(--blue); box-shadow: 0 0 0 3px rgba(31, 95, 158, .18); }
input.invalid { border-color: #c2410c; box-shadow: 0 0 0 3px rgba(194, 65, 12, .12); }

.month-year { display: grid; grid-template-columns: 1.4fr 1fr; gap: 8px; }
.unit-input { position: relative; }
.unit-input input { padding-right: 36px; text-align: right; }
.unit-input span { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }

.tax-note {
  margin-top: 16px;
  background: var(--blue-soft);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: .86rem;
  color: #24466d;
}

/* ---------- Begünstigende Optionen ---------- */
.favorable { padding: 0; }
.favorable summary {
  list-style: none;
  cursor: pointer;
  padding: 16px 18px;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 2px 10px;
  position: relative;
}
.favorable summary::-webkit-details-marker { display: none; }
.fav-title { font-weight: 650; font-size: 1.08rem; color: var(--navy); padding-right: 22px; display: flex; align-items: center; gap: 10px; }
.fav-sub { grid-column: 1 / -1; font-size: .84rem; color: var(--muted); padding-left: 36px; }
.favorable summary::after {
  content: ""; position: absolute; right: 18px; top: 22px;
  width: 8px; height: 8px; border-right: 2px solid var(--muted); border-bottom: 2px solid var(--muted);
  transform: rotate(45deg); transition: transform .2s;
}
.favorable[open] summary::after { transform: rotate(-135deg); top: 26px; }
.badge {
  grid-column: 2; grid-row: 1;
  margin-right: 22px;
  background: var(--teal); color: #fff;
  font-size: .76rem; font-weight: 600;
  border-radius: 999px; padding: 2px 9px; align-self: center; white-space: nowrap;
}
.fav-body { padding: 0 18px 18px; border-top: 1px solid var(--border); padding-top: 16px; }

.label-row { display: flex; align-items: center; gap: 6px; margin-bottom: 6px; }
.label-row label { margin: 0; }
.info {
  width: 22px; height: 22px; border-radius: 50%;
  border: 1px solid #b7c5d6; background: #fff; color: var(--blue);
  font: italic 600 .78rem Georgia, serif; cursor: pointer; padding: 0; flex: none;
  display: inline-grid; place-items: center;
}
.info[aria-expanded="true"] { background: var(--blue); color: #fff; border-color: var(--blue); }
.info-text {
  margin: 0 0 8px; font-size: .84rem; color: #24466d;
  background: var(--blue-soft); border-radius: 8px; padding: 8px 10px; line-height: 1.45;
}
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.chip {
  font: inherit; font-size: .84rem; cursor: pointer;
  border: 1px solid #c9d4e2; background: #fff; color: var(--navy);
  border-radius: 999px; padding: 6px 12px; min-height: 34px;
}
.chip:hover { border-color: var(--blue); }
.chip.active { background: var(--navy); color: #fff; border-color: var(--navy); }

.check {
  display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 4px 10px;
  padding: 10px 0; border-top: 1px solid #edf1f6;
}
.check label { margin: 0; font-weight: 600; cursor: pointer; }
.check .info-text { grid-column: 1 / -1; margin: 4px 0 0; }
input[type="checkbox"] { width: 20px; height: 20px; accent-color: var(--navy); margin: 0; cursor: pointer; }

.reset {
  font: inherit; font-size: .92rem; cursor: pointer;
  background: transparent; color: var(--muted);
  border: 1px dashed #b9c6d6; border-radius: 10px; padding: 10px; min-height: 44px;
}
.reset:hover { color: var(--navy); border-color: var(--navy); }

/* ---------- Ergebnisse ---------- */
.mini-disclaimer { margin: 12px 0 0; font-size: .78rem; color: var(--muted); }

.summary-card { border-left: 4px solid var(--teal); }
.summary { margin: 0; font-size: 1.1rem; line-height: 1.55; }
.summary strong { color: var(--navy); white-space: nowrap; }
.warning {
  margin: 12px 0 0; background: var(--warn-bg); color: var(--warn-text);
  border-radius: 10px; padding: 10px 12px; font-size: .9rem;
}

.kpis { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
@media (min-width: 640px) { .kpis { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.kpi {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 14px; display: flex; flex-direction: column; gap: 2px; min-width: 0;
}
.kpi-main { background: #1d7f7a; border-color: #1d7f7a; color: #fff; }
.kpi-label { font-size: .78rem; color: var(--muted); line-height: 1.3; }
.kpi-main .kpi-label, .kpi-main .kpi-sub { color: #dcf3f1; }
.kpi-value { font-size: clamp(1.25rem, 4.2vw, 1.6rem); font-weight: 700; color: var(--navy); font-variant-numeric: tabular-nums; margin-top: 4px; }
.kpi-main .kpi-value { color: #fff; }
.kpi-sub { font-size: .76rem; color: var(--muted); line-height: 1.35; }

.card-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 10px; }
.card-head h2 { margin: 0; }
.segmented { display: inline-flex; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 3px; }
.segmented button {
  font: inherit; font-size: .86rem; border: 0; background: transparent; color: var(--muted);
  padding: 6px 14px; border-radius: 7px; cursor: pointer; min-height: 34px;
}
.segmented button.active { background: #fff; color: var(--navy); font-weight: 600; box-shadow: 0 1px 3px rgba(16, 42, 76, .12); }

.legend { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: .8rem; color: var(--muted); margin-bottom: 8px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.sw { display: inline-block; width: 18px; height: 0; border-top: 3px solid; }
.sw-real { border-color: var(--blue); }
.sw-nom { border-color: var(--navy); border-top-width: 2px; }
.sw-dep { border-color: #9aa8b8; border-top-style: dotted; border-top-width: 3px; }
.sw-scen { border-color: #8fb4dc; border-top-style: dashed; border-top-width: 2px; }

.chart-box { position: relative; height: 400px; margin: 0 -6px; }
@media (min-width: 640px) { .chart-box { height: 440px; margin: 0; } }
.chart-foot { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 8px; margin-top: 10px; font-size: .84rem; color: var(--muted); }
.toggle { display: inline-flex; align-items: center; gap: 8px; font-weight: 500; font-size: .86rem; margin: 0; cursor: pointer; color: var(--text); }
.phase-key { display: inline-flex; align-items: center; gap: 6px; }
.pk { display: inline-block; width: 12px; height: 12px; border-radius: 3px; }
.pk-save { background: rgba(31, 95, 158, .16); }
.pk-wd { background: rgba(42, 157, 151, .2); margin-left: 8px; }

/* ---------- Tabelle ---------- */
.table-wrap { overflow-x: auto; max-height: 520px; overflow-y: auto; border: 1px solid var(--border); border-radius: 10px; }
table { border-collapse: collapse; width: 100%; font-size: .84rem; font-variant-numeric: tabular-nums; }
th, td { padding: 8px 10px; text-align: right; white-space: nowrap; border-bottom: 1px solid #edf1f6; }
th:first-child, td:first-child { text-align: left; }
thead th {
  position: sticky; top: 0; z-index: 1;
  background: #f6f8fb; color: var(--muted); font-weight: 600; font-size: .76rem;
  white-space: normal; vertical-align: bottom; min-width: 84px;
}
thead th:first-child { min-width: 70px; }
tbody tr.save td:first-child { box-shadow: inset 3px 0 0 rgba(31, 95, 158, .55); }
tbody tr.withdraw td:first-child { box-shadow: inset 3px 0 0 rgba(42, 157, 151, .7); }
tbody tr.mixed td:first-child { box-shadow: inset 3px 0 0 #b89c2a; }
tbody tr:hover td { background: #f8fafc; }
td.zero { color: #b3bfcc; }

.opt { display: none; }
.table-note { margin: 10px 0 0; font-size: .8rem; color: var(--muted); }
@media (min-width: 760px) { .opt { display: table-cell; } .table-note { display: none; } }

.link-btn {
  font: inherit; font-size: .88rem; background: none; border: 0; color: var(--blue);
  cursor: pointer; padding: 10px 0 0; text-decoration: underline; text-underline-offset: 3px;
}

/* ---------- Fuß ---------- */
.site-footer { border-top: 1px solid var(--border); background: #fff; padding: 22px 0 30px; font-size: .84rem; color: var(--muted); }
.site-footer p { max-width: 60em; margin: 0 0 10px; }
.site-footer strong { color: var(--text); }
.credits { font-size: .78rem; }

@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }

@media (max-width: 639px) {
  th, td { padding: 8px 7px; }
  thead th { min-width: 0; }
}

/* ---------- Linien-Auswahl im Diagramm ---------- */
.series { display: flex; flex-wrap: wrap; gap: 8px; margin: 4px 0 12px; }
.series-chip {
  display: inline-flex; align-items: center; gap: 8px;
  font: inherit; font-size: .82rem; line-height: 1.2;
  border: 1px solid #c9d4e2; background: #fff; color: var(--muted);
  border-radius: 999px; padding: 7px 12px; min-height: 36px; cursor: pointer;
  transition: background .15s, border-color .15s, color .15s;
}
.series-chip .sw { opacity: .45; transition: opacity .15s; }
.series-chip[aria-pressed="true"] { background: var(--blue-soft); border-color: #a9c2df; color: var(--navy); font-weight: 600; }
.series-chip[aria-pressed="true"] .sw { opacity: 1; }
@media (hover: hover) and (pointer: fine) { .series-chip:hover { border-color: var(--blue); } }
.series-chip.locked { background: var(--navy); border-color: var(--navy); color: #fff; font-weight: 600; cursor: default; }
.series-chip.locked .sw { opacity: 1; border-color: #9ecbff; }
.sw-scen { border-color: #6f9fd2; }
.sw-main { border-color: #9ecbff; }
.series-chip .sw-real { border-color: var(--teal); }
.chart-tip { font-size: .78rem; color: var(--muted); }
@media (hover: hover) and (pointer: fine) { .chart-tip { display: none; } }
.version { font-size: .76rem; color: #8494a7; font-variant-numeric: tabular-nums; margin-top: 4px; }

/* Einheitliche Chips: an = dunkelblau gefüllt, aus = weiß umrandet */
.series-chip[aria-pressed="true"] { background: var(--navy); border-color: var(--navy); color: #fff; font-weight: 600; }
.series-chip[aria-pressed="false"] { background: #fff; color: var(--muted); font-weight: 500; }
.series-chip[aria-pressed="false"] .sw { opacity: .4; }
.series-chip[aria-pressed="true"] .sw-main { border-color: #9ecbff; }
.series-chip[aria-pressed="true"] .sw-real { border-color: #6fd6cf; }
.series-chip[aria-pressed="true"] .sw-dep { border-color: #c7d1dd; }
.series-chip[aria-pressed="true"] .sw-scen { border-color: #9ecbff; }
@media (hover: hover) and (pointer: fine) { .series-chip[aria-pressed="true"]:hover { border-color: var(--navy-deep); background: var(--navy-deep); } }

/* ---------- 0.11: Vereinfachung ---------- */
/* Drei Kacheln: große Rente-Kachel, darunter zwei kleine */
.kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.kpi-main { grid-column: 1 / -1; }
@media (min-width: 640px) {
  .kpis { grid-template-columns: 1.6fr 1fr 1fr; }
  .kpi-main { grid-column: auto; }
}
.kpi-main .kpi-value { font-size: clamp(1.8rem, 7vw, 2.2rem); }
.kpi-nominal { margin-top: 6px; padding-top: 6px; border-top: 1px solid rgba(255, 255, 255, .22); }

/* Hinweis zu den Szenarien unter dem Diagramm */
.scen-note { margin: 8px 0 0; font-size: .8rem; color: var(--muted); }

/* Zugeklappte Tabelle */
.table-card summary {
  list-style: none; cursor: pointer; position: relative;
  font-size: 1.08rem; font-weight: 700; color: var(--navy); padding-right: 28px;
}
.table-card summary::-webkit-details-marker { display: none; }
.table-card summary::after {
  content: ""; position: absolute; right: 4px; top: 6px;
  width: 8px; height: 8px; border-right: 2px solid var(--muted); border-bottom: 2px solid var(--muted);
  transform: rotate(45deg); transition: transform .2s;
}
.table-card[open] summary::after { transform: rotate(-135deg); top: 10px; }
.table-card[open] summary { margin-bottom: 12px; }
.table-sub { font-size: .84rem; color: var(--muted); }

/* Ergebnisleiste am unteren Rand (nur Handy/Tablet) */
.result-bar {
  position: fixed; left: 12px; right: 12px; bottom: 12px; z-index: 20;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  background: #1d7f7a; color: #fff; text-decoration: none;
  border-radius: 14px; padding: 10px 16px;
  box-shadow: 0 6px 24px rgba(15, 43, 76, .28);
  transition: transform .25s ease, opacity .25s ease;
  padding-bottom: calc(10px + env(safe-area-inset-bottom, 0px));
}
.result-bar.hide { transform: translateY(140%); opacity: 0; pointer-events: none; }
.rb-label { font-size: .86rem; font-weight: 600; line-height: 1.25; }
.rb-label small { font-weight: 400; color: #dcf3f1; font-size: .74rem; }
.rb-value { font-size: 1.5rem; font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
@media (min-width: 960px) { .result-bar { display: none; } }
@media (max-width: 959px) { body { padding-bottom: 84px; } }

/* Kachel-Überschriften wie die übrigen Beschriftungen der Seite */
.kpi-label { font-size: .95rem; font-weight: 600; color: var(--text); line-height: 1.35; }
.kpi-main .kpi-label { color: #fff; }
.kpi-main .kpi-sub.kpi-strong { color: #fff; font-weight: 600; }
.results > .mini-disclaimer { margin: -6px 4px 0; }
.results > .warning { margin: 0; }

/* Rentenart (Schritt 3) */
.rent-mode { border: 0; padding: 12px 0 4px; margin: 0; border-top: 1px solid #edf1f6; }
.rent-mode legend { font-weight: 600; font-size: .95rem; padding: 0; margin-bottom: 8px; }
.radio { display: grid; grid-template-columns: auto 1fr; gap: 10px; align-items: start; font-weight: 400; margin: 0; padding: 8px 0; cursor: pointer; }
.radio input { width: 20px; height: 20px; margin: 1px 0 0; accent-color: var(--navy); }
.radio strong { display: block; font-size: .93rem; color: var(--text); }
.radio small { display: block; font-size: .82rem; color: var(--muted); line-height: 1.35; }
.target-input { margin: 6px 0 4px 30px; }
.target-input label { font-size: .9rem; }

/* Erklärung in der grünen Kachel */
.kpi-keep { display: flex; align-items: center; gap: 8px; }
.info-light { background: transparent; color: #fff; border-color: rgba(255, 255, 255, .6); }
.info-light[aria-expanded="true"] { background: #fff; color: #1d7f7a; border-color: #fff; }
.kpi-explain { margin-top: 8px; font-size: .84rem; line-height: 1.45; color: #fff; background: rgba(255, 255, 255, .12); border-radius: 8px; padding: 8px 10px; }
.kpi-main .kpi-sub.kpi-warn { color: #ffe3a3; font-weight: 600; }
.rent-mode legend { float: left; width: 100%; padding-top: 2px; }
.rent-mode legend + * { clear: both; }

/* Annahme Anlageform (Schritt 1) */
.assumption {
  margin: 10px 0 0; font-size: .84rem; line-height: 1.4; color: #24466d;
  background: var(--blue-soft); border-radius: 8px; padding: 8px 10px;
}
/* Info in weißen Kacheln */
.kpi-label-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
.kpi-label-row .info { margin-top: 1px; }
.kpi-explain-light { color: #24466d; background: var(--blue-soft); margin: 6px 0 4px; }
.tax-explain { margin: -4px 0 0; font-size: .84rem; line-height: 1.45; color: #24466d; background: var(--blue-soft); border-radius: 10px; padding: 10px 12px; }
.results > .mini-disclaimer { margin: -4px 0 0; padding: 10px 12px; border: 1px solid var(--border); border-radius: 10px; background: #fff; font-size: .82rem; color: var(--muted); }
.results > .mini-disclaimer strong { color: var(--text); }

/* Hinweis zu den Startwerten im Kopf */
.start-note {
  margin: 16px 0 0; max-width: 46em;
  background: var(--blue-soft); color: #1d3f66;
  border-radius: 10px; padding: 10px 14px; font-size: .92rem; line-height: 1.45;
}
.site-header { padding-bottom: 34px; }

/* Links im Fuß */
.footer-links a { color: var(--blue); font-weight: 600; text-underline-offset: 3px; }

/* Unterseiten (Datenschutz) */
.legal { max-width: 760px; margin: -14px auto 0; padding: 0 16px 40px; }
.legal .card { padding: 22px; }
.legal h2 { font-size: 1.05rem; margin: 22px 0 6px; display: block; }
.legal h2:first-child { margin-top: 0; }
.legal p { margin: 0 0 10px; }
.legal .placeholder { background: #fff3c4; color: #6b4e00; border-radius: 4px; padding: 0 4px; font-weight: 600; }
.back-link { display: inline-block; margin-top: 18px; color: #d6e2f0; text-decoration: none; font-weight: 600; }
.back-link:hover { color: #fff; }
.legal-note { font-size: .84rem; color: var(--muted); }
.sw-crash { border-color: #d97706; border-top-style: dashed; }
.series-chip[aria-pressed="true"] .sw-crash { border-color: #fbbf24; }
.kpi-main .kpi-sub.kpi-crash { color: #ffe3a3; }

/* So rechnen wir */
.howto summary { list-style: none; cursor: pointer; position: relative; padding-right: 28px; display: grid; gap: 2px; }
.howto summary::-webkit-details-marker { display: none; }
.howto summary span { font-size: 1.02rem; font-weight: 700; color: var(--navy); }
.howto summary small { font-size: .84rem; color: var(--muted); }
.howto summary::after {
  content: ""; position: absolute; right: 4px; top: 8px;
  width: 8px; height: 8px; border-right: 2px solid var(--muted); border-bottom: 2px solid var(--muted);
  transform: rotate(45deg); transition: transform .2s;
}
.howto[open] summary::after { transform: rotate(-135deg); top: 12px; }
.howto ul { margin: 12px 0 0; padding-left: 18px; font-size: .88rem; line-height: 1.5; color: var(--text); }
.howto li { margin-bottom: 6px; }
.howto li strong { color: var(--navy); }

/* 0.30: kompakter Kopf, Hinweis in Schritt 1 */
.start-hint { margin: -6px 0 14px; font-size: .84rem; color: var(--muted); line-height: 1.4; }
@media (max-width: 639px) {
  .site-header { padding: 14px 0 26px; }
  .brand { font-size: .92rem; }
  .brand-mark { width: 22px; height: 22px; }
  .site-header h1 { font-size: 1.4rem; margin: 12px 0 6px; }
  .lead { font-size: .92rem; line-height: 1.45; }
}
