:root {
  --ink: #0f1b2d;
  --muted: #5b6474;
  --paper: #faf8f3;
  --card: #ffffff;
  --line: #e6e1d6;
  --sun: #e8890c;
  --sun-deep: #a8430a;
  --sky: #0369a1;
  --ok: #1d7a34;
  --bad: #b42318;
  --radius: 14px;
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", "Noto Sans Devanagari", sans-serif;
  color: var(--ink);
  background: var(--paper);
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; line-height: 1.5; }
a { color: var(--sky); }
.wrap { max-width: 1120px; margin: 0 auto; padding: 0 16px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.muted { color: var(--muted); }
.small { font-size: 0.85rem; }
.num { text-align: right; font-variant-numeric: tabular-nums; }

.top { border-bottom: 1px solid var(--line); background: #fff; }
.top-row { display: flex; align-items: center; justify-content: space-between; height: 56px; }
.brand { display: flex; gap: 8px; align-items: center; font-weight: 650; color: var(--ink); text-decoration: none; }
.dot { width: 12px; height: 12px; border-radius: 50%; background: var(--sun); box-shadow: 0 0 0 4px #e8890c33; }

button { font: inherit; cursor: pointer; border: 0; border-radius: 10px; padding: 10px 16px; background: var(--ink); color: #fff; font-weight: 600; }
button.secondary { background: #fff; color: var(--ink); border: 1px solid var(--ink); }
button.link { background: none; color: var(--sky); padding: 4px 0; font-weight: 500; }
button:disabled { opacity: 0.5; cursor: default; }
input { font: inherit; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: #fff; width: 100%; }
input:focus { outline: 3px solid #e8890c44; border-color: var(--sun); }

.hero { padding: 40px 0 16px; max-width: 680px; }
.eyebrow { color: var(--sun-deep); font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; font-size: 0.8rem; margin: 0; }
h1 { font-size: clamp(1.9rem, 5vw, 2.8rem); line-height: 1.1; margin: 8px 0; letter-spacing: -0.02em; }
.lead { font-size: 1.1rem; color: var(--muted); margin: 0; }

.search { display: flex; gap: 8px; max-width: 520px; margin-top: 20px; }
.search input { font-size: 1.15rem; letter-spacing: 0.15em; font-variant-numeric: tabular-nums; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 12px 0; font-size: 0.9rem; }
.chip { background: #fff; color: var(--ink); border: 1px solid var(--line); border-radius: 999px; padding: 4px 12px; font-weight: 500; }
.chip:hover { border-color: var(--sun); }
.error { color: var(--bad); }

.panel { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.status { margin: 16px 0; display: flex; gap: 12px; align-items: center; }
.spinner { width: 20px; height: 20px; border-radius: 50%; border: 3px solid var(--line); border-top-color: var(--sun); animation: spin 0.9s linear infinite; flex: none; }
@keyframes spin { to { transform: rotate(360deg); } }

#result { margin-top: 24px; }
.result-head h2 { margin: 0; font-size: 2rem; font-variant-numeric: tabular-nums; }
.result-head p { margin: 0; }
.cards { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin: 16px 0; }
.cards div { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; }
.cards dt { font-size: 0.8rem; color: var(--muted); }
.cards dd { margin: 4px 0 0; font-size: 1.45rem; font-weight: 650; font-variant-numeric: tabular-nums; }
.cards dd small { display: block; font-size: 0.75rem; font-weight: 400; color: var(--muted); }

.summary { margin-bottom: 16px; }
.summary-head { display: flex; justify-content: space-between; align-items: center; }
.summary-head h3 { margin: 0; }
.toggle { display: flex; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.toggle button { background: #fff; color: var(--ink); border-radius: 0; padding: 4px 12px; font-weight: 500; }
.toggle button[aria-pressed="true"] { background: var(--ink); color: #fff; }
.summary-text { font-size: 1.05rem; }
.pitch summary { cursor: pointer; color: var(--sky); }

.split { display: grid; grid-template-columns: 3fr 2fr; gap: 12px; }
.map-wrap { min-width: 0; }
#map { height: 420px; border-radius: var(--radius); border: 1px solid var(--line); overflow: hidden; background: #eef1ea; }
.legend { display: flex; gap: 8px; align-items: center; font-size: 0.78rem; color: var(--muted); margin-top: 6px; }
.ramp { width: 120px; height: 10px; border-radius: 4px; background: linear-gradient(90deg, #fde9b8, #f29a2e, #a8430a); }
.roof h3 { margin: 4px 0 8px; font-size: 1.05rem; }
.roof .big { font-size: 1.8rem; font-weight: 700; margin: 0; font-variant-numeric: tabular-nums; }
.roof dl { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 12px; margin: 12px 0; }
.roof dt { font-size: 0.75rem; color: var(--muted); }
.roof dd { margin: 0; font-variant-numeric: tabular-nums; }
.tag { display: inline-block; font-size: 0.72rem; padding: 2px 8px; border-radius: 999px; background: #f1ede3; margin-right: 4px; }
.tag.commercial { background: #e0efff; }
.tag.institutional { background: #efe3ff; }

.filters { display: flex; flex-wrap: wrap; gap: 12px; align-items: end; margin: 20px 0 6px; }
.filters label { font-size: 0.8rem; color: var(--muted); }
.filters input#f-area { width: 140px; display: block; margin-top: 4px; }
.check { display: flex; gap: 6px; align-items: center; font-size: 0.9rem !important; color: var(--ink) !important; }
.check input { width: auto; }
.filters .secondary { margin-left: auto; }

.table-wrap { overflow-x: auto; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); }
table { width: 100%; min-width: 820px; border-collapse: collapse; font-size: 0.88rem; }
th { text-align: left; font-weight: 600; color: var(--muted); font-size: 0.78rem; background: #f7f5ef; padding: 8px 10px; cursor: pointer; white-space: nowrap; user-select: none; }
th[aria-sort="ascending"]::after { content: " ↑"; }
th[aria-sort="descending"]::after { content: " ↓"; }
td { padding: 8px 10px; border-top: 1px solid var(--line); }
td.addr { max-width: 280px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
tbody tr { cursor: pointer; }
tbody tr:hover { background: #faf7f0; }
tbody tr[aria-selected="true"] { background: #e7f3fb; }
.swatch { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: middle; }

.lead { margin: 32px 0; }
.lead h3 { margin-top: 0; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.grid2 label, .lead label { font-size: 0.85rem; color: var(--muted); }
.consent { margin: 12px 0; align-items: flex-start !important; }
.consent input { margin-top: 4px; }
#turnstile { margin: 8px 0 12px; }

.drawer { max-width: 640px; width: calc(100% - 32px); border: 0; border-radius: var(--radius); padding: 20px; }
.drawer::backdrop { background: #0f1b2d88; }
.drawer-head { display: flex; justify-content: space-between; align-items: center; }
.drawer-head h2 { margin: 0; }
.drawer table { min-width: 0; font-size: 0.9rem; }
.drawer td:first-child { color: var(--muted); }
.formula { background: #f7f5ef; border-radius: 10px; padding: 10px 12px; font-family: ui-monospace, Consolas, monospace; font-size: 0.85rem; white-space: pre-wrap; }

.foot { padding: 24px 16px 40px; border-top: 1px solid var(--line); margin-top: 24px; }
.maplibregl-popup-content { font: inherit; font-size: 0.85rem; }

@media (max-width: 760px) {
  .cards { grid-template-columns: 1fr 1fr; }
  .split { grid-template-columns: 1fr; }
  #map { height: 320px; }
  .grid2 { grid-template-columns: 1fr; }
  .filters .secondary { margin-left: 0; }
}
