/* Google-Fonts-Import bewusst NICHT hier per @import (das blockiert das
   Rendern der ganzen Seite, bis der externe Font-Request fertig ist -
   spürbar z. B. als kurzes Einfrieren, wenn der Browser-Tab durch einen
   nativen Datei-Dialog kurz pausiert wurde). Stattdessen nicht-blockierend
   im <head> geladen, siehe layout_top.php/layout_auth_top.php/layout_admin_top.php. */

/* Verwaltto-Design: dieselbe Palette/Typo wie die Marketing-Website
   (siehe /assets/css/style.css im Projektstamm), damit App und Website
   konsistent wirken. Variablennamen bewusst wie zuvor beibehalten, damit
   bestehende Templates unverändert bleiben - nur die Werte ändern sich. */
:root {
  --paper: #F6F7EF;
  --card: #FAFAF3;
  --white: #FFFFFF;
  --border: #E7E6DB;
  --border-soft: #EFEEE6;
  --ink: #14150F;
  --muted: #6B6A60;
  --accent: #14150F;
  --accent-soft: #EEF8C9;
  --lime: #DCF454;
  --lime-dark: #90A62B;
  --green-bg: #E4F3C7;
  --green-text: #3F6D16;
  --orange-bg: #F5E6D3;
  --orange-text: #8A5A20;
  --red-text: #A32D2D;
  --gray-bg: #F1EFE8;
  --gray-text: #5F5E5A;
  --inactive-row: #F5F5F3;
  --radius-full: 999px;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: 'IBM Plex Sans', sans-serif;
  font-size: 16px;
  line-height: 1.5;
}

html { scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
}

h1, h2, h3 { font-family: 'IBM Plex Sans', sans-serif; font-weight: 700; margin: 0; letter-spacing: -0.01em; }
h1 { font-size: 27px; }
h2 { font-size: 20px; margin-bottom: 14px; }

.accent-italic { font-family: 'Fraunces', serif; font-style: italic; font-weight: 500; }

a { color: var(--ink); text-decoration: underline; text-decoration-color: var(--border); text-underline-offset: 2px; }
a:hover { text-decoration-color: var(--ink); }

/* Lesbare Zahlen ohne gepunktete Null, mit gleich breiten Tabellenziffern. */
.mono { font-family: inherit; font-variant-numeric: lining-nums tabular-nums; }

input, select, textarea {
  font-family: 'IBM Plex Sans', sans-serif;
  font-size: 16px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 3px;
  background: #fff;
  color: var(--ink);
  max-width: 100%;
  min-width: 0;
}
input[type="date"], input[type="datetime-local"] { min-width: 10.5rem; min-height: 44px; }
input:focus, select:focus, textarea:focus {
  outline: 2px solid rgba(220, 244, 84, 0.45);
  border-color: var(--ink);
}
input[type="checkbox"] { width: auto; padding: 0; }

label.field-label {
  font-size: 14px;
  color: var(--muted);
  display: block;
  margin-bottom: 4px;
}

