:root {
  --paper: #f4f1ea;
  --panel: rgba(255, 252, 247, 0.94);
  --ink: #1e2a2f;
  --muted: #6a7476;
  --accent: #165f74;
  --accent-strong: #0f4254;
  --sea: #dce8ea;
  --land-empty: #d6d2c8;
  --shadow: 0 16px 40px rgba(20, 31, 35, 0.14);
}
* { box-sizing: border-box; }
body {
  margin: 0;
  min-height: 100vh;
  font-family: Cambria, "Segoe UI", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at top left, rgba(22, 95, 116, 0.11), transparent 30%),
    linear-gradient(180deg, #efeae0 0%, var(--paper) 48%, #ebe6dc 100%);
}
.page {
  width: min(1620px, calc(100vw - 32px));
  margin: 20px auto;
  padding: 22px;
  background: rgba(255, 255, 255, 0.46);
  border: 1px solid rgba(255, 255, 255, 0.42);
  border-radius: 28px;
  backdrop-filter: blur(12px);
  box-shadow: var(--shadow);
}
.hero {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: end;
  margin-bottom: 18px;
}
.hero-content {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}
.hero h1 {
  margin: 0;
  flex: 1 1 auto;
  font-size: clamp(1.8rem, 3vw, 2.8rem);
  line-height: 1.02;
  letter-spacing: 0.01em;
}
.lang-controls {
  justify-self: end;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px;
  border-radius: 999px;
  background: rgba(255, 252, 247, 0.72);
  border: 1px solid rgba(24, 44, 56, 0.08);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.7);
}
.lang-button {
  position: relative;
  min-width: 56px;
  padding: 10px 14px;
  border: 1px solid rgba(22, 95, 116, 0.14);
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-weight: 700;
  letter-spacing: 0.08em;
  transition: transform 140ms ease, background 140ms ease, border-color 140ms ease, color 140ms ease, box-shadow 140ms ease;
}
.lang-button:hover {
  transform: translateY(-1px);
  border-color: rgba(22, 95, 116, 0.28);
  color: var(--ink);
}
.lang-button.active {
  background: linear-gradient(135deg, var(--accent), var(--accent-strong));
  color: white;
  border-color: transparent;
  box-shadow: 0 10px 22px rgba(15, 66, 84, 0.22);
}
.lang-button.active::after {
  content: "";
  display: inline-block;
  width: 8px;
  height: 8px;
  margin-left: 8px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.18);
  vertical-align: middle;
}
.hero p {
  margin: 8px 0 0;
  color: var(--muted);
  max-width: 68ch;
  line-height: 1.4;
}
.layout {
  display: grid;
  grid-template-columns: minmax(330px, 390px) minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}
