/* Gewerbepark Sternheim – Mieterportal
 * Mobile first · Hell/Dunkel · Safe-Areas (Notch, Dynamic Island, Home-Indicator)
 * Foldables/Dual-Screen über Viewport-Segments. */

/* ---------- Tokens ---------- */
:root {
  --brand: #e30613;
  --brand-hover: #c20510;
  --brand-ink: #ffffff;
  --ink: #141414;
  --ink-2: #4a4a4a;
  --ink-3: #6e6e6e;
  --bg: #f4f4f2;
  --surface: #ffffff;
  --surface-2: #f8f8f7;
  --line: #e2e2df;
  --focus: #e30613;
  --ok-bg: #e8f5ec;   --ok-ink: #17602f;
  --warn-bg: #fff5dc; --warn-ink: #7a5300;
  --err-bg: #fdecec;  --err-ink: #a3000b;
  --info-bg: #eef3fb; --info-ink: #1f4d8f;

  --radius: 10px;
  --radius-sm: 6px;
  --shadow: 0 1px 2px rgb(0 0 0 / .05), 0 2px 8px rgb(0 0 0 / .04);
  --font: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;

  --sat: env(safe-area-inset-top, 0px);
  --sar: env(safe-area-inset-right, 0px);
  --sab: env(safe-area-inset-bottom, 0px);
  --sal: env(safe-area-inset-left, 0px);
  --gutter: 16px;
  --topbar-h: 60px;
  --bottombar-h: 62px;
  --sidebar-w: 240px;
  color-scheme: light;
}

/* Dunkel: automatisch nach Gerät (außer fest „Hell“ gewählt) oder fest „Dunkel“ (data-theme am <html>) */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --brand: #ff2a36;
    --brand-hover: #ff4d57;
    --ink: #f0f0ee;
    --ink-2: #c4c4c0;
    --ink-3: #9a9a96;
    --bg: #101010;
    --surface: #1b1b1b;
    --surface-2: #232323;
    --line: #333331;
    --focus: #ff4d57;
    --ok-bg: #12301c;   --ok-ink: #8ee0a8;
    --warn-bg: #3a2c05; --warn-ink: #ffd56b;
    --err-bg: #3d0f12;  --err-ink: #ff9aa0;
    --info-bg: #13253f; --info-ink: #a6c8ff;
    --shadow: none;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --brand: #ff2a36;
  --brand-hover: #ff4d57;
  --ink: #f0f0ee;
  --ink-2: #c4c4c0;
  --ink-3: #9a9a96;
  --bg: #101010;
  --surface: #1b1b1b;
  --surface-2: #232323;
  --line: #333331;
  --focus: #ff4d57;
  --ok-bg: #12301c;   --ok-ink: #8ee0a8;
  --warn-bg: #3a2c05; --warn-ink: #ffd56b;
  --err-bg: #3d0f12;  --err-ink: #ff9aa0;
  --info-bg: #13253f; --info-ink: #a6c8ff;
  --shadow: none;
  color-scheme: dark;
}

/* ---------- Basis ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.5;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  overflow-wrap: anywhere;
}
h1, h2, h3 { line-height: 1.2; margin: 0 0 .5em; letter-spacing: -0.01em; }
h1 { font-size: clamp(1.45rem, 1.2rem + 1vw, 1.9rem); }
h2 { font-size: 1.15rem; }
h3 { font-size: 1rem; margin-top: 1.5em; }
p { margin: 0 0 1em; }
a { color: inherit; text-decoration-color: var(--brand); text-underline-offset: 3px; }
a:hover { color: var(--brand); }
img, svg { max-width: 100%; }
code { font-size: .9em; background: var(--surface-2); padding: .1em .35em; border-radius: 4px; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 4px; }
[hidden] { display: none !important; }

.visually-hidden {
  position: absolute !important; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap;
}
.skip-link { position: absolute; left: -999px; top: 0; z-index: 100; background: var(--surface); padding: 8px 12px; }
.skip-link:focus { left: calc(var(--sal) + 8px); top: calc(var(--sat) + 8px); }
.muted { color: var(--ink-3); }
.small { font-size: .875rem; }
.center { text-align: center; }
.stack > * + * { margin-top: 14px; }

.icon { width: 22px; height: 22px; flex: none; }
.icon-lg { width: 30px; height: 30px; }
.icon-xl { width: 48px; height: 48px; }
.inline-icon .icon { width: 18px; height: 18px; vertical-align: -3px; }

/* Logo: Hell/Dunkel */
.logo-dark { display: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .logo-light { display: none; }
  :root:not([data-theme="light"]) .logo-dark { display: block; }
}
:root[data-theme="dark"] .logo-light { display: none; }
:root[data-theme="dark"] .logo-dark { display: block; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 10px 18px;
  font: inherit; font-weight: 600; line-height: 1.1; text-decoration: none;
  border: 1px solid transparent; border-radius: var(--radius-sm);
  cursor: pointer; touch-action: manipulation;
  transition: background-color .15s, border-color .15s, color .15s;
}
.btn:disabled { opacity: .55; cursor: progress; }
.btn .icon { width: 20px; height: 20px; }
.btn-primary { background: var(--brand); color: var(--brand-ink); }
.btn-primary:hover { background: var(--brand-hover); color: var(--brand-ink); }
.btn-secondary { background: var(--surface); color: var(--ink); border-color: var(--line); }
.btn-secondary:hover { border-color: var(--ink-3); color: var(--ink); }
.btn-ghost { background: transparent; color: var(--ink-2); }
.btn-ghost:hover { background: var(--surface-2); color: var(--ink); }
.btn-sm { min-height: 36px; padding: 6px 12px; font-size: .875rem; }
.btn-lg { min-height: 52px; font-size: 1.05rem; }
.btn-block { width: 100%; }
.btn-icon { padding: 8px; min-width: 44px; }

/* ---------- Formulare ---------- */
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-weight: 600; font-size: .925rem; }
.field label small { font-weight: 400; color: var(--ink-3); }
input:not([type="checkbox"]):not([type="radio"]), select, textarea {
  width: 100%; min-height: 46px; padding: 10px 12px;
  font: inherit; font-size: max(16px, 1rem); /* 16px verhindert Auto-Zoom auf iOS */
  color: var(--ink); background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  appearance: none;
}
select {
  background-image: linear-gradient(45deg, transparent 50%, currentColor 50%), linear-gradient(135deg, currentColor 50%, transparent 50%);
  background-position: calc(100% - 18px) 50%, calc(100% - 13px) 50%;
  background-size: 5px 5px; background-repeat: no-repeat; padding-right: 34px;
}
textarea { min-height: 96px; resize: vertical; }
input:disabled { color: var(--ink-3); background: var(--surface-2); }
input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 2px solid var(--focus); outline-offset: 0; border-color: var(--focus); }
.check { display: flex; gap: 10px; align-items: flex-start; cursor: pointer; }
.check input { width: 20px; height: 20px; margin-top: 2px; accent-color: var(--brand); flex: none; }
.hint { font-size: .85rem; color: var(--ink-3); margin: 0; }
.form-error { color: var(--err-ink); background: var(--err-bg); padding: 10px 12px; border-radius: var(--radius-sm); margin: 0; }
.grid-2 { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 240px), 1fr)); }
.inline-form { display: flex; flex-wrap: wrap; gap: 10px; }
.inline-form input { flex: 1 1 220px; }
.inline-form select { flex: 0 1 180px; }
.inline-form .btn { flex: 0 0 auto; }
.search-field { margin-bottom: 12px; }

