:root {
  --ink: #15181E; --muted: #5B6270; --line: #E3E6EB; --line2: #EEF0F3; --bg: #F4F5F7; --surface: #FFFFFF;
  --accent: #1D4ED8; --accent-dark: #1E40AF; --accent-soft: #E8EEFC; --accent-ink: #1E3A8A;
  --light: #7C9BF2; --amber: #C2620F; --warn-bg: #FDF0E1; --warn-ink: #8A3D07; --ok-bg: #E3F4E8; --ok-ink: #14612F;
  --danger: #B42318; --side: #15181E;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); font: 15px/1.5 var(--font); }
a { color: var(--accent); } a:hover { color: var(--accent-ink); }
:focus-visible { outline: 3px solid var(--light); outline-offset: 2px; }
h1 { font-size: 28px; line-height: 1.2; margin: 0; font-weight: 700; letter-spacing: -0.01em; }
h2 { font-size: 18px; margin: 0; font-weight: 650; }
.sub { color: var(--muted); margin: 4px 0 0; font-size: 14px; }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }

.shell { min-height: 100vh; display: flex; flex-wrap: wrap; }
.side { flex: 1 1 230px; max-width: 100%; background: var(--side); padding: 22px 14px; display: flex; flex-direction: column; gap: 4px; }
.brand { display: flex; align-items: center; gap: 10px; padding: 0 10px 20px; color: #fff; font-weight: 650; font-size: 17px; }
.nav { display: block; width: 100%; text-align: left; min-height: 44px; padding: 10px 14px; border: 0; border-radius: 8px; background: transparent; color: #C9CED8; font: 500 14px var(--font); cursor: pointer; text-decoration: none; }
.nav:hover { background: #262B35; color: #fff; }
.nav.on { background: #fff; color: var(--ink); }
.who { margin-top: auto; padding: 20px 10px 0; font-size: 13px; color: #9AA1AE; }
.who strong { color: #fff; font-weight: 500; }
.who button { margin-top: 8px; background: none; border: 0; color: #C9CED8; padding: 0; cursor: pointer; font: inherit; text-decoration: underline; }
main { flex: 999 1 560px; min-width: 0; padding: 28px clamp(16px, 3vw, 40px) 56px; }
.head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 12px; margin-bottom: 22px; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; }

.grid { display: grid; gap: 16px; }
.g4 { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.g2 { grid-template-columns: repeat(auto-fit, minmax(330px, 1fr)); }
.gap { margin-top: 16px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 20px; min-width: 0; }
.card.flush { padding: 6px 12px; }
.kpi .label { font-size: 13px; color: var(--muted); margin: 0; }
.kpi .value { font-size: 28px; font-weight: 650; margin: 4px 0 0; font-variant-numeric: tabular-nums; letter-spacing: -0.01em; }
.kpi .hint { font-size: 13px; color: var(--muted); margin: 4px 0 0; }
.cardhead { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; }

.stack { display: flex; height: 14px; border-radius: 7px; overflow: hidden; margin: 18px 0 14px; background: var(--line2); }
.legend { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-top: 1px solid var(--line2); font-size: 14px; }
.dot { width: 10px; height: 10px; border-radius: 3px; flex: none; }
.barrow { margin-top: 14px; }
.barrow .top { display: flex; justify-content: space-between; gap: 10px; font-size: 14px; }
.track { height: 8px; border-radius: 4px; background: var(--line2); margin-top: 6px; overflow: hidden; }
.track > div { height: 100%; background: var(--accent); border-radius: 4px; }
.list .row { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-top: 1px solid var(--line2); }
.list .row:first-child { border-top: 0; }
.row .main { flex: 1; min-width: 0; }
.row .t { font-weight: 500; font-size: 14px; }
.row .s { font-size: 13px; color: var(--muted); }
.date { min-width: 92px; font-weight: 650; font-size: 14px; font-variant-numeric: tabular-nums; }

.tablewrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: left; font-weight: 500; font-size: 13px; color: var(--muted); padding: 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 12px 10px; border-bottom: 1px solid var(--line2); vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
td .s { font-size: 12px; color: var(--muted); }

.pill { display: inline-block; padding: 3px 9px; border-radius: 999px; font-size: 12px; font-weight: 500; background: var(--line2); color: #3A404C; white-space: nowrap; }
.pill.warn { background: var(--warn-bg); color: var(--warn-ink); }
.pill.ok { background: var(--ok-bg); color: var(--ok-ink); }
.pill.blue { background: var(--accent-soft); color: var(--accent-ink); }

.btn, .btnp, .btnd { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 44px; padding: 0 16px; border-radius: 8px; font: 500 14px var(--font); cursor: pointer; text-decoration: none; white-space: nowrap; }
.btn { border: 1px solid #D4D8DF; background: #fff; color: var(--ink); }
.btn:hover { background: var(--bg); color: var(--ink); }
.btnp { border: 0; background: var(--accent); color: #fff; }
.btnp:hover { background: var(--accent-dark); color: #fff; }
.btnd { border: 1px solid #F1C4BF; background: #fff; color: var(--danger); }
.btnd:hover { background: #FEF3F2; }
.btn.on { background: var(--ink); color: #fff; border-color: var(--ink); }
.link { all: unset; cursor: pointer; color: var(--accent); font-weight: 500; }
.link:hover { text-decoration: underline; }
.mini { min-height: 36px; padding: 0 12px; font-size: 13px; }

.facts { margin: 0; }
.facts div { display: flex; justify-content: space-between; gap: 12px; padding: 10px 0; border-top: 1px solid var(--line2); font-size: 14px; }
.facts div:first-child { border-top: 0; }
.facts dt { color: var(--muted); } .facts dd { margin: 0; text-align: right; }
.tree div { padding: 5px 0; font-size: 14px; display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }

.empty { text-align: center; padding: 48px 20px; }
.empty p { color: var(--muted); max-width: 46ch; margin: 8px auto 18px; }

/* Formulare */
form .field { display: block; margin-top: 14px; font-size: 13px; color: var(--muted); }
form .field:first-of-type { margin-top: 0; }
input, select, textarea { display: block; width: 100%; min-height: 44px; margin-top: 6px; border: 1px solid #D4D8DF; border-radius: 8px; padding: 9px 12px; font: 400 15px var(--font); color: var(--ink); background: #fff; }
textarea { min-height: 88px; resize: vertical; }
input[type=file] { padding: 9px; }
.cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 0 14px; }
.cols .field:first-of-type { margin-top: 14px; }
.cols:first-child .field { margin-top: 0; }
.err { color: var(--danger); font-size: 14px; margin: 12px 0 0; min-height: 1px; }
.formfoot { display: flex; justify-content: flex-end; gap: 8px; margin-top: 22px; }

dialog { border: 0; border-radius: 14px; padding: 0; width: min(620px, calc(100vw - 24px)); max-height: calc(100vh - 32px); box-shadow: 0 24px 60px rgba(21, 24, 30, .25); }
dialog::backdrop { background: rgba(21, 24, 30, .45); }
dialog .dhead { display: flex; justify-content: space-between; align-items: center; padding: 18px 22px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: #fff; z-index: 1; }
dialog .dbody { padding: 20px 22px 22px; }
.x { all: unset; cursor: pointer; width: 36px; height: 36px; display: grid; place-items: center; border-radius: 8px; font-size: 22px; color: var(--muted); }
.x:hover { background: var(--bg); }

.auth { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.auth .card { width: min(420px, 100%); padding: 28px; }
.auth h1 { font-size: 24px; margin: 14px 0 4px; }

#toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: var(--ink); color: #fff; padding: 12px 18px; border-radius: 10px; font-size: 14px; opacity: 0; pointer-events: none; transition: opacity .2s; max-width: calc(100vw - 32px); }
#toast.show { opacity: 1; }
.qr { display: block; width: 200px; height: 200px; margin: 12px 0; }
code { background: var(--line2); padding: 2px 6px; border-radius: 6px; font-size: 13px; word-break: break-all; }
.note { font-size: 13px; color: var(--muted); margin: 12px 4px 0; }
@media (prefers-reduced-motion: reduce) { #toast { transition: none; } }
@media (max-width: 760px) {
  .side { flex: 1 1 100%; flex-direction: row; align-items: center; overflow-x: auto; padding: 10px; gap: 4px; position: sticky; top: 0; z-index: 5; }
  .brand { padding: 0 8px 0 4px; font-size: 0; gap: 0; }
  .nav { width: auto; white-space: nowrap; flex: none; }
  .who { margin: 0 0 0 8px; padding: 0; white-space: nowrap; font-size: 0; }
  .who button { margin: 0; font-size: 14px; }
  main { padding-top: 20px; }
  h1 { font-size: 24px; }
}

.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 10px; margin-top: 10px; }
.gallery a { display: block; aspect-ratio: 4 / 3; border-radius: 10px; overflow: hidden; background: #EEF0F3; }
.gallery img { width: 100%; height: 100%; object-fit: cover; display: block; }
.pill.err { background: #FEF3F2; color: var(--danger); }

.docbar { display: flex; gap: 12px; align-items: center; justify-content: space-between; flex-wrap: wrap; margin: 10px 0 4px; }
.docbar .crumbs { font-size: 14px; display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.docbar .crumbs a { color: var(--accent-ink, #1D4ED8); text-decoration: none; }
.docbar .docsearch { min-height: 36px; max-width: 260px; padding: 0 12px; }
.row.folder:hover { background: #F6F8FD; }
.cardhead .actions { display: flex; gap: 8px; }

/* 1.7.0 Miniaturansichten & Kacheln */
.rthumb { flex: none; width: 44px; height: 44px; border-radius: 8px; overflow: hidden; background: #EEF0F3; display: flex; align-items: center; justify-content: center; border: 1px solid var(--line); text-decoration: none; }
.rthumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.ext { font-size: 10px; font-weight: 600; letter-spacing: .04em; color: #5B6270; }
.pdfthumb .ext { color: #C2410C; }
.viewsw { display: flex; gap: 4px; }
.viewsw .btn.on { background: #E8EEFC; border-color: #3B5BDB; color: #1D3BB3; }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 14px; margin-top: 10px; }
.tile { position: relative; display: flex; flex-direction: column; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; background: var(--surface); transition: box-shadow .15s, border-color .15s; }
.tile:hover { border-color: #C9CFDA; box-shadow: 0 4px 14px rgba(21, 24, 30, .08); }
.tthumb { display: flex; align-items: center; justify-content: center; aspect-ratio: 4 / 3; background: #EEF0F3; overflow: hidden; text-decoration: none; position: relative; }
.tthumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.tthumb.pdfthumb img { object-fit: cover; object-position: top; }
.tthumb .ext { font-size: 15px; }
.fthumb { background: #F1F4FB; }
.fthumb img { opacity: .55; }
.fbadge { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; }
.fbadge svg { width: 46px; height: 46px; filter: drop-shadow(0 1px 2px rgba(0,0,0,.15)); }
.tcap { padding: 8px 10px 4px; min-width: 0; }
.tcap .t { font-weight: 500; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tcap .s { font-size: 12px; color: var(--muted); }
.tile { padding-bottom: 0; }
.tcap { padding-right: 76px; }
.tact { position: absolute; right: 8px; bottom: 9px; display: flex; gap: 4px; }
.ibtn { width: 30px; height: 30px; border: 1px solid var(--line); border-radius: 8px; background: #fff; color: var(--muted); font-size: 15px; line-height: 1; display: inline-flex; align-items: center; justify-content: center; cursor: pointer; text-decoration: none; padding: 0; }
.ibtn:hover { border-color: #3B5BDB; color: #1D3BB3; background: #F3F6FE; }
.ibtn.del:hover { border-color: #DC2626; color: #B91C1C; background: #FEF2F2; }
.tcap { padding-bottom: 10px; }
.tact:empty { display: none; }
.tile > .pill { position: absolute; top: 8px; right: 8px; }
.gallery a { cursor: zoom-in; }
.viewer { position: fixed; inset: 0; z-index: 1000; background: rgba(12, 14, 18, .94); display: flex; align-items: center; justify-content: center; }
.viewer .vtop { position: absolute; top: 0; left: 0; right: 0; display: flex; gap: 10px; align-items: center; padding: 12px 16px; color: #fff; }
.viewer .vtitle { flex: 1; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.viewer .vcount { color: #AEB4BF; font-size: 13px; }
.viewer .vstage { position: absolute; inset: 56px 64px 24px; display: flex; align-items: center; justify-content: center; }
.viewer .vstage img { max-width: 100%; max-height: 100%; object-fit: contain; border-radius: 4px; box-shadow: 0 10px 40px rgba(0,0,0,.5); }
.viewer .vnav { position: absolute; top: 50%; transform: translateY(-50%); width: 48px; height: 64px; border: 0; border-radius: 10px; background: rgba(255,255,255,.1); color: #fff; font-size: 34px; cursor: pointer; }
.viewer .vnav:hover { background: rgba(255,255,255,.2); }
.viewer .vprev { left: 8px; } .viewer .vnext { right: 8px; }
@media (max-width: 640px) { .tiles { grid-template-columns: repeat(2, 1fr); gap: 10px; } .viewer .vstage { inset: 56px 8px 16px; } .viewer .vnav { width: 40px; height: 52px; } .docbar { flex-wrap: wrap; } }

/* 1.7.1 Mieten je Rechtsträger */
.rentent { padding: 6px 0 10px; border-top: 1px solid var(--line2); }
.rentent:first-of-type { border-top: 0; }
.rentobj { display: flex; justify-content: space-between; gap: 12px; padding: 4px 0 0 14px; font-size: 13px; color: var(--muted); }
.rentobj a { color: var(--ink); text-decoration: none; }
.rentobj a:hover { text-decoration: underline; }

/* 1.8.0 Postfach */
.nbadge { display: inline-block; min-width: 20px; padding: 1px 6px; margin-left: 8px; border-radius: 10px; background: #DC2626; color: #fff; font-size: 12px; font-weight: 600; text-align: center; line-height: 18px; }
.nav.on .nbadge { background: #DC2626; color: #fff; }
.drop { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; min-height: 120px; padding: 20px; border: 2px dashed #C9CFDA; border-radius: 12px; background: #F8F9FB; cursor: pointer; text-align: center; transition: background .15s, border-color .15s; }
.drop:hover, .drop.over { border-color: #3B5BDB; background: #F1F4FE; }
.drop .s { font-size: 13px; color: var(--muted); }
.ibhead { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.ibhead .main { flex: 1; min-width: 200px; }
.ibhead .t { font-weight: 600; word-break: break-word; }
.ibhead .s { font-size: 13px; color: var(--muted); }
.ibthumb { width: 56px; height: 56px; }
.ibsum { margin: 12px 0 0; padding: 10px 12px; background: #F6F8FD; border-radius: 8px; font-size: 14px; line-height: 1.5; }
.ibsum .s, .ibupd .s { color: var(--muted); font-size: 12px; }
.ibform { margin-top: 12px; }
.ibupds { margin: 6px 0 4px; padding: 10px 12px; border: 1px solid #C7D2FE; background: #EEF2FF; border-radius: 8px; }
.ibupds > .t { font-weight: 600; font-size: 13px; margin-bottom: 6px; }
.ibupd { display: flex; gap: 10px; align-items: flex-start; padding: 4px 0; font-size: 14px; cursor: pointer; }
.ibupd input { width: 18px; min-height: 18px; margin-top: 2px; }
.ibupd .s { display: block; }
.spin { display: inline-block; width: 10px; height: 10px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: fcspin .8s linear infinite; vertical-align: -1px; }
@keyframes fcspin { to { transform: rotate(360deg); } }
.secthead { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 22px 0 6px; }
.secthead h2 { margin: 0; }
.ibdone { border-color: #BBF7D0; }
.ibwhere { margin-top: 10px; font-size: 14px; }
.ibset summary { cursor: pointer; list-style: none; font-size: 14px; }
.ibset summary::-webkit-details-marker { display: none; }
.ibset summary .s { color: var(--accent-ink, #1D4ED8); margin-left: 6px; font-size: 13px; }

/* 1.9.0 Kostenstellen */
.mini-kpi { display: flex; flex-direction: column; gap: 2px; padding: 12px 14px; border: 1px solid var(--line2); border-radius: 10px; background: #FAFBFC; }
.mini-kpi span { font-size: 12px; color: var(--muted); }
.mini-kpi strong { font-size: 20px; font-variant-numeric: tabular-nums; }
.mini-kpi em { font-style: normal; font-size: 12px; color: var(--muted); }
.neg { color: var(--danger, #B42318); }
.costlines input, .costlines select { min-height: 34px; padding: 4px 8px; font-size: 13px; }
.costlines td.num input { width: 96px; text-align: right; }
.costlines input[type=checkbox] { width: 18px; min-height: 18px; }
.ibcosts .costcat { min-height: 30px; padding: 2px 6px; font-size: 13px; width: auto; margin-right: 6px; }
.ibcosts .ibupd > span { display: block; }
.btn.on { background: #E8EEFC; border-color: #3B5BDB; color: #1D3BB3; }

/* 1.10.0 Darlehen */
.loan + .loan { border-top: 1px solid var(--line2); margin-top: 14px; padding-top: 4px; }
.plan { margin-top: 8px; }
.plan summary { cursor: pointer; color: var(--accent-ink, #1D4ED8); font-size: 14px; }
.plan tr.paid td { color: var(--muted); }

/* 1.12.0 Privates */
.privtile { display: block; text-decoration: none; color: inherit; border-color: #A7F3D0; }
.privtile:hover { box-shadow: 0 4px 14px rgba(21, 24, 30, .08); }
.tperson { font-size: 15px; margin: 14px 0 2px; }
.dropnote { font-size: 12px; color: var(--muted); margin: 2px 0 0; }
.card.dropping { outline: 2px dashed #3B5BDB; outline-offset: -6px; background: #F5F7FE; }
/* Mehrseitige Dokumente */
.multipage { position: relative; padding: 0 !important; }
.multipage .mpin { display: flex; align-items: center; justify-content: center; width: 100%; height: 100%; text-decoration: none; }
.multipage .mpin img { width: 100%; height: 100%; object-fit: cover; display: block; }
.multipage .mpin.pdfthumb img { object-position: top; }
.multipage::after { content: ''; position: absolute; inset: 0; box-shadow: 3px 3px 0 -1px #fff, 4px 4px 0 -1px var(--line); border-radius: inherit; pointer-events: none; }
.pbadge { position: absolute; right: 3px; bottom: 3px; background: rgba(21, 24, 30, .78); color: #fff; font-size: 10px; line-height: 1; padding: 3px 5px; border-radius: 6px; font-weight: 600; pointer-events: none; }
.tthumb .pbadge { font-size: 12px; right: 8px; bottom: 8px; padding: 4px 7px; }
.viewer .vpdf { width: min(1000px, 92vw); height: 84vh; border: 0; background: #fff; border-radius: 6px; }
.pggrid { margin-bottom: 16px; display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.pgcard { border: 1px solid var(--line); border-radius: 10px; overflow: hidden; background: #fff; }
.pgthumb { display: flex; align-items: center; justify-content: center; aspect-ratio: 4 / 3; background: #EEF0F3; text-decoration: none; }
.pgthumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.pgcap { padding: 8px 10px 4px; font-size: 13px; }
.pgact { display: flex; gap: 6px; padding: 4px 10px 10px; flex-wrap: wrap; }
