:root {
  --bg: #eef1f5;
  --panel: #ffffff;
  --panel-soft: #f7f9fc;
  --text: #162033;
  --muted: #647184;
  --line: #cfd7e3;
  --line-soft: #e2e7ef;
  --primary: #256db2;
  --primary-dark: #19558f;
  --primary-soft: #e8f2fd;
  --danger: #b73838;
  --danger-soft: #faeaea;
  --success: #21784f;
  --warning: #a86a0b;
  --radius-lg: 10px;
  --radius-md: 7px;
  --radius-sm: 5px;
  --shadow: 0 8px 24px rgba(25, 43, 70, .08);
  --font: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

[data-theme="dark"] {
  --bg: #111821;
  --panel: #182231;
  --panel-soft: #202c3d;
  --text: #eef4fb;
  --muted: #aab6c7;
  --line: #354458;
  --line-soft: #2a3648;
  --primary: #7db8ff;
  --primary-dark: #9ac8ff;
  --primary-soft: rgba(125, 184, 255, .13);
  --danger: #ff8b8b;
  --danger-soft: rgba(255, 139, 139, .12);
  --success: #7ed6a9;
  --warning: #ffd07c;
  --shadow: 0 8px 24px rgba(0, 0, 0, .22);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--bg);
}

body {
  margin: 0;
  min-height: 100%;
  color: var(--text);
  font-family: var(--font);
  font-size: 13px;
  line-height: 1.35;
  background: var(--bg);
}

button,
input,
select,
textarea {
  font: inherit;
}

button,
label.file-btn {
  user-select: none;
}

.app-shell {
  width: min(1500px, calc(100% - 18px));
  margin: 0 auto;
  padding: 10px 0 28px;
}

.topbar {
  display: grid;
  grid-template-columns: auto minmax(130px, .7fr) auto auto;
  gap: 12px;
  align-items: center;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--panel);
  box-shadow: var(--shadow);
}

.brand {
  display: inline-flex;
  gap: 9px;
  align-items: center;
  min-width: 180px;
  color: inherit;
  text-decoration: none;
}

.brand-logo {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 8px;
  color: #fff;
  font-weight: 900;
  letter-spacing: -.04em;
  background: linear-gradient(135deg, #174b81, #4d97df);
}

.brand strong,
.brand small {
  display: block;
  line-height: 1.1;
}

.brand small {
  margin-top: 3px;
  color: var(--muted);
  font-size: 11px;
}

.title-block h1 {
  margin: 0;
  font-size: 1.45rem;
  line-height: 1;
  letter-spacing: -.04em;
  text-transform: lowercase;
}

.title-block p {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.toolbar,
.button-group,
.modal-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: flex-end;
  align-items: center;
}

.btn {
  display: inline-flex;
  gap: 5px;
  align-items: center;
  justify-content: center;
  min-height: 30px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  color: var(--text);
  background: var(--panel-soft);
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
}

.btn:hover {
  border-color: var(--primary);
}

.btn.primary {
  color: #fff;
  border-color: var(--primary-dark);
  background: var(--primary-dark);
}

[data-theme="dark"] .btn.primary {
  color: #0b1724;
  border-color: var(--primary-dark);
  background: var(--primary-dark);
}

.btn.danger {
  color: var(--danger);
  border-color: rgba(183, 56, 56, .35);
  background: var(--danger-soft);
}

.btn.small {
  min-height: 28px;
  padding: 0 9px;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.statusline {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin: 8px 0;
  padding: 6px 10px;
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-md);
  color: var(--muted);
  background: var(--panel-soft);
  font-size: 12px;
}

.work-view {
  display: grid;
  gap: 10px;
}

.panel {
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--panel);
  box-shadow: var(--shadow);
}

.panel-head {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
  margin-bottom: 8px;
}

.panel h2 {
  margin: 0;
  font-size: 1rem;
  line-height: 1.15;
  letter-spacing: -.02em;
}

.metrics-inline {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: flex-end;
}

.metrics-inline span {
  padding: 4px 7px;
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-sm);
  color: var(--muted);
  background: var(--panel-soft);
  font-size: 12px;
}

.metrics-inline b {
  color: var(--text);
}

.form-grid {
  display: grid;
  gap: 8px;
}

.object-grid {
  grid-template-columns: 170px minmax(260px, 2fr) 145px 145px 145px;
}

.dialog-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.field {
  display: grid;
  gap: 3px;
}

.field.wide {
  grid-column: span 4;
}

.field span,
.select-line span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}

input,
select,
textarea {
  width: 100%;
  min-height: 32px;
  padding: 6px 8px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  color: var(--text);
  background: var(--panel);
  outline: none;
}

textarea {
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px var(--primary-soft);
}

.table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--panel);
}

.data-table,
.print-table {
  width: 100%;
  border-collapse: collapse;
}

.data-table th,
.data-table td {
  padding: 6px 7px;
  border-bottom: 1px solid var(--line-soft);
  text-align: left;
  vertical-align: middle;
  white-space: nowrap;
}

.data-table th {
  color: var(--muted);
  background: var(--panel-soft);
  font-size: 11px;
  font-weight: 800;
}

.data-table tbody tr:hover {
  background: var(--primary-soft);
}

.data-table tfoot th {
  padding: 7px;
  border-top: 1px solid var(--line);
  background: var(--panel-soft);
}

.num {
  text-align: right !important;
  font-variant-numeric: tabular-nums;
}

.actions-col {
  width: 1%;
  text-align: right !important;
}

.row-actions {
  display: flex;
  gap: 4px;
  justify-content: flex-end;
}

.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  color: var(--text);
  background: var(--panel-soft);
  cursor: pointer;
  font-weight: 800;
  line-height: 1;
}

.icon-btn.danger {
  color: var(--danger);
  background: var(--danger-soft);
}

.empty-state {
  display: none;
  margin: 8px 0 0;
  padding: 7px 8px;
  border: 1px dashed var(--line);
  border-radius: var(--radius-sm);
  color: var(--muted);
  background: var(--panel-soft);
}

.settlement-head {
  align-items: end;
}

