:root {
  color-scheme: light;
  --bg: #f4f1ea;
  --surface: #fffefa;
  --surface-strong: #f8faf8;
  --ink: #1c2420;
  --muted: #66736c;
  --line: #d8ded7;
  --sidebar: #17201b;
  --sidebar-soft: #223029;
  --teal: #0f766e;
  --red: #b23a48;
  --purple: #7057a3;
  --blue: #28708d;
  --gold: #a06a18;
  --shadow: 0 18px 48px rgba(28, 36, 32, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  background: var(--bg);
  color: var(--ink);
  font-family: "Segoe UI", "Noto Sans TC", Arial, sans-serif;
}

button,
input,
select {
  font: inherit;
}

a {
  color: inherit;
}

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

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 24px;
  padding: 28px 22px;
  background: var(--sidebar);
  color: #f6f4ed;
}

.brand {
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr);
  gap: 14px;
  align-items: center;
}

.brand-mark {
  display: grid;
  width: 48px;
  height: 48px;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-radius: 8px;
  background: #f6f4ed;
  color: var(--sidebar);
  font-weight: 800;
}

.brand h1,
.topbar h2,
.section-heading h3 {
  margin: 0;
  line-height: 1.18;
}

.brand h1 {
  font-size: 22px;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

.sidebar .eyebrow {
  color: #adc0b6;
}

.control-group {
  display: grid;
  gap: 9px;
}

.control-group label,
.control-label {
  color: #d8e1dc;
  font-size: 13px;
  font-weight: 700;
}

select,
input {
  width: 100%;
  min-height: 42px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 8px;
  background: var(--sidebar-soft);
  color: #fffefa;
  padding: 0 12px;
  outline: none;
}

select:focus,
input:focus,
button:focus-visible {
  border-color: #a9d8ce;
  box-shadow: 0 0 0 3px rgba(169, 216, 206, 0.22);
}

.hint {
  margin: 0;
  color: #adc0b6;
  font-size: 12px;
  line-height: 1.6;
}

.segmented {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px;
  padding: 4px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 8px;
  background: var(--sidebar-soft);
}

.segment {
  min-height: 34px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: #c8d4ce;
  cursor: pointer;
}

.segment.active {
  background: #f6f4ed;
  color: var(--sidebar);
  font-weight: 800;
}

.primary-action {
  min-height: 44px;
  border: 0;
  border-radius: 8px;
  background: #a9d8ce;
  color: #10211c;
  font-weight: 800;
  cursor: pointer;
}

.primary-action:active {
  transform: translateY(1px);
}

.home-area-actions {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 8px;
}

.side-action {
  min-height: 36px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 8px;
  background: var(--sidebar-soft);
  color: #f6f4ed;
  padding: 0 10px;
  font-size: 12px;
  font-weight: 800;
  cursor: pointer;
}

.side-action:disabled {
  cursor: default;
  opacity: 0.48;
}

.home-area-label {
  color: #adc0b6;
  font-size: 12px;
  line-height: 1.5;
}

.source-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: auto;
}

.source-strip a {
  display: inline-flex;
  min-height: 32px;
  align-items: center;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 999px;
  padding: 0 11px;
  color: #dbe7e1;
  font-size: 12px;
  text-decoration: none;
}

.dashboard {
  display: grid;
  gap: 22px;
  align-content: start;
  padding: 28px;
}

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

.topbar h2 {
  font-size: clamp(24px, 3vw, 38px);
}

.hero-copy {
  max-width: 760px;
  margin-top: 12px;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.75;
}

.hero-copy p {
  margin: 0;
}

.hero-copy p + p {
  margin-top: 4px;
}

.status-chips {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
  max-width: 640px;
}

.chip {
  display: inline-flex;
  min-height: 31px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  padding: 0 11px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.chip.live {
  border-color: rgba(15, 118, 110, 0.28);
  color: var(--teal);
}

.chip.fallback {
  border-color: rgba(160, 106, 24, 0.28);
  color: var(--gold);
}

.chip.error {
  border-color: rgba(178, 58, 72, 0.28);
  color: var(--red);
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(155px, 1fr));
  gap: 14px;
}

.period-strip {
  display: grid;
  grid-template-columns: minmax(180px, auto) 1fr;
  gap: 14px;
  align-items: center;
  border: 1px solid rgba(15, 118, 110, 0.2);
  border-radius: 8px;
  background: rgba(15, 118, 110, 0.08);
  padding: 13px 16px;
}

