:root {
  --ink: #151a1f;
  --panel: #ffffff;
  --paper: #f4f6f5;
  --line: rgba(21, 26, 31, 0.14);
  --muted: #6f746f;
  --text: #1e252b;
  --accent: #e7b84d;
  --teal: #238f9d;
  --rose: #d94f70;
  --shadow: 0 12px 34px rgba(21, 26, 31, 0.1);
}

* {
  box-sizing: border-box;
}

html,
body,
.app-shell,
#map {
  height: 100%;
  margin: 0;
}

body {
  overflow: hidden;
  color: var(--text);
  background: var(--paper);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 270px minmax(460px, 1fr) 360px;
  grid-template-rows: minmax(0, 1fr) 220px;
  gap: 12px;
  padding: 12px;
}

.workspace-panel {
  display: contents;
}

.topbar,
.side-panel,
.ranking-panel,
.kpi-strip {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 3px;
  box-shadow: var(--shadow);
}

.topbar {
  grid-column: 1;
  grid-row: 1 / 3;
  min-height: 0;
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
  gap: 16px;
  overflow: auto;
  padding: 16px;
}

.brand {
  display: flex;
  gap: 12px;
  align-items: flex-start;
}

.brand-mark {
  width: 40px;
  height: 40px;
  flex: 0 0 auto;
  background:
    radial-gradient(circle at 30% 28%, var(--accent) 0 17%, transparent 18%),
    conic-gradient(from 120deg, var(--teal), var(--accent), var(--rose), var(--teal));
  clip-path: polygon(50% 0, 92% 24%, 92% 76%, 50% 100%, 8% 76%, 8% 24%);
}

.brand strong,
.brand span {
  display: block;
}

.brand-copy {
  min-width: 0;
}

.brand-title-row {
  display: flex;
  align-items: center;
  gap: 7px;
}

.brand strong {
  line-height: 1.05;
}

.brand span {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}

.info-button {
  width: 24px;
  height: 24px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 50%;
  font-size: 13px;
  font-weight: 900;
  line-height: 1;
}

.info-button:hover,
.info-button:focus-visible {
  color: #fff;
  background: var(--teal);
  border-color: var(--teal);
}

.info-button:focus-visible {
  outline: 3px solid rgba(35, 143, 157, 0.2);
  outline-offset: 2px;
}

.control-strip {
  display: grid;
  gap: 10px;
}

