/* ============================================================================
   Wohnungs-Cockpit – Designsystem
   Professionell und ruhig, klar strukturiert, große Schrift und große
   Bedienflächen (für ältere Nutzer). Voll responsiv inkl. App-Ansicht mit
   unterer Tab-Leiste auf dem Handy.
   ========================================================================== */

:root {
  /* Grundfarben – ruhige, professionelle Palette */
  --bg:          #f3f4f6;
  --surface:     #ffffff;
  --surface-2:   #fafbfc;
  --ink:         #1f2933;
  --ink-soft:    #52606d;
  --ink-faint:   #7b8794;
  --line:        #e4e7eb;
  --line-stark:  #cbd2d9;

  /* Markenfarbe (Aktionen) */
  --brand:       #d75a22;
  --brand-dark:  #b5471a;
  --brand-tint:  #fbeadf;

  /* Ampel */
  --gruen:     #1f8a4c;  --gruen-bg:  #e6f4ec;
  --gelb:      #b7791f;  --gelb-bg:   #fbf1da;
  --rot:       #d13b3b;  --rot-bg:    #fbe4e4;

  --radius:   16px;
  --radius-s: 10px;
  --schatten:    0 1px 2px rgba(16,24,40,.05), 0 4px 14px rgba(16,24,40,.06);
  --schatten-s:  0 1px 2px rgba(16,24,40,.06);

  --nav-h: 66px;         /* untere Leiste (Handy) */
  --font: "Segoe UI", -apple-system, BlinkMacSystemFont, 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: 18px;
  line-height: 1.55;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

a { color: var(--brand-dark); }

h1 { font-size: 1.75rem; font-weight: 800; margin: 0 0 .25em; letter-spacing: -.01em; }
h2 { font-size: 1.35rem; font-weight: 800; margin: 1.3em 0 .5em; }
h3 { font-size: 1.12rem; font-weight: 700; margin: .2em 0 .6em; }
h4 { font-size: 1rem;    font-weight: 700; margin: .4em 0; }

/* ---------- Obere App-Leiste ---------- */
.appbar {
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  box-shadow: var(--schatten-s);
  position: sticky; top: 0; z-index: 40;
}
.appbar-inner {
  max-width: 1180px; margin: 0 auto;
  display: flex; align-items: center; gap: 1rem;
  padding: .55rem 1.1rem;
}
.brand {
  display: inline-flex; align-items: center; gap: .55rem;
  text-decoration: none; font-weight: 800; font-size: 1.2rem;
  color: var(--ink); white-space: nowrap;
}
.brand-icon { width: 30px; height: 30px; border-radius: 8px; display: block; }
.brand span { color: var(--ink); }

.topnav { display: flex; gap: .25rem; margin-left: .5rem; flex: 1; }
.topnav a {
  text-decoration: none; color: var(--ink-soft); font-weight: 600;
  padding: .55rem .85rem; border-radius: var(--radius-s);
  display: inline-flex; align-items: center; gap: .45rem;
}
.topnav a:hover { background: var(--surface-2); color: var(--ink); }
.topnav a.aktiv { background: var(--brand-tint); color: var(--brand-dark); }
.topnav .ico { font-size: 1.1rem; }

.nutzer-box { margin-left: auto; display: flex; align-items: center; gap: .7rem; }
.nutzer-name {
  font-weight: 700; color: var(--ink-soft); max-width: 180px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.logout {
  text-decoration: none; font-weight: 600;
  color: var(--ink-soft); padding: .5rem .9rem; border-radius: var(--radius-s);
  border: 1px solid var(--line); white-space: nowrap;
}
.logout:hover { background: var(--surface-2); }

/* ---------- Untere Tab-Leiste (App-Ansicht, nur Handy) ---------- */
.bottomnav { display: none; }

/* ---------- Layout ---------- */
main {
  max-width: 1180px; margin: 0 auto;
  padding: 1.5rem 1.1rem 3rem;
}
.kopf-zeile {
  display: flex; align-items: center; justify-content: space-between;
  gap: 1rem; flex-wrap: wrap; margin-bottom: .4rem;
}

/* ---------- Knöpfe ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
  font-family: inherit; font-size: 1rem; font-weight: 700; line-height: 1.1;
  padding: .75rem 1.25rem; min-height: 52px;
  border: 1px solid transparent; border-radius: 12px; cursor: pointer;
  text-decoration: none; transition: background .12s, box-shadow .12s, transform .04s;
  white-space: nowrap;
}
.btn:active { transform: translateY(1px); }
.btn-primar { background: var(--brand); color: #fff; box-shadow: var(--schatten-s); }
.btn-primar:hover { background: var(--brand-dark); }
.btn-grau  { background: var(--surface); color: var(--ink); border-color: var(--line-stark); }
.btn-grau:hover { background: var(--surface-2); }
.btn-rot   { background: var(--rot-bg); color: var(--rot); }
.btn-rot:hover { background: #f7d3d3; }
.btn-klein { min-height: 42px; padding: .45rem .85rem; font-size: .92rem; border-radius: 10px; }
.btn-gross { min-height: 60px; font-size: 1.1rem; padding: .9rem 1.6rem; }

/* ---------- Karten ---------- */
.karte {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--schatten);
  padding: 1.3rem 1.4rem; margin-bottom: 1.3rem;
}
.karte > h3:first-child { margin-top: 0; }

/* ---------- Statusleiste (Cockpit) ---------- */
.status-leiste { display: flex; gap: .7rem; flex-wrap: wrap; margin: 1.1rem 0 1.5rem; }
.status-pill {
  display: inline-flex; align-items: center; gap: .6rem;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 999px; padding: .5rem 1.1rem; font-weight: 600; color: var(--ink-soft);
  box-shadow: var(--schatten-s); text-decoration: none;
}
.status-pill .zahl { font-size: 1.35rem; font-weight: 800; color: var(--ink); }
.punkt { width: 20px; height: 20px; border-radius: 50%; display: inline-block; flex-shrink: 0; }
.punkt.gruen { background: var(--gruen); }
.punkt.gelb  { background: var(--gelb); }
.punkt.rot   { background: var(--rot); }

/* ---------- Kacheln (Wohnungen) ---------- */
.kacheln {
  display: grid; gap: 1.1rem;
  grid-template-columns: repeat(auto-fill, minmax(270px, 1fr));
}
.kachel {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--schatten);
  text-decoration: none; color: var(--ink);
  display: flex; flex-direction: column; overflow: hidden; position: relative;
  transition: transform .1s ease, box-shadow .1s ease;
}
.kachel::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 8px; background: var(--line-stark); }
.kachel.gruen::before { background: var(--gruen); }
.kachel.gelb::before  { background: var(--gelb); }
.kachel.rot::before   { background: var(--rot); }
.kachel:hover { transform: translateY(-2px); box-shadow: 0 8px 22px rgba(16,24,40,.12); }
.kachel-kopf { display: flex; align-items: center; justify-content: space-between; gap: .5rem; padding: 1.05rem 1.15rem .3rem 1.5rem; }
.kachel-haus { font-size: 1.7rem; line-height: 1; }
.kachel-body { padding: .2rem 1.15rem 1.15rem 1.5rem; flex: 1; }
.kachel .name { font-weight: 800; font-size: 1.1rem; line-height: 1.25; }
.kachel .adr { color: var(--ink-faint); font-size: .96rem; margin-top: .15rem; }
.kachel .zahlen { margin-top: .7rem; font-size: .95rem; color: var(--ink-soft); }
.kachel .zahlen b { color: var(--ink); }

