:root {
  --bg: #f4f0f8;
  --panel: #ffffff;
  --panel-strong: #ffffff;
  --stroke: rgba(96, 84, 123, 0.16);
  --text: #2f2640;
  --muted: #6f6784;
  --accent: #b04c7d;
  --accent-strong: #7e3459;
  --sea: #dfeaf8;
  --shadow: 0 18px 45px rgba(83, 64, 121, 0.12);
  --radius: 24px;
  --font-display: Georgia, "Times New Roman", serif;
  --font-body: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font-body);
  color: var(--text);
  background:
    radial-gradient(circle at 12% 18%, rgba(245, 171, 204, 0.32), transparent 28%),
    radial-gradient(circle at 88% 12%, rgba(154, 201, 255, 0.28), transparent 26%),
    linear-gradient(90deg, #f8d9e7 0%, #f4ecfb 44%, #dcecff 100%);
}

.page-shell {
  width: min(1320px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0 40px;
}

.hero {
  display: block;
  margin-bottom: 24px;
  padding: 24px;
  border: 1px solid var(--stroke);
  border-radius: var(--radius);
  background: #ffffff;
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
  position: relative;
}

.hero-title-box {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: min(760px, 100%);
  padding: 0;
  border: 0;
  background: transparent;
  box-shadow: none;
}

.lang-switch {
  position: absolute;
  top: 18px;
  right: 18px;
  display: inline-flex;
  gap: 4px;
  padding: 4px;
  border-radius: 999px;
  background: rgba(244, 240, 248, 0.95);
  border: 1px solid rgba(97, 120, 127, 0.14);
}

.lang-btn {
  border: 0;
  border-radius: 999px;
  padding: 5px 9px;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 0.8rem;
  font-weight: 700;
  cursor: pointer;
}

.lang-btn.is-active {
  background: #4f82df;
  color: #ffffff;
  box-shadow: 0 4px 10px rgba(79, 130, 223, 0.28);
}

.eyebrow,
.panel-kicker {
  margin: 0;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  font-size: 1.42rem;
  font-weight: 700;
}

.eyebrow {
  display: inline-block;
  background: linear-gradient(90deg, #e88db4 0%, #c89ae6 45%, #79aef2 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  font-size: 1.22rem;
  letter-spacing: 0.1em;
}

.panel-kicker {
  color: var(--accent);
}

h1,
h2 {
  margin: 0;
  font-family: var(--font-display);
  letter-spacing: -0.03em;
}

h1 {
  font-size: clamp(2.5rem, 4vw, 4.3rem);
  line-height: 0.95;
  margin-top: 0;
}

h2 {
  font-size: clamp(1.5rem, 2vw, 2rem);
}

.hero-text {
  max-width: 64ch;
  margin: 26px 0 0;
  color: var(--muted);
  font-size: 1rem;
  line-height: 1.65;
}

.panel,
.summary-card {
  border: 1px solid var(--stroke);
  box-shadow: var(--shadow);
}
.meta-label,
.summary-label,
.control-label,
.summary-note,
.chart-caption,
.legend-values,
.chart-legend {
  color: var(--muted);
}

.dashboard {
  display: grid;
  gap: 22px;
}

.panel {
  background: var(--panel);
  backdrop-filter: blur(10px);
  border-radius: var(--radius);
  padding: 22px;
}

.controls-panel {
  background: #ffffff;
}

.control-grid,
.summary-grid {
  display: grid;
  gap: 16px;
}

.control-grid {
  grid-template-columns: minmax(240px, 0.95fr) minmax(0, 1.65fr);
  margin-bottom: 18px;
}

.control {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.control-inline {
  min-width: 150px;
}

select {
  width: 100%;
  border: 1px solid rgba(105, 76, 38, 0.2);
  border-radius: 16px;
  padding: 14px 16px;
  font: inherit;
  color: var(--text);
  background: var(--panel-strong);
}

select:focus {
  outline: 2px solid rgba(141, 61, 46, 0.22);
  border-color: rgba(141, 61, 46, 0.4);
}

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

.summary-card {
  background: #ffffff;
  border-radius: 20px;
  padding: 18px;
}

.summary-card strong {
  display: block;
  margin: 10px 0 8px;
  font-size: 1.3rem;
  line-height: 1.1;
}

.summary-note {
  display: block;
  font-size: 0.92rem;
}

.map-panel,
.chart-panel {
  background: #ffffff;
  padding-left: 10px;
  padding-right: 10px;
}

.chart-layout {
  display: grid;
  grid-template-columns: 240px minmax(0, 1fr);
  gap: 24px;
  align-items: stretch;
}

.chart-sidebar {
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 18px;
  border-radius: 22px;
  background: #ffffff;
  border: 1px solid rgba(97, 120, 127, 0.16);
}

.chart-sidebar-block {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

#chartCurrentOptionTitle {
  font-size: 1.1rem;
  line-height: 1.4;
  color: var(--text);
}

.multi-select {
  width: 100%;
  position: relative;
}

.multi-select summary {
  list-style: none;
  border: 1px solid rgba(105, 76, 38, 0.2);
  border-radius: 16px;
  padding: 14px 16px;
  font: inherit;
  color: var(--text);
  background: var(--panel-strong);
  cursor: pointer;
}

.multi-select summary::-webkit-details-marker {
  display: none;
}

.multi-select[open] summary {
  border-color: rgba(141, 61, 46, 0.4);
}

.multi-select-menu {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  right: 0;
  z-index: 5;
  display: grid;
  gap: 8px;
  padding: 12px;
  border: 1px solid rgba(97, 120, 127, 0.18);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.98);
  box-shadow: 0 14px 28px rgba(83, 64, 121, 0.12);
}

.multi-select-item {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  font-size: 0.95rem;
  color: var(--text);
}

.multi-select-item input {
  margin-top: 2px;
}

.chart-canvas {
  min-width: 0;
  overflow: visible;
  position: relative;
}

.panel-head {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: flex-start;
  margin-bottom: 18px;
}

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

.legend-shell {
  min-width: 220px;
  width: 100%;
}

.legend-bar {
  height: 14px;
  border-radius: 999px;
  background: linear-gradient(90deg, rgb(248, 236, 213) 0%, rgb(230, 182, 127) 35%, rgb(207, 127, 72) 68%, rgb(141, 61, 46) 100%);
  border: 1px solid rgba(98, 69, 41, 0.16);
}

.legend-values {
  display: flex;
  justify-content: space-between;
  font-size: 0.9rem;
  margin-top: 6px;
  width: 100%;
}

.map-stage {
  position: relative;
  display: block;
  min-height: 430px;
  background: #ffffff;
  border-radius: 24px;
  overflow: hidden;
  border: 1px solid rgba(97, 120, 127, 0.22);
}

.map-stage > .map-overlay-controls {
  position: absolute !important;
  top: 24px !important;
  right: 24px !important;
  left: auto !important;
  bottom: auto !important;
  z-index: 2;
  display: flex;
  flex-direction: column;
  gap: 32px;
  align-items: stretch;
  width: 310px;
  max-width: calc(100% - 36px);
  padding: 18px;
  border-radius: 18px;
  background: #ffffff;
  border: 1px solid rgba(97, 120, 127, 0.18);
  box-shadow: 0 10px 24px rgba(83, 64, 121, 0.1);
  backdrop-filter: blur(8px);
}

.map-overlay-header {
  width: 100%;
  text-align: right;
}

.map-overlay-label {
  display: block;
  margin-bottom: 10px;
  font-size: 0.82rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

#mapOptionTitle {
  display: block;
  max-width: 100%;
  font-size: 1.2rem;
  line-height: 1.45;
  font-weight: 700;
  color: var(--text);
}

.map-control-block {
  width: 100%;
  align-items: flex-end;
  gap: 10px;
}

.legend-title {
  display: block;
  margin-bottom: 10px;
  text-align: right;
}

.map-control-block .control-label {
  width: 100%;
  text-align: right;
}

#mapSvg,
#chartSvg {
  width: 100%;
  display: block;
}

#mapSvg {
  position: relative;
  z-index: 1;
  height: 565px;
  width: 100%;
}