.divider { display: flex; align-items: center; gap: 12px; color: var(--ink-3); font-size: .85rem; margin: 22px 0; }
.divider::before, .divider::after { content: ""; flex: 1; height: 1px; background: var(--line); }
details > summary { cursor: pointer; color: var(--ink-2); font-weight: 600; min-height: 44px; display: flex; align-items: center; }
.divider-details { margin-top: 22px; border-top: 1px solid var(--line); padding-top: 6px; }
.divider-details[open] > summary { margin-bottom: 12px; }
.explain p { font-size: .9rem; color: var(--ink-2); margin-top: 4px; }

/* ---------- Meldungen ---------- */
.alert { padding: 12px 14px; border-radius: var(--radius-sm); margin: 0 0 16px; display: flex; gap: 8px; align-items: flex-start; }
.alert-success { background: var(--ok-bg); color: var(--ok-ink); }
.alert-warning { background: var(--warn-bg); color: var(--warn-ink); }
.alert-error { background: var(--err-bg); color: var(--err-ink); }
.alert-info { background: var(--info-bg); color: var(--info-ink); }
.badge { display: inline-block; font-size: .75rem; font-weight: 600; padding: 1px 8px; border-radius: 99px; background: var(--info-bg); color: var(--info-ink); }
.badge-danger { background: var(--err-bg); color: var(--err-ink); }
pre.debug { white-space: pre-wrap; font-size: .75rem; background: var(--surface-2); padding: 12px; border-radius: 6px; max-height: 50vh; overflow: auto; }

/* ---------- Einfaches Layout (Login, Einladung, Fehler) ---------- */
body.plain { min-height: 100dvh; }
.plain-main {
  min-height: 100dvh; display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: calc(var(--sat) + 24px) calc(var(--sar) + var(--gutter)) calc(var(--sab) + 24px) calc(var(--sal) + var(--gutter));
}
.plain-card {
  width: 100%; max-width: 440px; background: var(--surface);
  border-radius: 14px; box-shadow: var(--shadow); padding: 28px 24px;
  border-top: 4px solid var(--brand);
}
.plain-logo { display: block; margin: 0 auto 24px; max-width: 240px; }
.plain-logo img { width: 100%; height: auto; }
.plain-footer { margin-top: 20px; font-size: .8rem; color: var(--ink-3); text-align: center; }
@media (max-width: 380px) {
  .plain-card { padding: 22px 16px; border-radius: 10px; }
}

/* ---------- App-Layout (mobil zuerst) ---------- */
.app {
  min-height: 100dvh;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: auto 1fr;
  grid-template-areas: "top" "main";
}
.topbar {
  grid-area: top; position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  min-height: calc(var(--topbar-h) + var(--sat));
  padding: var(--sat) calc(var(--sar) + var(--gutter)) 0 calc(var(--sal) + var(--gutter));
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  -webkit-backdrop-filter: saturate(180%) blur(12px); backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--line);
}
.topbar-logo { display: block; width: 132px; flex: none; }
.topbar-logo img { width: 100%; height: auto; }
.topbar-context { display: flex; align-items: center; gap: 12px; min-width: 0; }
.tenant-name { display: none; font-weight: 600; color: var(--ink-2); }
.tenant-switch select { min-height: 38px; padding-block: 6px; font-size: 16px; max-width: 46vw; }
.user-chip { display: none; flex-direction: column; text-align: right; font-weight: 600; font-size: .9rem; line-height: 1.25; }
.user-chip small { font-weight: 400; color: var(--ink-3); }

.content {
  grid-area: main; min-width: 0; width: 100%; max-width: 1100px; margin: 0 auto;
  padding: 20px calc(var(--sar) + var(--gutter)) calc(var(--bottombar-h) + var(--sab) + 28px) calc(var(--sal) + var(--gutter));
}
.content:focus { outline: none; }

.sidebar { display: none; }
.sidebar ul, .more-menu ul { list-style: none; margin: 0; padding: 0; }

/* Untere Navigation (Smartphone) */
.bottombar {
  position: fixed; inset: auto 0 0 0; z-index: 30;
  display: grid; grid-template-columns: repeat(5, 1fr);
  padding: 0 var(--sar) var(--sab) var(--sal);
  background: color-mix(in srgb, var(--surface) 94%, transparent);
  -webkit-backdrop-filter: saturate(180%) blur(12px); backdrop-filter: saturate(180%) blur(12px);
  border-top: 1px solid var(--line);
}
.bottombar a, .bottombar button {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  min-height: var(--bottombar-h); padding: 6px 2px;
  font: inherit; font-size: .7rem; font-weight: 600; color: var(--ink-3); text-decoration: none;
  background: none; border: 0; cursor: pointer; -webkit-tap-highlight-color: transparent;
}
.bottombar [aria-current="page"], .bottombar [aria-expanded="true"] { color: var(--brand); }
.bottombar span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }

.more-menu {
  position: fixed; z-index: 40;
  right: calc(var(--sar) + 10px); bottom: calc(var(--bottombar-h) + var(--sab) + 10px);
  width: min(300px, calc(100vw - var(--sal) - var(--sar) - 20px));
  max-height: calc(100dvh - var(--bottombar-h) - var(--sab) - var(--sat) - 40px); overflow: auto;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: 0 10px 30px rgb(0 0 0 / .18); padding: 6px;
}
.more-menu a, .nav-button {
  display: flex; align-items: center; gap: 12px; width: 100%; min-height: 48px; padding: 10px 12px;
  font: inherit; color: var(--ink); text-decoration: none; text-align: left;
  background: none; border: 0; border-radius: var(--radius-sm); cursor: pointer;
}
.more-menu a:hover, .nav-button:hover { background: var(--surface-2); color: var(--ink); }

/* Sehr schmale Displays (z. B. Galaxy Z Fold außen, iPhone SE) */
@media (max-width: 359px) {
  :root { --gutter: 12px; }
  .topbar-logo { width: 112px; }
  .bottombar span { font-size: .62rem; }
}

/* Breiter als ein Smartphone: Namen zeigen */
@media (min-width: 600px) {
  .user-chip { display: flex; }
  .tenant-name { display: inline; }
  .topbar-logo { width: 160px; }
}

/* Tablet quer / Desktop / aufgeklapptes Foldable: Seitenleiste statt unterer Leiste */
@media (min-width: 900px) {
  .app {
    grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
    grid-template-areas: "top top" "nav main";
  }
  .sidebar {
    grid-area: nav; display: flex; flex-direction: column; justify-content: space-between;
    position: sticky; top: calc(var(--topbar-h) + var(--sat)); align-self: start;
    height: calc(100dvh - var(--topbar-h) - var(--sat));
    padding: 16px 12px calc(16px + var(--sab)) calc(var(--sal) + 12px);
    border-right: 1px solid var(--line); background: var(--surface); overflow-y: auto;
  }
  .sidebar a, .sidebar .nav-button {
    display: flex; align-items: center; gap: 12px; min-height: 44px; padding: 10px 12px;
    color: var(--ink-2); text-decoration: none; font-weight: 600; border-radius: var(--radius-sm);
  }
  .sidebar a:hover, .sidebar .nav-button:hover { background: var(--surface-2); color: var(--ink); }
  .sidebar a[aria-current="page"] { background: color-mix(in srgb, var(--brand) 10%, transparent); color: var(--brand); }
  .sidebar-secondary { border-top: 1px solid var(--line); padding-top: 12px !important; margin-top: 12px !important; }
  .bottombar, .more-menu { display: none !important; }
  .content { padding: 28px calc(var(--sar) + 32px) calc(var(--sab) + 40px) 32px; }
}