button, .btn {
  font-family: 'IBM Plex Sans', sans-serif;
  cursor: pointer;
  padding: 8px 16px;
  border-radius: var(--radius-full);
  font-size: 15.5px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: #fff;
  border: 1px solid var(--border);
  color: var(--ink);
  text-decoration: none;
}
button:hover, .btn:hover { border-color: var(--ink); text-decoration: none; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: #2B2C22; border-color: #2B2C22; }
.btn-danger { background: #fff; border-color: var(--border); color: var(--red-text); }
.btn-danger:hover { border-color: var(--red-text); }
.icon-btn {
  background: none; border: none; color: var(--gray-text); padding: 4px;
  display: inline-flex; align-items: center; cursor: pointer;
}
.icon-btn.danger { color: var(--red-text); }
.icon-btn:hover { color: var(--accent); }
:where(a, button, input, select, textarea):focus-visible { outline: 2px solid var(--ink); outline-offset: 3px; }

table { border-collapse: collapse; width: 100%; }
th, td { text-align: left; padding: 8px 10px; font-size: 15.5px; vertical-align: middle; }
th { color: var(--muted); font-weight: 500; border-bottom: 1px solid var(--border-soft); }
tr.row { border-bottom: 1px solid var(--border-soft); }

.badge {
  font-size: 13px; padding: 3px 10px; border-radius: var(--radius-full); font-weight: 600; display: inline-block;
  white-space: nowrap; overflow-wrap: normal; word-break: normal; flex-shrink: 0;
}
.badge-active { background: var(--green-bg); color: var(--green-text); }
.badge-inactive { background: var(--gray-bg); color: var(--gray-text); }
.badge-owner { background: var(--green-bg); color: var(--green-text); margin-left: 6px; }

.property-status-row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.year-badge {
  font-size: 14px; padding: 5px 10px; border-radius: var(--radius-full); font-weight: 600;
  text-decoration: none; display: inline-block; border: 1px solid transparent;
}
.year-badge-gruen { background: var(--green-bg); color: var(--green-text); }
.year-badge-orange { background: var(--orange-bg); color: var(--orange-text); }
.year-badge-grau { background: var(--gray-bg); color: var(--gray-text); }
.year-badge:hover { border-color: currentColor; }

/* App-Shell: schwarzer abgerundeter Rahmen + dunkle Sidebar links, nach dem
   Vorbild des Dashboard-Mockups auf der Marketing-Website (siehe
   .mockup-frame/.mockup-sidebar in /assets/css/style.css) - hier auf eine
   echte, ganzseitige App mit scrollbarem Inhalt skaliert. */
html, body { height: 100%; }
body { display: flow-root; }

.app-shell {
  display: flex;
  height: calc(100vh - 32px);
  margin: 16px;
  background: var(--accent);
  border-radius: 22px;
  padding: 10px;
  box-shadow: 0 16px 40px rgba(20, 21, 15, 0.14);
}

.app-sidebar {
  width: 240px;
  flex-shrink: 0;
  background: #23241B;
  color: #B9B8AC;
  border-radius: 15px 0 0 15px;
  padding: 18px 14px;
  display: flex;
  flex-direction: column;
  gap: 3px;
  overflow-y: auto;
}
.app-brand {
  display: flex; align-items: center; gap: 12px;
  color: #fff; font-weight: 700; font-size: 20px;
  padding: 6px 10px 24px;
}
.app-brand .logo-mark { width: 52px; height: 52px; display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; }
.app-brand .logo-mark svg { width: 100%; height: 100%; }

.app-nav { display: flex; flex-direction: column; gap: 3px; }
.app-nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px; border-radius: 10px;
  color: #B9B8AC; font-weight: 500; font-size: 15.5px;
  text-decoration: none;
}
.app-nav-item:hover { background: rgba(255, 255, 255, 0.06); text-decoration: none; }
.app-nav-item.active { background: rgba(220, 244, 84, 0.14); color: var(--lime); font-weight: 600; }

.app-sidebar-actions {
  margin-top: auto;
  padding-top: 12px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  display: flex;
  flex-direction: column;
  gap: 3px;
}

/* Demokonto-Einstieg: bewusst optisch von den echten Objekt-Tabs abgesetzt
   (gestrichelter Trenner, eigener Lime-Akzent), damit klar ist, dass das
   ein Ausflug in Beispieldaten ist und keine normale Navigation. */
.app-nav-demo {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px dashed rgba(220, 244, 84, 0.35);
}
.app-nav-demo .app-nav-item { color: var(--lime); }
.app-nav-demo .app-nav-item:hover { background: rgba(220, 244, 84, 0.1); }

.app-content {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  background: var(--paper);
  border-radius: 0 15px 15px 0;
  overflow: hidden;
}

.app-topbar {
  flex-shrink: 0;
  display: flex; align-items: center; justify-content: flex-end; gap: 16px;
  padding: 14px 24px;
  border-bottom: 1px solid var(--border-soft);
}
.header-context { display: flex; gap: 14px; align-items: center; margin: 0 auto 0 0; }
.header-context-field { display: flex; align-items: center; gap: 6px; }
.header-context-field .field-label { margin: 0; white-space: nowrap; }
.header-context-field select { padding: 4px 8px; font-size: 15px; border-radius: var(--radius-full); }

.page { flex: 1; overflow-y: auto; max-width: 1080px; margin: 0 auto; padding: 28px 24px 60px; width: 100%; }
.page.with-card { background: transparent; border: none; }

/* Mobile-Navigation: reines CSS (Checkbox-Hack, kein JS nötig), damit die
   App auch ohne JavaScript voll bedienbar bleibt. Auf Desktop unsichtbar/
   wirkungslos - die Sidebar bleibt dort wie gehabt immer eingeblendet. */
.nav-toggle-checkbox,
.nav-toggle-backdrop,
.nav-toggle-close,
.mobile-topbar-row {
  display: none;
}

@media (max-width: 860px) {
  .app-shell {
    flex-direction: column; height: 100dvh; min-height: 100dvh;
    margin: 0; padding: 0; border-radius: 0; background: var(--paper); box-shadow: none;
  }

  .mobile-topbar-row {
    display: flex; align-items: center; justify-content: space-between;
    width: 100%; padding-bottom: 10px; margin-bottom: 10px;
    border-bottom: 1px solid var(--border-soft);
  }
  .mobile-menu-btn {
    display: inline-flex; align-items: center; justify-content: center;
    width: 40px; height: 40px; border-radius: 10px; border: 1px solid var(--border);
    background: #fff; color: var(--ink); cursor: pointer; flex-shrink: 0;
  }
  .mobile-brand {
    display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 15px;
  }
  .mobile-brand .logo-mark { width: 28px; height: 28px; display: inline-flex; flex-shrink: 0; }
  .mobile-brand .logo-mark svg { width: 100%; height: 100%; }

  .nav-toggle-checkbox:checked ~ .nav-toggle-backdrop {
    display: block; position: fixed; inset: 0; background: rgba(20, 21, 15, 0.5); z-index: 55;
  }

  .app-sidebar {
    position: fixed; top: 0; left: 0; z-index: 60;
    width: 82%; max-width: 300px; height: 100dvh;
    border-radius: 0 15px 15px 0;
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    box-shadow: 0 0 30px rgba(0, 0, 0, 0.25);
  }
  .nav-toggle-checkbox:checked ~ .app-sidebar { transform: translateX(0); }
  .nav-toggle-close {
    display: flex; align-items: center; justify-content: center;
    position: absolute; top: 14px; right: 14px; width: 32px; height: 32px;
    border-radius: 8px; color: #fff; cursor: pointer;
  }
  .nav-toggle-close:hover { background: rgba(255, 255, 255, 0.08); }

  .app-content { border-radius: 0; }
  .app-topbar { flex-wrap: wrap; padding: 14px 16px; }
  .header-context { width: 100%; flex-direction: column; align-items: stretch; gap: 10px; margin: 0; }
  .header-context-field { width: 100%; justify-content: space-between; }
  .header-context-field select { flex: 1; }

  .metric-grid { grid-template-columns: repeat(3, 1fr); gap: 8px; }
  .metric-card { padding: 12px 10px; }
  .metric-label { min-height: 2.6em; display: block; }

  /* Breite Tabellen (Mieter, Verbrauchserfassung, ...) sollen nur innerhalb
     ihrer eigenen Karte seitlich scrollen, statt die ganze Seite inkl.
     Kopfbereich nach rechts zu schieben (siehe ui-ux-pro-max: "Table
     Handling" - overflow-x-auto-Wrapper statt Seiten-Overflow). */
  .card { overflow-x: auto; }
  .card table { min-width: 100%; }
}

.card { background: #fff; border: 1px solid var(--border); border-radius: 14px; padding: 18px 20px; margin-bottom: 14px; min-width: 0; max-width: 100%; overflow-x: auto; }
.card.tint { background: var(--card); }

.empty { color: var(--muted); font-size: 16px; font-style: italic; padding: 10px 0; }

.flash { padding: 10px 16px; border-radius: 12px; font-size: 15.5px; margin-bottom: 16px; }
.flash-success { background: var(--green-bg); color: var(--green-text); }
.flash-error { background: #FCEBEB; color: var(--red-text); }

.metric-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; margin-bottom: 24px; }
.metric-card {
  background: #fff; border: 1px solid var(--border); border-radius: 14px; padding: 18px 20px;
  display: block; text-decoration: none; color: inherit; transition: border-color 0.15s ease;
}
a.metric-card:hover { border-color: var(--accent); }
.metric-label { font-size: 14px; color: var(--muted); }
.metric-value { font-family: 'Fraunces', serif; font-size: 31px; font-weight: 600; }

.form-row { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; margin-bottom: 4px; }
.form-row + .form-row { margin-top: 10px; }

.dropzone {
  background: var(--card); border: 1px dashed var(--border); border-radius: 12px;
  padding: 12px 14px; margin-bottom: 16px; display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
}
.dropzone .hint { font-size: 14.5px; color: var(--muted); }
.upload-btn { background: var(--accent); color: #fff; border-radius: var(--radius-full); padding: 8px 14px; font-size: 15.5px; font-weight: 500; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; }
.upload-btn input[type="file"] { display: none; }

.scan-queue { margin-bottom: 16px; border: 1px solid var(--border); border-radius: 12px; overflow: hidden; }
.scan-queue-head { background: var(--card); padding: 8px 12px; display: flex; justify-content: space-between; align-items: center; font-size: 14.5px; font-weight: 500; }
.scan-row { padding: 12px; border-top: 1px solid var(--border-soft); cursor: pointer; transition: background-color 0.15s ease; }
.scan-row:nth-child(even) { background: var(--card); }
.scan-row:hover { background: var(--border-soft); }
.scan-row.is-selected { background: var(--accent-soft); box-shadow: inset 2px 0 0 var(--accent); }
.scan-row .filename { font-size: 13.5px; color: var(--muted); margin-bottom: 6px; display: flex; align-items: center; gap: 6px; }
.scan-row form { cursor: default; }

.spin { animation: hv-spin 1s linear infinite; display: inline-block; }
@keyframes hv-spin { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }

.tenant-form-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.edit-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.tenant-form-grid > *, .edit-grid > * { min-width: 0; }

.rate-row { display: grid; grid-template-columns: minmax(10.5rem, 12rem) minmax(8rem, 10rem); align-items: end; gap: 12px; margin-bottom: 12px; font-size: 16px; }
.rate-row > * { min-width: 0; }
.rate-row .rate-date, .rate-row .rate-amount { width: 100%; min-height: 44px; }
.rate-row .field-label { font-size: 14px; }
.form-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 20px; align-items: center; }

.tenant-list { position: relative; }
.tenant-table { min-width: 860px; table-layout: fixed; }
.tenant-table th, .tenant-table td { padding: 12px 10px; }
.tenant-table th:first-child { width: 96px; }
.tenant-table th:nth-child(4) { width: 160px; }
.tenant-table th:nth-child(5) { width: 112px; }
.tenant-table th:nth-child(6) { width: 132px; }
.tenant-table th:last-child { width: 104px; }
.tenant-table .tenant-value { overflow-wrap: anywhere; }
.tenant-table tr.row.is-inactive { background: var(--inactive-row); color: var(--muted); }
.tenant-table .tenant-period span { display: block; }
.tenant-table .tenant-amount { text-align: right; }
.tenant-table .tenant-amount .tenant-value { white-space: nowrap; }
.tenant-rate-note { display: block; font-size: 13px; color: var(--muted); }
.tenant-actions { display: flex; justify-content: flex-end; gap: 8px; }
.tenant-actions .icon-btn { width: 36px; height: 36px; justify-content: center; border-radius: 8px; }
.tenant-actions .icon-btn:hover { background: var(--card); }
.tenant-editor h3 { margin-bottom: 20px; font-size: 18px; }
.visually-hidden { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0; }

.invoice-field { width: 100%; max-width: 420px; min-width: 0; }
.invoice-field input[type="file"] { width: 100%; }
.invoice-selection { display: grid; gap: 8px; margin-top: 8px; }
.invoice-selection-row { display: flex; flex-wrap: wrap; align-items: flex-start; gap: 8px; min-width: 0; }
.invoice-filename { flex: 1 1 160px; min-width: 0; padding: 8px 10px; text-align: left; border-radius: 8px; background: var(--card); }
.invoice-filename span { min-width: 0; overflow-wrap: anywhere; }
.invoice-filename svg { flex-shrink: 0; }
.invoice-hint { margin: 6px 0 0; color: var(--muted); font-size: 13px; }
.stored-invoice { display: inline-flex; align-items: baseline; gap: 6px; margin-top: 12px; max-width: 100%; overflow-wrap: anywhere; font-size: 14px; }
.stored-invoice svg { flex-shrink: 0; }
.document-list { margin-top: 16px; padding-top: 12px; border-top: 1px solid var(--border-soft); }
.document-list-title { font-size: 14px; font-weight: 600; margin-bottom: 8px; }
.stored-documents { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.stored-document-row { display: flex; align-items: flex-start; gap: 12px; min-width: 0; padding: 4px 0; }
.stored-document-row .stored-invoice { flex: 1; min-width: 0; margin: 0; padding: 8px 0; }
.stored-invoice span { min-width: 0; overflow-wrap: anywhere; }
.stored-invoice.is-selected { font-weight: 600; }
.document-actions { display: flex; gap: 8px; flex-shrink: 0; }
.document-actions form { margin: 0; }
.document-actions .icon-btn { width: 36px; height: 36px; justify-content: center; border-radius: 8px; }
.preview-back { margin-top: 6px; padding: 6px 10px; font-size: 14px; }
.cost-item-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-start; gap: 12px; }
.cost-item-head > div { min-width: 0; max-width: 100%; overflow-wrap: anywhere; }
.cost-item-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.kosten-preview-title { overflow-wrap: anywhere; }
.consumption-help { margin: 0 0 20px; }
.consumption-help summary, .consumption-history summary, .consumption-checks summary, .consumption-general-issues summary { cursor: pointer; padding: 10px 0; font-weight: 600; }
.consumption-unit-head { display: flex; justify-content: space-between; align-items: flex-start; flex-wrap: wrap; gap: 12px; margin-bottom: 16px; }
.consumption-unit-head h3 { font-size: 20px; }
.consumption-unit-entries { display: grid; gap: 16px; }
.consumption-entry { padding: 16px; border: 1px solid var(--border); border-radius: 10px; min-width: 0; margin: 0; }
.consumption-entry-heading { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.consumption-entry-heading span { color: var(--muted); font-size: 14px; }
.consumption-entry-modes { display: flex; flex-wrap: wrap; gap: 12px 20px; padding-bottom: 12px; }
.consumption-entry-modes label { display: flex; align-items: center; gap: 6px; min-height: 36px; }
.consumption-reading-fields { display: grid; grid-template-columns: repeat(auto-fit,minmax(min(100%,190px),1fr)); gap: 12px; }
.consumption-entry input:not([type="radio"]):not([type="checkbox"]):not([type="hidden"]), .consumption-entry select { display: block; width: 100%; margin-top: 6px; }
.consumption-entry .meter-delta { margin: 12px 0; }
.consumption-entry > button { margin-top: 12px; }
.consumption-history { border-top: 1px solid var(--border-soft); margin-top: 16px; padding-top: 8px; }
.consumption-summaries { display: flex; flex-wrap: wrap; gap: 12px; padding: 12px 0; }
.consumption-summaries span { overflow-wrap: anywhere; }
.consumption-general-issues { border-left: 3px solid var(--orange-text); }
.unit-list { margin-top: 16px; }
.unit-details { border: 1px solid var(--border); border-radius: 12px; margin-bottom: 12px; background: var(--white); }
.unit-details > summary { cursor: pointer; padding: 16px; display: flex; flex-wrap: wrap; align-items: center; gap: 12px; }
.unit-details > summary::before { content: '▸'; }
.unit-details[open] > summary::before { content: '▾'; }
.unit-details > summary span { color: var(--muted); font-size: 14px; margin-left: auto; }
.unit-details summary:focus-visible { outline: 2px solid var(--ink); outline-offset: 3px; }
.unit-details-body { padding: 16px; border-top: 1px solid var(--border-soft); }
.meter-list { display: grid; gap: 16px; }
.meter-card { border: 1px solid var(--border); padding: 16px; border-radius: 10px; min-width: 0; scroll-margin-top: 16px; }
.meter-card h4 { margin: 0; font-size: 17px; }
.meter-card-head { display: flex; align-items: flex-start; justify-content: space-between; flex-wrap: wrap; gap: 10px; }
.meter-card-head > .badge { flex: 0 0 auto; align-self: flex-start; padding: 4px 10px; line-height: 1.35; white-space: nowrap; }
.meter-last-value { display: flex; flex-wrap: wrap; align-items: baseline; gap: 12px; margin: 16px 0; }
.meter-last-value strong { font-size: 23px; font-variant-numeric: tabular-nums; }
.meter-last-value span { color: var(--muted); font-size: 14px; }
.meter-reading-form, .meter-create-form { display: grid; grid-template-columns: repeat(auto-fit,minmax(min(100%,190px),1fr)); gap: 12px; align-items: end; }
.meter-reading-form input, .meter-create-form input, .meter-create-form select { width: 100%; display: block; margin-top: 6px; }
.meter-reading-form button, .meter-create-form button { justify-self: start; }
.meter-delta, .meter-form-wide { grid-column: 1 / -1; }
.meter-delta { display: block; border-radius: 8px; padding: 10px 12px; font-size: 14px; background: var(--accent-soft); color: var(--ink); }
.meter-delta.is-error { background: #FCEBEB; color: var(--red-text); }
.meter-delta.is-warning { background: var(--orange-bg); color: var(--orange-text); }
.meter-history, .meter-retire, .meter-new { margin-top: 16px; }
.meter-history > summary, .meter-retire > summary, .meter-new > summary { cursor: pointer; padding: 10px 0; font-weight: 600; }
.table-scroll { overflow-x: auto; max-width: 100%; }
.table-scroll table { min-width: 540px; }
.reading-reminder { border-color: #CBD9A9; border-left: 4px solid var(--lime-dark); }
.reading-reminder h3, #reading-reminders h3 { margin-bottom: 12px; font-size: 19px; }
.reading-reminder p { margin: 10px 0; }
.reading-reminder-eyebrow { color: var(--green-text); font-size: 13px; font-weight: 600; margin-bottom: 6px; }
.reading-reminder-tasks { list-style: none; padding: 0; margin: 16px 0; }
.reading-reminder-tasks li { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 12px; padding: 12px 0; border-top: 1px solid var(--border-soft); }
.reading-reminder-tasks li > div { min-width: 0; overflow-wrap: anywhere; }
.reading-reminder-property { display: block; color: var(--muted); font-size: 14px; }
.reading-reminder form { margin: 0; }
.reading-reminder-setup { padding-left: 20px; overflow-wrap: anywhere; }
.reminder-enabled { display: flex; gap: 10px; align-items: center; margin: 16px 0; }
.reminder-settings-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 210px), 1fr)); gap: 16px; }
.reminder-settings-grid select, .reminder-custom-row input, .reminder-custom-row select { width: 100%; display: block; margin-top: 6px; }
.reminder-meter-group { min-width: 0; margin: 16px 0; padding: 16px; border: 1px solid var(--border); border-radius: 10px; }
.reminder-meter-group legend { padding: 0 6px; font-weight: 600; overflow-wrap: anywhere; max-width: 100%; }
.reminder-meter-row .field-label { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr); align-items: center; gap: 16px; padding: 6px 0; }
.reminder-meter-row select { width: 100%; }
.reminder-meter-row span { overflow-wrap: anywhere; }
.reminder-custom-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 210px), 1fr)); gap: 16px; padding-top: 12px; margin-top: 12px; border-top: 1px solid var(--border-soft); }
@media (max-width: 600px) {
  .reminder-meter-row .field-label { grid-template-columns: minmax(0, 1fr); gap: 6px; padding: 10px 0; }
}
.meter-help-row { flex-basis: 100%; min-width: 0; }
.field-hint { margin: 4px 0 8px; color: var(--muted); font-size: 14px; font-weight: 400; }
.meter-help { margin-top: 8px; font-size: 14px; font-weight: 400; color: var(--ink); }
.meter-help summary { cursor: pointer; width: fit-content; max-width: 100%; padding: 8px 0; color: var(--ink); text-decoration: underline; text-underline-offset: 3px; }
.meter-help summary:focus-visible { outline: 2px solid var(--ink); outline-offset: 3px; }
.meter-help-content { margin: 4px 0 8px; padding: 12px 14px; border-left: 3px solid var(--lime-dark); background: var(--card); line-height: 1.6; overflow-wrap: anywhere; }
.meter-help-content p { margin: 0 0 10px; }
.meter-help-content p:last-child { margin-bottom: 0; }
.consumption-notice { margin-top: 12px; padding: 12px; border-radius: 8px; background: #FCEBEB; color: var(--red-text); font-size: 14px; font-weight: 500; }
.consumption-notice .field-hint { color: var(--red-text); }
.cost-entry-form { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.cost-entry-form > * { grid-column: 1 / -1; min-width: 0; }
.cost-entry-form > .cost-entry-field { grid-column: auto; }
.cost-entry-form > .invoice-field { max-width: none; }
.cost-entry-form > button { justify-self: start; }

.bank-fields { margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--border-soft); }
.bank-fields input.is-autofilled { background: var(--card); color: var(--gray-text); cursor: not-allowed; }

.statement-card { margin-bottom: 20px; break-inside: avoid; }
.statement-head { display: flex; justify-content: space-between; margin-bottom: 4px; }
.statement-total { font-size: 15px; color: var(--muted); text-align: right; }

.vacancy-card { background: var(--card); }

.icon { width: 14px; height: 14px; display: inline-block; vertical-align: -2px; }

.modal-overlay {
  position: fixed; inset: 0; background: rgba(43, 42, 40, 0.55);
  display: flex; align-items: center; justify-content: center; z-index: 100;
}
.modal-overlay[hidden] { display: none; }
.modal-panel {
  background: #fff; border: 1px solid var(--border); border-radius: 16px;
  padding: 24px 28px; width: 340px; max-width: 90vw; text-align: center;
}
.modal-panel .modal-title { font-family: 'Fraunces', serif; font-size: 18px; font-weight: 600; margin-bottom: 6px; }
.modal-panel .modal-text { font-size: 15px; color: var(--muted); margin-bottom: 16px; }

.modal-panel.modal-form { width: 640px; max-width: 92vw; text-align: left; max-height: 86vh; overflow-y: auto; }
.modal-panel.modal-form .modal-title { margin-bottom: 16px; }
.modal-actions { display: flex; gap: 8px; margin-top: 18px; }
.progress-bar {
  width: 100%; height: 10px; background: var(--border-soft); border-radius: 5px; overflow: hidden;
}
.progress-bar-fill {
  height: 100%; background: var(--accent); width: 0%; transition: width 0.2s ease;
}
.progress-percent { font-size: 14px; color: var(--muted); margin-top: 8px; }

/* Flüssiges Auf-/Zuklappen (ersetzt natives <details> und das hidden-
   Umschalten der Split-Zeilen) per CSS-Grid-Rows-Verfahren - animiert
   ohne Höhen-JS-Messung, dieselbe leise 0.2s-ease-out-Mikro-Animation
   wie .progress-bar-fill oben. */
.collapsible {
  display: grid;
  grid-template-rows: 0fr;
  transition: grid-template-rows 0.2s ease-out;
}
.collapsible.is-open { grid-template-rows: 1fr; }
.collapsible > div { overflow: hidden; min-height: 0; }
@media (prefers-reduced-motion: reduce) {
  .collapsible { transition: none; }
}

/* Kosten-Seite: Liste + Beleg-Vorschau nebeneinander. Nur diese Seite
   nutzt die volle verfügbare Breite innerhalb der Sidebar-Shell, alle
   anderen Seiten bleiben bei .page (1080px). */
.page.page-kosten { max-width: none; }

.kosten-split { display: flex; align-items: flex-start; }
.kosten-list-col { flex: 1 1 auto; min-width: 320px; max-width: 100%; }

.kosten-split-handle {
  flex: 0 0 auto;
  width: 6px;
  margin: 0 6px;
  align-self: stretch;
  cursor: col-resize;
  position: relative;
  background: var(--border-soft);
  border-radius: 3px;
}
.kosten-split-handle::before {
  /* größere unsichtbare Trefferfläche als die sichtbare 6px-Linie */
  content: '';
  position: absolute;
  top: 0; bottom: 0; left: -10px; right: -10px;
}
.kosten-split-handle:hover, .kosten-split-handle:focus-visible {
  background: var(--accent-soft);
}

.kosten-preview-col {
  position: sticky;
  top: 16px;
  flex: 0 0 auto;
  width: var(--kosten-preview-width, 420px);
  max-width: 60vw;
  height: calc(100vh - 190px);
  display: flex;
  flex-direction: column;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}
.kosten-preview-head {
  flex: 0 0 auto;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border-soft);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}
