/* === Reset & Base === */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --bg: #0f1117;
  --bg-secondary: #1a1d27;
  --bg-tertiary: #232733;
  --border: #2e3345;
  --text: #e4e6ed;
  --text-muted: #8b8fa3;
  --text-dim: #5c6078;
  --accent: #00BEFF;
  --impact: #00BEFF;
  --climate: #00B050;
  --returns: #FFC000;
  --danger: #F8696B;
  --success: #63BE7B;
  --warning: #FFEB84;
  --radius: 6px;
  --radius-lg: 10px;
  --shadow: 0 2px 8px rgba(0,0,0,0.3);
  --header-height: 56px;
  --filter-height: 64px;
}

html, body {
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Inter', Roboto, sans-serif;
  font-size: 13px;
  background: var(--bg);
  color: var(--text);
  overflow: hidden;
}

/* === Header === */
.header {
  height: var(--header-height);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.header-left {
  display: flex;
  align-items: baseline;
  gap: 14px;
}

.header-title {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.3px;
  color: var(--text);
}

.header-subtitle {
  font-size: 12px;
  color: var(--text-muted);
}

.header-right {
  display: flex;
  align-items: center;
  gap: 16px;
}

/* === Toggle Switch === */
.toggle-label {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  user-select: none;
}

.toggle-label input {
  display: none;
}

.toggle-slider {
  width: 36px;
  height: 20px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: 10px;
  position: relative;
  transition: background 0.2s;
}

.toggle-slider::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 14px;
  height: 14px;
  background: var(--text-muted);
  border-radius: 50%;
  transition: transform 0.2s, background 0.2s;
}

.toggle-label input:checked + .toggle-slider {
  background: var(--accent);
  border-color: var(--accent);
}

.toggle-label input:checked + .toggle-slider::after {
  transform: translateX(16px);
  background: #fff;
}

.toggle-text {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 500;
}

/* === Buttons === */
.btn {
  padding: 6px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-tertiary);
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
}

.btn:hover {
  background: var(--border);
  color: var(--text);
}

.btn-reset {
  border-color: var(--text-dim);
}

/* === Filter Bar === */
.filter-bar {
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 10px 20px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  overflow: visible;
  position: relative;
  z-index: 50;
}

.filter-group {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.filter-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  white-space: nowrap;
}

.filter-buttons {
  display: flex;
  gap: 4px;
}

.filter-btn {
  padding: 5px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: transparent;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}

.filter-btn:hover {
  background: var(--bg-tertiary);
  color: var(--text);
}

.filter-btn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.cat-btn.active[data-category="Impact"] {
  background: var(--impact);
  border-color: var(--impact);
}

.cat-btn.active[data-category="Climate"] {
  background: var(--climate);
  border-color: var(--climate);
}

.cat-btn.active[data-category="Returns"] {
  background: var(--returns);
  border-color: var(--returns);
  color: #111;
}

.cat-btn.active[data-category="all"] {
  background: var(--accent);
  border-color: var(--accent);
}

/* === Dropdown === */
.dropdown {
  position: relative;
}

.dropdown-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: transparent;
  color: var(--text-muted);
  font-size: 12px;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s;
}

.dropdown-btn:hover {
  background: var(--bg-tertiary);
  color: var(--text);
}

.dropdown-menu {
  display: none;
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  min-width: 220px;
  max-height: 400px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  z-index: 100;
  overflow: hidden;
}

.dropdown-menu.open {
  display: flex;
  flex-direction: column;
}

.dropdown-menu-wide {
  min-width: 320px;
}

.dropdown-actions {
  display: flex;
  gap: 8px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
}

.dropdown-action {
  padding: 3px 10px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: transparent;
  color: var(--text-muted);
  font-size: 11px;
  cursor: pointer;
  transition: all 0.15s;
}

.dropdown-action:hover {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.dropdown-list {
  overflow-y: auto;
  max-height: 340px;
  padding: 4px 0;
}

.dropdown-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  cursor: pointer;
  transition: background 0.1s;
  font-size: 12px;
}

.dropdown-item:hover {
  background: var(--bg-tertiary);
}

.dropdown-item input[type="checkbox"] {
  accent-color: var(--accent);
  width: 14px;
  height: 14px;
  cursor: pointer;
}

