/* =========================================================================
   Hausverwaltung – Design im Stil von edgarwessendorf.de:
   Source Sans Pro · Corporate-Blau #006fb7 · Tailwind-Grautöne ·
   helle, luftige, seriöse Optik ohne Emojis.
   ========================================================================= */
:root {
  --brand: #006fb7;
  --brand-dark: #004470;
  --brand-tint: #eaf3fb;   /* aktive Fläche / Icon-Kacheln */
  --brand-tint-2: #f4f9fd;
  --brand-soft: #bbdff6;

  --ink: #111827;        /* Überschriften / Zahlen */
  --body: #374151;       /* Fließtext */
  --muted: #6b7280;      /* sekundär */
  --faint: #9ca3af;      /* Icons in Ruhe */
  --line: #e9ecef;       /* Rahmen */
  --line-soft: #f1f3f5;  /* Trenner */
  --bg: #f6f7f9;
  --panel: #ffffff;

  --green: #15803d;  --green-bg: #eff8f1;
  --red:   #b91c1c;  --red-bg:   #fdf1f1;
  --amber: #b45309;  --amber-bg: #fdf6ec;

  --radius: 8px;
  --radius-lg: 12px;
  --shadow: 0 1px 2px rgba(17,24,39,.04), 0 1px 3px rgba(17,24,39,.06);
  --shadow-md: 0 4px 10px -2px rgba(17,24,39,.08), 0 2px 6px -2px rgba(17,24,39,.05);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; }
body {
  font-family: "Source Sans 3", "Source Sans Pro", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--body);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
h1, h2, h3 { color: var(--ink); }
svg { display: block; }

#app { display: grid; grid-template-columns: 264px 1fr; min-height: 100vh; }

/* ---------- Seitenleiste ---------- */
.sidebar {
  background: var(--panel);
  border-right: 1px solid var(--line);
  display: flex; flex-direction: column;
  padding: 22px 16px;
  position: sticky; top: 0; height: 100vh;
}
.brand { display: flex; align-items: center; gap: 12px; padding: 4px 6px 24px; }
.brand-mark {
  width: 40px; height: 40px; flex: none; display: grid; place-items: center;
  background: var(--brand); color: #fff; border-radius: 10px; box-shadow: var(--shadow-md);
}
.brand-mark svg { width: 23px; height: 23px; }
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-text strong { font-size: 16.5px; color: var(--ink); font-weight: 700; letter-spacing: -.2px; }
.brand-text small { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .07em; margin-top: 2px; }

.nav-label { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; color: var(--faint); padding: 6px 12px; }
#nav { display: flex; flex-direction: column; gap: 2px; }
#nav button {
  display: flex; align-items: center; gap: 12px;
  background: transparent; border: 0; color: var(--body);
  padding: 10px 12px; border-radius: var(--radius); font-size: 15px; font-weight: 500;
  cursor: pointer; text-align: left; font-family: inherit;
  transition: background .15s, color .15s;
}
#nav button svg { width: 20px; height: 20px; color: var(--faint); flex: none; transition: color .15s; }
#nav button:hover { background: var(--brand-tint-2); color: var(--ink); }
#nav button:hover svg { color: var(--brand); }
#nav button.active { background: var(--brand-tint); color: var(--brand-dark); font-weight: 600; box-shadow: inset 3px 0 0 var(--brand); }
#nav button.active svg { color: var(--brand); }
.sidebar-foot { margin-top: auto; font-size: 12px; color: var(--faint); padding: 10px 12px; border-top: 1px solid var(--line-soft); }