.period-strip strong {
  display: block;
  color: var(--ink);
  font-size: 17px;
}

.period-strip p:last-child {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.55;
}

.metric,
.map-panel,
.insight-panel,
.issue-panel,
.risk-method,
.profile-panel,
.share-panel,
.ranking-panel,
.report-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.metric {
  display: grid;
  gap: 8px;
  min-height: 132px;
  padding: 18px;
}

.metric-label {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.metric strong {
  font-size: clamp(30px, 4vw, 48px);
  line-height: 1;
}

.metric span:last-child {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.4;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(310px, 0.55fr);
  gap: 14px;
}

.map-panel,
.insight-panel,
.issue-panel,
.risk-method,
.profile-panel,
.share-panel,
.ranking-panel,
.report-panel {
  padding: 18px;
}

.risk-method {
  display: grid;
  gap: 4px;
}

.profile-grid,
.ranking-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(360px, 0.85fr);
  gap: 14px;
}

.profile-body,
.ranking-list,
.district-list,
.report-cards {
  display: grid;
  gap: 10px;
}

.profile-hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 104px;
  gap: 14px;
  align-items: center;
  border-bottom: 1px solid var(--line);
  padding-bottom: 14px;
}

.profile-label {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}

.profile-hero strong {
  display: block;
  font-size: 24px;
  line-height: 1.2;
}

.profile-hero p {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
}

.profile-score {
  display: grid;
  place-items: center;
  min-height: 92px;
  border-radius: 8px;
  background: #edf7f3;
  color: var(--teal);
  font-weight: 900;
}

.profile-score span {
  font-size: 42px;
  line-height: 1;
}

.profile-score small {
  color: var(--muted);
}

.profile-facts {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  margin-top: 14px;
}

.profile-facts div {
  display: grid;
  gap: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-strong);
  padding: 10px;
}

.profile-facts span,
.profile-facts small {
  color: var(--muted);
  font-size: 12px;
}

.profile-facts strong {
  font-size: 22px;
  line-height: 1;
}

.share-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.share-card {
  border: 1px solid rgba(15, 118, 110, 0.24);
  border-radius: 8px;
  background: #fffefa;
  padding: 8px;
  overflow: hidden;
}

.share-card-canvas {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 6px;
  background: #fffefa;
}

.share-card strong {
  display: block;
  font-size: 26px;
  line-height: 1.15;
}

.share-card p {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.share-score {
  min-width: 72px;
  color: var(--teal);
  font-size: 44px;
  font-weight: 900;
  line-height: 1;
  text-align: right;
}

.share-tags {
  grid-column: 1 / -1;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.share-tags span {
  border-radius: 999px;
  background: rgba(15, 118, 110, 0.1);
  padding: 5px 9px;
  color: var(--teal);
  font-size: 12px;
  font-weight: 900;
}

.share-text {
  width: 100%;
  min-height: 128px;
  margin-top: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-strong);
  color: var(--ink);
  padding: 10px;
  resize: vertical;
  line-height: 1.55;
}

.ranking-row,
.district-row {
  display: grid;
  grid-template-columns: 32px minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-strong);
  padding: 10px;
}

.ranking-row {
  width: 100%;
  color: inherit;
  cursor: pointer;
  text-align: left;
}

.ranking-row:hover,
.ranking-row.is-selected {
  border-color: rgba(15, 118, 110, 0.38);
  background: #edf7f3;
}

.ranking-rank {
  display: grid;
  width: 28px;
  height: 28px;
  place-items: center;
  border-radius: 999px;
  background: #f1ebe1;
  color: #7a4b12;
  font-size: 12px;
  font-weight: 900;
}

.ranking-name {
  display: block;
  font-weight: 900;
}

.ranking-detail,
.district-row span {
  color: var(--muted);
  font-size: 12px;
}

.ranking-row strong {
  color: var(--teal);
  font-size: 20px;
}

.district-row {
  grid-template-columns: 32px minmax(0, 1fr);
}

.district-track {
  grid-column: 2;
  height: 8px;
  border-radius: 999px;
  background: #ece8df;
  overflow: hidden;
}

.district-track span {
  display: block;
  height: 100%;
  min-width: 8px;
  border-radius: inherit;
  background: #7a4b12;
}

.report-panel {
  display: grid;
  gap: 12px;
}

.report-toggle {
  display: inline-grid;
  grid-template-columns: repeat(2, minmax(74px, 1fr));
  gap: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-strong);
  padding: 4px;
}

.report-mode {
  min-height: 30px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
  cursor: pointer;
}