#chartSvg {
  height: 430px;
}

.map-sea {
  fill: #ffffff;
}

.section-shape {
  stroke: rgba(68, 49, 27, 0.45);
  stroke-width: 1.6;
  vector-effect: non-scaling-stroke;
  cursor: pointer;
  transition:
    fill 180ms ease,
    transform 180ms ease,
    stroke 180ms ease,
    opacity 180ms ease;
}

.section-shape:hover,
.section-shape.is-active {
  stroke: var(--accent-strong);
  stroke-width: 2.4;
}

.section-shape:hover {
  transform-box: fill-box;
  transform-origin: center;
  transform: scale(1.03);
}

.section-shape.is-active {
  filter: drop-shadow(0 8px 12px rgba(93, 32, 23, 0.22));
}

.map-label {
  font-size: 12px;
  fill: rgba(46, 36, 25, 0.8);
  text-anchor: middle;
  pointer-events: none;
}

.map-tooltip {
  position: absolute;
  left: 0;
  top: 0;
  transform: translate(-50%, calc(-100% - 12px));
  padding: 12px 14px;
  border-radius: 14px;
  background: rgba(45, 33, 20, 0.92);
  color: #fff9f3;
  pointer-events: none;
  white-space: nowrap;
  box-shadow: 0 18px 35px rgba(27, 18, 9, 0.25);
  z-index: 20;
}

