:root {
  --bg: #f2efe7;
  --panel: rgba(250, 248, 242, 0.96);
  --line: #d6d0c2;
  --text: #1f2a23;
  --muted: #5e685f;
  --accent: #1f6d52;
  --accent-strong: #0e4d39;
  --cell-fill: rgba(31, 109, 82, 0.18);
  --cell-stroke: rgba(14, 77, 57, 0.72);
  --cell-active: rgba(191, 102, 48, 0.28);
  --cell-active-stroke: rgba(140, 67, 19, 0.92);
  --shadow: 0 18px 48px rgba(33, 34, 28, 0.12);
  --radius: 20px;
  --font: "IBM Plex Sans", "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  margin: 0;
  font-family: var(--font);
  color: var(--text);
  background: radial-gradient(circle at top, #fbf8f1 0%, #ebe5d7 58%, #dfd7c6 100%);
}

body {
  height: 100vh;
  overflow: hidden;
}

.layout {
  display: grid;
  grid-template-columns: minmax(560px, 720px) 1fr;
  height: 100vh;
  min-height: 0;
  overflow: hidden;
}

.sidebar {
  padding: 28px;
  background: var(--panel);
  border-right: 1px solid rgba(214, 208, 194, 0.7);
  backdrop-filter: blur(12px);
  overflow-y: auto;
  overscroll-behavior: contain;
}

.sidebar__header h1 {
  margin: 0 0 10px;
  font-size: clamp(2rem, 4vw, 2.8rem);
  line-height: 1;
}

.sidebar__columns {
  display: grid;
  grid-template-columns: minmax(170px, 220px) minmax(280px, 1fr);
  gap: 18px;
  align-items: start;
  margin-top: 28px;
}

.eyebrow {
  margin: 0 0 10px;
  font-size: 0.78rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--accent-strong);
}

.lede,
.panel__hint,
.notes,
.table-nav h2 {
  color: var(--muted);
}

.table-nav {
  display: grid;
  gap: 10px;
  position: sticky;
  top: 24px;
  max-height: calc(100vh - 48px);
  min-height: 0;
}

.table-nav h2 {
  margin: 0;
  font-size: 0.9rem;
  font-weight: 700;
}

.table-buttons {
  display: grid;
  gap: 8px;
  min-height: 0;
  overflow-y: auto;
  padding: 0 6px 4px 0;
  scrollbar-color: rgba(31, 109, 82, 0.4) transparent;
}

.table-group {
  display: grid;
  gap: 8px;
}

.table-group__toggle {
  display: flex;
  width: 100%;
  min-height: 44px;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid rgba(214, 208, 194, 0.86);
  border-radius: 8px;
  background: rgba(255, 253, 248, 0.76);
  color: var(--accent-strong);
  cursor: pointer;
  font: inherit;
  font-size: 0.82rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-align: left;
  text-transform: uppercase;
  transition:
    background-color 160ms ease,
    border-color 160ms ease,
    box-shadow 160ms ease;
}

.table-group__toggle:hover {
  border-color: rgba(31, 109, 82, 0.45);
  background: #f8f5ed;
}

.table-group__toggle:focus-visible {
  outline: 3px solid rgba(31, 109, 82, 0.24);
  outline-offset: 2px;
}

.table-group--open .table-group__toggle {
  border-color: rgba(14, 77, 57, 0.72);
  background: #e8f0eb;
  box-shadow: inset 3px 0 0 var(--accent-strong);
}

.table-group__chevron {
  width: 8px;
  height: 8px;
  flex: 0 0 8px;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: rotate(45deg);
  transition: transform 160ms ease;
}

.table-group--open .table-group__chevron {
  transform: rotate(225deg);
}

.table-group__buttons {
  display: grid;
  gap: 8px;
  padding-left: 8px;
}

.table-group__buttons[hidden] {
  display: none;
}

.table-button {
  width: 100%;
  min-height: 58px;
  padding: 11px 13px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffdf8;
  color: var(--text);
  font: inherit;
  text-align: left;
  cursor: pointer;
  transition:
    background-color 160ms ease,
    border-color 160ms ease,
    box-shadow 160ms ease,
    color 160ms ease,
    transform 160ms ease;
}

.table-button:hover {
  border-color: rgba(31, 109, 82, 0.45);
  background: #f8f5ed;
  box-shadow: 0 8px 20px rgba(33, 34, 28, 0.08);
  transform: translateY(-1px);
}

.table-button:focus-visible {
  outline: 3px solid rgba(31, 109, 82, 0.24);
  outline-offset: 2px;
}

.table-button--active {
  border-color: rgba(14, 77, 57, 0.86);
  background: #e8f0eb;
  color: var(--accent-strong);
  box-shadow: inset 3px 0 0 var(--accent-strong);
}

.table-button__label,
.table-button__title {
  display: block;
}

