:root {
  --bg: #f7f8fa;
  --panel: #ffffff;
  --border: #dde4ea;
  --text: #1f2937;
  --muted: #64748b;
  --accent: #0ea5e9;
  --accent-soft: #e0f2fe;
  --card: #ffffff;
}

body {
  font-family: 'Inter', sans-serif;
  background: var(--bg);
  color: var(--text);
  margin: 0;
  padding: 0;
  padding-top: 80px;
  line-height: 1.6;
}

/* ================= Modern Navbar ================= */
.navbar {
  background: #ffffff;
  border-bottom: 1px solid var(--border);
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 1000;
  box-shadow: 0 4px 12px rgba(15, 23, 42, 0.08);
  height: 80px;
}

.nav-container {
  display: flex;
  justify-content: space-between;
  align-items: center;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 1rem 0 2rem;
  height: 100%;
}

.nav-left {
  display: flex;
  align-items: center;
}

.nav-right {
  display: flex;
  gap: 1rem;
  align-items: center;
}

.nav-brand {
  font-size: 1.8rem;
  font-weight: 800;
  letter-spacing: 0.8px;
  color: var(--text);
  margin: 0;
}

.nav-link {
  color: var(--text);
  text-decoration: none;
  font-weight: 500;
  font-size: 0.95rem;
  padding: 0.65rem 1rem;
  border-radius: 10px;
  transition: all 0.2s ease;
  cursor: pointer;
  position: relative;
  overflow: hidden;
}

.nav-link:hover {
  color: #ffffff;
  background: var(--accent);
  transform: translateY(-1px);
  box-shadow: 0 5px 12px rgba(14, 165, 233, 0.2);
}

.nav-link:active {
  transform: translateY(0);
  box-shadow: none;
}

@media (max-width: 768px) {
  .nav-container {
    padding: 0 0.5rem 0 1rem;
  }

  .nav-right {
    gap: 1rem;
  }

  .nav-link {
    font-size: 0.85rem;
    padding: 0.5rem 1rem;
  }

  .nav-brand {
    font-size: 1.5rem;
  }
}

/* ================= Main Container ================= */
.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 2rem;
}

/* ================= Section Classes ================= */
.stats-section,
.advisory-section {
  margin-bottom: 3rem;
}

.map-section {
  margin-bottom: 2rem;
}
.section-title {
  color: var(--text);
  font-size: 2rem;
  font-weight: 700;
  text-align: center;
  margin-bottom: 1.6rem;
  position: relative;
}

.section-title::after {
  content: '';
  position: absolute;
  bottom: -10px;
  left: 50%;
  transform: translateX(-50%);
  width: 60px;
  height: 3px;
  background: var(--accent);
  border-radius: 2px;
}

.map-section h3 {
  color: var(--text);
  font-size: 1.3rem;
  font-weight: 700;
  margin: 0;
  margin-right: 1rem;
}

.map-section h3::after {
  content: '';
  position: absolute;
  bottom: -10px;
  left: 0;
  width: 60px;
  height: 3px;
  background: linear-gradient(90deg, #00d8ff, #0099cc);
  border-radius: 2px;
}

/* ================= Stats Section ================= */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem;
  margin: 2rem 0;
}

.stat-card {
  background: var(--card);
  padding: 1.4rem;
  border-radius: 12px;
  text-align: center;
  box-shadow: 0 6px 16px rgba(15, 23, 42, 0.08);
  border: 1px solid var(--border);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.stat-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 12px 24px rgba(15, 23, 42, 0.12);
}

.stat-card .stat-icon {
  font-size: 2.5rem;
  margin-bottom: 0.8rem;
  color: var(--accent);
}

.stat-label {
  font-size: 0.84rem;
  color: var(--muted);
  margin-bottom: 0.5rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.stat-value {
  font-size: 1.9rem;
  font-weight: 800;
  color: var(--text);
}

/* ================= Advisory Card ================= */
.advisory-card {
  background: var(--card);
  padding: 1.8rem;
  border-radius: 12px;
  margin: 2rem 0;
  text-align: center;
  border: 1px solid var(--border);
  box-shadow: 0 6px 16px rgba(15, 23, 42, 0.08);
}

.advisory-card h3 {
  color: var(--text);
  font-size: 1.4rem;
  font-weight: 700;
  margin-bottom: 0.8rem;
}

.advisory-card p {
  color: var(--muted);
  font-size: 1rem;
  line-height: 1.6;
  margin: 0;
}

/* ================= Last Readings Section ================= */
.last-readings {
  margin: 3rem 0;
}

.last-readings h3 {
  color: var(--text);
  font-size: 1.4rem;
  font-weight: 700;
  margin-bottom: 1.3rem;
  text-align: center;
  position: relative;
}

.last-readings h3::after {
  content: '';
  position: absolute;
  bottom: -8px;
  left: 50%;
  transform: translateX(-50%);
  width: 45px;
  height: 3px;
  background: var(--accent);
  border-radius: 2px;
}

.readings-list {
  display: flex;
  overflow-x: auto;
  gap: 1rem;
  padding: 0.8rem 0;
}

.reading-card {
  min-width: 180px;
  padding: 1rem;
  border-radius: 10px;
  text-align: center;
  flex-shrink: 0;
  background: var(--card);
  box-shadow: 0 6px 18px rgba(15, 23, 42, 0.06);
  border: 1px solid var(--border);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.reading-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 24px rgba(15, 23, 42, 0.12);
}

.reading-card p {
  margin: 0.35rem 0;
  font-size: 0.9rem;
  color: var(--muted);
}

.reading-card .value {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text);
}

