:root{
  --card-radius: 1.25rem;
  --soft-border: #e2e8f0;
  --soft-bg: #ffffff;
  --muted: #64748b;
  --title: #0f172a;
  --expo-navy: #07166f;
  --expo-blue: #1234bd;
  --expo-orange: #ff5a00;
  --expo-cyan: #20d9ff;
  --expo-purple: #8b5cf6;
}

body.dashboard-page{
  font-family: 'Noto Sans Thai', sans-serif;
  width: 100%;
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0;
  background-color: var(--expo-navy);
  background-image:
    linear-gradient(180deg, rgba(4,13,91,.50), rgba(7,22,111,.74)),
    url('/dashboad/co2eq2026/data/full-of-surprises.png');
  background-size: cover;
  background-position: center top;
  background-attachment: fixed;
  color: var(--title);
  overflow-x: hidden;
}

.floating-bg{
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  overflow: hidden;
}

.floating-bg span{
  position: absolute;
  display: block;
  border-radius: 999px;
  filter: blur(24px);
  opacity: .16;
  animation: floatBlob linear infinite;
}

.floating-bg span:nth-child(1){
  width: 180px;
  height: 180px;
  background: var(--expo-cyan);
  top: 6%;
  left: 4%;
  animation-duration: 18s;
}

.floating-bg span:nth-child(2){
  width: 220px;
  height: 220px;
  background: var(--expo-orange);
  top: 18%;
  right: 8%;
  animation-duration: 22s;
}

.floating-bg span:nth-child(3){
  width: 160px;
  height: 160px;
  background: var(--expo-purple);
  bottom: 10%;
  left: 10%;
  animation-duration: 20s;
}

.floating-bg span:nth-child(4){
  width: 200px;
  height: 200px;
  background: var(--expo-orange);
  bottom: 5%;
  right: 12%;
  animation-duration: 26s;
}

@keyframes floatBlob {
  0%   { transform: translateY(0) translateX(0) scale(1); }
  25%  { transform: translateY(-30px) translateX(24px) scale(1.05); }
  50%  { transform: translateY(12px) translateX(-18px) scale(.95); }
  75%  { transform: translateY(-18px) translateX(14px) scale(1.02); }
  100% { transform: translateY(0) translateX(0) scale(1); }
}

.page-wrap{
  position: relative;
  z-index: 1;
  width: 100%;
  min-height: 100vh;
  min-height: 100dvh;
}

.dashboard-shell{
  width: 100%;
  max-width: none;
  margin: 0;
  padding: clamp(.75rem, 1.25vw, 1.5rem);
}

.dashboard-card{
  position: relative;
  background: rgba(255,255,255,.94);
  border: 1px solid rgba(255,255,255,.78);
  border-radius: 1.35rem;
  padding: 1rem;
  backdrop-filter: blur(12px);
  box-shadow: 0 14px 34px rgba(2, 6, 60, .22);
  transition: all .22s ease;
}

.dashboard-card:hover{
  transform: translateY(-2px);
  box-shadow: 0 16px 35px rgba(15, 23, 42, 0.10);
}

.hero-card{
  overflow: hidden;
}

.hero-card::before{
  content: '';
  position: absolute;
  inset: -30%;
  background:
    conic-gradient(
      from 0deg,
      rgba(14,165,233,.10),
      transparent 18%,
      rgba(16,185,129,.09),
      transparent 38%,
      rgba(245,158,11,.09),
      transparent 60%,
      rgba(244,63,94,.08),
      transparent 82%,
      rgba(14,165,233,.10)
    );
  animation: heroSpin 16s linear infinite;
  pointer-events: none;
}

.hero-card > *{
  position: relative;
  z-index: 1;
}

@keyframes heroSpin {
  from { transform: rotate(0deg); }
  to   { transform: rotate(360deg); }
}

.dashboard-section-title{
  font-size: .95rem;
  font-weight: 700;
  color: #334155;
}

.dashboard-section-subtitle{
  font-size: .78rem;
  color: #94a3b8;
  margin-top: .15rem;
}

.filter-form{
  display: flex;
  flex-wrap: wrap;
  gap: .75rem;
  align-items: end;
  justify-content: space-between;
}

.filter-group{
  min-width: 260px;
  flex: 1 1 320px;
}

.filter-label{
  display: block;
  font-size: .85rem;
  font-weight: 600;
  color: #475569;
  margin-bottom: .4rem;
}

