:root {
  --ink: #18201d;
  --muted: #66716d;
  --surface: #fbfbf7;
  --panel: #ffffff;
  --line: #d7ddd5;
  --road: #177b82;
  --road-soft: #dff3f3;
  --violence: #8156a7;
  --violence-soft: #efe6f6;
  --pending: #b48118;
  --pending-soft: #fff1cf;
  --official: #586d79;
  --official-soft: #e8eef1;
  --ok: #28744a;
  --bad: #b0443e;
  --shadow: 0 18px 48px rgba(22, 32, 29, 0.16);
  --radius: 8px;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans TC",
    "Noto Sans", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  color: var(--ink);
  background: #eef2ed;
}

body {
  overflow: hidden;
}

button,
input {
  font: inherit;
}

button {
  color: inherit;
}

.app-shell {
  height: 100vh;
  display: grid;
  grid-template-rows: auto auto auto 1fr auto;
  gap: 10px;
  padding: 10px;
}

.disclosure-band {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 12px;
  border: 1px solid var(--pending);
  border-radius: var(--radius);
  background: var(--pending-soft);
  color: #6b4a0f;
  font-size: 12px;
  line-height: 1.4;
}

.disclosure-band svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

.disclosure-band p {
  margin: 0;
  font-weight: 650;
}

.topbar {
  min-height: 58px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 10px;
  background: rgba(251, 251, 247, 0.94);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 6px 20px rgba(24, 32, 29, 0.07);
  backdrop-filter: blur(12px);
}

.brand-block,
.top-actions,
.panel-title,
.summary-band,
.map-toolbar,
.mode-strip,
.dock-tabs,
.legend,
.quick-stats,
.sync-pill {
  display: flex;
  align-items: center;
}

.brand-block {
  gap: 10px;
  min-width: 0;
}

.brand-mark {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: #f8fbf7;
  background: conic-gradient(from 160deg, var(--road), #315b83, var(--violence), #6f7a3b, var(--road));
  font-weight: 800;
}

h1 {
  margin: 0;
  font-size: 18px;
  line-height: 1.1;
  letter-spacing: 0;
}

.brand-block p {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.25;
}

.top-actions {
  gap: 8px;
  flex-shrink: 0;
}

.sync-pill {
  gap: 6px;
  min-width: 74px;
  justify-content: center;
  padding: 7px 9px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--ok);
  background: #eef8f1;
  font-size: 12px;
  font-weight: 750;
}

.sync-pill.warning {
  color: var(--pending);
  background: var(--pending-soft);
}

.sync-pill.fail {
  color: var(--bad);
  background: #ffe9e4;
}

.language-switch,
.segmented {
  display: inline-flex;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #f3f5f0;
}

.language-switch button,
.segmented button,
.mode-strip button {
  min-width: 36px;
  height: 32px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  cursor: pointer;
  font-size: 12px;
  font-weight: 760;
}

.language-switch button.is-active,
.segmented button.is-active,
.mode-strip button.is-active {
  background: var(--ink);
  color: white;
}

.mobile-tonight {
  display: none;
}

.workspace-grid {
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(240px, 292px) minmax(0, 1fr) minmax(260px, 330px);
  gap: 10px;
}

.panel {
  min-height: 0;
  overflow: auto;
  background: rgba(251, 251, 247, 0.96);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 10px 28px rgba(24, 32, 29, 0.08);
}

.filter-panel,
.detail-panel {
  padding: 12px;
}

.panel.is-collapsed {
  display: none;
}

.panel-title {
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 12px;
  font-size: 14px;
  font-weight: 820;
}

.icon-button {
  width: 36px;
  height: 36px;
  display: inline-grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  cursor: pointer;
}

.icon-button:hover,
.filter-chip:hover,
.dock-tabs button:hover {
  border-color: #98aaa2;
}

.field {
  display: grid;
  gap: 6px;
  margin-bottom: 12px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
}

.field input[type="text"],
.field input:not([type]) {
  width: 100%;
}

input {
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 8px 10px;
  background: #fff;
  color: var(--ink);
}

input[type="range"] {
  padding: 0;
  accent-color: var(--road);
}

.segmented {
  width: 100%;
  margin-bottom: 12px;
}

.segmented button {
  flex: 1;
}

.filter-group {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin: 12px 0;
}

.group-label {
  width: 100%;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.filter-chip {
  min-height: 32px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 10px;
  background: #fff;
  cursor: pointer;
  font-size: 12px;
  font-weight: 720;
}

.filter-chip.is-active[data-event="drugDriving"],
.filter-chip.is-active[data-event="alcoholDriving"],
.filter-chip.is-active[data-event="hitRun"],
.filter-chip.is-active[data-event="dangerousDriving"],
.filter-chip.is-active[data-event="a1a2Crash"] {
  border-color: #8fc5c7;
  background: var(--road-soft);
  color: #075a61;
}

.filter-chip.is-active[data-event="assault"],
.filter-chip.is-active[data-event="homicide"],
.filter-chip.is-active[data-event="robbery"],
.filter-chip.is-active[data-event="snatch"],
.filter-chip.is-active[data-event="fight"],
.filter-chip.is-active[data-event="publicAttack"] {
  border-color: #c4a6d8;
  background: var(--violence-soft);
  color: #5e3482;
}

.switch-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 7px;
  margin: 12px 0;
}

.switch-grid label {
  min-height: 34px;
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 6px 8px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  font-size: 12px;
  font-weight: 700;
}

