/* ── Reset & base ─────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:        #06080f;
  --surface:   #0c1018;
  --surface-2: #111720;
  --border:    #1c2535;
  --border-2:  #243045;
  --heat:      #ff6b35;
  --heat-dim:  rgba(255,107,53,.15);
  --save:      #00d4aa;
  --save-dim:  rgba(0,212,170,.12);
  --danger:    #ff3358;
  --warn:      #f5c518;
  --text:      #dde3ef;
  --muted:     #5d6b82;
  --muted-2:   #8494a8;
  --font:      'Inter', system-ui, sans-serif;
  --mono:      'JetBrains Mono', 'Fira Code', monospace;
  --radius:    8px;
  --radius-lg: 14px;
}

html { font-size: 15px; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  line-height: 1.6;
  min-height: 100vh;
}

a { color: var(--heat); text-decoration: none; }
a:hover { color: var(--save); }

/* ── Nav ──────────────────────────────────────────────────────────────────── */
nav {
  position: sticky; top: 0; z-index: 100;
  display: flex; align-items: center; justify-content: space-between;
  padding: .85rem 2rem;
  background: rgba(6,8,15,.92);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(12px);
}

.nav-brand { display: flex; align-items: center; gap: .6rem; }
.nav-brand svg { width: 28px; height: 28px; }
.nav-brand .brand-name {
  font-size: 1.05rem; font-weight: 700; letter-spacing: -.02em;
  color: var(--text);
}
.nav-brand .brand-sub {
  font-size: .7rem; font-weight: 500; letter-spacing: .12em;
  color: var(--heat); text-transform: uppercase;
}

.nav-links { display: flex; gap: 1.8rem; }
.nav-links a {
  font-size: .85rem; font-weight: 500; color: var(--muted-2);
  transition: color .2s;
}
.nav-links a:hover, .nav-links a.active { color: var(--text); }

/* ── Hex background ───────────────────────────────────────────────────────── */
.hex-bg {
  position: fixed; inset: 0; pointer-events: none; z-index: 0;
  background-image:
    radial-gradient(ellipse 60% 50% at 20% 40%, rgba(255,107,53,.06) 0%, transparent 60%),
    radial-gradient(ellipse 50% 40% at 80% 70%, rgba(0,212,170,.04) 0%, transparent 60%),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='60' height='52'%3E%3Cpolygon points='30,2 56,16 56,44 30,58 4,44 4,16' fill='none' stroke='%231c2535' stroke-width='0.8'/%3E%3C/svg%3E");
  background-size: auto, auto, 60px 52px;
}

/* ── Hero (index page) ────────────────────────────────────────────────────── */
.hero {
  position: relative; z-index: 1;
  padding: 6rem 2rem 4rem;
  max-width: 900px; margin: 0 auto;
  text-align: center;
}

.hero-pill {
  display: inline-flex; align-items: center; gap: .4rem;
  padding: .3rem .8rem;
  border: 1px solid var(--border-2);
  border-radius: 999px;
  font-size: .72rem; font-weight: 600; letter-spacing: .1em;
  color: var(--heat); text-transform: uppercase;
  margin-bottom: 1.6rem;
}
.hero-pill span { width: 6px; height: 6px; border-radius: 50%; background: var(--heat); animation: pulse 1.8s infinite; }

.hero h1 {
  font-size: clamp(2rem, 5vw, 3.4rem);
  font-weight: 800; letter-spacing: -.03em; line-height: 1.1;
  margin-bottom: 1.2rem;
}
.hero h1 em { font-style: normal; color: var(--heat); }

.hero p {
  font-size: 1.05rem; color: var(--muted-2);
  max-width: 600px; margin: 0 auto 2.4rem;
  line-height: 1.7;
}

.hero-stats {
  display: flex; justify-content: center; gap: 3rem;
  margin-bottom: 3rem;
}
.hero-stat .num { font-size: 2.2rem; font-weight: 800; color: var(--heat); letter-spacing: -.04em; }
.hero-stat .label { font-size: .75rem; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; margin-top: .1rem; }

