:root {
  --bg: #f7f7f4;
  --panel: #ffffff;
  --ink: #1f2421;
  --muted: #68726d;
  --line: #d9ded8;
  --soft: #eef2ed;
  --teal: #197a75;
  --teal-dark: #0f5c58;
  --amber: #d9911b;
  --red: #c4493d;
  --violet: #6b5fb5;
  --marker: #8b9690;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
}

button,
input {
  font: inherit;
}

.app-shell {
  min-height: 100vh;
  padding: 24px;
}

.toolbar {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 24px;
  margin: 0 auto 16px;
  max-width: 1440px;
}

.title-block {
  min-width: 220px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--teal-dark);
  font-size: 13px;
  font-weight: 800;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: clamp(30px, 4vw, 54px);
  letter-spacing: 0;
  line-height: 1;
}

h2 {
  font-size: 18px;
  letter-spacing: 0;
}

.controls {
  display: flex;
  align-items: end;
  gap: 12px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.search-field,
.select-field {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.search-field input,
.select-field select {
  height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--ink);
  padding: 0 12px;
  outline: none;
}

.search-field input {
  width: min(42vw, 320px);
  min-width: 220px;
}

.select-field select {
  width: 150px;
}

.search-field input:focus,
.select-field select:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(25, 122, 117, 0.14);
}

.segmented {
  display: inline-grid;
  grid-template-columns: repeat(4, minmax(72px, 1fr));
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.segment {
  min-height: 34px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 14px;
  font-weight: 800;
}

.segment.is-active {
  background: var(--teal);
  color: #fff;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  max-width: 1440px;
  margin: 0 auto 12px;
}

.metric {
  display: grid;
  gap: 8px;
  min-height: 84px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

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

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

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 12px;
  max-width: 1440px;
  margin: 0 auto 12px;
}

.map-panel,
.detail-panel,
.table-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.map-panel {
  min-width: 0;
  overflow: hidden;
}

.map-header,
.table-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px;
  border-bottom: 1px solid var(--line);
}

.map-header p,
.empty-state span {
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
}

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

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

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

.legend-dot.both {
  background: var(--violet);
}

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

.legend-dot.frequent {
  background: var(--amber);
}

.legend-dot.normal {
  background: var(--marker);
}

.map-wrap {
  position: relative;
  min-height: 560px;
  background: #e8ede9;
}

#map {
  display: block;
  width: 100%;
  height: min(64vh, 680px);
  min-height: 560px;
}

.place-marker {
  cursor: pointer;
  opacity: 0.86;
  stroke: #fff;
  stroke-width: 0.55;
  transition:
    opacity 160ms ease,
    transform 160ms ease;
  transform-origin: center;
}

.place-marker:hover,
.place-marker.is-selected {
  opacity: 1;
  stroke: #1f2421;
  stroke-width: 0.85;
}

.place-marker.normal {
  fill: var(--marker);
}

.place-marker.frequent {
  fill: var(--amber);
}

.place-marker.official {
  fill: var(--red);
}

.place-marker.both {
  fill: var(--violet);
}

.leaflet-tooltip {
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  font: 800 12px/1.35 Inter, ui-sans-serif, system-ui, sans-serif;
}

.detail-panel {
  min-height: 320px;
  padding: 18px;
}

.empty-state {
  display: grid;
  align-content: center;
  min-height: 280px;
  color: var(--ink);
}

.empty-state[hidden],
.place-detail[hidden] {
  display: none;
}

.place-detail {
  display: grid;
  gap: 16px;
}

.detail-kicker {
  color: var(--teal-dark);
  font-size: 12px;
  font-weight: 900;
}

.place-detail h3 {
  margin: 4px 0 0;
  font-size: 24px;
  line-height: 1.15;
}

.detail-place {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.badges {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.badge {
  border-radius: 999px;
  background: var(--soft);
  color: var(--ink);
  padding: 5px 9px;
  font-size: 12px;
  font-weight: 800;
}

.badge.official {
  background: rgba(196, 73, 61, 0.12);
  color: #9d3128;
}

.badge.frequent {
  background: rgba(217, 145, 27, 0.16);
  color: #8f5d0d;
}

.detail-stats {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.detail-stat {
  display: grid;
  gap: 4px;
  min-height: 68px;
  padding: 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfa;
}

.detail-stat span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.detail-stat strong {
  font-size: 18px;
  line-height: 1.2;
}

.coordinate-stat {
  grid-column: 1 / -1;
}

.coordinate-stat strong {
  font-size: 15px;
  overflow-wrap: anywhere;
}

.map-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--teal);
  color: #fff;
  font-size: 13px;
  font-weight: 900;
  text-decoration: none;
}

.map-link:hover {
  background: var(--teal-dark);
}

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

.detail-list h4 {
  margin: 0;
  font-size: 13px;
}

.detail-list ul {
  display: grid;
  gap: 6px;
  margin: 0;
  padding: 0;
  list-style: none;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.42;
}

.table-panel {
  max-width: 1440px;
  margin: 0 auto;
  overflow: hidden;
}

.table-header span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.place-list {
  display: grid;
  max-height: 430px;
  overflow: auto;
}

.place-row {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) 96px 110px 110px 120px;
  gap: 12px;
  align-items: center;
  min-height: 58px;
  padding: 10px 16px;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: transparent;
  color: var(--ink);
  text-align: left;
  cursor: pointer;
}

.place-row:hover,
.place-row.is-selected {
  background: #f0f6f2;
}

.place-row strong {
  display: block;
  overflow-wrap: anywhere;
  line-height: 1.2;
}

.place-row small {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.25;
}

.row-number {
  font-weight: 900;
}

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

.row-pill {
  justify-self: start;
  min-width: 88px;
  border-radius: 999px;
  padding: 5px 8px;
  background: var(--soft);
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
  text-align: center;
}

.row-pill.both {
  background: rgba(107, 95, 181, 0.14);
  color: #51469a;
}

.row-pill.official {
  background: rgba(196, 73, 61, 0.12);
  color: #9d3128;
}

.row-pill.frequent {
  background: rgba(217, 145, 27, 0.16);
  color: #8f5d0d;
}

@media (max-width: 980px) {
  .app-shell {
    padding: 16px;
  }

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

  .toolbar {
    display: grid;
    align-items: start;
  }

  .controls {
    justify-content: stretch;
  }

  .search-field,
  .search-field input,
  .select-field,
  .select-field select,
  .segmented {
    width: 100%;
  }

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

  .workspace {
    display: grid;
  }

  .detail-panel {
    min-height: 0;
  }

  .place-row {
    grid-template-columns: minmax(160px, 1fr) 84px 100px 86px;
  }

  .place-row .row-amount {
    display: none;
  }
}

@media (max-width: 620px) {
  .summary-grid {
    grid-template-columns: 1fr;
  }

  .map-header,
  .table-header {
    align-items: start;
    flex-direction: column;
  }

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

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

  .row-pill {
    justify-self: start;
  }

  #map,
  .map-wrap {
    min-height: 420px;
  }
}