.kosten-preview-title { font-weight: 600; font-size: 15.5px; }
.kosten-preview-amount { font-size: 14.5px; color: var(--muted); }
.kosten-preview-zoom-controls { display: flex; align-items: center; gap: 2px; }
.kosten-preview-zoom-controls[hidden] { display: none; }
.kosten-preview-body { flex: 1 1 auto; overflow: auto; position: relative; background: var(--card); }
.kosten-preview-body iframe { width: 100%; height: 100%; border: 0; display: block; }
.kosten-preview-body .empty { padding: 20px; }

.kosten-preview-zoom-wrap {
  width: 100%; height: 100%; overflow: hidden;
  display: flex; align-items: center; justify-content: center;
  cursor: grab; touch-action: none;
}
.kosten-preview-zoom-wrap.is-dragging { cursor: grabbing; }
.kosten-preview-zoom-wrap img {
  max-width: 100%; max-height: 100%;
  user-select: none; -webkit-user-drag: none;
  transition: transform 0.2s ease-out;
}
@media (prefers-reduced-motion: reduce) {
  .kosten-preview-zoom-wrap img { transition: none; }
}

.js-preview-row.is-selected { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }

@media (max-width: 1280px) {
  .page.page-kosten { max-width: 980px; }
  .kosten-split { flex-direction: column; }
  .kosten-split-handle { display: none; }
  .kosten-preview-col { position: static; width: 100% !important; max-width: 100%; height: 70vh; margin-top: 16px; }
}

