:root {
  --bg: #f3f0e7;
  --ink: #18211f;
  --muted: #66716e;
  --line: rgba(24, 33, 31, 0.14);
  --panel: rgba(255, 252, 244, 0.94);
  --good: #1e9c64;
  --mixed: #d8a72d;
  --risky: #d75949;
  --unknown: #a4aaa8;
  --water: #c9dde0;
  --shadow: 0 22px 60px rgba(30, 39, 37, 0.16);
}

* {
  box-sizing: border-box;
}

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

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

button,
input,
select {
  font: inherit;
}

.topbar {
  align-items: center;
  background: rgba(255, 252, 244, 0.88);
  border-bottom: 1px solid var(--line);
  display: flex;
  gap: 24px;
  justify-content: space-between;
  left: 0;
  min-height: 82px;
  padding: 14px 24px;
  position: fixed;
  right: 0;
  top: 0;
  z-index: 20;
}

.brand {
  align-items: center;
  display: flex;
  gap: 12px;
  min-width: 230px;
}

.brand-mark {
  background:
    radial-gradient(circle at 55% 45%, #f5f0df 0 18%, transparent 19%),
    conic-gradient(from 20deg, #1e9c64, #d8a72d, #d75949, #1e9c64);
  border: 1px solid rgba(24, 33, 31, 0.18);
  border-radius: 50%;
  display: inline-block;
  flex: 0 0 auto;
  height: 40px;
  width: 40px;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 22px;
  line-height: 1.1;
}

.brand p,
.compare-head p {
  color: var(--muted);
  font-size: 13px;
  margin-top: 4px;
}

.toolbar {
  align-items: end;
  display: flex;
  gap: 10px;
}

.search,
.select-control {
  display: grid;
  gap: 5px;
}

.search span,
.select-control span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
}

input,
select {
  background: #fffdf7;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  min-height: 40px;
  outline: none;
  padding: 0 12px;
}

input {
  min-width: 240px;
}

input:focus,
select:focus,
button:focus-visible {
  border-color: #197b58;
  box-shadow: 0 0 0 3px rgba(30, 156, 100, 0.18);
}

.primary-button,
.icon-button {
  background: #18211f;
  border: 1px solid transparent;
  border-radius: 8px;
  color: #fffdf7;
  cursor: pointer;
  min-height: 40px;
  padding: 0 16px;
}

.icon-button {
  align-items: center;
  display: inline-flex;
  font-size: 18px;
  justify-content: center;
  padding: 0;
  width: 40px;
}

.layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  height: 100%;
  padding-top: 82px;
}

.map-stage {
  background:
    linear-gradient(rgba(255, 255, 255, 0.22) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.22) 1px, transparent 1px),
    var(--water);
  background-size: 80px 80px;
  min-height: 0;
  overflow: hidden;
  position: relative;
}

#worldMap {
  display: block;
  height: 100%;
  width: 100%;
}

.country {
  cursor: pointer;
  stroke: rgba(255, 252, 244, 0.82);
  stroke-width: 0.65;
  transition: fill 160ms ease, opacity 160ms ease, stroke-width 160ms ease;
}

.country:hover,
.country.active {
  opacity: 1;
  stroke: #17221f;
  stroke-width: 1.3;
}

.country.dimmed {
  opacity: 0.28;
}

.legend,
.loading-state,
.toast {
  background: rgba(255, 252, 244, 0.9);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  position: absolute;
}

.legend {
  bottom: 20px;
  display: grid;
  gap: 9px;
  font-size: 13px;
  left: 20px;
  padding: 12px;
}

.legend div {
  align-items: center;
  display: flex;
  gap: 8px;
}

.swatch {
  border: 1px solid rgba(24, 33, 31, 0.16);
  border-radius: 3px;
  display: inline-block;
  height: 14px;
  width: 24px;
}

.good {
  background: var(--good);
}

.mixed {
  background: var(--mixed);
}

.risky {
  background: var(--risky);
}

.unknown {
  background: var(--unknown);
}

.loading-state {
  left: 50%;
  padding: 12px 16px;
  top: 50%;
  transform: translate(-50%, -50%);
  z-index: 3;
}

.hidden {
  display: none !important;
}

.insights {
  background: #fffaf0;
  border-left: 1px solid var(--line);
  display: grid;
  gap: 24px;
  overflow: auto;
  padding: 22px;
}

.section-heading {
  align-items: baseline;
  display: flex;
  justify-content: space-between;
  margin-bottom: 12px;
}

.section-heading h2,
.method h2,
.compare-head h2 {
  font-size: 16px;
}

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

.rank-list {
  display: grid;
  gap: 8px;
}

