.properties-page {
  display: grid;
  gap: var(--space-12);
}

.properties-board {
  display: grid;
  gap: 16px;
}

.properties-filters {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding-bottom: 4px;
}

.properties-search {
  border: 1px solid var(--color-border);
  border-radius: var(--r-md);
  min-width: min(420px, 100%);
  width: 420px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: var(--search-padding-y) var(--search-padding-x);
  background: var(--color-surface);
}

.properties-search__icon {
  color: var(--color-gray-700);
  display: inline-flex;
}

.properties-search input {
  border: none;
  outline: none;
  width: 100%;
  font-size: var(--text-base4);
}

.properties-filter-selects {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.properties-create-form {
  display: grid;
  gap: 10px;
  padding-bottom: 4px;
}

.properties-create-grid {
  display: grid;
  gap: 10px;
  grid-template-columns: minmax(0, 1.15fr) minmax(0, 1.1fr) minmax(0, 0.95fr) minmax(0, 1fr) minmax(0, 0.72fr);
  align-items: start;
}

.properties-create-actions {
  display: flex;
  align-items: center;
  justify-content: flex-start;
}

.properties-create-code-field {
  position: relative;
  min-width: 0;
}

.properties-create-form .properties-create-code-field input {
  padding-right: 44px;
}

.properties-create-form .properties-create-code-field__help {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  width: 28px;
  height: 28px;
  border-radius: var(--r-sm);
  z-index: 1;
}

.properties-list {
  display: grid;
  gap: 8px;
}

.property-row {
  display: grid;
  grid-template-columns: 122px minmax(0, 1fr) 170px 170px;
  gap: 14px;
  padding: 16px;
  border: 1px solid var(--color-border-light);
  border-radius: var(--r-2xl);
  background: var(--color-surface);
}

.property-row img {
  width: 122px;
  height: 96px;
  object-fit: cover;
  border-radius: var(--r-xl);
}

.property-row__main {
  display: grid;
  gap: 6px;
  align-content: center;
}

.property-row__main h2 {
  font-size: var(--text-2xl2);
  letter-spacing: -0.02em;
}

.property-row__location {
  color: var(--color-gray-800);
}

.property-row__meta {
  color: var(--color-text-muted);
  font-size: var(--text-base2);
}

.property-row__meta span {
  margin: 0 6px;
}

.property-row__rent,
.property-row__status {
  display: grid;
  gap: 4px;
  align-content: center;
}

.property-row__rent span:first-child {
  color: var(--color-text-muted);
  font-size: var(--text-sm6);
}

.property-row__rent strong {
  font-size: var(--text-2xl3);
  letter-spacing: -0.02em;
}

.property-row__rent small,
.property-row__status small {
  color: var(--color-gray-700);
  font-size: var(--text-sm8);
}

.status-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 52px;
  padding: 6px 10px;
  border-radius: var(--r-full);
  font-size: var(--text-sm5);
  font-weight: 700;
}

.status-pill--active {
  color: var(--text-success);
  background: var(--bg-green-subtle);
}

.status-pill--inactive {
  color: var(--color-gray-800);
  background: var(--color-gray-150);
}

.properties-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: var(--color-gray-700);
  font-size: var(--text-base);
}

.properties-pagination {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.properties-pagination button {
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  color: var(--color-gray-900);
  border-radius: var(--r-sm);
  min-width: 32px;
  height: 32px;
  cursor: pointer;
}

.properties-pagination .is-active {
  color: var(--color-surface);
  background: var(--color-primary);
  border-color: var(--color-primary);
}

.property-detail-board {
  display: grid;
  gap: 18px;
  width: 100%;
  min-width: 0;
}

.property-detail-grid {
  display: grid;
  gap: 14px;
  grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr);
  align-items: start;
}

.property-archive-row {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 12px;
  flex-wrap: wrap;
}

.property-archive-form {
  display: flex;
  align-items: center;
  gap: 12px;
}

.property-delete-row {
  margin-top: -2px;
}

.property-card--units {
  min-width: 0;
}

.property-units-board__head {
  align-items: flex-start;
  padding-bottom: 10px;
}

.property-units-board__title {
  display: grid;
  gap: 4px;
}

.property-units-board__summary {
  margin: 0;
  color: var(--color-gray-700);
  font-size: var(--text-base2);
  max-width: 720px;
}