.city-quick-select {
  display: grid; grid-template-columns: 1fr auto;
  max-width: 520px; margin: 0 auto 1rem;
  border: 1px solid var(--border-2); border-radius: var(--radius-lg); overflow: hidden;
}
.city-quick-select select {
  background: var(--surface); border: none; outline: none;
  color: var(--text); font-size: .95rem; padding: .85rem 1.2rem;
  cursor: pointer; flex: 1;
}
.city-quick-select select option { background: var(--surface-2); }

/* ── Buttons ──────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
  padding: .75rem 1.6rem;
  border: none; border-radius: var(--radius); cursor: pointer;
  font-family: var(--font); font-size: .9rem; font-weight: 600;
  transition: all .2s; letter-spacing: .01em;
}
.btn-heat {
  background: var(--heat); color: #000;
}
.btn-heat:hover { background: #ff8255; transform: translateY(-1px); box-shadow: 0 6px 24px rgba(255,107,53,.35); }

.btn-ghost {
  background: transparent; color: var(--muted-2);
  border: 1px solid var(--border-2);
}
.btn-ghost:hover { color: var(--text); border-color: var(--border-2); }

.btn-save { background: var(--save); color: #000; }
.btn-save:hover { background: #26ffe0; }

.btn:disabled { opacity: .45; cursor: not-allowed; transform: none !important; box-shadow: none !important; }

/* ── Dashboard layout ─────────────────────────────────────────────────────── */
.dashboard {
  position: relative; z-index: 1;
  display: grid;
  grid-template-columns: 320px 1fr;
  min-height: calc(100vh - 58px);
}

/* ── Controls sidebar ─────────────────────────────────────────────────────── */
.controls {
  padding: 1.6rem;
  border-right: 1px solid var(--border);
  background: rgba(12,16,24,.7);
  display: flex; flex-direction: column; gap: 1.4rem;
  overflow-y: auto; max-height: calc(100vh - 58px); position: sticky; top: 58px;
}

.ctrl-group { display: flex; flex-direction: column; gap: .55rem; }

.ctrl-label {
  font-size: .7rem; font-weight: 700; letter-spacing: .1em;
  text-transform: uppercase; color: var(--muted);
}

.ctrl-select, .ctrl-input {
  background: var(--surface-2);
  border: 1px solid var(--border-2);
  border-radius: var(--radius);
  color: var(--text);
  font-family: var(--font); font-size: .9rem;
  padding: .65rem .9rem;
  outline: none; width: 100%; cursor: pointer;
  transition: border-color .2s;
}
.ctrl-select:focus, .ctrl-input:focus { border-color: var(--heat); }
.ctrl-select option { background: var(--surface-2); }

/* Scenario pills */
.scenario-pills { display: flex; flex-direction: column; gap: .4rem; }
.scenario-pill {
  padding: .55rem .8rem;
  border: 1px solid var(--border-2); border-radius: var(--radius);
  cursor: pointer; font-size: .82rem; transition: all .2s;
  color: var(--muted-2);
}
.scenario-pill:hover { border-color: var(--border-2); color: var(--text); }
.scenario-pill.active { border-color: var(--heat); background: var(--heat-dim); color: var(--heat); }
.scenario-pill .s-code { font-weight: 700; font-size: .75rem; }
.scenario-pill .s-desc { font-size: .72rem; color: inherit; opacity: .8; display: block; margin-top: .1rem; }

/* Sliders */
.slider-wrap { display: flex; flex-direction: column; gap: .35rem; }
.slider-row { display: flex; justify-content: space-between; align-items: center; }
.slider-val { font-family: var(--mono); font-size: .82rem; color: var(--save); font-weight: 600; }

input[type=range] {
  -webkit-appearance: none; width: 100%; height: 4px;
  background: var(--border-2); border-radius: 2px; outline: none; cursor: pointer;
}
input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none; width: 16px; height: 16px;
  background: var(--save); border-radius: 50%;
  box-shadow: 0 0 8px rgba(0,212,170,.5);
  transition: transform .15s;
}
input[type=range]::-webkit-slider-thumb:hover { transform: scale(1.2); }