/* ---------- Inhalt ---------- */
.content { display: flex; flex-direction: column; min-width: 0; }
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 20px 36px; background: var(--panel); border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 5;
}
.topbar h1 { margin: 0; font-size: 23px; font-weight: 700; letter-spacing: -.4px; }
.topbar-sub { margin: 3px 0 0; font-size: 14px; color: var(--muted); }
#view { padding: 30px 36px; animation: rise .4s ease both; }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 7px;
  border: 1px solid var(--line); background: #fff; color: var(--body);
  padding: 9px 15px; border-radius: var(--radius); font-size: 14px; cursor: pointer; font-weight: 600; font-family: inherit;
  transition: background .15s, border-color .15s, box-shadow .15s, color .15s;
}
.btn svg { width: 17px; height: 17px; }
.btn:hover { background: var(--line-soft); }
.btn-primary { background: var(--brand); border-color: var(--brand); color: #fff; box-shadow: var(--shadow); }
.btn-primary:hover { background: var(--brand-dark); border-color: var(--brand-dark); }
.btn-sm { padding: 6px 11px; font-size: 13px; }
.btn-sm svg { width: 15px; height: 15px; }
.btn-icon { padding: 7px; color: var(--muted); }
.btn-icon:hover { color: var(--brand); border-color: var(--brand-soft); background: var(--brand-tint-2); }
.btn-danger { color: var(--red); border-color: #f0d6d6; }
.btn-danger:hover { background: var(--red-bg); color: var(--red); border-color: #e6bcbc; }
.icon-btn { background: none; border: 0; cursor: pointer; color: var(--muted); padding: 4px; line-height: 0; }
.icon-btn svg { width: 20px; height: 20px; }
.icon-btn:hover { color: var(--ink); }

/* ---------- KPI-Karten ---------- */
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(224px, 1fr)); gap: 18px; }
.kpi {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius-lg);
  padding: 20px 22px; box-shadow: var(--shadow); animation: rise .5s ease both;
  transition: box-shadow .18s, border-color .18s, transform .18s;
}
.kpi:hover { box-shadow: var(--shadow-md); border-color: var(--brand-soft); transform: translateY(-2px); }
.kpi-head { display: flex; align-items: center; gap: 11px; }
.kpi-icon { width: 40px; height: 40px; flex: none; display: grid; place-items: center; background: var(--brand-tint); color: var(--brand); border-radius: 10px; }
.kpi-icon svg { width: 21px; height: 21px; }
.kpi .label { color: var(--muted); font-size: 13.5px; font-weight: 600; }
.kpi .value { font-size: 31px; font-weight: 700; margin-top: 15px; letter-spacing: -.7px; color: var(--ink); line-height: 1.05; font-variant-numeric: tabular-nums; }
.kpi .sub { color: var(--muted); font-size: 13px; margin-top: 6px; }
.kpi.good .value { color: var(--green); }
.kpi.good .kpi-icon { background: var(--green-bg); color: var(--green); }
.kpi.warn .value { color: var(--amber); }
.kpi.warn .kpi-icon { background: var(--amber-bg); color: var(--amber); }

.section-title { font-size: 16px; font-weight: 700; margin: 34px 0 14px; color: var(--ink); }
#view > .section-title:first-child { margin-top: 0; }