.dropdown-item label {
  cursor: pointer;
  flex: 1;
  color: var(--text);
}

.dropdown-item .item-tag {
  font-size: 10px;
  padding: 1px 6px;
  border-radius: 3px;
  color: #fff;
  font-weight: 600;
}

.dropdown-item .item-tag.ref {
  background: #6366f1;
}

.dropdown-group-header {
  padding: 8px 12px 4px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-dim);
  border-top: 1px solid var(--border);
}

.dropdown-group-header:first-child {
  border-top: none;
}

/* === Table === */
.table-wrapper {
  flex: 1;
  overflow: auto;
  position: relative;
  height: calc(100vh - var(--header-height) - var(--filter-height) - 22px);
}

.msd-table {
  border-collapse: separate;
  border-spacing: 0;
  width: max-content;
  min-width: 100%;
  font-size: 12px;
}

/* === Table Header === */
.msd-table thead {
  position: sticky;
  top: 0;
  z-index: 20;
}

/* Category header row */
.msd-table thead tr.cat-row th {
  padding: 6px 10px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  text-align: center;
  border-bottom: 1px solid var(--border);
  color: #fff;
}

.msd-table thead tr.cat-row th.cat-impact {
  background: var(--impact);
}

.msd-table thead tr.cat-row th.cat-climate {
  background: var(--climate);
}

.msd-table thead tr.cat-row th.cat-returns {
  background: var(--returns);
  color: #111;
}

.msd-table thead tr.cat-row th.cat-land {
  background: var(--bg-tertiary);
  color: var(--text-muted);
}

