:root {
  color-scheme: light;
  --navy: #06253b;
  --navy-soft: #103c55;
  --teal: #087b83;
  --teal-dark: #05636a;
  --gold: #d6a32b;
  --ink: #122b3d;
  --muted: #607381;
  --line: #cfdae0;
  --panel: #f8fbfc;
  --map: #e9eff2;
  --white: #fff;
  --risk-1: #2f6fa3;
  --risk-2: #3f8f5f;
  --risk-3: #d6a32b;
  --risk-4: #d97732;
  --risk-5: #b84545;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

html { background: #e7eef1; }

body {
  margin: 0;
  min-width: 320px;
  color: var(--ink);
  background: #e7eef1;
}

button,
input,
select { font: inherit; }

button,
select { cursor: pointer; }

button:focus-visible,
input:focus-visible,
select:focus-visible,
a:focus-visible,
.district-shape:focus-visible {
  outline: 3px solid #f2b93b;
  outline-offset: 3px;
}

.skip-link {
  position: fixed;
  top: 8px;
  left: 8px;
  z-index: 50;
  padding: 10px 14px;
  color: var(--navy);
  background: var(--white);
  transform: translateY(-150%);
}

.skip-link:focus { transform: none; }

.app-header {
  position: relative;
  z-index: 10;
  display: grid;
  grid-template-columns: minmax(250px, 360px) minmax(320px, 1fr) auto;
  gap: 24px;
  align-items: center;
  min-height: 86px;
  margin: 10px;
  padding: 13px 18px;
  color: var(--white);
  background: var(--navy);
  border: 1px solid #37576a;
  border-radius: 17px;
  box-shadow: 0 12px 34px rgb(6 37 59 / 18%);
}

.brand {
  display: flex;
  gap: 12px;
  align-items: center;
  color: inherit;
  text-decoration: none;
}

.brand__mark {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  color: #f2c45a;
  border: 2px solid currentColor;
  border-radius: 12px;
  font-size: 26px;
}

.brand strong,
.brand small { display: block; }

.brand strong { max-width: 285px; font-size: 15px; line-height: 1.15; }
.brand small { margin-top: 4px; color: #b8cad3; font-size: 12px; }

.disclaimer {
  margin: 0;
  padding: 9px 14px;
  color: #eef5f7;
  background: rgb(255 255 255 / 7%);
  border: 1px solid rgb(224 184 87 / 42%);
  border-radius: 9px;
  font-size: 12px;
  line-height: 1.35;
}

.language-switcher {
  display: flex;
  padding: 3px;
  border: 1px solid rgb(255 255 255 / 25%);
  border-radius: 10px;
}

.language-switcher button {
  min-width: 37px;
  padding: 7px;
  color: #cfe0e6;
  background: transparent;
  border: 0;
  border-radius: 7px;
  font-weight: 800;
  font-size: 12px;
}

.language-switcher button[aria-pressed="true"] { color: var(--navy); background: #f2c45a; }

.workspace {
  display: grid;
  grid-template-columns: minmax(230px, 285px) minmax(440px, 1fr) minmax(270px, 330px);
  gap: 12px;
  width: calc(100% - 20px);
  max-width: 1580px;
  min-height: calc(100vh - 118px);
  margin: 0 auto 10px;
}

.panel,
.map-panel {
  overflow: hidden;
  background: var(--panel);
  border: 1px solid #d9e2e7;
  border-radius: 16px;
  box-shadow: 0 9px 24px rgb(25 56 73 / 7%);
}

.panel { padding: 22px; }

.panel__heading { margin-bottom: 18px; }

.eyebrow {
  margin: 0 0 4px;
  color: var(--teal-dark);
  font-size: 11px;
  font-weight: 850;
  letter-spacing: .09em;
  text-transform: uppercase;
}

h1,
h2,
h3,
p { margin-top: 0; }

h1,
h2 { letter-spacing: -.035em; }

h1 { margin-bottom: 0; font-size: clamp(24px, 2.2vw, 32px); }
h2 { margin-bottom: 8px; font-size: clamp(22px, 2vw, 30px); }
h3 { font-size: 15px; }

.controls form { display: grid; gap: 8px; }

.controls label {
  margin-top: 7px;
  color: #2d4554;
  font-size: 12px;
  font-weight: 800;
}

.controls input,
.controls select {
  width: 100%;
  min-height: 45px;
  padding: 10px 12px;
  color: var(--ink);
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: 9px;
}

.search-row { display: grid; grid-template-columns: 1fr 43px; gap: 6px; }

.icon-button,
.quiet-button,
.close-button {
  color: var(--navy);
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: 9px;
  font-weight: 800;
}

.control-pair { display: grid; grid-template-columns: 1fr 1.25fr; gap: 8px; }
.control-pair > div { display: grid; gap: 8px; }

.method-note,
.source-note {
  margin-top: 24px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
  font-size: 12px;
  line-height: 1.55;
}

.method-note p,
.source-note p { margin: 6px 0 0; color: var(--muted); }

.map-panel {
  display: flex;
  flex-direction: column;
  min-width: 0;
  background: var(--map);
}

.map-toolbar {
  position: relative;
  z-index: 2;
  display: flex;
  gap: 18px;
  justify-content: space-between;
  align-items: flex-start;
  margin: 12px;
  padding: 15px 16px;
  background: rgb(255 255 255 / 94%);
  border: 1px solid #dbe4e8;
  border-radius: 13px;
  box-shadow: 0 9px 26px rgb(39 64 77 / 9%);
}

.map-toolbar h2 { margin-bottom: 3px; }
.map-toolbar p:last-child { margin: 0; color: var(--muted); font-size: 12px; }
.quiet-button { flex: none; padding: 8px 11px; font-size: 12px; }

.map-stage {
  position: relative;
  display: grid;
  flex: 1;
  place-items: center;
  min-height: 560px;
  overflow: hidden;
}

#uganda-map {
  display: block;
  width: min(94%, 680px);
  height: min(72vh, 760px);
  min-height: 520px;
  filter: drop-shadow(0 18px 18px rgb(18 43 61 / 10%));
}

.district-shape {
  stroke: #415e6c;
  stroke-width: 1.25;
  vector-effect: non-scaling-stroke;
  transition: filter 140ms ease, opacity 140ms ease, stroke 140ms ease;
}

.district-shape:hover,
.district-shape:focus-visible {
  filter: brightness(1.06);
  stroke: #041a29;
  stroke-width: 2.5;
}

.district-shape.is-selected {
  stroke: #041a29;
  stroke-width: 4;
  filter: drop-shadow(0 3px 3px rgb(0 0 0 / 28%));
}

.map-tooltip {
  position: fixed;
  z-index: 20;
  max-width: 220px;
  padding: 8px 10px;
  color: var(--white);
  background: var(--navy);
  border-radius: 8px;
  box-shadow: 0 7px 18px rgb(6 37 59 / 25%);
  pointer-events: none;
  font-size: 12px;
}

.map-tooltip strong,
.map-tooltip span { display: block; }
.map-tooltip span { margin-top: 3px; color: #c7d8df; }

.map-credit {
  position: absolute;
  right: 12px;
  bottom: 10px;
  margin: 0;
  padding: 5px 8px;
  color: #455d6a;
  background: rgb(255 255 255 / 85%);
  border-radius: 6px;
  font-size: 10px;
}

.loading {
  position: absolute;
  z-index: 5;
  inset: 0;
  display: grid;
  place-content: center;
  justify-items: center;
  background: var(--map);
}

.loading span {
  width: 34px;
  height: 34px;
  border: 4px solid #bfd0d8;
  border-top-color: var(--teal);
  border-radius: 50%;
  animation: spin 700ms linear infinite;
}

.loading p { margin: 12px 0 0; color: var(--muted); font-size: 13px; }

@keyframes spin { to { transform: rotate(360deg); } }

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 15px;
  justify-content: center;
  padding: 12px 16px 15px;
  color: #4b626f;
  background: rgb(255 255 255 / 72%);
  border-top: 1px solid #d5e0e5;
  font-size: 10px;
}

.legend span { display: inline-flex; gap: 4px; align-items: center; }
.legend i { width: 12px; height: 12px; border-radius: 3px; }
.legend em { font-style: normal; }
.risk-1 { background: var(--risk-1); }
.risk-2 { background: var(--risk-2); }
.risk-3 { background: var(--risk-3); }
.risk-4 { background: var(--risk-4); }
.risk-5 { background: var(--risk-5); }

.insights { position: relative; }
.insights > div > p:not(.eyebrow) { color: var(--muted); font-size: 13px; line-height: 1.55; }

.stat-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin: 16px 0;
}

.stat-grid div {
  padding: 12px;
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: 10px;
}

.stat-grid div:last-child { grid-column: 1 / -1; }
.stat-grid dt { color: var(--muted); font-size: 11px; }
.stat-grid dd { margin: 2px 0 0; font-size: 22px; font-weight: 850; }
.stat-grid dd::after { content: "/100"; color: var(--muted); font-size: 11px; font-weight: 650; }
.stat-grid div:last-child dd::after { content: ""; }

.hotspots { margin-top: 22px; padding-top: 17px; border-top: 1px solid var(--line); }
.hotspots ol { margin: 0; padding: 0; list-style: none; }
.hotspots li + li { border-top: 1px solid #e0e7ea; }
.hotspots button { display: flex; width: 100%; justify-content: space-between; padding: 9px 2px; color: var(--ink); background: transparent; border: 0; text-align: left; }
.hotspots button span { color: var(--muted); font-size: 12px; }

.close-button {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 36px;
  height: 36px;
  font-size: 20px;
}

#district-region { margin: -5px 0 15px; color: var(--muted); font-size: 13px; }

.score-card {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0 13px;
  align-items: center;
  padding: 14px;
  background: var(--white);
  border: 1px solid var(--line);
  border-left: 5px solid var(--risk-3);
  border-radius: 11px;
}

.score-card strong { grid-row: 1 / span 2; font-size: 44px; letter-spacing: -.06em; }
.score-card::after { content: "/100"; color: var(--muted); font-size: 11px; }
.score-card span { color: var(--muted); font-size: 12px; font-weight: 700; }

.component-list { margin: 20px 0; }
.component-list div { display: grid; grid-template-columns: 1fr auto; gap: 5px 10px; margin-top: 12px; }
.component-list dt { font-size: 12px; font-weight: 750; }
.component-list dd { margin: 0; font-size: 12px; font-weight: 800; }
.component-list i { grid-column: 1 / -1; height: 7px; overflow: hidden; background: #dce5e9; border-radius: 20px; }
.component-list i span { display: block; height: 100%; background: var(--teal); border-radius: inherit; }

.comparison { padding-top: 18px; border-top: 1px solid var(--line); }
.comparison__track { position: relative; height: 12px; margin: 20px 0 12px; background: linear-gradient(90deg, var(--risk-1), var(--risk-2), var(--risk-3), var(--risk-4), var(--risk-5)); border-radius: 20px; }
.comparison__track span,
.comparison__track i { position: absolute; top: 50%; width: 3px; height: 22px; transform: translate(-50%, -50%); }
.comparison__track span { background: var(--white); border: 1px solid var(--navy); }
.comparison__track i { background: var(--navy); }
.comparison p { color: var(--muted); font-size: 12px; line-height: 1.5; }

.source-note { margin-top: 28px; }

noscript { display: block; margin: 12px; padding: 20px; background: var(--white); }

@media (max-width: 1100px) {
  .app-header { grid-template-columns: 1fr auto; }
  .disclaimer { grid-column: 1 / -1; grid-row: 2; }
  .workspace { grid-template-columns: 250px minmax(430px, 1fr); }
  .insights { grid-column: 1 / -1; }
  .insights { display: grid; grid-template-columns: 1fr 1fr; gap: 30px; }
  .source-note { margin-top: 0; padding-top: 0; border-top: 0; }
}

@media (max-width: 760px) {
  .app-header { display: flex; flex-wrap: wrap; gap: 12px; margin: 0; border-radius: 0 0 16px 16px; }
  .brand { flex: 1 1 250px; }
  .disclaimer { order: 3; width: 100%; }
  .workspace { display: block; width: calc(100% - 16px); margin-top: 8px; }
  .panel,
  .map-panel { margin-bottom: 8px; }
  .controls { padding: 18px; }
  .controls form { grid-template-columns: 1fr 1fr; gap: 8px 10px; }
  .controls form > label,
  .controls form > select,
  .controls form > .search-row,
  .controls form > .control-pair { grid-column: 1 / -1; }
  .method-note { margin-top: 18px; }
  .map-toolbar { align-items: center; }
  .map-stage { min-height: 515px; }
  #uganda-map { width: 98%; height: 540px; min-height: 0; }
  .insights { display: block; padding: 18px; }
  .source-note { margin-top: 24px; padding-top: 18px; border-top: 1px solid var(--line); }
}

@media (max-width: 480px) {
  .brand strong { font-size: 14px; }
  .brand small { font-size: 11px; }
  .language-switcher { margin-left: auto; }
  .control-pair { grid-template-columns: 1fr; }
  .map-toolbar { display: block; }
  .quiet-button { margin-top: 10px; }
  .map-stage { min-height: 455px; }
  #uganda-map { height: 480px; }
  .legend { justify-content: flex-start; }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; }
}