.map-tooltip strong {
  display: block;
  margin-bottom: 4px;
  font-size: 0.95rem;
}

.chart-legend {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  font-size: 0.92rem;
}

.chart-legend-bottom {
  margin-top: 14px;
  justify-content: center;
}

.legend-line {
  display: inline-block;
  width: 28px;
  height: 3px;
  vertical-align: middle;
  margin-right: 8px;
  border-radius: 999px;
}

.legend-line-selected {
  background: var(--accent);
}

.legend-line-municipality {
  background: rgba(46, 36, 25, 0.52);
}

.chart-caption {
  margin: 10px 0 0;
  font-size: 0.94rem;
}

.chart-grid {
  stroke: rgba(120, 93, 58, 0.22);
  stroke-width: 1;
}

.chart-axis {
  stroke: rgba(76, 57, 36, 0.45);
  stroke-width: 1.4;
}

.chart-label {
  fill: rgba(84, 66, 44, 0.76);
  font-size: 12px;
}

.chart-series {
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.chart-series-municipality {
  stroke-width: 0;
}

.chart-series-section {
  stroke-width: 4.5;
}

.chart-point {
  stroke: white;
  stroke-width: 2.5;
  cursor: pointer;
}

.chart-empty {
  fill: var(--muted);
  font-size: 1rem;
  text-anchor: middle;
}

.chart-tooltip {
  position: absolute;
  left: 0;
  top: 0;
  transform: translate(-50%, calc(-100% - 12px));
  padding: 12px 14px;
  border-radius: 14px;
  background: rgba(45, 33, 20, 0.94);
  color: #fff9f3;
  pointer-events: none;
  white-space: nowrap;
  box-shadow: 0 18px 35px rgba(27, 18, 9, 0.25);
  z-index: 20;
}

.chart-tooltip strong {
  display: block;
  margin-bottom: 4px;
  font-size: 0.95rem;
}

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

@media (max-width: 720px) {
  .page-shell {
    width: min(100% - 20px, 1320px);
    padding-top: 20px;
  }

  .panel {
    padding: 18px;
    border-radius: 20px;
  }
  .panel-head {
    flex-direction: column;
    align-items: start;
  }

  .inline-controls {
    width: 100%;
    align-items: stretch;
    justify-content: flex-start;
  }

  .chart-layout {
    grid-template-columns: 1fr;
  }

  .control-inline {
    min-width: 0;
  }

  .legend-shell {
    width: 100%;
  }

  .map-stage {
    min-height: 360px;
  }

  #mapSvg {
    height: 450px;
  }
}