.filter-select{
  width: 100%;
  min-width: 240px;
  max-width: 320px;
  border: 1px solid #cbd5e1;
  background: rgba(255,255,255,.92);
  color: #0f172a;
  border-radius: .95rem;
  padding: .82rem 1rem;
  font-size: .95rem;
  outline: none;
  transition: all .2s ease;
}

.filter-select:focus{
  border-color: #38bdf8;
  box-shadow: 0 0 0 4px rgba(56, 189, 248, 0.15);
}

.filter-actions{
  display: flex;
  gap: .5rem;
  flex-wrap: wrap;
}

.btn-soft{
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: .9rem;
  padding: .78rem 1rem;
  font-size: .9rem;
  font-weight: 600;
  text-decoration: none;
  border: 1px solid transparent;
  transition: all .2s ease;
  white-space: nowrap;
}

.btn-primary{
  background: #0ea5e9;
  color: #fff;
}

.btn-primary:hover{
  background: #0284c7;
}

.btn-light{
  background: #f1f5f9;
  color: #334155;
}

.btn-light:hover{
  background: #e2e8f0;
}

.summary-table{
  overflow: hidden;
  border: 1px solid #f1f5f9;
  border-radius: 1rem;
  background: rgba(255,255,255,.75);
}

.summary-head,
.summary-row{
  display: grid;
  grid-template-columns: 7fr 3fr 2fr;
  gap: .5rem;
  align-items: center;
}

.summary-head{
  background: #f8fafc;
  color: #475569;
  font-size: .78rem;
  font-weight: 700;
  padding: .8rem 1rem;
}

.summary-row{
  border-top: 1px solid #f1f5f9;
  padding: .9rem 1rem;
  font-size: .92rem;
}

.summary-source{
  display: flex;
  align-items: center;
  gap: .55rem;
  color: #334155;
}

.summary-num{
  text-align: right;
}

.summary-num strong{
  color: #0f172a;
}

.bar-list{
  margin-top: 1rem;
  display: flex;
  flex-direction: column;
  gap: .9rem;
  max-width: 100%;
  overflow: hidden;
}

.bar-chart-card{
  overflow: hidden;
  border-top: 3px solid var(--expo-orange);
}

.bar-meta{
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: .5rem;
  margin-bottom: .35rem;
  font-size: .78rem;
  color: #64748b;
}

.bar-meta-left{
  display: flex;
  align-items: center;
  gap: .5rem;
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
}

.bar-icon{
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 clamp(2rem, 2.3vw, 2.45rem);
  width: clamp(2rem, 2.3vw, 2.45rem);
  height: clamp(2rem, 2.3vw, 2.45rem);
  max-width: 2.45rem;
  max-height: 2.45rem;
  overflow: hidden;
  font-size: clamp(1.45rem, 1.8vw, 2rem);
  line-height: 1;
}

.bar-track{
  height: 12px;
  border-radius: 999px;
  overflow: hidden;
  background: #e2e8f0;
}

.bar-fill{
  height: 12px;
  width: 0;
  border-radius: 999px;
}

.bar-anim{
  will-change: width;
}

.kpi-stack{
  display: grid;
  gap: 1rem;
  min-width: 0;
}

.kpi-card{
  position: relative;
  overflow: hidden;
  min-height: 0;
  background: rgba(255,255,255,.88);
  border: 1px solid rgba(255,255,255,.65);
  border-radius: 1.35rem;
  padding: 1.4rem;
  backdrop-filter: blur(12px);
  box-shadow: 0 10px 30px rgba(15, 23, 42, 0.06);
  transition: all .22s ease;
}

@media (min-width: 1024px){
  .kpi-stack{
    height: 100%;
    grid-template-rows: repeat(2, minmax(0, 1fr));
  }

  .kpi-card{
    height: 100%;
  }
}

.kpi-card:hover{
  transform: translateY(-2px);
  box-shadow: 0 16px 35px rgba(15, 23, 42, 0.10);
}

.kpi-card::after{
  content: "";
  position: absolute;
  top: -30%;
  left: -50%;
  width: 46%;
  height: 160%;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,.24), transparent);
  transform: rotate(18deg);
  animation: lightSweep 6s linear infinite;
  pointer-events: none;
}

.kpi-title{
  font-size: 1.6rem;
  font-weight: 700;
  color: #334155;
}

