* { margin: 0; padding: 0; box-sizing: border-box }
body { font-family: system-ui, -apple-system, sans-serif }

/* Header & stats */
#header {
  background: #1e293b; color: #f8fafc; padding: 10px 20px;
  display: flex; align-items: flex-start; justify-content: space-between;
  flex-wrap: wrap; gap: 6px;
}
#header > div {
  display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 16px;
}
#header h1 { font-size: 16px; font-weight: 600; letter-spacing: -0.01em }
.stats { font-size: 12px; color: #94a3b8; line-height: 1.4 }
.stats span { margin-right: 12px }
.stat-permitted { color: #16a34a }
.stat-conditional { color: #d97706 }

/* Legend — collapsible on the map, not in the header */
/* Floating overlay panels (shared) */
.map-overlay {
  position: absolute; z-index: 1100;
  background: rgba(30,41,59,0.93); color: #f8fafc;
  padding: 10px 14px; border-radius: 8px; font-size: 11px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.35);
  backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px);
}
.map-overlay.collapsed { display: none }
.map-overlay-close {
  float: right; background: none; border: none; color: #94a3b8;
  cursor: pointer; font-size: 22px; line-height: 1; margin: -6px -8px 0 8px;
  width: 32px; height: 32px; display: inline-flex;
  align-items: center; justify-content: center; border-radius: 6px;
  transition: background 0.15s, color 0.15s;
}
.map-overlay-close:hover { color: #f8fafc; background: rgba(255,255,255,0.12) }
.map-overlay-btn {
  position: absolute; z-index: 999;
  background: #1e293b; color: #f8fafc; border: none; padding: 7px 14px;
  border-radius: 8px; cursor: pointer; font-size: 12px; font-family: inherit;
  box-shadow: 0 2px 8px rgba(0,0,0,0.35); display: none;
  transition: background 0.15s;
}
.map-overlay-btn:hover { background: #334155 }

/* Legend — bottom left */
#legend { bottom: 25px; left: 10px; max-width: 420px }
#legend-toggle { bottom: 25px; left: 10px }

/* Stats — bottom right */
#stats-panel { bottom: 25px; right: 10px; max-width: 480px; max-height: calc(100vh - 150px); overflow-y: auto }
#stats-panel .zp-cat { color: #60a5fa }
#stats-panel .zp-table { color: #e2e8f0 }
#stats-panel .zp-hdr { color: #94a3b8 }
#stats-panel .zp-cell { color: #cbd5e1 }
#stats-panel .zp-desc { color: #94a3b8 }
#stats-panel .zp-row { border-bottom-color: rgba(255,255,255,0.1) }
#stats-toggle { bottom: 25px; right: 10px }
.leg-item { display: inline-flex; align-items: center; margin-right: 8px }
.leg-dot {
  width: 10px; height: 10px; border-radius: 50%;
  display: inline-block; margin-right: 3px;
  border: 1px solid rgba(255,255,255,0.3);
}
.leg-code { font-size: 10px }
.leg-row { margin-bottom: 3px; line-height: 1.5 }
.leg-cat { font-size: 9px; color: #94a3b8; margin-right: 5px; text-transform: uppercase; letter-spacing: 0.03em }
.leg-shapes { margin-top: 4px; font-size: 10px; color: #cbd5e1; padding-top: 4px; border-top: 1px solid rgba(255,255,255,0.1) }
.leg-line { display: inline-block; width: 22px; height: 0; margin-right: 3px; vertical-align: middle; }
.leg-overlay-hdr { margin-top: 4px; padding-top: 4px; border-top: 1px solid rgba(255,255,255,0.1) }

/* Date filter — top left */
#filter-panel { top: 10px; left: 60px; bottom: auto; padding: 8px 12px }
#filter-toggle { top: 10px; left: 60px }
.df-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap }
.df-row + .df-row { margin-top: 5px }
.df-label { font-weight: 600; font-size: 12px; min-width: 52px }
.df-toggle { display: inline-flex; gap: 0 }
.df-btn {
  background: #334155; color: #94a3b8; border: 1px solid #475569;
  padding: 4px 11px; font-size: 11px; cursor: pointer; font-family: inherit;
  transition: background 0.15s, color 0.15s;
}
.df-btn:first-child { border-radius: 4px 0 0 4px }
.df-btn:last-child { border-radius: 0 4px 4px 0; border-left: none }
.df-btn.df-active { background: #2563eb; color: #f8fafc; border-color: #2563eb }
.df-sep { font-size: 11px; color: #94a3b8 }
.df-count { font-size: 11px; color: #94a3b8; margin-left: auto }
.df-cb {
  display: inline-flex; align-items: center; gap: 3px;
  font-size: 11px; cursor: pointer; white-space: nowrap;
}
.df-cb input { margin: 0; accent-color: #2563eb }
#df-from, #df-to {
  background: #334155; color: #f8fafc; border: 1px solid #475569;
  border-radius: 4px; padding: 4px 8px; font-size: 11px; font-family: inherit;
}

/* Info-tip tooltip badge */
.info-tip {
  display: inline-flex; align-items: center; justify-content: center;
  width: 14px; height: 14px; border-radius: 50%;
  background: rgba(0,0,0,0.12); color: inherit;
  font-size: 10px; font-style: normal; font-weight: 700;
  cursor: default; margin-left: 3px; position: relative;
  user-select: none; vertical-align: middle; flex-shrink: 0;
}
.info-tip::after {
  content: attr(data-tip);
  position: absolute; bottom: calc(100% + 6px); left: 50%;
  transform: translateX(-50%);
  background: #1e293b; color: #f8fafc;
  padding: 6px 9px; border-radius: 6px;
  font-size: 11px; line-height: 1.45; white-space: normal; width: 210px;
  box-shadow: 0 2px 10px rgba(0,0,0,0.35);
  pointer-events: none; opacity: 0; transition: opacity 0.15s;
  z-index: 9999; text-align: left; font-weight: 400;
}
.info-tip:hover::after, .info-tip:focus::after { opacity: 1; }

/* Policy overlay */
#policy-overlay {
  display: none; position: fixed; inset: 0;
  background: #1a1a1a; z-index: 2000; flex-direction: column;
}
#policy-overlay.open { display: flex; }
#policy-hdr {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 20px; background: #111; border-bottom: 1px solid #333; flex-shrink: 0;
}
.policy-title { font-size: 14px; font-weight: 600; color: #f8fafc; }
#policy-close {
  padding: 4px 10px; background: transparent;
  border: 1px solid #555; color: #bbb; border-radius: 3px; cursor: pointer; font-size: 12px;
}
#policy-close:hover { border-color: #888; color: #fff; }
#policy-body {
  flex: 1; overflow-y: auto; padding: 24px 40px;
  columns: 2; column-gap: 32px;
}
.pol-row {
  display: flex; gap: 12px; align-items: baseline;
  padding: 7px 0; border-bottom: 1px solid #222;
  break-inside: avoid;
}
.pol-date { font-size: 11px; color: #64748b; white-space: nowrap; min-width: 72px; }
.pol-name { font-size: 13px; }
.pol-major .pol-name { color: #e2e8f0; font-weight: 500; }
.pol-area  .pol-name { color: #94a3b8; }
.pol-link { color: inherit; text-decoration: none; }
.pol-link:hover { text-decoration: underline; }

/* Map — fills remaining viewport below header */
#map-wrap { position: relative; flex: 0 0 auto; height: calc(100vh - 96px); width: 100% }
#map { height: 100%; width: 100% }

/* Responsive: smaller legend on narrow screens */
@media (max-width: 600px) {
  #legend { max-width: 280px; font-size: 10px; padding: 6px 8px }
  .leg-dot { width: 8px; height: 8px }
  .leg-code { font-size: 9px }
  #header h1 { font-size: 14px }
  .stats { font-size: 11px }
  #stats-panel { left: 10px; right: 10px; max-width: none; font-size: 10px }
  #stats-panel .zp-table { display: block; overflow-x: auto }
  #filter-panel { left: 10px; right: auto; max-width: calc(100vw - 20px) }
}


/* Zoning panel table */
.zp-section { margin-bottom: 20px }
.zp-cat {
  font-weight: 600; font-size: 13px; color: #60a5fa;
  margin-bottom: 8px; border-bottom: 1px solid #1e3a5f; padding-bottom: 5px;
}
.zp-table { font-size: 12px; border-collapse: collapse; width: 100% }
.zp-hdr { color: #94a3b8; font-size: 10px; text-transform: uppercase; letter-spacing: 0.04em }
.zp-hdr th { text-align: left; padding: 6px 6px 4px }
.zp-row { border-bottom: 1px solid #2a2a2a }
.zp-row:hover { background: rgba(255,255,255,0.03) }
.zp-code { white-space: nowrap; font-weight: 600; color: #e2e8f0; vertical-align: top; padding: 6px 8px 6px 0 }
.zp-dot {
  display: inline-block; width: 12px; height: 12px; border-radius: 50%;
  vertical-align: middle; margin-right: 4px;
  border: 1px solid rgba(255,255,255,0.15);
}
.zp-name { vertical-align: top; padding: 6px 8px 6px 0; min-width: 120px; color: #cbd5e1 }
.zp-expand {
  width: 32px; min-width: 32px; text-align: center; vertical-align: top;
  cursor: pointer; color: #475569; font-size: 20px;
  padding: 6px 0 0; user-select: none; border-right: 1px solid #2a2a2a;
}
.zp-expand:hover { color: #60a5fa; background: rgba(96,165,250,0.06) }
.zp-expand-empty { width: 32px; min-width: 32px; padding: 0 }
.zp-desc-inline {
  margin-top: 4px; font-size: 11px; color: #64748b; line-height: 1.5;
  font-weight: normal;
}
.zp-desc { font-size: 11px; color: #64748b }
.zp-cell { vertical-align: top; padding: 6px 6px; font-size: 11px; color: #94a3b8; line-height: 1.4 }
.zp-nowrap { white-space: nowrap; font-size: 12px }
.zp-last { padding-left: 6px; padding-right: 0 }

/* Scrollbar styling for panels */
#stats-panel::-webkit-scrollbar { width: 6px }
#stats-panel::-webkit-scrollbar-track { background: transparent }
#stats-panel::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.15); border-radius: 3px }
#stats-panel::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.25) }

/* List panel button & panel */
#list-btn {
  position: absolute; top: 10px; right: 10px; z-index: 1000;
  background: #1e293b; color: #f8fafc; border: none; padding: 8px 16px;
  border-radius: 8px; cursor: pointer; font-size: 13px; font-family: inherit;
  box-shadow: 0 2px 8px rgba(0,0,0,0.35); transition: background 0.15s;
}
#list-btn:hover { background: #334155 }
#list-panel {
  position: absolute; top: 10px; right: 10px; z-index: 1001;
  background: rgba(255,255,255,0.92); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  border-radius: 10px; box-shadow: 0 4px 24px rgba(0,0,0,0.28);
  width: max-content; max-width: min(680px, calc(100vw - 30px)); max-height: calc(100vh - 100px);
  overflow-y: auto; padding: 22px 26px; display: none;
}
#list-panel.open { display: block }
#list-close {
  float: right; background: none; border: none; font-size: 32px;
  cursor: pointer; color: #64748b; line-height: 1;
  width: 44px; height: 44px; display: inline-flex;
  align-items: center; justify-content: center; border-radius: 8px;
  transition: background 0.15s, color 0.15s;
  margin: -6px -8px 0 8px;
}
#list-close:hover { color: #1e293b; background: #e2e8f0 }
#list-header {
  display: flex; align-items: center; gap: 12px; margin-bottom: 12px;
}
#list-title { font-size: 17px; font-weight: 600; color: #1e293b }
#list-sort {
  background: #f1f5f9; color: #1e293b; border: 1px solid #cbd5e1;
  border-radius: 6px; padding: 5px 10px; font-size: 12px; font-family: inherit;
}
#list-count { font-size: 12px; color: #64748b; margin-left: auto }
.list-rows { display: flex; flex-direction: column; gap: 2px }
.list-row {
  display: flex; align-items: baseline; flex-wrap: wrap; gap: 2px 8px;
  padding: 4px 8px; border-radius: 4px; font-size: 12px; color: #475569;
  border-left: 3px solid transparent;
}
.list-row.list-clickable { cursor: pointer }
.list-row.list-clickable:hover { filter: brightness(0.93) }
.list-row.list-nomap { opacity: 0.45 }
.lr-date { color: #94a3b8; font-size: 11px; white-space: nowrap; flex-shrink: 0 }
.lr-name { font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  flex-shrink: 1; min-width: 80px; max-width: min(260px, 50vw) }
.lr-meta { color: #64748b; font-size: 11px; white-space: nowrap; flex-shrink: 0 }

/* Scrollbar for list panel */
#list-panel::-webkit-scrollbar { width: 6px }
#list-panel::-webkit-scrollbar-track { background: transparent }
#list-panel::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 3px }
#list-panel::-webkit-scrollbar-thumb:hover { background: #94a3b8 }

/* Responsive: list panel */
@media (max-width: 600px) {
  #list-btn { right: 10px; top: 10px }
  #list-panel { width: calc(100vw - 20px); padding: 14px 10px }
  .lr-name { max-width: 50vw }
  #trends-hdr { padding: 8px 10px; gap: 6px; }
  #trends-body { padding: 8px 12px; overflow-y: auto; align-items: flex-start; justify-content: flex-start; }
  #trends-canvas { max-height: none; width: 100%; }
  #policy-body { columns: 1; padding: 16px 18px; }
}

/* Popup */
.popup { font: 13px/1.5 system-ui, sans-serif; max-width: 320px }
.popup-name { font-weight: 600; font-size: 14px; margin-bottom: 5px; color: #1e293b }
.popup-body { color: #475569; line-height: 1.5 }
.popup-use { font-weight: 600 }
.popup-desc {
  margin-top: 8px; font-size: 12px; color: #64748b;
  border-top: 1px solid #e2e8f0; padding-top: 8px; line-height: 1.5;
}

/* Footer — sits below the fold; scroll down to see it */
#site-footer {
  flex-shrink: 0;
  background: #0f172a; color: #94a3b8;
  padding: 16px 20px;
  font-size: 11px; line-height: 1.6;
  word-wrap: break-word; overflow-wrap: break-word;
}
.footer-inner { padding: 0; }
.footer-license { margin-bottom: 8px; color: #cbd5e1; }
.footer-disclaimer { margin-bottom: 6px; }
.footer-disclaimer:last-child { margin-bottom: 0; }
#site-footer a { color: #60a5fa; text-decoration: none; }
#site-footer a:hover { text-decoration: underline; }
#site-footer strong { color: #cbd5e1; }
@media (max-width: 600px) {
  #site-footer { padding: 12px 12px; font-size: 10px; }
}

/* Trends overlay */
#trends-btn {
  background: rgba(255,255,255,0.1); border: 1px solid rgba(255,255,255,0.25);
  color: #f8fafc; padding: 5px 12px; border-radius: 4px; cursor: pointer;
  font-size: 13px; white-space: nowrap; align-self: center;
}
#trends-btn:hover { background: rgba(255,255,255,0.2); }
#trends-overlay {
  display: none; position: fixed; inset: 0;
  background: #1a1a1a; z-index: 2000; flex-direction: column;
}
#trends-overlay.open { display: flex; }
#trends-hdr {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 10px 16px; background: #111; border-bottom: 1px solid #333;
}
.trends-title { font-size: 14px; font-weight: 600; color: #f8fafc; margin-right: 4px; }
.trends-ctrl-group { display: flex; gap: 4px; }
.trends-use-filter { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.tr-filter-label { font-size: 11px; color: #888; margin-right: 2px; }
.tr-use {
  padding: 2px 9px; border-radius: 10px; font-size: 11px; cursor: pointer;
  border: 1.5px solid #555; background: transparent; color: #888;
}
.tr-use.tr-use-act { border-color: var(--uc); color: #fff; background: rgba(255,255,255,0.08); }
.tr-use:hover:not(.tr-use-act) { border-color: #888; color: #ccc; }
.tr-cat {
  padding: 4px 10px; border: 1px solid #555; background: transparent;
  color: #bbb; border-radius: 3px; cursor: pointer; font-size: 12px;
}
.tr-cat:hover { border-color: #888; color: #fff; }
.tr-cat.tr-active { background: #3a3a3a !important; color: #fff !important; border-color: #888 !important; }
.trends-metric-wrap {
  background: #111; border-radius: 999px; padding: 2px;
  display: flex; border: 1px solid #333; margin-left: 4px;
}
.tr-metric {
  padding: 4px 14px; border: none; background: transparent;
  color: #666; border-radius: 999px; cursor: pointer;
  font-size: 12px; font-weight: 500; transition: background 0.15s;
}
.tr-metric.tr-active { background: #4f46e5; color: #fff; }
.tr-metric:hover:not(.tr-active) { color: #ccc; }
#trends-close {
  margin-left: auto; padding: 4px 10px; background: transparent;
  border: 1px solid #555; color: #bbb; border-radius: 3px; cursor: pointer; font-size: 12px;
}
#trends-close:hover { border-color: #888; color: #fff; }
#trends-body {
  flex: 1; padding: 24px 40px; display: flex;
  align-items: center; justify-content: center; overflow: hidden;
}
#trends-canvas { max-height: 75vh; max-width: 100%; }
#classif-btn {
  background: rgba(255,255,255,0.1); border: 1px solid rgba(255,255,255,0.25);
  color: #f8fafc; padding: 5px 12px; border-radius: 4px; cursor: pointer;
  font-size: 13px; white-space: nowrap; align-self: center;
}
#classif-btn:hover { background: rgba(255,255,255,0.2); }
#classif-overlay {
  display: none; position: fixed; inset: 0;
  background: #1a1a1a; z-index: 2000; flex-direction: column; overflow-y: auto;
}
#classif-overlay.open { display: flex; }
#classif-hdr {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 20px; background: #111; border-bottom: 1px solid #333;
  flex-shrink: 0;
}
.classif-title { font-size: 14px; font-weight: 600; color: #f8fafc; }
#classif-close {
  padding: 4px 10px; background: transparent;
  border: 1px solid #555; color: #bbb; border-radius: 3px; cursor: pointer; font-size: 12px;
}
#classif-close:hover { border-color: #888; color: #fff; }
#classif-body {
  padding: 32px 40px; max-width: 760px; margin: 0 auto; width: 100%;
}
.classif-card {
  border: 1px solid #2a2a2a; border-left: 4px solid var(--cc);
  border-radius: 6px; padding: 16px 18px; margin-bottom: 14px;
  background: #111;
}
.classif-badge {
  display: inline-block; padding: 2px 10px; border-radius: 10px;
  font-size: 11px; font-weight: 600; color: #fff;
  background: var(--cc); margin-bottom: 8px;
}
.classif-desc { font-size: 12px; color: #94a3b8; line-height: 1.6; margin-bottom: 6px; }
.classif-method { font-size: 11px; color: #64748b; }
.classif-note {
  font-size: 11px; color: #64748b; border-top: 1px solid #2a2a2a;
  padding-top: 14px; margin-top: 6px; line-height: 1.7;
}
.classif-note code { color: #93c5fd; font-size: 10px; }

/* Zoning overlay (full-screen, dark) */
#zoning-btn {
  background: rgba(255,255,255,0.1); border: 1px solid rgba(255,255,255,0.25);
  color: #f8fafc; padding: 5px 12px; border-radius: 4px; cursor: pointer;
  font-size: 13px; white-space: nowrap; align-self: center;
}
#zoning-btn:hover { background: rgba(255,255,255,0.2); }
#policy-btn {
  background: rgba(255,255,255,0.1); border: 1px solid rgba(255,255,255,0.25);
  color: #f8fafc; padding: 5px 12px; border-radius: 4px; cursor: pointer;
  font-size: 13px; white-space: nowrap; align-self: center;
}
#policy-btn:hover { background: rgba(255,255,255,0.2); }
#zoning-overlay {
  display: none; position: fixed; inset: 0;
  background: #1a1a1a; z-index: 2000; flex-direction: column;
}
#zoning-overlay.open { display: flex; }
#zoning-overlay-hdr {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 20px; background: #111; border-bottom: 1px solid #333; flex-shrink: 0;
}
.zoning-overlay-title { font-size: 14px; font-weight: 600; color: #f8fafc; }
#zoning-overlay-close {
  padding: 4px 10px; background: transparent;
  border: 1px solid #555; color: #bbb; border-radius: 3px; cursor: pointer; font-size: 12px;
}
#zoning-overlay-close:hover { border-color: #888; color: #fff; }
#zoning-overlay-body { flex: 1; overflow-y: auto; padding: 24px 32px; }
#panel-note { font-size: 11px; color: #64748b; margin-bottom: 16px; line-height: 1.6; }
#zoning-overlay-body::-webkit-scrollbar { width: 6px; }
#zoning-overlay-body::-webkit-scrollbar-track { background: transparent; }
#zoning-overlay-body::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.15); border-radius: 3px; }
#zoning-overlay-body::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.25); }