.ctrl-divider { border: none; border-top: 1px solid var(--border); margin: .2rem 0; }

/* Year input */
.year-row { display: flex; align-items: center; gap: .6rem; }
.year-row input[type=number] {
  background: var(--surface-2); border: 1px solid var(--border-2); border-radius: var(--radius);
  color: var(--text); font-family: var(--mono); font-size: 1.1rem; font-weight: 700;
  padding: .5rem .8rem; width: 90px; outline: none; text-align: center;
}
.year-row input:focus { border-color: var(--heat); }
.year-presets { display: flex; gap: .3rem; flex-wrap: wrap; }
.year-preset {
  padding: .25rem .55rem; font-size: .72rem; font-weight: 600;
  border: 1px solid var(--border-2); border-radius: 4px; cursor: pointer;
  color: var(--muted-2); background: transparent; transition: all .15s;
}
.year-preset:hover, .year-preset.active { border-color: var(--heat); color: var(--heat); }

/* ── Results panel ────────────────────────────────────────────────────────── */
.results {
  padding: 1.6rem;
  display: flex; flex-direction: column; gap: 1.4rem;
  overflow-y: auto;
}

/* ── City header ──────────────────────────────────────────────────────────── */
.city-header {
  display: flex; align-items: flex-start; justify-content: space-between;
  padding: 1.2rem 1.4rem;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
}
.city-header .city-name { font-size: 1.6rem; font-weight: 800; letter-spacing: -.03em; }
.city-header .city-sub { font-size: .8rem; color: var(--muted-2); margin-top: .15rem; }
.city-coords { font-family: var(--mono); font-size: .75rem; color: var(--muted); }
.status-badge {
  display: inline-flex; align-items: center; gap: .4rem;
  padding: .3rem .7rem; border-radius: 999px; font-size: .72rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: .06em;
}
.status-badge.live { background: rgba(0,212,170,.15); color: var(--save); }
.status-badge.live::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: var(--save); animation: pulse 1.8s infinite; }
.status-badge.loading { background: rgba(245,197,24,.12); color: var(--warn); }
.status-badge.loading::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: var(--warn); animation: pulse .8s infinite; }

/* ── Metrics cards ────────────────────────────────────────────────────────── */
.metrics-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: .8rem;
}

.metric-card {
  padding: 1.1rem 1.2rem;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
  position: relative; overflow: hidden;
  transition: border-color .2s;
}
.metric-card:hover { border-color: var(--border-2); }
.metric-card.heat-card { border-color: rgba(255,107,53,.3); background: linear-gradient(135deg, var(--surface) 60%, var(--heat-dim)); }
.metric-card.save-card { border-color: rgba(0,212,170,.25); background: linear-gradient(135deg, var(--surface) 60%, var(--save-dim)); }

.metric-label { font-size: .68rem; font-weight: 700; text-transform: uppercase; letter-spacing: .1em; color: var(--muted); margin-bottom: .5rem; }
.metric-value { font-size: 1.9rem; font-weight: 800; letter-spacing: -.04em; line-height: 1; }
.metric-value.heat { color: var(--heat); }
.metric-value.save { color: var(--save); }
.metric-value.warn { color: var(--warn); }
.metric-sub { font-size: .72rem; color: var(--muted); margin-top: .3rem; }
.metric-delta {
  font-size: .75rem; font-weight: 600;
  padding: .15rem .4rem; border-radius: 4px; margin-top: .3rem; display: inline-block;
}
.metric-delta.down { background: rgba(0,212,170,.15); color: var(--save); }
.metric-delta.up   { background: rgba(255,51,88,.15); color: var(--danger); }

/* ── Pathways ─────────────────────────────────────────────────────────────── */
.section-title {
  font-size: .72rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: .1em; color: var(--muted); margin-bottom: .8rem;
  display: flex; align-items: center; gap: .5rem;
}
.section-title::after { content: ''; flex: 1; height: 1px; background: var(--border); }

