:root {
  --bg: #eef2f5;
  --panel: #ffffff;
  --ink: #17202a;
  --muted: #627286;
  --line: #d4dce4;
  --blue: #176b87;
  --orange: #b66a00;
  --green: #2f855a;
  --red: #b42318;
  --purple: #7b3f98;
  --focus: #2454d6;
  --shadow: 0 16px 46px rgba(17, 24, 39, 0.12);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  margin: 0;
}

body {
  background: var(--bg);
  color: var(--ink);
}

body.is-loading {
  background: #ffffff;
}

button,
select {
  font: inherit;
}

.loading-screen {
  align-items: center;
  background: #ffffff;
  color: var(--ink);
  display: flex;
  flex-direction: column;
  gap: 16px;
  inset: 0;
  justify-content: center;
  position: fixed;
  z-index: 9999;
}

.loading-screen p {
  color: var(--muted);
  font-size: 15px;
  font-weight: 720;
  letter-spacing: 0;
}

.loading-spinner {
  animation: loading-spin 0.85s linear infinite;
  border: 3px solid #e5ebf0;
  border-top-color: var(--blue);
  border-radius: 999px;
  height: 34px;
  width: 34px;
}

body:not(.is-loading) .loading-screen {
  display: none;
}

@keyframes loading-spin {
  to {
    transform: rotate(360deg);
  }
}

.political-shell {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  height: 100dvh;
  min-width: 320px;
  padding: 14px;
}

.question-bar {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  margin-bottom: 14px;
  padding: 12px;
}

select {
  appearance: none;
  background:
    linear-gradient(45deg, transparent 50%, var(--ink) 50%) calc(100% - 18px) 50% / 7px 7px no-repeat,
    linear-gradient(135deg, var(--ink) 50%, transparent 50%) calc(100% - 13px) 50% / 7px 7px no-repeat,
    #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  font-size: 20px;
  font-weight: 780;
  height: 58px;
  outline: none;
  padding: 0 44px 0 14px;
  width: 100%;
}

select:focus {
  border-color: var(--focus);
  box-shadow: 0 0 0 3px rgba(36, 84, 214, 0.16);
}

.split {
  display: grid;
  gap: 14px;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  min-height: 0;
}

.map-panel,
.answer-panel,
.error-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  min-height: 0;
  overflow: hidden;
}

.map-panel {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
}

.map-head,
.answer-head {
  border-bottom: 1px solid var(--line);
  padding: 14px 16px;
}

h1,
h2,
h3,
p {
  margin: 0;
}

.map-head h1,
.answer-head h2 {
  font-size: 20px;
  font-weight: 820;
  line-height: 1.2;
}

.map-head p,
.answer-head p {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.4;
  margin-top: 5px;
}

.rendered-map-shell {
  align-items: stretch;
  background: #dce8ee;
  display: flex;
  min-height: 0;
  overflow: hidden;
  width: 100%;
}

#renderedMap {
  display: block;
  height: 100%;
  object-fit: cover;
  object-position: center;
  width: 100%;
}

.map-footer {
  align-items: center;
  border-top: 1px solid var(--line);
  display: block;
  gap: 10px;
  min-height: 38px;
  padding: 8px 12px;
}

.map-legend {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  min-width: 0;
}

.legend-item {
  align-items: center;
  color: var(--muted);
  display: inline-flex;
  font-size: 12px;
  font-weight: 720;
  gap: 6px;
  line-height: 1.3;
}

.swatch {
  border-radius: 999px;
  display: inline-block;
  height: 10px;
  width: 10px;
}

.map-status {
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  height: 1px;
  overflow: hidden;
  position: absolute;
  white-space: nowrap;
  width: 1px;
}

.answer-panel {
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr) auto;
}

.kpis {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  padding: 14px 16px;
}

.kpi {
  align-items: center;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-height: 104px;
  min-width: 0;
  padding: 12px 10px;
  text-align: center;
}

