/* Targeted layout corrections for the existing theme and tables. */
.dashboard-heading { border: 1px solid var(--line); border-radius: 12px; padding: 18px 24px; box-shadow: var(--shadow); }
.dashboard-heading h1 { font-size: 30px; }
.tenant-prognosis-card { max-width: 620px; margin-inline: auto; text-align: center; }
#tenant-prognosis > .page-heading, #tenant-prognosis > .note { max-width: 620px; margin-inline: auto; }
#tenant-prognosis .tenant-prognosis-card .form-actions { justify-content: center; }
.tenant-prognosis-amount { margin: 18px 0; font: 700 36px Georgia, serif; }
#tenant-prognosis .forecast-status.repayment { color: var(--red); border-color: #e5c2be; background: #fff7f6; }
#tenant-prognosis .forecast-status.repayment i { background: var(--red); }
#tenant-prognosis .forecast-status.credit { color: #007b77; border-color: #add4d1; background: #f6fbfa; }
#tenant-prognosis .forecast-status.credit i { background: var(--green); }
.topbar nav[hidden] { display: none; }
#tenant-form .tenant-password-hint { font-size: 11px; font-weight: 400; color: var(--muted); }
#tenant-forecast thead th:nth-child(1) { width: 30%; }

.topbar { display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); }
.topbar .brand { justify-self: start; }
.topbar > .billing-year-picker { justify-self: center; }
.topbar nav { justify-self: end; }

@media (max-width: 800px) {
  .topbar { grid-template-columns: minmax(0, 1fr) auto; }
  .topbar > .billing-year-picker { justify-self: end; }
  .topbar nav { grid-column: 1 / -1; justify-self: stretch; justify-content: flex-end; }
}

