:root {
  --primary: #2D4A3E;
  --bg: #F0F5F2;
  --accent: #4A8C6F;
  --accent-hover: #3d7a5f;
  --text: #1A1A1A;
  --text2: #6B7280;
  --white: #FFFFFF;
  --border: #d1d5db;
  --error: #DC2626;
  --success: #16A34A;
  --shadow: 0 2px 8px rgba(0,0,0,0.08);
  --shadow-hover: 0 4px 16px rgba(0,0,0,0.12);
  --radius: 10px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

/* Hero */
.hero {
  background: linear-gradient(135deg, var(--primary) 0%, #1a3028 100%);
  color: var(--white);
  padding: 50px 20px 40px;
  text-align: center;
}
.hero h1 { font-size: 2.4em; margin-bottom: 6px; letter-spacing: -0.5px; }
.hero p { font-size: 1.05em; opacity: 0.8; margin-bottom: 28px; }

.search-box {
  max-width: 620px;
  margin: 0 auto;
  display: flex;
  gap: 8px;
}
.search-box input {
  flex: 1;
  padding: 14px 18px;
  border: none;
  border-radius: var(--radius);
  font-size: 16px;
  outline: none;
  transition: box-shadow 0.2s;
}
.search-box input:focus { box-shadow: 0 0 0 3px rgba(74,140,111,0.3); }
.search-box button {
  padding: 14px 28px;
  background: var(--accent);
  color: var(--white);
  border: none;
  border-radius: var(--radius);
  font-size: 16px;
  cursor: pointer;
  font-weight: 600;
  transition: background 0.2s;
}
.search-box button:hover { background: var(--accent-hover); }

.filters {
  max-width: 820px;
  margin: 18px auto 0;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: center;
}
.filters select,
.filters input[type=number] {
  padding: 9px 12px;
  border: 1px solid rgba(255,255,255,0.2);
  border-radius: 6px;
  font-size: 13px;
  background: rgba(255,255,255,0.12);
  color: var(--white);
  outline: none;
  transition: background 0.2s;
}
.filters select:focus,
.filters input[type=number]:focus {
  background: rgba(255,255,255,0.2);
}
.filters select option { color: var(--text); background: var(--white); }
.filters input::placeholder { color: rgba(255,255,255,0.5); }

/* Results */
.results {
  max-width: 1060px;
  margin: 0 auto;
  padding: 30px 20px 40px;
}
.results-header {
  display: flex;
  align-items: baseline;
  gap: 12px;
  margin-bottom: 20px;
}
.results-header h2 { color: var(--primary); font-size: 1.3em; }
.results-count { font-size: 0.9em; color: var(--text2); }

.status {
  text-align: center;
  padding: 50px;
  color: var(--text2);
  font-size: 1.05em;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(310px, 1fr));
  gap: 20px;
}

/* Card */
.card {
  background: var(--white);
  border-radius: 12px;
  overflow: hidden;
  box-shadow: var(--shadow);
  transition: transform 0.2s, box-shadow 0.2s;
  cursor: pointer;
}
.card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-hover);
}
.card-img {
  height: 200px;
  background: #e5e7eb;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text2);
  font-size: 14px;
  position: relative;
}
.card-img img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.card-badge {
  position: absolute;
  top: 10px;
  left: 10px;
  padding: 3px 10px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
}
.badge-sale { background: var(--accent); color: var(--white); }
.badge-rent { background: #2563eb; color: var(--white); }

.card-body { padding: 16px; }
.card-body h3 { font-size: 1.05em; margin-bottom: 6px; line-height: 1.3; }
.card-price {
  font-size: 1.3em;
  font-weight: 700;
  color: var(--accent);
  margin-bottom: 8px;
}
.card-price .negotiable {
  font-size: 0.6em;
  font-weight: 400;
  color: var(--text2);
  margin-left: 6px;
}
.card-meta {
  font-size: 0.85em;
  color: var(--text2);
  display: flex;
  flex-wrap: wrap;
  gap: 4px 14px;
}
.card-location {
  font-size: 0.85em;
  color: var(--text2);
  margin-top: 6px;
}

/* Pagination */
.pagination {
  display: flex;
  justify-content: center;
  gap: 6px;
  margin-top: 30px;
}
.pagination button {
  padding: 8px 14px;
  border: 1px solid var(--border);
  background: var(--white);
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
  transition: all 0.15s;
}
.pagination button:hover { border-color: var(--accent); color: var(--accent); }
.pagination button.active {
  background: var(--accent);
  color: var(--white);
  border-color: var(--accent);
}
.pagination button:disabled { opacity: 0.4; cursor: default; }

/* Modal */
.modal {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 1000;
  overflow-y: auto;
  padding: 40px 20px;
}
.modal.open { display: flex; align-items: flex-start; justify-content: center; }
.modal-content {
  background: var(--white);
  border-radius: 14px;
  max-width: 700px;
  width: 100%;
  position: relative;
  padding: 30px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.2);
}
.modal-close {
  position: absolute;
  top: 12px;
  right: 16px;
  font-size: 28px;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text2);
  line-height: 1;
}
.modal-close:hover { color: var(--text); }

.detail-title { font-size: 1.4em; margin-bottom: 8px; }
.detail-price { font-size: 1.6em; font-weight: 700; color: var(--accent); margin-bottom: 16px; }
.detail-section { margin-bottom: 16px; }
.detail-section h4 { color: var(--primary); margin-bottom: 6px; font-size: 0.95em; text-transform: uppercase; letter-spacing: 0.5px; }
.detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px 20px;
  font-size: 0.92em;
}
.detail-grid .label { color: var(--text2); }
.detail-grid .value { font-weight: 500; }
.detail-desc { font-size: 0.92em; line-height: 1.6; color: #374151; }
.detail-tags { display: flex; flex-wrap: wrap; gap: 6px; }
.detail-tag {
  padding: 3px 10px;
  background: var(--bg);
  border-radius: 4px;
  font-size: 0.82em;
  color: var(--primary);
}
.detail-poi { font-size: 0.88em; color: var(--text2); }
.detail-poi span { display: inline-block; margin-right: 14px; margin-bottom: 4px; }

/* Footer */
.footer {
  text-align: center;
  padding: 30px 20px;
  color: var(--text2);
  font-size: 0.85em;
  border-top: 1px solid #e5e7eb;
}
.footer a { color: var(--accent); text-decoration: none; }
.footer a:hover { text-decoration: underline; }
.footer-links { margin-top: 4px; }

/* API Status */
.api-status {
  position: fixed;
  bottom: 14px;
  right: 14px;
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 600;
  z-index: 100;
}
.api-ok { background: #dcfce7; color: var(--success); }
.api-err { background: #fee2e2; color: var(--error); }

/* Mobile */
@media (max-width: 640px) {
  .hero h1 { font-size: 1.8em; }
  .search-box { flex-direction: column; }
  .filters { gap: 6px; }
  .grid { grid-template-columns: 1fr; }
  .detail-grid { grid-template-columns: 1fr; }
  .modal-content { padding: 20px; }
}
