:root {
  --page-background: #eef1f4;
  --card-background: #ffffff;
  --text: #17191c;
  --muted: #69717b;
  --soft-border: #d9dee4;
  --hover: #e8edf2;
  --nato: #2367c9;
  --eu: #299451;
  --cow: #f28c28;
  --multi: #7a4f8b;
  --ocean: #dbe8f0;
  --shadow: 0 18px 50px rgba(20, 29, 38, 0.12);
}

* { box-sizing: border-box; }
html, body { min-height: 100%; margin: 0; }
body {
  color: var(--text);
  background: var(--page-background);
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
button, input { font: inherit; }

.page-header { padding: 28px clamp(18px, 4vw, 56px) 20px; }
.page-header h1 { margin: 2px 0 6px; font-size: clamp(2rem, 5vw, 4rem); line-height: 1; }
.page-header p { max-width: 820px; margin: 0; color: var(--muted); }
.eyebrow {
  margin: 0 0 8px !important;
  color: var(--muted);
  font-size: .75rem;
  font-weight: 800;
  letter-spacing: .13em;
  text-transform: uppercase;
}

.layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(320px, 410px);
  gap: 20px;
  align-items: start;
  padding: 0 clamp(18px, 4vw, 56px) 40px;
}
.map-column { display: grid; gap: 16px; min-width: 0; }
.map-card, .selection-card, .country-panel {
  overflow: hidden;
  border: 1px solid var(--soft-border);
  border-radius: 18px;
  background: var(--card-background);
  box-shadow: var(--shadow);
}

.selection-card {
  display: grid;
  grid-template-columns: minmax(190px, .7fr) minmax(320px, 1.3fr);
  gap: 18px 28px;
  align-items: center;
  padding: 20px 22px;
}
.selection-card h2 { margin: 0; font-size: 1.25rem; }
.group-controls { display: flex; flex-wrap: wrap; gap: 10px; align-items: stretch; }
.group-toggle {
  display: flex;
  gap: 10px;
  align-items: center;
  min-width: 150px;
  padding: 10px 12px;
  border: 1px solid var(--soft-border);
  border-radius: 12px;
  cursor: pointer;
  transition: transform .15s ease, border-color .15s ease, background .15s ease;
}
.group-toggle:hover { transform: translateY(-1px); background: #f7f9fb; }
.group-toggle:has(input:checked) { border-color: #7c8792; background: #f1f5f8; }
.group-toggle input { width: 18px; height: 18px; margin: 0; }
.group-toggle span:last-child { display: grid; line-height: 1.15; }
.group-toggle small { margin-top: 3px; color: var(--muted); }
.toggle-swatch, .legend-swatch {
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 1px solid rgba(0,0,0,.45);
  border-radius: 3px;
  flex: 0 0 auto;
}
.group-toggle-nato .toggle-swatch, .legend-swatch.nato { background: var(--nato); }
.group-toggle-eu .toggle-swatch, .legend-swatch.eu { background: var(--eu); }
.group-toggle-cow .toggle-swatch, .legend-swatch.cow { background: var(--cow); }
.legend-swatch.multi { background: var(--multi); }
.secondary-button {
  padding: 10px 14px;
  border: 1px solid var(--soft-border);
  border-radius: 12px;
  background: #fff;
  cursor: pointer;
}
.secondary-button:hover { background: var(--hover); }
.legend {
  grid-column: 1 / -1;
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  padding-top: 13px;
  border-top: 1px solid var(--soft-border);
  color: var(--muted);
  font-size: .82rem;
}
.legend span { display: inline-flex; gap: 7px; align-items: center; }

.map-card { position: relative; min-height: 1600px; background: #f7fafc; }
#map { width: 100%; height: 1600px; background: #f7fafc; }
.loading-message {
  position: absolute;
  z-index: 10;
  top: 18px;
  left: 50%;
  transform: translateX(-50%);
  padding: 10px 15px;
  border: 1px solid var(--soft-border);
  border-radius: 999px;
  background: rgba(255,255,255,.94);
  box-shadow: 0 8px 30px rgba(0,0,0,.12);
  font-size: .9rem;
}
.globe-hint {
  position: absolute;
  z-index: 5;
  left: 14px;
  bottom: 12px;
  padding: 7px 10px;
  border-radius: 8px;
  background: rgba(255,255,255,.86);
  color: var(--muted);
  font-size: .75rem;
  pointer-events: none;
}

.country-panel { position: sticky; top: 16px; min-height: 650px; }
.group-summary { padding: 26px 28px; border-bottom: 1px solid var(--soft-border); background: #f7f9fb; }
.group-summary h2 { margin: 0 0 6px; font-size: 1.7rem; }
.country-details { position: relative; padding: 30px; }
.close-button {
  position: absolute;
  top: 14px;
  right: 16px;
  width: 38px;
  height: 38px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 1.8rem;
  line-height: 1;
}
.close-button:hover, .close-button:focus-visible { background: var(--hover); color: var(--text); }
.panel-placeholder { display: grid; min-height: 300px; place-content: center; text-align: center; }
.panel-placeholder h2 { margin: 12px 0 6px; }
.panel-placeholder p, .data-status, .source-note { color: var(--muted); }
.globe-icon { font-size: 4rem; }
.panel-content h2 { margin: 4px 0 6px; padding-right: 32px; font-size: clamp(2rem, 4vw, 3rem); line-height: 1.05; }
.membership { min-height: 1.2em; margin: 0 0 7px; color: var(--muted); font-weight: 700; }
.data-status { min-height: 1.4em; margin: 0 0 20px; font-size: .9rem; line-height: 1.4; }
.statistics { display: grid; gap: 10px; margin: 0; }
.compact-statistics { grid-template-columns: 1fr 1fr; }
.wide-stat { grid-column: 1 / -1; }
.statistic { padding: 15px; border: 1px solid var(--soft-border); border-radius: 13px; background: #fff; }
.statistic dt { margin-bottom: 6px; color: var(--muted); font-size: .76rem; font-weight: 750; letter-spacing: .05em; text-transform: uppercase; }
.statistic dd { margin: 0; font-size: 1.2rem; font-weight: 800; overflow-wrap: anywhere; }
.source-note { margin-top: 24px; padding-top: 16px; border-top: 1px solid var(--soft-border); font-size: .8rem; line-height: 1.5; }
.summary-note { margin-bottom: 0; }

.maplibregl-canvas { cursor: grab; }
.maplibregl-canvas:active { cursor: grabbing; }
.maplibregl-popup-content {
  padding: 7px 10px;
  border-radius: 8px;
  font-family: inherit;
  font-weight: 700;
  box-shadow: 0 6px 22px rgba(0,0,0,.16);
}
.maplibregl-popup-tip { display: none; }
.maplibregl-ctrl-group { border-radius: 10px; overflow: hidden; }
.maplibregl-ctrl-attrib { font-size: 10px; }

@media (max-width: 1050px) {
  .selection-card { grid-template-columns: 1fr; }
  .legend { grid-column: auto; }
}
@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; }
  .country-panel { position: static; min-height: auto; }
  #map { height: 65vh; min-height: 470px; }
  .map-card { min-height: auto; }
}
@media (max-width: 520px) {
  .selection-card { padding: 18px; }
  .group-controls { display: grid; }
  .group-toggle, .secondary-button { width: 100%; }
  .compact-statistics { grid-template-columns: 1fr; }
  .wide-stat { grid-column: auto; }
  .country-details, .group-summary { padding: 24px 20px; }
}
