:root {
  --bg: #0a0e14;
  --bg-alt: #111820;
  --surface: #161c26;
  --surface-hover: #1e2632;
  --border: #242d3a;
  --text: #e4e8ec;
  --text-secondary: #8b95a5;
  --muted: #5c6778;
  --accent: #1f8a5b;
  --accent-strong: #27ae6d;
  --accent-glow: rgba(31,138,91,0.25);
  --radius: 8px;
  --shadow: 0 2px 8px rgba(0,0,0,0.3);
}

* { box-sizing: border-box; }

html, body {
  margin: 0; height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--text); background: var(--bg);
}

a { color: var(--accent-strong); text-decoration: none; }
a:hover { color: #34d68a; }

/* ---- NAV ---- */
.nav-top {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 24px; background: rgba(10,14,20,0.85);
  backdrop-filter: blur(12px); border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 100;
}
.nav-logo {
  display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 18px;
  color: var(--text); text-decoration: none;
}
.nav-logo:hover { color: var(--text); }
.nav-links { display: flex; gap: 24px; }
.nav-links a { color: var(--text-secondary); font-size: 14px; font-weight: 500; }
.nav-links a:hover { color: var(--text); text-decoration: none; }
.nav-cta { display: flex; gap: 10px; }

/* ---- HERO ---- */
.hero {
  position: relative; overflow: hidden;
  min-height: 480px; display: flex; align-items: center; justify-content: center;
  padding: 60px 24px;
}
.hero-grid {
  position: absolute; inset: 0; opacity: 0.07;
  background-image:
    radial-gradient(circle at 25% 30%, var(--accent) 1px, transparent 1px),
    radial-gradient(circle at 75% 60%, var(--accent) 1px, transparent 1px),
    radial-gradient(circle at 50% 80%, #3b82f6 1px, transparent 1px);
  background-size: 60px 60px, 80px 80px, 100px 100px;
}
.hero::before {
  content: ""; position: absolute; inset: 0;
  background: radial-gradient(ellipse at 50% 0%, rgba(31,138,91,0.08) 0%, transparent 60%),
              radial-gradient(ellipse at 80% 100%, rgba(59,130,246,0.05) 0%, transparent 50%);
}
.hero-content { position: relative; text-align: center; max-width: 720px; z-index: 1; }
.hero h1 { font-size: 40px; line-height: 1.2; margin: 0 0 16px; font-weight: 700; letter-spacing: -0.02em; }
.hero-lede { color: var(--text-secondary); font-size: 18px; line-height: 1.6; margin: 0 0 32px; }
.hero-cta { display: flex; gap: 14px; justify-content: center; }

/* ---- BUTTONS ---- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 10px 20px; border-radius: var(--radius); font-weight: 600; font-size: 15px;
  cursor: pointer; border: 1px solid transparent; transition: all 0.15s;
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-strong); color: #fff; text-decoration: none; box-shadow: 0 0 20px var(--accent-glow); }
.btn-outline { background: transparent; color: var(--text); border-color: var(--border); }
.btn-outline:hover { border-color: var(--accent); color: var(--text); text-decoration: none; }
.btn-ghost-light { background: transparent; color: var(--text-secondary); }
.btn-ghost-light:hover { color: var(--text); text-decoration: none; }
.btn-lg { padding: 14px 28px; font-size: 16px; }
.btn-block { width: 100%; }
.btn-small { padding: 5px 10px; font-size: 13px; border: 1px solid var(--border); background: var(--surface); color: var(--text); }
.btn-small:hover { border-color: var(--accent); text-decoration: none; }

/* ---- SECTIONS ---- */
.section { padding: 64px 24px; max-width: 960px; margin: 0 auto; }
.section-alt { background: var(--bg-alt); max-width: none; }
.section-head { text-align: center; font-size: 28px; margin: 0 0 40px; font-weight: 700; }

.feature-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 24px; }
.feature-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 28px; transition: border-color 0.15s;
}
.feature-card:hover { border-color: var(--accent); }
.feature-icon { font-size: 28px; margin-bottom: 12px; color: var(--accent-strong); }
.feature-card h3 { margin: 0 0 8px; font-size: 17px; }
.feature-card p { color: var(--text-secondary); font-size: 14px; line-height: 1.5; margin: 0; }