.rank-row {
  align-items: center;
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 8px;
  cursor: pointer;
  display: grid;
  gap: 8px;
  grid-template-columns: 1fr auto;
  padding: 10px;
}

.rank-row strong {
  display: block;
  font-size: 14px;
}

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

.score-pill {
  align-items: center;
  border-radius: 999px;
  color: #fff;
  display: inline-flex;
  font-weight: 800;
  height: 34px;
  justify-content: center;
  min-width: 42px;
  padding: 0 10px;
}

.method {
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
  padding-top: 18px;
}

.details-panel {
  background: var(--panel);
  border-left: 1px solid var(--line);
  bottom: 0;
  box-shadow: var(--shadow);
  max-width: 430px;
  overflow: auto;
  padding: 22px;
  position: fixed;
  right: 0;
  top: 82px;
  transform: translateX(0);
  width: min(430px, 100vw);
  z-index: 30;
}

.close {
  position: absolute;
  right: 14px;
  top: 14px;
}

.empty-state {
  color: var(--muted);
  display: grid;
  min-height: 220px;
  place-items: center;
  text-align: center;
}

.details-title {
  padding-right: 48px;
}

.details-title h2 {
  font-size: 30px;
}

.details-meta {
  color: var(--muted);
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 7px;
}

.hero-score {
  align-items: center;
  display: flex;
  gap: 18px;
  margin: 22px 0;
}

.score-ring {
  align-items: center;
  border-radius: 50%;
  color: white;
  display: flex;
  flex: 0 0 auto;
  font-size: 34px;
  font-weight: 900;
  height: 96px;
  justify-content: center;
  width: 96px;
}

.summary {
  color: #38423f;
  line-height: 1.55;
}

.factor-list {
  display: grid;
  gap: 10px;
  margin-top: 20px;
}

.factor-row {
  display: grid;
  gap: 6px;
}

.factor-label {
  align-items: center;
  display: flex;
  font-size: 13px;
  justify-content: space-between;
}

.bar {
  background: rgba(24, 33, 31, 0.1);
  border-radius: 999px;
  height: 9px;
  overflow: hidden;
}

.bar span {
  display: block;
  height: 100%;
}

.sparkline {
  border: 1px solid var(--line);
  border-radius: 8px;
  height: 82px;
  margin-top: 18px;
  width: 100%;
}

.compare-panel {
  background: #fffdf7;
  border-top: 1px solid var(--line);
  bottom: 0;
  box-shadow: var(--shadow);
  left: 0;
  max-height: 48vh;
  overflow: auto;
  padding: 18px 24px;
  position: fixed;
  right: 0;
  z-index: 40;
}

.compare-head {
  align-items: start;
  display: flex;
  justify-content: space-between;
  margin-bottom: 12px;
}

.compare-selectors,
.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}

.compare-selectors label {
  display: grid;
  gap: 5px;
  min-width: 180px;
}

.compare-selectors span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
}

.chip {
  align-items: center;
  background: #eef4ec;
  border: 1px solid var(--line);
  border-radius: 999px;
  display: inline-flex;
  gap: 8px;
  padding: 7px 10px;
}

.chip button {
  background: transparent;
  border: 0;
  cursor: pointer;
  font-weight: 900;
}

.compare-table {
  display: grid;
  min-width: 680px;
}

.compare-row {
  border-bottom: 1px solid var(--line);
  display: grid;
  gap: 12px;
  grid-template-columns: 220px repeat(3, minmax(120px, 1fr));
  min-height: 42px;
  padding: 8px 0;
}

.compare-row strong {
  font-size: 13px;
}

.toast {
  bottom: 20px;
  left: 50%;
  padding: 10px 14px;
  transform: translateX(-50%);
  z-index: 60;
}

@media (max-width: 980px) {
  .topbar {
    align-items: stretch;
    flex-direction: column;
    gap: 12px;
    min-height: 150px;
  }

  .toolbar {
    align-items: stretch;
    display: grid;
    grid-template-columns: 1fr 1fr auto;
  }

  input {
    min-width: 0;
    width: 100%;
  }

  .layout {
    grid-template-columns: 1fr;
    padding-top: 150px;
  }

  .insights {
    display: none;
  }

  .details-panel {
    top: 150px;
  }
}

@media (max-width: 640px) {
  .topbar {
    padding: 12px;
  }

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

  .layout {
    padding-top: 250px;
  }

  .details-panel {
    top: 250px;
  }

  .legend {
    bottom: 12px;
    font-size: 12px;
    left: 12px;
  }

  .compare-row {
    grid-template-columns: 160px repeat(3, minmax(100px, 1fr));
  }
}