.legend {
  flex-wrap: wrap;
  gap: 8px;
  padding-top: 8px;
  color: var(--muted);
  font-size: 12px;
}

.dot {
  width: 10px;
  height: 10px;
  display: inline-block;
  margin-right: 4px;
  border-radius: 50%;
}

.dot.road {
  background: var(--road);
}

.dot.violence {
  background: var(--violence);
}

.dot.pending {
  background: var(--pending);
}

.dot.official {
  background: var(--official);
}

.map-stage {
  position: relative;
  min-height: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #dde5df;
}

#map {
  width: 100%;
  height: 100%;
  min-height: 420px;
  background: #dbe5df;
}

.map-toolbar {
  position: absolute;
  z-index: 450;
  top: 12px;
  right: 12px;
  flex-direction: column;
  gap: 8px;
}

.summary-band {
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
}

.summary-band span {
  display: block;
  color: var(--muted);
  font-size: 11px;
  font-weight: 760;
}

.summary-band strong {
  display: block;
  margin-top: 3px;
  font-size: 14px;
}

.radar-wrap {
  min-height: 185px;
  display: grid;
  place-items: center;
  margin-bottom: 8px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: linear-gradient(180deg, #ffffff, #f4f6f2);
}

#riskRadar {
  width: min(100%, 260px);
  height: 185px;
}

.highlight-list,
.event-list,
.region-list,
.timeline,
.source-health {
  display: grid;
  gap: 8px;
}

.highlight,
.event-row,
.region-row,
.timeline-row,
.source-row,
.stat-tile {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  padding: 10px;
}

.highlight strong,
.event-row strong,
.region-row strong,
.timeline-row strong,
.source-row strong {
  display: block;
  font-size: 13px;
  line-height: 1.25;
}

.highlight p,
.event-row p,
.region-row p,
.timeline-row p,
.source-row p {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.badge-line {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 7px;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  padding: 3px 7px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 760;
}

.badge.road {
  background: var(--road-soft);
  color: #075a61;
}

.badge.violence {
  background: var(--violence-soft);
  color: #5e3482;
}

.badge.pending {
  background: var(--pending-soft);
  color: #7c5412;
}

.badge.official {
  background: var(--official-soft);
  color: #445965;
}

.badge.ok {
  background: #e4f4e9;
  color: var(--ok);
}

.bottom-dock {
  max-height: 34vh;
  min-height: 172px;
  display: grid;
  grid-template-rows: auto 1fr;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(251, 251, 247, 0.97);
  box-shadow: var(--shadow);
}

.dock-tabs {
  gap: 4px;
  padding: 6px;
  border-bottom: 1px solid var(--line);
  overflow-x: auto;
}

.dock-tabs button {
  height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 1px solid transparent;
  border-radius: 999px;
  padding: 0 12px;
  background: transparent;
  cursor: pointer;
  white-space: nowrap;
  font-size: 12px;
  font-weight: 780;
}

.dock-tabs button.is-active {
  background: var(--ink);
  color: #fff;
}

.dock-body {
  min-height: 0;
  overflow: auto;
  padding: 10px;
}

.view-pane {
  display: none;
}

.view-pane.is-active {
  display: block;
}

.quick-stats {
  flex-wrap: wrap;
  gap: 8px;
}

.stat-tile {
  min-width: 138px;
  flex: 1;
}

.stat-tile span {
  display: block;
  color: var(--muted);
  font-size: 11px;
  font-weight: 760;
}

.stat-tile strong {
  display: block;
  margin-top: 4px;
  font-size: 20px;
}

.leaflet-popup-content {
  margin: 12px;
  min-width: 220px;
}

.popup-title {
  margin: 0 0 5px;
  font-size: 14px;
  line-height: 1.25;
}

.popup-body {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

a {
  color: #176873;
  text-decoration-thickness: 1px;
}

@media (max-width: 1040px) {
  .workspace-grid {
    grid-template-columns: minmax(220px, 280px) minmax(0, 1fr);
  }

  .detail-panel {
    display: none;
  }
}

@media (max-width: 760px) {
  body {
    overflow: hidden;
  }

  .app-shell {
    grid-template-rows: auto auto auto minmax(0, 1fr) auto;
    padding: 6px;
    gap: 6px;
  }

  .topbar {
    min-height: 54px;
    padding: 7px;
  }

  .brand-mark {
    width: 34px;
    height: 34px;
  }

  h1 {
    font-size: 16px;
  }

  .brand-block p {
    max-width: 48vw;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .sync-pill {
    min-width: 44px;
    padding: 7px;
  }

  .sync-pill span {
    display: none;
  }

  .language-switch button {
    min-width: 32px;
  }

  .mobile-tonight {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 8px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: rgba(251, 251, 247, 0.96);
  }

  .mobile-tonight span {
    display: block;
    color: var(--muted);
    font-size: 11px;
    font-weight: 760;
  }

  .mobile-tonight strong {
    display: block;
    max-width: 54vw;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 13px;
  }

  .mode-strip {
    gap: 3px;
    padding: 3px;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: #fff;
  }

  .mode-strip button {
    min-width: 31px;
    width: 31px;
    height: 31px;
  }

  .workspace-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .filter-panel,
  .detail-panel {
    display: none;
  }

  #map {
    min-height: 0;
    height: 100%;
  }

  .map-toolbar {
    top: 8px;
    right: 8px;
  }

  .bottom-dock {
    max-height: 44vh;
    min-height: 186px;
  }

  .dock-tabs button {
    min-width: 60px;
    padding: 0 9px;
  }
}