.steps { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 20px; max-width: 800px; margin: 0 auto; }
.step { text-align: center; }
.step-num {
  display: inline-flex; align-items: center; justify-content: center;
  width: 36px; height: 36px; border-radius: 50%;
  background: var(--accent); color: #fff; font-weight: 700; font-size: 16px; margin-bottom: 10px;
}
.step strong { display: block; font-size: 15px; margin-bottom: 4px; }
.step span { display: block; color: var(--text-secondary); font-size: 13px; }

.steps-vertical { max-width: 600px; margin: 40px auto; display: flex; flex-direction: column; gap: 24px; }
.step-v { display: flex; gap: 18px; align-items: flex-start; }
.step-v .step-num { flex-shrink: 0; margin-top: 2px; }
.step-v h3 { margin: 0 0 4px; font-size: 16px; }
.step-v p { color: var(--text-secondary); font-size: 14px; line-height: 1.5; margin: 0; }

.page-content { max-width: 720px; margin: 40px auto; padding: 0 24px; }
.page-content h1 { font-size: 36px; margin: 0 0 12px; }
.page-content h2 { font-size: 22px; margin: 32px 0 10px; }
.page-content p { color: var(--text-secondary); font-size: 15px; line-height: 1.6; margin: 0 0 14px; }
.page-content a { color: var(--accent-strong); }
.lede { color: var(--text-secondary); font-size: 18px; line-height: 1.6; margin: 0 0 32px; }

/* ---- FOOTER ---- */
.footer { border-top: 1px solid var(--border); padding: 32px 24px; }
.footer-inner { max-width: 960px; margin: 0 auto; display: flex; flex-direction: column; gap: 14px; align-items: center; text-align: center; }
.footer-brand { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 15px; }
.footer-links { display: flex; gap: 20px; }
.footer-links a { color: var(--text-secondary); font-size: 13px; }
.footer-copy { color: var(--muted); font-size: 12px; }

/* ---- MAP PAGE ---- */
.page-map .map-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 16px; background: var(--surface); border-bottom: 1px solid var(--border);
}
.page-map .map-brand a { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 15px; color: var(--text); text-decoration: none; }
.page-map .map-meta { display: flex; align-items: center; gap: 14px; font-size: 13px; color: var(--text-secondary); }
.page-map .region { font-weight: 600; color: var(--text); }

.app-layout { display: flex; height: calc(100vh - 41px); }
.map { flex: 1; height: 100%; }

.sidebar {
  width: 360px; overflow-y: auto; background: var(--bg);
  border-left: 1px solid var(--border); display: flex; flex-direction: column; gap: 8px; padding: 10px;
}
.panel {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 12px; box-shadow: var(--shadow);
}
.panel h2 { margin: 0 0 8px; font-size: 13px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); }

textarea {
  width: 100%; padding: 10px; border: 1px solid var(--border); border-radius: var(--radius);
  font: inherit; font-size: 14px; resize: vertical; margin-bottom: 8px;
  background: var(--bg); color: var(--text);
}
textarea:focus { outline: none; border-color: var(--accent); }

.layer-toggle { display: flex; align-items: center; gap: 6px; padding: 3px 0; font-size: 13px; cursor: pointer; color: var(--text-secondary); }
.layer-toggle:hover { color: var(--text); }
.layer-toggle input[type=checkbox] { accent-color: var(--accent); }

.htmx-indicator { display: none; font-size: 12px; color: var(--muted); margin-top: 4px; }
.htmx-request .htmx-indicator, .htmx-request.htmx-indicator { display: block; }

.empty-state { color: var(--muted); font-size: 13px; padding: 8px 0; }
.error { color: #fca5a5; background: rgba(185,28,28,0.15); padding: 10px 12px; border-radius: var(--radius); font-size: 13px; margin-bottom: 8px; }

.criteria-card { background: rgba(31,138,91,0.08); border: 1px solid rgba(31,138,91,0.2); border-radius: var(--radius); padding: 8px 12px; margin-bottom: 8px; }
.criteria-card h3 { margin: 0 0 4px; font-size: 12px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--accent-strong); }
.criteria-list { margin: 0; padding-left: 16px; font-size: 13px; }
.criteria-list li { margin: 1px 0; }

.results-head { display: flex; align-items: center; justify-content: space-between; margin: 4px 0 8px; }
.results-head h3 { margin: 0; font-size: 13px; }