.report-mode.active {
  background: var(--teal);
  color: #fffefa;
}

.report-cards {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.report-card {
  display: grid;
  gap: 7px;
  align-content: start;
  min-height: 128px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-strong);
  padding: 13px;
}

.report-card span,
.report-card small {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.report-card strong {
  font-size: 28px;
  line-height: 1;
}

.report-card p {
  margin: 0;
  color: var(--ink);
  font-size: 13px;
  font-weight: 800;
  line-height: 1.45;
}

.risk-formula-list {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.risk-formula-item {
  display: grid;
  min-height: 104px;
  gap: 10px;
  align-content: space-between;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-strong);
  padding: 12px;
}

.risk-formula-item b {
  display: block;
  margin-bottom: 5px;
  font-size: 13px;
}

.risk-formula-item span {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.risk-formula-item strong {
  color: var(--teal);
  font-size: 20px;
}

.analysis-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(280px, 0.9fr);
  gap: 14px;
}

.analysis-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
  padding: 18px;
}

.analysis-panel-wide {
  grid-row: span 2;
}

.matrix-panel-wide {
  grid-column: 1 / -1;
}

.stack-chart {
  display: grid;
  gap: 13px;
}

.stack-row {
  display: grid;
  grid-template-columns: 112px minmax(0, 1fr);
  gap: 8px 12px;
  align-items: center;
  border-top: 1px solid var(--line);
  padding-top: 12px;
}

.stack-row:first-child {
  border-top: 0;
  padding-top: 0;
}

.stack-row.is-selected .stack-label b {
  color: var(--teal);
}

.stack-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.stack-label b {
  font-size: 13px;
}

.stack-label span,
.stack-values {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.stack-bars {
  display: grid;
  gap: 4px;
}

.stack-bar {
  display: block;
  height: 8px;
  min-width: 8px;
  border-radius: 999px;
}

.stack-bar.traffic {
  background: var(--red);
}

.stack-bar.drug {
  background: var(--gold);
}

.stack-bar.drugCrime {
  background: #7a4b12;
}

.stack-values {
  grid-column: 2;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.risk-matrix {
  position: relative;
  min-height: 560px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background:
    linear-gradient(90deg, rgba(122, 75, 18, 0.08) 0 50%, rgba(178, 58, 72, 0.08) 50% 100%),
    linear-gradient(0deg, rgba(28, 36, 32, 0.02) 0 50%, rgba(15, 118, 110, 0.08) 50% 100%),
    linear-gradient(to right, rgba(28, 36, 32, 0.08) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(28, 36, 32, 0.08) 1px, transparent 1px),
    var(--surface-strong);
  background-size: 25% 25%;
  overflow: hidden;
}

.matrix-quadrants {
  display: none;
  grid-template-areas:
    "drug high"
    "low traffic";
  grid-template-columns: repeat(2, minmax(0, 1fr));
  grid-template-rows: repeat(2, minmax(0, 1fr));
  gap: 18px;
  z-index: 3;
}

.matrix-quadrant {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 8px;
  min-width: 0;
  border: 1px solid rgba(28, 36, 32, 0.08);
  border-radius: 8px;
  background: rgba(255, 254, 250, 0.48);
  padding: 10px;
}

.matrix-quadrant.high {
  grid-area: high;
}

.matrix-quadrant.drug {
  grid-area: drug;
}

.matrix-quadrant.traffic {
  grid-area: traffic;
}

.matrix-quadrant.low {
  grid-area: low;
}

.matrix-quadrant-title {
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}

.matrix-quadrant.high .matrix-quadrant-title {
  color: var(--red);
}

.matrix-chip-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(88px, 1fr));
  gap: 8px;
  align-content: start;
}

.matrix-chip {
  display: grid;
  grid-template-columns: 22px minmax(0, 1fr);
  gap: 6px;
  align-items: center;
  min-height: 38px;
  border: 1px solid rgba(28, 36, 32, 0.12);
  border-radius: 8px;
  background: rgba(255, 254, 250, 0.92);
  padding: 5px 7px;
  box-shadow: 0 5px 12px rgba(28, 36, 32, 0.1);
}

.matrix-chip.is-selected {
  border-color: rgba(15, 118, 110, 0.42);
  background: #edf7f3;
}

.matrix-chip-dot {
  display: block;
  width: var(--dot-size);
  height: var(--dot-size);
  min-width: var(--dot-size);
  border: 2px solid #fffefa;
  border-radius: 999px;
  background: rgba(122, 75, 18, 0.88);
  box-shadow: 0 4px 10px rgba(28, 36, 32, 0.16);
}