.panel, .map-shell {
  background: var(--panel);
  border: 1px solid rgba(24, 44, 56, 0.08);
  border-radius: 20px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.65);
}
.panel {
  padding: 18px;
  display: grid;
  gap: 16px;
}
.section-title {
  margin: 0 0 8px;
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  color: var(--muted);
}
.field-grid {
  display: grid;
  gap: 12px;
}
.field-grid.two-col {
  grid-template-columns: 1fr 1fr;
}
label {
  display: grid;
  gap: 6px;
  font-size: 0.95rem;
  color: var(--muted);
}
select, button, input {
  font: inherit;
}
select, input {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid rgba(24, 44, 56, 0.12);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.9);
  color: var(--ink);
}
.button-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.toggle {
  border: 1px solid rgba(22, 95, 116, 0.14);
  border-radius: 14px;
  padding: 12px 14px;
  background: rgba(255, 255, 255, 0.76);
  color: var(--ink);
  cursor: pointer;
  transition: transform 140ms ease, background 140ms ease, border-color 140ms ease;
}
.toggle:hover, .map-button:hover, .search-row button:hover, .secondary-actions button:hover, .download-button:hover {
  transform: translateY(-1px);
  border-color: rgba(22, 95, 116, 0.3);
}
.toggle.active {
  background: linear-gradient(135deg, var(--accent), var(--accent-strong));
  color: white;
  border-color: transparent;
}
.search-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
}
#searchButton {
  display: none;
}
.search-panel {
  position: relative;
}
.search-row button, .secondary-actions button, .map-button {
  border: none;
  border-radius: 14px;
  background: linear-gradient(135deg, var(--accent), var(--accent-strong));
  color: white;
  cursor: pointer;
  padding: 12px 14px;
}
.suggestions {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  right: 0;
  z-index: 4;
  display: grid;
  gap: 4px;
  padding: 8px;
  border-radius: 14px;
  background: rgba(255, 252, 247, 0.98);
  border: 1px solid rgba(24, 44, 56, 0.1);
  box-shadow: 0 12px 24px rgba(20, 31, 35, 0.12);
}
.suggestion-item {
  width: 100%;
  text-align: left;
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 10px 12px;
  background: transparent;
  color: var(--ink);
  cursor: pointer;
}
.suggestion-item:hover,
.suggestion-item.selected {
  background: rgba(22, 95, 116, 0.08);
  border-color: rgba(22, 95, 116, 0.12);
}
.suggestion-item small {
  display: block;
  margin-top: 2px;
  color: var(--muted);
}
.secondary-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.secondary-actions button {
  background: rgba(23, 53, 66, 0.08);
  color: var(--ink);
  border: 1px solid rgba(24, 44, 56, 0.08);
}
.legend {
  display: grid;
  gap: 10px;
}
.download-button {
  border: none;
  border-radius: 14px;
  padding: 12px 14px;
  background: linear-gradient(135deg, var(--accent), var(--accent-strong));
  color: white;
  cursor: pointer;
}
.legend-bar {
  position: relative;
  height: 18px;
  border-radius: 999px;
  overflow: hidden;
  background: #eff1e2;
}
.legend-bar::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, #eff1e2 0%, #c7ddcf 25%, #8bb8ae 50%, #4d8890 75%, #195a73 100%);
}
.legend-values {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  color: var(--muted);
  font-size: 0.95rem;
  margin-top: 2px;
}
.legend-values span {
  display: inline-block;
  padding: 0 4px;
  background: var(--panel);
  border-radius: 6px;
}
.hidden {
  display: none !important;
}
.map-shell {
  position: relative;
  overflow: hidden;
  padding: 12px;
}
.map-frame {
  position: relative;
  border-radius: 16px;
  overflow: hidden;
  border: 1px solid rgba(24, 44, 56, 0.08);
  background:
    radial-gradient(circle at 20% 20%, rgba(255, 255, 255, 0.55), transparent 36%),
    linear-gradient(180deg, #dfe9eb 0%, #d5e1e3 100%);
}
.map-loading {
  position: absolute;
  inset: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(233, 239, 240, 0.68);
  backdrop-filter: blur(2px);
}
.map-loading-card {
  display: grid;
  justify-items: center;
  gap: 10px;
  padding: 16px 20px;
  min-width: 190px;
  border-radius: 18px;
  background: rgba(255, 252, 247, 0.94);
  border: 1px solid rgba(24, 44, 56, 0.08);
  box-shadow: 0 18px 32px rgba(12, 19, 23, 0.14);
  color: var(--ink);
}
.spinner {
  width: 42px;
  height: 42px;
  border-radius: 999px;
  border: 4px solid rgba(22, 95, 116, 0.16);
  border-top-color: var(--accent);
  animation: spin 0.9s linear infinite;
}
svg {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 1440 / 860;
  cursor: grab;
  user-select: none;
  touch-action: none;
}
svg.dragging { cursor: grabbing; }
.municipality {
  stroke: rgba(255, 251, 245, 0.8);
  stroke-width: 0.46;
  fill-rule: evenodd;
  vector-effect: non-scaling-stroke;
  transition: fill 180ms ease, stroke 120ms ease;
}
.municipality:hover {
  stroke: #0f2029;
  stroke-width: 1.2;
}
.municipality.selected {
  stroke: #0f2029;
  stroke-width: 1.7;
}
.island-box {
  fill: rgba(255, 255, 255, 0.06);
  stroke: rgba(22, 63, 78, 0.58);
  stroke-width: 1.2;
  stroke-dasharray: 10 7;
  vector-effect: non-scaling-stroke;
  pointer-events: none;
}
.boundary-level-2 {
  fill: none;
  stroke: rgba(110, 110, 110, 0.92);
  stroke-width: 1.08;
  vector-effect: non-scaling-stroke;
  pointer-events: none;
}
.boundary-level-1 {
  fill: none;
  stroke: rgba(0, 0, 0, 0.96);
  stroke-width: 2.15;
  vector-effect: non-scaling-stroke;
  pointer-events: none;
}
.map-toolbar {
  position: absolute;
  top: 14px;
  right: 14px;
  display: grid;
  gap: 8px;
  z-index: 2;
}
.map-button {
  padding: 10px 12px;
  min-width: 48px;
  box-shadow: 0 10px 24px rgba(22, 41, 50, 0.16);
}
.tooltip {
  position: absolute;
  display: none;
  min-width: 260px;
  max-width: 340px;
  padding: 14px 16px;
  border-radius: 16px;
  background: rgba(17, 29, 34, 0.94);
  color: white;
  pointer-events: none;
  z-index: 3;
  box-shadow: 0 18px 32px rgba(12, 19, 23, 0.26);
  border: 1px solid rgba(255, 255, 255, 0.08);
}
.tooltip-section {
  display: grid;
  gap: 8px;
}
.tooltip-divider {
  height: 1px;
  margin: 10px 0;
  background: rgba(255, 255, 255, 0.12);
}
.tooltip-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 14px;
}
.tooltip-label {
  color: rgba(255, 255, 255, 0.72);
  font-size: 0.84rem;
  line-height: 1.25;
}
.tooltip-value {
  color: white;
  font-size: 0.96rem;
  line-height: 1.25;
  text-align: right;
}
.tooltip-row-level .tooltip-value {
  max-width: 62%;
}
.tooltip-section-metrics .tooltip-label {
  color: rgba(255, 255, 255, 0.78);
}
.tooltip-metric-title {
  color: white;
  font-size: 0.95rem;
  font-weight: 700;
  line-height: 1.2;
  margin-bottom: 2px;
}
@keyframes spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}
@media (max-width: 1180px) {
  .layout { grid-template-columns: 1fr; }
  .hero { flex-direction: column; align-items: start; }
}
@media (max-width: 720px) {
  .page {
    width: calc(100vw - 16px);
    margin: 8px auto;
    padding: 12px;
  }
  .field-grid.two-col, .button-row, .secondary-actions, .search-row {
    grid-template-columns: 1fr;
  }
  .lang-controls {
    width: 100%;
    justify-content: flex-end;
  }
  .hero-content {
    align-items: start;
  }
  .map-toolbar { top: auto; bottom: 14px; }
}