.results-list { list-style: none; margin: 0; padding: 0; }
.result-row { border-bottom: 1px solid var(--border); transition: background 0.1s; }
.result-row a { display: block; padding: 6px 4px; color: var(--text); }
.result-row a:hover { background: var(--surface-hover); text-decoration: none; }
.result-row strong { display: block; font-size: 13px; }
.result-meta { font-size: 11px; color: var(--text-secondary); }
.result-row--hover { background: var(--surface-hover) !important; }

.site-detail { margin-top: 8px; border-top: 2px solid var(--border); padding-top: 8px; }
.site-detail h3 { margin: 0 0 8px; font-size: 15px; }
.detail-layer { margin-bottom: 12px; }
.detail-layer h4 { margin: 0 0 4px; font-size: 12px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); }
.detail-layer ul { margin: 0; padding-left: 14px; font-size: 12px; }
.detail-layer li { margin: 2px 0; color: var(--text-secondary); }
.detail-layer dl { display: grid; grid-template-columns: auto 1fr; gap: 2px 10px; margin: 0; font-size: 12px; }
.detail-layer dt { color: var(--muted); }
.detail-layer dd { margin: 0; }
.muted { color: var(--text-secondary); font-size: 12px; }

.badge { font-size: 10px; padding: 2px 6px; border-radius: 999px; font-weight: 600; white-space: nowrap; }
.badge-matched, .badge-derived { background: rgba(31,138,91,0.15); color: #34d68a; }
.badge-estimated { background: rgba(234,179,8,0.15); color: #facc15; }
.badge-unavailable, .badge-requires-verification { background: rgba(239,68,68,0.15); color: #fca5a5; }

.result-dot { background: var(--accent); border: 2px solid #fff; border-radius: 50%; }

/* Save button */
.detail-header { display: flex; align-items: center; justify-content: space-between; }
.detail-header h3 { margin: 0; }
.btn-save { background: none; border: none; cursor: pointer; font-size: 13px; padding: 4px 8px; color: var(--muted); transition: color 0.15s; display: flex; align-items: center; gap: 4px; }
.btn-save:hover { color: #eab308; }
.btn-save.saved { color: #eab308; }
.btn-save .save-icon { font-size: 16px; }

/* Saved page */
.saved-table { width: 100%; border-collapse: collapse; margin-top: 20px; }
.saved-table th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); padding: 8px 12px; border-bottom: 1px solid var(--border); }
.saved-table td { padding: 10px 12px; border-bottom: 1px solid var(--border); font-size: 13px; color: var(--text-secondary); }
.saved-table td:first-child { color: var(--text); font-weight: 500; }
.saved-table tr:hover { background: var(--surface-hover); }
.inline-detail { margin-top: 8px; }
.inline-detail .site-detail { margin-top: 0; border-top: none; padding: 10px; background: var(--surface); border-radius: var(--radius); }

/* ---- LOGIN PAGE ---- */
.login-page {
  flex: 1; display: flex; align-items: center; justify-content: center;
  padding: 40px 24px; min-height: calc(100vh - 150px);
}
.login-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 12px; padding: 40px; max-width: 420px; width: 100%;
  text-align: center; box-shadow: var(--shadow);
}
.login-logo { margin-bottom: 20px; }
.login-card h1 { margin: 0 0 8px; font-size: 22px; font-weight: 700; }
.login-sub { color: var(--text-secondary); font-size: 14px; line-height: 1.5; margin: 0 0 28px; }
.login-btn {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  background: #fff; color: #1f1f1f; border: 1px solid #dadce0; font-size: 15px;
}
.login-btn:hover { background: #f8f9fa; color: #1f1f1f; box-shadow: 0 1px 3px rgba(0,0,0,0.12); }
.google-icon { flex-shrink: 0; }
.login-error {
  background: rgba(239,68,68,0.12); border: 1px solid rgba(239,68,68,0.3);
  color: #fca5a5; padding: 10px 14px; border-radius: var(--radius);
  font-size: 13px; margin-bottom: 20px;
}
.login-footer { color: var(--muted); font-size: 12px; margin: 24px 0 0; }
body > .footer { margin-top: 0; }

/* ---- RESPONSIVE ---- */
@media (max-width: 768px) {
  .hero h1 { font-size: 28px; }
  .hero-lede { font-size: 15px; }
  .hero-cta { flex-direction: column; }
  .nav-links { display: none; }
  .app-layout { flex-direction: column; }
  .sidebar { width: 100%; max-height: 50vh; }
  .map { height: 50vh; }
}