/* Foldables / Dual-Screen nebeneinander (Surface Duo, Galaxy Fold aufgeklappt mit Scharnier):
   Navigation auf dem linken Display, Inhalt auf dem rechten – nie über das Scharnier. */
@media (horizontal-viewport-segments: 2) {
  .app {
    grid-template-columns: env(viewport-segment-width 0 0, 50vw) minmax(0, 1fr);
    column-gap: calc(env(viewport-segment-left 1 0, 50vw) - env(viewport-segment-right 0 0, 50vw));
    grid-template-areas: "top main" "nav main";
    grid-template-rows: auto 1fr;
  }
  .topbar { position: static; }
  .sidebar {
    grid-area: nav; display: flex; flex-direction: column; position: static; height: auto;
    padding: 16px calc(var(--gutter)) calc(var(--sab) + 16px) calc(var(--sal) + var(--gutter));
    border: 0; background: transparent;
  }
  .sidebar a, .sidebar .nav-button { display: flex; align-items: center; gap: 12px; min-height: 48px; padding: 10px 12px; text-decoration: none; color: var(--ink-2); font-weight: 600; }
  .sidebar a[aria-current="page"] { color: var(--brand); }
  .bottombar, .more-menu { display: none !important; }
  .content { max-width: none; height: 100dvh; overflow-y: auto; padding: calc(var(--sat) + 20px) calc(var(--sar) + 20px) calc(var(--sab) + 20px) 20px; }
}

/* Foldable übereinander (Laptop-Haltung): Inhalt oben, Navigation unten */
@media (vertical-viewport-segments: 2) {
  .content { padding-bottom: calc(100dvh - env(viewport-segment-top 0 1, 50dvh) + 16px); }
}

/* Querformat auf niedrigen Smartphones: kompaktere Leisten */
@media (max-height: 480px) and (orientation: landscape) and (max-width: 899px) {
  :root { --topbar-h: 48px; --bottombar-h: 50px; }
  .bottombar a span, .bottombar button span { display: none; }
}

/* ---------- Bausteine ---------- */
.page-head { margin-bottom: 20px; }
.page-head .muted { margin: -2px 0 0; }
.page-head-actions { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; justify-content: space-between; }
.page-head-actions h1 { margin: 0; }

.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 20px; margin-bottom: 18px;
}
@media (max-width: 480px) { .card { padding: 16px; border-radius: 8px; } }

.callout {
  display: grid; grid-template-columns: auto 1fr; gap: 12px 14px; align-items: center;
  background: var(--surface); border: 1px solid var(--line); border-left: 4px solid var(--brand);
  border-radius: var(--radius); padding: 16px; margin-bottom: 18px;
}
.callout p { margin: 2px 0 0; color: var(--ink-2); font-size: .925rem; }
.callout .btn { grid-column: 1 / -1; }
.callout > .icon { color: var(--brand); }
.callout-subtle { border-left-color: var(--line); }
.callout-subtle > .icon { color: var(--ink-2); }
@media (min-width: 600px) {
  .callout { grid-template-columns: auto 1fr auto; }
  .callout .btn { grid-column: auto; }
}

.stats { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 140px), 1fr)); margin-bottom: 18px; }
.stat {
  display: flex; flex-direction: column; padding: 16px; text-decoration: none;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
}
.stat-value { font-size: 1.8rem; font-weight: 700; line-height: 1.1; font-variant-numeric: tabular-nums; }
.stat-label { color: var(--ink-3); font-size: .85rem; }

.tiles { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 220px), 1fr)); }
.tile {
  display: flex; flex-direction: column; gap: 6px; padding: 20px; min-height: 140px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  text-decoration: none; color: var(--ink); transition: border-color .15s, transform .15s;
}
.tile:hover { border-color: var(--brand); color: var(--ink); }
.tile > .icon { color: var(--brand); margin-bottom: 4px; }
.tile span { color: var(--ink-3); font-size: .9rem; }

.list { list-style: none; margin: 0; padding: 0; }
.list.card { padding: 0; overflow: hidden; }
.list-row {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 12px 0; border-bottom: 1px solid var(--line);
}
.list.card .list-row { padding: 12px 16px; }
.list-row:last-child { border-bottom: 0; }
.list-row > .icon { color: var(--ink-3); }
.list-main { flex: 1 1 200px; min-width: 0; display: flex; flex-direction: column; text-decoration: none; color: inherit; }
a.list-main:hover strong { color: var(--brand); }
.list-row.is-disabled { opacity: .6; }
.list-row.is-pending > .icon { color: var(--info-ink); }
.list-row form { margin: 0; }
.list-empty { padding: 20px 16px; color: var(--ink-3); text-align: center; }

.empty-state { text-align: center; padding: 40px 20px; }
.empty-state > .icon { color: var(--ink-3); margin-bottom: 8px; }

/* Installationsanleitung */
.tab-list { display: flex; gap: 6px; overflow-x: auto; margin-bottom: 12px; padding-bottom: 2px; scrollbar-width: none; }
.tab-list [role="tab"] {
  flex: 0 0 auto; min-height: 44px; padding: 8px 16px; font: inherit; font-weight: 600;
  color: var(--ink-2); background: var(--surface); border: 1px solid var(--line); border-radius: 99px; cursor: pointer;
}
.tab-list [aria-selected="true"] { background: var(--ink); color: var(--surface); border-color: var(--ink); }
.steps { padding-left: 1.4em; margin: 0 0 1em; }
.steps li { margin-bottom: 10px; padding-left: 4px; }
.steps li::marker { font-weight: 700; color: var(--brand); }
.install-auto { margin-bottom: 18px; }

/* Druck */
@media print {
  .topbar, .sidebar, .bottombar, .more-menu { display: none !important; }
  .app { display: block; }
  .content { padding: 0; }
  .no-print, .no-tenant, .flash, .alert-info { display: none !important; }
  .card.statement { border: 0; box-shadow: none; padding: 0; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}

/* ---------- Flächen & Verträge ---------- */
.actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.card-head { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.card-head h2 { margin: 0; }
.grid-3 { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 170px), 1fr)); }
.badge-ok { background: var(--ok-bg); color: var(--ok-ink); }
.badge-warn { background: var(--warn-bg); color: var(--warn-ink); }
.badge-muted { background: var(--surface-2); color: var(--ink-3); }

.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin: 4px 0 16px; }
.toolbar input[type="search"] { flex: 1 1 220px; width: auto; }
.segmented { display: inline-flex; border: 1px solid var(--line); border-radius: var(--radius-sm); overflow: hidden; background: var(--surface); }
.segmented button {
  min-height: 44px; padding: 8px 14px; font: inherit; font-weight: 600; color: var(--ink-2);
  background: none; border: 0; border-right: 1px solid var(--line); cursor: pointer;
}
.segmented button:last-child { border-right: 0; }
.segmented [aria-pressed="true"] { background: var(--ink); color: var(--surface); }

