:root {
  --bg: #0d0f14;
  --surface: #161920;
  --surface-alt: #1d2130;
  --border: #2a2f42;
  --accent: #3b82f6;
  --accent-hover: #2563eb;
  --accent-green: #22c55e;
  --accent-orange: #f97316;
  --text: #e8ecf4;
  --muted: #9ab0cc;
  --danger: #ef4444;
  --success: #22c55e;
  --radius: 10px;
  --shadow: 0 2px 16px rgba(0,0,0,.45);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 15px;
  line-height: 1.65;
  min-height: 100vh;
  overflow-x: hidden;
  word-break: break-word;
  overflow-wrap: break-word;
}

/* Safe area insets for notched phones (iPhone X+) */
.header { padding-left: env(safe-area-inset-left); padding-right: env(safe-area-inset-right); }
footer  { padding-left: env(safe-area-inset-left); padding-right: env(safe-area-inset-right); padding-bottom: calc(24px + env(safe-area-inset-bottom)); }

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── Layout ── */
.container { max-width: 1200px; margin: 0 auto; padding: 0 16px; }
@media (min-width: 640px) { .container { padding: 0 24px; } }

/* ── Header ── */
.header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
  backdrop-filter: blur(8px);
}

.nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 56px;
  gap: 12px;
  position: relative;
}
@media (min-width: 769px) { .nav { height: 60px; } }

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 1.05rem;
  color: var(--text);
  text-decoration: none;
  flex-shrink: 0;
}
@media (min-width: 640px) { .brand { font-size: 1.1rem; } }

.brand-mark {
  width: 34px; height: 34px;
  background: var(--accent);
  border-radius: 8px;
  display: grid;
  place-items: center;
  font-weight: 900;
  font-size: 1rem;
  color: #fff;
  flex-shrink: 0;
}
@media (min-width: 640px) { .brand-mark { width: 36px; height: 36px; font-size: 1.1rem; } }

/* Mobile nav — hidden by default, shown when .open */
.nav nav {
  display: none;
  position: absolute;
  top: 100%;
  left: -16px;
  right: -16px;
  background: var(--surface);
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  padding: 8px 16px 12px;
  flex-direction: column;
  gap: 0;
  z-index: 200;
  box-shadow: var(--shadow);
}
.nav nav.open { display: flex; }
.nav nav a {
  color: var(--muted);
  font-size: .9rem;
  font-weight: 500;
  padding: 10px 4px;
  border-bottom: 1px solid var(--border);
  transition: color .15s;
  text-decoration: none;
}
.nav nav a:last-child { border-bottom: none; }
.nav nav a:hover, .nav nav a[style*="color:var(--accent)"] { color: var(--accent); }

/* Desktop nav — inline flex */
@media (min-width: 769px) {
  .nav nav {
    display: flex !important;
    position: static;
    flex-direction: row;
    background: none;
    border: none;
    padding: 0;
    gap: 20px;
    box-shadow: none;
  }
  .nav nav a { padding: 0; border-bottom: none; font-size: .875rem; }
}

/* Hamburger button */
.hamburger {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  cursor: pointer;
  padding: 8px;
  border: none;
  background: none;
  color: var(--text);
  min-width: 40px;
  min-height: 40px;
  border-radius: 6px;
  flex-shrink: 0;
}
.hamburger:hover { background: var(--surface-alt); }
.hamburger span {
  display: block;
  width: 22px;
  height: 2px;
  background: var(--text);
  border-radius: 2px;
  transition: transform .2s, opacity .2s;
}
.hamburger.active span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.hamburger.active span:nth-child(2) { opacity: 0; }
.hamburger.active span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }
@media (min-width: 769px) { .hamburger { display: none; } }

