@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@400;500;600;700&display=swap');

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: 'Poppins', system-ui, sans-serif; background: #F5F5F5; color: #323949; min-height: 100vh; display: flex; flex-direction: column; }

/* ── Header ────────────────────────────────── */
header { background: #144584; padding: 20px 40px; display: flex; align-items: center; justify-content: space-between; gap: 24px; }
.header-left { display: flex; align-items: center; gap: 28px; }
.logo-wrap { background: #fff; border-radius: 8px; padding: 6px 14px 5px; display: inline-flex; align-items: center; }
.logo-img { height: 36px; width: auto; display: block; }
.badge { background: #6BB96D; color: #fff; font-weight: 700; font-size: 11px; letter-spacing: .13em; padding: 7px 18px 7px 13px; border-radius: 0 9px 9px 0; white-space: nowrap; }
.header-back { color: rgba(255,255,255,.7); font-size: 13px; font-weight: 600; text-decoration: none; letter-spacing: .02em; transition: color .15s; white-space: nowrap; }
.header-back:hover { color: #fff; }

/* ── Main ──────────────────────────────────── */
main { flex: 1; max-width: 1060px; width: 100%; margin: 0 auto; padding: 56px 24px 80px; }
h1 { font-size: 32px; font-weight: 700; color: #144584; margin-bottom: 8px; }
.subtitle { font-size: 15px; font-weight: 600; color: #6BB96D; margin-bottom: 48px; }
.section-label { font-size: 11px; font-weight: 700; letter-spacing: .12em; color: #144584; margin-bottom: 14px; }

/* ── Index-Karten ──────────────────────────── */
.cards { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.card { background: #fff; border-radius: 12px; padding: 28px 28px 24px; border: 1px solid #CDCDCD; display: flex; flex-direction: column; gap: 12px; text-decoration: none; color: inherit; transition: box-shadow .15s, border-color .15s; }
.card:not(.disabled):hover { border-color: #144584; box-shadow: 0 4px 20px rgba(20,69,132,.12); }
.card.disabled { opacity: .45; pointer-events: none; }
.card-tag { display: inline-block; font-size: 10px; font-weight: 700; letter-spacing: .12em; padding: 4px 10px; border-radius: 20px; width: fit-content; }
.card-tag.blue  { background: #EEF2FB; color: #144584; }
.card-tag.green { background: #EAF3EA; color: #1a7d3c; }
.card-tag.grey  { background: #F0F0F0; color: #888; }
.card h2 { font-size: 20px; font-weight: 700; color: #144584; line-height: 1.25; }
.card p { font-size: 13.5px; font-weight: 500; color: #323949; line-height: 1.55; flex: 1; }
.card-arrow { font-size: 13px; font-weight: 700; color: #144584; margin-top: 4px; }

/* ── Rechner-Layout ────────────────────────── */
.calc-layout { display: grid; grid-template-columns: 360px 1fr; gap: 28px; align-items: start; }

/* ── Formular-Karte ────────────────────────── */
.form-card { background: #fff; border-radius: 12px; border: 1px solid #CDCDCD; padding: 28px; position: sticky; top: 24px; }
.form-group { margin-bottom: 18px; }
.form-group:last-child { margin-bottom: 0; }
.form-group > label { display: block; font-size: 11px; font-weight: 700; color: #144584; letter-spacing: .08em; margin-bottom: 7px; }
.form-divider { border: none; border-top: 1px solid #EBEBEB; margin: 22px 0 18px; }

select,
input[type="number"],
input[type="text"] {
  width: 100%;
  border: 1.5px solid #CDCDCD;
  border-radius: 8px;
  padding: 10px 14px;
  font-family: 'Poppins', system-ui, sans-serif;
  font-size: 14px;
  font-weight: 500;
  color: #323949;
  outline: none;
  background: #fff;
  transition: border-color .15s, box-shadow .15s;
  -webkit-appearance: none;
  appearance: none;
}
select:focus, input:focus { border-color: #144584; box-shadow: 0 0 0 3px rgba(20,69,132,.08); }
input[type="number"]:invalid { border-color: #C0392B; box-shadow: 0 0 0 3px rgba(192,57,43,.10); }

.select-wrapper { position: relative; }
.select-wrapper::after { content: '▾'; position: absolute; right: 13px; top: 50%; transform: translateY(-50%); font-size: 13px; color: #aaa; pointer-events: none; }
.select-wrapper select { padding-right: 34px; }

.input-euro { position: relative; }
.input-euro::before { content: '€'; position: absolute; left: 13px; top: 50%; transform: translateY(-50%); font-size: 13px; font-weight: 600; color: #bbb; pointer-events: none; z-index: 1; }
.input-euro input { padding-left: 28px; }

/* Toggle ja/nein */
.toggle-group { display: flex; border: 1.5px solid #CDCDCD; border-radius: 8px; overflow: hidden; }
.toggle-group input[type="radio"] { display: none; }
.toggle-group label { flex: 1; text-align: center; padding: 10px 16px; font-size: 13px; font-weight: 600; color: #888; letter-spacing: 0; margin: 0; cursor: pointer; background: #fff; transition: background .15s, color .15s; }
.toggle-group input[type="radio"]:checked + label { background: #144584; color: #fff; }

/* Noch nicht in Kraft getretene Felder (Q1-2027-Regeln) */
.field-disabled { opacity: .4; pointer-events: none; }
.form-warning {
  display: none;
  font-size: 11px; font-weight: 600; color: #E07800; background: #FFF8EE;
  border-radius: 6px; padding: 7px 10px; margin: -8px 0 12px; line-height: 1.5;
}

/* Tooltips */
.tip {
  display: inline-flex; align-items: center; justify-content: center;
  width: 15px; height: 15px; border-radius: 50%; background: #EEF2FB; color: #144584;
  font-size: 10px; font-weight: 700; font-style: normal; margin-left: 5px;
  cursor: help; position: relative; vertical-align: middle;
}
.tip::after {
  content: attr(data-tip);
  position: absolute; left: 50%; bottom: calc(100% + 9px); transform: translateX(-50%);
  background: #144584; color: #fff; font-size: 11px; font-weight: 500; line-height: 1.5;
  padding: 8px 11px; border-radius: 6px; width: 210px; white-space: normal; text-align: left;
  opacity: 0; visibility: hidden; transition: opacity .15s;
  pointer-events: none; z-index: 20;
}
.tip::before {
  content: ''; position: absolute; left: 50%; bottom: 100%; transform: translateX(-50%);
  border: 5px solid transparent; border-top-color: #144584;
  opacity: 0; visibility: hidden; transition: opacity .15s; z-index: 20;
}
.tip:hover::after, .tip:focus::after, .tip:hover::before, .tip:focus::before {
  opacity: 1; visibility: visible;
}

/* ── Ergebnis-Dokument ─────────────────────── */
.result-doc {
  background: #fff;
  border-radius: 12px;
  border: 1px solid #CDCDCD;
  padding: 32px;
  min-height: 320px;
}

.doc-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 280px;
  color: #aaa;
  font-size: 13px;
  font-weight: 500;
  line-height: 1.7;
  text-align: center;
  gap: 12px;
}
.doc-empty-icon { font-size: 36px; opacity: .35; }

/* Dokumentkopf */
.doc-header { display: flex; justify-content: space-between; align-items: flex-start; padding-bottom: 18px; border-bottom: 2px solid #144584; margin-bottom: 22px; gap: 16px; }
.doc-title { font-size: 14px; font-weight: 700; color: #144584; line-height: 1.3; letter-spacing: .03em; }
.doc-subtitle { font-size: 10px; font-weight: 600; color: #6BB96D; letter-spacing: .1em; margin-top: 3px; }
.doc-date { font-size: 11px; font-weight: 600; color: #999; white-space: nowrap; margin-top: 2px; }
.doc-regime-badge { font-size: 11px; color: #999; margin: -16px 0 18px; }

/* Abschnitte */
.doc-section { margin-bottom: 20px; }
.doc-section-title { font-size: 10px; font-weight: 700; letter-spacing: .12em; color: #144584; margin-bottom: 10px; }
.doc-meta-grid { display: flex; gap: 24px; flex-wrap: wrap; }
.doc-meta-item { display: flex; flex-direction: column; gap: 2px; }
.doc-meta-label { font-size: 10px; font-weight: 600; color: #aaa; letter-spacing: .06em; }
.doc-meta-value { font-size: 13px; font-weight: 600; color: #323949; }

.doc-divider { border: none; border-top: 1px solid #EBEBEB; margin: 18px 0; }
.doc-divider-strong { border: none; border-top: 2px solid #144584; margin: 22px 0; }

/* Kostentabelle */
.doc-cost-table { width: 100%; border-collapse: collapse; margin-bottom: 4px; }
.doc-cost-table td { padding: 7px 0; font-size: 13px; font-weight: 500; color: #323949; border-bottom: 1px solid #F0F0F0; vertical-align: middle; }
.doc-cost-table td:last-child { text-align: right; font-weight: 600; white-space: nowrap; padding-left: 12px; }
.doc-cost-table tr:last-child td { border-bottom: none; font-weight: 700; font-size: 14px; border-top: 1px solid #CDCDCD; padding-top: 10px; margin-top: 4px; }
.doc-cost-table tr.subtotal td { border-top: 1px solid #CDCDCD; padding-top: 10px; }

/* Berechnungsblöcke */
.doc-calc-block { background: #F8F9FB; border-radius: 10px; padding: 16px 18px; margin-bottom: 10px; }
.doc-calc-block:last-child { margin-bottom: 0; }
.doc-calc-title { font-size: 10px; font-weight: 700; letter-spacing: .1em; color: #144584; margin-bottom: 12px; }
.doc-calc-row { display: flex; justify-content: space-between; align-items: baseline; padding: 4px 0; }
.doc-calc-row .lbl { font-size: 13px; font-weight: 500; color: #555; }
.doc-calc-row .val { font-size: 13px; font-weight: 600; color: #323949; white-space: nowrap; padding-left: 12px; }
.doc-calc-row .rate { font-size: 13px; font-weight: 700; color: #144584; }
.doc-calc-row .rate.bonus { color: #1a7d3c; }
.doc-calc-hint { font-size: 11px; color: #999; margin-top: -2px; padding-bottom: 4px; }
.doc-calc-result { display: flex; justify-content: space-between; align-items: center; border-top: 1px solid #CDCDCD; margin-top: 8px; padding-top: 10px; }
.doc-calc-result .lbl { font-size: 13px; font-weight: 700; color: #144584; }
.doc-calc-result .val { font-size: 16px; font-weight: 700; color: #144584; }

/* Gesamtförderung */
.doc-total { background: #144584; border-radius: 10px; padding: 18px 22px; display: flex; justify-content: space-between; align-items: center; gap: 16px; margin-top: 16px; }
.doc-total-left .lbl { font-size: 10px; font-weight: 700; letter-spacing: .1em; color: rgba(255,255,255,.65); }
.doc-total-left .sub { font-size: 11px; font-weight: 500; color: rgba(255,255,255,.45); margin-top: 3px; }
.doc-total-value { font-size: 28px; font-weight: 700; color: #fff; white-space: nowrap; }

/* Status-Badges */
.doc-badge { display: inline-block; font-size: 10px; font-weight: 700; letter-spacing: .1em; padding: 5px 12px; border-radius: 20px; }
.doc-badge.ok  { background: #EAF3EA; color: #1a7d3c; }
.doc-badge.err { background: #FEF0EE; color: #C0392B; }
.doc-notice { font-size: 11px; font-weight: 500; color: #E07800; background: #FFF8EE; border-radius: 6px; padding: 7px 10px; margin-top: 6px; }

.doc-note { font-size: 11px; color: #aaa; font-weight: 500; line-height: 1.65; margin-top: 18px; padding-top: 16px; border-top: 1px solid #EBEBEB; }

/* Kostenvergleich */
.doc-comparison { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 12px; margin: 14px 0 10px; }
.doc-comp-col { background: #F8F9FB; border-radius: 10px; padding: 18px 22px; text-align: center; }
.doc-comp-col.doc-comp-highlight { background: #EAF3EA; }
.doc-comp-label { font-size: 10px; font-weight: 700; letter-spacing: .12em; color: #aaa; margin-bottom: 8px; }
.doc-comp-highlight .doc-comp-label { color: #1a7d3c; }
.doc-comp-value { font-size: 22px; font-weight: 700; color: #CDCDCD; line-height: 1.1; }
.doc-comp-highlight .doc-comp-value { color: #1a7d3c; }
.doc-comp-muted { color: #CDCDCD; }
.doc-comp-sub { font-size: 11px; font-weight: 500; color: #bbb; margin-top: 5px; }
.doc-comp-highlight .doc-comp-sub { color: #6BB96D; }
.doc-comp-arrow { font-size: 22px; color: #CDCDCD; text-align: center; flex-shrink: 0; }
.doc-comp-savings { display: flex; justify-content: space-between; align-items: center; background: #EEF2FB; border-radius: 8px; padding: 11px 16px; font-size: 13px; font-weight: 600; color: #144584; }
.doc-comp-pct { color: #1a7d3c; font-weight: 700; }

/* Export-Leiste */
.doc-export-bar { display: flex; gap: 10px; margin-top: 22px; padding-top: 18px; border-top: 1px solid #EBEBEB; flex-wrap: wrap; }
.doc-export-btn { font-family: 'Poppins', system-ui, sans-serif; font-size: 13px; font-weight: 700; padding: 10px 20px; border-radius: 8px; cursor: pointer; transition: background .15s, box-shadow .15s, border-color .15s; white-space: nowrap; border: none; background: #144584; color: #fff; }
.doc-export-btn:hover { background: #0f3569; box-shadow: 0 4px 14px rgba(20,69,132,.25); }
.doc-export-btn-outline { background: #fff; color: #144584; border: 1.5px solid #CDCDCD; }
.doc-export-btn-outline:hover { border-color: #144584; box-shadow: none; background: #F4F7FB; }

/* ── Dynamische Maßnahmen-Einträge ────────── */
.measure-entry { border: 1.5px solid #DDE4F0; border-radius: 8px; padding: 14px 14px 4px; margin-bottom: 10px; background: #F4F7FB; transition: opacity .2s, border-color .2s; }
.measure-entry.measure-inactive { opacity: .5; border-color: #CDCDCD; background: #F8F8F8; }
.measure-entry.measure-inactive .measure-entry-num { color: #999; }
.measure-entry-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; gap: 8px; }
.measure-entry-left { display: flex; align-items: center; gap: 8px; }
.measure-entry-num { font-size: 11px; font-weight: 700; letter-spacing: .08em; color: #144584; }
.measure-entry-actions { display: flex; align-items: center; gap: 2px; }
.measure-toggle-btn { background: #144584; border: none; color: #fff; font-size: 11px; font-weight: 700; line-height: 1; cursor: pointer; width: 52px; height: 22px; display: flex; align-items: center; justify-content: center; border-radius: 20px; transition: background .15s; padding: 0; letter-spacing: .04em; white-space: nowrap; }
.measure-toggle-btn.inactive { background: #CDCDCD; color: #777; }
.measure-move-btn { background: none; border: 1px solid #DDE4F0; color: #9DB5E0; font-size: 11px; line-height: 1; cursor: pointer; width: 22px; height: 22px; display: flex; align-items: center; justify-content: center; border-radius: 5px; transition: background .15s, color .15s; padding: 0; }
.measure-move-btn:hover { background: #E8EFF8; color: #144584; border-color: #9DB5E0; }
.measure-move-btn:disabled, .measure-move-btn[style*="hidden"] { opacity: .25; cursor: default; pointer-events: none; }
.measure-remove-btn { background: none; border: none; color: #c0c8d6; font-size: 20px; line-height: 1; cursor: pointer; width: 24px; height: 24px; display: flex; align-items: center; justify-content: center; border-radius: 50%; transition: background .15s, color .15s; padding: 0; margin-left: 4px; }
.measure-remove-btn:hover { background: #FEF0EE; color: #C0392B; }
.measure-entry .form-group { margin-bottom: 12px; }
.measure-entry select,
.measure-entry input[type="number"] { background: #fff; }

.btn-add-measure { width: 100%; padding: 11px 16px; background: #EEF2FB; color: #144584; border: 1.5px dashed #9DB5E0; border-radius: 8px; font-family: 'Poppins', system-ui, sans-serif; font-size: 13px; font-weight: 700; cursor: pointer; transition: background .15s, border-color .15s; letter-spacing: .02em; margin-top: 6px; }
.btn-add-measure:hover { background: #E2EAF8; border-color: #144584; }

/* ── Dashboard ─────────────────────────────── */
.dash-header { display: flex; align-items: flex-start; justify-content: space-between; flex-wrap: wrap; gap: 16px; margin-bottom: 36px; }
.dash-header h1 { margin-bottom: 4px; }
.dash-header .subtitle { margin-bottom: 0; }
.dash-actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }

.proj-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; }
.proj-card { background: #fff; border-radius: 12px; border: 1px solid #CDCDCD; padding: 22px 24px 18px; display: flex; flex-direction: column; gap: 0; cursor: pointer; transition: box-shadow .15s, border-color .15s; text-decoration: none; color: inherit; }
.proj-card:hover { border-color: #144584; box-shadow: 0 4px 20px rgba(20,69,132,.12); }
.proj-card-name { font-size: 15px; font-weight: 700; color: #144584; line-height: 1.3; margin-bottom: 6px; }
.proj-card-meta { font-size: 12px; font-weight: 500; color: #888; line-height: 1.6; }
.proj-card-meta span { color: #323949; font-weight: 600; }
.proj-card-tools { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 12px; padding-top: 12px; border-top: 1px solid #F0F0F0; }
.proj-card-tool { font-size: 10px; font-weight: 700; letter-spacing: .1em; padding: 3px 8px; border-radius: 20px; background: #EEF2FB; color: #144584; }
.proj-card-footer { display: flex; justify-content: space-between; align-items: center; margin-top: 12px; }
.proj-card-date { font-size: 11px; color: #aaa; font-weight: 500; }
.proj-card-arrow { font-size: 12px; font-weight: 700; color: #144584; }
.proj-card-del { background: none; border: none; cursor: pointer; color: #ccc; font-size: 16px; padding: 2px 4px; border-radius: 4px; transition: color .15s, background .15s; line-height: 1; }
.proj-card-del:hover { color: #C0392B; background: #FEF0EE; }

.dash-empty { text-align: center; padding: 60px 24px; color: #aaa; }
.dash-empty-icon { font-size: 48px; margin-bottom: 16px; opacity: .35; }
.dash-empty p { font-size: 14px; font-weight: 500; line-height: 1.7; margin-bottom: 24px; }

/* Modal */
.modal-overlay { display: none; position: fixed; inset: 0; background: rgba(20,33,52,.65); z-index: 9000; align-items: center; justify-content: center; padding: 24px; }
.modal-overlay.open { display: flex; }
.modal-box { background: #fff; border-radius: 14px; padding: 32px; width: 100%; max-width: 460px; box-shadow: 0 20px 60px rgba(0,0,0,.25); }
.modal-box h2 { font-size: 20px; font-weight: 700; color: #144584; margin-bottom: 24px; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 24px; }
.modal-box label { display: block; font-size: 11px; font-weight: 700; color: #144584; letter-spacing: .08em; margin-bottom: 6px; }
.modal-box input { width: 100%; border: 1.5px solid #CDCDCD; border-radius: 8px; padding: 10px 14px; font-family: 'Poppins', system-ui, sans-serif; font-size: 14px; font-weight: 500; color: #323949; outline: none; transition: border-color .15s; }
.modal-box input:focus { border-color: #144584; box-shadow: 0 0 0 3px rgba(20,69,132,.08); }
.modal-row { display: flex; gap: 12px; }
.modal-row .modal-field { flex: 1; }
.modal-field { margin-bottom: 16px; }
.modal-field:last-child { margin-bottom: 0; }

/* Projekt-Badge im Header */
.proj-badge { font-size: 13px; font-weight: 600; color: rgba(255,255,255,.8); max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ── WEG Einkommensbonus ───────────────────── */
.weg-dist-bar {
  display: flex; height: 8px; border-radius: 4px; overflow: hidden;
  background: #EBEBEB; margin-bottom: 12px; gap: 2px;
}
.weg-dist-seg { height: 100%; min-width: 0; flex: 0; border-radius: 2px; transition: flex .25s ease; }
.seg-40pct { background: #6f3d9e; }
.seg-30pct { background: #9b6ac2; }
.seg-10pct { background: #c4a8d8; }
.seg-none  { background: #D8D8D8; }

.weg-eink-grid {
  display: grid;
  grid-template-columns: 36px 1fr 1fr;
  gap: 8px 10px;
  align-items: center;
}
.weg-eink-hdr {
  font-size: 9px; font-weight: 700; color: #999;
  letter-spacing: .07em; text-transform: uppercase;
  padding-bottom: 5px; border-bottom: 1px solid #EBEBEB;
}
.weg-eink-rate { font-size: 12px; font-weight: 700; color: #6f3d9e; text-align: right; }
.weg-eink-cell { display: flex; flex-direction: column; gap: 4px; }
.weg-eink-threshold { font-size: 10px; font-weight: 600; color: #bbb; padding-left: 4px; white-space: nowrap; }
.weg-eink-status {
  grid-column: 1 / -1; font-size: 11px; font-weight: 600; color: #555;
  padding-top: 8px; border-top: 1px solid #EBEBEB; margin-top: 2px;
}
.weg-eink-status.ok   { color: #1a7d3c; }
.weg-eink-status.warn { color: #C0392B; }

.weg-stepper {
  display: flex; align-items: center; width: fit-content;
  border: 1.5px solid #CDCDCD; border-radius: 8px; overflow: hidden;
}
.weg-step-btn {
  background: #F4F7FB; border: none; color: #323949;
  font-size: 17px; font-weight: 400; line-height: 1; cursor: pointer;
  width: 28px; height: 34px; display: flex; align-items: center; justify-content: center;
  padding: 0; flex-shrink: 0; transition: background .12s, color .12s; user-select: none;
}
.weg-step-btn:hover:not(:disabled) { background: #144584; color: #fff; }
.weg-step-btn:disabled { opacity: .25; cursor: default; }
.weg-stepper input[type="number"] {
  width: 36px; border: none; border-left: 1px solid #EBEBEB; border-right: 1px solid #EBEBEB;
  border-radius: 0; padding: 0; text-align: center; height: 34px;
  font-size: 14px; font-weight: 700; color: #323949; background: #fff;
  box-shadow: none !important; -moz-appearance: textfield;
}
.weg-stepper input[type="number"]::-webkit-outer-spin-button,
.weg-stepper input[type="number"]::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.weg-stepper input[type="number"]:focus { outline: none; border-color: #EBEBEB; }

/* ── Footer ────────────────────────────────── */
footer { background: #323949; color: #CDCDCD; font-size: 12px; font-weight: 500; padding: 18px 40px; display: flex; justify-content: space-between; flex-wrap: wrap; gap: 8px; }
footer a { color: #6BB96D; font-weight: 700; text-decoration: none; }
footer .footer-right { display: flex; align-items: center; gap: 16px; }
#build-info { opacity: .55; }

/* ── Responsive ─────────────────────────────── */
@media (max-width: 800px) {
  header { padding: 16px 20px; }
  .header-back { display: none; }
  main { padding: 36px 16px 60px; }
  h1 { font-size: 24px; }
  .subtitle { margin-bottom: 32px; }
  .cards { grid-template-columns: 1fr; }
  .calc-layout { grid-template-columns: 1fr; }
  .form-card { position: static; }
  footer { padding: 16px 20px; }
}
