/* Copyright (c) 2025-2026 Tahseen Huda / Ooua */
:root {
  --bg: #fff; --fg: #111; --muted: #6b7280; --line: #e5e7eb; --accent: #d7263d; --soft: #f6f7f8;
  --side: 440px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif; font-size: 14px; color: var(--fg);
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; background: var(--bg); }
body { display: grid; grid-template-columns: minmax(0, 1fr); grid-template-rows: auto auto auto 1fr; height: 100dvh; overflow: hidden; }
#bar, #near, #filters, main { min-width: 0; }
#bar { grid-row: 1; } #near { grid-row: 2; } #filters { grid-row: 3; } main { grid-row: 4; }
.muted { color: var(--muted); font-size: 12px; }
.note { font-size: 12px; color: var(--muted); margin: 6px 0 8px; line-height: 1.4; }
button, select, input { font: inherit; }
button { cursor: pointer; }

/* header + tabs */
#bar { display: flex; align-items: center; gap: 10px; padding: 6px 12px; border-bottom: 1px solid var(--line); background: #fff; }
#brand { display: flex; flex-direction: column; line-height: 1.15; white-space: nowrap; }
#brand strong { font-size: 15px; }
#tabs { display: flex; gap: 2px; margin-left: auto; overflow-x: auto; min-width: 0; scrollbar-width: none; }
#tabs::-webkit-scrollbar { display: none; }
#tabs button { white-space: nowrap; flex: 0 0 auto; }
#tabs button { border: 0; background: transparent; padding: 7px 10px; border-radius: 6px; color: var(--muted); font-weight: 500; }
#tabs button.on { background: #111; color: #fff; }
#tabs #sources-btn { color: var(--fg); border: 1px solid var(--line); }

/* near me */
#near { display: flex; align-items: center; gap: 10px; padding: 6px 12px; border-bottom: 1px solid var(--line); background: var(--soft); position: relative; }
#loc-btn { border: 1px solid var(--line); background: #fff; border-radius: 6px; padding: 5px 10px; max-width: 60%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#loc-btn::before { content: "📍 "; }
#radius-wrap { display: flex; align-items: center; gap: 6px; flex: 1; }
#radius { flex: 1; min-width: 60px; accent-color: #111; }
#radius-label { min-width: 44px; text-align: right; font-variant-numeric: tabular-nums; }
#loc-pop { position: absolute; top: 100%; left: 12px; right: 12px; z-index: 20; background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: 10px; box-shadow: 0 8px 24px rgba(0,0,0,.12); }
#loc-pop input { width: 100%; padding: 8px; border: 1px solid var(--line); border-radius: 6px; }
#loc-pop .row { display: flex; gap: 8px; margin-top: 8px; }
#loc-pop .row button { flex: 1; padding: 7px; border: 1px solid var(--line); background: var(--soft); border-radius: 6px; }
#loc-results, #street-results, #loc-results { list-style: none; margin: 4px 0 0; padding: 0; max-height: 40vh; overflow: auto; border: 1px solid var(--line); border-radius: 6px; background: #fff; }
#loc-results li, #street-results li { padding: 7px 10px; cursor: pointer; display: flex; justify-content: space-between; gap: 8px; }
#loc-results li:hover, #street-results li:hover, li.active { background: var(--soft); }