.table-button__label {
  margin-bottom: 4px;
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.table-button__title {
  line-height: 1.25;
  font-size: 0.96rem;
  font-weight: 650;
}

.panel,
.notes {
  padding: 18px;
  border: 1px solid rgba(214, 208, 194, 0.85);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.62);
  box-shadow: var(--shadow);
}

.panel {
  min-height: 240px;
}

.panel h2,
.notes h2 {
  margin: 0 0 12px;
  font-size: 1rem;
}

.panel h3 {
  margin: 0 0 4px;
  font-size: 1.55rem;
}

.panel p {
  margin: 0 0 12px;
}

.panel__meta {
  font-size: 0.92rem;
  color: var(--muted);
}

.loading-state {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-size: 0.94rem;
  font-weight: 700;
}

.panel__loading {
  min-height: 180px;
  justify-content: center;
}

.popup__loading {
  min-width: 220px;
  padding: 8px 0;
}

.loading-ball {
  width: 14px;
  height: 14px;
  flex: 0 0 14px;
  border-radius: 999px;
  background: var(--accent-strong);
  box-shadow: 0 0 0 0 rgba(14, 77, 57, 0.35);
  animation: loading-pulse 900ms ease-in-out infinite;
}

@keyframes loading-pulse {
  0%,
  100% {
    transform: scale(0.72);
    opacity: 0.55;
    box-shadow: 0 0 0 0 rgba(14, 77, 57, 0.35);
  }

  50% {
    transform: scale(1);
    opacity: 1;
    box-shadow: 0 0 0 8px rgba(14, 77, 57, 0);
  }
}

@media (prefers-reduced-motion: reduce) {
  .loading-ball {
    animation: none;
  }
}

.table-preview {
  width: 100%;
  border-collapse: collapse;
  margin-top: 14px;
  font-size: 0.94rem;
}

.table-preview th,
.table-preview td {
  padding: 10px 8px;
  border-bottom: 1px solid rgba(214, 208, 194, 0.9);
  text-align: left;
}

.table-preview th:last-child,
.table-preview td:last-child {
  text-align: right;
}

.notes {
  margin-top: 18px;
}

.notes ul {
  margin: 0;
  padding-left: 18px;
}

.source-note {
  margin: 0;
  line-height: 1.45;
}

.source-note a {
  color: var(--accent-strong);
}

.notes li + li {
  margin-top: 8px;
}

.map-shell {
  position: relative;
  padding: 18px;
  min-height: 0;
  overflow: hidden;
}

#map {
  width: 100%;
  height: calc(100vh - 36px);
  border-radius: 28px;
  overflow: hidden;
  box-shadow: var(--shadow);
}

.leaflet-control-zoom {
  border: 0;
  box-shadow: var(--shadow);
}

.leaflet-control-zoom a {
  color: var(--text);
}

.leaflet-popup-content-wrapper {
  border-radius: 16px;
}

.leaflet-popup-content {
  margin: 14px 16px;
  min-width: 240px;
}

.leaflet-popup-content:has(.popup__table--columns) {
  min-width: min(520px, 72vw);
}

.popup__eyebrow {
  margin: 0 0 4px;
  font-size: 0.75rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent-strong);
}

.popup__title {
  margin: 0 0 6px;
  font-size: 1.15rem;
}

.popup__table-title {
  margin: 0 0 8px;
  color: var(--text);
  font-size: 0.92rem;
  font-weight: 700;
  line-height: 1.25;
}

.popup__meta {
  margin: 0 0 10px;
  color: var(--muted);
  font-size: 0.9rem;
}

.popup__table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.popup__table td {
  padding: 6px 0;
  border-bottom: 1px solid rgba(214, 208, 194, 0.9);
}

.popup__table td:last-child {
  text-align: right;
  font-weight: 700;
}

.popup__table--columns {
  display: block;
  columns: 2 180px;
  column-gap: 18px;
}

.popup__table--columns tbody,
.popup__table--columns tr {
  display: block;
}

.popup__table--columns tr {
  break-inside: avoid;
  display: grid;
  grid-template-columns: minmax(72px, 1fr) auto;
  gap: 10px;
}

.popup__table--columns td {
  min-width: 0;
}

@media (max-width: 960px) {
  body {
    height: auto;
    min-height: 100vh;
    overflow: auto;
  }

  .layout {
    grid-template-columns: 1fr;
    height: auto;
    min-height: 100vh;
    overflow: visible;
  }

  .sidebar {
    border-right: 0;
    border-bottom: 1px solid rgba(214, 208, 194, 0.7);
    overflow: visible;
  }

  .sidebar__columns {
    grid-template-columns: minmax(180px, 0.85fr) minmax(280px, 1.15fr);
  }

  .table-nav {
    position: static;
    max-height: none;
  }

  .map-shell {
    padding: 0;
  }

  #map {
    height: 68vh;
    border-radius: 0;
  }
}

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