@import url('https://fonts.googleapis.com/css2?family=DM+Sans:wght@400;500;600;700&family=Manrope:wght@500;600;700;800&display=swap');

:root {
  color-scheme: dark;
  --bg: #07111d;
  --panel: #0b1725;
  --panel-2: #101e2e;
  --line: rgba(179, 202, 222, 0.14);
  --text: #f4f8fb;
  --muted: #94a9bb;
  --soft: #c5d3de;
  --cyan: #55d9d1;
  --blue: #5da9ff;
  --violet: #987af5;
  --amber: #f0b35b;
  --orange: #ef794e;
  --red: #ee5364;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.28);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: "DM Sans", ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
button, select, a { font: inherit; }
a { color: inherit; }

.app-shell {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  height: 100vh;
  min-height: 100vh;
  background: radial-gradient(circle at 4% 8%, rgba(78, 132, 192, 0.16), transparent 26%), var(--bg);
}

.topbar {
  z-index: 1001;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  min-height: 88px;
  padding: 18px 28px;
  border-bottom: 1px solid var(--line);
  background: rgba(7, 17, 29, 0.94);
  backdrop-filter: blur(16px);
}

.brand-block h1,
.city-hero h2,
.section-heading h3 {
  margin: 0;
  font-family: "Manrope", ui-sans-serif, sans-serif;
  letter-spacing: -0.035em;
}
.brand-block h1 { margin-top: 3px; font-size: clamp(1.3rem, 2vw, 1.95rem); font-weight: 700; }
.eyebrow {
  color: var(--cyan);
  font-size: 0.69rem;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}
.header-meta { display: flex; align-items: center; gap: 10px; }
.city-picker {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 42px;
  padding: 5px 7px 5px 13px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel-2);
}
.city-picker span { color: var(--muted); font-size: 0.75rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em; }
.city-picker select {
  min-width: 150px;
  border: 0;
  outline: 0;
  padding: 6px 25px 6px 5px;
  background: transparent;
  color: var(--text);
  font-weight: 700;
}
.utility-link {
  padding: 11px 13px;
  border: 1px solid var(--line);
  border-radius: 12px;
  color: var(--soft);
  font-size: 0.82rem;
  font-weight: 700;
  text-decoration: none;
  transition: 160ms ease;
}
.utility-link:hover { border-color: rgba(85,217,209,.55); color: white; transform: translateY(-1px); }

.workspace { display: grid; grid-template-columns: minmax(0, 1fr) minmax(420px, 36vw); min-height: 0; }
.map-stage { position: relative; min-width: 0; overflow: hidden; background: #08131f; }
#map { width: 100%; height: 100%; min-height: 500px; background: #07111d; }
#map .leaflet-tile-pane { filter: grayscale(.45) invert(1) hue-rotate(180deg) brightness(.64) contrast(1.25) saturate(.75); }
#map .leaflet-control-zoom a { background: rgba(10, 23, 37, .94); color: var(--text); border-color: var(--line); }
#map .leaflet-control-zoom a:hover { background: #183149; }
#map .leaflet-control-attribution { background: rgba(7,17,29,.82); color: #a7bbc9; font-size: 10px; }
#map .leaflet-control-attribution a { color: #cfe2ef; }
.map-vignette {
  position: absolute;
  inset: 0;
  z-index: 401;
  pointer-events: none;
  box-shadow: inset -40px 0 75px rgba(5, 12, 20, .62), inset 0 -90px 90px rgba(5, 12, 20, .25);
}

.legend-card,
.map-note {
  z-index: 500;
  position: absolute;
  border: 1px solid rgba(194, 216, 232, 0.17);
  background: rgba(8, 20, 33, 0.9);
  backdrop-filter: blur(14px);
  box-shadow: var(--shadow);
}
.legend-card { top: 24px; left: 24px; width: 172px; padding: 15px 16px; border-radius: 14px; }
.legend-title { margin: 0 0 11px; color: var(--soft); font-size: .7rem; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; }
.legend-row { display: grid; grid-template-columns: 10px 1fr auto; align-items: center; gap: 9px; margin-top: 8px; font-size: .76rem; color: var(--soft); }
.legend-row b { color: var(--muted); font-variant-numeric: tabular-nums; }
.dot { width: 9px; height: 9px; border-radius: 50%; box-shadow: 0 0 0 3px rgba(255,255,255,.04); }
.dot.low { background: var(--blue); }
.dot.moderate { background: var(--amber); }
.dot.high { background: var(--orange); }
.dot.very-high { background: var(--red); }

.map-note {
  right: 24px;
  bottom: 24px;
  left: 24px;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 12px;
  padding: 14px 15px;
  border-radius: 15px;
}
.map-note strong, .map-note span { display: block; }
.map-note strong { font-size: .84rem; }
.map-note span { margin-top: 2px; color: var(--muted); font-size: .75rem; }
.pulse-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--cyan); box-shadow: 0 0 0 5px rgba(85,217,209,.12); }
#show-all {
  border: 1px solid rgba(85,217,209,.32);
  border-radius: 9px;
  padding: 8px 10px;
  background: rgba(85,217,209,.08);
  color: var(--cyan);
  cursor: pointer;
  font-weight: 800;
  font-size: .74rem;
}