.select-line {
  display: grid;
  grid-template-columns: auto minmax(260px, 380px);
  gap: 7px;
  align-items: center;
}

.result-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 8px;
}

.info-box {
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--panel-soft);
}

.info-box h3 {
  margin: 0 0 5px;
  font-size: .92rem;
}

.info-box dl {
  display: grid;
  gap: 2px;
  margin: 0;
}

.info-box dl div {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  padding: 4px 0;
  border-top: 1px solid var(--line-soft);
}

.info-box dt {
  color: var(--muted);
}

.info-box dd {
  margin: 0;
  font-weight: 750;
  text-align: right;
}

.result-box {
  border-color: rgba(37, 109, 178, .42);
  background: var(--primary-soft);
}

.result-box.positive {
  border-color: rgba(183, 56, 56, .45);
}

.result-box.negative {
  border-color: rgba(33, 120, 79, .45);
}

.strong dt,
.strong dd,
.final dt,
.final dd {
  font-weight: 900;
}

.final {
  margin-top: 2px;
  padding-top: 6px !important;
  border-top: 2px solid var(--line) !important;
}

.check-badge {
  padding: 4px 8px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--panel-soft);
  font-size: 12px;
  font-weight: 800;
}

.check-list {
  display: grid;
  gap: 5px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.check-list li {
  display: flex;
  gap: 7px;
  align-items: flex-start;
  padding: 6px 8px;
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-sm);
  background: var(--panel-soft);
}

.check-list .dot {
  width: 8px;
  height: 8px;
  margin-top: 5px;
  border-radius: 50%;
  background: var(--primary);
  flex: 0 0 auto;
}

.check-list .warning .dot {
  background: var(--warning);
}

.check-list .error .dot {
  background: var(--danger);
}

.check-list .ok .dot {
  background: var(--success);
}

.legal-note {
  margin: 7px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.modal {
  width: min(920px, calc(100% - 18px));
  padding: 0;
  border: 0;
  border-radius: var(--radius-lg);
  background: transparent;
}

.modal::backdrop {
  background: rgba(4, 8, 14, .55);
}

.modal-card {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  color: var(--text);
  background: var(--panel);
  box-shadow: var(--shadow);
}

.modal-head {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
  margin-bottom: 8px;
}

.modal-head h2 {
  margin: 0;
  font-size: 1.05rem;
}

.modal-actions {
  margin-top: 10px;
}

.print-view {
  display: none;
}

.print-view.active {
  display: block;
}

body.print-mode .topbar,
body.print-mode .statusline,
body.print-mode .work-view {
  display: none;
}

.print-toolbar {
  display: flex;
  justify-content: flex-end;
  gap: 6px;
  margin-bottom: 8px;
}

.print-document {
  max-width: 1040px;
  margin: 0 auto;
  padding: 30px;
  border: 1px solid #ccc;
  color: #111;
  background: #fff;
  box-shadow: var(--shadow);
}

.print-header {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  align-items: flex-start;
  padding-bottom: 12px;
  border-bottom: 2px solid #111;
}

.print-header p {
  margin: 0 0 4px;
  color: #555;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .06em;
}

.print-header h1 {
  margin: 0;
  font-size: 1.7rem;
}

.print-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
}

.print-document section {
  margin-top: 18px;
}

.print-document h2 {
  margin: 0 0 7px;
  font-size: 1rem;
}

.print-document p {
  margin: 3px 0;
}

.print-table th,
.print-table td {
  padding: 6px 7px;
  border: 1px solid #c9c9c9;
  text-align: left;
  vertical-align: top;
}

.print-table th {
  background: #f0f0f0;
}

.print-table tfoot th,
.print-table tfoot td,
.final-row th,
.final-row td {
  font-weight: 900;
}

.print-table.compact {
  max-width: 720px;
}

.print-document footer {
  margin-top: 18px;
  padding-top: 10px;
  border-top: 1px solid #ccc;
  color: #555;
  font-size: 12px;
}

@media (max-width: 1180px) {
  .topbar {
    grid-template-columns: 1fr;
  }

  .toolbar {
    justify-content: flex-start;
  }

  .object-grid,
  .dialog-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .field.wide {
    grid-column: span 2;
  }

  .result-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 680px) {
  .app-shell {
    width: min(100% - 10px, 1500px);
    padding-top: 5px;
  }

  .topbar,
  .panel {
    padding: 8px;
  }

  .object-grid,
  .dialog-grid,
  .print-grid {
    grid-template-columns: 1fr;
  }

  .field.wide {
    grid-column: auto;
  }

  .panel-head,
  .statusline,
  .select-line {
    display: flex;
    flex-direction: column;
    align-items: stretch;
  }

  .metrics-inline {
    justify-content: flex-start;
  }

  .print-document {
    padding: 18px;
  }

  body {
    font-size: 12px;
  }
}

@media print {
  html,
  body {
    background: #fff !important;
  }

  .no-print,
  dialog,
  .topbar,
  .statusline,
  .work-view {
    display: none !important;
  }

  .app-shell {
    width: 100%;
    margin: 0;
    padding: 0;
  }

  .print-view {
    display: block !important;
  }

  .print-document {
    max-width: none;
    margin: 0;
    padding: 0;
    border: 0;
    box-shadow: none;
  }

  .print-document section {
    page-break-inside: avoid;
  }

  .print-table tr {
    page-break-inside: avoid;
  }
}


.monthly-advances,
.dialog-details {
  margin-top: 8px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--panel-soft);
}

.monthly-advances summary,
.dialog-details summary {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
  padding: 7px 8px;
  cursor: pointer;
  font-weight: 800;
}

.monthly-advances summary strong {
  font-variant-numeric: tabular-nums;
}

.monthly-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(105px, 1fr));
  gap: 7px;
  padding: 8px;
  border-top: 1px solid var(--line-soft);
}

.monthly-field {
  display: grid;
  gap: 3px;
}

.monthly-field span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}

