:root {
  --ink: #14191d;
  --muted: #66727a;
  --faint: #8b979e;
  --line: rgba(20, 25, 29, 0.1);
  --track: #e7ebed;
  --field: #f3f5f6;
  --paper: rgba(250, 251, 252, 0.96);
  --accent: #0c8f86;
  --shadow: 0 18px 50px rgba(16, 24, 32, 0.16);
  --dock: 350px;
  color: var(--ink);
  font-family: "IBM Plex Sans", "SF Pro Text", "Segoe UI", sans-serif;
  font-size: 14px;
  letter-spacing: -0.011em;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  background: #b7c4c8;
}

#map {
  position: fixed;
  inset: 0;
  background: #c5d2d6;
  z-index: 0;
}

.leaflet-top.leaflet-left .leaflet-control-zoom {
  margin-left: 16px;
}

.leaflet-control-zoom {
  border: 0 !important;
  box-shadow: var(--shadow) !important;
  border-radius: 12px !important;
  overflow: hidden;
}

.leaflet-control-zoom a {
  display: flex !important;
  align-items: center;
  justify-content: center;
  width: 34px !important;
  height: 34px !important;
  line-height: 1 !important;
  color: var(--ink) !important;
  border: 0 !important;
  background: white;
}

.leaflet-control-zoom a + a {
  border-top: 1px solid var(--line) !important;
}

.leaflet-control-zoom a.leaflet-control-fullscreen svg { display: block; }

.leaflet-top.leaflet-right .leaflet-control-attribution {
  margin-top: 8px !important;
  border-radius: 8px;
  box-shadow: none;
}

.leaflet-control-attribution {
  background: rgba(250, 251, 252, 0.82) !important;
  color: var(--faint) !important;
  border-radius: 8px 0 0 0;
  font-size: 11px !important;
}

.banner {
  position: fixed;
  z-index: 900;
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  max-width: min(560px, calc(100vw - 40px));
  margin: 0;
  padding: 10px 14px;
  border-radius: 999px;
  background: #1c2428;
  color: white;
  font-size: 13px;
  box-shadow: var(--shadow);
}

.about-card code {
  display: inline-block;
  margin-top: 2px;
  padding: 2px 6px;
  border-radius: 6px;
  background: var(--field);
  color: var(--ink);
  font: 500 12.5px/1.4 "IBM Plex Sans", "SF Pro Text", "Segoe UI", sans-serif;
}

.dock {
  position: fixed;
  z-index: 800;
  top: auto;
  bottom: 16px;
  left: 16px;
  width: var(--dock);
  max-height: calc(100vh - 32px);
  display: flex;
  flex-direction: column;
  padding: 14px;
  border: 1px solid rgba(255, 255, 255, 0.72);
  border-radius: 22px;
  background: var(--paper);
  backdrop-filter: blur(18px) saturate(1.2);
  box-shadow: var(--shadow);
}

body[data-panel="products"] .dock {
  top: 16px;
  bottom: 16px;
  width: min(860px, calc(100vw - 32px));
}

.dock-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 22px;
  padding-bottom: 12px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.mark {
  width: 34px;
  height: 34px;
  flex: none;
  display: block;
}