.kpi[data-tone="ok"] {
  background: #eaf6ef;
  border-color: #b9dec5;
}

.kpi[data-tone="warn"] {
  background: #fff3df;
  border-color: #ebc172;
}

.kpi[data-tone="risk"] {
  background: #fff0ed;
  border-color: #f2b8b0;
}

.kpi-value {
  color: var(--ink);
  display: block;
  font-size: 25px;
  font-weight: 850;
  line-height: 1.06;
  overflow-wrap: anywhere;
}

.kpi-label {
  color: var(--muted);
  display: block;
  font-size: 12px;
  font-weight: 750;
  line-height: 1.35;
  margin-top: 7px;
}

.kpi-hint {
  color: var(--muted);
  display: block;
  font-size: 12px;
  line-height: 1.35;
  margin-top: 2px;
}

.answer-body {
  min-height: 0;
  overflow: auto;
  padding: 0 16px 16px;
}

.chart-block {
  border-top: 1px solid var(--line);
  padding-top: 14px;
}

.chart-block h3 {
  font-size: 16px;
  margin-bottom: 12px;
}

.bar-list {
  display: grid;
  gap: 9px;
}

.bar-row {
  display: grid;
  gap: 8px;
  grid-template-columns: minmax(92px, 132px) minmax(0, 1fr) minmax(78px, auto);
}

.bar-label,
.bar-value {
  align-self: center;
  color: var(--ink);
  font-size: 13px;
  font-weight: 760;
  line-height: 1.25;
}

.bar-value {
  color: var(--muted);
  text-align: right;
}

.bar-track {
  align-self: center;
  background: #e6ecf1;
  border-radius: 999px;
  height: 13px;
  overflow: hidden;
}

.bar-fill {
  background: var(--blue);
  border-radius: 999px;
  height: 100%;
}

.bar-fill.ok {
  background: var(--green);
}

.bar-fill.warn {
  background: var(--orange);
}

.bar-fill.risk {
  background: var(--red);
}

.bar-fill.fza {
  background: var(--blue);
}

.bar-fill.mixed {
  background: var(--purple);
}

.bar-fill.msc {
  background: var(--orange);
}

.proof-card {
  background: #f8fafb;
  border: 1px solid var(--line);
  border-radius: 8px;
  margin-top: 16px;
  overflow: hidden;
}

.proof-head {
  align-items: center;
  border-bottom: 1px solid var(--line);
  display: block;
  padding: 11px 12px;
}

.proof-head h3 {
  font-size: 15px;
  line-height: 1.25;
}

.proof-list {
  display: grid;
  gap: 8px;
  list-style: none;
  margin: 0;
  padding: 12px;
}

.proof-list li {
  color: var(--ink);
  font-size: 14px;
  font-weight: 660;
  line-height: 1.38;
  padding-left: 24px;
  position: relative;
}

.proof-list li::before {
  background: var(--blue);
  border-radius: 999px;
  content: "";
  height: 7px;
  left: 0;
  line-height: 7px;
  position: absolute;
  top: 8px;
  width: 7px;
}

.method-note {
  background: #f8fafb;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
  padding: 12px 16px;
}

.error-panel {
  color: var(--red);
  margin-top: 14px;
  padding: 16px;
}

@media (max-width: 980px) {
  .political-shell {
    height: auto;
    min-height: 100dvh;
  }

  .split {
    grid-template-columns: 1fr;
  }

  .map-panel {
    min-height: 520px;
  }

  .rendered-map-shell {
    min-height: 360px;
  }
}

@media (max-width: 640px) {
  .political-shell {
    padding: 8px;
  }

  select {
    font-size: 16px;
    height: 52px;
  }

  .kpis {
    grid-template-columns: 1fr;
  }

  .bar-row {
    grid-template-columns: 1fr;
  }

  .bar-value {
    text-align: left;
  }

  .proof-head {
    align-items: flex-start;
    flex-direction: column;
  }
}