.monthly-field input {
  min-height: 30px;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.dialog-monthly-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

@media (max-width: 900px) {
  .monthly-grid,
  .dialog-monthly-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 520px) {
  .monthly-grid,
  .dialog-monthly-grid {
    grid-template-columns: 1fr;
  }
}


.quantity-total-field {
  display: none;
}


/* Deutlichere Summenzeile in 03 · Betriebskosten */
.data-table tfoot tr {
  border-top: 2px solid var(--primary);
}

.data-table tfoot th,
.data-table tfoot td {
  font-size: 13px;
  font-weight: 900;
  color: var(--text);
  background: var(--primary-soft);
}

.data-table tfoot th:first-child {
  letter-spacing: .01em;
}

.data-table tfoot .num {
  font-size: 14px;
  font-weight: 950;
}


/* Kopfsteuerung für Zeitraum und Modus */
.controlbar {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: flex-end;
  align-items: end;
}

.period-picker {
  display: grid;
  gap: 3px;
  min-width: 190px;
}

.period-picker span,
.mode-toggle > span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
}

.period-picker select {
  min-height: 30px;
  padding: 5px 7px;
}

.mode-toggle {
  display: flex;
  gap: 4px;
  align-items: end;
  margin-left: 4px;
}

.mode-toggle > span {
  align-self: center;
  margin-right: 2px;
}

.mode-btn {
  min-height: 30px;
  padding: 0 9px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  color: var(--text);
  background: var(--panel-soft);
  cursor: pointer;
  font-weight: 800;
}

.mode-btn.active {
  color: #fff;
  border-color: var(--primary-dark);
  background: var(--primary-dark);
}

[data-theme="dark"] .mode-btn.active {
  color: #0b1724;
}

.landlord-only {
  display: none;
}

body[data-mode="landlord"] .landlord-only {
  display: block;
}

body[data-mode="landlord"] #settlementTitle::after {
  content: " · ausgewählte Wohnung";
  color: var(--muted);
  font-weight: 500;
}

@media (max-width: 1280px) {
  .topbar {
    grid-template-columns: 1fr;
  }

  .controlbar {
    justify-content: flex-start;
  }
}

@media (max-width: 680px) {
  .controlbar,
  .mode-toggle {
    align-items: stretch;
  }

  .period-picker {
    min-width: 0;
    width: 100%;
  }
}


/* v9 Kopfbereich und Analytics */
.brand-compact {
  min-width: 0;
  width: auto;
}

.brand-compact .brand-logo {
  width: 34px;
  height: 34px;
}

.period-picker-inline {
  display: flex;
  flex-direction: row;
  gap: 7px;
  align-items: center;
  min-width: 235px;
}

.period-picker-inline span {
  margin-top: 0;
}

.period-picker-inline select {
  min-width: 170px;
}

.title-block p {
  font-weight: 800;
  color: var(--primary);
}

.analytics-panel {
  background:
    linear-gradient(180deg, color-mix(in srgb, var(--panel) 92%, var(--primary-soft)), var(--panel));
}

.analytics-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(280px, .65fr);
  gap: 10px;
}

.analytics-card {
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: linear-gradient(180deg, var(--panel), var(--panel-soft));
  box-shadow: 0 8px 22px rgba(25, 43, 70, .06);
  min-width: 0;
}

.analytics-card.wide {
  grid-column: 1 / -1;
}

.analytics-card-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: baseline;
  margin-bottom: 8px;
}

.analytics-card h3 {
  margin: 0;
  font-size: .98rem;
  letter-spacing: -.02em;
}

.analytics-card p {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
}

.analytics-card canvas {
  display: block;
  width: 100%;
  height: auto;
  max-height: 320px;
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-sm);
  background: color-mix(in srgb, var(--panel) 94%, var(--primary-soft));
}

.analytics-empty {
  display: grid;
  place-items: center;
  min-height: 180px;
  color: var(--muted);
  border: 1px dashed var(--line);
  border-radius: var(--radius-sm);
  background: var(--panel-soft);
}

@supports not (color: color-mix(in srgb, white, black)) {
  .analytics-panel,
  .analytics-card,
  .analytics-card canvas {
    background: var(--panel);
  }
}

@media (max-width: 980px) {
  .analytics-grid {
    grid-template-columns: 1fr;
  }

  .analytics-card.wide {
    grid-column: auto;
  }

  .analytics-card-head {
    flex-direction: column;
    align-items: flex-start;
  }

  .period-picker-inline {
    width: 100%;
  }

  .period-picker-inline select {
    flex: 1;
    min-width: 0;
  }
}

.brand {
  min-width: 0;
}

.brand-textless {
  min-width: 0;
}


.controlbar .btn.danger {
  color: var(--danger);
  border-color: rgba(183, 56, 56, .42);
  background: var(--danger-soft);
}

.controlbar .btn.danger:hover {
  border-color: var(--danger);
}


.analytics-panel-head {
  align-items: center;
}

.analytics-actions {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 6px;
  margin-left: auto;
}

.analytics-content[hidden] {
  display: none !important;
}

#analyticsParetoChart {
  max-height: 420px;
}

@media (max-width: 680px) {
  .analytics-panel-head {
    align-items: stretch;
  }

  .analytics-actions {
    justify-content: space-between;
    margin-left: 0;
  }
}


/* v13 · Velum-/los-chronos-Logo im flatcost-Kopfbereich */
.brand {
  display: flex;
  align-items: center;
  gap: 9px;
  padding-right: 6px;
  min-width: 0;
  color: inherit;
  text-decoration: none;
}

.brand-compact {
  width: auto;
  min-width: 0;
}

.brand-logo {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: auto;
  height: auto;
  min-width: 0;
  padding: 0;
  line-height: 0;
  border-radius: 8px;
  background: transparent;
  box-shadow: 0 2px 8px rgba(0, 0, 0, .22);
  overflow: hidden;
}

.brand-logo svg {
  display: block;
  width: 28px;
  height: 28px;
  border-radius: 8px;
}

.brand-logo:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, .26);
}

.brand-logo:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 3px;
}


/* v14 · Logo sauber, größer, ohne Wackeln und ohne hellen Außenrahmen */
.topbar .brand-compact {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding-right: 0;
}

