@import url('https://fonts.googleapis.com/css2?family=Barlow+Condensed:wght@400;600;700;800&family=Barlow:wght@400;500;600&family=JetBrains+Mono:wght@400;500;700&display=swap');

/* ============================================================
   VARIABLES
   ============================================================ */
:root {
  --bg:        #07070b;
  --surf:      #0e0e14;
  --surf2:     #14141c;
  --surf3:     #1b1b25;
  --border:    #1c1c28;
  --border2:   #28283a;
  --text:      #ededf2;
  --muted:     #5a5a72;
  --dim:       #2e2e42;

  --amber:     #f59e0b;
  --amber-lo:  rgba(245,158,11,.1);
  --blue:      #38bdf8;
  --blue-lo:   rgba(56,189,248,.08);
  --green:     #34d399;
  --green-lo:  rgba(52,211,153,.08);
  --red:       #f87171;
  --red-lo:    rgba(248,113,113,.08);
  --orange:    #fb923c;
  --purple:    #a78bfa;

  --r:  4px;
  --rl: 10px;
  --mono: 'JetBrains Mono', monospace;
  --cond: 'Barlow Condensed', sans-serif;
  --sans: 'Barlow', sans-serif;

  --ease-out-expo: cubic-bezier(.16,1,.3,1);
  --ease-in-out:   cubic-bezier(.4,0,.2,1);
}

/* ============================================================
   KEYFRAMES
   ============================================================ */

/* CRT scanline sweep */
@keyframes scanMove {
  from { background-position: 0 0; }
  to   { background-position: 0 120px; }
}

