@font-face {
  font-family: "Geist";
  src: url("../fonts/Geist-Variable.ttf") format("truetype-variations");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Geist Mono";
  src: url("../fonts/GeistMono-Variable.ttf") format("truetype-variations");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

:root {
  --bg: #0b0b0a;
  --panel: #11120f;
  --panel-soft: #151713;
  --ink: #f0efe9;
  --muted: #8c8a80;
  --faint: #5c5a52;
  --rule: #25251f;
  --rule-strong: #34342d;
  --teal: #78d2bf;
  --teal-strong: #2fa58c;
  --blue: #7ca7ff;
  --amber: #e4b05a;
  --violet: #a68cff;
  --danger: #ff9d82;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
}

body {
  font-family: "Geist", system-ui, sans-serif;
  font-size: 14px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

button,
select,
input {
  font: inherit;
}

a {
  color: inherit;
}

.app-shell {
  display: grid;
  grid-template-columns: 304px minmax(0, 1fr);
  min-height: 100vh;
}

.filter-rail {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 22px 18px;
  border-right: 1px solid var(--rule);
  background: #090908;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.brand {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr);
  gap: 12px;
  align-items: center;
  color: var(--ink);
  text-decoration: none;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--rule);
}

.brand-mark {
  width: 42px;
  height: 42px;
  border: 1px solid var(--rule-strong);
  border-radius: 8px;
  display: grid;
  place-items: center;
  color: var(--teal);
  font-family: "Geist Mono", monospace;
  font-size: 18px;
  background: #10110f;
}

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

.brand strong {
  font-size: 15px;
  line-height: 1.15;
}

.brand em {
  color: var(--muted);
  font-style: normal;
  font-size: 12px;
  margin-top: 2px;
}

label {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 760;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

select,
input {
  height: 38px;
  border: 1px solid var(--rule-strong);
  border-radius: 8px;
  background: var(--panel);
  color: var(--ink);
  padding: 0 10px;
  outline: none;
}

select:focus,
input:focus,
button:focus-visible,
.district-shape:focus-visible {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(120, 210, 191, 0.18);
}

.check-row {
  grid-template-columns: 18px 1fr;
  gap: 10px;
  align-items: center;
  color: var(--ink);
  text-transform: none;
  letter-spacing: 0;
}

.check-row input {
  width: 16px;
  height: 16px;
  accent-color: var(--teal-strong);
}

.export-button {
  height: 42px;
  border: 0;
  border-radius: 8px;
  background: var(--teal-strong);
  color: #06110f;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  font-weight: 850;
  cursor: pointer;
}

.export-button svg {
  width: 17px;
  height: 17px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.source-note {
  margin-top: auto;
  padding: 12px;
  border: 1px solid rgba(228, 176, 90, 0.34);
  border-radius: 8px;
  background: rgba(228, 176, 90, 0.08);
  color: #e9ce9b;
}

.source-note strong {
  display: block;
  color: var(--amber);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 6px;
}

.source-note p,
.panel p,
.caveat-band,
.back-link {
  margin: 0;
  color: var(--muted);
}

.workspace {
  min-width: 0;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.back-link {
  display: inline-block;
  color: var(--muted);
  font-family: "Geist Mono", monospace;
  font-size: 12px;
  text-decoration: none;
  margin-bottom: 4px;
}

.back-link:hover {
  color: var(--ink);
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 34px;
  line-height: 1.05;
  letter-spacing: 0;
}

h2 {
  font-size: 17px;
  line-height: 1.2;
  letter-spacing: 0;
}

.status-pill {
  min-height: 34px;
  padding: 8px 12px;
  border: 1px solid var(--rule-strong);
  border-radius: 8px;
  background: var(--panel);
  color: var(--muted);
  font-family: "Geist Mono", monospace;
  font-size: 12px;
  text-align: right;
  max-width: 360px;
}

.status-pill.warning {
  color: var(--amber);
  border-color: rgba(228, 176, 90, 0.36);
}

.caveat-band {
  padding: 12px 14px;
  border-left: 4px solid var(--amber);
  border-radius: 8px;
  background: rgba(228, 176, 90, 0.08);
  color: #d9c8a7;
}

.caveat-band strong {
  color: var(--amber);
  margin-right: 8px;
}

.kpi-strip {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 10px;
}

.metric,
.panel {
  border: 1px solid var(--rule);
  border-radius: 8px;
  background: var(--panel);
}

.metric {
  padding: 13px 14px;
  display: grid;
  gap: 5px;
}

.metric span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 820;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.metric strong {
  font-size: 23px;
  line-height: 1.05;
}

.metric.warning strong {
  color: var(--amber);
}

.panel {
  min-width: 0;
  padding: 16px;
}

.panel-heading {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 12px;
}

.panel-heading p {
  font-size: 13px;
  line-height: 1.42;
  margin-top: 4px;
}

.infographic-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(280px, 0.65fr);
  gap: 16px;
}

.map-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(180px, 0.35fr);
  gap: 14px;
  align-items: stretch;
}

.map-frame {
  min-height: 338px;
  border: 1px solid var(--rule);
  border-radius: 8px;
  background: #0d0e0c;
  overflow: hidden;
}

.map-frame svg {
  width: 100%;
  height: 100%;
  min-height: 338px;
  display: block;
}

.district-shape {
  stroke: #0b0b0a;
  stroke-width: 1.15;
  cursor: pointer;
  transition: filter 160ms ease, stroke 160ms ease, stroke-width 160ms ease, opacity 160ms ease;
}

.district-shape:hover,
.district-shape:focus {
  filter: brightness(1.16) saturate(1.18);
  outline: none;
}

.district-shape.active {
  stroke: var(--ink);
  stroke-width: 2.8;
}

.district-shape.low-sample {
  stroke-dasharray: 3 2;
}

.district-label {
  pointer-events: none;
  text-anchor: middle;
  font-size: 12px;
  font-weight: 820;
  fill: var(--ink);
  paint-order: stroke;
  stroke: #0b0b0a;
  stroke-width: 3px;
}

.map-legend {
  display: grid;
  align-content: end;
  gap: 10px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 720;
}

.tooltip-card {
  display: grid;
  grid-template-columns: 1fr;
  gap: 5px;
  padding: 10px;
  border: 1px solid var(--rule-strong);
  border-radius: 8px;
  background: var(--panel-soft);
}

.tooltip-card span,
.tooltip-card small {
  color: var(--muted);
  font-size: 11px;
  font-weight: 820;
  text-transform: uppercase;
}

.tooltip-card strong {
  font-size: 18px;
  line-height: 1.1;
  overflow-wrap: break-word;
}

.tooltip-card em {
  color: var(--teal);
  font-size: 14px;
  font-style: normal;
  font-weight: 820;
  overflow-wrap: break-word;
}

.legend-row {
  display: grid;
  grid-template-columns: 22px 1fr;
  gap: 8px;
  align-items: center;
}

.legend-swatch {
  width: 22px;
  height: 16px;
  border-radius: 4px;
  border: 1px solid var(--rule-strong);
}

.evidence-panel {
  display: grid;
  align-content: start;
  gap: 12px;
}

.evidence-list {
  display: grid;
  gap: 10px;
}

.evidence-list div {
  padding: 10px 0;
  border-bottom: 1px solid var(--rule);
  display: grid;
  gap: 5px;
}

.evidence-list span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 820;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.evidence-list strong {
  font-size: 20px;
  line-height: 1.15;
}

.view-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.65fr) minmax(280px, 0.75fr);
  gap: 16px;
}