.topbar .brand-logo {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  padding: 0;
  margin: 0;
  border: 0;
  outline: 0;
  border-radius: 9px;
  background: transparent !important;
  box-shadow: none !important;
  overflow: visible;
  line-height: 0;
  transform: none !important;
  transition: none !important;
}

.topbar .brand-logo svg {
  display: block;
  width: 34px;
  height: 34px;
  border-radius: 9px;
  background: transparent;
  box-shadow: 0 2px 8px rgba(0, 0, 0, .22);
}

.topbar .brand-logo:hover,
.topbar .brand-logo:active,
.topbar .brand-logo:focus {
  transform: none !important;
  box-shadow: none !important;
  background: transparent !important;
}

.topbar .brand-logo:hover svg {
  transform: none !important;
}


/* v15 · bessere Lesbarkeit der Analytics-Diagramme */
.analytics-card canvas {
  min-height: 260px;
}

#analyticsParetoChart {
  min-height: 430px;
  max-height: 520px;
}

#analyticsLineChart {
  min-height: 290px;
}

#analyticsDonutChart {
  min-height: 290px;
}

@media (max-width: 760px) {
  #analyticsParetoChart {
    min-height: 500px;
  }
}


/* v16 · edlere Diagrammoptik und bessere Pareto-Beschriftung */
.analytics-card {
  border-color: color-mix(in srgb, var(--line) 82%, var(--primary));
  box-shadow: 0 10px 28px rgba(25, 43, 70, .08);
}

.analytics-card canvas {
  border-color: color-mix(in srgb, var(--line) 78%, var(--primary));
  box-shadow: inset 0 1px 0 rgba(255,255,255,.28);
}

#analyticsParetoChart {
  min-height: 390px;
  max-height: 455px;
}

@media (max-width: 760px) {
  #analyticsParetoChart {
    min-height: 455px;
  }
}


/* v17 · schwarze feinere Konturen und mehr Unterraum im Pareto-Diagramm */
#analyticsParetoChart {
  min-height: 430px;
  max-height: 500px;
}

@media (max-width: 760px) {
  #analyticsParetoChart {
    min-height: 500px;
  }
}


/* v19 · Sortierfelder rechts neben 03 Betriebskosten */
.cost-panel-head {
  align-items: center;
}

.cost-head-actions {
  display: flex;
  justify-content: flex-end;
  align-items: end;
  gap: 7px;
  margin-left: auto;
  flex-wrap: wrap;
}

.cost-head-actions .button-group {
  align-items: end;
}

.mini-filter {
  display: grid;
  gap: 3px;
  min-width: 140px;
}

.mini-filter span {
  font-size: 11px;
  font-weight: 800;
  color: var(--muted);
}

.mini-filter select {
  min-height: 30px;
  padding: 5px 7px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--panel-soft);
  color: var(--text);
  font: inherit;
  font-size: 12px;
}

@media (max-width: 920px) {
  .cost-panel-head {
    align-items: stretch;
  }

  .cost-head-actions {
    justify-content: stretch;
    margin-left: 0;
  }

  .mini-filter {
    min-width: 0;
    flex: 1 1 145px;
  }

  .cost-head-actions .button-group {
    flex: 1 1 230px;
  }
}


/* v24 · Analytics: Abrechnungsergebnis je Zeitraum */
.analytics-result-table .result-negative {
  color: var(--danger);
  font-weight: 900;
}

.analytics-result-table .result-positive {
  color: var(--success);
  font-weight: 900;
}

.analytics-result-table .result-neutral,
.analytics-result-table .muted-result {
  color: var(--muted);
  font-weight: 800;
}

.analytics-result-table .result-negative span,
.analytics-result-table .result-positive span,
.analytics-result-table .result-neutral span {
  font-weight: 800;
  opacity: .9;
  margin-left: 4px;
}


/* v26 · Analytics: Kostensteigerung */
.cost-increase-head {
  align-items: center;
}

.cost-increase-head .btn {
  margin-left: auto;
}

.cost-increase-content[hidden] {
  display: none !important;
}

.cost-compare-controls {
  display: grid;
  grid-template-columns: minmax(180px, 260px) minmax(180px, 260px);
  gap: 8px;
  margin: 4px 0 10px;
}

.compact-field {
  margin: 0;
}

.cost-increase-table th,
.cost-increase-table td {
  white-space: nowrap;
}

.cost-increase-table .result-negative {
  color: var(--danger);
  font-weight: 900;
}

.cost-increase-table .result-positive {
  color: var(--success);
  font-weight: 900;
}

.cost-increase-table .result-neutral {
  color: var(--muted);
  font-weight: 800;
}

.cost-increase-table .result-negative span,
.cost-increase-table .result-positive span,
.cost-increase-table .result-neutral span {
  font-weight: 800;
  opacity: .9;
  margin-left: 4px;
}

.cost-increase-table tfoot th,
.cost-increase-table tfoot td {
  font-size: 13px;
  font-weight: 950;
}

@media (max-width: 760px) {
  .cost-compare-controls {
    grid-template-columns: 1fr;
  }
}


/* v27 · Veränderungswerte exakt rechtsbündig untereinander */
.cost-increase-table td.result-negative,
.cost-increase-table td.result-positive,
.cost-increase-table td.result-neutral {
  text-align: right;
}

.cost-increase-table .change-cell {
  display: inline-grid;
  grid-template-columns: minmax(86px, auto) minmax(74px, auto);
  column-gap: 10px;
  justify-content: end;
  align-items: baseline;
  min-width: 178px;
}

.cost-increase-table .change-amount,
.cost-increase-table .change-percent {
  display: block;
  text-align: right;
  white-space: nowrap;
}

.cost-increase-table .change-percent {
  font-weight: 800;
  opacity: .9;
}

.cost-increase-table .result-negative span.change-percent,
.cost-increase-table .result-positive span.change-percent,
.cost-increase-table .result-neutral span.change-percent {
  margin-left: 0;
}

@media (max-width: 760px) {
  .cost-increase-table .change-cell {
    min-width: 155px;
    grid-template-columns: minmax(74px, auto) minmax(63px, auto);
    column-gap: 8px;
  }
}


