@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800;900&display=swap');

*,
*::before,
*::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --bg-primary: #0a0e1a;
  --bg-secondary: #111827;
  --bg-card: rgba(17, 24, 39, 0.7);
  --bg-card-hover: rgba(30, 41, 59, 0.8);
  --glass-border: rgba(255, 255, 255, 0.08);
  --glass-shadow: rgba(0, 0, 0, 0.3);

  --text-primary: #f1f5f9;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;

  --aqi-good: #22c55e;
  --aqi-moderate: #eab308;
  --aqi-unhealthy-sensitive: #f97316;
  --aqi-unhealthy: #ef4444;
  --aqi-very-unhealthy: #a855f7;
  --aqi-hazardous: #7f1d1d;

  --accent-blue: #3b82f6;
  --accent-cyan: #06b6d4;
  --accent-purple: #8b5cf6;
  --accent-emerald: #10b981;

  --gradient-primary: linear-gradient(135deg, #3b82f6, #8b5cf6);
  --gradient-danger: linear-gradient(135deg, #ef4444, #f97316);
  --gradient-success: linear-gradient(135deg, #10b981, #06b6d4);

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 24px;

  --transition-fast: 0.2s ease;
  --transition-med: 0.3s ease;

  --header-height: 64px;
  --tab-bar-height: 42px;
}

html,
body {
  height: 100%;
  overflow: hidden;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  display: flex;
  flex-direction: column;
}

/* ===== ANIMATED BACKGROUND ===== */
.bg-animation {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  pointer-events: none;
  overflow: hidden;
}

.bg-animation .orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(80px);
  opacity: 0.12;
  animation: float 20s ease-in-out infinite;
}

.bg-animation .orb:nth-child(1) {
  width: 600px;
  height: 600px;
  background: var(--accent-blue);
  top: -200px;
  left: -200px;
}

.bg-animation .orb:nth-child(2) {
  width: 500px;
  height: 500px;
  background: var(--accent-purple);
  top: 50%;
  right: -150px;
  animation-delay: -7s;
}

.bg-animation .orb:nth-child(3) {
  width: 400px;
  height: 400px;
  background: var(--accent-emerald);
  bottom: -100px;
  left: 30%;
  animation-delay: -14s;
}

@keyframes float {

  0%,
  100% {
    transform: translate(0, 0) scale(1);
  }

  25% {
    transform: translate(50px, -50px) scale(1.1);
  }

  50% {
    transform: translate(-30px, 30px) scale(0.95);
  }

  75% {
    transform: translate(40px, 20px) scale(1.05);
  }
}

/* ===== TOP HEADER BAR ===== */
.top-header {
  position: relative;
  z-index: 10;
  height: var(--header-height);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 28px;
  background: rgba(17, 24, 39, 0.85);
  backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--glass-border);
  flex-shrink: 0;
}

.top-header .brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.top-header .brand svg {
  flex-shrink: 0;
}

.top-header .brand h1 {
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: -0.5px;
  background: linear-gradient(135deg, #f1f5f9, #94a3b8);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.header-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 5px 14px;
  background: rgba(59, 130, 246, 0.12);
  border: 1px solid rgba(59, 130, 246, 0.25);
  border-radius: 100px;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--accent-blue);
  letter-spacing: 0.5px;
  text-transform: uppercase;
}

.header-badge .pulse-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--aqi-good);
  animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {

  0%,
  100% {
    opacity: 1;
    transform: scale(1);
  }

  50% {
    opacity: 0.4;
    transform: scale(0.7);
  }
}