@media print {
  .no-print { display: none !important; }
  body { background: #fff; }
  .app-shell { display: block; height: auto; margin: 0; padding: 0; background: none; box-shadow: none; }
  .app-content { border-radius: 0; background: none; overflow: visible; }
  .page { border: none; background: #fff; overflow: visible; height: auto; max-width: none; }
}

.reading-history-entry { padding: 16px 0; border-top: 1px solid var(--border-soft); min-width: 0; }
.reading-history-table { width: 100%; font-variant-numeric: tabular-nums; }
.reading-table-scroll .reading-history-table { min-width: 660px; }
.reading-history-table th, .reading-history-table td { padding: 12px; text-align: left; vertical-align: middle; }
.reading-history-table .reading-date, .reading-history-table .reading-difference { white-space: nowrap; }
.reading-history-table th { font-size: 13px; font-weight: 600; }
.reading-history-table .reading-value { min-width: 140px; }
.reading-note { max-width: 220px; overflow-wrap: anywhere; white-space: normal; }
.reading-photo-link { display: inline-flex; border-radius: 8px; overflow: hidden; border: 1px solid var(--border); }
.reading-photo-link:focus-visible { outline: 3px solid var(--ink); outline-offset: 3px; }
.reading-photo-thumb { display: block; width: 64px; height: 64px; object-fit: cover; background: var(--card); }
.reading-row-actions { min-width: 110px; }
.reading-row-actions > a { display: inline-block; padding: 8px 0; }
.reading-editor-row > td { background: var(--card); }
.reading-table-scroll:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }
.reading-scroll-hint { display: none; }
@media (max-width: 860px) { .reading-scroll-hint { display: block; } }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0; }
.clipboard-upload { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 8px; width: 100%; }
.clipboard-upload > .field-hint { display: block; flex-basis: 100%; }
.clipboard-upload button { white-space: normal; }
.clipboard-photo-preview[hidden] { display: none; }
.reading-history-values, .reading-history-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 20px; margin: 8px 0; }
.reading-history-values { font-variant-numeric: tabular-nums; }
.reading-edit { margin-top: 12px; }
.reading-edit > summary { cursor: pointer; font-weight: 600; }
.reading-edit[open] { background: var(--card); padding: 12px; border-radius: 10px; }
.reading-edit .meter-reading-form { margin-top: 16px; }
.meter-reading-form input[type="file"], .meter-create-form input[type="file"], .consumption-entry input[type="file"] { width: 100%; min-width: 0; max-width: 100%; }
.reading-history-entry .field-hint, .reading-history-entry strong { overflow-wrap: anywhere; }