/* Logo glitch */
@keyframes glitch {
  0%, 84%, 100% { transform: none; text-shadow: none; filter: none; }
  85% { transform: translate(-3px, 1px) skewX(-3deg); text-shadow: 3px 0 #0ff, -3px 0 #f06; filter: brightness(1.3); }
  86% { transform: translate(3px, -1px) skewX(3deg); text-shadow: -3px 0 #0ff, 3px 0 #f06; }
  87% { transform: translate(-2px, 2px); text-shadow: 2px 0 #0ff; filter: hue-rotate(90deg); }
  88% { transform: translate(2px, -1px) scaleX(1.03); text-shadow: -2px 0 #f06, 4px 0 rgba(0,255,255,.4); }
  89% { transform: none; text-shadow: 0 0 8px #f59e0b; filter: none; }
  90% { transform: translate(-1px, 0) scaleX(.98); text-shadow: 3px 0 #0ff, -3px 0 #f06; }
  91% { transform: none; text-shadow: none; }
}

/* Header animated border */
@keyframes borderFlow {
  0%   { background-position: 0% 0; }
  100% { background-position: 300% 0; }
}

/* Card flip entrance */
@keyframes flipIn {
  from { opacity: 0; transform: perspective(800px) rotateY(90deg) translateY(10px); }
  to   { opacity: 1; transform: perspective(800px) rotateY(0deg) translateY(0); }
}

/* Card pulse ring */
@keyframes pulseRing {
  0%   { transform: scale(1); opacity: .5; }
  60%  { opacity: 0; }
  100% { transform: scale(1.08); opacity: 0; }
}

/* Chart horizontal scan line */
@keyframes chartScan {
  0%   { top: -2px; opacity: 0; }
  5%   { opacity: 1; }
  95%  { opacity: .8; }
  100% { top: 100%; opacity: 0; }
}

/* Sonar multi-ring */
@keyframes sonarExpand {
  0%   { transform: translate(-50%, -50%) scale(1); opacity: .6; }
  100% { transform: translate(-50%, -50%) scale(4.5); opacity: 0; }
}

/* AQI thumb glow */
@keyframes aqiGlow {
  from { box-shadow: 0 0 4px 1px var(--aqi-color, #34d399), 0 0 0 2px var(--bg); }
  to   { box-shadow: 0 0 12px 4px var(--aqi-color, #34d399), 0 0 24px 8px var(--aqi-color, #34d399), 0 0 0 2px var(--bg); }
}

/* Live dot blink */
@keyframes blink {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%       { opacity: .3; transform: scale(.7); }
}

/* Value flash */
@keyframes valueFlash {
  0%   { color: var(--amber); text-shadow: 0 0 24px rgba(245,158,11,.8), 0 0 48px rgba(245,158,11,.4); }
  60%  { color: var(--amber); }
  100% { color: var(--text); text-shadow: none; }
}

/* Row slide in */
@keyframes rowSlideIn {
  from { opacity: 0; transform: translateX(24px); background: rgba(245,158,11,.08); }
  to   { opacity: 1; transform: translateX(0); background: transparent; }
}

/* Fade in up (entrance) */
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(20px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* Mesh gradient blobs */
@keyframes blobFloat1 {
  0%, 100% { transform: translate(0, 0) scale(1); }
  33%       { transform: translate(60px, -40px) scale(1.1); }
  66%       { transform: translate(-30px, 50px) scale(.9); }
}
@keyframes blobFloat2 {
  0%, 100% { transform: translate(0, 0) scale(1); }
  40%       { transform: translate(-70px, 30px) scale(1.15); }
  70%       { transform: translate(40px, -60px) scale(.85); }
}
@keyframes blobFloat3 {
  0%, 100% { transform: translate(0, 0) scale(1); }
  50%       { transform: translate(50px, 40px) scale(1.2); }
}

/* Typewriter cursor */
@keyframes twBlink {
  0%, 50% { opacity: 1; }
  51%, 100% { opacity: 0; }
}

/* Cracked glass effect */
@keyframes crackIn {
  0%   { opacity: 0; filter: brightness(2); }
  20%  { opacity: 1; filter: brightness(1.5); }
  100% { opacity: 1; filter: brightness(1); }
}
@keyframes crackTremor {
  0%, 100% { transform: translateY(-5px) scale(1.005); }
  20%       { transform: translateY(-5px) scale(1.005) skewX(.4deg) translateX(1px); }
  50%       { transform: translateY(-5px) scale(1.005) skewX(-.5deg) translateX(-1px); }
  80%       { transform: translateY(-5px) scale(1.005) skewX(.3deg); }
}
@keyframes crackSkew {
  0%, 100% { transform: none; }
  15%       { transform: skewX(-.8deg) translateX(-1px); }
  35%       { transform: skewX(1.2deg) translateX(1px); }
  55%       { transform: skewX(-.4deg); }
  75%       { transform: skewX(.6deg) translateX(.5px); }
}

/* ── Cracked card state ─────────────────────────────────── */
.metric-card.card-cracked {
  border-color: rgba(248,113,113,.55) !important;
  box-shadow:
    inset 0 1px 0 rgba(248,113,113,.06),
    0 0 0 1px rgba(248,113,113,.3),
    0 12px 40px rgba(248,113,113,.25) !important;
  animation: crackTremor 3.5s ease-in-out infinite !important;
}

/* Override the pulse-ring ::after with crack overlay */
.metric-card.card-cracked::after {
  /* remove normal pulse ring */
  border: none !important;
  animation: crackIn .45s ease-out forwards !important;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='300' height='200'%3E%3Cg stroke='rgba(248%2C113%2C113%2C.5)' stroke-width='1' fill='none' stroke-linecap='round'%3E%3Ccircle cx='95' cy='85' r='5' fill='rgba(248%2C113%2C113%2C.85)' stroke='none'/%3E%3Cpolyline points='95%2C85 78%2C58 58%2C38 32%2C22'/%3E%3Cpolyline points='95%2C85 118%2C65 142%2C54 172%2C46'/%3E%3Cpolyline points='95%2C85 128%2C82 162%2C78 205%2C72'/%3E%3Cpolyline points='95%2C85 108%2C102 125%2C120 118%2C148 142%2C162'/%3E%3Cpolyline points='95%2C85 78%2C104 60%2C122 38%2C138 15%2C155'/%3E%3Cpolyline points='95%2C85 84%2C118 68%2C142 72%2C175'/%3E%3Cline x1='78' y1='58' x2='65' y2='72'/%3E%3Cline x1='118' y1='65' x2='140' y2='78'/%3E%3Cline x1='108' y1='102' x2='92' y2='108'/%3E%3Cline x1='125' y1='120' x2='148' y2='112'/%3E%3Cline x1='60' y1='122' x2='48' y2='108'/%3E%3Cpolyline points='32%2C22 12%2C8'/%3E%3Cpolyline points='172%2C46 215%2C36 248%2C44'/%3E%3Cpolyline points='205%2C72 245%2C66 298%2C58'/%3E%3Cpolyline points='142%2C162 165%2C178 192%2C170'/%3E%3C/g%3E%3C/svg%3E");
  background-size: 100% 100%;
  background-position: center;
  mix-blend-mode: screen;
  opacity: .9;
  z-index: 3;
  top: 0; left: 0; right: 0; bottom: 0;
  border-radius: var(--rl);
  pointer-events: none;
}

.metric-card.card-cracked .big-value {
  text-shadow:
    2px 1px 0 rgba(248,113,113,.9),
    -2px -1px 0 rgba(56,189,248,.6) !important;
  animation: crackSkew 2.8s ease-in-out infinite, neonFlicker 1.4s infinite !important;
}

/* Neon flicker on big values */
@keyframes neonFlicker {
  0%, 19%, 21%, 23%, 25%, 54%, 56%, 100% { opacity: 1; }
  20%, 24%, 55%                           { opacity: .6; }
}

/* Secondary card entrance */
@keyframes fadeInScale {
  from { opacity: 0; transform: scale(.96) translateY(10px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}

/* ============================================================
   RESET & BASE
   ============================================================ */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }
html { scroll-behavior: smooth; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.5;
  min-height: 100vh;
  background-image: radial-gradient(circle, rgba(255,255,255,.022) 1px, transparent 1px);
  background-size: 28px 28px;
  position: relative;
  cursor: default;
}

/* CRT scanlines */
body::after {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 9998;
  background: repeating-linear-gradient(
    0deg,
    transparent,
    transparent 2px,
    rgba(0,255,70,.011) 2px,
    rgba(0,255,70,.011) 4px
  );
  animation: scanMove 10s linear infinite;
}

/* Noise overlay */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 9999;
  opacity: 0.028;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='512' height='512'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='512' height='512' filter='url(%23n)'/%3E%3C/svg%3E");
  background-size: 160px 160px;
}

/* Canvas backgrounds */
#matrixCanvas {
  position: fixed;
  top: 0; left: 0;
  width: 100%; height: 100%;
  z-index: -2;
  pointer-events: none;
  opacity: 0.055;
}
#particleCanvas {
  position: fixed;
  top: 0; left: 0;
  width: 100%; height: 100%;
  z-index: -1;
  pointer-events: none;
}

/* Mesh gradient blobs */
.mesh-bg {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  overflow: hidden;
}
.blob {
  position: absolute;
  border-radius: 50%;
  filter: blur(80px);
}
.blob.b1 {
  width: 600px; height: 600px;
  top: -200px; left: -100px;
  background: radial-gradient(circle, rgba(245,158,11,.04) 0%, transparent 70%);
  animation: blobFloat1 22s ease-in-out infinite;
}
.blob.b2 {
  width: 500px; height: 500px;
  bottom: -150px; right: -100px;
  background: radial-gradient(circle, rgba(56,189,248,.04) 0%, transparent 70%);
  animation: blobFloat2 28s ease-in-out infinite;
}
.blob.b3 {
  width: 400px; height: 400px;
  top: 40%; left: 50%;
  background: radial-gradient(circle, rgba(248,113,113,.03) 0%, transparent 70%);
  animation: blobFloat3 18s ease-in-out infinite;
}

/* value flash class (via JS) */
.value-flash {
  animation: valueFlash .55s var(--ease-out-expo) forwards;
}

/* Typewriter cursor */
.tw-cursor {
  display: inline-block;
  margin-left: 2px;
  color: var(--amber);
  animation: twBlink .8s step-end infinite;
}

/* ============================================================
   HEADER
   ============================================================ */
header {
  position: sticky;
  top: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  gap: 20px;
  height: 56px;
  padding: 0 28px;
  background: rgba(7,7,11,.88);
  backdrop-filter: blur(20px) saturate(1.4);
  -webkit-backdrop-filter: blur(20px) saturate(1.4);
  border-bottom: none;
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,.04),
    0 8px 32px rgba(0,0,0,.4);
  overflow: hidden;
}

/* Animated amber border at bottom of header */
header::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 1.5px;
  background: linear-gradient(
    90deg,
    transparent 0%,
    var(--amber) 15%,
    #34d399 35%,
    var(--amber) 55%,
    var(--blue) 75%,
    transparent 100%
  );
  background-size: 300% 100%;
  animation: borderFlow 4s linear infinite;
}

.header-brand {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-shrink: 0;
}

/* Logo glitch */
.logo-text {
  font-family: var(--cond);
  font-size: 1.25rem;
  font-weight: 800;
  letter-spacing: .12em;
  animation: glitch 7s infinite;
}
.logo-text em {
  color: var(--amber);
  font-style: normal;
}

.live-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 3px 9px;
  background: rgba(52,211,153,.07);
  border: 1px solid rgba(52,211,153,.22);
  border-radius: 3px;
  font-family: var(--cond);
  font-size: .65rem;
  font-weight: 700;
  letter-spacing: .18em;
  color: var(--green);
}

.live-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--green);
  animation: blink 1.6s ease-in-out infinite;
  flex-shrink: 0;
}

.header-center {
  flex: 1;
  display: flex;
  justify-content: center;
}

.uptime-block {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
}
.uptime-label {
  font-family: var(--cond);
  font-size: .58rem;
  font-weight: 700;
  letter-spacing: .2em;
  color: var(--muted);
}
.uptime-value {
  font-family: var(--mono);
  font-size: .82rem;
  font-weight: 500;
  color: var(--text);
}

.header-right {
  display: flex;
  align-items: center;
  gap: 18px;
  flex-shrink: 0;
}

.nav-btn {
  font-family: var(--cond);
  font-size: .68rem;
  font-weight: 700;
  letter-spacing: .12em;
  color: var(--muted);
  text-decoration: none;
  border: 1px solid var(--border2);
  padding: 5px 13px;
  border-radius: var(--r);
  transition: all .22s var(--ease-in-out);
}
.nav-btn:hover {
  color: var(--amber);
  border-color: var(--amber);
  background: var(--amber-lo);
  box-shadow: 0 0 12px rgba(245,158,11,.2);
}

.conn-status {
  display: flex;
  align-items: center;
  gap: 7px;
  font-family: var(--cond);
  font-size: .68rem;
  font-weight: 700;
  letter-spacing: .1em;
  color: var(--muted);
}

/* Status dot + multi-ring sonar */
.status-dot-wrap {
  position: relative;
  width: 8px;
  height: 8px;
  flex-shrink: 0;
}
.status-dot {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: var(--dim);
  transition: background .35s, box-shadow .35s;
  z-index: 1;
}
.status-dot.online  {
  background: var(--green);
  box-shadow: 0 0 8px var(--green), 0 0 16px rgba(52,211,153,.4);
}
.status-dot.offline { background: var(--red); }

.sonar-ring {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  border: 1px solid var(--green);
  opacity: 0;
  pointer-events: none;
}
.status-dot.online ~ .sonar-ring:nth-child(2) {
  animation: sonarExpand 2s ease-out infinite 0s;
}
.status-dot.online ~ .sonar-ring:nth-child(3) {
  animation: sonarExpand 2s ease-out infinite .55s;
}
.status-dot.online ~ .sonar-ring:nth-child(4) {
  animation: sonarExpand 2s ease-out infinite 1.1s;
}

.hdr-update {
  font-family: var(--mono);
  font-size: .65rem;
  color: var(--dim);
}

/* ============================================================
   MAIN LAYOUT
   ============================================================ */
main {
  max-width: 1560px;
  margin: 0 auto;
  padding: 22px 28px 48px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  position: relative;
  z-index: 1;
}

/* Section titles with amber bar */
.section-title {
  font-family: var(--cond);
  font-size: .68rem;
  font-weight: 700;
  letter-spacing: .22em;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 10px;
}
.section-title::before {
  content: '';
  display: inline-block;
  width: 3px;
  height: 12px;
  background: var(--amber);
  border-radius: 2px;
  opacity: .8;
  box-shadow: 0 0 6px var(--amber);
}

/* ============================================================
   PRIMARY GRID
   ============================================================ */
.primary-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr 1.15fr;
  gap: 10px;
  perspective: 1200px;
}

.metric-card {
  border: 1px solid var(--border);
  border-radius: var(--rl);
  padding: 20px 20px 16px;
  position: relative;
  overflow: visible;
  transition: border-color .3s var(--ease-in-out),
              box-shadow .3s var(--ease-in-out),
              transform .3s var(--ease-out-expo);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.03);
  animation: flipIn .6s var(--ease-out-expo) both;
}

.card-temp  { background: radial-gradient(ellipse at 0% 0%, rgba(248,113,113,.08) 0%, var(--surf) 55%); }
.card-hum   { background: radial-gradient(ellipse at 0% 0%, rgba(56,189,248,.08) 0%, var(--surf) 55%); }
.card-door  { background: radial-gradient(ellipse at 0% 0%, rgba(245,158,11,.08) 0%, var(--surf) 55%); }
.card-aqi   { background: radial-gradient(ellipse at 0% 0%, rgba(167,139,250,.08) 0%, var(--surf) 55%); }

/* flip stagger */
.metric-card:nth-child(1) { animation-delay: .05s; }
.metric-card:nth-child(2) { animation-delay: .15s; }
.metric-card:nth-child(3) { animation-delay: .25s; }
.metric-card:nth-child(4) { animation-delay: .35s; }

.metric-card:hover {
  border-color: var(--border2);
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,.05),
    0 12px 48px rgba(0,0,0,.6),
    0 0 0 1px var(--border2);
  transform: translateY(-5px) scale(1.005);
}

/* top stripe */
.metric-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  z-index: 1;
  transition: height .3s var(--ease-in-out), box-shadow .3s;
  border-radius: var(--rl) var(--rl) 0 0;
}
.metric-card:hover::before {
  height: 4px;
  box-shadow: 0 0 12px currentColor;
}
.card-temp::before  { background: linear-gradient(90deg, #f87171, #fb923c 70%); }
.card-hum::before   { background: linear-gradient(90deg, #38bdf8, #818cf8 70%); }
.card-door::before  { background: linear-gradient(90deg, #f59e0b, #f87171 70%); }
.card-aqi::before   { background: linear-gradient(90deg, #34d399 0%, #fbbf24 50%, #f87171 100%); }

/* pulse ring — positioned outside the card via overflow:visible */
.metric-card::after {
  content: '';
  position: absolute;
  inset: -3px;
  border-radius: calc(var(--rl) + 3px);
  pointer-events: none;
  animation: pulseRing 4s ease-out infinite;
  z-index: -1;
}
.card-temp::after  { border: 1.5px solid rgba(248,113,113,.5); animation-delay: 0s; }
.card-hum::after   { border: 1.5px solid rgba(56,189,248,.5);  animation-delay: 1s; }
.card-door::after  { border: 1.5px solid rgba(245,158,11,.5);  animation-delay: 2s; }
.card-aqi::after   { border: 1.5px solid rgba(167,139,250,.5); animation-delay: 3s; }

.card-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}
.card-label {
  font-family: var(--cond);
  font-size: .65rem;
  font-weight: 700;
  letter-spacing: .18em;
  color: var(--muted);
}
.card-tag {
  font-family: var(--mono);
  font-size: .58rem;
  color: var(--dim);
  letter-spacing: .05em;
}

.card-value-row {
  display: flex;
  align-items: baseline;
  gap: 6px;
  margin-bottom: 18px;
}

.big-value {
  font-family: var(--mono);
  font-size: 3rem;
  font-weight: 700;
  line-height: 1;
  transition: color .35s, text-shadow .35s;
  animation: neonFlicker 8s infinite;
}
.metric-card:nth-child(2) .big-value { animation-delay: 1.5s; }
.metric-card:nth-child(3) .big-value { animation-delay: 3s; }
.metric-card:nth-child(4) .big-value { animation-delay: 5s; }
.card-temp:hover  .big-value { text-shadow: 0 0 32px rgba(248,113,113,.5); color: #f87171; }
.card-hum:hover   .big-value { text-shadow: 0 0 32px rgba(56,189,248,.5);  color: #38bdf8; }
.card-door:hover  .big-value { text-shadow: 0 0 32px rgba(245,158,11,.5);  color: #f59e0b; }
.card-aqi:hover   .big-value { text-shadow: 0 0 32px rgba(167,139,250,.5); color: #a78bfa; }

.big-unit {
  font-family: var(--cond);
  font-size: 1rem;
  color: var(--muted);
  font-weight: 600;
}

/* stat pills */
.card-stats {
  display: flex;
  gap: 6px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}
.stat-pill {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 3px;
  background: rgba(255,255,255,.022);
  border: 1px solid rgba(255,255,255,.04);
  border-radius: 6px;
  padding: 6px 8px;
  transition: background .2s, border-color .2s;
}
.metric-card:hover .stat-pill {
  background: rgba(255,255,255,.04);
  border-color: rgba(255,255,255,.07);
}
.stat-pill.center { align-items: center; }
.stat-lbl {
  font-family: var(--cond);
  font-size: .58rem;
  font-weight: 700;
  letter-spacing: .12em;
  color: var(--dim);
}
.stat-val {
  font-family: var(--mono);
  font-size: .8rem;
  font-weight: 700;
  color: var(--muted);
}
.stat-pill.center .stat-val {
  color: var(--text);
  font-size: .9rem;
}

/* Door card */
.door-display {
  display: flex;
  align-items: center;
  gap: 18px;
  margin-top: 4px;
  margin-bottom: 4px;
}
.door-3d { perspective: 240px; flex-shrink: 0; }
.door-frame {
  width: 44px; height: 58px;
  border: 2px solid var(--border2);
  border-radius: 3px 3px 0 0;
  position: relative;
  background: var(--bg);
}
.door-panel {
  position: absolute;
  inset: 2px;
  background: var(--surf3);
  border-radius: 2px 2px 0 0;
  transform-origin: left center;
  transition: transform .65s cubic-bezier(.4,0,.2,1);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding-right: 6px;
}
.door-panel.is-open { transform: perspective(240px) rotateY(-72deg); }
.door-handle {
  width: 4px; height: 10px;
  border-radius: 2px;
  background: var(--amber);
  opacity: .6;
}
.door-info { display: flex; flex-direction: column; gap: 6px; }
.door-status-text {
  font-family: var(--cond);
  font-size: 1.6rem;
  font-weight: 800;
  letter-spacing: .05em;
  line-height: 1;
}
.door-status-text.is-closed { color: var(--green); text-shadow: 0 0 12px rgba(52,211,153,.5); }
.door-status-text.is-open   { color: var(--red);   text-shadow: 0 0 12px rgba(248,113,113,.5); }
.door-evt-count {
  font-family: var(--mono);
  font-size: .65rem;
  color: var(--muted);
}

/* AQI card */
.aqi-track {
  position: relative;
  margin-top: 12px;
  height: 16px;
}
.aqi-gradient {
  width: 100%;
  height: 8px;
  border-radius: 4px;
  background: linear-gradient(90deg, #34d399, #fbbf24 50%, #f87171);
  box-shadow: 0 0 8px rgba(0,0,0,.4);
}
.aqi-thumb {
  --aqi-color: #34d399;
  position: absolute;
  top: -4px;
  width: 14px; height: 14px;
  border-radius: 50%;
  background: var(--text);
  box-shadow: 0 0 0 2px var(--bg);
  transition: left .5s var(--ease-in-out);
  transform: translateX(-50%);
  animation: aqiGlow 1.5s ease-in-out infinite alternate;
}
.aqi-scale-labels {
  display: flex;
  justify-content: space-between;
  margin-top: 4px;
  font-family: var(--cond);
  font-size: .58rem;
  font-weight: 700;
  letter-spacing: .08em;
  color: var(--dim);
}

/* ============================================================
   SECONDARY GRID
   ============================================================ */
.secondary-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
}

.sec-card {
  background: var(--surf);
  border: 1px solid var(--border);
  border-radius: var(--rl);
  padding: 16px;
  transition: border-color .25s var(--ease-in-out),
              transform .3s var(--ease-out-expo),
              box-shadow .25s var(--ease-in-out);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.02);
  animation: fadeInScale .5s var(--ease-out-expo) both;
}
.sec-card:nth-child(1) { animation-delay: .3s; }
.sec-card:nth-child(2) { animation-delay: .38s; }
.sec-card:nth-child(3) { animation-delay: .46s; }
.sec-card:nth-child(4) { animation-delay: .54s; }
.sec-card:hover {
  border-color: var(--amber);
  transform: translateY(-4px);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.03), 0 8px 32px rgba(0,0,0,.5), 0 0 0 1px rgba(245,158,11,.15);
}

.sec-label {
  display: block;
  font-family: var(--cond);
  font-size: .62rem;
  font-weight: 700;
  letter-spacing: .18em;
  color: var(--muted);
  margin-bottom: 8px;
}
.sec-val-row {
  display: flex;
  align-items: baseline;
  gap: 4px;
  margin-bottom: 10px;
}
.sec-value {
  font-family: var(--mono);
  font-size: 1.85rem;
  font-weight: 700;
  line-height: 1;
  transition: text-shadow .3s;
}
.sec-card:hover .sec-value {
  text-shadow: 0 0 20px rgba(245,158,11,.4);
  color: var(--amber);
}
.sec-value-sm { font-size: 1.2rem; }
.sec-unit {
  font-family: var(--cond);
  font-size: .8rem;
  color: var(--muted);
  font-weight: 600;
}
.sec-stats {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  padding-top: 8px;
  border-top: 1px solid var(--border);
  font-family: var(--mono);
  font-size: .68rem;
  color: var(--muted);
}
.sec-stats b { color: var(--text); }

/* Signal bars */
.signal-bars {
  display: flex;
  gap: 5px;
  align-items: flex-end;
  height: 26px;
  padding-top: 4px;
  margin-top: 2px;
}
.sig-bar {
  flex: 1;
  border-radius: 2px;
  background: var(--border2);
  transition: background .35s, box-shadow .35s;
}
.sig-bar[data-i="1"] { height: 28%; }
.sig-bar[data-i="2"] { height: 52%; }
.sig-bar[data-i="3"] { height: 76%; }
.sig-bar[data-i="4"] { height: 100%; }
.sig-bar.sig-active      { background: var(--blue);   box-shadow: 0 0 6px rgba(56,189,248,.4); }
.sig-bar.sig-active-fair { background: var(--orange); box-shadow: 0 0 6px rgba(251,146,60,.4); }
.sig-bar.sig-active-weak { background: var(--red);    box-shadow: 0 0 6px rgba(248,113,113,.4); }

/* ============================================================
   SECTION HEADERS
   ============================================================ */
.charts-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 2px 4px;
  margin-top: 10px;
  border-top: 1px solid var(--border);
}

.time-filter { display: flex; gap: 4px; }
.filter-btn {
  background: var(--surf);
  border: 1px solid var(--border);
  color: var(--muted);
  padding: 5px 14px;
  border-radius: var(--r);
  cursor: pointer;
  font-family: var(--cond);
  font-size: .7rem;
  font-weight: 700;
  letter-spacing: .1em;
  transition: all .22s var(--ease-in-out);
}
.filter-btn:hover {
  border-color: var(--amber);
  color: var(--text);
  transform: translateY(-2px);
  box-shadow: 0 4px 16px rgba(245,158,11,.2);
}
.filter-btn.active {
  background: var(--amber);
  border-color: var(--amber);
  color: #000;
  box-shadow: 0 2px 14px rgba(245,158,11,.4), 0 0 28px rgba(245,158,11,.15);
}

/* ============================================================
   CHARTS
   ============================================================ */
.charts-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}

.chart-card {
  background: var(--surf);
  border: 1px solid var(--border);
  border-radius: var(--rl);
  padding: 16px 16px 12px;
  transition: border-color .25s, box-shadow .25s;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.02);
  position: relative;
  overflow: hidden;
  animation: fadeInUp .5s var(--ease-out-expo) .35s both;
}
.chart-card:hover {
  border-color: rgba(52,211,153,.3);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.03), 0 6px 28px rgba(0,0,0,.4), 0 0 0 1px rgba(52,211,153,.1);
}

/* horizontal scan line sweep */
.chart-card::before {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  height: 1px;
  pointer-events: none;
  z-index: 2;
  background: linear-gradient(
    90deg,
    transparent 0%,
    rgba(52,211,153,.15) 20%,
    rgba(52,211,153,.7) 50%,
    rgba(52,211,153,.15) 80%,
    transparent 100%
  );
  box-shadow: 0 0 8px 2px rgba(52,211,153,.25), 0 0 2px rgba(52,211,153,.6);
  animation: chartScan 5s ease-in-out infinite;
}
.chart-hdr {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
  position: relative;
  z-index: 1;
}
.chart-label {
  font-family: var(--cond);
  font-size: .65rem;
  font-weight: 700;
  letter-spacing: .15em;
  color: var(--muted);
}
.chart-cur {
  font-family: var(--mono);
  font-size: .82rem;
  font-weight: 700;
  color: var(--text);
}
.chart-card:nth-child(1)::before { animation-delay: 0s; }
.chart-card:nth-child(2)::before { animation-delay: 1.25s; }
.chart-card:nth-child(3)::before { animation-delay: 2.5s; }
.chart-card:nth-child(4)::before { animation-delay: 3.75s; }
.chart-card canvas { max-height: 190px; position: relative; z-index: 1; }

/* ============================================================
   DOOR TIMELINE
   ============================================================ */
.timeline-header {
  padding: 10px 2px 4px;
  margin-top: 10px;
  border-top: 1px solid var(--border);
}
.door-timeline {
  background: var(--surf);
  border: 1px solid var(--border);
  border-radius: var(--rl);
  overflow-y: auto;
  max-height: 200px;
  padding: 4px 0;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.02);
}
.tl-empty {
  text-align: center;
  padding: 24px;
  font-family: var(--mono);
  font-size: .75rem;
  color: var(--dim);
}
.tl-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 9px 18px;
  border-bottom: 1px solid var(--border);
  transition: background .15s, padding-left .18s var(--ease-out-expo);
}
.tl-item:last-child { border-bottom: none; }
.tl-item:hover { background: var(--surf2); padding-left: 26px; }
.tl-dot {
  width: 9px; height: 9px;
  border-radius: 50%;
  flex-shrink: 0;
}
.tl-dot.open   { background: var(--red);   box-shadow: 0 0 8px var(--red); }
.tl-dot.closed { background: var(--green); box-shadow: 0 0 8px var(--green); }
.tl-time {
  font-family: var(--mono);
  font-size: .72rem;
  color: var(--muted);
  width: 155px;
  flex-shrink: 0;
}
.tl-event {
  font-family: var(--cond);
  font-size: .88rem;
  font-weight: 800;
  letter-spacing: .06em;
}
.tl-event.open   { color: var(--red); }
.tl-event.closed { color: var(--green); }
.tl-dur {
  margin-left: auto;
  font-family: var(--mono);
  font-size: .68rem;
  color: var(--dim);
}

/* ============================================================
   TABLE
   ============================================================ */
.table-header {
  padding: 10px 2px 4px;
  margin-top: 10px;
  border-top: 1px solid var(--border);
}
.table-wrap {
  background: var(--surf);
  border: 1px solid var(--border);
  border-radius: var(--rl);
  overflow: auto;
  max-height: 380px;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.02);
}
table { width: 100%; border-collapse: collapse; }
thead {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--surf2);
}
th {
  font-family: var(--cond);
  font-size: .62rem;
  font-weight: 700;
  letter-spacing: .16em;
  color: var(--muted);
  text-align: left;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
td {
  font-family: var(--mono);
  font-size: .76rem;
  padding: 8px 14px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  color: var(--text);
  transition: background .12s;
}
tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--surf2); }
tr:hover td:first-child {
  border-left: 2px solid var(--amber);
  padding-left: 12px;
}
/* New row slide-in */
tr.row-new td {
  animation: rowSlideIn .35s var(--ease-out-expo) both;
}

.td-door-closed { color: var(--green); font-weight: 700; }
.td-door-open   { color: var(--red);   font-weight: 700; }
.aqi-good     { color: var(--green); }
.aqi-moderate { color: var(--orange); }
.aqi-bad      { color: var(--red); }

/* ============================================================
   SCROLLBAR
   ============================================================ */
::-webkit-scrollbar { width: 4px; height: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: rgba(245,158,11,.2);
  border-radius: 2px;
}
::-webkit-scrollbar-thumb:hover { background: rgba(245,158,11,.5); }

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 1200px) {
  .primary-grid { grid-template-columns: repeat(2, 1fr); }
  .charts-grid  { grid-template-columns: 1fr; }
}
@media (max-width: 900px) {
  .secondary-grid { grid-template-columns: repeat(2, 1fr); }
  .header-center  { display: none; }
}
@media (max-width: 640px) {
  main            { padding: 14px 14px 40px; }
  header          { padding: 0 14px; }
  .primary-grid   { grid-template-columns: 1fr; }
  .secondary-grid { grid-template-columns: 1fr; }
  .big-value      { font-size: 2.4rem; }
  .hdr-update     { display: none; }
}