.property-units-board__toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  flex-wrap: wrap;
  padding: 0 0 12px;
  border-bottom: 1px solid var(--color-border-light);
}

.property-units-board__controls {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 10px;
}

.property-units-search {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: min(360px, 100%);
  width: 360px;
  padding: var(--search-padding-y) var(--search-padding-x);
  border: var(--search-border);
  border-radius: var(--search-radius);
  background: var(--search-bg);
}

.property-units-search__icon {
  display: inline-flex;
  color: var(--search-icon-color);
}

.property-units-search input {
  border: none;
  outline: none;
  width: 100%;
  padding: 0;
  background: transparent;
  color: var(--color-text);
  font-size: var(--search-font-size);
}

.property-units-filter-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.property-units-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 28px;
  padding: 0;
  border-bottom: none;
}

.property-units-tab,
.property-units-status-chip {
  appearance: none;
  -webkit-appearance: none;
  border: none !important;
  background: transparent !important;
  border-radius: 0;
  color: var(--color-gray-700);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  padding: 10px 0 14px;
  transition:
    color 140ms ease,
    background-color 140ms ease,
    box-shadow 140ms ease;
}

.property-units-tab strong,
.property-units-status-chip strong {
  font-size: var(--text-sm5);
}

.property-units-tab.is-active,
.property-units-status-chip.is-active {
  color: var(--color-primary);
  background: transparent !important;
  box-shadow: inset 0 -2px 0 var(--color-primary);
}

.property-units-filter-panel {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 12px;
  padding: 12px 14px;
  border: 1px solid var(--color-border-light);
  border-radius: var(--r-2xl);
  background: var(--bg-surface-subtle);
}

.property-units-filter-panel[hidden] {
  display: none;
}

.property-units-filter-panel__label {
  color: var(--color-gray-700);
  font-size: var(--text-sm5);
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.property-units-status-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.property-units-stack {
  margin-top: 16px;
  display: grid;
  gap: 16px;
  min-width: 0;
}

.property-units-stack > .panel-card {
  min-width: 0;
}

.property-units-table-wrap {
  overflow-x: auto;
  border: 1px solid var(--color-border-light);
  border-radius: var(--r-xl);
}

.property-units-table {
  min-width: 1260px;
  table-layout: fixed;
  font-size: var(--text-base);
}

.property-units-col--identity {
  width: 260px;
}

.property-units-col--floor {
  width: 104px;
}

.property-units-col--type {
  width: 124px;
}

.property-units-col--area {
  width: 100px;
}

.property-units-col--usable-area {
  width: 100px;
}

.property-units-col--rooms {
  width: 96px;
}

.property-units-col--share {
  width: 270px;
}

.property-units-col--nutzwert {
  width: 90px;
}

.property-units-col--status {
  width: 120px;
}

.property-units-col--action {
  width: 88px;
}

.property-units-table th,
.property-units-table td {
  vertical-align: top;
}

.property-units-table th {
  white-space: nowrap;
  font-size: var(--text-sm9);
}

.property-unit-row:hover {
  background: rgba(59, 130, 246, 0.02);
}

.property-units-table th,
.property-units-table td {
  padding-top: 16px;
  padding-bottom: 16px;
  padding-left: 14px;
  padding-right: 14px;
}

.property-unit-row td:first-child {
  min-width: 280px;
}

.property-unit-identity {
  display: grid;
  gap: 8px;
  min-width: 0;
}

.property-unit-identity__meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  color: var(--color-gray-700);
  font-size: var(--text-sm8);
}

.property-unit-building-part-select {
  min-width: 0;
  width: 118px;
}

.property-unit-identity__notes {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
}

.property-unit-identity__notes input {
  min-width: 0;
}

.property-units-table input,
.property-units-table select {
  border: none;
  background: transparent;
  border-radius: 0;
  box-sizing: border-box;
  box-shadow: none;
  padding: 2px 0;
  min-height: 30px;
  color: var(--color-gray-900);
  font-size: var(--text-base);
  line-height: 1.2;
}