/* ---------- Admin-Panel (layout_admin_top.php) ----------
   Eigene, schlanke Kopfzeile statt der App-Sidebar - bisher fehlten
   diese Klassen komplett in diesem Stylesheet, wodurch u. a. das
   Logo-<svg> ganz ohne Größenvorgabe auf die Browser-Standardgröße
   für unstyled SVGs zurückfiel (deutlich zu groß). */
.header-bar { background: var(--white); border-bottom: 1px solid var(--border); }
.header-inner { max-width: 1080px; margin: 0 auto; padding: 20px 24px 0; }
.header-top { display: flex; align-items: center; justify-content: space-between; padding-bottom: 16px; }
.header-top h1 { display: flex; align-items: center; gap: 10px; font-size: 20px; }
.header-top .logo-mark { width: 30px; height: 30px; display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; }
.header-top .logo-mark svg { width: 100%; height: 100%; }
.tabs { display: flex; gap: 4px; }
.tab {
  padding: 10px 16px; border-radius: 10px 10px 0 0; text-decoration: none;
  color: var(--muted); font-weight: 600; font-size: 14.5px;
  border-bottom: 2px solid transparent;
}
.tab:hover { color: var(--ink); background: var(--card); text-decoration: none; }
.tab.active { color: var(--ink); border-bottom-color: var(--ink); }