.control-strip label,
.scatter-controls label {
  display: grid;
  gap: 4px;
  min-width: 0;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

select {
  width: 100%;
  min-width: 0;
  height: 36px;
  color: var(--text);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 3px;
  padding: 0 30px 0 10px;
}

select:focus {
  outline: 3px solid rgba(35, 143, 157, 0.18);
  border-color: var(--teal);
}

.kpi-strip {
  grid-column: 3;
  grid-row: 1;
  align-self: start;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1px;
  overflow: hidden;
}

.kpi-item {
  min-width: 0;
  padding: 11px 12px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 3px;
}

.kpi-item span,
.kpi-item strong,
.kpi-item i {
  display: block;
}

.kpi-item span {
  color: var(--muted);
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.kpi-item strong {
  margin-top: 5px;
  overflow: hidden;
  font-size: 20px;
  line-height: 1;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.kpi-item i {
  min-height: 14px;
  margin-top: 5px;
  color: var(--teal);
  font-size: 11px;
  font-style: normal;
}

.map-column {
  position: relative;
  grid-column: 2;
  grid-row: 1;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  background: #dde3e1;
  border: 1px solid rgba(255, 255, 255, 0.16);
  box-shadow: var(--shadow);
}

.map-stage {
  position: absolute;
  inset: 0;
}

#map {
  background: #dde3e1;
}

.map-vignette {
  position: absolute;
  inset: 0;
  z-index: 420;
  pointer-events: none;
  background: linear-gradient(0deg, rgba(21, 26, 31, 0.12), transparent 28%);
}

.map-actions {
  position: absolute;
  z-index: 650;
  top: 14px;
  left: 14px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.map-actions button,
.ranking-head button,
.drawer-actions button,
.scatter-head button,
.scatter-actions button {
  height: 32px;
  border: 1px solid rgba(21, 26, 31, 0.12);
  border-radius: 3px;
  color: var(--ink);
  background: var(--accent);
  padding: 0 10px;
}

.legend {
  position: absolute;
  z-index: 610;
  left: 14px;
  bottom: 14px;
  width: min(280px, calc(100% - 28px));
  padding: 11px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 3px;
  box-shadow: 0 12px 34px rgba(21, 26, 31, 0.16);
  backdrop-filter: blur(14px);
}

.legend-title {
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.legend-ramp {
  height: 9px;
}

.legend-scale {
  display: flex;
  justify-content: space-between;
  margin-top: 6px;
  color: var(--muted);
  font-size: 11px;
}

.question-window {
  position: absolute;
  z-index: 660;
  left: 14px;
  top: 56px;
  width: min(360px, calc(100% - 28px));
  max-height: calc(100% - 160px);
  overflow: hidden;
  color: var(--text);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 3px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px);
}

.question-window.is-hidden {
  display: none;
}

.question-window.is-minimized {
  width: 220px;
}

.question-window.is-minimized .question-body,
.question-window.is-minimized #activeQuestionLabel {
  display: none;
}

.question-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 34px 34px;
  min-height: 54px;
}

.question-title,
.question-minimize,
.question-close {
  border: 0;
  color: var(--text);
  background: transparent;
}

.question-title {
  padding: 10px 12px;
  text-align: left;
}

.question-title span,
.question-title strong {
  display: block;
}

.question-title span {
  color: var(--accent);
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
}

.question-title strong {
  margin-top: 4px;
  font-size: 14px;
}

.question-minimize,
.question-close {
  border-left: 1px solid var(--line);
}

.question-body {
  display: grid;
  grid-template-rows: 1fr;
  overflow: hidden;
  border-top: 1px solid var(--line);
}

.question-window.is-collapsed .question-body {
  grid-template-rows: 0fr;
  border-top-color: transparent;
}

.question-list {
  min-height: 0;
  max-height: min(380px, calc(100vh - 240px));
  overflow: auto;
  padding: 6px;
}

.question-card {
  width: 100%;
  display: grid;
  grid-template-columns: 4px minmax(0, 1fr);
  gap: 10px;
  padding: 10px 9px 10px 0;
  color: var(--text);
  background: transparent;
  border: 0;
  border-bottom: 1px solid var(--line);
  text-align: left;
}

.question-card::before {
  content: "";
  background: var(--teal);
}

.question-card strong,
.question-card span {
  display: block;
}

.question-card strong {
  font-size: 13px;
}

.question-card span {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.3;
}

.question-card:hover,
.question-card.is-active {
  background: rgba(204, 71, 120, 0.08);
}

.side-panel {
  grid-column: 3;
  grid-row: 1;
  min-height: 0;
  align-self: end;
  height: calc(100% - 150px);
  overflow: auto;
  padding: 16px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 3px;
  box-shadow: var(--shadow);
}

.map-tools {
  position: absolute;
  z-index: 652;
  top: 14px;
  left: 126px;
  display: flex;
  align-items: flex-start;
  gap: 8px;
  pointer-events: auto;
}

.map-search {
  position: relative;
  width: 210px;
}

.map-search input {
  width: 100%;
  height: 32px;
  border: 1px solid rgba(21, 26, 31, 0.14);
  border-radius: 3px;
  padding: 0 10px;
  background: #fff;
  color: var(--text);
  box-shadow: var(--shadow);
  outline: none;
}

.map-search input:focus {
  border-color: rgba(204, 71, 120, 0.5);
}

.map-search-results {
  position: absolute;
  z-index: 2;
  top: 38px;
  left: 0;
  right: 0;
  max-height: 210px;
  overflow: auto;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 3px;
  box-shadow: var(--shadow);
}

.map-search-results.is-hidden {
  display: none;
}

.map-search-results button {
  width: 100%;
  min-height: 34px;
  padding: 7px 9px;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: #fff;
  color: var(--text);
  text-align: left;
  font-size: 12px;
}

.map-search-results button:hover,
.map-search-results button.is-active {
  background: rgba(204, 71, 120, 0.08);
}

.map-level-switch {
  display: grid;
  grid-template-columns: repeat(2, minmax(72px, 1fr));
  gap: 4px;
  height: 32px;
  padding: 3px;
  background: #fff;
  border: 1px solid rgba(21, 26, 31, 0.14);
  border-radius: 3px;
  box-shadow: var(--shadow);
}

.map-level-switch button {
  border: 0;
  border-radius: 2px;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.map-level-switch button.is-active {
  color: #fff;
  background: var(--ink);
}

.top-party-pin {
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border: 2px solid #fff;
  border-radius: 50%;
  background: var(--accent);
  color: var(--ink);
  font-size: 11px;
  font-weight: 900;
  box-shadow: 0 8px 18px rgba(21, 26, 31, 0.28);
}

.panel-kicker,
.section-title {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.side-panel h1 {
  margin: 8px 0;
  font-size: 22px;
  line-height: 1.1;
}

.side-panel p {
  margin: 0;
  color: var(--muted);
  line-height: 1.4;
}

.metrics-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1px;
  margin: 16px -16px 0;
  background: var(--line);
}

.metric {
  min-height: 78px;
  padding: 12px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 3px;
}

.metric span,
.metric i {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-style: normal;
}

.metric strong {
  display: block;
  margin-top: 6px;
  font-size: 21px;
  line-height: 1;
}

.metric i {
  margin-top: 6px;
  color: var(--teal);
}

.micro-section {
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.section-note,
.reading {
  font-size: 13px;
}

.bar-compare {
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr) 52px;
  align-items: center;
  gap: 8px;
  margin: 8px 0;
  font-size: 12px;
}

.bar-compare div {
  height: 8px;
  overflow: hidden;
  background: rgba(21, 26, 31, 0.12);
}

.bar-compare i {
  display: block;
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, var(--teal), var(--accent), var(--rose));
}

.bar-compare b {
  text-align: right;
}

.ranking-panel {
  grid-column: 2 / 4;
  grid-row: 2;
  min-height: 0;
  display: grid;
  grid-template-rows: auto 1fr;
  overflow: hidden;
}

.ranking-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
}