/* v28 · iPad-Optimierung -------------------------------------------------- */
/* Gute Bedienbarkeit bei 768–1180 px Breite, ohne Desktop-Layout zu verschlechtern. */

@media (hover: none) and (pointer: coarse) {
  button,
  select,
  input,
  textarea,
  summary,
  .icon-btn,
  .btn,
  .mode-btn {
    min-height: 38px;
  }

  .icon-btn {
    min-width: 38px;
  }

  input,
  select,
  textarea {
    font-size: 16px; /* verhindert iOS-Zoom beim Fokussieren */
  }
}

@media (min-width: 700px) and (max-width: 1180px) {
  body {
    overflow-x: hidden;
  }

  .app-shell,
  .app {
    max-width: 100%;
  }

  .topbar {
    grid-template-columns: auto minmax(180px, 1fr);
    gap: 10px;
    align-items: center;
  }

  .topbar .toolbar,
  .topbar .controlbar,
  .controlbar {
    grid-column: 1 / -1;
    justify-content: flex-start;
    width: 100%;
  }

  .controlbar {
    display: grid;
    grid-template-columns: minmax(220px, 1fr) auto auto auto minmax(210px, auto);
    align-items: end;
    gap: 8px;
  }

  .period-picker-inline {
    width: 100%;
    min-width: 0;
  }

  .period-picker-inline select {
    width: 100%;
  }

  .mode-toggle {
    justify-content: flex-end;
  }

  .toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
  }

  .toolbar .btn,
  .toolbar label.btn {
    flex: 0 0 auto;
  }

  .object-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .object-grid .field:first-child,
  .object-grid .field:nth-child(2) {
    grid-column: auto;
  }

  .metrics {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .cost-panel-head,
  .analytics-panel-head,
  .panel-head {
    gap: 10px;
  }

  .cost-head-actions {
    width: 100%;
    justify-content: flex-start;
  }

  .mini-filter {
    min-width: 165px;
  }

  .analytics-grid {
    grid-template-columns: 1fr;
  }

  .analytics-card,
  .analytics-card.wide {
    grid-column: auto;
  }

  .analytics-card-head {
    align-items: flex-start;
  }

  .analytics-card canvas {
    max-width: 100%;
  }

  #analyticsLineChart,
  #analyticsDonutChart {
    min-height: 285px;
  }

  #analyticsParetoChart {
    min-height: 470px;
    max-height: 540px;
  }

  .cost-compare-controls {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
  }

  .data-table {
    min-width: 760px;
  }

  .cost-increase-table {
    min-width: 1180px;
  }

  .analytics-result-table {
    min-width: 860px;
  }

  .cost-increase-table .change-cell {
    min-width: 180px;
  }

  dialog {
    width: min(720px, calc(100vw - 32px));
    max-height: calc(100dvh - 34px);
  }

  .dialog-grid,
  .unit-form-grid,
  .cost-form-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (min-width: 700px) and (max-width: 900px) {
  .topbar {
    grid-template-columns: auto 1fr;
  }

  .controlbar {
    grid-template-columns: minmax(0, 1fr) auto auto auto;
  }

  .mode-toggle {
    grid-column: 1 / -1;
    justify-content: flex-start;
    margin-left: 0;
  }

  .period-picker-inline {
    justify-content: flex-start;
  }

  .object-grid {
    grid-template-columns: 1fr 1fr;
  }

  .metrics {
    grid-template-columns: 1fr;
  }

  .cost-head-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .cost-head-actions .button-group {
    grid-column: 1 / -1;
    justify-content: flex-start;
  }

  .analytics-actions {
    width: 100%;
    justify-content: space-between;
  }

  .cost-increase-head {
    gap: 8px;
  }

  .cost-increase-head .btn {
    margin-left: 0;
  }
}

/* iPad Hochformat: Panels und Kopfbereiche entspannen */
@media (min-width: 700px) and (max-width: 850px) and (orientation: portrait) {
  .topbar {
    position: static;
  }

  .panel,
  .analytics-card {
    border-radius: 12px;
  }

  .panel-head,
  .analytics-card-head {
    flex-direction: column;
    align-items: stretch;
  }

  .panel-head h2,
  .analytics-card h3 {
    line-height: 1.25;
  }

  .button-group,
  .analytics-actions {
    justify-content: flex-start;
  }

  .cost-compare-controls {
    grid-template-columns: 1fr;
  }

  .dialog-grid,
  .unit-form-grid,
  .cost-form-grid {
    grid-template-columns: 1fr;
  }
}

/* iPad Landscape: breitere Diagramme nutzen, Tabellen scrollen nur im Tabellenbereich */
@media (min-width: 901px) and (max-width: 1180px) and (orientation: landscape) {
  .analytics-grid {
    grid-template-columns: minmax(0, 1.05fr) minmax(300px, .95fr);
  }

  .analytics-card.wide {
    grid-column: 1 / -1;
  }

  .object-grid {
    grid-template-columns: 1.1fr 1.5fr .8fr .8fr .8fr;
  }
}


/* v29 · iPad-Kopfbereich neu geordnet ------------------------------------ */
/* Ziel: keine isolierte Logo-Zeile; klare Reihenfolge Logo/Titel + Steuerung + Aktionen. */

@media (min-width: 700px) and (max-width: 1180px) {
  .topbar {
    display: grid;
    grid-template-columns: auto minmax(180px, 1fr) auto;
    grid-template-areas:
      "brand title toolbar"
      "controls controls controls";
    align-items: center;
    gap: 10px 12px;
    padding: 10px;
  }

  .topbar .brand {
    grid-area: brand;
    justify-self: start;
  }

  .topbar .title-block {
    grid-area: title;
    justify-self: start;
    min-width: 0;
  }

  .topbar .title-block h1 {
    white-space: nowrap;
  }

  .topbar .title-block p {
    margin-top: 2px;
  }

  .topbar .toolbar {
    grid-area: toolbar;
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 6px;
    width: auto;
    min-width: 0;
  }

  .topbar .toolbar .btn,
  .topbar .toolbar label.btn {
    min-height: 34px;
    padding-inline: 9px;
  }

  .topbar .controlbar {
    grid-area: controls;
    display: grid;
    grid-template-columns: minmax(260px, 1fr) auto auto auto minmax(210px, auto);
    align-items: end;
    gap: 8px;
    width: 100%;
    justify-content: stretch;
    padding-top: 4px;
    border-top: 1px solid var(--line-soft);
  }

  .period-picker-inline {
    width: 100%;
    min-width: 0;
  }

  .period-picker-inline select {
    width: 100%;
  }

  .mode-toggle {
    justify-content: end;
    margin-left: 0;
  }
}

