:root {
  color-scheme: light;
  --bg: #f6f7f9;
  --panel: #ffffff;
  --ink: #18202a;
  --muted: #667085;
  --line: #d9dee7;
  --accent: #0f766e;
  --accent-strong: #0b5d57;
  --select: #e8f4f2;
  --shadow: 0 10px 28px rgba(16, 24, 40, 0.10);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
select {
  font: inherit;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 22px 12px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
}

h1 {
  margin: 0;
  font-size: 24px;
  line-height: 1.2;
  letter-spacing: 0;
}

#app-subtitle {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.view-switcher {
  display: inline-flex;
  gap: 4px;
  padding: 4px;
  background: #eef1f5;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.view-button,
.secondary-button,
.primary-button,
.icon-button {
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel);
  color: var(--ink);
  cursor: pointer;
}

.view-button {
  padding: 0 12px;
}

.view-button.is-active,
.primary-button {
  border-color: var(--accent);
  background: var(--accent);
  color: #ffffff;
}

.secondary-button,
.primary-button {
  padding: 0 14px;
}

.controls {
  display: grid;
  grid-template-columns: minmax(210px, 2fr) repeat(4, minmax(110px, 1fr)) auto auto auto auto auto;
  gap: 10px;
  padding: 14px 22px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
}

.controls label {
  display: grid;
  gap: 4px;
}

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

.controls input[type="search"],
.controls input[type="number"],
.controls select {
  width: 100%;
  min-height: 36px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #ffffff;
  color: var(--ink);
}

.check-control {
  align-content: end;
  grid-auto-flow: column;
  align-items: center;
  justify-content: start;
  gap: 8px;
  min-height: 58px;
}

.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 10px;
  padding: 12px 22px;
}

.stat {
  min-width: 0;
  padding: 10px 12px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.stat strong {
  display: block;
  font-size: 18px;
  line-height: 1.2;
  overflow: hidden;
  text-overflow: ellipsis;
}

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

.layout {
  display: grid;
  gap: 12px;
  padding: 0 22px 22px;
  min-height: calc(100vh - 190px);
}

.layout.is-split {
  grid-template-columns: minmax(520px, 1.1fr) minmax(380px, 0.9fr);
}

.layout.is-table,
.layout.is-map,
.layout.is-cards {
  grid-template-columns: 1fr;
}

.panel {
  min-width: 0;
  min-height: 420px;
  overflow: hidden;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.layout.is-table .map-panel,
.layout.is-table .cards-panel,
.layout.is-map .table-panel,
.layout.is-map .cards-panel,
.layout.is-cards .table-panel,
.layout.is-cards .map-panel,
.layout.is-split .cards-panel {
  display: none;
}

.table-scroll {
  height: 100%;
  overflow: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: #eef1f5;
  border-bottom: 1px solid var(--line);
}

th,
td {
  padding: 9px 10px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  white-space: nowrap;
}

th button {
  border: 0;
  background: transparent;
  color: var(--ink);
  cursor: pointer;
  padding: 0;
  font-weight: 700;
}

td.numeric {
  text-align: right;
}

tr {
  cursor: pointer;
}

tr.is-selected {
  background: var(--select);
  outline: 2px solid rgba(15, 118, 110, 0.35);
}

.feedback-actions {
  display: inline-flex;
  gap: 4px;
  align-items: center;
}

.feedback-button {
  min-width: 42px;
  min-height: 28px;
  padding: 0 8px;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: #ffffff;
  color: var(--muted);
}

.feedback-button.is-on {
  border-color: var(--accent);
  background: var(--select);
  color: var(--accent);
}

tr.is-liked,
.property-card.is-liked {
  box-shadow: inset 3px 0 0 var(--accent);
}

tr.is-disliked,
.property-card.is-disliked {
  opacity: 0.68;
}

.comment-flag {
  display: inline-block;
  margin-left: 6px;
  padding: 1px 5px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  font-size: 11px;
}

#map {
  width: 100%;
  height: 100%;
  min-height: 520px;
}

#cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 12px;
  padding: 12px;
}

.property-card {
  display: grid;
  gap: 8px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  cursor: pointer;
}

.property-card.is-selected {
  border-color: var(--accent);
  box-shadow: var(--shadow);
}

.card-title {
  font-weight: 700;
}

.card-meta {
  color: var(--muted);
  font-size: 13px;
}

.detail-panel {
  position: fixed;
  right: 18px;
  bottom: 18px;
  width: min(420px, calc(100vw - 36px));
  max-height: calc(100vh - 36px);
  overflow: auto;
  padding: 18px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  transform: translateY(16px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 160ms ease, transform 160ms ease;
  z-index: 1000;
}

.detail-panel.is-open {
  transform: translateY(0);
  opacity: 1;
  pointer-events: auto;
}

.icon-button {
  float: right;
  width: 30px;
  min-height: 30px;
}

.detail-panel h2 {
  margin: 0 38px 6px 0;
  font-size: 19px;
}

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

.detail-item {
  padding: 9px;
  background: #f7f8fa;
  border-radius: 6px;
}

.detail-item span {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.detail-item strong {
  display: block;
  margin-top: 2px;
}

.detail-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 12px 0;
}

.comment-box {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.comment-box textarea {
  min-height: 92px;
  resize: vertical;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  font: inherit;
}

.listing-link {
  color: var(--accent-strong);
  font-weight: 700;
}

.pin {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border: 2px solid #ffffff;
  border-radius: 999px;
  background: var(--accent);
  color: #ffffff;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.24);
  font-size: 11px;
  font-weight: 700;
}

.pin.is-liked {
  background: #be123c;
}

.pin.is-disliked {
  background: #6b7280;
}

.pin.is-selected {
  width: 36px;
  height: 36px;
  background: #1f2937;
}

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

  .topbar {
    align-items: stretch;
  }

  .view-switcher {
    justify-content: stretch;
  }

  .view-button {
    flex: 1;
  }

  .controls {
    display: grid;
    padding: 12px;
  }

  .stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    padding: 12px;
  }

  .layout,
  .layout.is-split {
    grid-template-columns: 1fr;
    padding: 0 12px 12px;
  }

  .layout.is-split .table-panel,
  .layout.is-split .map-panel {
    min-height: 360px;
  }
}
