.entity-grid {
  display: grid;
  grid-template-columns: minmax(320px, 420px) minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}

.entity-form-card {
  position: sticky;
  top: 16px;
}

.entity-main-column {
  display: grid;
  min-width: 0;
  gap: 16px;
}

.property-map-card {
  display: grid;
  gap: 12px;
  padding: 16px;
}

.property-map-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.property-map-header h2 {
  margin: 0;
  color: var(--text);
  font-size: 18px;
  line-height: 1.2;
}

.property-map-header p {
  margin: 5px 0 0;
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 700;
}

.property-map-header span {
  flex: 0 0 auto;
  padding: 5px 9px;
  border-radius: 999px;
  background: var(--primary-soft);
  color: var(--primary);
  font-size: 12px;
  font-weight: 900;
}

.properties-map-shell {
  position: relative;
}

.properties-map {
  height: 320px;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-muted);
}

.properties-map-empty {
  position: absolute;
  inset: 14px;
  display: grid;
  place-items: center;
  padding: 18px;
  border: 1px dashed var(--border);
  border-radius: 8px;
  background: rgba(248, 250, 252, 0.92);
  color: var(--text-muted);
  font-weight: 900;
  text-align: center;
  pointer-events: none;
}

.property-map-marker {
  border: 0;
  background: transparent;
  color: var(--primary);
}

.property-map-marker svg,
.property-location-marker svg {
  display: block;
  width: 100%;
  height: 100%;
  overflow: visible;
  filter: drop-shadow(0 8px 10px rgba(91, 77, 245, 0.26));
}

.property-map-marker path,
.property-location-marker path {
  fill: currentColor;
  stroke: #fff;
  stroke-width: 2.4;
  stroke-linejoin: round;
}

.property-map-marker circle,
.property-location-marker circle {
  fill: #fff;
}

.property-map-marker-dolu {
  color: var(--success);
}

.property-map-marker-satilik {
  color: var(--amber);
}

.property-map-popup {
  display: grid;
  min-width: 220px;
  gap: 5px;
}

.property-map-popup strong {
  color: #0f172a;
  font-size: 14px;
  line-height: 1.25;
}

.property-map-popup span {
  color: #64748b;
  font-size: 12px;
  font-weight: 700;
  line-height: 1.35;
}

.property-map-popup div {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 4px;
}

.property-map-popup em {
  color: #0f172a;
  font-style: normal;
  font-weight: 900;
}

.property-map-popup .btn {
  min-height: 32px;
  padding: 0 10px;
  border-radius: 8px;
  font-size: 12px;
}

.property-table-tools {
  display: grid;
  grid-template-columns: minmax(240px, 1fr) minmax(120px, 150px) minmax(130px, 150px) minmax(130px, 150px) auto auto;
  gap: 10px;
  align-items: center;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

.property-search-field {
  min-width: 0;
}

.property-table-tools .input,
.property-table-tools .select {
  min-height: 42px;
}

.property-table-tools .btn {
  min-height: 42px;
  padding: 0 14px;
  white-space: nowrap;
}

.property-table-tools [data-properties-result-count] {
  min-width: 88px;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 900;
  text-align: right;
  white-space: nowrap;
}

.property-location-cell {
  display: flex;
  min-width: 0;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}

.property-location-cell > span:first-child {
  min-width: 0;
}

.location-missing-badge {
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  min-height: 22px;
  padding: 3px 8px;
  border-radius: 999px;
  background: #fff7ed;
  color: #ea580c;
  font-size: 11px;
  font-weight: 900;
  line-height: 1;
}

.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 14px;
}

.form-message {
  min-height: 20px;
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 700;
}

.details-panel {
  display: grid;
  gap: 12px;
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

.details-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.details-panel-header h3 {
  margin: 0;
  color: var(--text);
  font-size: 15px;
  line-height: 1.25;
}

.details-panel-header span {
  padding: 4px 8px;
  border-radius: 999px;
  background: var(--primary-soft);
  color: var(--primary);
  font-size: 12px;
  font-weight: 800;
}

.details-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.location-picker {
  display: grid;
  gap: 10px;
  margin-top: 14px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

.location-picker-header,
.location-picker-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.location-picker-header h3 {
  margin: 0;
  color: var(--text);
  font-size: 15px;
  line-height: 1.25;
}

.location-picker-header p,
.location-picker-footer span {
  margin: 3px 0 0;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 800;
  line-height: 1.35;
}

.location-picker-header p.is-success {
  color: var(--success);
}

.location-picker-header p.is-error {
  color: var(--danger);
}

.location-picker-header p.is-warning {
  color: var(--amber);
}

.location-picker .btn {
  min-height: 38px;
  white-space: nowrap;
}

.location-map {
  height: 230px;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-muted);
}

.property-location-marker {
  border: 0;
  background: transparent;
  color: var(--primary);
}

.leaflet-container {
  color: #0f172a;
  font: inherit;
}

.check-field {
  display: flex;
  min-height: 40px;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text-muted);
  font-weight: 800;
}

.check-field input {
  width: 16px;
  height: 16px;
  accent-color: var(--primary);
}

.form-message.is-success {
  color: var(--success);
}

.form-message.is-error {
  color: var(--danger);
}

.table-empty {
  padding: 28px 14px;
  color: var(--text-muted);
  text-align: center;
}

.cell-title {
  display: grid;
  gap: 2px;
}

.cell-title strong {
  font-size: 14px;
}

.cell-title span {
  color: var(--text-muted);
  font-size: 12px;
}

.table-actions {
  display: flex;
  justify-content: flex-end;
}

.tenant-row,
.property-row,
.contract-row {
  cursor: pointer;
}