.ranking-head span {
  display: block;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

.ranking-head strong {
  display: block;
  margin-top: 2px;
}

.ranking-list {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(280px, 32%);
  overflow-x: auto;
  overflow-y: hidden;
}

.ranking-item {
  min-height: 100%;
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr);
  align-content: center;
  gap: 10px;
  padding: 12px;
  color: var(--text);
  background: transparent;
  border: 0;
  border-right: 1px solid var(--line);
  text-align: left;
}

.ranking-item:hover,
.ranking-item.is-active {
  background: rgba(35, 143, 157, 0.12);
}

.rank-index {
  grid-row: span 2;
  color: var(--rose);
  font-weight: 900;
}

.ranking-item strong,
.ranking-item span {
  display: block;
}

.ranking-item strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ranking-item span {
  color: var(--muted);
  font-size: 12px;
}

.rank-value {
  grid-column: 2;
  margin-top: 7px;
  color: var(--text);
  font-weight: 900;
}

.circuit-drawer {
  position: absolute;
  z-index: 670;
  right: 14px;
  bottom: 14px;
  width: min(520px, calc(100% - 320px));
  height: min(390px, calc(100% - 110px));
  min-height: 250px;
  display: grid;
  grid-template-rows: auto 1fr;
  overflow: hidden;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 3px;
  box-shadow: var(--shadow);
}

.circuit-drawer.is-hidden,
.scatter-panel.is-hidden {
  display: none;
}

.drawer-head,
.scatter-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 11px 12px;
  border-bottom: 1px solid var(--line);
}

.drawer-head span,
.scatter-head span {
  display: block;
  color: var(--muted);
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
}

.drawer-head strong,
.scatter-head strong {
  display: block;
  margin-top: 2px;
}

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

#circuitMap {
  min-height: 0;
}

.scatter-panel {
  position: fixed;
  z-index: 900;
  left: 320px;
  top: 72px;
  width: min(760px, calc(100vw - 360px));
  min-width: 560px;
  max-height: calc(100vh - 110px);
  display: grid;
  grid-template-rows: auto auto minmax(360px, 1fr) auto auto;
  overflow: hidden;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 3px;
  box-shadow: var(--shadow);
}

.scatter-panel.is-dragging {
  opacity: 0.94;
}

.scatter-head {
  cursor: move;
}

.scatter-controls {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  padding: 12px;
  border-bottom: 1px solid var(--line);
}

.scatter-chart-wrap {
  min-height: 0;
  padding: 10px 12px 0;
}

#scatterChart {
  width: 100%;
  height: 100%;
  min-height: 360px;
  display: block;
}

.plot-bg {
  fill: rgba(21, 26, 31, 0.04);
}

.axis-line {
  stroke: rgba(21, 26, 31, 0.52);
}

.reference-line {
  stroke: rgba(21, 26, 31, 0.34);
  stroke-width: 1;
  stroke-dasharray: 4 5;
  vector-effect: non-scaling-stroke;
}

.trend-line {
  stroke: var(--rose);
  stroke-width: 2;
  stroke-dasharray: 6 5;
}

.scatter-point {
  fill: var(--teal);
  stroke: var(--ink);
  stroke-width: 1;
  opacity: 0.76;
  cursor: pointer;
}

.scatter-point:hover,
.scatter-point.is-selected {
  fill: var(--rose);
  opacity: 1;
}

.brush-rect {
  fill: rgba(35, 143, 157, 0.18);
  stroke: var(--teal);
}

.axis-title {
  fill: var(--muted);
  font-size: 11px;
  font-weight: 800;
}

.axis-tick {
  fill: rgba(21, 26, 31, 0.62);
  font-size: 10px;
  font-weight: 750;
  pointer-events: none;
}

.axis-zero-label {
  fill: rgba(21, 26, 31, 0.82);
  font-weight: 900;
}

.middle {
  text-anchor: middle;
}

.scatter-stats,
.scatter-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  color: var(--muted);
  font-size: 12px;
  border-top: 1px solid var(--line);
}

.loading {
  position: fixed;
  z-index: 1000;
  inset: 0;
  display: grid;
  place-items: center;
  color: #fff;
  background: var(--ink);
  transition: opacity 240ms ease, visibility 240ms ease;
}

.loading.is-hidden {
  opacity: 0;
  visibility: hidden;
}

.methodology-modal[hidden] {
  display: none;
}

.methodology-modal {
  position: fixed;
  z-index: 1100;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 24px;
}

.methodology-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(21, 26, 31, 0.46);
}

.methodology-panel {
  position: relative;
  z-index: 1;
  width: min(760px, 100%);
  max-height: calc(100vh - 48px);
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  overflow: hidden;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 3px;
  box-shadow: 0 20px 64px rgba(21, 26, 31, 0.24);
}

.methodology-panel:focus {
  outline: none;
}