.kpi-unit{
  margin-top: .4rem;
  font-size: 1rem;
  color: #64748b;
}

.kpi-value{
  margin-top: .8rem;
  font-size: clamp(2rem, 5vw, 3.2rem);
  font-weight: 800;
  line-height: 1;
  color: #0f172a;
}

.kpi-note{
  margin-top: .5rem;
  font-size: .78rem;
  color: #94a3b8;
}

.footer-note{
  text-align: center;
  font-size: .78rem;
  color: #94a3b8;
}

.top-nav{
  position: sticky;
  top: 0;
  z-index: 20;
  backdrop-filter: blur(12px);
  background: linear-gradient(90deg, rgba(5,18,112,.96), rgba(20,46,184,.93));
  border-bottom: 2px solid rgba(255,90,0,.9);
  box-shadow: 0 8px 28px rgba(2,6,60,.28);
}

.top-nav .text-slate-800{
  color: #fff !important;
}

.top-nav .header-location-label{
  color: rgba(255,255,255,.82);
}

.top-nav-inner{
  width: 100%;
  max-width: none;
  margin: 0;
  padding: .85rem clamp(.75rem, 1.25vw, 1.5rem);
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 1rem;
}

.top-nav-actions{
  display: flex;
  flex-wrap: wrap;
  gap: .5rem;
  flex: 0 1 auto;
  justify-content: flex-end;
  margin-left: auto;
}

.dashboard-title-block{
  min-width: 0;
  flex: 0 1 430px;
}

.dashboard-logo-strip{
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: clamp(.45rem, .65vw, .75rem);
  width: auto;
  min-width: 0;
  flex: 0 1 auto;
  padding: .2rem 0;
  filter: drop-shadow(0 3px 8px rgba(0,0,0,.22));
}

.dashboard-logo{
  display: block;
  width: auto;
  max-width: 112px;
  height: 46px;
  flex: 0 1 auto;
  object-fit: contain;
  object-position: center;
  border-radius: .35rem;
}

.dashboard-logo-expo{
  width: 54px;
  max-width: 54px;
  height: 54px;
}

.header-location-form{
  display: flex;
  align-items: center;
  gap: .45rem;
  margin-top: .2rem;
  max-width: 420px;
}

.header-location-label{
  flex: 0 0 auto;
  color: #64748b;
  font-size: .75rem;
  font-weight: 600;
}

.header-location-select{
  width: min(100%, 320px);
  min-height: 32px;
  border: 1px solid rgba(255,255,255,.7);
  border-radius: .6rem;
  background: rgba(255,255,255,.95);
  color: #334155;
  padding: .3rem 2rem .3rem .65rem;
  font-size: .78rem;
  outline: none;
}

.header-location-select:focus{
  border-color: #0ea5e9;
  box-shadow: 0 0 0 3px rgba(14,165,233,.16);
}

.header-location-submit{
  min-height: 32px;
  border: 0;
  border-radius: .6rem;
  background: #0ea5e9;
  color: #fff;
  padding: .3rem .7rem;
  font-size: .78rem;
  font-weight: 600;
}

.nav-pill{
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: .65rem .9rem;
  border-radius: .9rem;
  font-size: .88rem;
  text-decoration: none;
  transition: all .2s ease;
}

.nav-pill-gray{
  background: rgba(255,255,255,.13);
  color: #fff;
  border: 1px solid rgba(255,255,255,.18);
}

.nav-pill-gray:hover{
  background: rgba(255,255,255,.24);
}

.nav-pill-green{
  background: var(--expo-orange);
  color: #fff;
}

.nav-pill-green:hover{
  background: #e94f00;
}

.nav-pill-red{
  background: #fff1f2;
  color: #be123c;
}

.nav-pill-red:hover{
  background: #ffe4e6;
}

.nav-pill-sky{
  background: #e0f2fe;
  color: #0369a1;
}

.nav-pill-sky:hover{
  background: #bae6fd;
}

/* =========================
   Environmental Animated Cards
========================= */
.env-section{
  overflow: hidden;
}

.env-card{
  position: relative;
  overflow: hidden;
  isolation: isolate;
  min-height: 170px;
  box-shadow: 0 10px 25px rgba(15,23,42,.12);
  transition: transform .25s ease, box-shadow .25s ease, background-color .35s ease;
}

.env-card:hover{
  transform: translateY(-3px);
  box-shadow: 0 18px 38px rgba(15,23,42,.18);
}

