:root {
  --bg: #f3f5f7;
  --surface: #ffffff;
  --surface-soft: #f8fafb;
  --text: #17212b;
  --muted: #66727e;
  --line: #dce2e7;
  --primary: #163f6b;
  --primary-dark: #0f3155;
  --positive: #08783f;
  --negative: #b42318;
  --warning: #8a4b08;
  --warning-bg: #fff4e5;
  --error-bg: #fff0ee;
  --shadow: 0 18px 50px rgba(20, 35, 50, 0.08);
  --radius: 20px;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  min-width: 320px;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.5;
}
button, input, select { font: inherit; }
.container { width: min(1320px, calc(100% - 32px)); margin: 0 auto; }
.page-header {
  padding: 62px 0 42px;
  background: radial-gradient(circle at 80% 20%, rgba(255,255,255,.13), transparent 28%), linear-gradient(135deg, #102f50, #1b527f);
  color: #fff;
}
.eyebrow { margin: 0 0 8px; color: #cde2f5; font-size: 13px; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; }
h1 { margin: 0; font-size: clamp(36px, 6vw, 66px); line-height: 1.04; letter-spacing: -.04em; }
.intro { max-width: 820px; margin: 18px 0 0; color: rgba(255,255,255,.82); font-size: 18px; }
main { padding: 34px 0 60px; }
.panel { margin-bottom: 24px; padding: 26px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow); }
.section-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 24px; margin-bottom: 24px; }
.section-heading > div:first-child { display: flex; align-items: center; gap: 12px; }
.section-heading h2 { margin: 0; font-size: 24px; letter-spacing: -.02em; }
.section-heading p { max-width: 620px; margin: 4px 0 0; color: var(--muted); font-size: 14px; text-align: right; }
.step { display: inline-grid; place-items: center; width: 34px; height: 34px; flex: 0 0 auto; border-radius: 50%; background: var(--primary); color: #fff; font-weight: 800; }
.input-grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 16px; }
.input-grid .wide { grid-column: span 2; }
.finance-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px; }
.finance-card { min-width: 0; margin: 0; padding: 22px; border: 1px solid var(--line); border-radius: 16px; background: var(--surface-soft); }
.finance-card legend { padding: 0 9px; color: var(--primary); font-size: 18px; font-weight: 800; }
label { display: block; min-width: 0; }
label + label { margin-top: 14px; }
.input-grid label + label { margin-top: 0; }
label > span { display: block; min-height: 40px; margin-bottom: 7px; color: #3d4955; font-size: 13px; font-weight: 700; }
.input-wrap { display: flex; align-items: center; min-height: 46px; overflow: hidden; border: 1px solid #cfd7df; border-radius: 11px; background: #fff; transition: border-color .15s ease, box-shadow .15s ease; }
.input-wrap:focus-within { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(22, 63, 107, .11); }
.input-wrap input { width: 100%; min-width: 0; padding: 11px 12px; border: 0; outline: 0; background: transparent; color: var(--text); font-weight: 700; }
.input-wrap b { align-self: stretch; display: grid; place-items: center; min-width: 46px; padding: 0 9px; border-left: 1px solid var(--line); background: #f3f6f8; color: var(--muted); font-size: 13px; }
.input-wrap.readonly { background: #eef2f5; }
.input-wrap input:disabled, .input-wrap input[readonly] { color: #687683; cursor: not-allowed; }
select { width: 100%; min-width: 0; padding: 11px 38px 11px 12px; border: 0; outline: 0; appearance: none; background: transparent; color: var(--text); font-weight: 700; cursor: pointer; }
.select-wrap { position: relative; }
.select-wrap::after { content: "▾"; position: absolute; right: 14px; top: 50%; pointer-events: none; color: var(--muted); transform: translateY(-50%); }
.summary-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin-top: 22px; }
.summary-grid.compact { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.summary-card { padding: 17px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface-soft); }
.summary-card.accent { border-color: rgba(22, 63, 107, .28); background: #edf5fc; }
.summary-card span { display: block; margin-bottom: 6px; color: var(--muted); font-size: 12px; font-weight: 750; text-transform: uppercase; letter-spacing: .04em; }
.summary-card strong { display: block; color: var(--primary); font-size: clamp(17px, 2vw, 24px); line-height: 1.25; }
.modernization-summary { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.modernization-info { display: grid; gap: 5px; margin-bottom: 22px; padding: 16px 18px; border-left: 4px solid var(--primary); border-radius: 10px; background: #edf5fc; color: #32485e; font-size: 14px; }
.modernization-info strong { color: var(--primary); }
.warning { margin-top: 16px; padding: 13px 15px; border: 1px solid #f2c48c; border-radius: 11px; background: var(--warning-bg); color: var(--warning); font-size: 14px; font-weight: 700; }
.warning.error { border-color: #efb1aa; background: var(--error-bg); color: var(--negative); }
.sync-option { display: flex; align-items: center; gap: 10px; margin: -4px 0 22px; padding: 13px 15px; border: 1px solid var(--line); border-radius: 12px; background: #f1f6fa; cursor: pointer; }
.sync-option input { width: 18px; height: 18px; accent-color: var(--primary); }
.sync-option span { min-height: auto; margin: 0; color: var(--primary); font-size: 14px; }
.finance-note { grid-column: 1 / -1; margin: 14px 0 0; color: var(--muted); font-size: 12px; }
.actions { display: flex; gap: 12px; margin-top: 24px; }
.actions button { padding: 13px 19px; border: 0; border-radius: 11px; cursor: pointer; font-weight: 800; transition: transform .15s ease, background .15s ease; }
.actions button:hover { transform: translateY(-1px); }
.primary { background: var(--primary); color: #fff; }
.primary:hover { background: var(--primary-dark); }
.secondary { background: #e8edf1; color: var(--text); }
.result-panel { overflow: hidden; }
.result-panel h3 { margin: 28px 0 12px; color: var(--primary); font-size: 18px; }
.result-panel h3:first-of-type { margin-top: 0; }
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 14px; }
table { width: 100%; border-collapse: collapse; }
.cashflow-table { min-width: 720px; }
.tax-table { min-width: 1700px; }
th, td { padding: 13px 12px; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); text-align: right; white-space: nowrap; }
th:last-child, td:last-child { border-right: 0; }
thead th { background: #eef3f7; color: #41505e; font-size: 11px; letter-spacing: .035em; text-transform: uppercase; }
thead tr:first-child th { background: #dfe9f1; color: var(--primary); font-size: 12px; }
th:first-child, td:first-child { position: sticky; left: 0; z-index: 1; text-align: left; background: #fff; font-weight: 800; }
thead th:first-child { z-index: 3; background: #dfe9f1; }
tbody tr:nth-child(even) td, tbody tr:nth-child(even) th:first-child { background: #fbfcfd; }
tbody tr:last-child th, tbody tr:last-child td { border-bottom: 0; }
.cashflow { font-weight: 900; }
.positive { color: var(--positive); }
.negative { color: var(--negative); }

/* Farbliche Zuordnung der Finanzierungsvarianten */
.group-annuity, .annuity-cell { background: #eef0f2 !important; }
.group-bauspar, .bauspar-cell { background: #eaf4ff !important; }
.group-fund, .fund-cell { background: #eaf8ee !important; }
thead .group-annuity { color: #4b5563 !important; }
thead .group-bauspar { color: #245c8a !important; }
thead .group-fund { color: #267044 !important; }
tbody tr:nth-child(even) .annuity-cell { background: #e7eaed !important; }
tbody tr:nth-child(even) .bauspar-cell { background: #e1effc !important; }
tbody tr:nth-child(even) .fund-cell { background: #e1f3e7 !important; }

.model-note { margin: 16px 2px 0; color: var(--muted); font-size: 13px; }
footer { padding: 24px 0 40px; color: var(--muted); font-size: 13px; text-align: center; }

@media (max-width: 1100px) {
  .input-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .finance-grid { grid-template-columns: 1fr; }
  .finance-card { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
  .finance-card legend { grid-column: 1 / -1; }
  .finance-card label + label { margin-top: 0; }
  .modernization-summary { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 760px) {
  .page-header { padding: 44px 0 34px; }
  .panel { padding: 19px; border-radius: 16px; }
  .section-heading { align-items: flex-start; flex-direction: column; }
  .section-heading p { text-align: left; }
  .input-grid, .finance-card, .summary-grid, .summary-grid.compact, .modernization-summary { grid-template-columns: 1fr; }
  .input-grid .wide { grid-column: auto; }
  label > span { min-height: auto; }
  .actions { flex-direction: column; }
  .actions button { width: 100%; }
}
