:root {
  --bg: #f4f5f7; --karte: #fff; --text: #1f2933; --leise: #6b7480; --linie: #e1e4e8;
  --haupt: #1d5fa8; --haupt-h: #174d8a; --rot: #c0392b; --gruen: #2e7d4f; --gelb: #b7791f;
  --radius: 10px;
}
* { box-sizing: border-box; }
body { margin: 0; font: 15px/1.45 "Segoe UI", system-ui, sans-serif; background: var(--bg); color: var(--text); }
a { color: var(--haupt); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 24px; margin: 0 0 4px; }
h2 { font-size: 18px; margin: 0 0 12px; }
h3 { font-size: 16px; margin: 0 0 10px; }

.kopf { position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: 18px; flex-wrap: wrap;
  padding: 10px 24px; background: #1f2933; color: #fff; }
.kopf .marke { color: #fff; font-weight: 700; font-size: 17px; }
.kopf nav { display: flex; gap: 4px; flex-wrap: wrap; }
.kopf nav a { color: #cfd6de; padding: 6px 10px; border-radius: 6px; }
.kopf nav a:hover, .kopf nav a.aktiv { background: #33414f; color: #fff; text-decoration: none; }
.kopf .suche { flex: 1; min-width: 180px; }
.kopf .suche input { width: 100%; border: 0; background: #33414f; color: #fff; }
.kopf .suche input::placeholder { color: #9aa5b1; }

main { padding: 20px 24px 60px; }
.seitenkopf { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; margin-bottom: 16px; }
.pfad { font-size: 13px; color: var(--leise); margin-bottom: 2px; }
.leise { color: var(--leise); font-weight: normal; }
.hinweis { color: var(--leise); font-size: 13px; margin: 4px 0 10px; }
.warnung { color: var(--gelb); }
.leer { color: var(--leise); font-style: italic; }

.karte { background: var(--karte); border: 1px solid var(--linie); border-radius: var(--radius); padding: 18px 20px; margin-bottom: 18px; }
.karte-kopf { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 10px; }
.karte-kopf h2, .karte-kopf h3 { margin: 0; }
.anzahl { background: var(--bg); color: var(--leise); border-radius: 10px; padding: 1px 8px; font-size: 12px; font-weight: 600; }

.zweispaltig { display: grid; grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); gap: 18px; }
.kacheln { display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: 18px; }
@media (max-width: 900px) { .zweispaltig { grid-template-columns: 1fr; } main { padding: 14px; } }

label { display: block; font-size: 13px; color: var(--leise); margin-bottom: 10px; }
input, select, textarea { display: block; width: 100%; margin-top: 3px; padding: 7px 9px; font: inherit; color: var(--text);
  border: 1px solid #cbd2d9; border-radius: 6px; background: #fff; }
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid #9cc3ef; border-color: var(--haupt); }
.raster { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 0 14px; }
.raster.zwei { grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
label.haken { display: flex; align-items: center; gap: 8px; color: var(--text); }
label.haken input { width: auto; margin: 0; }
.zeile { display: flex; gap: 8px; margin-bottom: 10px; }
.zeile input { margin: 0; }

.knopf { display: inline-block; padding: 8px 14px; border-radius: 7px; border: 1px solid #cbd2d9; background: #fff; color: var(--text);
  font: inherit; font-weight: 600; cursor: pointer; text-decoration: none; white-space: nowrap; }
.knopf:hover { background: #eef1f4; text-decoration: none; }
.knopf.haupt { background: var(--haupt); border-color: var(--haupt); color: #fff; }
.knopf.haupt:hover { background: var(--haupt-h); }
.knopf.leise { font-weight: 500; }
.knopf.klein { padding: 5px 10px; font-size: 13px; }
.knopf:disabled { opacity: .5; cursor: not-allowed; }
.knopfreihe { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

.tabelle { width: 100%; border-collapse: collapse; }
.tabelle th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .03em; color: var(--leise); font-weight: 600;
  border-bottom: 1px solid var(--linie); padding: 6px 8px; }
.tabelle td { border-bottom: 1px solid #f0f2f4; padding: 8px; vertical-align: top; }
.tabelle .r { text-align: right; white-space: nowrap; }
tr.klickbar { cursor: pointer; }
tr.klickbar:hover td { background: #f7f9fb; }
tr.gewaehlt td { background: #eaf2fb; }

.badge { display: inline-block; padding: 1px 8px; border-radius: 10px; font-size: 12px; font-weight: 600; background: #eef1f4; color: var(--leise); }
.s-offen { background: #fde8e6; color: var(--rot); }
.s-beauftragt { background: #e6effa; color: var(--haupt); }
.s-erledigt { background: #e3f3e9; color: var(--gruen); }
.s-abgerechnet { background: #eef1f4; color: #4a5560; }
.s-storniert { background: #eef1f4; color: #9aa5b1; text-decoration: line-through; }
.d-dringend { background: #fdf3e1; color: var(--gelb); }
.d-notfall { background: var(--rot); color: #fff; }

.kennzahlen { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 14px; margin-bottom: 18px; }
.kz { background: var(--karte); border: 1px solid var(--linie); border-radius: var(--radius); padding: 14px 16px; color: var(--text); }
.kz:hover { text-decoration: none; border-color: #b8c2cc; }
.kz b { display: block; font-size: 28px; }
.kz span { color: var(--leise); font-size: 13px; }
.kz.warn b { color: var(--rot); }

.reiter { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 14px; }
.reiter a { background: var(--karte); border: 1px solid var(--linie); border-radius: 20px; padding: 4px 12px; font-size: 13px; }
[id] { scroll-margin-top: 70px; }

.mieter { border-bottom: 1px solid #f0f2f4; padding: 8px 0; }
.mieter.ehemalig { opacity: .7; }
.mieter-kopf { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
details summary { cursor: pointer; color: var(--haupt); font-size: 13px; margin: 4px 0; }
details[open] summary { margin-bottom: 10px; }
.neu-mieter { margin-top: 12px; }
.neu-mieter summary { list-style: none; display: inline-block; }

.galerie { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; margin-bottom: 12px; }
.galerie figure { margin: 0; position: relative; border: 1px solid var(--linie); border-radius: 8px; overflow: hidden; background: #fafbfc; }
.galerie img, .galerie .dok { display: block; width: 100%; height: 115px; object-fit: cover; }
.galerie .dok { display: flex; align-items: center; justify-content: center; font-weight: 700; color: var(--leise); background: #eef1f4; }
.galerie figcaption { font-size: 12px; padding: 5px 7px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.titelbild { color: var(--gruen); margin-right: 4px; }
.fig-knoepfe { position: absolute; top: 5px; right: 5px; display: flex; gap: 4px; }
.mini { border: 0; border-radius: 5px; width: 26px; height: 26px; background: rgba(255,255,255,.9); cursor: pointer; font-size: 13px; }
.mini.rot { color: var(--rot); }
.ablagezone { position: relative; display: block; border: 2px dashed #cbd2d9; border-radius: 8px; padding: 14px; text-align: center; color: var(--leise); cursor: pointer; margin: 0; }
.ablagezone:hover, .ablagezone.drueber { border-color: var(--haupt); background: #f3f8fe; }
.ablagezone input { position: absolute; inset: 0; opacity: 0; cursor: pointer; margin: 0; }

.verlauf { list-style: none; padding: 0; margin: 0; font-size: 14px; }
.verlauf li { padding: 5px 0; border-bottom: 1px solid #f0f2f4; }
.verlauf .leise { font-size: 12px; margin-right: 6px; }

.meldung { padding: 10px 14px; border-radius: 8px; margin-bottom: 14px; font-weight: 500; }
.meldung.ok { background: #e3f3e9; color: var(--gruen); }
.meldung.fehler { background: #fde8e6; color: var(--rot); }
.filter { display: flex; gap: 14px; flex-wrap: wrap; padding: 12px 20px 2px; }
.filter label { min-width: 220px; }

/* Dashboard */
.dash { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 18px; align-items: start; }
@media (max-width: 1000px) { .dash { grid-template-columns: minmax(0, 1fr); } }
.dash-seite .karte { padding: 14px 16px; }
.dash-seite p { margin: 0 0 10px; }
.klein { font-size: 13px; }
.balken { display: block; height: 6px; background: #eef1f4; border-radius: 3px; margin-top: 8px; overflow: hidden; }
.balken > i { display: block; height: 100%; background: var(--haupt); border-radius: 3px; }
.balken.duenn { height: 4px; }
.statusleiste { display: flex; gap: 10px; flex-wrap: wrap; font-size: 13px; }
.statusleiste a { color: var(--text); }
.hinweis-karte { border-left: 4px solid var(--gelb); }
.liste { list-style: none; padding: 0; margin: 0; }
.liste li { padding: 6px 0; border-bottom: 1px solid #f0f2f4; }
.liste li .leise { display: block; font-size: 13px; }
.objektkacheln { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 12px; }
.objektkachel { display: block; border: 1px solid var(--linie); border-radius: 8px; padding: 12px; color: var(--text); }
.objektkachel:hover { border-color: #b8c2cc; background: #fafbfc; text-decoration: none; }
.ok-kopf { display: flex; justify-content: space-between; gap: 6px; align-items: center; }
.belegung { display: flex; gap: 3px; flex-wrap: wrap; margin: 8px 0 4px; }
.belegung i { width: 14px; height: 14px; border-radius: 3px; }
.belegung i.voll { background: var(--gruen); }
.belegung i.frei { background: #fff; border: 2px solid var(--rot); }

.summe { margin: 6px 0 0; font-size: 15px; }

.tabelle-scroll { overflow-x: auto; }
.empfaenger { max-height: 520px; overflow-y: auto; }
.empfaenger .haken { margin-bottom: 6px; }
.mietart { display: flex; gap: 18px; }

/* Anmeldung */
.benutzer-kopf { color: #cfd6de; font-size: 13px; white-space: nowrap; }
.benutzer-kopf:hover { color: #fff; }
body.anmeldung main { max-width: 420px; padding-top: 12vh; }
.anmeldekarte h1 { margin-bottom: 14px; }

.zeile-mit-knopf { display: flex; justify-content: space-between; align-items: center; gap: 10px; }

details.inline { display: inline-block; position: relative; }
details.inline[open] .sp-form { position: absolute; right: 0; z-index: 5; background: var(--karte); border: 1px solid var(--linie);
  border-radius: 8px; padding: 12px; width: 300px; box-shadow: 0 6px 20px rgba(0,0,0,.12); }

/* Zähler */
.zaehler-gruppe { margin: 16px 0 4px; }
.zaehler-gruppe h3 { font-size: 15px; }
tr.ehemalig { opacity: .6; }
.zaehlerfoto { width: 54px; height: 54px; object-fit: cover; border-radius: 5px; border: 1px solid var(--linie); margin: 0 4px 4px 0; vertical-align: middle; }
.foto-nach { display: inline-block; }
.foto-nach label { margin: 0; }
label.haken { display: flex; gap: 8px; align-items: center; font-weight: normal; }
label.haken input { width: auto; margin: 0; }
.reiter a.aktiv { background: var(--haupt); border-color: var(--haupt); color: #fff; }
.tabelle.ablesung input[type=file] { max-width: 220px; font-size: 12px; }
[hidden] { display: none !important; }

/* Mietauswertung: sortierbare Spaltenköpfe */
a.sortkopf { color: inherit; text-decoration: none; white-space: nowrap; }
a.sortkopf:hover { text-decoration: underline; }

/* Handy-Code einrichten */
.qr-bild { background: #fff; display: inline-block; padding: 8px; }

/* Abnahmeformular, auch auf dem Handy */
.ab-zeile { display: flex; flex-wrap: wrap; gap: 0 12px; align-items: flex-end; border-bottom: 1px solid var(--linie); padding: 8px 0; }
.ab-zeile > label { flex: 1 1 150px; }
.ab-zeile > .ab-breit { flex: 3 1 240px; }
.ab-zeile > .ab-zahl { flex: 0 1 90px; }
.ab-zeile > .haken { flex: 0 0 auto; }
.ab-unterschriften { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 16px; }
.ab-unterschrift canvas { display: block; width: 100%; height: auto; border: 1px solid var(--linie); border-radius: 6px; background: #fff; touch-action: none; margin: 4px 0 6px; }
.ab-leiste { position: sticky; bottom: 0; display: flex; flex-wrap: wrap; gap: 10px; justify-content: flex-end; padding: 10px 0; background: var(--grund, #f3f4f6); z-index: 5; }
input[type=checkbox], input[type=radio] { flex: none; }

/* Auf dem Handy nimmt der Kopf sonst den halben Bildschirm ein */
@media (max-width: 1000px), (pointer: coarse) { .kopf { position: static; } }

/* Breite Tabellen rollen innerhalb ihrer Karte, die Seite selbst bleibt so breit wie der Bildschirm */
.karte { min-width: 0; overflow-x: auto; }

/* Aktualisieren am Computer */
.kopf .neu-laden { background: #33414f; color: #fff; border: 0; }

/* iPhone-Oberfläche: Leisten sind nur auf dem Handy sichtbar */
.ios-kopf, .ios-tabs, .ios-mehr { display: none; }
@media (max-width: 820px), (pointer: coarse) and (max-width: 1000px) {
  :root { --bg: #f2f2f7; --haupt: #007aff; --haupt-h: #0062cc; --linie: #e5e5ea; --radius: 12px; --text: #1c1c1e; --leise: #8a8a8e; }
  body { font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", sans-serif; font-size: 16px; -webkit-text-size-adjust: 100%; }
  .kopf { display: none; }
  main { padding: 8px 16px calc(84px + env(safe-area-inset-bottom)); }
  body.anmeldung main { padding: 12vh 16px 40px; }
  h1 { font-size: 30px; font-weight: 700; letter-spacing: -.3px; }
  input, select, textarea { font-size: 16px; min-height: 44px; border-radius: 10px; }   /* unter 16 px vergrößert Safari die Seite beim Tippen */
  input[type=checkbox], input[type=radio] { min-height: 0; width: 22px; height: 22px; }
  textarea { min-height: 70px; }
  .knopf { min-height: 44px; border-radius: 10px; display: inline-flex; align-items: center; justify-content: center; }
  .knopf.klein { min-height: 36px; }
  .karte { border: 0; padding: 14px 16px; margin-bottom: 14px; box-shadow: none; }
  .filter label { min-width: 0; flex: 1 1 100%; }
  .kacheln { grid-template-columns: minmax(0, 1fr); }
  .ab-leiste { bottom: calc(50px + env(safe-area-inset-bottom)); background: var(--bg); }
  body.leisten-weg .ab-leiste { bottom: env(safe-area-inset-bottom); }

  .ios-kopf { display: flex; position: sticky; top: 0; z-index: 20; align-items: center; justify-content: space-between; gap: 4px;
    height: calc(44px + env(safe-area-inset-top)); padding: env(safe-area-inset-top) 6px 0; background: rgba(242, 242, 247, .85);
    -webkit-backdrop-filter: blur(20px); backdrop-filter: blur(20px); border-bottom: .5px solid #c6c6c8; transition: transform .2s; }
  .ios-titel { flex: 1; min-width: 0; text-align: center; font-weight: 600; font-size: 17px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .ios-symbol { width: 44px; height: 44px; padding: 10px; background: none; border: 0; color: var(--haupt); flex: none; }
  .ios-symbol[hidden] { visibility: hidden; display: block; }
  .ios-symbol svg, .ios-tabs svg { width: 100%; height: 100%; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

  .ios-tabs { display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; padding: 4px 2px env(safe-area-inset-bottom);
    background: rgba(249, 249, 249, .9); -webkit-backdrop-filter: blur(20px); backdrop-filter: blur(20px); border-top: .5px solid #c6c6c8; transition: transform .2s; }
  .ios-tabs a, .ios-tabs button { flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: center; gap: 1px; padding: 2px 0; background: none; border: 0;
    color: #8a8a8e; font-size: 10px; font-family: inherit; text-decoration: none; }
  .ios-tabs svg { width: 25px; height: 25px; }
  .ios-tabs .aktiv { color: var(--haupt); }
  body.leisten-weg .ios-tabs { transform: translateY(110%); }
  body.leisten-weg .ios-kopf { transform: translateY(-110%); }

  .ios-mehr { display: flex; position: fixed; inset: 0; z-index: 30; align-items: flex-end; background: rgba(0, 0, 0, .35); }
  .ios-mehr[hidden] { display: none; }
  .ios-blatt { width: 100%; max-height: 85vh; overflow-y: auto; padding: 14px 16px calc(14px + env(safe-area-inset-bottom)); background: var(--bg); border-radius: 14px 14px 0 0; }
  .ios-blatt input { margin: 0 0 12px; background: #e3e3e9; border: 0; }
  .ios-liste { background: #fff; border-radius: 12px; overflow: hidden; }
  .ios-liste a { display: block; padding: 12px 16px; color: var(--text); border-bottom: .5px solid var(--linie); font-size: 17px; }
  .ios-liste a:last-child { border-bottom: 0; }
  .ios-liste a.rot { color: #ff3b30; }
  .ios-schliessen { width: 100%; margin-top: 12px; min-height: 48px; background: #fff; border: 0; border-radius: 12px; color: var(--haupt); font: inherit; font-weight: 600; }

  /* Tabellen als Karten */
  table.tabelle, table.tabelle tbody, table.tabelle tr, table.tabelle td { display: block; width: 100%; }
  table.tabelle thead { display: none; }
  table.tabelle tr { padding: 8px 0; border-bottom: .5px solid var(--linie); }
  table.tabelle tr:last-child { border-bottom: 0; }
  table.tabelle td { display: flex; justify-content: space-between; gap: 14px; padding: 3px 0; border: 0; text-align: right; }
  table.tabelle td::before { content: attr(data-titel); flex: none; max-width: 45%; color: var(--leise); font-size: 14px; text-align: left; }
  table.tabelle td:not([data-titel])::before, table.tabelle td[data-titel=""]::before { display: none; }
  table.tabelle td:not([data-titel]) { justify-content: flex-end; }
  table.tabelle td:empty { display: none; }
  table.tabelle td:first-child { font-weight: 600; }
}
@media (max-width: 820px), (pointer: coarse) and (max-width: 1000px) {
  .kennzahlen { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  table.tabelle td > *, table.tabelle td { overflow-wrap: anywhere; }
}
@media (max-width: 820px), (pointer: coarse) and (max-width: 1000px) {
  table.tabelle .zellwert { flex: 1; min-width: 0; text-align: right; }
  table.tabelle td:first-child .zellwert:only-child { text-align: left; }
}