/* ---------- Badges ---------- */
.badge {
  display: inline-flex; align-items: center; gap: .4rem;
  font-weight: 700; font-size: .88rem;
  padding: .3rem .7rem; border-radius: 999px; white-space: nowrap;
}
.badge.gruen { background: var(--gruen-bg); color: var(--gruen); }
.badge.gelb  { background: var(--gelb-bg);  color: var(--gelb); }
.badge.rot   { background: var(--rot-bg);   color: var(--rot); }
.badge.info  { background: #e7edf3; color: #3a4a5a; }
.badge .punkt { width: 12px; height: 12px; }

.beispiel-tag {
  font-size: .74rem; font-weight: 700; color: var(--ink-faint);
  background: #eef1f4; padding: .12rem .5rem; border-radius: 6px; margin-left: .4rem;
  vertical-align: middle;
}

/* Mieter auf der Kachel */
.mieter-zeile {
  margin-top: .55rem; font-weight: 700; color: var(--ink);
  display: flex; align-items: center; gap: .35rem;
}

/* Werkzeug-Leiste (Cockpit) */
.werkzeuge { display: flex; gap: .5rem; flex-wrap: wrap; margin: .2rem 0 .4rem; }

/* Fristen & Erinnerungen */
.fristen-karte summary { cursor: pointer; list-style: none; }
.fristen-karte summary::-webkit-details-marker { display: none; }
.fristen-karte .frist-titel { font-size: 1.12rem; font-weight: 700; }
.fristen-karte summary::before { content: "▸ "; color: var(--ink-faint); }
.fristen-karte[open] summary::before { content: "▾ "; }
.fristen-karte .liste li { padding-left: .6rem; border-left: 5px solid var(--line-stark); border-radius: 4px; margin-bottom: 2px; }
.frist-icon { font-size: 1.3rem; }
.frist-hoch   { border-left-color: var(--rot) !important; background: var(--rot-bg); }
.frist-mittel { border-left-color: var(--gelb) !important; background: var(--gelb-bg); }
.frist-niedrig{ border-left-color: var(--line-stark) !important; }
.frist-info   { border-left-color: var(--line-stark) !important; }

/* Umschalter Kacheln/Liste */
.ansicht-schalter {
  display: inline-flex; background: var(--surface); border: 1px solid var(--line);
  border-radius: 999px; padding: 3px; box-shadow: var(--schatten-s);
}
.ansicht-schalter a {
  text-decoration: none; color: var(--ink-soft); font-weight: 700;
  padding: .4rem .9rem; border-radius: 999px; font-size: .95rem;
}
.ansicht-schalter a.aktiv { background: var(--brand); color: #fff; }

/* ---------- Formulare ---------- */
form.stack { display: grid; gap: 1.1rem; }
.feld { display: flex; flex-direction: column; gap: .35rem; }
.feld label { font-weight: 700; color: var(--ink); }
.feld .hinweis { color: var(--ink-faint); font-size: .88rem; font-weight: 400; }
input[type=text], input[type=number], input[type=date], input[type=email],
input[type=tel], input[type=password], input[type=file], select, textarea {
  font-family: inherit; font-size: 1.02rem; color: var(--ink);
  padding: .72rem .85rem; border: 1.5px solid var(--line-stark);
  border-radius: var(--radius-s); background: #fff; width: 100%;
}
input:focus, select:focus, textarea:focus {
  outline: 3px solid var(--brand-tint); outline-offset: 0; border-color: var(--brand);
}
textarea { min-height: 92px; resize: vertical; }
.raster2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.raster3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 1rem; }
.aktionen { display: flex; gap: .8rem; flex-wrap: wrap; margin-top: .4rem; }

/* Auswahl-Kacheln (Status-Radios) */
.wahl {
  display: flex; align-items: center; gap: .55rem; cursor: pointer;
  border: 1.5px solid var(--line-stark); border-radius: var(--radius-s);
  padding: .7rem .85rem; font-weight: 700; background: #fff;
}
.wahl input { width: auto; margin: 0; accent-color: var(--brand); transform: scale(1.25); }
.wahl:hover { background: var(--surface-2); }

/* ---------- Tabellen / Listen ---------- */
.tabelle-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: .75rem .6rem; border-bottom: 1px solid var(--line); }
th { color: var(--ink-faint); font-size: .82rem; text-transform: uppercase; letter-spacing: .03em; font-weight: 700; }
tr:last-child td { border-bottom: none; }