.methodology-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 15px 16px;
  border-bottom: 1px solid var(--line);
}

.methodology-head span {
  display: block;
  color: var(--muted);
  font-size: 10px;
  font-weight: 900;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.methodology-head h2 {
  margin: 2px 0 0;
  color: var(--ink);
  font-size: 21px;
  line-height: 1.1;
}

.methodology-close {
  width: 32px;
  height: 32px;
  flex: 0 0 auto;
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 3px;
  font-weight: 900;
}

.methodology-close:hover,
.methodology-close:focus-visible {
  color: #fff;
  background: var(--ink);
  border-color: var(--ink);
}

.methodology-close:focus-visible {
  outline: 3px solid rgba(35, 143, 157, 0.2);
  outline-offset: 2px;
}

.methodology-content {
  min-height: 0;
  overflow: auto;
  padding: 18px 20px 22px;
  color: var(--text);
  font-size: 14px;
  line-height: 1.55;
}

.methodology-content h3 {
  margin: 22px 0 8px;
  color: var(--ink);
  font-size: 15px;
  line-height: 1.25;
}

.methodology-content p,
.methodology-content ul,
.methodology-content ol {
  margin: 0 0 12px;
}

.methodology-content ul,
.methodology-content ol {
  padding-left: 20px;
}

.methodology-content li + li {
  margin-top: 5px;
}

.methodology-content a {
  color: #146f7a;
  font-weight: 800;
}

.methodology-doc-link {
  padding-top: 10px;
  border-top: 1px solid var(--line);
}

.methodology-foot {
  padding: 10px 16px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  background: #fff;
  font-size: 11px;
  font-weight: 700;
  line-height: 1.35;
}

.methodology-foot a {
  color: #146f7a;
  font-weight: 900;
}

.map-tooltip {
  padding: 8px 10px;
  color: #fff;
  background: rgba(21, 26, 31, 0.92);
  border: 0;
  box-shadow: var(--shadow);
}

.map-tooltip .tooltip-title,
.map-tooltip .tooltip-value {
  font-weight: 900;
}

.map-tooltip .tooltip-unit {
  margin: 3px 0;
  color: rgba(255, 255, 255, 0.68);
  font-size: 10px;
  text-transform: uppercase;
}

.map-tooltip .tooltip-category {
  margin: 4px 0;
  color: #7bd2df;
  font-size: 13px;
  font-weight: 900;
}

.leaflet-container {
  font: inherit;
}

.pulse-ring {
  animation: pulse 800ms ease-out;
}

@keyframes pulse {
  45% {
    filter: drop-shadow(0 0 12px rgba(231, 184, 77, 0.9));
  }
}

@media (max-width: 1180px) {
  body {
    overflow: auto;
  }

  .app-shell {
    height: auto;
    min-height: 100dvh;
    grid-template-columns: 1fr;
    grid-template-rows: auto minmax(56vh, 620px) auto auto;
  }

  .topbar,
  .map-column,
  .kpi-strip,
  .side-panel,
  .ranking-panel {
    grid-column: 1;
    grid-row: auto;
  }

  .topbar {
    grid-template-rows: auto auto;
  }

  .control-strip {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .map-column {
    min-height: 56vh;
  }

  .side-panel {
    height: auto;
  }

  .ranking-list {
    grid-auto-flow: row;
    grid-auto-columns: auto;
    overflow-y: auto;
  }

  .ranking-item {
    min-height: auto;
    grid-template-columns: 34px minmax(0, 1fr) auto;
  }

  .rank-value {
    grid-column: auto;
  }

  .scatter-panel {
    left: 16px;
    top: 16px;
    width: calc(100vw - 32px);
    min-width: 0;
  }

  .methodology-modal {
    padding: 16px;
  }
}

@media (max-width: 720px) {
  .app-shell {
    padding: 8px;
    gap: 8px;
  }

  .control-strip,
  .kpi-strip,
  .metrics-grid,
  .scatter-controls {
    grid-template-columns: 1fr;
  }

  .question-window,
  .circuit-drawer {
    left: 8px;
    right: 8px;
    width: auto;
  }

  .circuit-drawer {
    height: 300px;
  }
}

/* Version 05: tablero 30/50/20 */
.app-shell {
  grid-template-columns: minmax(260px, 19fr) minmax(620px, 66fr) minmax(220px, 15fr);
  grid-template-rows: minmax(0, 1fr);
  background: var(--paper);
}

.workspace-panel {
  display: contents;
}

.topbar {
  grid-column: 1;
  grid-row: 1;
  min-height: 0;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 18px;
}

.map-column {
  grid-column: 2;
  grid-row: 1;
  display: grid;
  grid-template-rows: minmax(0, 2.65fr) minmax(180px, 1fr);
  gap: 12px;
  overflow: hidden;
  background: transparent;
  border: 0;
  box-shadow: none;
}

.map-pane {
  position: relative;
  min-height: 0;
  overflow: hidden;
  background: #eef3f1;
  border: 1px solid var(--line);
  border-radius: 3px;
  box-shadow: var(--shadow);
}

.map-summary {
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(190px, 1fr) minmax(220px, 1fr) minmax(360px, 2fr);
  gap: 12px;
}

.kpi-strip {
  grid-column: auto;
  grid-row: auto;
  align-self: stretch;
  grid-template-columns: 1fr;
  gap: 0;
  min-height: 0;
  padding: 0;
  overflow: hidden;
  color: #f7fbff;
  background: #111a21;
  border-color: rgba(255, 255, 255, 0.08);
}

.kpi-strip .kpi-item {
  min-height: 0;
  padding: clamp(6px, 0.72vw, 9px) clamp(8px, 0.9vw, 11px);
  color: #f7fbff;
  background: #26313a;
  border: 0;
  border-right: 1px solid rgba(255, 255, 255, 0.08);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 0;
}

.kpi-strip .kpi-item span {
  color: #9fc3d6;
  font-size: clamp(8px, 0.68vw, 9px);
  letter-spacing: 0;
  text-transform: none;
}

.kpi-strip .kpi-item strong {
  margin-top: clamp(2px, 0.36vw, 4px);
  color: #fff;
  font-size: clamp(13px, 1vw, 17px);
  line-height: 1.08;
  white-space: normal;
}

.kpi-strip .kpi-item i {
  margin-top: clamp(1px, 0.28vw, 3px);
  min-height: 0;
  color: #f2c14e;
  font-size: clamp(8px, 0.68vw, 10px);
  line-height: 1.2;
}

.vote-stack-card,
.total-vote-card {
  min-width: 0;
  min-height: 0;
  display: grid;
  grid-template-rows: auto clamp(18px, 3.2vh, 34px) minmax(0, auto);
  gap: clamp(5px, 1vw, 10px);
  padding: clamp(8px, 1.1vw, 14px);
  overflow: hidden;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 3px;
  box-shadow: var(--shadow);
}

.vote-stack,
.total-vote-stack {
  display: flex;
  min-width: 0;
  overflow: hidden;
  background: #f1f3f2;
  border: 1px solid var(--line);
  border-radius: 3px;
}

.vote-stack span,
.total-vote-stack span {
  min-width: 2px;
  display: grid;
  place-items: center;
  overflow: hidden;
  color: #fff;
  font-size: 10px;
  font-weight: 900;
  text-shadow: 0 1px 2px rgba(21, 26, 31, 0.42);
}

.vote-stack-legend,
.total-vote-legend {
  min-height: 0;
  overflow: hidden;
  display: grid;
  gap: clamp(3px, 0.7vw, 6px);
  align-content: start;
}

.vote-stack-legend div,
.total-vote-legend div {
  display: grid;
  grid-template-columns: 10px minmax(0, 1fr) auto;
  align-items: center;
  gap: clamp(5px, 0.8vw, 8px);
  color: var(--muted);
  font-size: clamp(9px, 0.78vw, 12px);
  line-height: 1.15;
}

.vote-stack-legend i,
.total-vote-legend i {
  width: clamp(7px, 0.8vw, 10px);
  height: clamp(7px, 0.8vw, 10px);
}

.winner-legend {
  display: grid;
  gap: 6px;
}

.winner-legend div {
  display: grid;
  grid-template-columns: 10px minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 12px;
}

.winner-legend i {
  width: 10px;
  height: 10px;
}

.winner-legend span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.competitiveness-legend {
  display: grid;
  gap: 6px;
}

.competitiveness-legend div {
  display: grid;
  grid-template-columns: 10px minmax(0, 1fr);
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 12px;
}

.competitiveness-legend i {
  width: 10px;
  height: 10px;
}

.vote-stack-legend span,
.total-vote-legend span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ranking-panel {
  grid-column: 3;
  grid-row: 1;
  min-height: 0;
  background: #fff;
  border-radius: 3px;
}

.ranking-list {
  grid-auto-flow: row;
  grid-auto-columns: auto;
  overflow-x: hidden;
  overflow-y: auto;
}

.ranking-item {
  min-height: 72px;
  grid-template-columns: 30px minmax(0, 1fr) auto;
  border-right: 0;
  border-bottom: 1px solid var(--line);
  background: #fff;
}

.rank-value {
  grid-column: 3;
  grid-row: 1 / 3;
  align-self: center;
  margin-top: 0;
  white-space: nowrap;
}

.rank-value b,
.rank-value small,
.rank-category {
  display: block;
}

.rank-value small {
  margin-top: 3px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}

.rank-category {
  color: var(--teal) !important;
  font-weight: 800;
}

.side-panel {
  display: none;
}

.segmented {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 4px;
  padding: 4px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 3px;
}

.filter-group {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.segmented button,
.panel-actions button {
  min-height: 36px;
  border: 1px solid transparent;
  border-radius: 3px;
  color: var(--text);
  background: #fff;
}

.segmented button.is-active {
  color: #fff;
  background: var(--ink);
}

.panel-actions {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(116px, 100%), 1fr));
  gap: clamp(6px, 1vw, 8px);
}

.panel-actions button {
  min-width: 0;
  padding: 0 clamp(8px, 1vw, 12px);
  background: linear-gradient(180deg, #f5c95e, #e7b84d);
  border-color: rgba(21, 26, 31, 0.12);
  font-size: clamp(12px, 0.9vw, 14px);
  font-weight: 800;
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.7) inset, 0 8px 20px rgba(231, 184, 77, 0.18);
}

.export-actions button {
  background: #fff;
  border-color: var(--line);
  font-weight: 700;
  box-shadow: none;
}

.panel-actions button:disabled {
  cursor: not-allowed;
  color: rgba(21, 26, 31, 0.45);
  background: #eef0ef;
  border-color: rgba(21, 26, 31, 0.1);
  box-shadow: none;
}

.metric-definition {
  margin: 0;
  padding: 10px;
  color: var(--muted);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 3px;
  font-size: 12px;
  line-height: 1.35;
}

.filter-election-compare,
.vote-type-filter,
.force-filter,
.positive-measure-filter {
  display: grid !important;
}

body.is-compare-mode .filter-election-single {
  display: grid !important;
}

body.is-compare-mode .filter-election-compare,
body.is-votes-metric .vote-type-filter,
body.is-positive-vote .force-filter,
body.is-positive-vote .positive-measure-filter {
  display: grid !important;
}

.control-strip label.is-disabled {
  opacity: 0.48;
}

.control-strip label.is-disabled select {
  cursor: not-allowed;
  color: rgba(30, 37, 43, 0.5);
  background: #eef0ef;
}

.ranking-context {
  max-width: 150px;
  text-align: right;
}

.legend {
  left: 14px;
  bottom: 14px;
  width: min(250px, calc(100% - 28px));
}

.question-window {
  left: 14px;
  top: 58px;
  width: min(330px, calc(100% - 28px));
}

body.is-questions-open .map-pane {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(360px, 1fr);
  gap: 12px;
  padding: 0;
  background: transparent;
  border: 0;
}

body.is-questions-open .map-stage,
body.is-questions-open .question-window {
  position: relative;
  inset: auto;
  min-width: 0;
  min-height: 0;
  height: 100%;
  border: 1px solid var(--line);
  border-radius: 3px;
  overflow: hidden;
  background: #fff;
  box-shadow: var(--shadow);
}

body.is-questions-open .map-stage {
  background: #eef3f1;
}

body.is-questions-open #map {
  height: 100%;
}