.matrix-chip.is-selected .matrix-chip-dot {
  background: var(--teal);
}

.matrix-chip-text {
  display: grid;
  gap: 1px;
  min-width: 0;
}

.matrix-chip-text b {
  color: var(--ink);
  font-size: 12px;
  line-height: 1.2;
  white-space: nowrap;
}

.matrix-chip-text small {
  color: var(--muted);
  font-size: 10px;
  line-height: 1.2;
  white-space: nowrap;
}

.matrix-cross {
  position: absolute;
  z-index: 1;
  background: rgba(28, 36, 32, 0.34);
  box-shadow: 0 0 0 1px rgba(255, 254, 250, 0.72);
}

.matrix-cross-x {
  left: 0;
  top: 50%;
  width: 100%;
  height: 2px;
}

.matrix-cross-y {
  left: 50%;
  top: 0;
  width: 2px;
  height: 100%;
}

.matrix-zone {
  position: absolute;
  z-index: 1;
  border-radius: 999px;
  background: rgba(255, 254, 250, 0.82);
  padding: 3px 7px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 900;
}

.matrix-zone-high {
  right: 10px;
  top: 10px;
  color: var(--red);
}

.matrix-zone-traffic {
  right: 10px;
  bottom: 30px;
}

.matrix-zone-drug {
  left: 10px;
  top: 34px;
}

.matrix-zone-low {
  left: 10px;
  bottom: 30px;
}

.matrix-axis {
  position: absolute;
  z-index: 2;
  color: var(--muted);
  font-size: 11px;
  font-weight: 900;
}

.matrix-axis.x {
  right: 10px;
  bottom: 8px;
}

.matrix-axis.y {
  top: 10px;
  left: 10px;
}

.matrix-note {
  position: absolute;
  z-index: 2;
  right: 10px;
  top: 34px;
  border-radius: 999px;
  background: rgba(255, 254, 250, 0.86);
  padding: 3px 7px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 900;
}

.matrix-entry {
  position: absolute;
  z-index: 3;
  width: var(--size);
  height: var(--size);
  transform: translate(-50%, 50%);
}

.matrix-point {
  display: grid;
  place-items: center;
  width: var(--size);
  height: var(--size);
  border: 2px solid #fffefa;
  border-radius: 999px;
  background: rgba(122, 75, 18, 0.84);
  color: #fffefa;
  box-shadow: 0 8px 18px rgba(28, 36, 32, 0.22);
  font-size: 12px;
  font-weight: 900;
  line-height: 1;
}

.matrix-entry.bubble .matrix-label {
  position: absolute;
  z-index: 4;
  max-width: 56px;
  border: 1px solid rgba(28, 36, 32, 0.12);
  border-radius: 999px;
  background: rgba(255, 254, 250, 0.96);
  padding: 2px 6px;
  color: var(--ink);
  font-size: 11px;
  font-weight: 900;
  line-height: 1.25;
  white-space: nowrap;
  box-shadow: 0 5px 12px rgba(28, 36, 32, 0.14);
}

.matrix-entry.bubble .matrix-label::before {
  content: "";
  position: absolute;
  background: rgba(28, 36, 32, 0.28);
}

.matrix-entry.above .matrix-label {
  left: 50%;
  bottom: calc(100% + 7px);
  transform: translateX(-50%);
}

.matrix-entry.above .matrix-label::before {
  left: 50%;
  top: 100%;
  width: 1px;
  height: 7px;
}

.matrix-entry.below .matrix-label {
  left: 50%;
  top: calc(100% + 7px);
  transform: translateX(-50%);
}

.matrix-entry.below .matrix-label::before {
  left: 50%;
  bottom: 100%;
  width: 1px;
  height: 7px;
}

.matrix-entry.right .matrix-label {
  left: calc(100% + 7px);
  top: 50%;
  transform: translateY(-50%);
}

.matrix-entry.right .matrix-label::before {
  right: 100%;
  top: 50%;
  width: 7px;
  height: 1px;
}

.matrix-entry.left .matrix-label {
  right: calc(100% + 7px);
  top: 50%;
  transform: translateY(-50%);
}

.matrix-entry.left .matrix-label::before {
  left: 100%;
  top: 50%;
  width: 7px;
  height: 1px;
}

.matrix-entry.is-selected .matrix-point {
  outline: 3px solid rgba(15, 118, 110, 0.28);
  background: var(--teal);
}

