:root {
  --ink: #16191c;
  --paper: #f7f6f3;
  --line: #dedad2;
  --accent: #1f5b4c;
  --accent-soft: #e6efe9;
  --warn: #a2492b;
  --warn-soft: #f5e6e0;
  --muted: #6b6f72;
  --radius: 6px;
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; background: var(--paper); color: var(--ink); }
#app { display: flex; flex-direction: column; height: 100vh; }

#topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  background: #fff;
  border-bottom: 1px solid var(--line);
  flex-wrap: wrap;
}
#brand { display: flex; align-items: baseline; gap: 8px; }
.brand-mark { color: var(--accent); font-size: 18px; }
.brand-name { font-weight: 700; font-size: 15px; letter-spacing: -0.01em; }
.layer-badge {
  font-size: 11px; color: var(--accent); background: var(--accent-soft);
  padding: 2px 8px; border-radius: 999px; font-weight: 600;
}

#check-form { display: flex; gap: 8px; flex: 1; max-width: 340px; min-width: 180px; }
#street-input {
  flex: 1; padding: 9px 12px; border: 1px solid var(--line);
  border-radius: var(--radius); font-size: 13px; outline: none;
}
#street-input:focus { border-color: var(--accent); }
#check-btn {
  background: #fff; color: var(--ink); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 9px 14px; font-size: 13px; font-weight: 600; cursor: pointer; white-space: nowrap;
}
#check-btn:hover { border-color: var(--accent); color: var(--accent); }

#search-area-btn {
  background: var(--ink); color: #fff; border: none; border-radius: var(--radius);
  padding: 9px 16px; font-size: 13px; font-weight: 600; cursor: pointer; white-space: nowrap;
}
#search-area-btn:hover { background: #000; }
#search-area-btn:disabled { opacity: 0.5; cursor: default; }

#body { display: flex; flex: 1; min-height: 0; }

#watchlist {
  width: 300px; flex-shrink: 0; border-right: 1px solid var(--line);
  background: #fff; display: flex; flex-direction: column; min-height: 0;
}
#watchlist-header {
  display: flex; align-items: baseline; justify-content: space-between; padding: 14px 16px 10px;
  border-bottom: 1px solid var(--line);
}
#watchlist-header h2 { font-size: 13px; text-transform: uppercase; letter-spacing: 0.04em; margin: 0; color: var(--muted); }
#watchlist-count { font-size: 12px; color: var(--muted); }

#watchlist-items { overflow-y: auto; flex: 1; }
.empty-state { padding: 20px 16px; font-size: 13px; color: var(--muted); line-height: 1.5; }

.watch-card { padding: 12px 16px; border-bottom: 1px solid var(--line); cursor: pointer; }
.watch-card:hover { background: var(--accent-soft); }
.watch-card.elevated { border-left: 3px solid var(--warn); }
.watch-street { font-weight: 600; font-size: 13px; margin-bottom: 4px; }
.watch-meta { display: flex; align-items: center; gap: 8px; font-size: 11px; color: var(--muted); }
.watch-flag { padding: 2px 7px; border-radius: 999px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.03em; font-size: 10px; }
.watch-flag.elevated { background: var(--warn-soft); color: var(--warn); }
.watch-flag.normal { background: var(--accent-soft); color: var(--accent); }

#map-wrap { flex: 1; position: relative; }
#map { width: 100%; height: 100%; }
#map-legend {
  position: absolute; bottom: 20px; left: 16px; background: #fff; border: 1px solid var(--line);
  border-radius: var(--radius); padding: 8px 12px; display: flex; gap: 14px; font-size: 11px;
  color: var(--muted); box-shadow: 0 1px 4px rgba(0,0,0,0.08);
}
#map-legend .dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 5px; }
#map-legend .dot.elevated { background: var(--warn); }
#map-legend .dot.normal { background: var(--accent); }

#detail-panel {
  width: 420px; flex-shrink: 0; border-left: 1px solid var(--line);
  background: #fff; padding: 20px; position: relative; overflow-y: auto;
}
#detail-panel.hidden { display: none; }
#close-detail {
  position: absolute; top: 12px; right: 14px; border: none; background: none;
  font-size: 20px; cursor: pointer; color: var(--muted);
}
#detail-content .type-label { font-size: 11px; color: var(--accent); text-transform: uppercase; letter-spacing: 0.03em; }
#detail-content h3 { margin: 2px 0 4px; font-size: 20px; }
#detail-content .subtitle { color: var(--muted); font-size: 13px; margin-bottom: 12px; }

.signal-flag {
  display: inline-block; padding: 4px 10px; border-radius: 999px; font-weight: 700;
  font-size: 12px; text-transform: uppercase; letter-spacing: 0.03em; margin-bottom: 18px;
}
.signal-flag.elevated { background: var(--warn-soft); color: var(--warn); }
.signal-flag.normal { background: var(--accent-soft); color: var(--accent); }

.contact-cta { margin-bottom: 16px; }
#find-contact-btn {
  background: var(--accent); color: #fff; border: none; border-radius: var(--radius);
  padding: 9px 14px; font-size: 13px; font-weight: 600; cursor: pointer;
}
#find-contact-btn:hover { background: #164539; }

#contact-results { margin-bottom: 20px; }
.contact-row {
  padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--radius);
  margin-bottom: 6px; cursor: pointer; background: #fff;
}
.contact-row:hover { border-color: var(--accent); }
.contact-name { font-weight: 600; font-size: 13px; }
.contact-addr { font-size: 12px; color: var(--muted); margin-top: 2px; }

.permits-heading { font-size: 13px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); margin: 20px 0 10px; }

.permit-table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); }
.permit-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.permit-table th {
  text-align: left; padding: 8px 10px; background: var(--paper); color: var(--muted);
  font-weight: 600; text-transform: uppercase; font-size: 10px; letter-spacing: 0.03em;
  border-bottom: 1px solid var(--line); white-space: nowrap;
}
.permit-table td {
  padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: top;
}
.permit-table tr:last-child td { border-bottom: none; }
.permit-table .desc-cell { color: var(--muted); min-width: 220px; }

.permit-source { font-size: 11px; color: var(--muted); margin-top: 20px; }
.permit-source a { color: var(--accent); }

.hidden { display: none; }

@media (max-width: 1000px) {
  #watchlist { width: 240px; }
  #detail-panel { width: 340px; }
}
@media (max-width: 800px) {
  #body { flex-direction: column; }
  #watchlist { width: 100%; max-height: 30vh; border-right: none; border-bottom: 1px solid var(--line); }
  #detail-panel { position: absolute; right: 0; top: 0; bottom: 0; z-index: 5; width: 100%; }
}