/* ================= Legend ================= */
.readings-legend {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 1rem;
  margin-top: 1.5rem;
  padding: 1rem;
  background: var(--card);
  border-radius: 10px;
  border: 1px solid var(--border);
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.legend-color {
  width: 16px;
  height: 16px;
  border-radius: 4px;
}

.legend-label {
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 500;
}

/* ================= Map Controls ================= */
.map-controls {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin: 2rem 0 2.5rem 0;
  padding: 1.2rem;
  background: var(--card);
  border-radius: 10px;
  border: 1px solid var(--border);
  box-shadow: 0 6px 16px rgba(15, 23, 42, 0.08);
}

.map-controls h3 {
  color: var(--text);
  font-size: 1.2rem;
  font-weight: 700;
  margin: 0;
}

.control-group {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.form-select {
  background: #ffffff !important;
  color: var(--text) !important;
  border: 1px solid var(--border) !important;
  border-radius: 8px !important;
  padding: 0.6rem 0.85rem !important;
  font-weight: 500 !important;
  min-width: 150px;
}

.form-select option {
  background: #ffffff;
  color: var(--text);
}

.form-select:focus {
  border-color: var(--accent) !important;
  box-shadow: 0 0 0 0.15rem rgba(14, 165, 233, 0.2) !important;
}

.btn-primary {
  background: var(--accent) !important;
  border: none !important;
  border-radius: 8px !important;
  font-weight: 600 !important;
  padding: 0.6rem 1.15rem !important;
  box-shadow: 0 4px 10px rgba(14, 165, 233, 0.2) !important;
  color: #ffffff !important;
}

.btn-primary:hover {
  box-shadow: 0 6px 14px rgba(14, 165, 233, 0.25) !important;
  opacity: 0.95 !important;
}

.btn-primary:active {
  transform: scale(0.99);
  box-shadow: 0 4px 10px rgba(14, 165, 233, 0.2) !important;
}

/* ================= Map */
/* ================= Map ================= */
#map-container {
  height: 500px;
  border-radius: 14px;
  box-shadow: 0 8px 22px rgba(15, 23, 42, 0.12);
  border: 1px solid var(--border);
  overflow: hidden;
  margin-top: 1rem;
}

/* ================= Global Animations ================= */
@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(30px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes pulse {
  0%, 100% {
    opacity: 1;
  }
  50% {
    opacity: 0.7;
  }
}

.stat-card, .advisory-card, .reading-card, .map-controls {
  animation: fadeInUp 0.6s ease-out;
}

.stat-card:nth-child(1) { animation-delay: 0.1s; }
.stat-card:nth-child(2) { animation-delay: 0.2s; }
.stat-card:nth-child(3) { animation-delay: 0.3s; }
.stat-card:nth-child(4) { animation-delay: 0.4s; }

.advisory-card {
  animation-delay: 0.5s;
}

.last-readings {
  animation-delay: 0.6s;
}

.map-controls {
  animation-delay: 0.7s;
}

/* ================= Loading States ================= */
.stat-value:empty::after,
#healthAdvice:empty::after {
  content: '';
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 2px solid rgba(0, 216, 255, 0.3);
  border-radius: 50%;
  border-top-color: #00d8ff;
  animation: pulse 1s ease-in-out infinite;
  margin-left: 8px;
}

/* ================= Enhanced Focus States ================= */
.nav-link:focus,
.form-select:focus,
.btn-primary:focus {
  outline: none;
  box-shadow: 0 0 0 3px rgba(0, 216, 255, 0.3);
}

body {
  scroll-behavior: smooth;
}

/* ================= Responsive Design ================= */
@media (max-width: 768px) {
  .container {
    padding: 1rem;
  }

  .section-title {
    font-size: 2rem;
    margin-bottom: 2rem;
  }

  .stats-grid {
    grid-template-columns: 1fr;
    gap: 1.5rem;
    margin: 2rem 0;
  }

  .stat-card {
    padding: 1.5rem;
  }

  .stat-card .stat-icon {
    font-size: 2.5rem;
  }

  .stat-value {
    font-size: 2rem;
  }

  .advisory-card {
    padding: 2rem;
  }

  .map-controls {
    flex-direction: column;
    gap: 1.5rem;
    text-align: center;
  }

  .control-group {
    flex-direction: column;
    gap: 1rem;
    width: 100%;
  }

  .form-select {
    width: 100%;
    min-width: unset;
  }

  .btn-primary {
    width: 100%;
  }

  .readings-list {
    gap: 1rem;
  }

  .reading-card {
    min-width: 160px;
    padding: 1rem;
  }

  .readings-legend {
    gap: 1rem;
  }
}

@media (max-width: 480px) {
  .nav-container {
    padding: 0 0.25rem 0 0.5rem;
  }

  .nav-brand {
    font-size: 1.25rem;
  }

  .nav-right {
    gap: 0.5rem;
  }

  .nav-link {
    padding: 0.5rem 0.75rem;
    font-size: 0.8rem;
  }

  .stat-card {
    padding: 1rem;
  }

  .stat-value {
    font-size: 1.75rem;
  }

  .reading-card {
    min-width: 140px;
    padding: 0.75rem;
  }
}

/* ================= Chart Containers ================= */
.chart-container {
  background: var(--card);
  padding: 1.5rem;
  border-radius: 12px;
  margin-bottom: 2rem;
  box-shadow: 0 6px 16px rgba(15, 23, 42, 0.08);
  border: 1px solid var(--border);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.chart-container:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(15, 23, 42, 0.12);
}

.chart-container h3 {
  color: var(--text);
  font-size: 1.2rem;
  font-weight: 600;
  margin-bottom: 1rem;
  text-align: center;
}

.chart-container canvas {
  background: #ffffff;
  border-radius: 8px;
  max-height: 300px;
}