.building { margin-bottom: 28px; }
.floor-head { font-size: .85rem; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-3); margin: 18px 0 8px; }
.unit-grid { display: grid; gap: 8px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 150px), 1fr)); }
.unit {
  --section: #888888;
  display: flex; flex-direction: column; gap: 2px; min-height: 92px; padding: 10px 12px 10px 14px;
  background: var(--surface); border: 1px solid var(--line); border-left: 5px solid var(--section);
  border-radius: var(--radius-sm); text-decoration: none; color: var(--ink); font-size: .875rem;
}
.unit:hover { border-color: var(--ink-3); border-left-color: var(--section); color: var(--ink); }
.unit-head { display: flex; justify-content: space-between; align-items: baseline; gap: 6px; }
.unit-head strong { font-size: 1rem; }
.unit-section { font-size: .72rem; font-weight: 700; color: var(--ink-3); }
.unit-area { color: var(--ink-3); }
.unit-tenant { font-weight: 600; line-height: 1.3; }
.unit-tenant small { display: block; font-weight: 400; color: var(--ink-3); }
.unit-free { background: var(--surface-2); border-style: dashed; border-left-style: solid; }
.unit-free .unit-tenant { color: var(--ok-ink); }
.unit-inactive { opacity: .55; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0; }
.chip {
  --section: #888888;
  display: inline-flex; align-items: center; gap: 6px; min-height: 32px; padding: 4px 10px;
  font-size: .85rem; font-weight: 600; color: var(--ink); text-decoration: none;
  background: var(--surface-2); border: 1px solid var(--line); border-radius: 99px;
}
.chip small { font-weight: 400; color: var(--ink-3); }
.chip-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--section); flex: none; }
a.chip:hover { border-color: var(--ink-3); color: var(--ink); }

.lease { border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 14px; margin-bottom: 12px; }
.lease-head { display: flex; justify-content: space-between; gap: 10px; align-items: flex-start; }
.lease-head > div { display: flex; flex-direction: column; }
.lease-foot { margin: 10px 0 0; }
.facts { display: grid; gap: 8px 16px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 140px), 1fr)); margin: 8px 0 0; }
.facts div { display: flex; flex-direction: column; }
.facts dt { font-size: .78rem; color: var(--ink-3); }
.facts dd { margin: 0; font-weight: 600; font-variant-numeric: tabular-nums; }

.picker-sum { font-variant-numeric: tabular-nums; }
.picker-group { border: 0; padding: 0; margin: 0 0 14px; min-width: 0; }
.picker-group legend { font-weight: 700; margin-bottom: 8px; }
.picker-grid { display: grid; gap: 6px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 128px), 1fr)); }
.pick {
  --section: #888888;
  position: relative; display: flex; flex-direction: column; min-height: 56px; padding: 8px 10px 8px 34px;
  background: var(--surface); border: 1px solid var(--line); border-left: 4px solid var(--section);
  border-radius: var(--radius-sm); cursor: pointer; font-size: .85rem; -webkit-tap-highlight-color: transparent;
}
.pick input { position: absolute; left: 9px; top: 10px; width: 18px; height: 18px; margin: 0; accent-color: var(--brand); }
.pick-num { font-weight: 700; font-size: .95rem; }
.pick-meta { color: var(--ink-3); line-height: 1.25; }
.pick.is-selected { background: color-mix(in srgb, var(--brand) 8%, var(--surface)); border-color: var(--brand); border-left-color: var(--section); }
.pick.is-busy:not(.is-selected) { opacity: .6; }
.pick:has(input:focus-visible) { outline: 3px solid var(--focus); outline-offset: 2px; }

.sticky-actions {
  position: sticky; bottom: calc(var(--bottombar-h) + var(--sab) + 8px); z-index: 5;
  display: flex; flex-wrap: wrap; gap: 10px; align-items: center; justify-content: flex-end;
  padding: 10px 12px; margin-top: 12px; background: color-mix(in srgb, var(--surface) 94%, transparent);
  -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
  border: 1px solid var(--line); border-radius: var(--radius);
}
.sticky-actions > span { margin-right: auto; }
@media (min-width: 900px) { .sticky-actions { bottom: calc(var(--sab) + 12px); } }

.area-table { display: grid; gap: 6px 14px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 200px), 1fr)); }
.area-floor { grid-column: 1 / -1; font-size: .85rem; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-3); margin: 14px 0 2px; }
.area-floor:first-child { margin-top: 0; }
.area-row {
  --section: #888888;
  display: grid; grid-template-columns: 70px 1fr auto; align-items: center; gap: 8px;
  padding-left: 8px; border-left: 4px solid var(--section);
}
.area-num { font-weight: 700; }
.area-num small { font-weight: 400; color: var(--ink-3); }
.area-row input { min-height: 42px; text-align: right; font-variant-numeric: tabular-nums; }
.area-unit { color: var(--ink-3); font-size: .85rem; }

.table-wrap { overflow-x: auto; margin: 0 -4px 12px; }
.table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.table th, .table td { padding: 8px 6px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; white-space: nowrap; }
.table th { font-size: .78rem; color: var(--ink-3); font-weight: 600; }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }
.table form { margin: 0; }
.color-input { flex: 0 0 56px !important; min-height: 46px; padding: 4px !important; }

/* ---------- Tickets ---------- */
.segmented a {
  display: inline-flex; align-items: center; min-height: 44px; padding: 8px 14px;
  font-weight: 600; color: var(--ink-2); text-decoration: none; border-right: 1px solid var(--line);
}
.segmented a:last-child { border-right: 0; }
.segmented a[aria-current="true"] { background: var(--ink); color: var(--surface); }
.search-form { display: flex; flex-wrap: wrap; gap: 8px; flex: 1 1 320px; }
.search-form input[type="search"] { flex: 1 1 200px; width: auto; }
.search-form select { flex: 0 1 200px; width: auto; }
.badge-new { background: color-mix(in srgb, var(--brand) 14%, transparent); color: var(--brand); }

.ticket-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.ticket-row {
  display: flex; flex-direction: column; gap: 4px; padding: 14px 16px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  text-decoration: none; color: var(--ink);
}
.ticket-row:hover { border-color: var(--ink-3); color: var(--ink); }
.ticket-row.prio-urgent { border-left: 4px solid var(--brand); }
.ticket-row.prio-high { border-left: 4px solid var(--warn-ink); }
.ticket-top { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.ticket-no { font-weight: 700; color: var(--ink-3); font-variant-numeric: tabular-nums; }
.ticket-time { margin-left: auto; font-size: .8rem; color: var(--ink-3); }
.ticket-title { font-size: 1.02rem; display: flex; align-items: center; gap: 8px; }
.ticket-row.is-unread .ticket-title { font-weight: 800; }
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--brand); flex: none; }
.ticket-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; font-size: .85rem; color: var(--ink-3); }
.meta-count { display: inline-flex; align-items: center; gap: 3px; }
.meta-count .icon { width: 15px; height: 15px; }

.choice-group { border: 0; padding: 0; margin: 0 0 14px; min-width: 0; }
.choice-group legend { font-weight: 600; font-size: .925rem; margin-bottom: 8px; }
.choices { display: flex; flex-wrap: wrap; gap: 8px; }
.choice { position: relative; }
.choice input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.choice span {
  display: inline-flex; align-items: center; min-height: 44px; padding: 8px 16px;
  font-weight: 600; background: var(--surface-2); border: 1px solid var(--line); border-radius: 99px;
}
.choice input:checked + span { background: var(--ink); color: var(--surface); border-color: var(--ink); }
.choice input:focus-visible + span { outline: 3px solid var(--focus); outline-offset: 2px; }
.check-urgent { padding: 12px; border: 1px solid var(--line); border-radius: var(--radius-sm); }
.check-urgent:has(input:checked) { border-color: var(--brand); background: color-mix(in srgb, var(--brand) 8%, transparent); }