/* ── Cards ── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
}
@media (min-width: 640px) { .card { padding: 24px; } }

.cards {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
}
@media (min-width: 600px) { .cards { grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 18px; } }

/* ── Section head ── */
.section-head { padding: 24px 0 14px; }
@media (min-width: 640px) { .section-head { padding: 32px 0 18px; } }
.section-head h1, .section-head h2 { font-size: 1.4rem; font-weight: 700; margin-bottom: 6px; line-height: 1.25; }
@media (min-width: 640px) { .section-head h1, .section-head h2 { font-size: 1.75rem; } }
.section-head p { color: var(--muted); max-width: 640px; font-size: .9rem; }
@media (min-width: 640px) { .section-head p { font-size: 1rem; } }

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 18px;
  border-radius: 7px;
  font-size: .875rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: background .2s, opacity .2s;
  text-decoration: none;
  min-height: 42px;
  touch-action: manipulation;
}
.btn:hover { opacity: .9; text-decoration: none; }
.btn-primary  { background: var(--accent); color: #fff; }
.btn-secondary { background: var(--surface-alt); color: var(--text); border: 1px solid var(--border); }
.btn-danger   { background: var(--danger); color: #fff; }
.btn-success  { background: var(--success); color: #fff; }
.btn-sm { padding: 6px 13px; font-size: .8rem; min-height: 34px; }

.cta-row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-top: 14px; }

/* ── Forms ── */
.field { display: flex; flex-direction: column; gap: 5px; }
label { font-size: .8rem; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.field-hint { font-size: .75rem; color: var(--muted); margin-top: 2px; }

input, select, textarea {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 7px;
  color: var(--text);
  padding: 10px 13px;
  font-size: .95rem;
  font-family: inherit;
  width: 100%;
  transition: border-color .2s;
  min-height: 42px;
  touch-action: manipulation;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
}
textarea { resize: vertical; min-height: 100px; }

/* ── Table ── */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.data-table { width: 100%; border-collapse: collapse; font-size: .875rem; min-width: 500px; }
.data-table th, .data-table td { padding: 10px 14px; text-align: left; border-bottom: 1px solid var(--border); }
.data-table th { color: var(--muted); font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; white-space: nowrap; }
.data-table tbody tr:hover { background: var(--surface-alt); }

/* ── Badges ── */
.badge {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 99px;
  font-size: .72rem;
  font-weight: 700;
  letter-spacing: .03em;
  text-transform: uppercase;
}
.badge-green  { background: rgba(34,197,94,.15); color: var(--success); }
.badge-blue   { background: rgba(59,130,246,.15); color: var(--accent); }
.badge-orange { background: rgba(249,115,22,.15); color: var(--accent-orange); }
.badge-red    { background: rgba(239,68,68,.15); color: var(--danger); }
.badge-gray   { background: rgba(124,138,170,.15); color: var(--muted); }

/* ── Stats ── */
.stats { display: flex; gap: 12px; flex-wrap: wrap; padding: 14px 0; }
@media (min-width: 640px) { .stats { gap: 16px; padding: 18px 0; } }
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 18px;
  min-width: 120px;
  flex: 1;
}
@media (min-width: 640px) { .stat-card { padding: 16px 24px; min-width: 140px; } }
.stat-value { font-size: 1.6rem; font-weight: 800; line-height: 1; }
@media (min-width: 640px) { .stat-value { font-size: 2rem; } }
.stat-label { font-size: .75rem; color: var(--muted); margin-top: 4px; text-transform: uppercase; letter-spacing: .04em; }

/* ── Listing grid ── */
.listing-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
  padding: 14px 0;
}
@media (min-width: 640px) { .listing-grid { grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 18px; padding: 18px 0; } }

.listing-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  transition: border-color .2s;
}
@media (min-width: 640px) { .listing-card { padding: 20px; } }
.listing-card:hover { border-color: var(--accent); }
.listing-card h3 { font-size: 1rem; font-weight: 700; margin-bottom: 4px; }
.listing-card .meta { font-size: .8rem; color: var(--muted); margin-bottom: 10px; }
.listing-card .details { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; font-size: .82rem; margin-bottom: 12px; }
.listing-card .details span { color: var(--muted); }

.ai-score {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: .78rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 99px;
  background: rgba(59,130,246,.12);
  color: var(--accent);
}
.ai-score.high { background: rgba(34,197,94,.12); color: var(--success); }

