:root {
  --bg-dark: #0f172a;
  --panel: #1e293b;
  --panel-elevated: #243249;
  --text-muted: #9ca3af;
  --text-light: #e2e8f0;
  --accent-blue: #3b82f6;
  --accent-green: #22c55e;
  --accent-red: #ef4444;
  --accent-orange: #f59e0b;
}

body {
  margin: 0;
  font-family: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg-dark);
  color: var(--text-light);
}

.dashboard-container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 2rem 1.5rem 4rem;
  display: flex;
  flex-direction: column;
  gap: 2rem;
}

.dashboard-header {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 1rem;
  align-items: center;
}

.dashboard-header h1 {
  margin: 0;
  font-size: 1.85rem;
}

.controls {
  display: flex;
  gap: 0.75rem;
  align-items: center;
}

.country-selector {
  background: var(--panel);
  color: var(--text-light);
  border: 1px solid rgba(148, 163, 184, 0.4);
  padding: 0.5rem 0.75rem;
  border-radius: 0.5rem;
  min-width: 140px;
}

.btn {
  border: none;
  border-radius: 999px;
  padding: 0.55rem 1.2rem;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.2s ease;
}

.btn-primary {
  background: var(--accent-blue);
  color: white;
}

.btn-secondary {
  background: rgba(148, 163, 184, 0.2);
  color: var(--text-light);
}

.btn:hover {
  opacity: 0.85;
}

.comparison-pagination {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--text-muted);
}

.comparison-pagination .btn {
  padding: 0.35rem 0.9rem;
  font-size: 0.85rem;
}

.comparison-pagination span {
  font-size: 0.85rem;
}

.subjective-card .pillar-card__score-label {
  text-transform: none;
}

.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.75rem;
}

.summary-section,
.pillars-section,
.indicators-section,
.subjective-section,
.comparison-section,
.trends-section,
.interpretation-section {
  background: var(--panel);
  border-radius: 1.25rem;
  padding: 1.5rem;
  box-shadow: 0 25px 45px rgba(15, 23, 42, 0.45);
}

.summary-section {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 1.5rem;
  align-items: center;
}

.score-display {
  display: flex;
  flex-direction: column;
  gap: 0.125rem;
  align-items: flex-start;
}

.score-display .score-value {
  font-size: 3.5rem;
  font-weight: 700;
}

.score-display .score-label {
  color: var(--text-muted);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-size: 0.8rem;
}

.radar-container {
  display: flex;
  justify-content: center;
}

.pillar-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 1rem;
}

.pillar-card {
  background: var(--panel-elevated);
  border-radius: 1rem;
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  cursor: pointer;
  transition: border 0.2s ease, transform 0.2s ease;
  border: 1px solid transparent;
}

.pillar-card:hover {
  border-color: rgba(59, 130, 246, 0.4);
  transform: translateY(-2px);
}

.pillar-card__header {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
  align-items: flex-start;
}

.pillar-card__title {
  margin: 0;
  font-size: 1.05rem;
}

.pillar-card__description {
  color: var(--text-muted);
  font-size: 0.9rem;
  margin: 0.25rem 0 0;
}

.pillar-card__score {
  font-size: 2rem;
  font-weight: 700;
  color: var(--accent-green);
  text-align: right;
}