.upload-drop {
  display: flex; align-items: center; gap: 14px; padding: 18px; cursor: pointer;
  border: 2px dashed var(--line); border-radius: var(--radius); background: var(--surface-2);
}
.upload-drop:hover { border-color: var(--ink-3); }
.upload-drop > .icon { color: var(--brand); }
.uploader:has(input:focus-visible) .upload-drop { outline: 3px solid var(--focus); outline-offset: 2px; }
.uploader.is-busy .upload-drop { opacity: .6; cursor: progress; }
.upload-previews { list-style: none; margin: 10px 0 0; padding: 0; display: grid; gap: 8px; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); }
.upload-item {
  position: relative; aspect-ratio: 1; border-radius: var(--radius-sm); overflow: hidden;
  background: var(--surface-2); border: 1px solid var(--line); display: flex; align-items: center; justify-content: center;
}
.upload-item img { width: 100%; height: 100%; object-fit: cover; }
.upload-item small { position: absolute; left: 4px; bottom: 4px; background: rgb(0 0 0 / .6); color: #fff; padding: 0 5px; border-radius: 4px; font-size: .7rem; }
.upload-name { font-size: .75rem; padding: 6px; text-align: center; word-break: break-all; }
.upload-remove {
  position: absolute; top: 4px; right: 4px; width: 32px; height: 32px; border-radius: 50%;
  border: 0; background: rgb(0 0 0 / .65); color: #fff; font-size: 1.2rem; line-height: 1; cursor: pointer;
}

.ticket-head { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-bottom: 6px; }
.ticket-layout { display: grid; gap: 18px; grid-template-columns: minmax(0, 1fr); }
@media (min-width: 1100px) {
  .ticket-layout { grid-template-columns: minmax(0, 1fr) 300px; align-items: start; }
  .ticket-side { position: sticky; top: calc(var(--topbar-h) + var(--sat) + 16px); }
}
.ticket-desc { margin-top: 14px; white-space: normal; line-height: 1.6; }

.attachments { display: grid; gap: 8px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 120px), 1fr)); margin-top: 12px; }
.thumb { display: block; aspect-ratio: 4 / 3; border-radius: var(--radius-sm); overflow: hidden; border: 1px solid var(--line); background: var(--surface-2); }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.file-chip {
  display: flex; flex-direction: column; gap: 4px; padding: 10px; min-height: 90px;
  border: 1px solid var(--line); border-radius: var(--radius-sm); text-decoration: none; color: var(--ink); font-size: .85rem;
  overflow-wrap: anywhere;
}
.file-chip small { color: var(--ink-3); }

.timeline-head { margin: 22px 0 10px; }
.timeline { list-style: none; margin: 0 0 18px; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.tl-event { display: flex; flex-wrap: wrap; justify-content: center; gap: 4px 10px; font-size: .85rem; color: var(--ink-3); text-align: center; }
.tl-event time { opacity: .8; }
.tl-msg { display: flex; }
.tl-msg.is-mine { justify-content: flex-end; }
.tl-bubble {
  max-width: min(640px, 92%); padding: 10px 14px; border-radius: 14px;
  background: var(--surface); border: 1px solid var(--line);
}
.tl-msg.is-staff .tl-bubble { border-left: 3px solid var(--brand); }
.tl-msg.is-mine .tl-bubble { background: color-mix(in srgb, var(--ink) 6%, var(--surface)); }
.tl-msg.is-internal .tl-bubble { background: var(--warn-bg); border-color: transparent; color: var(--ink); }
.tl-meta { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px 10px; font-size: .82rem; margin-bottom: 4px; }
.tl-meta time { color: var(--ink-3); }
.tl-body { line-height: 1.55; }

.category-form { flex: 1; align-items: center; }
.category-form input[name="name"] { flex: 1 1 180px; }
.sort-input { flex: 0 0 80px !important; }

/* ---------- Nachrichten & Badges ---------- */
.nav-badge {
  display: inline-flex; align-items: center; justify-content: center; min-width: 20px; height: 20px; padding: 0 6px;
  margin-left: auto; font-size: .72rem; font-weight: 700; line-height: 1; color: #fff; background: var(--brand); border-radius: 99px;
}
.nav-icon { position: relative; display: inline-flex; }
.bottombar .nav-icon { overflow: visible; max-width: none; }
.bottombar .nav-badge { position: absolute; top: -7px; left: 14px; right: auto; max-width: none; overflow: visible; margin: 0; min-width: 18px; height: 18px; font-size: .66rem; border: 2px solid var(--surface); box-sizing: content-box; }
.conv-row.is-broadcast { border-left: 4px solid var(--brand); }
.conv-company { font-size: .9rem; }
.conv-excerpt { display: block; overflow: hidden; text-overflow: ellipsis; }
.conv-excerpt .meta-count { margin-left: 8px; }
.badge .icon { width: 13px; height: 13px; vertical-align: -2px; }
a.badge { text-decoration: none; }
.tl-msg.is-letter .tl-bubble { max-width: 100%; width: 100%; border-radius: var(--radius); padding: 18px 20px; }
.tl-msg.is-letter .tl-body { font-size: 1.02rem; line-height: 1.65; }
.recipients summary { min-height: auto; }
.audience-panel { margin-top: 6px; display: grid; gap: 8px; }
.company-picks { display: grid; gap: 6px 16px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 240px), 1fr)); max-height: 340px; overflow-y: auto; padding: 4px; }
.company-pick { min-height: 36px; align-items: center; }

/* ---------- Dokumente ---------- */
.doc-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.doc-row {
  display: flex; align-items: stretch; gap: 4px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
}
.doc-row:hover { border-color: var(--ink-3); }
.doc-open { flex: 1; min-width: 0; display: flex; gap: 14px; padding: 14px 4px 14px 14px; text-decoration: none; color: var(--ink); }
.doc-open:hover { color: var(--ink); }
.doc-icon {
  flex: none; width: 44px; height: 52px; display: flex; align-items: center; justify-content: center;
  border-radius: 6px; background: var(--surface-2); color: var(--ink-2); font-size: .7rem; font-weight: 800; letter-spacing: .04em;
}
.doc-icon.is-pdf { background: color-mix(in srgb, var(--brand) 12%, transparent); color: var(--brand); }
.doc-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.doc-title { display: flex; align-items: center; gap: 8px; }
.doc-row.is-unread .doc-title { font-weight: 800; }
.doc-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 6px; font-size: .82rem; color: var(--ink-3); }
.doc-desc { font-size: .88rem; color: var(--ink-2); }
.doc-read { font-size: .8rem; color: var(--ink-3); display: inline-flex; align-items: center; gap: 4px; }
.doc-read.is-read { color: var(--ok-ink); }
.doc-read .icon { width: 15px; height: 15px; }
.doc-actions { display: flex; flex-direction: column; justify-content: center; padding: 6px; }
.doc-actions form { margin: 0; }
@media (min-width: 600px) { .doc-actions { flex-direction: row; align-items: center; } }
.push-state { font-weight: 600; color: var(--ink-2); }
.push-state.is-on { color: var(--ok-ink); }

/* ---------- Statusleiste (iOS, black-translucent) ----------
   Die App reicht unter die Statusleiste – oben, im Querformat oder beim iPhone Duo auch seitlich.
   iOS beschriftet sie dann immer weiß; damit Uhrzeit & Co. lesbar bleiben, liegt unter jedem
   Sicherheitsrand (oben/links/rechts) ein dunkler Streifen. Ohne Ränder (Desktop) ist er 0 px breit. */