/* iPad Hochformat: keine Logo-Solo-Zeile; Titel steht neben Logo */
@media (min-width: 700px) and (max-width: 900px) {
  .topbar {
    grid-template-columns: auto minmax(140px, 1fr);
    grid-template-areas:
      "brand title"
      "controls controls"
      "toolbar toolbar";
  }

  .topbar .brand {
    justify-self: start;
  }

  .topbar .title-block {
    justify-self: start;
  }

  .topbar .toolbar {
    justify-content: flex-start;
    width: 100%;
    padding-top: 2px;
  }

  .topbar .controlbar {
    grid-template-columns: minmax(0, 1fr) auto auto auto;
    padding-top: 8px;
  }

  .topbar .controlbar .mode-toggle {
    grid-column: 1 / -1;
    justify-content: flex-start;
    padding-top: 2px;
  }

  .period-picker-inline {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    align-items: center;
  }
}

/* iPad Hochformat knapp: Aktionsbuttons als ordentliche Werkzeugleiste */
@media (min-width: 700px) and (max-width: 820px) and (orientation: portrait) {
  .topbar {
    gap: 9px;
  }

  .topbar .toolbar {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 7px;
  }

  .topbar .toolbar .btn,
  .topbar .toolbar label.btn {
    width: 100%;
    justify-content: center;
  }

  .topbar .controlbar {
    grid-template-columns: minmax(0, 1fr) auto auto auto;
  }

  .topbar .controlbar > .btn {
    min-width: 42px;
  }

  .topbar .controlbar #duplicatePeriodBtn,
  .topbar .controlbar #deletePeriodBtn {
    min-width: 92px;
  }
}

/* iPad Querformat: kompakte Kopfzeile plus Steuerleiste */
@media (min-width: 901px) and (max-width: 1180px) and (orientation: landscape) {
  .topbar {
    grid-template-columns: auto minmax(150px, .7fr) minmax(520px, 1.6fr);
    grid-template-areas:
      "brand title toolbar"
      "controls controls controls";
  }

  .topbar .toolbar {
    flex-wrap: nowrap;
  }

  .topbar .toolbar .btn,
  .topbar .toolbar label.btn {
    font-size: 12px;
  }

  .topbar .controlbar {
    grid-template-columns: minmax(300px, 1fr) auto auto auto minmax(230px, auto);
  }
}


/* v30 · kleiner Zwischenraum zwischen Zeitraum-von und Zeitraum-bis */
.date-from-field {
  margin-right: 4px;
}

.date-to-field {
  margin-left: 4px;
}

@media (max-width: 900px) {
  .date-from-field,
  .date-to-field {
    margin-left: 0;
    margin-right: 0;
  }

  .object-grid {
    column-gap: 12px;
    row-gap: 9px;
  }
}

@media (min-width: 901px) {
  .object-grid {
    column-gap: 12px;
  }
}


/* v31 · iPad: Kopfbereich kompakter + Datumsfelder bleiben im Panel */

/* Auf iPad sollen die erklärenden Labels im Kopfbereich nicht zusätzlich Platz verbrauchen. */
@media (min-width: 700px) and (max-width: 1180px) {
  .controlbar .period-picker-inline > span,
  .controlbar .mode-toggle > span {
    display: none;
  }

  .controlbar .period-picker-inline {
    display: block;
  }

  .controlbar .period-picker-inline select {
    width: 100%;
  }

  .controlbar .mode-toggle {
    align-items: stretch;
  }

  .controlbar .mode-btn {
    min-width: 92px;
  }

  /* Wichtig: Das Objekt-Grid darf nie breiter als das Panel werden. */
  .object-grid {
    width: 100%;
    max-width: 100%;
    overflow: hidden;
  }

  .object-grid > .field {
    min-width: 0;
  }

  .object-grid input,
  .object-grid textarea,
  .object-grid select {
    min-width: 0;
    max-width: 100%;
  }

  /* Die vorherige Margin-Lösung konnte das letzte Datumsfeld rechts herausdrücken. */
  .date-from-field,
  .date-to-field {
    margin-left: 0 !important;
    margin-right: 0 !important;
  }
}

/* iPad Querformat: Datumsfelder erhalten Platz, ohne den rechten Rand zu sprengen. */
@media (min-width: 901px) and (max-width: 1180px) and (orientation: landscape) {
  .object-grid {
    grid-template-columns:
      minmax(150px, .9fr)
      minmax(260px, 1.6fr)
      minmax(120px, .75fr)
      minmax(135px, .8fr)
      minmax(135px, .8fr);
    column-gap: 10px;
  }
}

/* iPad Hochformat: Zeitraum von/bis sauber zweispaltig, nicht überstehend. */
@media (min-width: 700px) and (max-width: 900px) {
  .object-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    column-gap: 10px;
    row-gap: 9px;
  }

  .object-grid .address-field {
    grid-column: 1 / -1;
  }

  .date-from-field,
  .date-to-field {
    grid-column: auto;
  }
}

/* Sehr schmales iPad-Hochformat: Datumsfelder untereinander statt gequetscht. */
@media (min-width: 700px) and (max-width: 760px) and (orientation: portrait) {
  .object-grid {
    grid-template-columns: 1fr;
  }

  .object-grid .field,
  .object-grid .address-field,
  .date-from-field,
  .date-to-field {
    grid-column: 1 / -1;
  }
}


/* v32 · iPad Querformat / Touch-Geräte: Zeitraum- und Modus-Label zuverlässig ausblenden */
/* Nicht nur nach Breite, sondern zusätzlich nach Touch-Bedienung. */