.liste { list-style: none; padding: 0; margin: 0; }
.liste li {
  display: flex; align-items: center; gap: .85rem;
  padding: .8rem .1rem; border-bottom: 1px solid var(--line);
}
.liste li:last-child { border-bottom: none; }
.liste .erledigt { text-decoration: line-through; color: var(--ink-faint); }

/* Große Checkbox */
.check {
  width: 32px; height: 32px; border: 2px solid var(--line-stark); border-radius: 9px;
  background: #fff; cursor: pointer; display: inline-flex; align-items: center;
  justify-content: center; font-size: 1.25rem; color: #fff; flex-shrink: 0; padding: 0;
}
.check:hover { border-color: var(--gruen); }
.check.an { background: var(--gruen); border-color: var(--gruen); }

/* ---------- Zählerstände ---------- */
.zaehler-block {
  border: 1px solid var(--line); border-radius: var(--radius-s);
  padding: 1rem 1.1rem; margin-bottom: 1rem; background: var(--surface-2);
}
.zaehler-kopf {
  display: flex; align-items: center; justify-content: space-between;
  gap: 1rem; flex-wrap: wrap;
}
.z-titel { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }
.z-icon { font-size: 1.5rem; }
.z-letzter b { font-size: 1.15rem; }
.z-aktionen {
  display: flex; align-items: end; gap: .8rem; flex-wrap: wrap; margin-top: .8rem;
}
.z-manuell { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }
.z-manuell input { width: auto; }
.z-manuell input[type=number] { max-width: 200px; }
.z-verlauf { margin-top: .7rem; }
.z-verlauf summary { cursor: pointer; font-weight: 700; color: var(--ink-soft); }