:root { --chrome: #141414; }
html::before, body::before, body::after {
  content: ""; position: fixed; z-index: 1000; pointer-events: none; background: var(--chrome);
}
html::before { top: 0; left: 0; right: 0; height: var(--sat); }
body::before { top: 0; bottom: 0; left: 0; width: var(--sal); }
body::after  { top: 0; bottom: 0; right: 0; width: var(--sar); }

/* ---------- 1.7.0: Raumhistorie, Verlauf, Profil, Versionen ---------- */
.btn-danger { background: var(--err-ink); color: #fff; }
.btn-danger:hover { filter: brightness(1.1); color: #fff; }
.danger-zone { border-color: color-mix(in srgb, var(--err-ink) 40%, var(--line)); }
.danger-zone > summary, .history > summary { display: flex; align-items: center; justify-content: space-between; gap: 10px; font-weight: 700; color: var(--ink); }
.history-list { list-style: none; margin: 12px 0 0; padding: 0; display: grid; gap: 12px; }
.history-list > li { border-left: 3px solid var(--line); padding: 2px 0 2px 12px; }
.history-list > li:first-child { border-left-color: var(--brand); }
.history-head { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.history-version { font-weight: 800; font-variant-numeric: tabular-nums; color: var(--ink-3); font-size: .85rem; }
.history-changes { margin: 6px 0 0; padding-left: 18px; font-size: .88rem; }
.history-changes del { color: var(--err-ink); text-decoration: line-through; }
.history-changes ins { color: var(--ok-ink); text-decoration: none; font-weight: 600; }
.unit-table td { vertical-align: top; }
.unit-table tr.is-past td { color: var(--ink-3); }
.row-actions { text-align: right; }
.inline-menu { position: relative; display: inline-block; text-align: left; }
.inline-menu > summary { list-style: none; min-height: 36px; }
.inline-menu > summary::-webkit-details-marker { display: none; }
.inline-menu-body {
  position: absolute; right: 0; z-index: 20; width: min(340px, 86vw); margin-top: 6px; padding: 14px;
  display: grid; gap: 14px; white-space: normal;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: 0 10px 30px rgb(0 0 0 / .2);
}
.unit-history { margin: 4px 0 8px; }
.unit-history ul { margin: 6px 0 0; padding-left: 18px; }
.profile-layout { display: grid; gap: 18px; grid-template-columns: minmax(0, 1fr); }
@media (min-width: 900px) { .profile-layout { grid-template-columns: 280px minmax(0, 1fr); align-items: start; } }
.profile-preview { display: flex; flex-direction: column; align-items: center; gap: 10px; text-align: center; }
.logo-box {
  width: 100%; aspect-ratio: 3 / 2; display: flex; align-items: center; justify-content: center; padding: 14px;
  background: #fff; border: 1px dashed var(--line); border-radius: var(--radius-sm);
}
.logo-box img { max-width: 100%; max-height: 100%; object-fit: contain; }
.profile-name { font-size: 1.1rem; }
.releases { list-style: none; margin: 0; padding: 0; }
.release-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 8px; }
.release-version { font-weight: 800; color: var(--brand); font-variant-numeric: tabular-nums; }
.release-date { margin-left: auto; }
.release ul { margin: 10px 0 0; padding-left: 20px; }
.release li + li { margin-top: 4px; }

/* ---------- 1.8.0: Hilfe ---------- */
.help-button {
  display: inline-flex; align-items: center; justify-content: center; width: 40px; height: 40px; flex: none;
  border-radius: 50%; color: var(--ink-2); text-decoration: none; border: 1px solid var(--line); background: var(--surface);
}
.help-button:hover { color: var(--brand); border-color: var(--brand); }
.help-groups { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 320px), 1fr)); align-items: start; }
.help-group h2 { font-size: 1rem; text-transform: uppercase; letter-spacing: .05em; color: var(--ink-3); }
.help-links { list-style: none; margin: 0; padding: 0; }
.help-links li + li { border-top: 1px solid var(--line); }
.help-links a { display: flex; flex-direction: column; gap: 2px; padding: 10px 0; text-decoration: none; color: var(--ink); }
.help-links a:hover strong { color: var(--brand); }
.help-article { max-width: 760px; line-height: 1.65; }
.help-article h2 { margin-top: 1.4em; font-size: 1.2rem; }
.help-article h2:first-child { margin-top: 0; }
.help-article h3 { margin-top: 1.2em; }
.help-article ul, .help-article ol { padding-left: 1.4em; margin: 0 0 1em; }
.help-article li { margin-bottom: 6px; }
.help-article ol li::marker { font-weight: 700; color: var(--brand); }
.help-tip {
  margin: 0 0 1em; padding: 12px 14px; border-left: 4px solid var(--brand); border-radius: var(--radius-sm);
  background: color-mix(in srgb, var(--brand) 7%, var(--surface));
}
.table td.neg { color: var(--err-ink); font-weight: 600; }
.table td.pos { color: var(--ok-ink); font-weight: 600; }

/* ---------- 1.11.0: Rollen ---------- */
.role-legend { display: grid; gap: 10px 20px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 260px), 1fr)); margin: 0; }
.role-legend div { display: flex; flex-direction: column; }
.role-legend dt { font-weight: 700; }
.role-legend dd { margin: 0; color: var(--ink-2); font-size: .9rem; }
.team-row .chips { margin: 6px 0 0; }
.chip-extra { background: color-mix(in srgb, var(--brand) 10%, var(--surface)); border-color: color-mix(in srgb, var(--brand) 35%, var(--line)); }
.extra-roles { border: 0; padding: 0; margin: 0; display: grid; gap: 8px; min-width: 0; }
.extra-roles[disabled] { opacity: .45; }