.property-unit-metric-input {
  width: 96px;
  min-width: 0;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.property-unit-room-input,
.property-unit-nutzwert-input {
  width: 72px;
  min-width: 0;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.property-unit-floor-select {
  min-width: 0;
  width: 88px;
}

.property-unit-usage-select {
  min-width: 0;
  width: 112px;
}

.property-unit-cell--area,
.property-unit-cell--usable-area {
  padding-right: 10px;
}

.property-units-table input:hover,
.property-units-table select:hover {
  background: rgba(59, 130, 246, 0.03);
}

.property-units-table input:focus,
.property-units-table select:focus {
  border: none;
  box-shadow: inset 0 -2px 0 var(--color-primary);
  background: rgba(59, 130, 246, 0.04);
}

.property-unit-identity > input[name="unit_label"] {
  font-size: var(--text-base2);
  font-weight: 700;
}

.property-unit-identity__notes input {
  font-size: var(--text-sm9);
  color: var(--color-gray-700);
}

.unit-code-badge,
.unit-type-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--r-full);
  padding: 4px 10px;
  font-size: var(--text-sm3);
  font-weight: 700;
}

.unit-code-badge {
  background: var(--bg-blue-pale);
  color: var(--color-primary);
}

.unit-type-badge {
  background: var(--bg-surface-subtle);
  color: var(--color-gray-800);
}

.unit-type-badge--mieteinheiten {
  background: var(--bg-blue-pale);
  color: var(--color-primary);
}

.unit-type-badge--gewerbeeinheiten {
  background: var(--bg-orange-subtle);
  color: var(--text-amber);
}

.unit-type-badge--stellplaetze {
  background: var(--bg-green-subtle);
  color: var(--text-success-light);
}

.property-unit-share {
  display: flex;
  align-items: center;
  gap: 8px;
}

.property-unit-share input {
  max-width: 100%;
  min-width: 0;
}

.property-unit-status-select {
  min-width: 0;
  width: 96px;
  border-radius: var(--r-full);
  padding: 5px 8px;
  font-size: var(--text-sm3);
  font-weight: 700;
}

.property-unit-status-select--active {
  background: var(--bg-green-subtle);
  color: var(--text-success-light);
}

.property-unit-status-select--vacant {
  background: var(--bg-orange-subtle);
  color: var(--text-amber);
}

.property-unit-status-select--inactive {
  background: var(--color-gray-150);
  color: var(--color-gray-800);
}

.property-unit-action-cell {
  text-align: right;
  padding-right: 10px;
  vertical-align: middle;
}

.property-unit-action-cell .row-actions {
  justify-content: flex-end;
}

.js-unit-empty {
  margin: 0;
}

.property-units-stack > .panel-card .panel-card__head h2 {
  font-size: var(--text-xl3);
}

.property-unit-create-form {
  margin-top: 0.5rem;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 10px;
  align-items: end;
}

.property-unit-create-form input,
.property-unit-create-form select {
  width: 100%;
  min-width: 0;
}

.property-unit-create-form__field {
  display: grid;
  gap: 6px;
  min-width: 0;
}

.property-unit-create-form__field > span {
  color: var(--color-gray-700);
  font-size: var(--text-sm8);
  font-weight: 700;
}

.property-unit-create-form__field--wide {
  grid-column: 1 / -1;
}

.property-unit-create-form__preview input {
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  letter-spacing: 0.02em;
}

.property-unit-create-form__preview small {
  color: var(--color-gray-700);
  font-size: var(--text-sm8);
}

.property-unit-create-advanced {
  grid-column: 1 / -1;
  border: 1px solid var(--color-border-light);
  border-radius: var(--r-xl);
  padding: 10px 12px;
  background: var(--bg-surface-subtle);
}

.property-unit-create-advanced > summary {
  cursor: pointer;
  font-weight: 700;
  color: var(--color-gray-900);
  margin-bottom: 10px;
}

.property-unit-create-form button {
  grid-column: 1 / -1;
  justify-self: flex-start;
}

@media (max-width: 1499px) {
  .property-row {
    grid-template-columns: 108px minmax(0, 1fr) 150px 150px;
  }

  .property-row__main h2 {
    font-size: var(--text-xl2);
  }
}

@media (max-width: 1199px) {
  .property-row {
    grid-template-columns: 104px minmax(0, 1fr);
  }

  .property-row__rent,
  .property-row__status {
    grid-column: 1 / -1;
    padding-left: 2px;
  }

  .properties-footer {
    flex-wrap: wrap;
  }

  .property-units-board__controls {
    width: 100%;
    justify-content: flex-start;
  }

  .property-units-search {
    width: min(100%, 360px);
  }

  .property-units-table {
    min-width: 1180px;
  }
}