.matrix-entry.is-selected .matrix-label {
  border-color: rgba(15, 118, 110, 0.36);
  color: var(--teal);
}

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

.concentration-row {
  display: grid;
  grid-template-columns: 26px minmax(0, 1fr);
  gap: 10px;
  align-items: start;
}

.concentration-rank {
  display: grid;
  width: 26px;
  height: 26px;
  place-items: center;
  border-radius: 999px;
  background: #f1ebe1;
  color: #7a4b12;
  font-size: 12px;
  font-weight: 900;
}

.concentration-main {
  display: grid;
  gap: 5px;
}

.concentration-head {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  font-size: 13px;
}

.concentration-head span,
.concentration-main small {
  color: var(--muted);
  font-size: 12px;
}

.concentration-track {
  height: 9px;
  border-radius: 999px;
  background: #ece8df;
  overflow: hidden;
}

.concentration-track span {
  display: block;
  height: 100%;
  min-width: 8px;
  border-radius: inherit;
  background: #7a4b12;
}

.section-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 14px;
}

.section-heading h3 {
  font-size: 20px;
}

.legend {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.map-tools {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
}

.map-reset {
  min-height: 31px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-strong);
  color: var(--ink);
  padding: 0 10px;
  font-size: 12px;
  font-weight: 900;
  cursor: pointer;
}

.map-reset:hover {
  border-color: rgba(15, 118, 110, 0.38);
  color: var(--teal);
}

.map-reset:disabled {
  cursor: default;
  opacity: 0.48;
}

.legend span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.dot {
  display: inline-block;
  width: 9px;
  height: 9px;
  border-radius: 50%;
}

.dot.traffic {
  background: var(--red);
}

.dot.drug {
  background: var(--gold);
}

.dot.drugCrime {
  background: #7a4b12;
}

.dot.air {
  background: var(--purple);
}

.dot.water {
  background: var(--blue);
}

.map-canvas {
  position: relative;
  min-height: 520px;
  height: min(64vh, 640px);
  border: 1px solid #e5e1d7;
  border-radius: 8px;
  background: #e8efe7;
  overflow: hidden;
}

.map-canvas .leaflet-container,
.leaflet-container {
  font-family: "Segoe UI", "Noto Sans TC", Arial, sans-serif;
}

.map-canvas .leaflet-control-attribution {
  font-size: 10px;
}

.county-risk-marker {
  display: flex;
  width: 100%;
  height: 100%;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  border: 1px solid rgba(28, 36, 32, 0.16);
  border-radius: 8px;
  background: rgba(255, 254, 250, 0.94);
  color: var(--ink);
  padding: 3px;
  box-shadow: 0 4px 12px rgba(28, 36, 32, 0.2);
  line-height: 1;
}

.county-risk-marker .marker-name {
  font-size: 10px;
  font-weight: 900;
  white-space: nowrap;
}

.county-risk-marker .marker-count {
  display: grid;
  min-width: 24px;
  height: 15px;
  place-items: center;
  border-radius: 5px;
  color: #fffefa;
  font-size: 10px;
  font-weight: 900;
}

.county-risk-marker.traffic .marker-count {
  background: var(--red);
}

.county-risk-marker.drug .marker-count {
  background: var(--gold);
}

.county-risk-marker.drugCrime .marker-count {
  background: #7a4b12;
}

.county-risk-marker.air .marker-count {
  background: var(--purple);
}

.county-risk-marker.water .marker-count {
  background: var(--blue);
}

.county-risk-marker.all .marker-count {
  background: var(--teal);
}

.county-index {
  width: 190px;
  max-height: 310px;
  border: 1px solid rgba(28, 36, 32, 0.16);
  border-radius: 8px;
  background: rgba(255, 254, 250, 0.96);
  box-shadow: 0 10px 24px rgba(28, 36, 32, 0.18);
  overflow: hidden;
}

.county-index[hidden] {
  display: none;
}

.county-index-title {
  border-bottom: 1px solid var(--line);
  padding: 9px 10px;
  color: var(--ink);
  font-size: 13px;
  font-weight: 900;
}

.county-index-list {
  display: grid;
  gap: 4px;
  max-height: 266px;
  overflow: auto;
  padding: 8px;
}

.county-index-item {
  display: flex;
  min-height: 30px;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  border: 1px solid transparent;
  border-radius: 7px;
  background: #f8faf8;
  color: var(--ink);
  padding: 0 8px;
  cursor: pointer;
  font-size: 12px;
  font-weight: 800;
}