/* ===== SHEET CONTENT ===== */
.sheet-content {
  position: relative;
  z-index: 1;
  flex: 1;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.sheet-page {
  display: none;
  flex: 1;
  overflow-y: auto;
  padding: 24px 28px;
  animation: fadeSheet 0.35s ease;
}

.sheet-page.active {
  display: flex;
  flex-direction: column;
}

@keyframes fadeSheet {
  from {
    opacity: 0;
    transform: translateY(8px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ===== BOTTOM TAB BAR ===== */
.tab-bar {
  position: relative;
  z-index: 10;
  height: var(--tab-bar-height);
  display: flex;
  align-items: stretch;
  background: rgba(17, 24, 39, 0.9);
  backdrop-filter: blur(20px);
  border-top: 1px solid var(--glass-border);
  flex-shrink: 0;
  overflow-x: auto;
  scrollbar-width: none;
}

.tab-bar::-webkit-scrollbar {
  display: none;
}

.tab-btn {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 0 20px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-family: inherit;
  font-size: 0.78rem;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  border-right: 1px solid var(--glass-border);
  transition: all var(--transition-fast);
  position: relative;
}

.tab-btn:hover {
  color: var(--text-secondary);
  background: rgba(255, 255, 255, 0.03);
}

.tab-btn.active {
  color: var(--text-primary);
  background: rgba(59, 130, 246, 0.1);
}

.tab-btn.active::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: var(--accent-blue);
}

.tab-btn svg {
  width: 15px;
  height: 15px;
  flex-shrink: 0;
}

/* ===== GLASS CARD ===== */
.glass-card {
  background: var(--bg-card);
  backdrop-filter: blur(20px);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  padding: 24px;
  transition: box-shadow var(--transition-med), border-color var(--transition-med);
}

.glass-card:hover {
  box-shadow: 0 8px 32px var(--glass-shadow);
  border-color: rgba(255, 255, 255, 0.12);
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

.card-header h2 {
  font-size: 1.1rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 10px;
}

.card-header h2 svg {
  width: 20px;
  height: 20px;
  opacity: 0.7;
}

.card-header .subtitle {
  font-size: 0.78rem;
  color: var(--text-muted);
}

/* ===== OVERVIEW STATS ===== */
.stats-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 20px;
}

.stat-card {
  background: var(--bg-card);
  backdrop-filter: blur(20px);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-md);
  padding: 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  transition: all var(--transition-med);
  position: relative;
  overflow: hidden;
}

.stat-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
}

.stat-card:nth-child(1)::before {
  background: var(--gradient-danger);
}

.stat-card:nth-child(2)::before {
  background: var(--gradient-primary);
}

.stat-card:nth-child(3)::before {
  background: var(--gradient-success);
}

.stat-card:nth-child(4)::before {
  background: linear-gradient(135deg, #f97316, #eab308);
}

.stat-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.3);
  border-color: rgba(255, 255, 255, 0.15);
}

.stat-icon-wrap {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.stat-card:nth-child(1) .stat-icon-wrap {
  background: rgba(239, 68, 68, 0.12);
}

.stat-card:nth-child(2) .stat-icon-wrap {
  background: rgba(59, 130, 246, 0.12);
}

.stat-card:nth-child(3) .stat-icon-wrap {
  background: rgba(16, 185, 129, 0.12);
}

.stat-card:nth-child(4) .stat-icon-wrap {
  background: rgba(249, 115, 22, 0.12);
}

.stat-icon-wrap svg {
  width: 22px;
  height: 22px;
}

.stat-info {
  flex: 1;
}

.stat-value {
  font-size: 1.6rem;
  font-weight: 800;
  letter-spacing: -0.5px;
  line-height: 1.2;
}

.stat-card:nth-child(1) .stat-value {
  color: #ef4444;
}

.stat-card:nth-child(2) .stat-value {
  color: var(--accent-blue);
}

.stat-card:nth-child(3) .stat-value {
  color: var(--accent-emerald);
}

.stat-card:nth-child(4) .stat-value {
  color: #f97316;
}

.stat-label {
  font-size: 0.72rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-weight: 500;
}

/* ===== OVERVIEW TWO-COL ===== */
.overview-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  flex: 1;
  min-height: 0;
}

/* ===== MAP ===== */
.map-container {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
  border-radius: var(--radius-md);
  background: rgba(10, 14, 26, 0.4);
}

.map-container svg {
  width: 100%;
  height: 100%;
  display: block;
}

.map-container svg path.country-shape {
  stroke: rgba(255, 255, 255, 0.15);
  stroke-width: 0.5;
  transition: all var(--transition-fast);
  cursor: pointer;
}

.map-container svg path.country-shape:hover {
  stroke: rgba(255, 255, 255, 0.5);
  stroke-width: 1;
  filter: brightness(1.3);
}

.map-tooltip {
  position: absolute;
  background: rgba(15, 23, 42, 0.95);
  backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  pointer-events: none;
  opacity: 0;
  transition: opacity var(--transition-fast);
  z-index: 100;
  min-width: 180px;
}

.map-tooltip.visible {
  opacity: 1;
}

.map-tooltip .tt-country {
  font-weight: 700;
  font-size: 0.92rem;
  margin-bottom: 6px;
}

.map-tooltip .tt-row {
  font-size: 0.82rem;
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 3px;
  color: var(--text-secondary);
}