.tenant-row:hover td,
.tenant-row:focus-visible td,
.property-row:hover td,
.property-row:focus-visible td,
.contract-row:hover td,
.contract-row:focus-visible td {
  background: #f8fafc;
}

.detail-open {
  overflow: hidden;
}

.detail-overlay {
  position: fixed;
  z-index: 2000;
  inset: 0;
  display: flex;
  justify-content: flex-end;
  background: rgba(15, 23, 42, 0.5);
}

.detail-overlay[hidden] {
  display: none;
}

.detail-panel {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-rows: auto 1fr;
  width: min(680px, 92vw);
  height: 100vh;
  background: var(--surface);
  box-shadow: -18px 0 42px rgba(15, 23, 42, 0.18);
}

.detail-panel-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 22px;
  border-bottom: 1px solid var(--border);
}

.detail-panel-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.detail-panel-header h2 {
  margin: 2px 0 0;
  font-size: 22px;
  line-height: 1.15;
}

.detail-kicker {
  margin: 0;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.detail-panel-body {
  display: grid;
  align-content: start;
  gap: 16px;
  overflow-y: auto;
  padding: 18px 22px 0;
}

.detail-loading,
.detail-empty {
  padding: 18px;
  border: 1px dashed var(--border);
  border-radius: 8px;
  color: var(--text-muted);
  background: var(--surface-muted);
}

.detail-hero {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-muted);
}

.detail-avatar {
  display: grid;
  width: 46px;
  height: 46px;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 999px;
  background: linear-gradient(135deg, #5b4df5, #7c3aed);
  color: #fff;
  font-weight: 900;
}

.detail-hero h3 {
  margin: 0;
  font-size: 18px;
}

.detail-hero p {
  margin: 2px 0 0;
  color: var(--text-muted);
  font-weight: 800;
}

.detail-section {
  display: grid;
  gap: 10px;
}

.detail-section h4 {
  margin: 0;
  font-size: 15px;
}

.detail-section-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.detail-info-grid,
.detail-stat-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.detail-info-item {
  display: grid;
  gap: 3px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
}

.detail-info-item span {
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

.detail-info-item strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.detail-note {
  min-height: 74px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  white-space: pre-wrap;
}

.detail-edit-form {
  display: grid;
  gap: 14px;
}

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

.detail-edit-notes {
  min-height: 110px;
}

.detail-warning {
  padding: 12px;
  border: 1px solid #fde68a;
  border-radius: 8px;
  background: #fffbeb;
  color: #92400e;
  font-size: 13px;
  font-weight: 800;
  line-height: 1.4;
}

.detail-warning-danger {
  border-color: #fecaca;
  background: #fef2f2;
  color: #b91c1c;
}

.contract-action-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-muted);
}

.contract-action-summary span {
  color: var(--text-muted);
  font-weight: 800;
}

.contract-payment-preview {
  display: grid;
  max-height: 460px;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: auto;
}

.contract-payment-preview-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
}

.contract-payment-preview-row:last-child {
  border-bottom: 0;
}

.contract-payment-preview-row div {
  display: grid;
  gap: 2px;
}

.contract-payment-preview-row span {
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 800;
}

.contract-payment-more {
  padding: 11px 12px;
  border-top: 1px dashed var(--border);
  background: var(--surface-muted);
  color: var(--text-muted);
  font-weight: 900;
  text-align: center;
}

.contract-extend-options {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.contract-extend-options .btn {
  min-height: 40px;
  padding: 0 10px;
  white-space: nowrap;
}

.detail-edit-bar {
  position: sticky;
  bottom: 0;
  display: grid;
  grid-template-columns: 1fr minmax(124px, auto) minmax(144px, auto);
  gap: 12px;
  align-items: center;
  margin: 14px -22px 0;
  padding: 18px 22px 22px;
  border-top: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.98);
  box-shadow: 0 -18px 30px rgba(15, 23, 42, 0.1);
}

.detail-edit-bar .btn {
  min-height: 52px;
  padding: 0 24px;
  border-radius: 10px;
  font-size: 16px;
  font-weight: 900;
}

.detail-edit-message {
  min-height: 20px;
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 800;
}

.detail-edit-message.is-error {
  color: var(--danger);
}

.detail-edit-message.is-success {
  color: var(--success);
}

.detail-rental-card {
  display: grid;
  gap: 3px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #f8fafc;
}

.detail-rental-card span {
  color: var(--text-muted);
}

.detail-payment-list,
.detail-contract-list {
  display: grid;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}

.detail-payment-row,
.detail-contract-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 11px 12px;
  border-bottom: 1px solid var(--border);
}

.detail-payment-row:last-child,
.detail-contract-row:last-child {
  border-bottom: 0;
}

.detail-payment-row div span,
.detail-contract-row div span {
  color: var(--text-muted);
}

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

  .entity-form-card {
    position: static;
  }

  .property-table-tools {
    grid-template-columns: minmax(220px, 1fr) repeat(3, minmax(120px, 1fr)) auto;
  }

  .property-table-tools [data-properties-result-count] {
    grid-column: 1 / -1;
    text-align: left;
  }
}

@media (max-width: 720px) {
  .property-map-header {
    align-items: stretch;
    flex-direction: column;
  }

  .properties-map {
    height: 260px;
  }

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

  .property-table-tools .btn,
  .property-table-tools [data-properties-result-count] {
    width: 100%;
    text-align: center;
  }

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

  .location-picker-header,
  .location-picker-footer {
    align-items: stretch;
    flex-direction: column;
  }

  .location-picker .btn {
    width: 100%;
  }

  .detail-info-grid,
  .detail-stat-grid,
  .detail-edit-grid {
    grid-template-columns: 1fr;
  }

  .detail-edit-bar {
    grid-template-columns: 1fr;
  }

  .detail-edit-bar .btn {
    width: 100%;
  }

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

}