.env-card::before{
  content:'';
  position:absolute;
  inset:auto -20% -45% -20%;
  height:75%;
  background: radial-gradient(circle, rgba(255,255,255,.24), transparent 65%);
  animation: glowBreath 3.5s ease-in-out infinite;
  pointer-events:none;
}

.env-card::after{
  content:'';
  position:absolute;
  inset:0;
  background: linear-gradient(120deg, transparent 10%, rgba(255,255,255,.15) 35%, transparent 55%);
  transform: translateX(-130%);
  animation: shineMove 5.5s infinite;
  pointer-events:none;
}

.env-card .env-bg-glow{
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 50% 30%, rgba(255,255,255,.18), transparent 45%);
  pointer-events: none;
  z-index: 0;
}

.env-card > *{
  position: relative;
  z-index: 1;
}

@keyframes glowBreath{
  0%,100% { opacity:.45; transform: scale(1); }
  50%     { opacity:.78; transform: scale(1.08); }
}

@keyframes shineMove{
  0%   { transform: translateX(-130%); }
  55%  { transform: translateX(130%); }
  100% { transform: translateX(130%); }
}

/* PM2.5 */
.pm-card{
  transition: background .4s ease, box-shadow .4s ease;
}

.pm-card.pm-high{
  animation: pmPulse 1.8s ease-in-out infinite;
  box-shadow: 0 0 0 rgba(239,68,68,0), 0 12px 30px rgba(127,29,29,.22);
}

@keyframes pmPulse{
  0%,100%{
    box-shadow: 0 0 0 rgba(239,68,68,0), 0 12px 30px rgba(127,29,29,.18);
    filter: saturate(1);
  }
  50%{
    box-shadow: 0 0 28px rgba(248,113,113,.26), 0 16px 34px rgba(127,29,29,.28);
    filter: saturate(1.08);
  }
}

.pm-particles{
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  z-index: 0;
}

.pm-particle{
  position: absolute;
  bottom: -14px;
  width: 6px;
  height: 6px;
  border-radius: 999px;
  background: rgba(255,255,255,.35);
  filter: blur(.3px);
  opacity: .7;
  animation: floatDust var(--dust-duration, 7s) linear infinite;
  animation-delay: var(--dust-delay, 0s);
  left: var(--dust-left, 50%);
  transform: translateY(0) scale(var(--dust-scale, 1));
}

.pm-card.pm-high .pm-particle{
  background: rgba(255, 240, 240, .46);
  animation-duration: var(--dust-duration-fast, 3.2s);
}

@keyframes floatDust{
  0%{
    transform: translate3d(0, 0, 0) scale(var(--dust-scale, 1));
    opacity: 0;
  }
  10%{
    opacity: .9;
  }
  100%{
    transform: translate3d(var(--dust-drift, 18px), -150px, 0) scale(calc(var(--dust-scale, 1) + .25));
    opacity: 0;
  }
}

/* TEMP */
.thermo-shell{
  width: 54px;
  height: 74px;
  margin: 0 auto 8px;
  position: relative;
  animation: thermoBob 3s ease-in-out infinite;
}

.thermo-shell svg{
  display: block;
  margin: 0 auto;
  overflow: visible;
}

.thermo-fill{
  transform-box: fill-box;
  transform-origin: center bottom;
  transition: transform 1.35s cubic-bezier(.22,.8,.18,1), fill .4s ease;
  will-change: transform;
}

@keyframes thermoBob{
  0%,100%{ transform: translateY(0); }
  50%{ transform: translateY(-4px); }
}

/* HUMIDITY */
.humidity-card{
  --wave-level: 45%;
}

.humidity-water{
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: var(--wave-level);
  z-index: 0;
  pointer-events: none;
  transition: height 1s ease;
}

.humidity-water::before,
.humidity-water::after{
  content: "";
  position: absolute;
  left: -20%;
  width: 140%;
  height: 46px;
  border-radius: 42%;
  background: rgba(255,255,255,.22);
  animation: waveMove 8s linear infinite;
  top: -18px;
}

.humidity-water::after{
  background: rgba(255,255,255,.14);
  animation-duration: 11s;
  animation-direction: reverse;
  top: -12px;
}

@keyframes waveMove{
  from { transform: translateX(0) translateY(0); }
  50% { transform: translateX(-6%) translateY(3px); }
  to   { transform: translateX(-12%) translateY(0); }
}