/* Indicator header row */
.msd-table thead tr.ind-row th {
  padding: 8px 6px;
  font-size: 11px;
  font-weight: 600;
  text-align: center;
  background: var(--bg-secondary);
  border-bottom: 2px solid var(--border);
  color: var(--text);
  cursor: pointer;
  white-space: nowrap;
  position: relative;
  transition: background 0.15s;
  max-width: 120px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.msd-table thead tr.ind-row th:hover {
  background: var(--bg-tertiary);
}

.msd-table thead tr.ind-row th .sort-arrow {
  font-size: 9px;
  margin-left: 3px;
  opacity: 0.4;
}

.msd-table thead tr.ind-row th.sorted .sort-arrow {
  opacity: 1;
  color: var(--accent);
}

.msd-table thead tr.ind-row th .th-name {
  display: block;
  font-size: 11px;
  font-weight: 600;
  line-height: 1.3;
  white-space: normal;
  word-break: break-word;
}

.msd-table thead tr.ind-row th .th-unit {
  display: block;
  font-size: 9px;
  font-weight: 400;
  color: var(--text-muted);
  margin-top: 2px;
}

.msd-table thead tr.ind-row th .th-year {
  display: block;
  font-size: 9px;
  font-weight: 400;
  color: var(--text-dim);
}

/* Sticky country column */
.msd-table thead th.sticky-col,
.msd-table tbody td.sticky-col {
  position: sticky;
  left: 0;
  z-index: 10;
  background: var(--bg);
}

.msd-table thead th.sticky-col {
  z-index: 30;
  background: var(--bg-secondary);
}

.msd-table thead tr.cat-row th.sticky-col {
  background: var(--bg-tertiary);
}

/* === Table Body === */
.msd-table tbody tr {
  transition: background 0.1s;
}

.msd-table tbody tr:hover {
  background: rgba(255,255,255,0.03);
}

.msd-table tbody tr:hover td.sticky-col {
  background: var(--bg-tertiary);
}

.msd-table tbody tr.ref-row {
  border-top: 2px solid var(--border);
}

.msd-table tbody tr.ref-row td.sticky-col .country-name {
  color: #6366f1;
  font-style: italic;
}

.msd-table tbody td {
  padding: 6px 8px;
  text-align: center;
  border-bottom: 1px solid rgba(46,51,69,0.5);
  white-space: nowrap;
  color: var(--text);
  transition: background 0.2s, color 0.2s;
}

.msd-table tbody td.sticky-col {
  text-align: left;
  font-weight: 600;
  padding-left: 14px;
  min-width: 140px;
  border-right: 2px solid var(--border);
}

.country-name {
  display: flex;
  align-items: center;
  gap: 6px;
}

.region-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

/* Region colors */
.region-dot[data-region="Afrika"] { background: #e879a0; }
.region-dot[data-region="Asien"] { background: #f59e0b; }
.region-dot[data-region="Europa"] { background: #6366f1; }
.region-dot[data-region="Lat. Amerika"] { background: #10b981; }
.region-dot[data-region="Nordamerika"] { background: #3b82f6; }

/* Trend arrows */
.trend-up { color: var(--success); }
.trend-down { color: var(--danger); }
.trend-neutral { color: var(--text-muted); }

/* Text ratings */
.esg-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.3px;
}

/* Null values */
.null-val {
  color: var(--text-dim);
  font-style: italic;
  font-size: 11px;
}

/* === Heatmap cell colors === */
.msd-table tbody td.heatmap-cell {
  font-weight: 500;
}

/* === Tooltip === */
.tooltip {
  display: none;
  position: fixed;
  padding: 10px 14px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 4px 16px rgba(0,0,0,0.4);
  font-size: 12px;
  max-width: 300px;
  z-index: 1000;
  pointer-events: none;
}

.tooltip.visible {
  display: block;
  pointer-events: auto;
}

.tooltip-title {
  font-weight: 700;
  margin-bottom: 4px;
  color: var(--text);
}

.tooltip-unit {
  font-size: 11px;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.tooltip-source {
  font-size: 10px;
  color: var(--text-dim);
  border-top: 1px solid var(--border);
  padding-top: 6px;
  margin-top: 6px;
}

.tooltip-explanation {
  font-size: 11px;
  color: var(--text-muted);
  line-height: 1.4;
}

/* === Scrollbar === */
.table-wrapper::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

.table-wrapper::-webkit-scrollbar-track {
  background: var(--bg);
}

.table-wrapper::-webkit-scrollbar-thumb {
  background: var(--bg-tertiary);
  border-radius: 4px;
}

.table-wrapper::-webkit-scrollbar-thumb:hover {
  background: var(--border);
}

.table-wrapper::-webkit-scrollbar-corner {
  background: var(--bg);
}

/* === Responsive === */
@media (max-width: 1200px) {
  .filter-bar {
    flex-wrap: wrap;
    gap: 12px;
  }

  .msd-table {
    font-size: 11px;
  }
}

/* === Layout === */
body {
  display: flex;
  flex-direction: column;
}

/* === No data message === */
.no-data {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
  font-size: 14px;
}

/* === View Tabs === */
.header-center {
  display: flex;
  align-items: center;
}

.view-tabs {
  display: flex;
  gap: 2px;
  background: var(--bg-tertiary);
  border-radius: var(--radius);
  padding: 2px;
}

.view-tab {
  padding: 6px 12px;
  border: none;
  border-radius: 4px;
  background: transparent;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
}

.view-tab:hover {
  color: var(--text);
}

.view-tab.active {
  background: var(--accent);
  color: #fff;
}

/* === View Containers === */
.view-container {
  display: none;
  flex: 1;
  overflow: hidden;
}

.view-container.active {
  display: flex;
  flex-direction: column;
  animation: viewFadeIn 0.25s ease forwards;
}

@keyframes viewFadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* === World Map View === */
.map-controls {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 20px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
}

.map-select {
  padding: 5px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-tertiary);
  color: var(--text);
  font-size: 12px;
  min-width: 250px;
  cursor: pointer;
}

.map-canvas {
  flex: 1;
  width: 100%;
}

/* === Compare View (Radar) === */
.compare-layout {
  display: flex;
  flex: 1;
  overflow: hidden;
}

.compare-sidebar {
  width: 220px;
  padding: 16px;
  background: var(--bg-secondary);
  border-right: 1px solid var(--border);
  overflow-y: auto;
}

.compare-title {
  font-size: 14px;
  font-weight: 700;
  margin-bottom: 4px;
}

.compare-hint {
  font-size: 11px;
  color: var(--text-dim);
  margin-bottom: 12px;
}

.compare-country-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.compare-country-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border-radius: 4px;
  cursor: pointer;
  transition: background 0.1s;
  font-size: 12px;
}

.compare-country-item:hover {
  background: var(--bg-tertiary);
}

.compare-country-item.selected {
  background: var(--bg-tertiary);
  font-weight: 600;
}

.compare-country-item .cc-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  border: 2px solid var(--border);
  flex-shrink: 0;
}

.compare-country-item.selected .cc-dot {
  border-color: transparent;
}

.compare-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.radar-canvas {
  width: 100%;
  max-width: 600px;
  height: 500px;
}

.compare-legend {
  display: flex;
  gap: 20px;
  margin-top: 12px;
  flex-wrap: wrap;
  justify-content: center;
}

.compare-legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 500;
}

.compare-legend-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
}

/* === Scoring View === */
.scoring-layout {
  display: flex;
  flex: 1;
  overflow: hidden;
}

.scoring-sidebar {
  width: 240px;
  padding: 20px;
  background: var(--bg-secondary);
  border-right: 1px solid var(--border);
}

.scoring-title {
  font-size: 14px;
  font-weight: 700;
  margin-bottom: 16px;
}

.scoring-slider-group {
  margin-bottom: 16px;
}

.scoring-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  margin-bottom: 6px;
  color: var(--text);
}