/* Anpassungen für Formulare und Datenlisten in App und Admin-Bereich. */
@media (max-width: 1100px) {
  .edit-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .header-context { flex-wrap: wrap; }
}

@media (max-width: 860px) {
  .page { padding: 20px 16px 40px; }
  .card { padding: 16px; }
  .app-content, .page { min-height: 0; }
  .header-context-field { min-width: 0; }
  .header-context-field select { min-width: 0; max-width: 100%; }
  .form-row > div { max-width: 100%; min-width: 0; }
  .form-row input:not([type="checkbox"]):not([type="radio"]), .form-row select, .form-row textarea { max-width: 100%; }
  button, .btn, input:not([type="checkbox"]):not([type="radio"]), select { min-height: 44px; }
  .icon-btn, .tenant-actions .icon-btn { min-width: 44px; min-height: 44px; justify-content: center; }
  .mobile-menu-btn, .nav-toggle-close { width: 44px; height: 44px; }
  .app-topbar { padding-top: max(12px, env(safe-area-inset-top)); }
  .page { padding-bottom: max(40px, env(safe-area-inset-bottom)); }
  .tenant-list { padding: 0; border: 0; background: transparent; overflow: visible; }
  .tenant-list .tenant-table { display: block; min-width: 0; width: 100%; }
  .tenant-table thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
  .tenant-table tbody { display: block; }
  .tenant-table tr.row { display: block; margin-bottom: 16px; padding: 12px 16px; background: var(--white); border: 1px solid var(--border); border-radius: 14px; }
  .tenant-table td[data-label] { display: grid; grid-template-columns: 7rem minmax(0, 1fr); align-items: baseline; gap: 12px; padding: 8px 0; text-align: left; }
  .tenant-table td[data-label]::before { content: attr(data-label); color: var(--muted); font-size: 14px; font-weight: 500; }
  .tenant-table .tenant-amount .tenant-value { white-space: normal; }
  .tenant-table .tenant-actions { justify-content: flex-start; }
  .header-inner { padding: 16px 16px 0; }
  .header-top { flex-wrap: wrap; gap: 12px; }
  .tabs { flex-wrap: wrap; }
}