.pillar-card__score-label {
  display: block;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.pillar-card__indicators {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.indicator-row {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  font-size: 0.9rem;
}

.indicator-name {
  color: var(--text-muted);
}

.indicator-value {
  font-weight: 600;
}

.indicator-group {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  margin-bottom: 0.75rem;
}

.indicator-group__title {
  font-size: 0.75rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.indicator-group--supplementary .indicator-group__title {
  color: var(--accent-orange);
}

.trend-positive {
  color: var(--accent-green);
}

.trend-negative {
  color: var(--accent-red);
}

.trend-neutral {
  color: var(--text-muted);
}

.pillar-card__footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.pillar-card__trend {
  font-weight: 600;
}

.indicator-tabs {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}

.tab-btn {
  border: 1px solid rgba(148, 163, 184, 0.3);
  border-radius: 999px;
  background: transparent;
  color: var(--text-light);
  padding: 0.45rem 1rem;
  cursor: pointer;
  transition: background 0.2s ease, border-color 0.2s ease;
}

.tab-btn.active {
  background: rgba(59, 130, 246, 0.2);
  border-color: rgba(59, 130, 246, 0.5);
}

.indicator-content {
  display: grid;
  gap: 0.75rem;
}

.indicator-detail {
  display: flex;
  justify-content: space-between;
  border-bottom: 1px solid rgba(148, 163, 184, 0.2);
  padding-bottom: 0.5rem;
}

.indicator-detail__name {
  font-weight: 600;
}

.indicator-detail__meta {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  font-size: 0.9rem;
}

.indicator-detail__value {
  font-weight: 600;
}

.indicator-detail__year {
  color: var(--text-muted);
}

.badge {
  border-radius: 999px;
  padding: 0.1rem 0.6rem;
  text-transform: capitalize;
  font-size: 0.75rem;
  border: 1px solid rgba(148, 163, 184, 0.3);
}

.badge.core {
  border-color: rgba(59, 130, 246, 0.6);
  color: var(--accent-blue);
}

.badge.supplementary {
  border-color: rgba(249, 115, 22, 0.6);
  color: var(--accent-orange);
}

.comparison-matrix {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.comparison-matrix thead th {
  text-align: left;
  padding: 0.75rem;
  color: var(--text-muted);
  font-weight: 500;
}

.comparison-matrix tbody td {
  padding: 0.6rem 0.75rem;
  border-top: 1px solid rgba(148, 163, 184, 0.15);
  vertical-align: middle;
}

.country-cell {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 600;
}

.score-cell {
  text-align: center;
}

.score-box {
  display: inline-flex;
  min-width: 56px;
  justify-content: center;
  padding: 0.35rem 0.5rem;
  border-radius: 0.75rem;
  font-weight: 600;
}

.score-na {
  color: var(--text-muted);
}

.sparkline {
  display: block;
  margin: 0.15rem auto 0;
}

.chart-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1rem;
}

.interpretation-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 1rem;
}

.interpretation-grid ul {
  list-style: none;
  padding: 0;
  margin: 0.5rem 0 0;
}

.interpretation-grid li {
  padding: 0.25rem 0;
  border-bottom: 1px solid rgba(148, 163, 184, 0.2);
}

.recommendation {
  background: rgba(15, 23, 42, 0.35);
  border-radius: 0.75rem;
  padding: 0.75rem;
  margin-bottom: 0.5rem;
}

.recommendation h4 {
  margin: 0 0 0.35rem;
}

.recommendation-empty {
  color: var(--text-muted);
  font-style: italic;
}

.loading-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.75);
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  align-items: center;
  justify-content: center;
  color: var(--text-light);
  z-index: 20;
}

.spinner {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: 4px solid rgba(59, 130, 246, 0.2);
  border-top-color: var(--accent-blue);
  animation: spin 1s linear infinite;
}

.error-banner {
  position: fixed;
  right: 1.5rem;
  bottom: 1.5rem;
  background: rgba(239, 68, 68, 0.95);
  color: white;
  padding: 0.75rem 1rem;
  border-radius: 0.75rem;
  display: flex;
  gap: 0.75rem;
  align-items: center;
  z-index: 25;
}

.error-banner button {
  background: transparent;
  border: none;
  color: inherit;
  font-size: 1rem;
  cursor: pointer;
}

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

@media (max-width: 768px) {
  .dashboard-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .controls {
    width: 100%;
    flex-wrap: wrap;
  }

  .controls select,
  .controls .btn {
    flex: 1 1 120px;
  }

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

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