@media (max-width: 520px) {
  .topbar { grid-template-columns: minmax(0, 1fr); }
  .topbar > .billing-year-picker { justify-self: start; }
  .topbar > .billing-year-picker select { width: 96px; }
  .topbar nav { grid-column: 1; justify-content: space-between; }
}
#tenant-forecast thead th:nth-child(2) { width: 18%; }
#tenant-forecast thead th:nth-child(3) { width: 22%; }
#tenant-forecast thead th:nth-child(4) { width: 30%; }
#tenant-forecast .tenant-view-link { text-decoration: none; white-space: nowrap; }
#tenant-forecast .tenant-view-link:disabled { background: #eef1f0; border-color: #cbd4d1; color: #687572; opacity: 1; cursor: not-allowed; }
#tenant-forecast tbody td:first-child { display: table-cell; vertical-align: middle; }
#tenant-forecast tbody td:first-child .tenant-avatar { display: inline-grid; vertical-align: middle; margin-right: 13px; }
#data .page-heading h1, #entries .page-heading h1, #master .page-heading h1 { font-size: 30px; }
#entries { width: min(1600px, calc(100vw - 48px)); margin-left: 50%; transform: translateX(-50%); }
.page-heading > div:first-child { min-width: 0; }
.page-heading .actions { flex-shrink: 0; margin-left: auto; justify-content: flex-end; }
.data-transfers { padding: 0 24px; }
.data-transfer-row { display: flex; align-items: center; justify-content: space-between; gap: 24px; padding: 24px 0; }
.data-transfer-row + .data-transfer-row { border-top: 1px solid var(--line); }
.data-transfer-row > div:first-child { min-width: 0; }
.data-area-link { color: var(--green); font-size: 18px; font-weight: 650; text-underline-offset: 4px; }
.data-transfer-row p { margin: 7px 0 0; font-size: 13px; line-height: 1.5; }
.data-transfer-row .actions { flex-shrink: 0; flex-wrap: nowrap; }
.data-transfer-row .button { min-width: 90px; }
.data-transfer-row.is-disabled button:disabled { background: #eef1f0; border-color: #cbd4d1; color: #687572; cursor: not-allowed; }
.data-transfer-row.is-disabled .data-area-link { pointer-events: none; }
.auto-import-button { min-width: 76px !important; }
.scan-method-options { display: grid; gap: 10px; }
.scan-method-option { display: flex; gap: 12px; align-items: flex-start; padding: 14px; border: 1px solid var(--line); border-radius: 9px; cursor: pointer; }
.scan-method-option input { margin-top: 3px; }
.scan-method-option strong, .scan-method-option small { display: block; }
.scan-method-option small { margin-top: 4px; color: #687572; line-height: 1.45; }
.scan-method-option.is-unavailable { opacity: .58; cursor: not-allowed; }
#scan-storage-dialog { width: min(810px, calc(100vw - 32px)); max-width: calc(100vw - 32px); }
#scan-storage-form { gap: 18px; padding: 32px 32px 0; }
#scan-storage-dialog .dialog-head h2 { margin-top: 8px; font-size: 30px; line-height: 1.15; letter-spacing: -.5px; }
#scan-storage-dialog .icon { width: 42px; height: 42px; font-size: 24px; color: #536b82; background: #eef3f7; }
.scan-storage-options { display: grid; gap: 16px; }
.scan-storage-option { display: grid; grid-template-columns: 22px minmax(0, 1fr); align-items: center; column-gap: 18px; padding: 20px; border: 1px solid #cbd5df; border-radius: 10px; background: #fff; }
.scan-storage-option:has(> input:checked) { border-color: #009b96; background: #f2fbfa; box-shadow: 0 0 0 1px #009b961f; }
.scan-storage-option > input { width: 22px; height: 22px; margin: 0; accent-color: #009b96; }
.scan-storage-option-summary { display: grid; grid-template-columns: 52px minmax(0, 1fr); align-items: center; gap: 16px; min-width: 0; cursor: pointer; }
.scan-storage-option-icon { display: grid; place-items: center; width: 52px; height: 52px; border-radius: 50%; background: #edf2f7; color: #536b82; }
.scan-storage-option-icon svg { width: 30px; height: 30px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.scan-storage-drive-icon { background: transparent; }
.scan-storage-drive-icon svg { width: 48px; height: 38px; stroke: none; }
#message-drive-card { display: contents; }
#message-drive-heading[hidden], #message-drive-actions[hidden] { display: none; }
#message-dialog.drive-mode { width: min(720px, calc(100vw - 32px)); }
#message-dialog.drive-mode #message-form { gap: 18px; padding: 32px 32px 0; }
#message-dialog.drive-mode .dialog-head h2 { margin-top: 8px; font-size: 30px; line-height: 1.15; letter-spacing: -.5px; }
#message-dialog.drive-mode .dialog-head h2::before { content: "GOOGLE DRIVE"; display: block; margin-bottom: 8px; color: #008b87; font: 800 11px Inter, ui-sans-serif, system-ui, sans-serif; letter-spacing: .13em; }
#message-dialog.drive-mode .icon { width: 42px; height: 42px; font-size: 24px; color: #536b82; background: #eef3f7; }
#message-dialog.drive-mode #message-text { color: #66758a; }
#message-dialog.drive-mode #message-drive-card { display: grid; gap: 16px; padding: 20px; border: 1px solid #cbd5df; border-radius: 10px; background: #fff; }
#message-dialog.drive-mode #message-drive-heading { display: grid; grid-template-columns: 52px minmax(0, 1fr); align-items: center; gap: 16px; color: #142033; font-size: 18px; }
#message-dialog.drive-mode #message-input-label { padding: 16px 20px; border: 1px solid #d8e0e8; border-radius: 9px; background: #fff; }
#message-dialog.drive-mode #message-drive-actions { display: flex; align-items: center; gap: 14px; }
#message-dialog.drive-mode #message-drive-check { min-width: 100px; }
#message-dialog.drive-mode #message-drive-status { margin: 0; color: #008b77; font-size: 13px; line-height: 1.4; }
#message-dialog.drive-mode #message-drive-status.is-error { color: #a33b32; }
#message-dialog.drive-mode .dialog-actions { margin: 0 -32px; padding: 18px 32px 24px; border-top: 1px solid #dfe5eb; }
#message-dialog.drive-mode .dialog-actions .button, #message-dialog.drive-mode .dialog-actions .primary { min-width: 126px; padding: 13px 22px; font-size: 15px; }
@media(max-width:620px){#message-dialog.drive-mode #message-form{padding:24px 20px 0}#message-dialog.drive-mode .dialog-head h2{font-size:25px}#message-dialog.drive-mode #message-drive-card{padding:16px}#message-dialog.drive-mode #message-drive-heading{grid-template-columns:42px minmax(0,1fr);gap:12px}#message-dialog.drive-mode #message-drive-icon{width:42px;height:42px}#message-dialog.drive-mode #message-drive-actions{align-items:flex-start;flex-direction:column}#message-dialog.drive-mode .dialog-actions{margin:0 -20px;padding:16px 20px 20px}}
.scan-storage-option-summary strong, .scan-storage-option-summary small { display: block; }
.scan-storage-option-summary strong { color: #142033; font-size: 18px; line-height: 1.3; }
.scan-storage-option-summary small { margin-top: 4px; color: #66758a; font-size: 14px; font-weight: 400; line-height: 1.45; }
.scan-storage-actions { grid-column: 2; display: grid; margin-top: 16px; padding: 0 24px; border: 1px solid #d8e0e8; border-radius: 9px; background: #fff; }
.scan-storage-actions[hidden] { display: none; }
.scan-storage-action { display: grid; grid-template-columns: 160px minmax(0, 1fr) auto; align-items: center; gap: 18px; min-height: 61px; }
.scan-storage-action + .scan-storage-action { border-top: 1px solid #d8e0e8; }
.scan-storage-action > span { color: #53657d; font-size: 14px; }
.scan-storage-action strong { color: #27364b; font-size: 14px; overflow-wrap: anywhere; }
.scan-storage-action strong.is-ready { color: #008b77; }
.scan-storage-link { border: 0; padding: 5px 0; background: transparent; color: #008b87; font: 650 14px inherit; text-decoration: underline; text-underline-offset: 3px; cursor: pointer; }
.scan-storage-link:disabled { opacity: .45; }
.scan-storage-remember { flex-direction: row; align-items: center; gap: 12px; margin: 2px 0 8px; color: #40536d; font-size: 14px; }
.scan-storage-remember input { width: 22px; height: 22px; margin: 0; }
#scan-storage-status { min-height: 1.4em; margin: -4px 0 0 34px; }
#scan-storage-dialog .dialog-actions { margin: 0 -32px; padding: 18px 32px 24px; border-top: 1px solid #dfe5eb; }
#scan-storage-dialog .dialog-actions .button, #scan-storage-dialog .dialog-actions .primary { min-width: 126px; padding: 13px 22px; font-size: 15px; }
@media(max-width:620px){#scan-storage-form{padding:24px 20px 0}#scan-storage-dialog .dialog-head h2{font-size:25px}.scan-storage-option{padding:16px;column-gap:12px}.scan-storage-option-summary{grid-template-columns:42px minmax(0,1fr);gap:12px}.scan-storage-option-icon{width:42px;height:42px}.scan-storage-actions{padding:0 14px}.scan-storage-action{grid-template-columns:1fr auto;gap:5px 12px;padding:10px 0}.scan-storage-action>span{grid-column:1}.scan-storage-action strong{grid-column:1}.scan-storage-action button{grid-column:2;grid-row:1/3}#scan-storage-dialog .dialog-actions{margin:0 -20px;padding:16px 20px 20px}}
#invoice-auto-status { margin-left: 4px; color: #16825e; font-weight: 800; }
#invoice-auto-prompt { position: fixed; inset: auto 24px 24px auto; margin: 0; border: 0; max-width: min(360px, calc(100vw - 48px)); padding: 14px 17px; border-radius: 8px; background: #007b77; color: #fff; box-shadow: var(--shadow); line-height: 1.5; }
#invoice-auto-prompt::backdrop { background: transparent; pointer-events: none; }
#invoice-auto-prompt p { margin: 0 0 12px; font-size: 14px; }
#invoice-auto-prompt > div { display: flex; justify-content: flex-end; gap: 8px; }
#invoice-auto-prompt button { min-width: 64px; padding: 6px 10px; border: 1px solid #fff; border-radius: 6px; background: transparent; color: #fff; font: inherit; font-size: 13px; font-weight: 600; cursor: pointer; }
#invoice-auto-prompt #invoice-auto-continue { background: #fff; color: #007b77; }
.data-transfer-hint { margin-top: 20px; font-size: 13px; line-height: 1.5; }
#allocation-keys .table-card { width: 100%; max-width: 100%; }
.data-transfers .data-transfer-unavailable { cursor: not-allowed; }
.data-transfers .data-transfer-unavailable .button:disabled { background: #eef1f0; border-color: #cbd4d1; color: #687572; opacity: 1; pointer-events: none; }
.table-card table, .forecast-table table { width: 100%; min-width: 0; table-layout: fixed; }
.table-card th, .table-card td, .forecast-table th, .forecast-table td { white-space: normal; overflow-wrap: anywhere; }
.table-card .right, .forecast-table .tenant-total { white-space: nowrap; }
#entries .row-buttons, #categories .row-buttons { flex-wrap: nowrap; gap: 8px; }
#entries .row-buttons button, #categories .row-buttons button { white-space: nowrap; overflow-wrap: normal; flex: 0 0 auto; padding-inline: 4px; }
#entries-table-layout thead tr:first-child th:last-child, #category-table-layout thead tr:first-child th:last-child { width: 184px; }
#entries-table-layout .entry-column-invoiceNumber { width: 16%; }
#entries-table-layout .entry-column-vendor { width: max(180px, calc(42% - 257px)); }
#category-table-layout thead tr:first-child th:first-child { width: 30%; }
#category-table-layout thead tr:first-child th:nth-child(2) { width: 110px; }
#category-table-layout thead tr:first-child th:nth-child(4) { width: 15%; }
#category-table-layout thead tr:first-child th:nth-child(5) { width: 145px; }
#entries-table-layout .entry-column-amount { width: 120px; }
#entries-table-layout .entry-column-date { width: 100px; }
#entries-table-layout .entry-column-category { width: auto; }
#entries-table .entry-income-amount { display: inline-block; padding: 2px 6px; border-radius: 5px; background: #e7f4eb; color: #276b3c; }
#entries-table-layout .category-filters th { width: auto; }
.category-filters input, .category-filters select { min-width: 0; max-width: 100%; }
.excel-filter { min-width: 0; }
#import-preview-filter-status { padding: 12px 16px; font-size: 12px; }
#object-import-preview-card[data-hide-kind="true"] tr > :first-child { display: none; }
#object-import-dialog #object-import-preview-card th:nth-child(3) { width: 190px; min-width: 190px; }
#object-import-preview-card .excel-filter summary { white-space: nowrap; overflow-wrap: normal; }
#object-import-preview-card .excel-filter-menu { position: static; width: 100%; min-width: 0; max-height: none; overflow: visible; margin-top: 6px; box-shadow: none; }
#object-import-preview-card .excel-filter-values { max-height: none; overflow: visible; }
#object-import-preview-card .excel-filter-option { width: 100%; min-width: 0; align-items: center; white-space: nowrap; overflow-wrap: normal; word-break: normal; }
#object-import-preview-card .excel-filter-option input { flex-shrink: 0; }
.excel-filter summary { white-space: normal; overflow-wrap: anywhere; }
.entry-category-path { overflow-wrap: anywhere; }
#entries-table .entry-category-path { white-space: pre-line; }
#category-table .category-group-content > span:first-child > strong { font-size: 15px; }
dialog:has(.table-card), #tenant-cost-dialog { width: min(1440px, calc(100vw - 32px)); max-width: calc(100vw - 32px); }
#tenant-cost-dialog { width: min(1200px, calc(100vw - 32px)); }
#object-import-dialog { width: min(720px, calc(100vw - 32px)); }
#object-import-dialog:has(#object-import-preview-card:not([hidden])) { width: min(1440px, calc(100vw - 32px)); }
#data-import-mapping { display: grid; gap: 14px; }
#data-import-mapping fieldset { min-width: 0; }
#dashboard-detail-dialog { width: min(1100px, calc(100vw - 32px)); }
#dashboard-detail-dialog table th:last-child { width: 150px; }
#tenant-cost-dialog .right { width: 120px; }
@media print {
  body > :not(#tenant-cost-dialog) { display: none !important; }
  #tenant-cost-dialog[open] { display: block !important; position: static; width: 100%; max-width: none; margin: 0; padding: 0; border: 0; box-shadow: none; }
  #tenant-cost-dialog .dialog-form { padding: 0; }
  #tenant-cost-dialog .table-card { overflow: visible; border: 0; box-shadow: none; }
  #tenant-cost-dialog .dialog-actions, #tenant-cost-dialog .icon { display: none !important; }
  #tenant-cost-dialog table { width: 100%; }
}
#object-import-dialog th:nth-child(1), #object-import-dialog th:nth-child(3) { width: 120px; }
#object-import-dialog th:nth-child(2) { width: 22%; }
#object-import-status { white-space: pre-line; overflow-wrap: anywhere; }
#consumption .card { max-width: 100%; width: 100%; }
#building .master-overview { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; }
#building .card { padding: 18px; }
#building .building-form { gap: 12px; }
#building .building-form input { padding: 9px 10px; }
#building .card-head h2 { font-size: 19px; }
#building .list-item, #entries .row-actions, #categories .row-actions { container-type: inline-size; }
#building .item-actions { flex: 0 0 auto; flex-direction: row; align-items: center; }
@container (max-width: 245px) { #building .item-actions { flex-direction: column; align-items: flex-end; gap: 4px; } #building .list-item { align-items: flex-start; } #tenants-list .item-actions { align-self: flex-start; } }
@container (max-width: 130px) { #entries .row-buttons, #categories .row-buttons { flex-direction: column; align-items: flex-end; gap: 4px; } }
.consumption-overview-row, .consumption-meter-head, .consumption-meter-row { grid-template-columns: minmax(180px, 3fr) repeat(3, minmax(90px, 1fr)); }
#consumption-form input[name=waterTotal] { background: #eef1f0; color: #687572; cursor: not-allowed; }
.consumption-meter-actions { display: none; }
@media (max-width: 900px) {
  #building .master-overview { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .page-heading { flex-wrap: wrap; }
  .page-heading .actions { flex-shrink: 1; }
  .table-card th, .table-card td, .forecast-table th, .forecast-table td { padding: 8px; }
  #entries-table-layout .entry-column-amount, #entries-table-layout .entry-column-date,
  #dashboard-detail-dialog table th:last-child, #tenant-cost-dialog .right { width: auto; }
  #entries-table-layout thead tr:first-child th:last-child, #category-table-layout thead tr:first-child th:last-child { width: 160px; }
  #category-table-layout thead tr:first-child th:nth-child(2), #category-table-layout thead tr:first-child th:nth-child(5) { width: 90px; }
  .table-card .right, .forecast-table .tenant-total { white-space: normal; }
  .forecast-status { white-space: normal; }
}
@media (max-width: 800px) {
  .topbar { height: auto; min-height: 76px; flex-wrap: wrap; gap: 8px; padding-block: 10px; }
  .topbar .brand { max-width: 100%; min-width: 0; gap: 8px; }
  .topbar .brand small { display: block; min-width: 0; padding-left: 8px; font-size: 11px; line-height: 1.35; }
  .page > .note small { display: block; }
}
@media (max-width: 620px) {
  #building .master-overview { grid-template-columns: 1fr; }
  #entries { width: calc(100vw - 32px); }
  .topbar { height: auto; min-height: 76px; flex-wrap: wrap; gap: 8px; padding-block: 10px; }
  .topbar nav { min-height: 36px; }
  .data-transfer-row { align-items: flex-start; flex-direction: column; gap: 14px; }
  .data-transfer-row .actions { width: 100%; }
  #category-table-layout thead tr:first-child th:nth-child(2), #category-table-layout thead tr:first-child th:nth-child(5) { width: auto; }
  #entries-table-layout thead tr:first-child th:last-child, #category-table-layout thead tr:first-child th:last-child { width: 140px; }
  .dashboard-heading { padding: 16px; }
  .consumption-overview-row, .consumption-meter-head, .consumption-meter-row { grid-template-columns: minmax(0, 1fr) repeat(3, minmax(0, 1fr)); gap: 6px; }
  .consumption-meter-head strong { overflow-wrap: anywhere; }
  .consumption-overview-row label { overflow-wrap: anywhere; min-width: 0; }
  #object-import-dialog th:nth-child(1), #object-import-dialog th:nth-child(2), #object-import-dialog th:nth-child(3) { width: auto; }
}

/* Reuse table rows as mobile cards, including the existing filters and actions. */
@media screen and (max-width: 620px) {
  #building .sort-handle { display: inline-flex; align-items: center; justify-content: center; min-width: 44px; min-height: 44px; }
  #master > .tabs { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 3px; }
  #master > .tabs button { min-width: 0; padding: 12px 4px; font-size: 14px; white-space: normal; overflow-wrap: anywhere; }
  #entries > .table-card, #categories > .table-card { border: 0; background: transparent; box-shadow: none; }
  #entries-table-layout, #category-table-layout { display: block; width: 100%; min-width: 0; }
  #entries-table-layout thead, #category-table-layout thead { display: block; margin-bottom: 16px; padding: 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--white); }
  #entries-table-layout thead tr, #category-table-layout thead tr { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  #entries-table-layout thead th, #category-table-layout thead th { display: block; width: auto !important; min-width: 0; padding: 0; border: 0; text-align: left; text-transform: none; letter-spacing: normal; }
  #entries-table-layout thead th:last-child, #category-table-layout thead th:last-child { display: none; }
  #entries-table-layout thead tr:first-child, #category-table-layout thead tr:first-child { display: none; }
  #entries-table-layout .table-sort, #category-table-layout .table-sort { width: 100%; min-height: 44px; padding: 8px; border: 1px solid var(--line); border-radius: 7px; font-size: 12px; text-align: left; }
  #entries-filters th::before, #category-table-layout .category-filters th::before { display: block; margin-bottom: 5px; color: var(--muted); font-size: 12px; font-weight: 600; }
  #entries-filters th::before { content: attr(data-label); }
  #category-table-layout .category-filters th:nth-child(1)::before { content: "Kategorie"; }
  #category-table-layout .category-filters th:nth-child(2)::before { content: "Umlagefähigkeit"; }
  #category-table-layout .category-filters th:nth-child(3)::before { content: "Verteilerschlüssel"; }
  #category-table-layout .category-filters th:nth-child(4)::before { content: "Mieterzuordnung"; }
  #category-table-layout .category-filters th:nth-child(5)::before { content: "Jahresplanung [€]"; }
  #entries-table-layout .excel-filter summary, #category-table-layout .excel-filter summary { min-height: 44px; padding: 12px 24px 12px 10px; }
  #entries-table-layout .excel-filter-menu, #category-table-layout .excel-filter-menu { min-width: 0; width: min(260px, calc(100vw - 64px)); max-height: 60vh; overflow: auto; }
  #entries-table-layout .category-filters th:nth-child(even) .excel-filter-menu, #category-table-layout .category-filters th:nth-child(even) .excel-filter-menu { left: auto; right: 0; }
  #entries-table, #category-table { display: grid; gap: 12px; }
  #entries-table > tr, #category-table > tr { display: block; min-width: 0; padding: 8px 14px; border: 1px solid var(--line); border-radius: 12px; background: var(--white); box-shadow: var(--shadow); }
  #category-table > tr[hidden] { display: none; }
  #entries-table td, #category-table td { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 3fr); align-items: start; gap: 12px; width: auto; min-width: 0; padding: 10px 0; font-size: 14px; line-height: 1.5; text-align: left; border-bottom: 1px solid var(--line); }
  #entries-table-layout td.entry-column-category, #entries-table-layout td.entry-column-vendor { width: auto; }
  #entries-table td.entry-column-category { display: block; }
  #entries-table td.entry-column-category::before { display: block; margin-bottom: 4px; }
  #entries-table td::before, #category-table td::before { color: var(--muted); font-size: 12px; font-weight: 600; }
  #entries-table td[data-label]::before { content: attr(data-label); }
  #entries-table td.entry-column-vendor { display: block; }
  #entries-table td.entry-column-vendor::before { display: block; margin-bottom: 4px; }
  #entries-table td.entry-column-vendor strong { display: block; font-size: 16px; }
  #entries-table td.entry-column-invoiceNumber { display: block; width: auto; }
  #entries-table td.entry-column-invoiceNumber::before { content: "Verwendungszweck"; display: block; margin-bottom: 4px; }
  #category-table tr[data-category-index] td:nth-child(2)::before { content: "Umlagefähig"; }
  #category-table tr[data-category-index] td:nth-child(3)::before { content: "Verteilerschlüssel"; }
  #category-table tr[data-category-index] td:nth-child(4)::before { content: "Mieter"; }
  #category-table tr[data-category-index] td:nth-child(5)::before { content: "Jahresplanung"; }
  #category-table tr[data-category-index] td:empty { display: none; }
  #entries-table .entry-category-path { font-size: 14px; }
  #entries-table .entry-column-amount, #category-table tr[data-category-index] td:nth-child(5) { font-weight: 700; }
  #entries-table .pill { justify-self: start; }
  #entries-table td.row-actions, #category-table td.row-actions, #entries-table td.empty, #category-table .category-group-row td { display: block; border-bottom: 0; }
  #entries .row-buttons, #categories .row-buttons { flex-direction: row; flex-wrap: wrap; align-items: center; gap: 8px; }
  #entries .row-buttons button, #categories .row-buttons button { min-height: 44px; padding: 8px 12px; border: 1px solid var(--line); border-radius: 7px; font-size: 14px; }
  #category-table tr[data-category-index] td:first-child { display: flex; align-items: center; gap: 8px; padding: 10px 0; font-size: 16px; }
  #category-table tr[data-category-index][data-category-parent-index=""] td:first-child { padding-left: 10px; }
  #category-table tr[data-category-parent-index]:not([data-category-parent-index=""]) td:first-child { padding-left: 12px; }
  #category-table .category-root-name, #category-table .category-child-name { min-width: 0; padding-left: 0; white-space: normal; overflow-wrap: anywhere; }
  #category-table .category-child-name { color: var(--ink); font-size: 15px; }
  #category-table tr[data-category-index] td:first-child::before { content: "H2"; flex: 0 0 auto; padding: 3px 6px; border-radius: 5px; background: var(--mint); color: var(--green); font-size: 11px; }
  #category-table tr[data-category-parent-index]:not([data-category-parent-index=""]) { margin-left: 12px; border-left: 3px solid var(--green); box-shadow: none; }
  #category-table tr[data-category-parent-index]:not([data-category-parent-index=""])::before { content: "H2: " attr(data-category-parent-name); display: block; padding-top: 6px; color: var(--muted); font-size: 12px; line-height: 1.5; overflow-wrap: anywhere; }
  #category-table tr[data-category-parent-index]:not([data-category-parent-index=""]) td:first-child { padding-left: 30px; }
  #category-table tr[data-category-parent-index]:not([data-category-parent-index=""]) td:first-child::before { content: "H3"; }
  #category-table { gap: 0; }
  #category-table > tr { margin-top: 14px; }
  #category-table .category-group-row { margin-top: 24px; border-color: #a8c9c3; }
  #category-table .category-group-row:first-child { margin-top: 0; }
  #category-table .category-group-row td { background: transparent; }
  #category-table .category-group-content > span:first-child::before { content: "H1"; padding: 3px 6px; border-radius: 5px; background: var(--green); color: var(--white); font-size: 11px; font-weight: 700; }
  #category-table tr[data-category-parent-index=""]:has(+ tr[data-category-parent-index]:not([data-category-parent-index=""]):not([hidden])) { border-bottom: 0; border-bottom-left-radius: 0; border-bottom-right-radius: 0; }
  #category-table tr[data-category-parent-index]:not([data-category-parent-index=""]) { margin: 0; padding-left: 24px; border-left: 1px solid var(--line); border-top: 0; border-radius: 0; background: #f6faf9; }
  #category-table tr[data-category-parent-index]:not([data-category-parent-index=""])::before { content: none; }
  #category-table tr[data-category-parent-index]:not([data-category-parent-index=""]):not(:has(+ tr[data-category-parent-index]:not([data-category-parent-index=""]):not([hidden]))) { border-bottom-left-radius: 12px; border-bottom-right-radius: 12px; }
  #category-table .category-toggle { flex: 0 0 36px; width: 36px; height: 44px; margin: 0; font-size: 18px; }
  #category-table .category-sort-handle { flex-shrink: 0; }
  #category-table .category-group-row { background: var(--mint); box-shadow: none; }
  #category-table .category-group-content { flex-wrap: wrap; gap: 10px; }
  #category-table .category-group-content > span:first-child { display: flex; align-items: center; gap: 8px; min-width: 0; font-size: 16px; }
  #category-table .category-group-content strong { min-width: 0; overflow-wrap: anywhere; }
  #entries-table-layout tfoot, #category-table-layout tfoot { display: block; margin-top: 16px; padding: 14px; border: 1px solid var(--line); border-radius: 12px; background: var(--white); }
  #entries-table-layout tfoot tr, #category-table-layout tfoot tr { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 12px; }
  #entries-table-layout tfoot th, #category-table-layout tfoot th { width: auto; padding: 0; border: 0; font-size: 14px; }
  #entries-table-layout tfoot th:empty, #category-table-layout tfoot th:empty { display: none; }

  #tenant-forecast .forecast-table { border: 0; background: transparent; box-shadow: none; }
  #tenant-forecast table { display: block; width: 100%; min-width: 0; }
  #tenant-forecast thead { display: none; }
  #tenant-forecast tbody { display: grid; gap: 12px; }
  #tenant-forecast tbody tr { display: grid; grid-template-columns: minmax(0, 1fr) auto; column-gap: 10px; min-width: 0; padding: 14px; border: 1px solid var(--line); border-radius: 12px; background: var(--white); box-shadow: var(--shadow); }
  #tenant-forecast tbody td { display: block; width: auto; min-width: 0; padding: 8px 0; border: 0; font-size: 14px; line-height: 1.5; }
  #tenant-forecast tbody td:first-child { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; padding-top: 0; font-size: 16px; }
  #tenant-forecast tbody td:first-child .tenant-avatar { margin-right: 0; }
  #tenant-forecast tbody td:first-child strong { flex: 1; min-width: 0; overflow-wrap: anywhere; }
  #tenant-forecast tbody td:nth-child(2) { align-self: start; padding-top: 0; }
  #tenant-forecast tbody td:nth-child(n+3) { grid-column: 1 / -1; }
  #tenant-forecast .orphan-warning { flex-basis: 100%; }
  #tenant-forecast tbody .tenant-total { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px; font-size: 18px; font-weight: 700; }
  #tenant-forecast tbody .tenant-total::before { content: "Summe"; align-self: center; color: var(--muted); font-size: 12px; font-weight: 600; }
  #tenant-forecast .forecast-status { width: 100%; border-radius: 8px; white-space: normal; font-size: 12px; }
  #tenant-forecast .forecast-status i { flex: 0 0 8px; }
  #tenant-forecast tfoot { display: block; margin-top: 16px; padding: 14px; border: 1px solid var(--line); border-radius: 12px; background: var(--white); }
  #tenant-forecast tfoot tr { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 12px; }
  #tenant-forecast tfoot th { width: auto; padding: 0; border: 0; background: transparent; font-size: 14px; }
  #tenant-forecast tfoot th:empty { display: none; }

  #tenant-cost-dialog .dialog-form { padding: 18px; }
  #tenant-cost-dialog .dialog-head h2 { min-width: 0; font-size: 22px; overflow-wrap: anywhere; }
  #tenant-cost-dialog .table-card { border: 0; background: transparent; box-shadow: none; }
  #tenant-cost-dialog table { display: block; width: 100%; min-width: 0; }
  #tenant-cost-dialog thead { display: none; }
  #tenant-cost-dialog thead tr { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  #tenant-cost-dialog thead th { display: block; width: auto; min-width: 0; padding: 0; border: 0; text-transform: none; letter-spacing: normal; }
  #tenant-cost-dialog .table-sort { width: 100%; min-height: 44px; padding: 8px; border: 1px solid var(--line); border-radius: 7px; font-size: 12px; text-align: left; }
  #tenant-cost-table { display: grid; gap: 14px; }
  #tenant-cost-table > tr { display: block; min-width: 0; padding: 14px; border: 1px solid var(--line); border-radius: 12px; background: var(--white); }
  #tenant-cost-dialog #tenant-cost-table td { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 3fr); align-items: start; gap: 12px; width: auto; min-width: 0; padding: 10px 0; border-bottom: 1px solid var(--line); font-size: 14px; line-height: 1.5; text-align: left; }
  #tenant-cost-table td::before { color: var(--muted); font-size: 12px; font-weight: 600; }
  #tenant-cost-table td:nth-child(1)::before { content: "Empfänger"; }
  #tenant-cost-table td:nth-child(2)::before { content: "Kategorie"; }
  #tenant-cost-table td:nth-child(3)::before { content: "Art"; }
  #tenant-cost-table td:nth-child(4)::before { content: "Betrag"; }
  #tenant-cost-table td:nth-child(5)::before { content: "Schlüssel"; }
  #tenant-cost-table td:nth-child(6)::before { content: "Mieteranteil"; }
  #tenant-cost-dialog #tenant-cost-table td:nth-child(1), #tenant-cost-dialog #tenant-cost-table td:nth-child(2), #tenant-cost-dialog #tenant-cost-table td.empty { display: block; }
  #tenant-cost-table td:nth-child(1)::before, #tenant-cost-table td:nth-child(2)::before { display: block; margin-bottom: 4px; }
  #tenant-cost-table td:nth-child(1) strong { font-size: 16px; }
  #tenant-cost-table .entry-category-path { font-size: 14px; }
  #tenant-cost-table .pill { justify-self: start; }
  #tenant-cost-table td:nth-child(6) { border-bottom: 0; font-weight: 700; }
  #tenant-cost-dialog #tenant-cost-table td:empty { display: none; }
  #tenant-cost-table td.empty::before { content: none; }
  #tenant-cost-totals { display: grid; gap: 14px; margin-top: 16px; }
  #tenant-cost-totals[hidden] { display: none; }
  #tenant-cost-totals tr { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 12px; padding: 14px; border: 1px solid var(--line); border-radius: 12px; }
  #tenant-cost-dialog #tenant-cost-totals th { width: auto; padding: 0; border: 0; font-size: 14px; }
  #tenant-cost-totals th:empty { display: none; }
  #tenant-cost-totals tr:first-child th:first-child { width: 100% !important; }
  #tenant-cost-dialog #tenant-cost-totals #tenant-amount-total, #tenant-cost-dialog #tenant-cost-totals #tenant-share-total { display: flex; justify-content: space-between; gap: 12px; width: 100%; }
  #tenant-amount-total::before { content: "Gesamtbetrag"; color: var(--muted); font-weight: 400; }
  #tenant-share-total::before { content: "Mieteranteil"; color: var(--muted); font-weight: 400; }
  #tenant-cost-dialog .dialog-actions { flex-wrap: wrap; }

  #dashboard .note { align-items: flex-start; }
  #dashboard .note-mark { flex: 0 0 27px; }
  #dashboard .note small { display: block; font-size: 13px; line-height: 1.6; }
  #consumption .consumption-overview-row { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
  #consumption .consumption-total-meter, #consumption .consumption-total-usage { grid-column: 1 / -1; }
  #consumption .consumption-meter-head { display: none; }
  #consumption .consumption-meter-row { grid-template-columns: minmax(0, 1fr); gap: 14px; padding: 16px; border: 1px solid var(--line); border-radius: 12px; background: var(--white); }
  #consumption .consumption-meter-row::before { content: attr(data-meter-label); color: var(--green); font-size: 15px; font-weight: 700; line-height: 1.5; overflow-wrap: anywhere; }
  #consumption .consumption-meter-identity { display: none; }
  #consumption .consumption-meter-row > .meter-reading-input::before { display: block; margin-bottom: 5px; color: var(--muted); font-size: 12px; font-weight: 600; }
  #consumption .consumption-meter-row > .meter-reading-input:nth-of-type(1)::before { content: "Periodenanfang"; }
  #consumption .consumption-meter-row > .meter-reading-input:nth-of-type(2)::before { content: "Periodenende"; }
  #consumption .consumption-meter-row > .meter-reading-input:nth-of-type(3)::before { content: "Verbrauch"; }
  #consumption .consumption-meter-row > .meter-reading-input > span { top: auto; bottom: 10px; transform: none; }
  #consumption .consumption-meter-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; }
  #consumption .consumption-meter-actions [hidden] { display: none; }
  #consumption .consumption-meter-actions button { min-height: 44px; }
}

/* Teilbeträge bleiben im vorhandenen Rechnungsdialog. */

/* Wasserzähler wie in der tabellarischen Gesamtkarte, mit Datum direkt unter dem Stand. */
#consumption .water-meter-section { width: min(100%, 1000px); margin-inline: auto; }
#consumption .water-meter-section-head { margin-bottom: 16px; }
#consumption-form { display: block; }
#consumption .water-meter-reading-list { display: flex; flex-direction: column; align-items: flex-start; gap: 18px; }
#consumption .water-meter-entry { display: flex; flex-direction: column; align-items: stretch; width: max-content; max-width: 100%; gap: 10px; padding: 18px; }
#consumption .water-meter-units { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); width: 100%; gap: 16px; align-items: start; }
#consumption .water-meter-entry:not([data-water-main]) { width: 100%; }
#consumption .water-meter-heading { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 10px; align-items: end; }
#consumption .water-meter-heading label { display: block; font-size: 12px; font-weight: 600; color: var(--green); }
#consumption .water-meter-heading input { display: block; width: var(--water-name-ch); max-width: 100%; margin-top: 7px; background: #eef1f0; color: var(--ink); }
#consumption .water-meter-grid { display: flex; flex-wrap: nowrap; width: max-content; max-width: 100%; gap: 10px; align-items: flex-start; overflow-x: auto; padding-bottom: 2px; }
#consumption .water-reading-card { flex: 0 0 145px; min-width: 0; }
#consumption .water-reading-card-head { min-height: 18px; display: flex; justify-content: space-between; gap: 5px; align-items: flex-start; margin-bottom: 7px; }
#consumption .water-reading-card-head strong { font-size: 12px; font-weight: 600; }
#consumption .water-reading-card input { min-width: 0; width: 100%; background: #eef1f0; }
#consumption .water-reading-card input[type=date] { margin-top: 7px; font-size: 12px; padding: 8px 5px; }
#consumption .water-reading-remove { border: 0; background: transparent; color: var(--green); cursor: pointer; }
#consumption .water-reading-remove { font-size: 18px; line-height: 1; }
#consumption .water-reading-add { flex: 0 0 auto; align-self: flex-start; margin-top: 25px; }
#consumption .water-meter-result { align-self: end; min-width: 145px; padding: 0 0 11px; color: var(--ink); font-size: 14px; text-align: right; white-space: nowrap; }
#consumption .water-meter-result[hidden] { display: none; }
#consumption [data-water-difference] { display: block; margin-top: 3px; color: var(--red); font-size: 11px; font-weight: 600; }
#consumption [data-water-difference][hidden] { display: none; }
#consumption .water-meter-actions { display: flex; justify-content: flex-end; gap: 9px; margin-top: 2px; }
#consumption .water-meter-actions [hidden] { display: none; }
#consumption .water-reading-card input:disabled { background: #eef1f0; color: #687572; cursor: not-allowed; }
#consumption .water-meter-entry:not(.is-editing) .water-reading-card-head strong { color: #7d8986; }
#consumption .water-meter-entry.is-editing .water-reading-card input { background: var(--white); color: var(--ink); }
#consumption .water-reading-add:disabled { background: #eef1f0; border-color: #cbd4d1; color: #687572; cursor: not-allowed; }
#consumption .water-reading-remove:disabled { color: #9ca8a4; cursor: not-allowed; }
@media (max-width: 800px) {
  #consumption .water-meter-units { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 620px) {
  #consumption .water-meter-entry { padding: 16px; }
  #consumption .water-meter-heading { grid-template-columns: minmax(0, 1fr); }
  #consumption .water-meter-result { justify-self: start; text-align: left; }
  #consumption .water-meter-grid { flex-direction: column; flex-wrap: nowrap; gap: 12px; }
  #consumption .water-reading-card { flex: 0 0 auto; width: 100%; min-width: 145px; }
  #consumption .water-reading-card-head { min-height: 0; }
  #consumption .water-reading-card input, #consumption .water-reading-card input[type=date] { min-height: 44px; font-size: 16px; }
  #consumption .water-reading-add { margin-top: 0; }
}
.entry-category-field[hidden], #entry-split-section[hidden] { display: none; }
#entry-split-toggle { grid-column: 1 / -1; justify-self: start; }
#entry-split-section { border-top: 1px solid var(--line); padding-top: 16px; }
.entry-split-row { display: grid; grid-template-columns: minmax(100px, 1fr) minmax(180px, 2fr) auto; gap: 12px; align-items: end; margin-bottom: 12px; }
.entry-split-row > * { min-width: 0; }
.entry-split-error { color: #b42318; }
@media (max-width: 600px) { .entry-split-row { grid-template-columns: 1fr; padding-bottom: 12px; border-bottom: 1px solid var(--line); } .entry-split-row button { justify-self: start; } }