.brand strong {
  display: block;
  font-size: 20px;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.tabs {
  display: flex;
  padding: 3px;
  border-radius: 11px;
  background: var(--track);
}

.tabs button {
  border: 0;
  background: transparent;
  color: var(--muted);
  border-radius: 8px;
  padding: 6px 9px;
  font: 500 12.5px/1 "IBM Plex Sans", sans-serif;
  cursor: pointer;
}

.tabs button[aria-selected="true"] {
  background: white;
  color: var(--ink);
  box-shadow: 0 1px 2px rgba(16, 24, 32, 0.08);
}

.dock-scroll, .catalog {
  min-height: 0;
}

.dock-scroll { overflow: auto; padding-right: 2px; flex: 1; }

.credit {
  flex: none;
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
  color: var(--faint);
  font-size: 11px;
  line-height: 1.4;
}

.credit p { margin: 0; }

.credit a {
  color: var(--muted);
}

.about-cite-title {
  margin: 18px 0 0;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.summary {
  margin: 4px 0 14px;
  line-height: 1.35;
}

.summary strong {
  display: block;
  font-size: 18px;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.fields {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px 10px;
}

.span-2 { grid-column: span 2; }

label {
  display: block;
  color: var(--muted);
  font-size: 11px;
  font-weight: 500;
}

label.is-locked {
  opacity: 0.42;
  pointer-events: none;
}

label.is-locked select:disabled {
  color: var(--faint);
  cursor: default;
}

select, input[type="search"] {
  display: block;
  width: 100%;
  height: 36px;
  margin-top: 4px;
  padding: 0 10px;
  border: 1px solid transparent;
  border-radius: 10px;
  background: var(--field);
  color: var(--ink);
  font: 13.5px/36px "IBM Plex Sans", sans-serif;
  letter-spacing: -0.011em;
}

select:focus, input[type="search"]:focus {
  outline: 2px solid rgba(12, 143, 134, 0.35);
  background: white;
}

.control { margin-top: 12px; }

.control-label {
  display: block;
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 500;
}

.segment {
  display: flex;
  padding: 3px;
  border-radius: 11px;
  background: var(--track);
}

.segment label {
  position: relative;
  flex: 1;
  margin: 0;
  text-align: center;
}

.segment input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.segment span {
  display: block;
  padding: 7px 4px;
  border-radius: 8px;
  color: var(--muted);
  font-size: 12.5px;
  font-weight: 500;
  cursor: pointer;
}

.segment input:checked + span {
  background: white;
  color: var(--ink);
  box-shadow: 0 1px 2px rgba(16, 24, 32, 0.08);
}

.segment input:focus-visible + span {
  outline: 2px solid rgba(12, 143, 134, 0.45);
}

.map-source {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px 10px;
  margin-top: 12px;
}

.basemap { margin-top: 0; }

.stats {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
}

.stats-scope {
  margin: 0 0 8px;
  color: var(--ink);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-align: left;
  text-transform: uppercase;
}

.stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px 14px;
}

.stats-grid span {
  display: block;
  color: var(--muted);
  font-size: 11px;
  font-weight: 500;
}

.stats-grid strong {
  display: block;
  margin-top: 1px;
  font-size: 13.5px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.hist-block[hidden] { display: none; }

.hist {
  display: flex;
  align-items: flex-end;
  gap: 2px;
  height: 52px;
}

.hist i {
  flex: 1;
  display: block;
  min-height: 2px;
  border-radius: 2px 2px 0 0;
  background: var(--accent);
}

.hist-axis {
  display: flex;
  justify-content: space-between;
  margin-top: 4px;
  color: var(--muted);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}

.status-line { margin-top: 12px; }

.user-scale {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 8px;
}

.user-scale[hidden] { display: none; }

.user-scale input {
  display: block;
  width: 100%;
  height: 36px;
  margin-top: 4px;
  padding: 0 10px;
  border: 1px solid transparent;
  border-radius: 10px;
  background: white;
  color: var(--ink);
  font: 13.5px/36px "IBM Plex Sans", sans-serif;
}

.user-scale input:focus {
  outline: 2px solid rgba(12, 143, 134, 0.35);
}

.pager button {
  border: 1px solid var(--line);
  background: white;
  color: var(--ink);
  border-radius: 10px;
  padding: 8px 12px;
  font: 500 13px/1 "IBM Plex Sans", sans-serif;
  cursor: pointer;
}

.pager button:hover { border-color: rgba(20, 25, 29, 0.22); }

.modal {
  position: fixed;
  z-index: 1200;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(16, 24, 32, 0.35);
}

.modal[hidden] { display: none; }

.modal-card {
  width: min(420px, 100%);
  padding: 22px;
  border-radius: 18px;
  background: white;
  box-shadow: var(--shadow);
}

.modal-card h2 {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.modal-card p {
  margin: 10px 0 16px;
  color: var(--muted);
  line-height: 1.45;
}

.about-card {
  width: min(480px, 100%);
}

.about-card p {
  margin: 10px 0 0;
}

.about-card p + .modal-actions {
  margin-top: 16px;
}

.about-card a {
  color: var(--ink);
}

.modal-actions {
  display: flex;
  gap: 8px;
}

.modal-card button {
  border: 0;
  border-radius: 10px;
  background: var(--ink);
  color: white;
  padding: 8px 14px;
  font: 500 13px/1 "IBM Plex Sans", sans-serif;
  cursor: pointer;
}

.modal-actions button:last-child {
  background: transparent;
  color: var(--ink);
  border: 1px solid var(--line);
}

.pager button:disabled { opacity: 0.4; cursor: default; }

.hint, .catalog-meta, .catalog-meta p {
  margin: 0;
  color: var(--faint);
  font-size: 12px;
}

.catalog {
  display: flex;
  flex-direction: column;
  gap: 10px;
  flex: 1;
}

.catalog[hidden], #map-view[hidden] { display: none; }

.catalog-tools { display: grid; gap: 8px; }

.product-filters {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px 10px;
}

.catalog-meta { margin: 0; }

.table-wrap {
  min-height: 0;
  flex: 1;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.65);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

th, td {
  padding: 9px 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  white-space: nowrap;
}

th {
  position: sticky;
  top: 0;
  background: #f7f8f9;
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
}

tbody tr { cursor: pointer; }
tbody tr:hover { background: rgba(12, 143, 134, 0.08); }
td:last-child, th:last-child { font-variant-numeric: tabular-nums; }

.pager {
  display: flex;
  align-items: center;
  gap: 10px;
}

#product-page {
  color: var(--muted);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

.legend {
  position: fixed;
  z-index: 700;
  right: 16px;
  bottom: 16px;
  display: flex;
  flex-direction: column;
  gap: 0;
  width: calc(236px * 1.15);
  padding: 10px 12px 12px;
  border: 1px solid rgba(255, 255, 255, 0.72);
  border-radius: 16px;
  background: var(--paper);
  backdrop-filter: blur(16px);
  box-shadow: var(--shadow);
}

.legend[hidden] { display: none; }

.legend .legend-caption {
  margin: 0;
  line-height: 1.35;
  text-align: left;
}

.legend .stats-scope {
  margin: 0 0 8px;
  color: var(--ink);
  text-align: left;
}

.legend-scale {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.legend img {
  display: block;
  width: 100%;
  height: 10px;
  border-radius: 999px;
}

.legend-ticks {
  position: relative;
  height: 14px;
  margin-bottom: 5px;
}

.legend-ticks span {
  position: absolute;
  top: 0;
  transform: translateX(-50%);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}

.legend-ticks span.is-start {
  left: 0 !important;
  transform: none;
}

.legend-ticks span.is-end {
  right: 0;
  left: auto !important;
  transform: none;
}

.legend p {
  margin: 0;
  color: var(--faint);
  font-size: 11px;
  text-align: right;
}

.map-actions {
  position: fixed;
  z-index: 700;
  left: calc(var(--dock) + 32px);
  bottom: 16px;
  display: flex;
  align-items: flex-end;
  flex-wrap: wrap;
  gap: 8px;
  max-width: calc(100vw - var(--dock) - 300px);
}

.download-stack {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
}

.download-row {
  display: flex;
  gap: 8px;
}

.extent-box {
  position: absolute;
  right: 0;
  bottom: calc(100% + 8px);
  width: 320px;
  padding: 12px;
  border: 1px solid rgba(255, 255, 255, 0.72);
  border-radius: 16px;
  background: var(--paper);
  backdrop-filter: blur(16px);
  box-shadow: var(--shadow);
}

.extent-box[hidden] { display: none; }

.extent-close {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 22px;
  height: 22px;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font: 600 16px/22px "IBM Plex Sans", sans-serif;
  cursor: pointer;
}

.extent-close:hover { color: var(--ink); background: var(--field); }

.extent-box > .hint { padding-right: 18px; }

.extent-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.extent-box input {
  display: block;
  width: 100%;
  height: 36px;
  margin-top: 4px;
  padding: 0 10px;
  border: 1px solid transparent;
  border-radius: 10px;
  background: white;
  color: var(--ink);
  font: 13.5px/36px "IBM Plex Sans", sans-serif;
}

.extent-box input:focus {
  outline: 2px solid rgba(12, 143, 134, 0.35);
}

.extent-box .hint { margin: 0 0 8px; }

#extent-status { min-height: 16px; margin: 8px 0 0; }

.download-row button,
#extent-apply {
  border: 1px solid rgba(255, 255, 255, 0.72);
  border-radius: 14px;
  background: var(--paper);
  backdrop-filter: blur(16px);
  box-shadow: var(--shadow);
  color: var(--ink);
  display: flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  height: 37px;
  padding: 0 12px;
  font: 500 13px/1 "IBM Plex Sans", sans-serif;
  cursor: pointer;
}

#extent-apply {
  width: 100%;
  margin-top: 8px;
  background: var(--ink);
  color: white;
  border-color: transparent;
}

.download-row button[hidden] { display: none; }

.download-row button:hover { border-color: rgba(20, 25, 29, 0.22); }

.download-row button:disabled,
#extent-apply:disabled { opacity: 0.55; cursor: default; }

.leaflet-container.is-drawing,
.leaflet-container.is-drawing .leaflet-interactive { cursor: crosshair !important; }

.readout {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  box-sizing: border-box;
  height: 37px;
  padding: 0 12px;
  border: 1px solid rgba(255, 255, 255, 0.72);
  border-radius: 14px;
  background: var(--paper);
  backdrop-filter: blur(16px);
  box-shadow: var(--shadow);
  font-size: 13px;
}

.readout span { color: var(--muted); }

.readout strong {
  font-size: inherit;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.readout.is-empty { color: var(--muted); }

@media (max-width: 680px) {
  .dock {
    top: auto;
    right: 12px;
    bottom: 12px;
    left: 12px;
    width: auto;
    max-height: 48vh;
  }

  body[data-panel="products"] .dock {
    width: auto;
    max-height: 72vh;
  }

  .map-actions, .legend { display: none; }
  .leaflet-control-zoom { display: none; }
}