/* filters */
#filters { display: flex; flex-wrap: wrap; gap: 6px 12px; padding: 6px 12px; border-bottom: 1px solid var(--line); background: #fff; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.chip { border: 1px solid var(--line); background: #fff; border-radius: 999px; padding: 3px 9px; font-size: 12px; color: var(--muted); display: inline-flex; align-items: center; gap: 5px; }
.chip i { width: 8px; height: 8px; border-radius: 50%; display: inline-block; opacity: .35; }
.chip i.ring { border: 2px solid #00a676; width: 6px; height: 6px; }
.chip.on { color: var(--fg); border-color: #111; }
.chip.on i { opacity: 1; }
#filters select { border: 1px solid var(--line); border-radius: 999px; padding: 3px 8px; font-size: 12px; background: #fff; }

/* views */
main { position: relative; overflow: hidden; }
.view { display: none; position: absolute; inset: 0; overflow-y: auto; overflow-x: hidden; padding: 8px 12px 24px; }
.view.on { display: block; }
#view-map { padding: 0; }
.viewhead { display: flex; align-items: baseline; gap: 10px; }
.viewhead h2 { margin: 6px 0 2px; font-size: 16px; }

/* rows */
.rows { list-style: none; margin: 0; padding: 0; }
.rows li { display: grid; grid-template-columns: 1fr auto; gap: 2px 10px; padding: 8px 0; border-bottom: 1px solid var(--line); cursor: pointer; }
.rows .a { font-weight: 600; }
.rows .v { font-weight: 600; text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.rows .v.nd { color: #9ca3af; font-weight: 400; font-style: italic; }
.rows .m { grid-column: 1 / -1; font-size: 12px; color: var(--muted); display: flex; flex-wrap: wrap; gap: 4px 10px; align-items: center; }
.rows .m a { color: #2e86de; text-decoration: none; }
.tag { display: inline-flex; align-items: center; gap: 4px; font-size: 11px; padding: 0 6px; border-radius: 4px; background: var(--soft); color: var(--fg); }
.tag i { width: 7px; height: 7px; border-radius: 50%; display: inline-block; }
.tag.dev { border: 1px solid #00a676; background: #fff; }
.tag.scale { background: #fff; border: 1px dashed #bbb; }
.tag.build { background: #111; color: #fff; }
.tag.withheld { background: #fff; border: 1px solid var(--line); color: var(--muted); font-style: italic; }
.tag.city { background: #fff; border: 1px solid #111; font-weight: 600; letter-spacing: .02em; }
.tag.city-mississauga { border-color: #0a7c7c; color: #0a7c7c; }
.tag.city-brampton { border-color: #8a5a00; color: #8a5a00; }

/* pipeline groups */
.group h3 { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 14px 0 4px; display: flex; justify-content: space-between; }

/* street */
#street-input { width: 100%; padding: 8px 10px; border: 1px solid var(--line); border-radius: 6px; margin: 4px 0; }
.kpis { display: flex; gap: 14px; margin: 8px 0 2px; flex-wrap: wrap; }
.kpis div { display: flex; flex-direction: column; }
.kpis b { font-size: 16px; }
.kpis span { font-size: 11px; color: var(--muted); }
.stack { display: flex; align-items: flex-end; gap: 3px; height: 110px; margin: 22px 0 2px; border-bottom: 1px solid var(--line); }
.stack .col { flex: 1; height: 100%; display: flex; flex-direction: column-reverse; position: relative; max-width: 56px; }
.stack .col span { display: block; flex: 0 0 auto; }
.stack .col small { position: absolute; top: -14px; left: 0; right: 0; text-align: center; font-size: 10px; color: var(--muted); }
.axis { display: flex; justify-content: space-between; font-size: 10px; color: var(--muted); }
.axis span { flex: 1; text-align: center; }
.companies { margin: 6px 0; padding: 0; list-style: none; }
.companies li { display: flex; justify-content: space-between; padding: 4px 0; border-bottom: 1px solid var(--line); font-size: 13px; }
h3.sub { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 14px 0 4px; }
.more { border: 1px solid var(--line); background: #fff; border-radius: 6px; padding: 5px 10px; margin: 6px 0; }

/* map */
#map { position: absolute; inset: 0; }
#map-tools { position: absolute; top: 8px; left: 8px; right: 8px; z-index: 4; display: flex; flex-wrap: wrap; gap: 6px 10px; align-items: center;
  background: rgba(255,255,255,.94); border: 1px solid var(--line); border-radius: 8px; padding: 6px 10px; font-size: 12px; }
#map-tools label { display: inline-flex; align-items: center; gap: 4px; }
#map-tools input[type=checkbox] { margin: 0; }
#window { display: inline-flex; border: 1px solid var(--line); border-radius: 6px; overflow: hidden; }
#window label { padding: 2px 8px; }
#window label:first-child { border-right: 1px solid var(--line); }
#window input { display: none; }
#window label:has(input:checked) { background: #111; color: #fff; }
#pin-here { margin-left: auto; border: 1px solid var(--line); background: #fff; border-radius: 6px; padding: 3px 8px; font-size: 12px; }
#legend { position: absolute; left: 8px; bottom: 26px; z-index: 4; background: rgba(255,255,255,.92); border: 1px solid var(--line); border-radius: 6px; padding: 4px 8px; font-size: 11px; line-height: 1.5; }
#legend::before { content: 'Legend ▸'; display: block; font-weight: 600; cursor: pointer; }
#legend.open::before { content: 'Legend ▾'; }
#legend > div { display: none; }
#legend.open > div { display: block; }
#legend .dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; margin-right: 6px; vertical-align: -1px; }
#legend .ring { border: 2px solid; background: transparent; width: 8px; height: 8px; }
#legend .sep { height: 1px; background: var(--line); margin: 3px 0; }
#hint { position: absolute; top: 56px; left: 50%; transform: translateX(-50%); z-index: 4; background: rgba(17,17,17,.85); color: #fff; font-size: 12px; padding: 5px 10px; border-radius: 6px; pointer-events: none; }
.maplibregl-ctrl-attrib { font-size: 10px; }
.maplibregl-ctrl-bottom-right { max-width: 60vw; }

/* detail + sources panels */
#panel, #sources { position: fixed; z-index: 30; background: #fff; overflow: auto; padding: 14px 16px 24px; box-shadow: 0 -4px 24px rgba(0,0,0,.12);
  left: 0; right: 0; bottom: 0; height: 70dvh; border-top: 1px solid var(--line); border-radius: 12px 12px 0 0; }
#panel-close, #sources-close { position: absolute; top: 8px; right: 10px; width: 28px; height: 28px; border: 0; background: transparent; font-size: 20px; color: var(--muted); }
#panel h2, #sources h2 { margin: 0 24px 2px 0; font-size: 16px; line-height: 1.25; }
#panel h3, #sources h3 { margin: 16px 0 6px; font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.kind { display: inline-block; font-size: 11px; padding: 1px 6px; border-radius: 4px; color: #fff; margin-bottom: 6px; }
dl { margin: 0; display: grid; grid-template-columns: minmax(110px, 38%) 1fr; gap: 3px 10px; font-size: 13px; }
dt { color: var(--muted); overflow-wrap: anywhere; }
dd { margin: 0; overflow-wrap: anywhere; white-space: pre-wrap; }
dd.nd { color: #9ca3af; font-style: italic; }
dd a, .src a { color: #2e86de; }
details { margin-top: 8px; font-size: 12px; }
details summary { cursor: pointer; color: var(--muted); }
details pre { white-space: pre-wrap; overflow-wrap: anywhere; font-size: 11px; background: var(--soft); padding: 8px; border-radius: 4px; margin: 6px 0 0; }
.src { font-size: 12px; margin: 4px 0; }
.chart { display: flex; align-items: flex-end; gap: 2px; height: 90px; margin: 6px 0 2px; border-bottom: 1px solid var(--line); }
.chart .b { flex: 1; min-width: 4px; max-width: 48px; background: #111; position: relative; }
.chart .b:hover { background: var(--accent); }
.chart .b span { position: absolute; bottom: 100%; left: 50%; transform: translateX(-50%); font-size: 10px; color: var(--muted); display: none; white-space: nowrap; }
.chart .b:hover span { display: block; }
.types .tr { display: grid; grid-template-columns: 10px 110px 1fr 36px; align-items: center; gap: 6px; font-size: 12px; margin: 3px 0; }
.types i { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.types .tb { height: 8px; background: #f0f1f3; border-radius: 4px; overflow: hidden; }
.types .tb span { display: block; height: 100%; }
.types .tn { text-align: right; font-variant-numeric: tabular-nums; }
.actions { display: flex; gap: 8px; margin: 8px 0; }
.actions button { border: 1px solid var(--line); background: #fff; border-radius: 6px; padding: 5px 10px; font-size: 12px; }
#sources p, #sources li { font-size: 13px; line-height: 1.45; }
#sources ul { padding-left: 18px; margin: 4px 0; }
.stat { font-variant-numeric: tabular-nums; }

/* desktop: side column + always-on map */
@media (min-width: 900px) {
  body { grid-template-columns: var(--side) 1fr; grid-template-rows: auto auto auto 1fr; }
  #bar { grid-column: 1 / -1; }
  #near, #filters { grid-column: 1; }
  main { grid-column: 1; border-right: 1px solid var(--line); }
  #view-map { display: block !important; position: fixed; top: 49px; left: var(--side); right: 0; bottom: 0; }
  #tabs .map-tab { display: none; }
  #panel, #sources { left: auto; top: 49px; right: 0; bottom: 0; width: 400px; height: auto; border-radius: 0; border-left: 1px solid var(--line); border-top: 0; box-shadow: -4px 0 16px rgba(0,0,0,.06); }
}
@media (max-width: 899px) {
  #brand .muted { display: none; }
  #bar { padding: 6px 8px; }
  #tabs { margin-left: auto; gap: 0; }
  #tabs button { padding: 7px 7px; font-size: 13px; }
  #brand strong { font-size: 14px; }
  #tabs #sources-btn { padding: 5px 8px; }
  #near { padding: 6px 8px; }
  #filters { padding: 6px 8px; gap: 5px 8px; }
  .view { padding: 6px 10px 24px; }
}