/* Baumarkt-Angebote */
.markt-grid { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); margin-top: 1rem; }
.markt-karte { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--schatten); overflow: hidden; }
.markt-kopf { display: flex; align-items: center; gap: .6rem; padding: .9rem 1rem; color: #fff; }
.markt-logo { background: rgba(255,255,255,.25); border-radius: 8px; padding: .15rem .55rem; font-weight: 800; }
.markt-name { font-weight: 800; font-size: 1.1rem; }
.markt-body { padding: .8rem 1rem 1.1rem; }
.markt-aktionen { display: flex; gap: .5rem; flex-wrap: wrap; margin-top: .8rem; }

/* Toast-Hinweis */
.toast {
  position: fixed; left: 50%; bottom: calc(var(--nav-h) + 20px); transform: translateX(-50%);
  background: var(--ink); color: #fff; padding: .7rem 1.1rem; border-radius: 12px;
  z-index: 100; box-shadow: 0 6px 20px rgba(0,0,0,.25); font-weight: 600; max-width: 92vw; text-align: center;
}

/* ---------- Unterschriften-Pad ---------- */
.sigpad {
  width: 100%; max-width: 460px; height: 150px; background: #fff;
  border: 2px dashed var(--line-stark); border-radius: var(--radius-s);
  touch-action: none; cursor: crosshair; display: block;
}
.sig-vorhanden { max-width: 220px; border: 1px solid var(--line); border-radius: 8px; background: #fff; margin-bottom: .3rem; display: block; }

/* ---------- Bildergalerie ---------- */
.galerie {
  display: grid; gap: .8rem;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
}
.galerie-item { position: relative; }
.galerie-item img {
  width: 100%; height: 130px; object-fit: cover;
  border-radius: var(--radius-s); border: 1px solid var(--line); display: block;
}
.bild-loeschen {
  position: absolute; top: 6px; right: 6px;
  border: none; border-radius: 8px; cursor: pointer;
  background: rgba(255,255,255,.9); font-size: 1rem; padding: .25rem .4rem;
  line-height: 1; box-shadow: var(--schatten-s);
}
.bild-loeschen:hover { background: #fff; }

/* ---------- Vertrags-Konfigurator ---------- */
.konf-grid { display: grid; grid-template-columns: 1fr 260px; gap: 1.1rem; align-items: start; }
.wohnungswahl { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px,1fr)); gap: .6rem; }
.whl-karte {
  display: flex; align-items: flex-start; gap: .5rem; text-align: left;
  border: 1.5px solid var(--line-stark); background: #fff; border-radius: var(--radius-s);
  padding: .6rem .7rem; cursor: pointer; font: inherit; color: var(--ink);
  overflow: hidden;
}
.whl-karte:hover { background: var(--surface-2); border-color: var(--brand); }
.whl-karte.aktiv { border-color: var(--brand); background: var(--brand-tint); }
.whl-haus { font-size: 1.4rem; flex-shrink: 0; }
.whl-txt { min-width: 0; overflow-wrap: anywhere; word-break: break-word; line-height: 1.3; }
.dropzone {
  border: 2px dashed var(--line-stark); border-radius: var(--radius-s);
  min-height: 120px; padding: 1rem; display: flex; flex-direction: column;
  justify-content: center; text-align: center; background: var(--surface-2);
}
.dropzone .dz-name { font-weight: 800; font-size: 1.05rem; margin-top: .3rem; }
.gesamt-box {
  margin-top: .8rem; padding: .7rem 1rem; border-radius: var(--radius-s);
  background: var(--brand-tint); color: var(--brand-dark); font-size: 1.15rem;
}
.gesamt-box b { font-size: 1.3rem; }
@media (max-width: 640px) { .konf-grid { grid-template-columns: 1fr; } }

/* ---------- Vertrag Druckansicht ---------- */
.vertrag-druck h2 { font-size: 1.15rem; border-bottom: 1px solid var(--line); padding-bottom: 3px; margin-top: 1.4rem; }
.vertrag-druck table { width: 100%; border-collapse: collapse; }
.vertrag-druck .box { border: 1px solid var(--line); }
.vertrag-druck .parteien td { width: 50%; border: 1px solid var(--line); padding: 8px; vertical-align: top; }

/* ---------- Meldungen ---------- */
.meldung {
  padding: .95rem 1.15rem; border-radius: 12px; margin-bottom: 1.1rem; font-weight: 600;
  display: flex; align-items: center; gap: .6rem; border: 1px solid transparent;
}
.meldung.ok     { background: var(--gruen-bg); color: var(--gruen); border-color: #cbe7d5; }
.meldung.fehler { background: var(--rot-bg);   color: var(--rot);   border-color: #f2c9c9; }

/* ---------- Leerzustand ---------- */
.leer-zustand { text-align: center; padding: 3rem 1.2rem; color: var(--ink-soft); }
.leer-zustand .gross { font-size: 3.2rem; }

/* ---------- Hilfsklassen ---------- */
.muted { color: var(--ink-faint); }
.rechts { text-align: right; }
.trenn { height: 1px; background: var(--line); border: none; margin: 1.2rem 0; }
.zurueck { display: inline-flex; align-items: center; gap: .35rem; margin-bottom: .9rem; font-weight: 600; text-decoration: none; color: var(--ink-soft); }
.zurueck:hover { color: var(--brand-dark); }
.info-box { background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius-s); padding: 1rem 1.15rem; color: var(--ink-soft); }

/* ---------- Login ---------- */
.login-wrap { min-height: 82vh; display: flex; align-items: center; justify-content: center; }
.login-box {
  width: 100%; max-width: 400px; background: var(--surface);
  border-radius: var(--radius); box-shadow: var(--schatten);
  padding: 2.2rem 2rem; text-align: center; border: 1px solid var(--line);
}
.login-box .brand-icon-gross { width: 64px; height: 64px; border-radius: 16px; }

/* Google-Login-Knopf */
.google-btn {
  width: 100%; background: #fff; color: #3c4043;
  border: 1.5px solid var(--line-stark); font-weight: 700; margin-top: .4rem;
  gap: .7rem;
}
.google-btn:hover { background: #f7f8fa; }
.google-btn .g-logo { display: inline-flex; }
.oder {
  display: flex; align-items: center; gap: .8rem; color: var(--ink-faint);
  font-size: .85rem; margin: 1.2rem 0 .2rem;
}
.oder::before, .oder::after { content: ""; height: 1px; background: var(--line); flex: 1; }

/* ---------- Upload-Prüfseite ---------- */
.pruef-grid { display: grid; grid-template-columns: 300px 1fr; gap: 1.3rem; align-items: start; }
.vorschau-karte { position: sticky; top: 90px; }
.vorschau-bild { width: 100%; border-radius: var(--radius-s); border: 1px solid var(--line); background: #fff; }
.treffer-bar { height: 10px; border-radius: 999px; background: var(--line); overflow: hidden; margin-top: .4rem; }
.treffer-bar > i { display: block; height: 100%; background: var(--gruen); }

/* ============================================================================
   Responsiv / App-Ansicht
   ========================================================================== */
@media (max-width: 860px) {
  body { font-size: 18px; padding-bottom: calc(var(--nav-h) + env(safe-area-inset-bottom, 0px)); }
  .topnav { display: none; }
  .nutzer-name { display: none; }
  .brand span { font-size: 1.1rem; }
  main { padding: 1.1rem .9rem 2rem; }
  .raster2, .raster3 { grid-template-columns: 1fr; }
  .pruef-grid { grid-template-columns: 1fr; }
  .vorschau-karte { position: static; }
  h1 { font-size: 1.5rem; }

  /* untere Tab-Leiste einblenden */
  .bottomnav {
    display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 50;
    background: var(--surface); border-top: 1px solid var(--line);
    box-shadow: 0 -2px 12px rgba(16,24,40,.06);
    padding: .3rem .2rem calc(.3rem + env(safe-area-inset-bottom, 0px));
    justify-content: space-around;
  }
  .bottomnav a {
    flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px;
    text-decoration: none; color: var(--ink-faint); font-size: .72rem; font-weight: 600;
    padding: .35rem .1rem; border-radius: 10px; min-width: 0;
  }
  .bottomnav a .ico { font-size: 1.45rem; line-height: 1; }
  .bottomnav a.aktiv { color: var(--brand-dark); }
  .bottomnav a.aktiv .ico { transform: translateY(-1px); }
}

@media (max-width: 400px) {
  .bottomnav a { font-size: .66rem; }
  .status-pill { padding: .45rem .8rem; }
}

/* ---------- Druckansicht ---------- */
@media print {
  .appbar, .bottomnav, .noprint { display: none !important; }
  main { max-width: none; padding: 0; }
  body { background: #fff; font-size: 12pt; padding: 0; }
  .karte { box-shadow: none; border: none; padding: 0; }
}