@media (max-width: 600px) {
  .cost-entry-form { grid-template-columns: minmax(0, 1fr); }
  .tenant-form-grid, .edit-grid { grid-template-columns: minmax(0, 1fr); }
  .modal-panel.modal-form { width: calc(100% - 24px); max-width: 640px; padding: 20px; max-height: calc(100dvh - 32px); }
  .modal-actions { flex-wrap: wrap; }
  .statement-head { flex-wrap: wrap; gap: 8px; }
  .kosten-list-col { min-width: 0; width: 100%; }
  .metric-grid { gap: 8px; }
  .metric-card { min-width: 0; padding: 12px 8px; }
  .metric-label { font-size: 13px; overflow-wrap: anywhere; }
  .metric-value { font-size: 26px; }
}

@media (max-width: 480px) {
  .rate-row { grid-template-columns: minmax(0, 1fr); gap: 8px; padding: 12px; border: 1px solid var(--border-soft); border-radius: 8px; }
  .rate-row .rate-date { min-width: 0; }
  .tenant-table td[data-label] { grid-template-columns: 6rem minmax(0, 1fr); gap: 8px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}

@media (max-width: 860px) and (max-height: 500px) {
  .app-topbar { gap: 12px; padding: 8px 12px; align-items: flex-end; }
  .mobile-topbar-row { width: auto; margin: 0; padding: 0; border: 0; }
  .mobile-brand { display: none; }
  .header-context { width: auto; flex: 1; flex-direction: row; gap: 10px; }
  .header-context-field { width: auto; flex: 1; flex-direction: column; align-items: stretch; gap: 4px; }
  .header-context-field:first-child { flex: 2; }
  .header-context-field .field-label { font-size: 12px; }
}