body.is-questions-open .question-window {
  z-index: 1;
  left: auto;
  top: auto;
  width: auto;
  max-height: none;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
}

body.is-questions-open .question-window.is-hidden {
  display: none;
}

body.is-questions-open .question-window.is-collapsed .question-body,
body.is-questions-open .question-window.is-minimized .question-body,
body.is-questions-open .question-window.is-minimized #activeQuestionLabel {
  display: grid;
}

body.is-questions-open .question-head {
  grid-template-columns: minmax(0, 1fr) 34px;
}

body.is-questions-open .question-minimize {
  display: none;
}

body.is-questions-open .question-body {
  min-height: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  border-top: 1px solid var(--line);
}

body.is-questions-open .assistant-response {
  padding: 14px;
  border-bottom: 1px solid var(--line);
  background: #101820;
  color: #fff;
}

body.is-questions-open .assistant-response span,
body.is-questions-open .question-group-title {
  display: block;
  color: var(--muted);
  font-size: 10px;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0;
}

body.is-questions-open .assistant-response strong {
  display: block;
  margin-top: 5px;
  font-size: 16px;
  line-height: 1.2;
}

body.is-questions-open .assistant-response p {
  margin: 10px 0 0;
  color: rgba(255, 255, 255, 0.82);
  font-size: 13px;
  line-height: 1.45;
}