.pathways-grid { display: flex; flex-direction: column; gap: .6rem; }

.pathway-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
  overflow: hidden;
}
.pathway-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: .85rem 1.1rem; cursor: pointer;
  transition: background .15s;
}
.pathway-header:hover { background: var(--surface-2); }
.pathway-left { display: flex; align-items: center; gap: .8rem; }
.pathway-icon {
  width: 36px; height: 36px; border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.1rem;
}
.pathway-icon.p1 { background: rgba(255,107,53,.15); }
.pathway-icon.p2 { background: rgba(245,197,24,.12); }
.pathway-icon.p3 { background: rgba(93,107,130,.15); }
.pathway-title { font-size: .88rem; font-weight: 600; }
.pathway-source { font-size: .68rem; color: var(--muted); margin-top: .1rem; }
.pathway-deaths { text-align: right; }
.pathway-deaths .num { font-size: 1.3rem; font-weight: 800; color: var(--heat); letter-spacing: -.03em; }
.pathway-deaths .label { font-size: .68rem; color: var(--muted); }

.pathway-body {
  border-top: 1px solid var(--border);
  padding: .9rem 1.1rem;
  display: none;
}
.pathway-body.open { display: block; }

.calc-row {
  display: flex; flex-direction: column; gap: .6rem;
  font-size: .8rem; color: var(--muted-2);
}
.calc-formula {
  font-family: var(--mono); font-size: .75rem;
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 6px; padding: .6rem .8rem;
  color: var(--text); line-height: 1.5;
  overflow-x: auto; white-space: pre-wrap; word-break: break-all;
}
.calc-vars {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: .4rem;
}
.calc-var {
  background: var(--surface-2); border-radius: 6px; padding: .4rem .6rem;
}
.calc-var .k { font-size: .67rem; color: var(--muted); }
.calc-var .v { font-size: .82rem; font-weight: 700; font-family: var(--mono); color: var(--text); }

/* ── Charts ───────────────────────────────────────────────────────────────── */
.charts-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 1rem;
}
@media (max-width: 1200px) { .charts-grid { grid-template-columns: 1fr; } }

.chart-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
  padding: 1.2rem 1.4rem;
}
.chart-card h3 {
  font-size: .8rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: .08em; color: var(--muted); margin-bottom: 1rem;
}
.chart-wrap { position: relative; height: 220px; }

/* ── Mitigation comparison ────────────────────────────────────────────────── */
.mit-section {
  background: var(--surface); border: 1px solid rgba(0,212,170,.2); border-radius: var(--radius-lg);
  padding: 1.3rem 1.4rem;
}
.mit-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 1.1rem; }
.mit-title { font-size: .95rem; font-weight: 700; }
.mit-tag {
  font-size: .7rem; font-weight: 600; padding: .25rem .6rem;
  border-radius: 999px; background: var(--save-dim); color: var(--save);
  text-transform: uppercase; letter-spacing: .06em;
}

.mit-compare {
  display: grid; grid-template-columns: 1fr 1fr 1fr; gap: .8rem;
}
.mit-col { display: flex; flex-direction: column; gap: .4rem; }
.mit-col-label { font-size: .68rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
.mit-col-val {
  font-size: 1.35rem; font-weight: 800; letter-spacing: -.03em;
}
.mit-col-val.baseline { color: var(--danger); }
.mit-col-val.mitigated { color: var(--save); }
.mit-col-val.saved { color: var(--warn); }
.mit-col-sub { font-size: .72rem; color: var(--muted); }

.mit-bar-track {
  margin-top: .8rem; height: 6px; border-radius: 3px; background: var(--border-2); overflow: hidden;
}
.mit-bar-fill {
  height: 100%; background: linear-gradient(90deg, var(--save), var(--heat));
  border-radius: 3px; transition: width .5s ease;
}

/* ── Strategic analysis ───────────────────────────────────────────────────── */
.analysis-grid { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: .8rem; }
@media (max-width: 1100px) { .analysis-grid { grid-template-columns: 1fr; } }

.analysis-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
  padding: 1.1rem 1.2rem;
}
.analysis-card h4 { font-size: .8rem; font-weight: 700; color: var(--heat); margin-bottom: .5rem; }
.analysis-card p { font-size: .8rem; color: var(--muted-2); line-height: 1.65; }

