/* IMMOapp Web – Petrol-Design wie in der Android-App */

:root {
  --primary: #0B6E79;
  --primary-dunkel: #08525A;
  --primary-hell: #79AFB5;
  --primary-tint: #E2EEEF;
  --blau: #2563A8;
  --ink: #13202E;
  --ink-muted: #4A5563;
  --hintergrund: #F4F6F8;
  --flaeche: #FFFFFF;
  --rahmen: #E1E6EC;
  --feld-rahmen: #C9D1DA;
  --positiv: #1E7A4C;
  --negativ: #B3261E;
  --zebra: #F7F8FA;
  --radius: 16px;
  --schrift: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: light;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--hintergrund);
  color: var(--ink);
  font-family: var(--schrift);
  font-size: 16px;
  line-height: 1.45;
  -webkit-tap-highlight-color: transparent;
}

a { color: var(--primary); }

button { font: inherit; }

.zahl, td, .wert { font-variant-numeric: tabular-nums; }

/* ---------- Kopfzeile ---------- */

.kopf {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 4px;
  min-height: 56px;
  padding: env(safe-area-inset-top) max(8px, env(safe-area-inset-right)) 0 max(8px, env(safe-area-inset-left));
  background: var(--flaeche);
  border-bottom: 1px solid var(--rahmen);
}

.kopf h1 {
  flex: 1;
  margin: 0 0 0 8px;
  font-size: 19px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.kopf .zurueck {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 50%;
  background: none;
  color: var(--ink);
  cursor: pointer;
}
.kopf .zurueck:hover { background: var(--hintergrund); }
.kopf .zurueck[hidden] { display: none; }

.kopf .logo {
  width: 32px;
  height: 32px;
  margin-right: 8px;
  border-radius: 8px;
}

/* ---------- Inhalt ---------- */

main {
  max-width: 720px;
  margin: 0 auto;
  padding: 16px 16px 120px;
}

body.startseite .kopf { display: none; }
body.startseite main { padding-top: max(16px, env(safe-area-inset-top)); padding-bottom: 32px; }

.einleitung {
  margin: 0 0 16px;
  color: var(--ink-muted);
  font-size: 15px;
}

.abschnitt {
  margin: 24px 0 10px;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-muted);
}

.karte {
  background: var(--flaeche);
  border: 1px solid var(--rahmen);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 12px;
}

.karte > h2 {
  margin: 0 0 12px;
  font-size: 16px;
  font-weight: 600;
}

/* ---------- Startseite ---------- */

.start-kopf {
  display: flex;
  align-items: center;
  gap: 14px;
  margin: 8px 0 4px;
}
.start-kopf img { width: 56px; height: 56px; border-radius: 14px; }
.start-kopf h1 { margin: 0; font-size: 24px; }
.start-kopf p { margin: 0; color: var(--ink-muted); font-size: 14px; }