body.is-questions-open .question-list {
  max-height: none;
  padding: 10px;
}

body.is-questions-open .question-group + .question-group {
  margin-top: 14px;
}

body.is-questions-open .question-group-title {
  margin: 0 0 6px;
  color: var(--muted);
}

body.is-questions-open .question-card {
  min-height: 54px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 3px;
  background: #fff;
}

body.is-questions-open .question-card + .question-card {
  margin-top: 6px;
}

body.is-questions-open .question-card::before {
  border-radius: 2px;
}

body.is-questions-open .question-card.is-active {
  border-color: rgba(204, 71, 120, 0.42);
  background: rgba(204, 71, 120, 0.08);
}

.question-head,
.drawer-head,
.scatter-head {
  cursor: move;
}

.is-dragging {
  user-select: none;
  opacity: 0.96;
}

.circuit-drawer {
  right: 14px;
  bottom: 14px;
  width: min(420px, calc(100% - 300px));
  height: min(330px, calc(100% - 104px));
}

.mini-compare {
  display: grid;
  grid-template-columns: 94px minmax(0, 1fr) 48px;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
  color: #d8e6ef;
  font-size: 11px;
}

.mini-compare div {
  height: 8px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.14);
  border-radius: 0;
}

.mini-compare b {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, #22c7e6, #b7e884, #f2c14e, #ef5f72);
}

.mini-compare em {
  font-style: normal;
  text-align: right;
}