.scoring-cat-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

.scoring-slider {
  width: 100%;
  height: 4px;
  -webkit-appearance: none;
  appearance: none;
  background: var(--bg-tertiary);
  border-radius: 2px;
  outline: none;
  cursor: pointer;
}

.scoring-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
}

.slider-impact::-webkit-slider-thumb { background: var(--impact); }
.slider-climate::-webkit-slider-thumb { background: var(--climate); }
.slider-returns::-webkit-slider-thumb { background: var(--returns); }

.scoring-total {
  font-size: 12px;
  color: var(--text-muted);
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

.scoring-main {
  flex: 1;
  overflow: auto;
}

.scoring-table-wrapper {
  padding: 16px;
}

.scoring-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.scoring-table th {
  padding: 10px 12px;
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-dim);
  border-bottom: 2px solid var(--border);
}

.scoring-table td {
  padding: 8px 12px;
  border-bottom: 1px solid rgba(46,51,69,0.5);
}

.scoring-table tbody tr:hover {
  background: rgba(255,255,255,0.03);
}

.scoring-rank {
  width: 40px;
  text-align: center !important;
}

.scoring-rank-cell {
  text-align: center;
  font-weight: 700;
  color: var(--text-dim);
}

.scoring-country {
  width: 150px;
}

.scoring-country-cell {
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 6px;
}

.scoring-val {
  width: 70px;
  text-align: center !important;
}