.county-index-item:hover {
  border-color: rgba(15, 118, 110, 0.28);
  background: #edf7f3;
}

.county-index-item strong {
  display: grid;
  min-width: 24px;
  height: 20px;
  place-items: center;
  border-radius: 999px;
  color: #fffefa;
  font-size: 11px;
}

.county-index-item.traffic strong {
  background: var(--red);
}

.county-index-item.drug strong {
  background: var(--gold);
}

.county-index-item.drugCrime strong {
  background: #7a4b12;
}

.county-index-item.air strong {
  background: var(--purple);
}

.county-index-item.water strong {
  background: var(--blue);
}

.county-index-item.all strong {
  background: var(--teal);
}

.leaflet-popup-content {
  min-width: 180px;
  margin: 12px 14px;
  color: var(--ink);
  line-height: 1.55;
}

.popup-title {
  margin: 0 0 6px;
  font-size: 15px;
  font-weight: 900;
}

.popup-meta {
  display: grid;
  gap: 3px;
  margin: 0;
  color: var(--muted);
  font-size: 12px;
}

.map-fallback {
  display: grid;
  gap: 12px;
  height: 100%;
  min-height: 520px;
  align-content: start;
  padding: 18px;
  background: #faf7ef;
  color: var(--ink);
}

.fallback-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 10px;
}

.fallback-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 12px;
}

.fallback-card b {
  display: block;
  margin-bottom: 5px;
}

.action-list {
  display: grid;
  gap: 12px;
  margin: 0;
  padding-left: 20px;
}

.action-list li {
  padding-left: 4px;
  color: var(--ink);
  line-height: 1.55;
}

.action-list strong {
  display: block;
  margin-bottom: 3px;
}

.action-list span {
  color: var(--muted);
  font-size: 13px;
}

.issue-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 14px;
}

.issue-panel.is-muted {
  opacity: 0.48;
}

.panel-meta {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-align: right;
}

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

.bar-row {
  display: grid;
  gap: 7px;
}

.bar-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  color: var(--ink);
  font-size: 13px;
  font-weight: 800;
}

.bar-track {
  width: 100%;
  height: 10px;
  border-radius: 999px;
  background: #ece8df;
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  min-width: 6px;
  border-radius: inherit;
  background: var(--teal);
}

.bar-fill.traffic {
  background: var(--red);
}

.bar-fill.drug {
  background: var(--gold);
}

.bar-fill.air {
  background: var(--purple);
}

.bar-fill.water {
  background: var(--blue);
}

.compact-list {
  display: grid;
  gap: 8px;
  margin-top: 14px;
}

.row-item {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: start;
  border-top: 1px solid var(--line);
  padding-top: 10px;
}

.row-item b {
  display: block;
  margin-bottom: 2px;
  font-size: 13px;
}

.row-item span {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.row-pill {
  border-radius: 999px;
  background: var(--surface-strong);
  padding: 4px 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.data-note {
  margin: 14px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.6;
}

.loading {
  cursor: progress;
}

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

  .sidebar {
    position: static;
    height: auto;
  }

  .summary-grid,
  .issue-grid,
  .risk-formula-list,
  .profile-facts,
  .report-cards,
  .analysis-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .profile-grid,
  .ranking-grid {
    grid-template-columns: 1fr;
  }

  .analysis-panel-wide {
    grid-row: auto;
    grid-column: 1 / -1;
  }

  .matrix-panel-wide {
    grid-column: 1 / -1;
  }

  .workspace {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 720px) {
  .dashboard,
  .sidebar {
    padding: 18px;
  }

  .topbar,
  .section-heading {
    display: grid;
  }

  .status-chips,
  .legend,
  .share-actions {
    justify-content: flex-start;
  }

  .summary-grid,
  .issue-grid,
  .risk-formula-list,
  .profile-facts,
  .report-cards,
  .analysis-grid {
    grid-template-columns: 1fr;
  }

  .profile-hero,
  .share-card {
    grid-template-columns: 1fr;
  }

  .profile-score {
    min-height: 78px;
  }

  .share-score {
    text-align: left;
  }

  .analysis-panel-wide {
    grid-column: auto;
  }

  .matrix-panel-wide {
    grid-column: auto;
  }

  .stack-row {
    grid-template-columns: 1fr;
  }

  .stack-values {
    grid-column: auto;
  }

  .map-canvas {
    min-height: 420px;
    height: 58vh;
  }

  .metric {
    min-height: 112px;
  }
}