/* ---------- Proaktive Aufgaben ---------- */
.tasks-head-row { display: flex; align-items: center; gap: 10px; margin: 34px 0 14px; }
#view > .tasks-head-row:first-child { margin-top: 0; }
.tasks-count { font-size: 12px; font-weight: 700; color: #fff; background: var(--brand); border-radius: 999px; padding: 1px 9px; }
.tasks-list { display: flex; flex-direction: column; }
.task { display: flex; align-items: center; gap: 13px; width: 100%; text-align: left; background: none; border: 0; border-bottom: 1px solid var(--line-soft); padding: 13px 18px; cursor: pointer; font-family: inherit; transition: background .14s; }
.task:last-child { border-bottom: 0; }
.task:hover { background: var(--brand-tint-2); }
.dot { width: 9px; height: 9px; border-radius: 50%; flex: none; }
.dot.red { background: var(--red); } .dot.amber { background: var(--amber); } .dot.blue { background: var(--brand); }
.task-body { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.task-body strong { font-size: 14.5px; font-weight: 600; color: var(--ink); }
.task-body small { font-size: 13px; color: var(--muted); margin-top: 1px; }
.task-cat { flex: none; }
.task-arrow { color: var(--faint); display: grid; place-items: center; flex: none; }
.task:hover .task-arrow { color: var(--brand); }
.tasks-more { padding: 11px 18px; font-size: 13px; color: var(--muted); background: #fbfcfd; }
.tasks-panel.done { display: flex; align-items: center; gap: 13px; background: var(--green-bg); border: 1px solid #cde9d5; border-radius: var(--radius-lg); padding: 16px 20px; margin-bottom: 8px; }
.tasks-panel.done .tasks-icon { width: 38px; height: 38px; display: grid; place-items: center; background: #fff; color: var(--green); border-radius: 50%; flex: none; }
.tasks-panel.done strong { display: block; color: var(--ink); }
.tasks-panel.done small { color: var(--muted); }

/* ---------- Werkzeugleiste (Abrechnung) ---------- */
.toolbar { display: flex; align-items: flex-end; gap: 16px; flex-wrap: wrap; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 16px 18px; box-shadow: var(--shadow); }
.field.inline { margin-bottom: 0; }
.field.inline label { margin-bottom: 5px; }
.field.inline select, .field.inline input { min-width: 200px; }
.hint { color: var(--muted); font-size: 13px; margin: 14px 2px 0; }
tfoot td { padding: 13px 20px; border-top: 1px solid var(--line); background: #fbfcfd; }

/* ---------- Aufklappbare Umlage-Herleitung ---------- */
tr.expandable { cursor: pointer; }
tr.expandable td:first-child { display: flex; align-items: center; gap: 8px; }
.chev { display: inline-grid; place-items: center; color: var(--faint); transition: transform .18s, color .18s; }
.chev.open { transform: rotate(90deg); color: var(--brand); }
tr.detail-row > td { padding: 0; background: var(--brand-tint-2); border-bottom: 1px solid var(--line); }
.detail-wrap { padding: 14px 20px 18px 44px; }
.detail-head { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin-bottom: 8px; }
.detail-table { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; font-size: 13.5px; }
.detail-table th { padding: 9px 14px; font-size: 11px; }
.detail-table td { padding: 9px 14px; }
.detail-table .formel { font-variant-numeric: tabular-nums; }
.detail-table tfoot td { background: #fbfcfd; padding: 10px 14px; }

/* ---------- Tabellen / Flächen ---------- */
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius-lg); box-shadow: var(--shadow); overflow: hidden; }
table { width: 100%; border-collapse: collapse; font-size: 14.5px; }
thead th { text-align: left; padding: 13px 20px; color: var(--muted); font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; border-bottom: 1px solid var(--line); background: #fbfcfd; }
tbody td { padding: 14px 20px; border-bottom: 1px solid var(--line-soft); color: var(--body); }
tbody td strong { color: var(--ink); font-weight: 600; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: var(--brand-tint-2); }
.row-actions { display: flex; gap: 8px; justify-content: flex-end; }
.muted { color: var(--muted); }
.num { text-align: right; font-variant-numeric: tabular-nums; }
th.num { text-align: right; }

/* ---------- Badges ---------- */
.badge { display: inline-block; padding: 3px 11px; border-radius: 999px; font-size: 12px; font-weight: 600; letter-spacing: .01em; }
.badge.green { background: var(--green-bg); color: var(--green); }
.badge.red   { background: var(--red-bg);   color: var(--red); }
.badge.amber { background: var(--amber-bg); color: var(--amber); }
.badge.gray  { background: var(--line-soft); color: var(--muted); }
.badge.blue  { background: var(--brand-tint); color: var(--brand-dark); }

/* ---------- Leerzustand ---------- */
.empty { text-align: center; padding: 64px 20px; color: var(--muted); }
.empty-icon { width: 60px; height: 60px; margin: 0 auto 14px; display: grid; place-items: center; background: var(--brand-tint); color: var(--brand); border-radius: 50%; }
.empty p { margin: 0; font-size: 15px; }

/* ---------- KI-Assistent ---------- */
.ki-status { display: flex; align-items: center; gap: 9px; padding: 12px 16px; border-radius: var(--radius); font-size: 13.5px; margin-bottom: 16px; line-height: 1.4; }
.ki-status .ki-ico { display: grid; place-items: center; flex: none; }
.ki-status.ok { background: var(--brand-tint); color: var(--brand-dark); }
.ki-status.warn { background: var(--amber-bg); color: var(--amber); }
.ki-status code { background: rgba(0,0,0,.06); padding: 1px 6px; border-radius: 4px; font-size: 12.5px; }
.ki-tabs { display: flex; gap: 4px; background: var(--line-soft); padding: 4px; border-radius: var(--radius); width: fit-content; margin-bottom: 18px; }
.ki-tabs button { border: 0; background: transparent; color: var(--muted); padding: 8px 16px; border-radius: 6px; font-size: 14px; font-weight: 600; cursor: pointer; font-family: inherit; }
.ki-tabs button:hover { color: var(--ink); }
.ki-tabs button.active { background: #fff; color: var(--brand-dark); box-shadow: var(--shadow); }
.ki-card { padding: 22px 24px; }
.ki-label { display: block; font-size: 13px; font-weight: 600; color: var(--ink); margin-bottom: 8px; }
.ki-textarea { width: 100%; padding: 12px 14px; border: 1px solid var(--line); border-radius: var(--radius); font-size: 14.5px; font-family: inherit; color: var(--ink); resize: vertical; }
.ki-textarea:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px rgba(0,111,183,.15); }
.ki-chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.chip { border: 1px solid var(--line); background: #fff; color: var(--muted); border-radius: 999px; padding: 6px 13px; font-size: 13px; cursor: pointer; font-family: inherit; transition: background .14s, color .14s, border-color .14s; }
.chip:hover { background: var(--brand-tint-2); color: var(--brand-dark); border-color: var(--brand-soft); }
.ki-actions { margin-top: 16px; }
.ki-or { display: flex; align-items: center; text-align: center; color: var(--faint); font-size: 12px; margin: 14px 0; }
.ki-or::before, .ki-or::after { content: ''; flex: 1; height: 1px; background: var(--line); }
.ki-or span { padding: 0 12px; }
.ki-file { display: block; font-size: 14px; color: var(--body); }
.ki-file::file-selector-button { border: 1px solid var(--line); background: #fff; color: var(--body); padding: 8px 13px; border-radius: var(--radius); font-family: inherit; font-weight: 600; font-size: 13px; margin-right: 12px; cursor: pointer; }
.ki-answer { margin-top: 18px; padding: 16px 18px; background: var(--brand-tint-2); border: 1px solid var(--line); border-radius: var(--radius); font-size: 15px; line-height: 1.6; color: var(--ink); }
.ki-loading { margin-top: 18px; display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 14px; }
.spinner { width: 16px; height: 16px; border: 2px solid var(--line); border-top-color: var(--brand); border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.ki-letter-head { display: flex; align-items: center; justify-content: space-between; margin: 18px 0 0; font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.ki-letter { margin: 8px 0 0; padding: 20px 22px; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); font-family: inherit; font-size: 14.5px; line-height: 1.65; color: var(--ink); white-space: pre-wrap; }
.ki-beleg-result { margin-top: 18px; }
.ki-beleg-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 14px; padding: 16px 18px; background: var(--brand-tint-2); border: 1px solid var(--line); border-radius: var(--radius); }
.ki-beleg-grid span { display: block; font-size: 12px; color: var(--muted); margin-bottom: 3px; }
.ki-beleg-grid strong { font-size: 15.5px; color: var(--ink); }
.ki-beleg-note { color: var(--muted); font-size: 13px; margin: 12px 2px 16px; }

/* ---------- Dialog ---------- */
.modal-backdrop { position: fixed; inset: 0; background: rgba(17,24,39,.5); display: flex; align-items: flex-start; justify-content: center; padding: 64px 20px; z-index: 50; animation: fade .15s ease; }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.modal { background: #fff; border-radius: var(--radius-lg); width: 100%; max-width: 520px; box-shadow: 0 24px 60px rgba(17,24,39,.3); animation: pop .18s ease; display: flex; flex-direction: column; max-height: calc(100vh - 128px); }
@keyframes pop { from { opacity: 0; transform: translateY(-10px) scale(.98); } to { opacity: 1; transform: none; } }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 19px 24px; border-bottom: 1px solid var(--line); flex: none; }
.modal-head h2 { margin: 0; font-size: 18px; font-weight: 700; }
#modalForm { padding: 22px 24px; overflow-y: auto; }
.field { margin-bottom: 16px; }
.field label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; color: var(--ink); }
.field input, .field select { width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--radius); font-size: 14.5px; font-family: inherit; background: #fff; color: var(--ink); transition: border-color .15s, box-shadow .15s; }
.field input:focus, .field select:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px rgba(0,111,183,.15); }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 8px; }

/* ---------- Toast ---------- */
.toast { position: fixed; bottom: 26px; left: 50%; transform: translateX(-50%); background: var(--ink); color: #fff; padding: 12px 20px; border-radius: var(--radius); font-size: 14.5px; box-shadow: var(--shadow-md); z-index: 60; }

/* ---------- Rechtssicherheit ---------- */
.ampel-row { margin: 0 0 16px; }
.ampel { display: inline-flex; align-items: center; gap: 7px; font-size: 13.5px; font-weight: 600; padding: 7px 13px; border-radius: 999px; }
.ampel svg { display: block; }
.ampel.green { background: var(--green-bg); color: var(--green); }
.ampel.amber { background: var(--amber-bg); color: var(--amber); }
.ampel.red { background: var(--red-bg); color: var(--red); }
.recht-warn { display: flex; gap: 12px; align-items: flex-start; background: var(--red-bg); border: 1px solid #eecccc; color: var(--red); border-radius: var(--radius-lg); padding: 14px 18px; margin: 0 0 18px; font-size: 14px; line-height: 1.5; }
.recht-warn strong { color: var(--red); }
.recht-warn .ki-ico { flex: none; margin-top: 1px; }
.recht-info { display: flex; gap: 12px; align-items: flex-start; background: var(--brand-tint-2); border: 1px solid var(--line); color: var(--body); border-radius: var(--radius-lg); padding: 14px 18px; margin: 0 0 8px; font-size: 14px; line-height: 1.5; }
.recht-info .ki-ico { flex: none; color: var(--brand); margin-top: 1px; }
tr.row-excluded td { background: #fdf6f6; }
tr.row-excluded td strong { text-decoration: line-through; text-decoration-color: var(--red); }
.mh-cur { font-size: 14px; color: var(--body); margin-bottom: 16px; }
.mh-checks { list-style: none; margin: 4px 0 0; padding: 0; display: flex; flex-direction: column; gap: 9px; }
.mh-checks li { display: flex; align-items: flex-start; gap: 9px; font-size: 14px; color: var(--body); }
.mh-checks li svg { flex: none; margin-top: 1px; }
.mh-checks li.ok svg { color: var(--green); }
.mh-checks li.bad svg { color: var(--red); }
.mh-verdict { margin-top: 14px; padding: 11px 15px; border-radius: var(--radius); font-weight: 600; font-size: 14.5px; }
.mh-verdict.ok { background: var(--green-bg); color: var(--green); }
.mh-verdict.bad { background: var(--red-bg); color: var(--red); }

/* ---------- Portal-Verwaltung ---------- */
.portal-link { display: flex; align-items: center; gap: 8px; }
.portal-link input { flex: 1; min-width: 220px; padding: 7px 10px; border: 1px solid var(--line); border-radius: var(--radius); font-size: 12.5px; color: var(--muted); background: var(--line-soft); font-family: inherit; }

/* ---------- Mieterportal (öffentlich) ---------- */
.portal-body { background: var(--bg); }
.portal-top { background: #fff; border-bottom: 1px solid var(--line); padding: 16px 24px; position: sticky; top: 0; z-index: 5; }
.portal-brand { display: flex; align-items: center; gap: 12px; max-width: 920px; margin: 0 auto; }
.portal-brand .brand-mark { width: 38px; height: 38px; display: grid; place-items: center; background: var(--brand); color: #fff; border-radius: 10px; }
.portal-brand .brand-mark svg { width: 22px; height: 22px; }
.portal-brand strong { display: block; font-size: 16px; color: var(--ink); }
.portal-brand small { font-size: 11px; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); }
.portal-main { max-width: 920px; margin: 0 auto; padding: 30px 24px 60px; }
.portal-loading { color: var(--muted); padding: 40px; text-align: center; }
.portal-hi { font-size: 26px; margin: 6px 0 2px; letter-spacing: -.4px; }
.portal-sub { color: var(--muted); margin: 0 0 24px; font-size: 15px; }
.portal-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; margin-bottom: 18px; }
.portal-card { background: #fff; border: 1px solid var(--line); border-radius: var(--radius-lg); box-shadow: var(--shadow); padding: 22px 24px; }
.portal-card h2 { font-size: 16px; margin: 0 0 16px; }
.portal-dl { margin: 0; display: flex; flex-direction: column; gap: 10px; }
.portal-dl > div { display: flex; justify-content: space-between; gap: 16px; font-size: 14.5px; border-bottom: 1px solid var(--line-soft); padding-bottom: 10px; }
.portal-dl > div:last-child { border-bottom: 0; padding-bottom: 0; }
.portal-dl dt { color: var(--muted); margin: 0; }
.portal-dl dd { margin: 0; color: var(--ink); text-align: right; }
.portal-table { width: 100%; border-collapse: collapse; font-size: 14.5px; }
.portal-table td { padding: 10px 4px; border-bottom: 1px solid var(--line-soft); }
.portal-table tr:last-child td { border-bottom: 0; }
.portal-meld { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line-soft); }
.portal-meld:last-child { border-bottom: 0; }
.portal-meld .muted { font-size: 13px; margin-top: 2px; }
.portal-card .field { margin-bottom: 14px; }
.portal-card .field label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; color: var(--ink); }
.portal-card .field input, .portal-card .field select, .portal-card .field textarea { width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--radius); font-size: 14.5px; font-family: inherit; color: var(--ink); }
.portal-card .field input:focus, .portal-card .field select:focus, .portal-card .field textarea:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px rgba(0,111,183,.15); }
@media (max-width: 720px) { .portal-grid { grid-template-columns: 1fr; } }

/* ---------- Export & API ---------- */
.export-quick { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 14px; margin-bottom: 8px; }
.export-big { display: flex; align-items: center; gap: 13px; text-align: left; background: #fff; border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 16px 18px; cursor: pointer; font-family: inherit; box-shadow: var(--shadow); transition: box-shadow .18s, border-color .18s, transform .18s; }
.export-big:hover { box-shadow: var(--shadow-md); border-color: var(--brand-soft); transform: translateY(-2px); }
.export-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; }
.export-item { display: flex; align-items: center; gap: 12px; text-align: left; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 13px 15px; cursor: pointer; font-family: inherit; transition: background .15s, border-color .15s; }
.export-item:hover { background: var(--brand-tint-2); border-color: var(--brand-soft); }
.export-ic { width: 38px; height: 38px; flex: none; display: grid; place-items: center; background: var(--line-soft); color: var(--muted); border-radius: 9px; }
.export-ic.blue { background: var(--brand-tint); color: var(--brand); }
.export-body { display: flex; flex-direction: column; min-width: 0; }
.export-body strong { font-size: 14.5px; color: var(--ink); }
.export-body small { font-size: 12.5px; color: var(--muted); margin-top: 1px; }
.panel code { font-size: 12.5px; color: var(--brand-dark); }

/* ---------- Login ---------- */
#loginOverlay { position: fixed; inset: 0; background: linear-gradient(160deg, #eef4fb 0%, #f6f7f9 60%); display: flex; align-items: center; justify-content: center; padding: 24px; z-index: 100; }
.login-card { background: #fff; border: 1px solid var(--line); border-radius: 16px; box-shadow: 0 20px 55px rgba(17,24,39,.14); width: 100%; max-width: 400px; padding: 32px 34px; }
.login-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 22px; }
.login-brand .brand-mark { width: 40px; height: 40px; display: grid; place-items: center; background: var(--brand); color: #fff; border-radius: 10px; }
.login-brand .brand-mark svg { width: 23px; height: 23px; }
.login-brand strong { display: block; font-size: 16.5px; color: var(--ink); }
.login-brand small { font-size: 11px; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); }
.login-card h1 { font-size: 20px; margin: 0 0 20px; }
.login-card .field { margin-bottom: 15px; }
.login-card label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; color: var(--ink); }
.login-card input { width: 100%; padding: 11px 13px; border: 1px solid var(--line); border-radius: var(--radius); font-size: 15px; font-family: inherit; color: var(--ink); }
.login-card input:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px rgba(0,111,183,.15); }
.login-err { background: var(--red-bg); color: var(--red); font-size: 13.5px; padding: 9px 12px; border-radius: var(--radius); margin-bottom: 14px; }
.login-hint { margin: 18px 0 0; font-size: 12px; color: var(--muted); text-align: center; line-height: 1.5; }

/* ---------- Benutzer-Box in der Seitenleiste ---------- */
.user-box { padding: 12px; border-top: 1px solid var(--line-soft); margin-top: auto; }
.user-box .ub-name { font-size: 14px; font-weight: 600; color: var(--ink); }
.user-box .ub-role { font-size: 12px; color: var(--muted); margin: 1px 0 10px; }
.user-box .btn { width: 100%; justify-content: center; }
.user-box + .sidebar-foot { margin-top: 0; }

/* ---------- Rechte-Auswahl im Benutzerdialog ---------- */
.mod-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 14px; }
.mod-check { display: flex; align-items: center; gap: 8px; font-size: 14px; color: var(--body); cursor: pointer; }
.mod-check input { width: 16px; height: 16px; accent-color: var(--brand); }
.mod-flags { display: flex; flex-direction: column; gap: 10px; margin: 16px 0 4px; padding-top: 14px; border-top: 1px solid var(--line-soft); }

/* ---------- Aufgaben-Board (Portal) ---------- */
.board-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.board-head .ki-tabs { margin-bottom: 0; }

/* ---------- Rote Zähler-Badges ---------- */
#nav button .nav-text { flex: 1; }
.nav-badge { flex: none; min-width: 20px; height: 20px; padding: 0 6px; display: inline-flex; align-items: center; justify-content: center; background: var(--red); color: #fff; border-radius: 999px; font-size: 12px; font-weight: 700; line-height: 1; }
.count-badge { min-width: 24px; height: 24px; padding: 0 8px; display: inline-flex; align-items: center; justify-content: center; border-radius: 999px; font-size: 13px; font-weight: 700; color: #fff; }
.count-badge.red { background: var(--red); }

/* ---------- Status-Auswahl im Board ---------- */
.status-select { border: 1px solid var(--line); border-radius: var(--radius); padding: 6px 26px 6px 10px; font-size: 13px; font-weight: 600; font-family: inherit; cursor: pointer; background: #fff; color: var(--body); appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2.5' stroke-linecap='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 8px center; }
.status-select:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px rgba(0,111,183,.15); }
.status-select.st-offen { color: var(--red); border-color: #e6bcbc; background-color: var(--red-bg); }
.status-select.st-inBearbeitung { color: var(--amber); border-color: #e6d3ac; background-color: var(--amber-bg); }
.status-select.st-erledigt { color: var(--green); border-color: #cde9d5; background-color: var(--green-bg); }

/* ---------- Objekt-Karten ---------- */
.obj-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 20px; }
.obj-card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius-lg); overflow: hidden; box-shadow: var(--shadow); transition: box-shadow .18s, transform .18s; }
.obj-card:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); }
.obj-img { height: 150px; background-size: cover; background-position: center; background-color: var(--brand-tint); }
.obj-body { padding: 15px 17px; position: relative; }
.obj-name { font-size: 16px; font-weight: 700; color: var(--ink); }
.obj-addr { font-size: 13.5px; color: var(--muted); margin: 2px 0 12px; }
.obj-meta { display: flex; flex-wrap: wrap; gap: 6px; }
.obj-actions { position: absolute; top: 13px; right: 14px; display: flex; gap: 6px; }
.obj-card .obj-img + .obj-body .obj-actions { top: -137px; }

/* ---------- Bild-Upload im Formular ---------- */
.bild-upload { display: flex; gap: 14px; align-items: flex-start; }
.bild-vorschau { width: 130px; height: 78px; object-fit: cover; border-radius: var(--radius); border: 1px solid var(--line); background: var(--brand-tint); flex: none; }
.bild-upload > div { flex: 1; }

/* ---------- Inline-Einheiten im Objektformular ---------- */
.unit-row { display: grid; grid-template-columns: 1.4fr 1fr .7fr .8fr 1fr auto; gap: 6px; margin-bottom: 7px; }
.unit-row input { padding: 8px 9px; border: 1px solid var(--line); border-radius: var(--radius); font-size: 13.5px; font-family: inherit; width: 100%; min-width: 0; }
.unit-row input:focus { outline: none; border-color: var(--brand); }

/* ---------- Einheiten-Zeilen & Detail ---------- */
.clickable-row { cursor: pointer; }
.detail-hero { height: 130px; border-radius: var(--radius); background-size: cover; background-position: center; background-color: var(--brand-tint); margin-bottom: 16px; }
.detail-dl { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 20px; margin: 0 0 8px; }
.detail-dl > div { display: flex; justify-content: space-between; gap: 12px; border-bottom: 1px solid var(--line-soft); padding-bottom: 8px; font-size: 14px; }
.detail-dl dt { color: var(--muted); margin: 0; }
.detail-dl dd { margin: 0; color: var(--ink); text-align: right; }
.detail-doc { margin: 12px 0 0; }
.detail-vacant { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; background: var(--amber-bg); color: var(--amber); border-radius: var(--radius); padding: 12px 15px; font-size: 14px; }
.detail-vacant svg { flex: none; }

/* ---------- Kopfleiste rechts & Suche ---------- */
.topbar-right { display: flex; align-items: center; gap: 14px; }
.search-wrap { position: relative; }
.search-ic { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--faint); display: grid; place-items: center; pointer-events: none; }
.search-ic svg { width: 17px; height: 17px; }
.global-search { width: 260px; padding: 9px 12px 9px 34px; border: 1px solid var(--line); border-radius: var(--radius); font-size: 14px; font-family: inherit; color: var(--ink); background: var(--bg); transition: width .2s, box-shadow .15s, border-color .15s; }
.global-search:focus { outline: none; width: 320px; background: #fff; border-color: var(--brand); box-shadow: 0 0 0 3px rgba(0,111,183,.13); }
.search-results { position: absolute; top: calc(100% + 6px); right: 0; width: 380px; max-width: 90vw; max-height: 60vh; overflow-y: auto; background: #fff; border: 1px solid var(--line); border-radius: var(--radius-lg); box-shadow: var(--shadow-md); z-index: 30; padding: 6px; }
.search-item { display: flex; align-items: center; gap: 12px; width: 100%; text-align: left; background: none; border: 0; padding: 9px 10px; border-radius: var(--radius); cursor: pointer; font-family: inherit; }
.search-item:hover { background: var(--brand-tint-2); }
.search-type { flex: none; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--brand); background: var(--brand-tint); padding: 3px 8px; border-radius: 6px; min-width: 62px; text-align: center; }
.search-lbl { display: flex; flex-direction: column; min-width: 0; }
.search-lbl strong { font-size: 14px; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.search-lbl small { font-size: 12.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.search-empty { padding: 16px; color: var(--muted); font-size: 14px; text-align: center; }
@media (max-width: 900px) { .global-search { width: 150px; } .global-search:focus { width: 200px; } }

/* ---------- Mini-Listen in Detail-Dialogen ---------- */
.mini-list { display: flex; flex-direction: column; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.mini-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; width: 100%; text-align: left; background: #fff; border: 0; border-bottom: 1px solid var(--line-soft); padding: 11px 14px; cursor: pointer; font-family: inherit; transition: background .14s; }
.mini-row:last-child { border-bottom: 0; }
.mini-row:hover { background: var(--brand-tint-2); }
.mini-row span:first-child { display: flex; flex-direction: column; min-width: 0; }
.mini-row strong { font-size: 14px; color: var(--ink); }
.mini-row small { font-size: 12.5px; color: var(--muted); margin-top: 1px; }
.link-inline { color: var(--brand); cursor: pointer; text-decoration: underline; text-underline-offset: 2px; }
.link-inline:hover { color: var(--brand-dark); }

/* ---------- Vertrags-Verlinkung in Details ---------- */
.mini-right { display: flex; align-items: center; gap: 9px; color: var(--faint); flex: none; }
.mini-right svg { width: 16px; height: 16px; }
.detail-doc { display: flex; gap: 10px; flex-wrap: wrap; margin: 12px 0 0; }

/* ---------- Inline „Neuer Mieter" im Vertragsformular ---------- */
.neuer-mieter { border: 1px dashed var(--brand-soft); border-radius: var(--radius); padding: 14px 14px 0; margin: -4px 0 16px; background: var(--brand-tint-2); }