.kpi-competitiveness {
  min-height: 0;
  background: #111a21 !important;
}

.kpi-competitiveness .kpi-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}

.kpi-info-button {
  width: 17px;
  height: 17px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  padding: 0;
  color: #f7fbff;
  background: rgba(247, 251, 255, 0.12);
  border: 1px solid rgba(247, 251, 255, 0.28);
  border-radius: 50%;
  font-size: 10px;
  font-weight: 900;
  line-height: 1;
}

.kpi-info-button:hover,
.kpi-info-button:focus-visible {
  color: #111a21;
  background: #f2c14e;
  border-color: #f2c14e;
  outline: none;
}

.kpi-competitiveness span {
  color: #f7fbff !important;
  font-weight: 900;
  letter-spacing: 0.06em !important;
  text-transform: uppercase !important;
}

.kpi-competitiveness p {
  display: block;
  margin: clamp(1px, 0.28vw, 3px) 0 0;
  color: #f2c14e;
  font-size: clamp(8px, 0.68vw, 10px);
  line-height: 1.2;
}

.competitiveness-info-modal {
  position: fixed;
  inset: 0;
  z-index: 1200;
  display: none;
  place-items: center;
  padding: 14px;
}

.competitiveness-info-modal.is-open {
  display: grid;
}

.competitiveness-info-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(21, 26, 31, 0.34);
}

.competitiveness-info-panel {
  position: relative;
  z-index: 1;
  width: min(430px, calc(100vw - 28px));
  max-height: min(620px, calc(100vh - 28px));
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  overflow: hidden;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 3px;
  box-shadow: var(--shadow);
}

.competitiveness-info-panel header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 34px;
  align-items: center;
  gap: 8px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
}

.competitiveness-info-panel h2 {
  margin: 0;
  font-size: 15px;
}

.competitiveness-info-panel header button {
  width: 30px;
  height: 30px;
  border: 1px solid var(--line);
  border-radius: 3px;
  background: #fff;
  font-weight: 900;
}

.competitiveness-info-content {
  min-height: 0;
  overflow-y: auto;
  padding: 14px;
  color: var(--text);
  font-size: 13px;
  line-height: 1.45;
}

.competitiveness-info-content p,
.competitiveness-info-content ul {
  margin: 0 0 10px;
}

.competitiveness-info-content h3 {
  margin: 4px 0 8px;
  font-size: 12px;
  text-transform: uppercase;
}

.pinned-circuit-map {
  position: fixed;
  z-index: 880;
  width: min(420px, calc(100vw - 32px));
  height: 310px;
  display: grid;
  grid-template-rows: auto 1fr;
  overflow: hidden;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 3px;
  box-shadow: var(--shadow);
}

.pinned-map-canvas {
  min-height: 0;
}

body.is-scatter-page .app-shell {
  grid-template-columns: minmax(260px, 22fr) minmax(0, 78fr);
}

body.is-scatter-page .ranking-panel,
body.is-scatter-page .map-summary,
body.is-scatter-page .legend,
body.is-scatter-page .question-window,
body.is-scatter-page .circuit-drawer {
  display: none !important;
}

body.is-scatter-page .map-column {
  grid-column: 2;
  grid-template-rows: minmax(0, 1fr);
}

body.is-scatter-page .map-pane {
  min-height: 0;
}

body.is-scatter-page .scatter-panel {
  position: fixed;
  left: calc(30vw + 28px);
  top: 26px;
  width: min(760px, calc(70vw - 54px));
  min-width: 520px;
  max-height: calc(100vh - 52px);
}

body.is-questions-open.is-scatter-page .question-window {
  display: grid !important;
}

body.is-questions-open.is-scatter-page .map-pane {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(360px, 1fr);
}

body.is-questions-open.is-scatter-page .scatter-panel {
  left: calc(50vw + 16px);
  top: 26px;
  width: min(620px, calc(50vw - 42px));
}