/* ── Empty / loading states ──────────────────────────────────────────────── */
.empty-state {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 5rem 2rem; text-align: center; color: var(--muted);
  gap: 1rem;
}
.empty-icon { font-size: 3rem; opacity: .4; }
.empty-state p { max-width: 360px; font-size: .88rem; line-height: 1.7; }

.spinner {
  width: 28px; height: 28px;
  border: 3px solid var(--border-2);
  border-top-color: var(--heat);
  border-radius: 50%;
  animation: spin .7s linear infinite;
}

/* ── System notice ────────────────────────────────────────────────────────── */
.sys-notice {
  background: rgba(28,37,53,.7); border: 1px solid var(--border); border-radius: var(--radius);
  padding: .6rem 1rem; font-size: .72rem; color: var(--muted); text-align: center;
  line-height: 1.5;
}

/* ── Animations ───────────────────────────────────────────────────────────── */
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: .35; }
}
@keyframes spin {
  to { transform: rotate(360deg); }
}
@keyframes fade-in {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}
.fade-in { animation: fade-in .35s ease; }

/* ── City search ─────────────────────────────────────────────────────────── */
.search-wrap { position: relative; }

.search-input {
  width: 100%;
  background: var(--surface-2);
  border: 1px solid var(--border-2);
  border-radius: var(--radius);
  color: var(--text);
  font-family: var(--font); font-size: .9rem;
  padding: .65rem .9rem .65rem 2.2rem;
  outline: none;
  transition: border-color .2s;
}
.search-input:focus { border-color: var(--heat); }
.search-input::placeholder { color: var(--muted); }

.search-icon {
  position: absolute; left: .7rem; top: 50%;
  transform: translateY(-50%);
  color: var(--muted); font-size: .85rem; pointer-events: none;
}

.search-suggestions {
  position: absolute; top: calc(100% + 4px); left: 0; right: 0;
  background: var(--surface-2);
  border: 1px solid var(--border-2);
  border-radius: var(--radius);
  z-index: 200;
  overflow: hidden;
  box-shadow: 0 8px 24px rgba(0,0,0,.4);
  display: none;
}
.search-suggestions.open { display: block; }

.suggestion-item {
  padding: .6rem .9rem;
  cursor: pointer;
  display: flex; align-items: center; justify-content: space-between;
  transition: background .12s;
  border-bottom: 1px solid var(--border);
  font-size: .85rem;
}
.suggestion-item:last-child { border-bottom: none; }
.suggestion-item:hover, .suggestion-item.selected { background: var(--surface); }
.suggestion-item .s-name { font-weight: 600; }
.suggestion-item .s-country { font-size: .72rem; color: var(--muted-2); }
.suggestion-item .s-nmr { font-size: .7rem; font-family: var(--mono); color: var(--heat); }
.suggestion-item .s-badge {
  font-size: .6rem; padding: .1rem .4rem; border-radius: 3px;
  background: var(--heat-dim); color: var(--heat);
  text-transform: uppercase; letter-spacing: .06em;
}
.suggestion-item .s-badge.geocoded {
  background: rgba(93,107,130,.15); color: var(--muted-2);
}
.suggestion-empty {
  padding: .6rem .9rem; font-size: .8rem; color: var(--muted); text-align: center;
}

/* ── Utility ──────────────────────────────────────────────────────────────── */
.hidden  { display: none !important; }
.mt-auto { margin-top: auto; }
.text-heat { color: var(--heat); }
.text-save { color: var(--save); }
.text-muted { color: var(--muted); }