.scoring-val-cell {
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.scoring-bar-header {
  width: 300px;
}

.scoring-bar-cell {
  padding-right: 20px;
}

.scoring-bar {
  display: flex;
  height: 22px;
  border-radius: 3px;
  overflow: hidden;
  background: var(--bg-tertiary);
}

.scoring-bar-segment {
  height: 100%;
  transition: width 0.3s ease;
}

.scoring-bar-segment.impact { background: var(--impact); }
.scoring-bar-segment.climate { background: var(--climate); }
.scoring-bar-segment.returns { background: var(--returns); opacity: 0.9; }

.scoring-composite {
  font-weight: 700;
  font-size: 14px;
}

.ref-label {
  font-size: 9px;
  padding: 1px 4px;
  border-radius: 3px;
  background: #6366f1;
  color: #fff;
  margin-left: 4px;
}

/* === Country Flags === */
.country-flag {
  font-size: 14px;
  line-height: 1;
}

/* === Source Links in Tooltip === */
.source-link {
  color: var(--accent);
  text-decoration: none;
  border-bottom: 1px dotted var(--accent);
}

.source-link:hover {
  color: #fff;
  border-bottom-color: #fff;
}

/* === Language Toggle === */
.lang-toggle {
  display: flex;
  gap: 2px;
  background: var(--bg-tertiary);
  border-radius: 4px;
  padding: 2px;
}

.lang-btn {
  padding: 4px 8px;
  border: none;
  border-radius: 3px;
  background: transparent;
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
}

.lang-btn.active {
  background: var(--accent);
  color: #fff;
}

/* === Traffic Light View === */
.traffic-layout {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
}

.traffic-header {
  margin-bottom: 20px;
}

.traffic-title {
  font-size: 16px;
  font-weight: 700;
  margin-right: 12px;
}

.traffic-subtitle {
  font-size: 12px;
  color: var(--text-muted);
}

.traffic-grid {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.traffic-card {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 10px 16px;
  background: var(--bg-secondary);
  border-radius: var(--radius);
  transition: background 0.15s;
}

.traffic-card:hover {
  background: var(--bg-tertiary);
}

.traffic-rank {
  width: 30px;
  font-weight: 700;
  color: var(--text-dim);
  text-align: center;
  font-size: 13px;
}

.traffic-country {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 180px;
  font-weight: 600;
  font-size: 13px;
}

.traffic-lights {
  display: flex;
  gap: 24px;
  flex: 1;
  justify-content: center;
}

.traffic-light-group {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.tl-dot {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 2px solid rgba(255,255,255,0.1);
}

.tl-red { background: #ef4444; box-shadow: 0 0 8px rgba(239,68,68,0.4); }
.tl-yellow { background: #f59e0b; box-shadow: 0 0 8px rgba(245,158,11,0.3); }
.tl-green { background: #22c55e; box-shadow: 0 0 8px rgba(34,197,94,0.3); }
.tl-gray { background: var(--bg-tertiary); }

.tl-label {
  font-size: 9px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.traffic-score {
  width: 60px;
  text-align: right;
  font-weight: 700;
  font-size: 14px;
  font-variant-numeric: tabular-nums;
}

/* === Cluster View === */
.cluster-layout {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
}

.cluster-header {
  margin-bottom: 20px;
}

.cluster-title {
  font-size: 16px;
  font-weight: 700;
  margin-right: 12px;
}

.cluster-subtitle {
  font-size: 12px;
  color: var(--text-muted);
}

.cluster-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 16px;
}

.cluster-card {
  background: var(--bg-secondary);
  border-radius: var(--radius-lg);
  padding: 16px 20px;
}

.cluster-card-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
}

.cluster-icon {
  font-size: 18px;
}

.cluster-label {
  font-size: 14px;
  font-weight: 700;
  flex: 1;
}

.cluster-count {
  font-size: 11px;
  color: var(--text-muted);
  background: var(--bg-tertiary);
  padding: 2px 8px;
  border-radius: 10px;
}

.cluster-centroid {
  display: flex;
  gap: 8px;
  margin-bottom: 14px;
}

.cluster-pill {
  font-size: 10px;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 4px;
  color: #fff;
}

.cluster-members {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.cluster-member {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  padding: 4px 8px;
  background: var(--bg-tertiary);
  border-radius: 4px;
}

/* === Skip to Content (Accessibility) === */
.skip-to-content {
  position: absolute;
  top: -100px;
  left: 16px;
  padding: 8px 16px;
  background: var(--accent);
  color: #fff;
  border-radius: var(--radius);
  z-index: 10000;
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
  transition: top 0.2s;
}

.skip-to-content:focus {
  top: 8px;
}

/* === Focus Indicators === */
*:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.view-tab:focus-visible,
.filter-btn:focus-visible,
.lang-btn:focus-visible,
.btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  box-shadow: 0 0 0 4px rgba(0, 190, 255, 0.2);
}

:focus:not(:focus-visible) {
  outline: none;
}

/* === Export Button === */
.btn-export {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

/* === Country Detail View === */
.detail-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 1100;
  background: var(--bg);
  overflow-y: auto;
  animation: viewFadeIn 250ms ease-out;
}
.detail-overlay.open { display: block; }

.detail-content {
  max-width: 1200px;
  margin: 0 auto;
  padding: 24px 32px 48px;
}

/* Hero */
.detail-hero {
  margin-bottom: 24px;
}

.detail-back-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: none;
  border: 1px solid var(--border);
  color: var(--text-muted);
  padding: 6px 14px;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 13px;
  margin-bottom: 16px;
  transition: all 0.15s;
}
.detail-back-btn:hover {
  color: var(--text);
  border-color: var(--text-muted);
  background: var(--bg-tertiary);
}

.detail-hero-main {
  display: flex;
  align-items: center;
  gap: 16px;
}

.detail-flag {
  font-size: 48px;
  line-height: 1;
}

.detail-country-name {
  font-size: 28px;
  font-weight: 700;
  color: var(--text);
  margin: 0;
  line-height: 1.2;
}

.detail-ref-tag {
  font-size: 11px;
  padding: 2px 6px;
  border-radius: 3px;
  background: #6366f1;
  color: #fff;
  vertical-align: middle;
  margin-left: 8px;
  font-weight: 600;
}

.detail-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--text-muted);
  font-size: 14px;
  margin-top: 4px;
}

/* Score Cards */
.detail-scores {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 28px;
}

.detail-score-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px;
  text-align: center;
}

.detail-score-label {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 6px;
}

.detail-score-value {
  font-size: 32px;
  font-weight: 700;
  line-height: 1.1;
  margin-bottom: 8px;
}

.detail-score-bar {
  height: 6px;
  background: var(--bg-tertiary);
  border-radius: 3px;
  overflow: hidden;
  margin-bottom: 8px;
}

.detail-score-bar-fill {
  height: 100%;
  border-radius: 3px;
  transition: width 0.4s ease;
}

.detail-score-rank {
  font-size: 11px;
  color: var(--text-muted);
}

/* Body: Radar + Indicators */
.detail-body {
  display: flex;
  gap: 28px;
  align-items: flex-start;
}

.detail-radar-sidebar {
  flex: 0 0 320px;
  position: sticky;
  top: 24px;
}

.detail-radar-canvas {
  width: 320px;
  height: 320px;
  display: block;
}

.detail-indicators {
  flex: 1;
  min-width: 0;
}

/* Pillar Headers */
.detail-pillar-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 0 8px;
  margin-top: 16px;
  margin-bottom: 8px;
  border-bottom: 2px solid;
  font-size: 15px;
  font-weight: 700;
}
.detail-pillar-header:first-child { margin-top: 0; }