/* ---------- 1.12.0: Mieterakte ---------- */
.drop-zone {
  display: flex; flex-direction: column; align-items: center; gap: 8px; text-align: center; padding: 28px 16px; cursor: pointer;
  border: 2px dashed var(--line); border-radius: var(--radius); background: var(--surface-2); transition: border-color .15s, background-color .15s;
}
.drop-zone > .icon { color: var(--brand); }
.drop-zone.is-over { border-color: var(--brand); background: color-mix(in srgb, var(--brand) 8%, var(--surface)); }
.record-drop:has(input:focus-visible) .drop-zone { outline: 3px solid var(--focus); outline-offset: 2px; }
.drop-options { margin-top: 12px; }
.upload-progress { list-style: none; margin: 10px 0 0; padding: 0; display: grid; gap: 4px; font-size: .88rem; }
.upload-progress li { padding: 6px 10px; border-radius: var(--radius-sm); background: var(--surface-2); }
.upload-progress li.is-ok { background: var(--ok-bg); color: var(--ok-ink); }
.upload-progress li.is-error { background: var(--err-bg); color: var(--err-ink); }
.record-list { list-style: none; margin: 0; padding: 0; }
.record-row { display: flex; align-items: center; gap: 6px; border-bottom: 1px solid var(--line); }
.record-row:last-child { border-bottom: 0; }
.record-main { flex: 1; min-width: 0; display: flex; gap: 12px; padding: 12px 0; text-decoration: none; color: var(--ink); }
.record-main:hover strong { color: var(--brand); }
.record-icon { flex: none; width: 40px; height: 40px; display: flex; align-items: center; justify-content: center; border-radius: 8px; background: var(--surface-2); color: var(--ink-2); }
.record-icon.kind-email { background: var(--info-bg); color: var(--info-ink); }
.record-icon.kind-contract { background: color-mix(in srgb, var(--brand) 12%, transparent); color: var(--brand); }
.record-icon.kind-note { background: var(--warn-bg); color: var(--warn-ink); }
.record-body { min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.record-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 6px; font-size: .82rem; color: var(--ink-3); }
.record-snippet { font-size: .86rem; color: var(--ink-2); }
mark { background: color-mix(in srgb, #ffd400 55%, transparent); color: inherit; padding: 0 2px; border-radius: 3px; }
.record-text { white-space: normal; line-height: 1.6; margin-top: 14px; overflow-wrap: anywhere; }
.record-actions { margin-top: 12px; }
.record-actions form { margin: 0; }
.record-image { max-width: 100%; border-radius: var(--radius-sm); border: 1px solid var(--line); }

/* ---------- 1.13.0: Vertragsunterlagen ---------- */
.cdoc-current { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; padding: 10px 0; }
.cdoc-current > div { flex: 1 1 220px; display: flex; flex-direction: column; gap: 2px; }
.cdoc-history, .cdoc-upload { margin-top: 10px; border-top: 1px solid var(--line); padding-top: 6px; }
.cdoc-history .list-row form { margin: 0; }

/* ---------- 1.14.0: Unterschrift auf dem iPad ---------- */
.sign-steps { list-style: none; display: flex; gap: 6px; margin: 0 0 16px; padding: 0; counter-reset: st; }
.sign-steps li {
  flex: 1; display: flex; align-items: center; gap: 8px; padding: 10px 12px; font-weight: 600; font-size: .9rem; color: var(--ink-3);
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm); counter-increment: st;
}
.sign-steps li::before {
  content: counter(st); display: inline-flex; align-items: center; justify-content: center; width: 24px; height: 24px; flex: none;
  border-radius: 50%; background: var(--surface-2); font-size: .8rem;
}
.sign-steps li.is-active { color: var(--ink); border-color: var(--brand); }
.sign-steps li.is-active::before { background: var(--brand); color: #fff; }
.sign-steps li.is-done::before { content: "✓"; background: var(--ok-bg); color: var(--ok-ink); }
.sign-pages { display: grid; gap: 14px; max-height: 70vh; overflow-y: auto; padding: 8px; background: var(--surface-2); border-radius: var(--radius-sm); }
.sign-page { position: relative; background: #fff; box-shadow: 0 1px 6px rgb(0 0 0 / .18); }
.sign-page canvas { display: block; width: 100%; height: auto; }
.sign-box {
  --x0: .1; --x1: .47; --line: .85;
  position: absolute; left: calc(var(--x0) * 100%); width: calc((var(--x1) - var(--x0)) * 100%);
  top: calc(var(--line) * 100% - 4%); height: 4%;
  display: flex; align-items: center; justify-content: center; font-size: .75rem; font-weight: 700; color: var(--brand);
  border: 2px dashed var(--brand); border-radius: 4px; background: color-mix(in srgb, var(--brand) 10%, transparent); pointer-events: none;
}
.sign-page.is-adjusting { outline: 3px solid var(--brand); cursor: crosshair; }
.sign-adjust { margin-top: 12px; }
.sign-pad-wrap { position: relative; margin: 10px 0 12px; border: 2px solid var(--line); border-radius: var(--radius); background: #fff; }
.sign-pad { display: block; width: 100%; height: clamp(180px, 32vh, 320px); touch-action: none; cursor: crosshair; }
.sign-line { position: absolute; left: 6%; right: 6%; bottom: 26%; border-bottom: 1.5px solid #9a9a96; pointer-events: none; }
.sign-hint { position: absolute; left: 0; right: 0; bottom: 10%; text-align: center; font-size: .85rem; color: #9a9a96; pointer-events: none; }
.sign-nav { display: flex; flex-wrap: wrap; gap: 10px; justify-content: flex-end; margin-top: 14px; }
.sign-result .btn { flex: 1 1 220px; }
.hash { font-family: ui-monospace, Menlo, monospace; font-size: .75rem; word-break: break-all; }
@media (max-width: 600px) { .sign-steps li { font-size: .75rem; padding: 8px; } .sign-steps li::before { width: 20px; height: 20px; } }

/* ---------- Nebenkosten ---------- */
.grow { flex: 1 1 auto; min-width: 0; }
.statement h1 { font-size: 1.35rem; margin: 18px 0 4px; }
.statement h2 { font-size: 1rem; margin: 22px 0 6px; }
.statement-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; margin-bottom: 18px; }
.statement-head img { max-width: 40%; height: auto; }
.statement .table td, .statement .table th { white-space: normal; }
.statement tfoot th { border-top: 2px solid var(--ink); }

/* ---------- Strom ---------- */
.input-sm { width: 7.5em; min-height: 40px; padding: 6px 8px; }
.table select { min-height: 40px; padding: 6px 8px; width: auto; }

/* ---------- Profilbild & Ansprechpartner ---------- */
.avatar { width: 40px; height: 40px; border-radius: 50%; object-fit: cover; flex: 0 0 auto; background: var(--surface-2); }
.avatar-lg { width: 72px; height: 72px; }
.avatar-xl { width: 112px; height: 112px; }
.avatar-initials { display: inline-flex; align-items: center; justify-content: center; font-weight: 700; color: var(--ink-2); border: 1px solid var(--line); }
.avatar-lg.avatar-initials { font-size: 1.4rem; }
.avatar-xl.avatar-initials { font-size: 2rem; }
.avatar-edit { display: flex; gap: 18px; align-items: flex-start; flex-wrap: wrap; }
.file-btn { position: relative; overflow: hidden; }
.file-btn input[type="file"] { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.chip-contact { background: var(--ok-bg); color: var(--ok-ink); }
.contact-grid { list-style: none; margin: 0 0 12px; padding: 0; display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 260px), 1fr)); }
.contact-card { display: flex; gap: 14px; align-items: center; padding: 12px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface); }
.contact-body { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.contact-body a { overflow-wrap: anywhere; }

/* ---------- Hausmeister-Bericht ---------- */
.print-only { display: none; }
@media print { .print-only { display: block; } }
.person { display: inline-flex; align-items: center; gap: 8px; }
.person .avatar { width: 28px; height: 28px; font-size: .75rem; }
.activity-table td { white-space: normal; vertical-align: top; }
.activity-table tr.is-done td { background: var(--ok-bg); }

/* ---------- Monatsbericht & Diagramme ---------- */
/* Reihenfarben: geprüfte Palette (Hell/Dunkel je eigene Stufe), Text bleibt in Textfarben */
:root { --series-1: #2a78d6; --series-2: #eb6834; --series-3: #1baf7a; --viz-surface: var(--surface); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) { --series-1: #3987e5; --series-2: #d95926; --series-3: #199e70; } }
:root[data-theme="dark"] { --series-1: #3987e5; --series-2: #d95926; --series-3: #199e70; }
.s1 { --c: var(--series-1); }
.s2 { --c: var(--series-2); }
.s3 { --c: var(--series-3); }
.viz { display: block; width: 100%; height: auto; overflow: visible; }
.viz-grid { stroke: var(--line); stroke-width: 1; }
.viz-base { stroke: var(--ink-3); }
.viz-tick, .viz-label, .viz-value { fill: var(--ink-3); font-size: 14px; font-family: inherit; }
.viz-label { fill: var(--ink-2); font-size: 15px; }
.viz-value { fill: var(--ink); font-size: 15px; font-weight: 600; }
.viz-fill { fill: var(--c); }
.viz-line { fill: none; stroke: var(--c); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.viz-dot { fill: var(--c); stroke: var(--viz-surface); stroke-width: 2; }
.viz-hit { fill: transparent; cursor: pointer; outline: none; }
.viz-hit:hover, .viz-hit:focus { fill: var(--ink); fill-opacity: .05; }
.viz-legend { list-style: none; display: flex; flex-wrap: wrap; gap: 4px 16px; margin: 0 0 8px; padding: 0; font-size: .82rem; color: var(--ink-2); }
.viz-legend li { display: inline-flex; align-items: center; gap: 6px; }
.viz-swatch { width: 12px; height: 12px; border-radius: 3px; background: var(--c); display: inline-block; }
.viz-tooltip { position: fixed; z-index: 50; pointer-events: none; max-width: 280px; padding: 8px 10px; border-radius: var(--radius-sm);
  background: var(--ink); color: var(--surface); font-size: .8rem; line-height: 1.35; box-shadow: 0 4px 14px rgba(0,0,0,.18); }
.viz-table { margin-top: 6px; }
.report-head { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 12px; align-items: flex-end; }
.kpis { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 170px), 1fr)); margin-bottom: 16px; }
.kpi { display: flex; flex-direction: column; gap: 2px; padding: 14px 16px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface); }
.kpi-label { font-size: .78rem; color: var(--ink-3); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.kpi-value { font-size: 1.55rem; line-height: 1.2; font-variant-numeric: tabular-nums; }
.kpi-sub { font-size: .8rem; color: var(--ink-3); }
.kpi-delta { font-size: .78rem; color: var(--ink-2); }
.kpi-delta.is-up::first-letter, .kpi-delta.is-down::first-letter { font-size: .7rem; }
.report-grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 420px), 1fr)); margin-bottom: 16px; }
.report-grid > .card { margin: 0; }
.report-tenants td.wrap { white-space: normal; min-width: 120px; }
@media print {
  .report .card { break-inside: avoid; border: 1px solid #ccc; box-shadow: none; }
  .report-grid { grid-template-columns: 1fr 1fr; }
  .kpis { grid-template-columns: repeat(3, 1fr); }
  .viz-hit { display: none; }
  .report-tenants .table { font-size: 9pt; }
  :root:root:root { --series-1: #2a78d6; --series-2: #eb6834; --series-3: #1baf7a; --ink: #141414; --ink-2: #3b3b3b; --ink-3: #6e6e6e; --surface: #fff; --line: #ddd; }
}

.report-units { margin: -4px 0 16px; font-size: .9rem; color: var(--ink-2); }
.viz-fill.is-forecast { fill-opacity: .42; }
.viz-swatch.is-forecast { opacity: .42; }
.viz-swatch.is-hatch { background: repeating-linear-gradient(45deg, var(--c) 0 2px, transparent 2px 5px); border: 1px solid var(--c); }
.is-forecast-row td { color: var(--ink-2); font-style: italic; }

/* Druck/PDF immer hell – auch wenn am Bildschirm der Dunkelmodus aktiv ist */
@media print {
  :root:root:root {
  --brand: #e30613;
  --brand-hover: #c20510;
  --brand-ink: #ffffff;
  --ink: #141414;
  --ink-2: #4a4a4a;
  --ink-3: #6e6e6e;
  --bg: #f4f4f2;
  --surface: #ffffff;
  --surface-2: #f8f8f7;
  --line: #e2e2df;
  --focus: #e30613;
  --ok-bg: #e8f5ec;   --ok-ink: #17602f;
  --warn-bg: #fff5dc; --warn-ink: #7a5300;
  --err-bg: #fdecec;  --err-ink: #a3000b;
  --info-bg: #eef3fb; --info-ink: #1f4d8f;

  --radius: 10px;
  --radius-sm: 6px;
  --shadow: 0 1px 2px rgb(0 0 0 / .05), 0 2px 8px rgb(0 0 0 / .04);
  --font: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;

  --sat: env(safe-area-inset-top, 0px);
  --sar: env(safe-area-inset-right, 0px);
  --sab: env(safe-area-inset-bottom, 0px);
  --sal: env(safe-area-inset-left, 0px);
  --gutter: 16px;
  --topbar-h: 60px;
  --bottombar-h: 62px;
  --sidebar-w: 240px;
  color-scheme: light;
    color-scheme: light;
  }
  body { background: #fff; }
  .logo-light { display: block !important; }
  .logo-dark { display: none !important; }
}

/* ---------- Darstellung: Übersicht anpassen & Navigation sortieren ---------- */
.dash-toolbar { display: flex; justify-content: flex-end; margin: -6px 0 8px; }
.dash-grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 220px), 1fr)); align-items: stretch; }
.dash-item { position: relative; display: flex; flex-direction: column; min-width: 0; }
.dash-item > .tile { flex: 1; }
.dash-item.is-wide { grid-column: 1 / -1; }
.dash-item > .card, .dash-item > .stats { margin: 0; }
.dash-controls { display: none; }
.dash-editing .dash-item { outline: 2px dashed var(--line); outline-offset: 3px; border-radius: var(--radius); }
.dash-editing .dash-item a { pointer-events: none; }
.dash-editing .dash-controls { display: flex; gap: 4px; justify-content: flex-end; order: -1; margin-bottom: 6px; }
.dash-controls button, .dash-handle {
  min-width: 36px; min-height: 36px; padding: 0 8px; font: inherit; font-size: 1rem; line-height: 1;
  color: var(--ink); background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm); cursor: pointer;
}
.dash-handle { cursor: grab; touch-action: none; user-select: none; -webkit-user-select: none; }
.dash-item.is-dragging, .sort-list li.is-dragging { opacity: .55; outline: 2px solid var(--brand); }
.dash-catalog { list-style: none; margin: 0 0 12px; padding: 0; display: grid; gap: 8px; }
.dash-catalog li { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; }
.sort-list { list-style: none; margin: 8px 0 0; padding: 0; display: grid; gap: 6px; }
.sort-list li { display: flex; align-items: center; gap: 10px; padding: 6px 8px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface); }
.sort-list .sort-label { flex: 1; font-weight: 600; }
.sort-list .sort-main { display: none; }
.sort-list li.is-main { border-color: color-mix(in srgb, var(--brand) 45%, var(--line)); }
.sort-list li.is-main .sort-main { display: inline-flex; }
.chip-object { background: var(--info-bg); color: var(--info-ink); }