@media (hover: none) and (pointer: coarse) {
  .controlbar .period-picker-inline > span,
  .controlbar .mode-toggle > span {
    display: none !important;
  }

  .controlbar .period-picker-inline {
    display: block !important;
  }

  .controlbar .period-picker-inline select {
    width: 100%;
  }

  .controlbar .mode-toggle {
    margin-left: 0;
  }
}

/* Breitere iPad-/Tablet-Queransichten, z. B. iPad Pro, zusätzlich abdecken. */
@media (min-width: 700px) and (max-width: 1400px) {
  .controlbar .period-picker-inline > span,
  .controlbar .mode-toggle > span {
    display: none !important;
  }

  .controlbar .period-picker-inline {
    display: block !important;
  }

  .controlbar .period-picker-inline select {
    width: 100%;
  }
}

/* Für breite iPad-Queransichten die Steuerleiste weiter sauber halten. */
@media (min-width: 1181px) and (max-width: 1400px) and (hover: none) and (pointer: coarse) {
  .topbar {
    display: grid;
    grid-template-columns: auto minmax(150px, .65fr) minmax(520px, 1.6fr);
    grid-template-areas:
      "brand title toolbar"
      "controls controls controls";
    gap: 10px 12px;
    align-items: center;
  }

  .topbar .brand {
    grid-area: brand;
    justify-self: start;
  }

  .topbar .title-block {
    grid-area: title;
    justify-self: start;
    min-width: 0;
  }

  .topbar .toolbar {
    grid-area: toolbar;
    justify-content: flex-end;
    flex-wrap: nowrap;
    width: auto;
  }

  .topbar .controlbar {
    grid-area: controls;
    display: grid;
    grid-template-columns: minmax(320px, 1fr) auto auto auto minmax(230px, auto);
    align-items: end;
    gap: 8px;
    width: 100%;
    padding-top: 6px;
    border-top: 1px solid var(--line-soft);
  }

  .controlbar .mode-toggle {
    justify-content: flex-end;
  }
}


/* v33 · iPad: Objekt-/Zeitraum-Grid endgültig innerhalb des Panels halten */
/* Das letzte Datumsfeld darf nicht mehr rechts aus 01 · Objekt & Zeitraum herauslaufen. */

@media (min-width: 700px) and (max-width: 1400px) {
  .compact-panel,
  #objectTitle,
  #objectTitle + .metrics-inline,
  .object-grid {
    min-width: 0;
  }

  .object-grid {
    display: grid;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    overflow: visible;
    gap: 9px 10px;
  }

  .object-grid > .field {
    min-width: 0;
    max-width: 100%;
    box-sizing: border-box;
  }

  .object-grid input,
  .object-grid textarea,
  .object-grid select {
    width: 100%;
    min-width: 0;
    max-width: 100%;
    box-sizing: border-box;
  }

  .date-from-field,
  .date-to-field {
    margin: 0 !important;
    min-width: 0;
  }
}

/* iPad Querformat: lieber etwas schmalere, aber sichere Spalten. */
@media (min-width: 901px) and (max-width: 1400px) and (hover: none) and (pointer: coarse) {
  .object-grid {
    grid-template-columns:
      minmax(130px, .85fr)
      minmax(220px, 1.55fr)
      minmax(105px, .7fr)
      minmax(118px, .78fr)
      minmax(118px, .78fr) !important;
  }
}

/* Falls der Platz dennoch knapp wird: Datumsfelder gemeinsam in eine zweite Zeile. */
@media (min-width: 901px) and (max-width: 1120px) and (hover: none) and (pointer: coarse) {
  .object-grid {
    grid-template-columns:
      minmax(140px, .9fr)
      minmax(260px, 1.6fr)
      minmax(120px, .8fr)
      minmax(150px, 1fr)
      minmax(150px, 1fr) !important;
  }
}

/* iPad Hochformat: Adresse über volle Breite, Daten sauber zweispaltig. */
@media (min-width: 700px) and (max-width: 900px) and (hover: none) and (pointer: coarse) {
  .object-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  }

  .object-grid .address-field {
    grid-column: 1 / -1;
  }

  .date-from-field,
  .date-to-field {
    grid-column: auto;
  }
}

/* Sehr knappe iPad-Breiten: alle Felder untereinander, dafür ohne Überstand. */
@media (min-width: 700px) and (max-width: 760px) and (hover: none) and (pointer: coarse) {
  .object-grid {
    grid-template-columns: 1fr !important;
  }

  .object-grid > .field,
  .object-grid .address-field,
  .date-from-field,
  .date-to-field {
    grid-column: 1 / -1 !important;
  }
}


/* v34 · iPad Queransicht: 01 · Objekt & Zeitraum in klare Zeilen aufteilen */
/*
  Zeile 1: Name Zeitraum | Objektadresse
  Zeile 2: Gesamtwohnfläche | Zeitraum von | Zeitraum bis
  Dadurch kann "Zeitraum bis" nicht mehr rechts aus dem Panel laufen.
*/
@media (min-width: 901px) and (max-width: 1400px) and (orientation: landscape) and (hover: none) and (pointer: coarse) {
  .object-grid {
    grid-template-columns: repeat(6, minmax(0, 1fr)) !important;
    gap: 10px 12px !important;
    width: 100%;
    max-width: 100%;
    overflow: visible;
  }

  /* 1. Feld: Name Zeitraum */
  .object-grid > .field:nth-child(1) {
    grid-column: 1 / 3;
  }

  /* 2. Feld: Objektadresse */
  .object-grid > .field:nth-child(2),
  .object-grid > .address-field {
    grid-column: 3 / 7;
  }

  /* 3. Feld: Gesamtwohnfläche */
  .object-grid > .field:nth-child(3) {
    grid-column: 1 / 3;
  }

  /* 4. Feld: Zeitraum von */
  .object-grid > .field:nth-child(4),
  .object-grid > .date-from-field {
    grid-column: 3 / 5;
  }

  /* 5. Feld: Zeitraum bis */
  .object-grid > .field:nth-child(5),
  .object-grid > .date-to-field {
    grid-column: 5 / 7;
  }

  .object-grid > .field,
  .object-grid input,
  .object-grid textarea,
  .object-grid select {
    min-width: 0;
    max-width: 100%;
    box-sizing: border-box;
  }

  .date-from-field,
  .date-to-field {
    margin: 0 !important;
  }
}