/* LIGHT */
.light-card .sun-core{
  width: 52px;
  height: 52px;
  margin: 0 auto 6px;
  border-radius: 999px;
  background: rgba(255,255,255,.42);
  box-shadow:
    0 0 0 8px rgba(255,255,255,.08),
    0 0 28px rgba(255,255,255,.25);
  animation: sunPulse 2.8s ease-in-out infinite;
}

.light-card::after{
  content: "";
  position: absolute;
  top: -30%;
  left: -50%;
  width: 46%;
  height: 160%;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,.18), transparent);
  transform: rotate(18deg);
  animation: lightSweep 5.6s linear infinite;
  pointer-events: none;
  z-index: 0;
}

@keyframes sunPulse{
  0%,100%{
    transform: scale(1);
    box-shadow: 0 0 0 8px rgba(255,255,255,.08), 0 0 28px rgba(255,255,255,.25);
  }
  50%{
    transform: scale(1.08);
    box-shadow: 0 0 0 14px rgba(255,255,255,.10), 0 0 36px rgba(255,255,255,.34);
  }
}

@keyframes lightSweep{
  0%{ left: -60%; }
  100%{ left: 130%; }
}

/* WIND */
.wind-svg{
  width: 56px;
  height: 56px;
  display: block;
  margin: 0 auto 8px;
  filter: drop-shadow(0 6px 12px rgba(0,0,0,.08));
}

.wind-rotor{
  transform-origin: 32px 22px;
  will-change: transform;
}

.wind-speed-chip{
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 58px;
  padding: 3px 10px;
  font-size: 11px;
  border-radius: 999px;
  background: rgba(255,255,255,.18);
  backdrop-filter: blur(4px);
}

/* Last update pill */
.env-last-update{
  display: inline-flex;
  align-items: center;
  gap: .5rem;
  border-radius: 999px;
  background: #f1f5f9;
  padding: .55rem 1rem;
  font-size: .78rem;
  color: #475569;
  border: 1px solid #e2e8f0;
  box-shadow: 0 6px 18px rgba(15,23,42,.04);
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce){
  .floating-bg span,
  .hero-card::before,
  .pm-card.pm-high,
  .pm-particle,
  .humidity-water::before,
  .humidity-water::after,
  .light-card::after,
  .light-card .sun-core,
  .thermo-shell{
    animation: none !important;
  }

  .thermo-fill,
  .humidity-water,
  .bar-fill{
    transition: none !important;
  }
}

@media (max-width: 1100px){
  .top-nav-inner{
    flex-wrap: wrap;
  }

  .dashboard-logo-strip{
    order: 3;
    width: 100%;
    min-width: 0;
    justify-content: center;
  }
}

@media (max-width: 768px){
  body.dashboard-page{
    background-attachment: scroll;
  }
  .top-nav-inner{
    flex-direction: column;
    align-items: stretch;
  }

  .top-nav-actions{
    justify-content: flex-start;
  }

  .dashboard-logo-strip{
    display: grid;
    order: 2;
    width: 100%;
    min-width: 0;
    grid-template-columns: repeat(4, minmax(55px, 1fr));
    justify-items: center;
    gap: .4rem .75rem;
    padding: .35rem 0;
  }

  .dashboard-logo{
    width: 100%;
    max-width: 110px;
    height: 38px;
  }

  .dashboard-logo-expo{
    width: 42px;
    max-width: 42px;
    height: 42px;
  }

  .top-nav-actions{
    order: 3;
  }

  .dashboard-title-block,
  .header-location-form{
    width: 100%;
    max-width: none;
  }

  .dashboard-title-block{
    flex: none;
    flex-basis: auto;
  }

  .header-location-select{
    width: 100%;
    max-width: none;
  }

  .summary-head,
  .summary-row{
    grid-template-columns: 6fr 3fr 3fr;
  }

  .filter-actions{
    width: 100%;
  }

  .filter-actions .btn-soft{
    flex: 1 1 auto;
  }

  .env-card:hover,
  .dashboard-card:hover,
  .kpi-card:hover{
    transform: none;
  }
}

@media (max-width: 640px){
  .bar-icon{
    flex-basis: 2rem;
    width: 2rem;
    height: 2rem;
    font-size: 1.5rem;
  }

  .filter-select,
  .filter-actions .btn-soft{
    width: 100%;
    max-width: 100%;
  }
}