.kacheln {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.kachel {
  display: flex;
  flex-direction: column;
  padding: 16px;
  background: var(--flaeche);
  border: 1px solid var(--rahmen);
  border-radius: var(--radius);
  color: inherit;
  text-decoration: none;
  transition: border-color .15s, box-shadow .15s;
}
.kachel:hover { border-color: var(--primary-hell); box-shadow: 0 2px 10px rgba(11, 110, 121, .08); }
.kachel strong { margin-top: 10px; font-size: 15px; font-weight: 600; line-height: 1.3; }
.kachel > span:last-child { margin-top: 4px; font-size: 13px; color: var(--ink-muted); }

.icon-flaeche {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  flex: none;
  border-radius: 12px;
  background: var(--primary-tint);
  color: var(--primary);
}
.icon-flaeche svg { width: 22px; height: 22px; }

.liste-karte { padding: 0; overflow: hidden; }

.listeneintrag {
  display: flex;
  align-items: center;
  gap: 14px;
  min-height: 72px;
  padding: 12px 12px 12px 16px;
  color: inherit;
  text-decoration: none;
}
.listeneintrag + .listeneintrag { border-top: 1px solid var(--rahmen); }
.listeneintrag:hover { background: var(--zebra); }
.listeneintrag div { flex: 1; min-width: 0; }
.listeneintrag strong { display: block; font-size: 15px; font-weight: 600; }
.listeneintrag div span { display: block; font-size: 13px; color: var(--ink-muted); }
.listeneintrag > svg { width: 20px; height: 20px; color: var(--ink-muted); flex: none; }

.installhinweis {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  margin-top: 16px;
  padding: 14px 16px;
  border-radius: var(--radius);
  background: var(--primary-tint);
  font-size: 14px;
}
.installhinweis p { margin: 0; }
.installhinweis button {
  margin-left: auto;
  border: 0;
  background: none;
  color: var(--ink-muted);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
}

.fuss {
  margin-top: 28px;
  text-align: center;
  font-size: 13px;
  color: var(--ink-muted);
}
.fuss nav { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px 18px; margin-bottom: 8px; }

/* ---------- Formular ---------- */

.felder {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px 12px;
}
.feld { min-width: 0; }
.feld.breit { grid-column: 1 / -1; }
.feld[hidden] { display: none; }

.feld label {
  display: block;
  margin-bottom: 6px;
  font-size: 14px;
  font-weight: 500;
}
.feld label small { font-weight: 400; color: var(--ink-muted); }

.eingabe {
  display: flex;
  align-items: center;
  min-height: 48px;
  border: 1px solid var(--feld-rahmen);
  border-radius: 12px;
  background: var(--flaeche);
  transition: border-color .15s, box-shadow .15s;
}
.eingabe:focus-within { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(11, 110, 121, .15); }
.eingabe input {
  flex: 1;
  min-width: 0;
  height: 46px;
  padding: 0 12px;
  border: 0;
  border-radius: 12px;
  background: transparent;
  color: var(--ink);
  font: inherit;
  font-size: 16px; /* verhindert das automatische Zoomen auf dem iPhone */
  font-variant-numeric: tabular-nums;
  outline: none;
}
.eingabe .einheit { padding-right: 12px; color: var(--ink-muted); font-size: 15px; white-space: nowrap; }

.feld .hilfe { margin: 4px 2px 0; font-size: 12px; color: var(--ink-muted); }
.feld .fehlertext { display: none; margin: 4px 2px 0; font-size: 13px; color: var(--negativ); }
.feld.fehler .eingabe { border-color: var(--negativ); }
.feld.fehler .eingabe:focus-within { box-shadow: 0 0 0 3px rgba(179, 38, 30, .15); }
.feld.fehler .fehlertext { display: block; }
.feld.fehler .hilfe { display: none; }

.umschalter {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  padding: 4px;
  margin-bottom: 16px;
  border-radius: 12px;
  background: var(--hintergrund);
  border: 1px solid var(--rahmen);
}
.umschalter button {
  min-height: 40px;
  border: 0;
  border-radius: 9px;
  background: none;
  color: var(--ink-muted);
  font-weight: 500;
  cursor: pointer;
}
.umschalter button[aria-pressed="true"] {
  background: var(--flaeche);
  color: var(--primary);
  box-shadow: 0 1px 3px rgba(19, 32, 46, .12);
}

details.mehr { margin-top: 4px; }
details.mehr summary {
  cursor: pointer;
  padding: 6px 0;
  color: var(--primary);
  font-weight: 500;
  list-style: none;
}
details.mehr summary::-webkit-details-marker { display: none; }
details.mehr summary::before { content: "+ "; }
details.mehr[open] summary::before { content: "− "; }
details.mehr .felder { margin-top: 10px; }

/* ---------- Schaltflächen ---------- */

.knopf {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 48px;
  padding: 0 20px;
  border: 1px solid transparent;
  border-radius: 12px;
  background: var(--primary);
  color: #fff;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
}
.knopf:hover { background: var(--primary-dunkel); }
.knopf.umriss { background: var(--flaeche); border-color: var(--feld-rahmen); color: var(--primary); }
.knopf.umriss:hover { background: var(--primary-tint); }
.knopf.text { background: none; color: var(--primary); padding: 0 8px; min-height: 40px; }
.knopf.text:hover { background: var(--primary-tint); }
.knopf.voll { width: 100%; }
.knopf svg { width: 20px; height: 20px; }

.leiste {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 10;
  background: var(--flaeche);
  border-top: 1px solid var(--rahmen);
  padding: 12px max(16px, env(safe-area-inset-right)) calc(12px + env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
}
.leiste div {
  display: grid;
  grid-template-columns: 1fr 2fr;
  gap: 12px;
  max-width: 720px;
  margin: 0 auto;
}

/* ---------- Ergebnis ---------- */

.ergebnis { margin-top: 24px; scroll-margin-top: 72px; }
.ergebnis[hidden] { display: none; }

.zusammenfassung {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
  font-size: 14px;
  color: var(--ink-muted);
}
.zusammenfassung span { flex: 1; }

.held {
  padding: 20px;
  margin-bottom: 12px;
  border-radius: 18px;
  background: var(--primary);
  color: #fff;
}
.held .label { font-size: 14px; opacity: .85; }
.held .wert { margin: 2px 0 6px; font-size: 34px; font-weight: 700; letter-spacing: -0.01em; }
.held .details { font-size: 14px; opacity: .85; }

.kpis {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 12px;
}
.kpi {
  padding: 14px 16px;
  background: var(--flaeche);
  border: 1px solid var(--rahmen);
  border-radius: var(--radius);
}
.kpi .label { font-size: 13px; color: var(--ink-muted); }
.kpi .wert { margin-top: 2px; font-size: 20px; font-weight: 600; }

.negativ { color: var(--negativ); }
.positiv { color: var(--positiv); }

.zeilen { margin: 0; }
.zeile {
  display: flex;
  align-items: baseline;
  gap: 12px;
  padding: 7px 0;
  font-size: 15px;
}
.zeile + .zeile { border-top: 1px solid var(--zebra); }
.zeile dt { flex: 1; color: var(--ink-muted); }
.zeile dd { margin: 0; text-align: right; font-weight: 500; font-variant-numeric: tabular-nums; }
.zeile.einzug dt { padding-left: 14px; }
.zeile .punkt { display: inline-block; width: 10px; height: 10px; margin-right: 10px; border-radius: 3px; vertical-align: 0; }
.zeile.mit-punkt dt { color: var(--ink); }

.balken {
  display: flex;
  gap: 2px;
  height: 14px;
  margin: 4px 0 12px;
}
.balken span { border-radius: 3px; }

.fazit {
  margin: 4px 0 12px;
  padding: 14px 16px;
  border-radius: var(--radius);
  background: var(--primary-tint);
  color: var(--primary-dunkel);
  font-weight: 600;
  font-size: 16px;
}

.hinweis { font-size: 13px; color: var(--ink-muted); margin: 8px 0 0; }

.meldung {
  padding: 16px;
  border-radius: var(--radius);
  background: var(--flaeche);
  border: 1px solid var(--rahmen);
}

/* Diagramme */
.diagramm { width: 100%; min-height: 240px; }
.diagramm svg { display: block; width: 100%; height: auto; overflow: visible; }
.diagramm text { font-family: var(--schrift); font-size: 11px; fill: var(--ink-muted); }
.legende { display: flex; flex-wrap: wrap; gap: 6px 16px; margin-top: 10px; font-size: 13px; }
.legende span { display: inline-flex; align-items: center; gap: 6px; }
.legende i { display: inline-block; width: 12px; height: 12px; border-radius: 3px; }
.legende i.linie { height: 3px; border-radius: 2px; }

/* Jahrestabelle */
.tabelle-rahmen { overflow-x: auto; margin: 0 -16px -16px; border-top: 1px solid var(--rahmen); }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { padding: 9px 12px; text-align: right; white-space: nowrap; }
th:first-child, td:first-child { text-align: left; padding-left: 16px; }
th:last-child, td:last-child { padding-right: 16px; }
thead th { position: sticky; top: 0; background: var(--primary-tint); font-weight: 600; }
tbody tr:nth-child(even) { background: var(--zebra); }

.steuerbalken { display: block; height: 8px; border-radius: 4px; background: var(--primary-hell); }
tr.aktuell td { font-weight: 700; color: var(--primary-dunkel); }

.aktionen { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 4px; }
.aktionen .knopf { flex: 1 1 200px; }

/* Infotext */
.info h2 { font-size: 17px; margin: 0 0 8px; }
.info p { margin: 0 0 10px; }
.info p:last-child { margin-bottom: 0; }

.nur-druck { display: none; }

/* Impressum und Datenschutz */
.platzhalter { color: var(--negativ); font-weight: 600; }
.meldung.warnung { margin-bottom: 12px; border-color: var(--negativ); background: #FDF2F1; font-size: 14px; }
.meldung code { font-size: 13px; }
.info a { word-break: break-word; }

@media (max-width: 380px) {
  .felder { grid-template-columns: 1fr; }
  .held .wert { font-size: 30px; }
}

@media (min-width: 640px) {
  .kacheln { grid-template-columns: repeat(4, 1fr); }
  .kpis { grid-template-columns: repeat(4, 1fr); }
}

/* ---------- Druck / PDF ---------- */

@media print {
  @page { size: A4; margin: 14mm 12mm; }
  body { background: #fff; font-size: 11pt; }
  .kopf, .leiste, .formular, .zusammenfassung, .aktionen, .einleitung, .installhinweis, .fuss { display: none !important; }
  main { max-width: none; padding: 0; }
  .nur-druck { display: block; }
  .druck-kopf { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; padding-bottom: 10px; border-bottom: 2px solid var(--primary); }
  .druck-kopf img { width: 40px; height: 40px; border-radius: 8px; }
  .druck-kopf h1 { margin: 0; font-size: 18pt; }
  .druck-kopf p { margin: 0; color: var(--ink-muted); font-size: 10pt; }
  .ergebnis { margin-top: 0; }
  .karte, .kpi, .held, .fazit { break-inside: avoid; }
  .karte.lang { break-inside: auto; }
  .held, .fazit, thead th, .punkt, .balken span, .legende i, .steuerbalken { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .kpis { grid-template-columns: repeat(4, 1fr); }
  .tabelle-rahmen { overflow: visible; margin: 0; }
  thead { display: table-header-group; }
  tr { break-inside: avoid; }
}
