* {
  box-sizing: border-box;
  margin: 0;
}

html,
body,
#map {
  width: 100%;
  height: 100%;
}

body {
  font-family: Cabin, Arial, sans-serif;
}

#map {
  position: absolute;
  inset: 0;
}

/* Layer panel */
.layers-panel {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 1000;
  min-width: 220px;
  background: rgba(255, 255, 255, 0.96);
  border: 1px solid rgba(0, 0, 0, 0.35);
  border-radius: 6px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.18);
  overflow: hidden;
}

.layers-panel__body {
  padding: 8px 10px;
}

.layers-panel__toggle {
  width: 100%;
  border: 0;
  background: #5f89b0;
  color: #fff;
  padding: 8px 10px;
  font-size: 12px;
  text-transform: uppercase;
  cursor: pointer;
}

.layers-panel__toggle:hover {
  background: #4c7398;
}

.layers-panel--collapsed .layers-panel__body {
  display: none;
}

.layer-panel__title {
  font-size: 14px;
  font-weight: 700;
  margin-bottom: 8px;
}

.layer-panel__list {
  display: grid;
  gap: 8px;
}

.layer-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.layer-row label {
  cursor: pointer;
  font-size: 13px;
  line-height: 1.2;
}

/* Popup */
.ol-popup {
  position: absolute;
  background: #fff;
  padding: 12px 14px;
  border-radius: 8px;
  border: 1px solid #ccc;
  min-width: 300px;
  max-width: 460px;
  width: max-content;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.2);
}

#popup-content {
  padding-top: 8px;
  font-size: 13px;
  line-height: 1.4;
}

#popup-content table {
  border-collapse: collapse;
  width: auto;
  table-layout: auto;
}

#popup-content th,
#popup-content td {
  text-align: left;
  vertical-align: top;
  padding: 4px 8px;
  border-bottom: 1px solid #eee;
  font-size: 12px;
}

#popup-content th {
  white-space: nowrap;
  width: 1%;
  padding-right: 16px;
  font-weight: 700;
}

#popup-content td {
  white-space: normal;
  width: auto;
}

.ol-popup.hidden {
  display: none;
}

.ol-popup-closer {
  position: absolute;
  top: 4px;
  right: 6px;
  border: 0;
  background: transparent;
  font-size: 20px;
  cursor: pointer;
  line-height: 1;
}

/* Optional legend chip styles */
.legend-chip {
  display: inline-block;
  width: 14px;
  height: 14px;
  border-radius: 2px;
  margin-right: 6px;
  vertical-align: middle;
}

.map-legend {
  position: absolute;
  right: 8px;
  bottom: 34px; /* sits above OL attribution */
  z-index: 1000;
  min-width: 210px;
  max-width: 260px;
  background: rgba(255, 255, 255, 0.95);
  border: 1px solid rgba(0, 0, 0, 0.35);
  border-radius: 6px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.18);
  overflow: hidden;
  font-family: Cabin, Arial, sans-serif;
}

.map-legend__body {
  padding: 8px 10px 4px 10px;
}

.map-legend__item {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
  font-size: 12px;
  line-height: 1.2;
}

.map-legend__item:last-child {
  margin-bottom: 0;
}

.map-legend__icon {
  width: 18px;
  height: 18px;
  object-fit: contain;
  flex: 0 0 18px;
}

.map-legend__line {
  width: 24px;
  height: 0;
  border-top: 3px solid #000;
  flex: 0 0 24px;
}

.map-legend__label {
  white-space: nowrap;
}

.map-legend__toggle {
  display: block;
  width: 100%;
  border: 0;
  border-top: 1px solid rgba(0, 0, 0, 0.15);
  background: #5f89b0;
  color: #fff;
  padding: 6px 10px;
  font-size: 12px;
  cursor: pointer;
  text-transform: uppercase;
}

.map-legend--collapsed .map-legend__body {
  display: none;
}

.north-arrow {
  position: absolute;
  left: 10px;
  bottom: 48px; /* sits above the scale line */
  z-index: 1000;
  pointer-events: none;
}

.north-arrow img {
  display: block;
  width: 36px;
  height: auto;
}