@media (max-width: 1180px) {
  html,
  body,
  .app-shell {
    height: auto;
  }

  body {
    overflow: auto;
  }

  .app-shell,
  body.is-scatter-page .app-shell {
    grid-template-columns: 1fr;
    grid-template-rows: auto auto auto;
    min-height: 100vh;
  }

  .workspace-panel,
  .map-column,
  .ranking-panel,
  body.is-scatter-page .map-column {
    grid-column: 1;
    grid-row: auto;
  }

  .workspace-panel {
    display: grid;
  }

  .map-column {
    grid-template-rows: minmax(360px, 56vh) auto;
    overflow: hidden;
  }

  .map-summary {
    grid-template-columns: 1fr;
  }

  .ranking-panel {
    height: clamp(340px, 44vh, 520px);
    min-height: 340px;
  }

  body.is-questions-open .map-pane,
  body.is-questions-open.is-scatter-page .map-pane {
    grid-template-columns: 1fr;
    grid-template-rows: minmax(420px, 1fr) minmax(360px, auto);
  }

  body.is-questions-open .question-window {
    min-height: 360px;
  }

  .kpi-strip {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  body.is-scatter-page .scatter-panel {
    left: 16px;
    top: 16px;
    width: calc(100vw - 32px);
    min-width: 0;
  }

  body.is-questions-open.is-scatter-page .scatter-panel {
    left: 16px;
    top: 16px;
    width: calc(100vw - 32px);
  }
}

@media (max-width: 720px) {
  .map-tools {
    left: 8px;
    right: 8px;
    top: 52px;
    flex-wrap: wrap;
  }

  .map-search {
    width: min(100%, 240px);
  }

  .map-column {
    grid-template-rows: minmax(330px, 52vh) auto;
  }

  .methodology-modal {
    padding: 8px;
  }

  .methodology-panel {
    max-height: calc(100vh - 16px);
  }

  .methodology-head {
    padding: 12px;
  }

  .methodology-content {
    padding: 14px 14px 18px;
    font-size: 13px;
  }

  .panel-actions,
  .kpi-strip,
  .map-summary {
    grid-template-columns: 1fr;
  }

  .ranking-panel {
    height: clamp(320px, 48vh, 460px);
    min-height: 320px;
  }

  .ranking-item {
    grid-template-columns: 30px minmax(0, 1fr);
  }

  .rank-value {
    grid-column: 2;
    grid-row: auto;
    white-space: normal;
  }

  body.is-questions-open .map-pane,
  body.is-questions-open.is-scatter-page .map-pane {
    display: block;
  }

  body.is-questions-open .map-stage {
    position: absolute;
    inset: 0;
    height: 100%;
  }

  body.is-questions-open .question-window {
    position: fixed;
    z-index: 950;
    left: 8px;
    right: 8px;
    top: 70px;
    bottom: 10px;
    width: auto;
    height: auto;
    min-height: 0;
    max-height: calc(100vh - 80px);
    display: grid;
    grid-template-rows: auto minmax(0, 1fr);
  }

  body.is-questions-open .question-window.is-hidden {
    display: none;
  }

  body.is-questions-open .question-body {
    min-height: 0;
    overflow: hidden;
  }

  body.is-questions-open .question-list {
    min-height: 0;
    overflow-y: auto;
  }

  body.is-questions-open .assistant-response {
    max-height: 34vh;
    overflow-y: auto;
  }
}

.report-root {
  display: none;
}

.report-root.is-rendering {
  position: fixed;
  left: -10000px;
  top: 0;
  width: 794px;
  min-height: 1123px;
  display: block;
  visibility: hidden;
  pointer-events: none;
}

.report-page {
  color: var(--text);
  background: #fff;
}

.report-header,
.report-section {
  padding: 18px 0;
  border-bottom: 1px solid var(--line);
}

.report-header h1 {
  margin: 0 0 8px;
  font-size: 24px;
  line-height: 1.1;
}

.report-meta,
.report-method {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px 18px;
  color: var(--muted);
  font-size: 11px;
}

.report-section h2 {
  margin: 0 0 10px;
  font-size: 15px;
}

.report-kpis {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.report-kpis .kpi-item {
  min-height: 70px;
}

.report-map {
  position: relative;
  height: 430px;
  overflow: hidden;
  background: #eef3f1;
  border: 1px solid var(--line);
}

#reportMapCanvas,
.report-map .leaflet-container {
  width: 100%;
  height: 100%;
}

#reportMapCanvas {
  height: 360px;
  min-height: 360px;
  display: block;
}

.report-map .leaflet-control-container {
  display: none !important;
}

.report-map .top-party-pin {
  box-shadow: 0 1px 4px rgba(21, 26, 31, 0.45);
}

.report-ranking {
  display: grid;
  gap: 6px;
}

.report-ranking .ranking-item {
  min-height: 0;
  grid-template-columns: 30px minmax(0, 1fr) auto;
  padding: 8px 10px;
  border: 1px solid var(--line);
}

.report-distribution {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.report-distribution .vote-stack-card,
.report-distribution .total-vote-card {
  box-shadow: none;
}

@media print {
  * {
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
  }

  @page {
    size: A4 portrait;
    margin: 14mm;
  }

  html,
  body {
    height: auto;
    overflow: visible;
    background: #ffffff !important;
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
  }

  .report-root,
  .report-root *,
  .report,
  .report *,
  .report-page,
  .report-page * {
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
  }

  .app-shell > :not(.report-root) {
    display: none !important;
  }

  .app-shell,
  .report-root {
    display: block !important;
    min-height: auto;
    height: auto;
    padding: 0;
  }

  .report-root {
    position: static !important;
    width: auto !important;
    min-height: auto !important;
    visibility: visible !important;
    font-size: 12px;
  }

  .report-section {
    break-inside: avoid;
    page-break-inside: avoid;
  }

  .report-map,
  .report-distribution {
    break-inside: avoid;
    page-break-inside: avoid;
  }

  .report-map {
    height: 360px;
  }

  .vote-stack span,
  .total-vote-stack span,
  .vote-stack-legend i,
  .total-vote-legend i {
    outline: 1px solid rgba(21, 26, 31, 0.28);
  }

  .report-ranking .ranking-item {
    break-inside: avoid;
  }
}