/* ── Hero ── */
.hero { padding: 40px 0 28px; text-align: center; }
@media (min-width: 640px) { .hero { padding: 72px 0 48px; } }
.hero h1 { font-size: clamp(1.7rem, 5vw, 3.2rem); font-weight: 900; line-height: 1.15; margin-bottom: 14px; }
@media (min-width: 640px) { .hero h1 { margin-bottom: 18px; } }
.hero p { font-size: 1rem; color: var(--muted); max-width: 600px; margin: 0 auto 22px; }
@media (min-width: 640px) { .hero p { font-size: 1.1rem; margin: 0 auto 28px; } }

.hero-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 24px;
  align-items: center;
  padding: 24px 0;
}
@media (min-width: 720px) { .hero-grid { grid-template-columns: 1fr 1fr; gap: 40px; padding: 40px 0; } }

/* ── Map placeholder ── */
.map-placeholder {
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  height: 300px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  font-size: .9rem;
  position: relative;
  overflow: hidden;
}
@media (min-width: 640px) { .map-placeholder { height: 460px; } }

/* ── Filters ── */
.filters {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
  margin-bottom: 14px;
}
@media (min-width: 640px) { .filters { gap: 10px; padding: 16px 0; margin-bottom: 18px; } }
.filters select { width: auto; min-width: 130px; }
@media (max-width: 480px) { .filters { flex-direction: column; } .filters select { width: 100%; min-width: unset; } }

/* ── Search / form grid ── */
.search-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}
@media (min-width: 600px) { .search-grid { grid-template-columns: 1fr 1fr; gap: 14px; } }

/* ── Report grid ── */
.report-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}
@media (min-width: 600px) { .report-grid { grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 14px; } }

/* ── Value items ── */
.value-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  font-size: .875rem;
}
.value-item strong { display: block; margin-bottom: 4px; }

/* ── Alert boxes ── */
.alert {
  border-radius: var(--radius);
  padding: 12px 16px;
  font-size: .875rem;
  margin-bottom: 14px;
}
.alert-success { background: rgba(34,197,94,.1); border: 1px solid rgba(34,197,94,.3); color: var(--success); }
.alert-error   { background: rgba(239,68,68,.1);  border: 1px solid rgba(239,68,68,.3);  color: var(--danger); }
.alert-info    { background: rgba(59,130,246,.1); border: 1px solid rgba(59,130,246,.3); color: var(--accent); }

/* ── Rules box ── */
.rules-box {
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  font-size: .875rem;
}
@media (min-width: 640px) { .rules-box { padding: 16px 20px; } }

/* ── Muted text ── */
.muted-text { color: var(--muted); font-size: .85rem; }

/* ── Footer ── */
footer {
  border-top: 1px solid var(--border);
  margin-top: 40px;
  padding: 24px 0;
  text-align: center;
  color: var(--muted);
  font-size: .82rem;
}
@media (min-width: 640px) { footer { margin-top: 60px; padding: 32px 0; } }

/* ── Status dots ── */
.status-dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  display: inline-block;
  margin-right: 6px;
}
.status-dot.green  { background: var(--success); }
.status-dot.red    { background: var(--danger); }
.status-dot.yellow { background: var(--accent-orange); }

/* ── Utility ── */
.hide-sm { display: none; }
@media (min-width: 640px) { .hide-sm { display: revert; } }

.text-center { text-align: center; }
.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.mt-3 { margin-top: 24px; }
.gap-row { display: flex; gap: 10px; flex-wrap: wrap; }

/* ── Mobile-only utilities ── */
@media (max-width: 600px) {
  .btn-block-sm { width: 100%; justify-content: center; }
  .cta-row { flex-direction: column; }
  .cta-row .btn { width: 100%; justify-content: center; }
  .data-table th, .data-table td { padding: 8px 10px; font-size: .8rem; }
  h1 { line-height: 1.2; }
  h2 { line-height: 1.25; }
  .card { padding: 14px; }
  .stat-card { min-width: unset; }
}