@media (max-width: 1199px) {
  .property-detail-grid {
    grid-template-columns: minmax(0, 1fr);
  }
}

@media (min-width: 1200px) {
  .property-detail-board {
    max-width: 1400px;
    margin: 0 auto;
  }

  .property-detail-grid {
    grid-template-columns: minmax(0, 760px) minmax(0, 620px);
    justify-content: center;
  }

  .property-detail-grid > .property-card {
    width: 100%;
    min-width: 0;
  }

  .property-card--master {
    max-width: 760px;
  }

  .property-card--analysis {
    max-width: 620px;
  }

  .property-card--units {
    max-width: 1400px;
  }

  .property-card--weg {
    max-width: 1400px;
  }
}

@media (max-width: 640px) {
  .properties-search {
    width: 100%;
    min-width: 0;
  }

  .property-row {
    grid-template-columns: 1fr;
  }

  .property-row img {
    width: 100%;
    height: auto;
    max-height: 220px;
  }

  .property-row__main h2 {
    font-size: var(--text-lg3);
  }

  .property-units-search {
    width: 100%;
    min-width: 0;
  }

  .property-unit-identity__notes {
    grid-template-columns: minmax(0, 1fr);
  }
}

.property-weg-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 16px;
  margin-bottom: 12px;
  color: var(--color-gray-800);
}

.property-weg-summary strong {
  color: var(--color-gray-900);
}

.property-weg-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 16px;
}

.property-weg-form {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 10px;
  align-items: end;
  margin-top: 8px;
}

.property-weg-form label {
  display: grid;
  gap: 6px;
}

.property-weg-form label > span {
  color: var(--color-gray-800);
  font-size: var(--text-sm8);
  font-weight: 700;
}

.property-weg-form input,
.property-weg-form select {
  width: 100%;
  min-width: 0;
}

.property-weg-form button {
  grid-column: 1 / -1;
  justify-self: flex-start;
}

.weg-hero-card {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(320px, 0.9fr);
  gap: 18px;
  align-items: stretch;
  background: linear-gradient(180deg, rgba(37, 99, 235, 0.06), rgba(255, 255, 255, 0));
}

.weg-hero-card__intro {
  display: grid;
  gap: 10px;
  align-content: start;
}

.weg-hero-card__eyebrow {
  color: var(--color-primary);
  font-size: var(--text-sm2);
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.weg-hero-card__intro h2 {
  font-size: var(--text-2xl2);
  letter-spacing: -0.02em;
}

.weg-hero-card__facts {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.weg-hero-card__fact {
  border: 1px solid var(--color-border-light);
  border-radius: var(--r-xl);
  background: var(--color-surface);
  padding: 12px 14px;
  display: grid;
  gap: 4px;
  min-width: 0;
}

.weg-hero-card__fact--wide {
  grid-column: 1 / -1;
}

.weg-hero-card__fact span {
  color: var(--color-gray-700);
  font-size: var(--text-sm8);
  font-weight: 700;
}

.weg-hero-card__fact strong {
  color: var(--color-gray-950);
  font-size: var(--text-lg4);
  line-height: 1.2;
  overflow-wrap: anywhere;
}

.weg-hero-card__fact small {
  color: var(--color-gray-700);
}

.weg-metrics {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin: 6px 0 16px;
}

.weg-metric {
  border: 1px solid var(--color-border-light);
  border-radius: var(--r-xl);
  background: var(--color-surface);
  padding: 12px 14px;
  display: grid;
  gap: 4px;
  min-width: 0;
}

.weg-metric span {
  color: var(--color-gray-700);
  font-size: var(--text-sm8);
  font-weight: 700;
}

.weg-metric strong {
  color: var(--color-gray-950);
  font-size: var(--text-xl2);
  line-height: 1;
  letter-spacing: -0.02em;
}

.weg-metric small {
  color: var(--color-gray-700);
}

.weg-section-card .panel-card__head {
  align-items: flex-start;
}

.weg-section-card .panel-card__summary {
  margin-top: 4px;
}

@media (max-width: 1199px) {
  .weg-hero-card {
    grid-template-columns: minmax(0, 1fr);
  }

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

@media (max-width: 640px) {
  .weg-hero-card__facts,
  .weg-metrics {
    grid-template-columns: minmax(0, 1fr);
  }
}