.map-tooltip .tt-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  display: inline-block;
}

/* ===== AQI LEGEND ===== */
.aqi-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 12px;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 0.7rem;
  color: var(--text-secondary);
}

.legend-color {
  width: 12px;
  height: 12px;
  border-radius: 3px;
}

/* ===== CHART ===== */
.chart-wrapper {
  position: relative;
  width: 100%;
  flex: 1;
  min-height: 0;
}

.chart-wrapper canvas {
  width: 100% !important;
  height: 100% !important;
}

.chart-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

/* ===== POLLUTANT TABS ===== */
.pill-tabs {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.pill-btn {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 100px;
  padding: 6px 16px;
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition-fast);
  font-family: inherit;
}

.pill-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  color: var(--text-primary);
}

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

/* ===== TABLE ===== */
.table-controls {
  display: flex;
  align-items: center;
  gap: 12px;
}

.search-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 100px;
  padding: 6px 16px;
  width: 260px;
  transition: border-color var(--transition-fast);
}

.search-bar:focus-within {
  border-color: var(--accent-blue);
}

.search-bar svg {
  width: 14px;
  height: 14px;
  color: var(--text-muted);
  flex-shrink: 0;
}

.search-bar input {
  background: transparent;
  border: none;
  outline: none;
  color: var(--text-primary);
  font-size: 0.82rem;
  font-family: inherit;
  width: 100%;
}

.search-bar input::placeholder {
  color: var(--text-muted);
}

.table-scroll {
  flex: 1;
  overflow-y: auto;
  border-radius: var(--radius-md);
  min-height: 0;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

.data-table thead {
  position: sticky;
  top: 0;
  z-index: 5;
}

.data-table th {
  background: rgba(30, 41, 59, 0.95);
  padding: 12px 14px;
  text-align: left;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  font-size: 0.7rem;
  letter-spacing: 0.5px;
  cursor: pointer;
  white-space: nowrap;
  user-select: none;
  transition: color var(--transition-fast);
}

.data-table th:hover {
  color: var(--text-primary);
}

.data-table th .sort-arrow {
  margin-left: 4px;
  opacity: 0.3;
  font-size: 0.65rem;
}

.data-table th.sorted .sort-arrow {
  opacity: 1;
  color: var(--accent-blue);
}

.data-table td {
  padding: 10px 14px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
  white-space: nowrap;
}

.data-table tbody tr {
  transition: background var(--transition-fast);
}

.data-table tbody tr:hover {
  background: rgba(59, 130, 246, 0.06);
}

.aqi-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  border-radius: 100px;
  font-weight: 600;
  font-size: 0.8rem;
}

.aqi-badge .dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
}

.trend-up {
  color: #ef4444;
}

.trend-down {
  color: #22c55e;
}

.trend-stable {
  color: #eab308;
}

/* ===== HEALTH CARDS ===== */
.health-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  flex: 1;
  min-height: 0;
  align-content: start;
}

.health-card {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: var(--radius-md);
  padding: 28px 24px;
  text-align: center;
  transition: all var(--transition-med);
}

.health-card:hover {
  background: rgba(255, 255, 255, 0.06);
  transform: translateY(-2px);
}

.health-card .health-icon {
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.health-card .health-icon svg {
  width: 48px;
  height: 48px;
}

.health-card .health-stat {
  font-size: 2rem;
  font-weight: 800;
  margin-bottom: 6px;
  background: var(--gradient-danger);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.health-card .health-label {
  font-size: 0.85rem;
  color: var(--text-secondary);
  line-height: 1.5;
}

/* ===== ABOUT TEXT ===== */
.about-text {
  color: var(--text-secondary);
  font-size: 0.9rem;
  line-height: 1.8;
  max-width: 720px;
}

.about-text a {
  color: var(--accent-blue);
  text-decoration: none;
}

.about-text a:hover {
  text-decoration: underline;
}

/* ===== RESPONSIVE ===== */
@media (max-width: 1024px) {
  .overview-grid {
    grid-template-columns: 1fr;
  }

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

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

@media (max-width: 640px) {
  .sheet-page {
    padding: 16px;
  }

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

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

  .glass-card {
    padding: 16px;
  }

  .card-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
  }

  .top-header {
    padding: 0 16px;
  }

  .top-header .brand h1 {
    font-size: 0.95rem;
  }
}

/* ===== SCROLLBAR ===== */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.08);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.15);
}