.lower-grid {
  grid-template-columns: minmax(320px, 0.85fr) minmax(0, 1.35fr);
}

.chart-frame {
  width: 100%;
  min-height: 320px;
  overflow: hidden;
}

.chart-frame.compact {
  min-height: 320px;
}

.chart-frame svg {
  width: 100%;
  height: auto;
  display: block;
}

.crime-panel {
  grid-column: 1 / -1;
}

.crime-readout {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 12px;
}

.crime-readout div {
  min-width: 0;
  padding: 10px;
  border: 1px solid var(--rule);
  border-radius: 8px;
  background: var(--panel-soft);
}

.crime-readout span {
  display: block;
  color: var(--muted);
  font-size: 11px;
  font-weight: 820;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 4px;
}

.crime-readout strong {
  display: block;
  font-size: 19px;
  line-height: 1.12;
  overflow-wrap: break-word;
}

.crime-readout p {
  grid-column: 1 / -1;
  padding: 10px 12px;
  border-left: 4px solid var(--danger);
  border-radius: 8px;
  background: rgba(255, 157, 130, 0.08);
  color: #e0b4a7;
}

.axis text,
.chart-label,
.legend text {
  fill: var(--muted);
  font-family: "Geist Mono", monospace;
  font-size: 11px;
}

.axis line,
.axis path,
.grid-line {
  stroke: var(--rule-strong);
}

.ranking-list {
  display: grid;
  gap: 8px;
}

.rank-row {
  display: grid;
  grid-template-columns: 1fr auto 42px;
  gap: 10px;
  align-items: center;
  padding: 9px 0;
  border-bottom: 1px solid var(--rule);
  color: var(--muted);
}

.rank-row button {
  text-align: left;
  border: 0;
  padding: 0;
  background: transparent;
  color: var(--ink);
  cursor: pointer;
  font-weight: 720;
}

.rank-row strong {
  color: var(--ink);
}

.rank-row em {
  color: var(--amber);
  font-style: normal;
  text-align: right;
}

.table-panel {
  padding: 0;
  overflow: hidden;
}

.table-panel .panel-heading {
  padding: 16px 16px 4px;
}

.table-scroll {
  overflow: auto;
}

table {
  width: 100%;
  min-width: 840px;
  border-collapse: collapse;
}

th,
td {
  padding: 11px 14px;
  border-top: 1px solid var(--rule);
  text-align: left;
  font-size: 13px;
}

th {
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  background: #0e0f0d;
}

td {
  color: #d7d5cc;
}

.empty-row td {
  color: var(--muted);
  text-align: center;
  padding: 28px;
}

.error-state {
  max-width: 760px;
  margin: 12vh auto;
  padding: 24px;
  border: 1px solid rgba(255, 157, 130, 0.34);
  border-radius: 8px;
  background: rgba(255, 157, 130, 0.08);
}

.error-state h1 {
  color: var(--danger);
  margin-bottom: 8px;
}

@media (max-width: 1060px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .filter-rail {
    position: static;
    height: auto;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .brand,
  .source-note {
    grid-column: 1 / -1;
  }

  .topbar,
  .infographic-grid,
  .view-grid,
  .lower-grid {
    display: grid;
    grid-template-columns: 1fr;
  }

  .map-layout {
    grid-template-columns: 1fr;
  }

  .kpi-strip {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .crime-readout {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .status-pill {
    justify-self: start;
    text-align: left;
  }
}

@media (max-width: 640px) {
  .workspace,
  .filter-rail {
    padding: 16px;
  }

  .filter-rail,
  .kpi-strip,
  .crime-readout {
    grid-template-columns: 1fr;
  }

  h1 {
    font-size: 27px;
  }

  .metric strong {
    font-size: 21px;
  }

  .map-frame,
  .map-frame svg {
    min-height: 300px;
  }
}