.city-marker { transition: filter 150ms ease; }
.city-marker:hover { filter: brightness(1.16); }
.leaflet-tooltip.city-tooltip {
  border: 1px solid rgba(207, 228, 241, .18);
  border-radius: 8px;
  padding: 5px 7px;
  background: rgba(6, 16, 27, .94);
  color: white;
  box-shadow: 0 8px 20px rgba(0,0,0,.34);
  font-weight: 800;
  font-size: .71rem;
}
.leaflet-tooltip.city-tooltip::before { display: none; }

.insight-panel {
  min-height: 0;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: #30465b transparent;
  border-left: 1px solid var(--line);
  background: linear-gradient(180deg, #0b1725 0%, #091420 100%);
}
.insight-panel > section,
.insight-panel > details,
.panel-footer { margin-inline: 26px; }
.city-hero {
  display: grid;
  grid-template-columns: 1fr 112px;
  align-items: center;
  gap: 18px;
  padding: 28px 0 18px;
  border-bottom: 1px solid var(--line);
}
.hero-kicker { display: flex; gap: 8px; color: var(--muted); font-size: .73rem; font-weight: 800; letter-spacing: .09em; text-transform: uppercase; }
.hero-kicker .separator { color: #4b6375; }
.city-hero h2 { margin-top: 6px; font-size: 2.55rem; line-height: 1; }
.official-status { margin: 11px 0 0; max-width: 36ch; color: var(--soft); font-size: .82rem; line-height: 1.45; }
.score-ring {
  --score: 0%;
  --ring: var(--cyan);
  width: 104px;
  height: 104px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: conic-gradient(var(--ring) var(--score), rgba(255,255,255,.075) 0);
  box-shadow: 0 0 35px color-mix(in srgb, var(--ring) 16%, transparent);
}
.ring-centre { width: 82px; height: 82px; display: grid; place-content: center; text-align: center; border-radius: 50%; background: #0b1725; }
.ring-centre strong { display: block; font-family: "Manrope", sans-serif; font-size: 1.7rem; line-height: 1; }
.ring-centre span { margin-top: 4px; color: var(--muted); font-size: .67rem; font-weight: 700; }
.takeaway { margin: 18px 26px 0; color: #e6eef4; font-size: 1rem; line-height: 1.58; }

.score-card,
.evidence-card,
.comparison-card,
.sources-card {
  margin-top: 20px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(16,30,46,.78);
}
.section-heading { display: flex; align-items: end; justify-content: space-between; gap: 16px; margin-bottom: 16px; }
.section-heading h3 { margin-top: 4px; font-size: 1rem; }
.scale-note { color: var(--muted); font-size: .68rem; font-weight: 700; }
.component-bars { display: grid; gap: 13px; }
.component-row { display: grid; grid-template-columns: 118px 1fr 36px; align-items: center; gap: 11px; }
.component-label { color: var(--soft); font-size: .77rem; font-weight: 700; }
.component-track { height: 8px; border-radius: 999px; background: rgba(255,255,255,.07); overflow: hidden; }
.component-fill { height: 100%; border-radius: inherit; transform-origin: left; background: linear-gradient(90deg, var(--blue), var(--cyan)); box-shadow: 0 0 14px rgba(85,217,209,.25); }
.component-row.climate .component-fill { background: linear-gradient(90deg, var(--violet), #c28bff); }
.component-score { text-align: right; color: white; font-size: .76rem; font-weight: 800; font-variant-numeric: tabular-nums; }
.formula-note { margin: 14px 0 0; color: var(--muted); font-size: .69rem; line-height: 1.48; }

.evidence-card { padding: 16px 18px; }
.evidence-card p { margin: 7px 0 0; color: var(--soft); font-size: .83rem; line-height: 1.58; }
.accent-card { border-color: rgba(152, 122, 245, .28); background: linear-gradient(135deg, rgba(152,122,245,.12), rgba(16,30,46,.84)); }
.accent-card .eyebrow { color: #c6adff; }

.evidence-detail { margin-top: 10px; border: 1px solid var(--line); border-radius: 12px; background: rgba(255,255,255,.018); overflow: hidden; }
.evidence-detail summary { display: flex; justify-content: space-between; align-items: center; padding: 13px 15px; cursor: pointer; list-style: none; color: #dce8f0; font-size: .79rem; font-weight: 800; }
.evidence-detail summary::-webkit-details-marker { display: none; }
.evidence-detail summary span { color: var(--cyan); transition: transform 160ms ease; }
.evidence-detail[open] summary span { transform: rotate(45deg); }
.evidence-detail p { margin: 0; padding: 0 15px 15px; color: var(--muted); font-size: .78rem; line-height: 1.58; }
.caveat-detail { border-color: rgba(240,179,91,.18); }

.comparison-bars { display: grid; gap: 8px; }
.comparison-row { display: grid; grid-template-columns: 102px 1fr 28px; align-items: center; gap: 10px; width: 100%; border: 0; padding: 5px 0; background: transparent; color: inherit; cursor: pointer; text-align: left; }
.comparison-row:hover .comparison-name,
.comparison-row.active .comparison-name { color: white; }
.comparison-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); font-size: .72rem; font-weight: 700; }
.comparison-track { position: relative; height: 7px; border-radius: 99px; background: rgba(255,255,255,.06); overflow: hidden; }
.comparison-fill { position: absolute; inset: 0 auto 0 0; border-radius: inherit; opacity: .92; }
.comparison-value { text-align: right; font-size: .71rem; font-weight: 800; font-variant-numeric: tabular-nums; }

.sources-card ol { margin: 0; padding: 0; list-style: none; counter-reset: sources; }
.sources-card li { counter-increment: sources; display: grid; grid-template-columns: 28px 1fr; gap: 10px; padding: 11px 0; border-top: 1px solid var(--line); }
.sources-card li:first-child { border-top: 0; padding-top: 0; }
.sources-card li::before { content: counter(sources, decimal-leading-zero); color: var(--cyan); font-size: .69rem; font-weight: 800; padding-top: 2px; }
.source-link { color: #e5eef5; font-size: .78rem; font-weight: 700; line-height: 1.35; text-decoration: none; }
.source-link:hover { color: var(--cyan); }
.source-meta { display: block; margin-top: 3px; color: var(--muted); font-size: .67rem; line-height: 1.4; }
.panel-footer { padding: 22px 0 28px; color: #71889b; font-size: .7rem; line-height: 1.55; }
.panel-footer p { margin: 0 0 7px; }

@media (max-width: 980px) {
  body { overflow: auto; }
  .app-shell { height: auto; min-height: auto; }
  .topbar { position: sticky; top: 0; flex-wrap: wrap; padding: 14px 18px; }
  .header-meta { width: 100%; }
  .city-picker { flex: 1; }
  .city-picker select { width: 100%; }
  .workspace { grid-template-columns: 1fr; }
  .map-stage { height: 58vh; min-height: 480px; }
  .insight-panel { overflow: visible; border-left: 0; border-top: 1px solid var(--line); }
}

@media (max-width: 620px) {
  .utility-link { padding: 10px; font-size: .73rem; }
  .city-picker span { display: none; }
  .workspace { display: block; }
  .map-stage { height: 60vh; min-height: 430px; }
  .legend-card { top: 14px; right: 14px; left: auto; width: 154px; padding: 12px; }
  .leaflet-tooltip.city-tooltip { display: none; }
  .map-note { right: 14px; bottom: 14px; left: 14px; grid-template-columns: auto 1fr; }
  #show-all { grid-column: 2; justify-self: start; }
  .insight-panel > section,
  .insight-panel > details,
  .panel-footer { margin-inline: 16px; }
  .city-hero { grid-template-columns: 1fr 90px; }
  .city-hero h2 { font-size: 2.05rem; }
  .score-ring { width: 88px; height: 88px; }
  .ring-centre { width: 68px; height: 68px; }
  .ring-centre strong { font-size: 1.4rem; }
  .takeaway { margin-inline: 16px; }
}

@media print {
  body { overflow: visible; background: white; color: #122333; }
  .topbar { position: static; background: white; border-color: #cad5de; }
  .header-meta { display: none; }
  .workspace { display: block; }
  .map-stage { height: 58vh; break-after: page; }
  .insight-panel { background: white; overflow: visible; border: 0; }
  .score-card, .evidence-card, .comparison-card, .sources-card, .evidence-detail { background: white; color: #122333; border-color: #cad5de; }
}