.detail-pillar-count {
  font-size: 12px;
  font-weight: 400;
  color: var(--text-muted);
}

/* Indicator Cards */
.detail-indicator-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
  margin-bottom: 6px;
}

.detail-ind-top {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  margin-bottom: 6px;
}

.detail-ind-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  flex: 1;
  min-width: 0;
}

.detail-ind-value {
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
  white-space: nowrap;
}

/* Percentile Bar */
.detail-pct-bar {
  height: 4px;
  background: var(--bg-tertiary);
  border-radius: 2px;
  overflow: hidden;
  margin-bottom: 6px;
}

.detail-pct-bar-fill {
  height: 100%;
  border-radius: 2px;
  transition: width 0.3s ease;
  opacity: 0.7;
}

.detail-ind-bottom {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

.detail-ind-meta {
  font-size: 11px;
  color: var(--text-dim);
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.detail-ind-rank {
  font-size: 11px;
  color: var(--text-muted);
  white-space: nowrap;
  font-weight: 500;
}

.detail-source-link {
  color: var(--accent);
  text-decoration: none;
  font-size: 11px;
}
.detail-source-link:hover { text-decoration: underline; }

.detail-source-text {
  color: var(--text-dim);
  font-size: 11px;
}

/* === Print / PDF Export === */
@media print {
  body {
    overflow: visible !important;
    background: #fff !important;
    color: #111 !important;
    height: auto !important;
  }

  .header {
    background: #fff !important;
    border-bottom: 2px solid #333 !important;
    height: auto !important;
  }

  .header-title { color: #111 !important; }
  .header-subtitle { color: #555 !important; }

  .filter-bar,
  .header-right,
  .lang-toggle,
  .toggle-label,
  .btn-reset,
  .btn-export,
  .compare-sidebar,
  .scoring-sidebar,
  .map-controls,
  .tooltip,
  .skip-to-content,
  .detail-overlay { display: none !important; }

  .view-container { display: none !important; }
  .view-container.active {
    display: block !important;
    overflow: visible !important;
    height: auto !important;
    animation: none !important;
  }

  .table-wrapper {
    overflow: visible !important;
    height: auto !important;
  }

  .msd-table { font-size: 9px !important; }

  .msd-table thead th.sticky-col,
  .msd-table tbody td.sticky-col {
    position: static !important;
  }

  .map-canvas,
  .radar-canvas {
    max-width: 100% !important;
    height: 500px !important;
  }

  .scoring-table,
  .traffic-card,
  .cluster-card {
    background: #fff !important;
    color: #111 !important;
    border-color: #ccc !important;
  }

  .scoring-layout,
  .compare-layout {
    display: block !important;
  }

  @page {
    margin: 1cm;
    size: A4 landscape;
  }
}

/* === Responsive: Tablet (768px) === */
@media (max-width: 768px) {
  html, body {
    overflow: auto;
    overflow-x: hidden;
  }

  .header {
    flex-wrap: wrap;
    height: auto;
    padding: 10px 12px;
    gap: 8px;
  }

  .header-left {
    flex-basis: 100%;
    gap: 4px;
  }

  .view-tabs {
    flex-wrap: wrap;
    gap: 2px;
  }

  .view-tab {
    padding: 5px 8px;
    font-size: 11px;
  }

  .filter-bar {
    flex-wrap: wrap;
    gap: 8px;
    padding: 8px 12px;
    height: auto;
  }

  .filter-group {
    flex-wrap: wrap;
  }

  .compare-layout {
    flex-direction: column;
  }

  .compare-sidebar {
    width: 100%;
    border-right: none;
    border-bottom: 1px solid var(--border);
    max-height: 180px;
    overflow-y: auto;
  }

  .compare-country-list {
    flex-direction: row;
    flex-wrap: wrap;
  }

  .scoring-layout {
    flex-direction: column;
  }

  .scoring-sidebar {
    width: 100%;
    border-right: none;
    border-bottom: 1px solid var(--border);
    padding: 12px 16px;
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: center;
  }

  .scoring-title {
    width: 100%;
  }

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

  .table-wrapper {
    height: calc(100vh - 160px);
  }

  .traffic-card {
    gap: 8px;
    padding: 8px 12px;
  }

  /* Detail responsive (tablet) */
  .detail-content {
    padding: 16px;
  }

  .detail-scores {
    grid-template-columns: repeat(2, 1fr);
  }

  .detail-body {
    flex-direction: column;
  }

  .detail-radar-sidebar {
    flex: none;
    position: static;
    width: 100%;
    display: flex;
    justify-content: center;
  }

  .detail-radar-canvas {
    width: 280px;
    height: 280px;
  }

  .detail-flag { font-size: 36px; }
  .detail-country-name { font-size: 22px; }
}

/* === Responsive: Mobile (480px) === */
@media (max-width: 480px) {
  html, body {
    font-size: 12px;
  }

  .header-title {
    font-size: 14px;
  }

  .header-subtitle {
    font-size: 10px;
  }

  .header-center {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .view-tabs {
    flex-wrap: nowrap;
    overflow-x: auto;
    min-width: max-content;
  }

  .filter-bar {
    flex-direction: column;
    align-items: stretch;
    gap: 6px;
    padding: 8px;
    height: auto;
  }

  .filter-group {
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
  }

  .filter-buttons {
    flex-wrap: wrap;
  }

  .dropdown-menu {
    min-width: 85vw;
  }

  .map-controls {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
  }

  .map-select {
    min-width: auto;
    width: 100%;
  }

  .compare-sidebar {
    max-height: 140px;
    padding: 8px;
  }

  .radar-canvas {
    height: 280px;
  }

  .scoring-sidebar {
    padding: 8px;
  }

  .traffic-card {
    flex-wrap: wrap;
    gap: 6px;
    padding: 8px;
  }

  .traffic-country {
    min-width: 100%;
  }

  /* Detail responsive (mobile) */
  .detail-content { padding: 12px; }
  .detail-scores { grid-template-columns: 1fr 1fr; gap: 8px; }
  .detail-score-value { font-size: 24px; }
  .detail-score-card { padding: 10px; }
  .detail-flag { font-size: 32px; }
  .detail-country-name { font-size: 20px; }
  .detail-radar-canvas { width: 240px; height: 240px; }
  .detail-indicator-card { padding: 10px; }
}
