:root {
  --navy: #0b1f3a;
  --navy-2: #143056;
  --gold: #c9a227;
  --teal: #1a9b8e;
  --citizen: #d97706;
  --police: #2563eb;
  --bg: #eef2f7;
  --card: #ffffff;
  --text: #1f2937;
  --muted: #6b7280;
  --line: #e5e7eb;
  --down: #047857;
  --up: #b91c1c;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: "Noto Sans TC", "Microsoft JhengHei", sans-serif;
  background: var(--bg);
  color: var(--text);
}
.topbar {
  background: linear-gradient(90deg, var(--navy), var(--navy-2));
  color: #fff;
  padding: 16px 24px 0;
  position: sticky;
  top: 0;
  z-index: 20;
  box-shadow: 0 8px 24px rgba(11, 31, 58, 0.18);
}
.topbar h1 {
  margin: 0;
  font-size: 22px;
  font-weight: 700;
  letter-spacing: 0.04em;
}
.topbar .sub {
  margin: 6px 0 12px;
  color: #d7e3f4;
  font-size: 13px;
}
.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 16px;
  padding-bottom: 12px;
  align-items: end;
}
.filters label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 12px;
  color: #c5d4ea;
}
.filters select, .filters button {
  font-family: inherit;
  border: 0;
  border-radius: 8px;
  padding: 7px 10px;
  min-width: 120px;
}
.tabs {
  display: flex;
  gap: 4px;
}
.tabs button {
  background: transparent;
  color: #c5d4ea;
  border: 0;
  padding: 10px 16px;
  cursor: pointer;
  font-size: 14px;
  border-bottom: 3px solid transparent;
}
.tabs button.active {
  color: #fff;
  border-bottom-color: var(--gold);
  font-weight: 700;
}
.wrap { padding: 18px 24px 40px; }
.kpis {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}
.kpi {
  background: var(--card);
  border-radius: 14px;
  padding: 14px 16px;
  box-shadow: 0 4px 14px rgba(15, 23, 42, 0.06);
}
.kpi .label { color: var(--muted); font-size: 12px; }
.kpi .value { font-size: 24px; font-weight: 800; margin-top: 4px; color: var(--navy); }
.kpi .hint { font-size: 11px; color: var(--muted); margin-top: 4px; }
.grid-2 {
  display: grid;
  grid-template-columns: 1.3fr 1fr;
  gap: 14px;
}
.grid-3 {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 14px;
}
.card {
  background: var(--card);
  border-radius: 14px;
  padding: 14px 16px;
  box-shadow: 0 4px 14px rgba(15, 23, 42, 0.06);
  min-height: 120px;
}
.card h2 {
  margin: 0 0 10px;
  font-size: 16px;
  color: var(--navy);
}
.card h3 { margin: 0 0 8px; font-size: 14px; color: var(--navy-2); }
.map { height: 520px; border-radius: 12px; overflow: hidden; }
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
th, td {
  padding: 8px 8px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  white-space: nowrap;
}
th { cursor: pointer; color: var(--muted); font-weight: 600; background: #f8fafc; position: sticky; top: 0; }
tr:hover { background: #f4f8ff; }
tr.selected { background: #e8f4f2; }
.table-wrap { max-height: 460px; overflow: auto; }
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
}
.badge.good { background: #d1fae5; color: #047857; }
.badge.warn { background: #fee2e2; color: #b91c1c; }
.badge.mid { background: #f3f4f6; color: #4b5563; }
.verdict { white-space: normal; min-width: 180px; line-height: 1.5; }
.guide {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin: 8px 0 12px;
  font-size: 13px;
  line-height: 1.7;
}
.guide div {
  background: #f8fafc;
  border-radius: 10px;
  padding: 10px 12px;
}
.down { color: var(--down); font-weight: 700; }
.up { color: var(--up); font-weight: 700; }
.muted { color: var(--muted); }
.panel { display: none; }
.panel.active { display: block; }
.map-box { position: relative; }
.map-legend {
  position: absolute;
  left: 10px;
  bottom: 28px;
  z-index: 500;
  background: rgba(255,255,255,.96);
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 12px;
  line-height: 1.75;
  box-shadow: 0 2px 10px rgba(15, 23, 42, 0.12);
  color: var(--text);
}
.map-legend b { display: block; margin-bottom: 2px; color: var(--navy); }
.dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; margin-right: 4px; }
.note {
  background: #fff8e8;
  border-left: 4px solid var(--gold);
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 13px;
  line-height: 1.7;
  margin-bottom: 14px;
}
.method p { line-height: 1.8; font-size: 14px; margin: 8px 0; }
.method h3 { margin-top: 16px; }
.detail {
  font-size: 13px;
  line-height: 1.7;
}
.detail b { color: var(--navy); }
.small { font-size: 12px; color: var(--muted); }
@media (max-width: 980px) {
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .map { height: 360px; }
}