/* ---------- Fotos & Schloss ---------- */
.photo-grid { list-style: none; margin: 0 0 16px; padding: 0; display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 150px), 1fr)); }
.photo-item { display: flex; flex-direction: column; gap: 4px; position: relative; }
.photo-item img { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; border-radius: var(--radius-sm); border: 1px solid var(--line); background: var(--surface-2); display: block; }
.photo-item form { position: absolute; top: 4px; right: 4px; }
.photo-item form .btn { background: var(--surface); min-height: 34px; padding: 4px 8px; }
.photo-heic { display: flex; align-items: center; justify-content: center; gap: 6px; aspect-ratio: 4 / 3; border: 1px dashed var(--line); border-radius: var(--radius-sm); font-size: .85rem; }
.lock-fields { border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 12px 14px; margin: 0; display: grid; gap: 10px; }
.lock-fields legend { padding: 0 6px; }

.import-report { margin: 6px 0 12px; padding-left: 18px; max-height: 420px; overflow-y: auto; }
.import-fehler li { color: var(--err-ink); }
.import-hinweis li { color: var(--warn-ink); }

/* Türschild-Text */
.sign-field { border: 1px solid var(--line, #e3e3e3); border-radius: 12px; padding: 10px 12px 12px; margin: 0; display: grid; gap: 8px; }
.sign-field legend { padding: 0 4px; }

/* Netzwerkdosen */
.net-table .net-desc { white-space: normal; min-width: 140px; }

.probe-banner { position: sticky; top: 0; z-index: 1000; background: #b45309; color: #fff; font-weight: 700; text-align: center; padding: 6px 12px; font-size: .9rem; }