/* Falls ein iPad quer besonders knapp skaliert: dieselbe Logik mit etwas mehr vertikaler Luft. */
@media (min-width: 901px) and (max-width: 1100px) and (orientation: landscape) and (hover: none) and (pointer: coarse) {
  .object-grid {
    grid-template-columns: repeat(6, minmax(0, 1fr)) !important;
    row-gap: 11px !important;
  }

  .object-grid > .field:nth-child(1) {
    grid-column: 1 / 3;
  }

  .object-grid > .field:nth-child(2),
  .object-grid > .address-field {
    grid-column: 3 / 7;
  }

  .object-grid > .field:nth-child(3) {
    grid-column: 1 / 3;
  }

  .object-grid > .field:nth-child(4),
  .object-grid > .date-from-field {
    grid-column: 3 / 5;
  }

  .object-grid > .field:nth-child(5),
  .object-grid > .date-to-field {
    grid-column: 5 / 7;
  }
}


/* v35 · iPad Queransicht: Datumsfelder bewusst schmaler und rechter Sicherheitsrand */
/*
  Zeile 1: Name Zeitraum | Objektadresse
  Zeile 2: Gesamtwohnfläche | Zeitraum von | Zeitraum bis | Sicherheitsraum
  Damit "Zeitraum bis" nicht mehr nach rechts übersteht.
*/
@media (min-width: 901px) and (max-width: 1400px) and (orientation: landscape) and (hover: none) and (pointer: coarse) {
  .object-grid {
    grid-template-columns: repeat(12, minmax(0, 1fr)) !important;
    gap: 10px 10px !important;
    width: 100%;
    max-width: 100%;
    overflow: hidden;
    box-sizing: border-box;
    padding-right: 2px;
  }

  /* Zeile 1 */
  .object-grid > .field:nth-child(1) {
    grid-column: 1 / 4 !important;
  }

  .object-grid > .field:nth-child(2),
  .object-grid > .address-field {
    grid-column: 4 / 13 !important;
  }

  /* Zeile 2: bewusst schmaler. Rechts bleiben zwei Spalten Luft. */
  .object-grid > .field:nth-child(3) {
    grid-column: 1 / 4 !important;
  }

  .object-grid > .field:nth-child(4),
  .object-grid > .date-from-field {
    grid-column: 4 / 7 !important;
  }

  .object-grid > .field:nth-child(5),
  .object-grid > .date-to-field {
    grid-column: 7 / 10 !important;
  }

  .object-grid > .field,
  .object-grid input,
  .object-grid textarea,
  .object-grid select {
    min-width: 0 !important;
    max-width: 100% !important;
    width: 100% !important;
    box-sizing: border-box !important;
  }

  .date-from-field,
  .date-to-field {
    margin: 0 !important;
  }
}

/* Bei besonders breiter iPad-Queransicht darf die Adresse mehr Platz bekommen, die Datumsfelder bleiben trotzdem kompakt. */
@media (min-width: 1181px) and (max-width: 1400px) and (orientation: landscape) and (hover: none) and (pointer: coarse) {
  .object-grid > .field:nth-child(1) {
    grid-column: 1 / 4 !important;
  }

  .object-grid > .field:nth-child(2),
  .object-grid > .address-field {
    grid-column: 4 / 13 !important;
  }

  .object-grid > .field:nth-child(3) {
    grid-column: 1 / 4 !important;
  }

  .object-grid > .field:nth-child(4),
  .object-grid > .date-from-field {
    grid-column: 4 / 7 !important;
  }

  .object-grid > .field:nth-child(5),
  .object-grid > .date-to-field {
    grid-column: 7 / 10 !important;
  }
}

/* Falls Safari das native date input breiter erzwingen will: hart begrenzen. */
@media (min-width: 901px) and (max-width: 1400px) and (orientation: landscape) and (hover: none) and (pointer: coarse) {
  .date-from-field input[type="date"],
  .date-to-field input[type="date"] {
    width: 100% !important;
    min-width: 0 !important;
    max-width: 100% !important;
    appearance: none;
    -webkit-appearance: none;
  }
}


/* Personenanteile am Abrechnungsergebnis */
.settlement-selects {
  display: grid;
  gap: 7px;
  min-width: min(100%, 430px);
}

.person-share-box {
  margin-top: 8px;
}

.person-share-head {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  align-items: center;
  margin-bottom: 5px;
}

.person-share-head h3 {
  margin: 0;
  font-size: .92rem;
}

.person-share-box dl {
  display: grid;
  gap: 2px;
  margin: 0;
}

.person-share-box dl div {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  padding: 4px 0;
  border-top: 1px solid var(--line-soft);
}

.person-share-box dt {
  color: var(--muted);
}

.person-share-box dd {
  margin: 0;
  font-weight: 750;
  text-align: right;
}

.dialog-help {
  margin: 0;
  padding: 0 8px 8px;
  color: var(--muted);
  font-size: 12px;
}

.person-share-dialog-list {
  display: grid;
  gap: 7px;
  padding: 0 8px 8px;
}

.person-share-dialog-row {
  display: grid;
  grid-template-columns: minmax(160px, 1.2fr) minmax(130px, .8fr) minmax(130px, .8fr) auto;
  gap: 7px;
  align-items: end;
  padding: 8px;
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-sm);
  background: var(--panel);
}

.person-share-dialog-row .icon-btn {
  margin-bottom: 0;
}

.person-share-details > .btn {
  margin: 0 8px 8px;
}

#unitPersonShareRows:empty::before {
  content: "Noch keine Person angelegt.";
  display: block;
  padding: 7px 8px;
  border: 1px dashed var(--line);
  border-radius: var(--radius-sm);
  color: var(--muted);
  background: var(--panel-soft);
}

@media (max-width: 680px) {
  .settlement-selects,
  .select-line {
    min-width: 0;
    width: 100%;
  }

  .person-share-dialog-row {
    grid-template-columns: 1fr;
  }
}
