/* ==========================================================================
   SAVER-KIT | Central Monitoring Hub Design System
   High-Fidelity Cyber-Glassmorphism UI (Matching Waveshare 5" Touch LCD)
   ========================================================================== */

:root {
  --bg-primary: #070b12;
  --bg-secondary: #0d1522;
  --card-bg: rgba(18, 27, 40, 0.78);
  --card-border: rgba(46, 75, 105, 0.5);
  --card-hover: rgba(26, 38, 56, 0.85);

  --cyan-neon: #00f0ff;
  --cyan-bright: #38ef7d;
  --cyan-glow: rgba(0, 240, 255, 0.45);
  
  --amber-neon: #ffaa00;
  --amber-glow: rgba(255, 170, 0, 0.5);

  --blue-neon: #2979ff;
  --blue-dark: #122842;

  --text-main: #f0f6fc;
  --text-muted: #8b9bb4;
  --text-dim: #546882;

  --font-main: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-tech: 'Chakra Petch', sans-serif;
  --font-digital: 'Orbitron', monospace;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html {
  overflow-x: auto;
  overflow-y: auto;
  -webkit-text-size-adjust: 100%;
}

body {
  background-color: var(--bg-primary);
  background-image: 
    radial-gradient(circle at 15% 15%, rgba(0, 240, 255, 0.04) 0%, transparent 40%),
    radial-gradient(circle at 85% 85%, rgba(41, 121, 255, 0.04) 0%, transparent 40%),
    linear-gradient(180deg, #070b12 0%, #0c1320 100%);
  color: var(--text-main);
  font-family: var(--font-main);
  min-height: 100vh;
  overflow-x: auto;
  overflow-y: auto;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding: 8px;
  -webkit-overflow-scrolling: touch;
}

/* Splash Screen */
.splash-screen {
  position: fixed;
  inset: 0;
  background: radial-gradient(circle at center, #0e192b 0%, #060a11 100%);
  z-index: 9999;
  display: flex;
  justify-content: center;
  align-items: center;
  transition: opacity 0.8s ease, visibility 0.8s;
}

.splash-screen.fade-out {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.splash-content {
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.splash-logo {
  width: 90px;
  height: 90px;
  margin-bottom: 20px;
}

.pulse-circle {
  animation: pulseRing 2s infinite ease-in-out;
}

@keyframes pulseRing {
  0% { stroke-width: 2; opacity: 0.4; }
  50% { stroke-width: 4; opacity: 1; filter: drop-shadow(0 0 10px #00f0ff); }
  100% { stroke-width: 2; opacity: 0.4; }
}

.splash-title {
  font-family: var(--font-tech);
  font-size: 3rem;
  letter-spacing: 5px;
  color: var(--cyan-neon);
  text-shadow: 0 0 20px var(--cyan-glow);
  margin-bottom: 4px;
}

.splash-acronym {
  font-family: var(--font-tech);
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: 2px;
  color: #38ef7d;
  text-shadow: 0 0 12px rgba(56, 239, 125, 0.45);
  margin-bottom: 6px;
  max-width: 650px;
}

.splash-subtitle {
  color: var(--text-muted);
  font-size: 0.85rem;
  letter-spacing: 2.5px;
  margin-bottom: 30px;
}

.splash-loader {
  width: 260px;
  height: 4px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 4px;
  overflow: hidden;
  position: relative;
}

.loader-bar {
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, #00f0ff, #38ef7d);
  animation: loadProgress 5s cubic-bezier(0.2, 0.8, 0.2, 1) forwards;
}

@keyframes loadProgress {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(0%); }
}

/* Sleep Overlay (Double tap to wake) */
.screen-sleep-overlay {
  position: fixed;
  inset: 0;
  background: #000000;
  z-index: 5000;
  display: flex;
  justify-content: center;
  align-items: center;
  cursor: pointer;
  transition: opacity 0.4s ease;
}

.screen-sleep-overlay.hidden {
  display: none;
}

.sleep-hint {
  color: rgba(255, 255, 255, 0.45);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  font-size: 0.95rem;
  letter-spacing: 1px;
  animation: breathe 3s infinite ease-in-out;
}

@keyframes breathe {
  0%, 100% { opacity: 0.3; }
  50% { opacity: 0.8; }
}

/* Main Container: Flexible, Scrollable & Mobile-Optimized */
.app-container {
  width: 100%;
  max-width: 1150px;
  min-height: calc(100vh - 16px);
  height: auto;
  display: flex;
  flex-direction: column;
  padding: 12px 16px 24px 16px;
  background: rgba(10, 16, 26, 0.95);
  box-shadow: 0 0 50px rgba(0, 0, 0, 0.8);
  border-radius: 12px;
  overflow: visible;
  position: relative;
  margin: 0 auto;
}

/* TOP NAVIGATION BAR */
.top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 52px;
  margin-bottom: 10px;
  padding: 0 4px;
}

/* Hamburger Menu Button */
.hamburger-btn {
  background: rgba(22, 34, 50, 0.8);
  border: 1px solid var(--card-border);
  border-radius: 8px;
  width: 44px;
  height: 42px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
}

.hamburger-btn:hover, .hamburger-btn:active {
  background: rgba(35, 54, 78, 0.9);
  border-color: var(--cyan-neon);
  box-shadow: 0 0 10px var(--cyan-glow);
}

.hamburger-icon {
  width: 20px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.hamburger-icon span {
  display: block;
  height: 2.5px;
  background: #a2bcd9;
  border-radius: 2px;
}

/* Brand Title */
.brand-container {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-left: 12px;
}

.brand-text {
  font-family: var(--font-tech);
  font-size: 1.65rem;
  font-weight: 700;
  letter-spacing: 2px;
  color: var(--cyan-neon);
  text-shadow: 0 0 12px var(--cyan-glow);
}

.animated-saver {
  animation: logoGlow 4s infinite ease-in-out;
}

@keyframes logoGlow {
  0%, 100% { text-shadow: 0 0 8px rgba(0, 240, 255, 0.4); }
  50% { text-shadow: 0 0 18px rgba(0, 240, 255, 0.85), 0 0 25px rgba(0, 240, 255, 0.4); }
}

.node-badge {
  background: rgba(0, 240, 255, 0.12);
  border: 1px solid rgba(0, 240, 255, 0.3);
  color: #72ecff;
  font-size: 0.72rem;
  padding: 3px 8px;
  border-radius: 12px;
  font-weight: 500;
}

/* Clock Widget */
.clock-widget {
  text-align: center;
  margin: 0 auto;
}

.time-display {
  font-family: var(--font-main);
  font-size: 1.85rem;
  font-weight: 600;
  color: #ffffff;
  letter-spacing: 1px;
  line-height: 1.1;
}

.date-display {
  font-size: 0.72rem;
  color: #8fa0b5;
  letter-spacing: 0.5px;
}

/* Status Group on Top Right */
.status-group {
  display: flex;
  align-items: center;
  gap: 12px;
}

.status-item {
  background: rgba(18, 28, 42, 0.7);
  border: 1px solid var(--card-border);
  border-radius: 8px;
  padding: 4px 10px;
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-main);
  cursor: pointer;
  transition: all 0.2s;
}

.status-item:hover {
  border-color: rgba(0, 240, 255, 0.4);
}

.wifi-status {
  flex-direction: column;
  padding: 3px 10px;
  gap: 1px;
}

.wifi-icon {
  width: 20px;
  height: 20px;
  fill: var(--cyan-neon);
  filter: drop-shadow(0 0 4px var(--cyan-glow));
}

.status-sub {
  font-size: 0.65rem;
  color: #a0b2c6;
  font-weight: 500;
}

/* Blynk Badge */
.blynk-badge {
  border: 1px solid #1fa37a;
  background: rgba(13, 46, 38, 0.5);
  box-shadow: 0 0 10px rgba(31, 163, 122, 0.25);
}

.blynk-icon-wrapper {
  position: relative;
  color: #38ef7d;
}

.blynk-sparkle {
  position: absolute;
  top: -6px;
  right: -6px;
  font-size: 10px;
  color: #fffa65;
  animation: sparkleRotate 3s infinite linear;
}

@keyframes sparkleRotate {
  0% { transform: rotate(0deg) scale(0.9); }
  50% { transform: rotate(180deg) scale(1.2); }
  100% { transform: rotate(360deg) scale(0.9); }
}

.blynk-text {
  display: flex;
  flex-direction: column;
  text-align: left;
}

.blynk-title {
  font-size: 0.68rem;
  color: #38ef7d;
  font-weight: 600;
  line-height: 1.1;
}

.blynk-sub {
  font-size: 0.62rem;
  color: #9fe2bf;
}

/* MicroSD Badge */
.sd-status {
  padding: 4px 10px;
}

.sd-icon {
  color: #a4b8cc;
}

.sd-text {
  display: flex;
  flex-direction: column;
  text-align: left;
}

.sd-title {
  font-size: 0.68rem;
  color: #e0e8f0;
  font-weight: 600;
  line-height: 1.1;
}

.sd-sub {
  font-size: 0.62rem;
  color: #8da2bb;
}

/* DASHBOARD MAIN GRID */
.dashboard-grid {
  display: grid;
  grid-template-columns: 290px 200px 1fr;
  gap: 12px;
  flex: 1;
  min-height: 0;
}

/* Glass Card Baseline */
.glass-card {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: 12px;
  backdrop-filter: blur(14px);
  position: relative;
  overflow: hidden;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
}

.card-glow-reflection {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 40%;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.04) 0%, transparent 100%);
  pointer-events: none;
}

.card-header-cyan {
  font-family: var(--font-tech);
  font-size: 0.88rem;
  color: #4ed8ea;
  letter-spacing: 1px;
  font-weight: 600;
  margin-bottom: 8px;
}

/* ==========================================================================
   COLUMN 1: PZEM-004T DUAL METERS
   ========================================================================== */
.col-left {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.pzem-card {
  padding: 12px 14px;
}

.pzem-card-large {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.pzem-metrics-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.pzem-metrics-grid.row-2 {
  margin-top: 6px;
  border-top: 1px solid rgba(46, 75, 105, 0.3);
  padding-top: 8px;
}

.metric-block {
  display: flex;
  flex-direction: column;
}

.metric-label-top {
  font-size: 0.72rem;
  color: #728ca6;
  margin-bottom: 2px;
}

.metric-label-bottom {
  font-size: 0.72rem;
  color: #728ca6;
  margin-top: 2px;
}

.metric-value-box {
  display: flex;
  align-items: baseline;
  gap: 2px;
}

.digital-num {
  font-family: var(--font-main);
  font-size: 2.2rem;
  font-weight: 600;
  color: #e4f5ff;
  line-height: 1.1;
}

.digital-seven {
  font-family: var(--font-digital);
  font-size: 1.85rem;
  font-weight: 700;
  color: #c7f9ff;
  letter-spacing: -1px;
}

.metric-unit {
  font-size: 1.1rem;
  color: #79a5c9;
  font-weight: 400;
}

/* ==========================================================================
   COLUMN 2: RELAYS (1A, 1B, 2C, 2D)
   ========================================================================== */
.col-middle {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.relay-card {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  position: relative;
  transition: all 0.25s ease;
}

.relay-label {
  font-family: var(--font-main);
  font-size: 1.05rem;
  font-weight: 600;
  color: #e0eaf6;
  letter-spacing: 0.3px;
}

/* Pill Button */
.relay-pill-btn {
  width: 68px;
  height: 34px;
  border-radius: 20px;
  background: rgba(14, 21, 32, 0.9);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  outline: none;
}

.btn-text {
  font-family: var(--font-tech);
  font-size: 0.95rem;
  font-weight: 700;
  letter-spacing: 0.5px;
}

/* Relay Button Themes */
.btn-cyan.on {
  border: 2px solid var(--cyan-neon);
  box-shadow: 0 0 14px var(--cyan-glow), inset 0 0 6px var(--cyan-glow);
  color: var(--cyan-neon);
}

.relay-pill-btn.off,
.btn-blue.off,
.btn-dark.off,
.btn-cyan.off,
.btn-amber.off {
  border: 1.5px solid #6385ab !important;
  color: #ffffff !important;
  background: #2b415c !important;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.35);
  font-weight: 700;
}

.relay-pill-btn.off:hover,
.btn-blue.off:hover,
.btn-dark.off:hover {
  background: #395577 !important;
  border-color: #8bb0dc !important;
}

/* Glowing Neon Underline */
.neon-underline {
  position: absolute;
  bottom: 0;
  left: 14px;
  right: 14px;
  height: 2px;
  border-radius: 2px;
}

.line-cyan {
  background: var(--cyan-neon);
  box-shadow: 0 0 8px var(--cyan-neon);
}

.line-blue {
  background: #1e599b;
  box-shadow: 0 0 5px #1e599b;
}

/* ==========================================================================
   COLUMN 3: MODES & SENSORS
   ========================================================================== */
.col-right {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.mode-card {
  height: 46px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
}

.mode-label {
  font-size: 0.9rem;
  font-weight: 600;
  color: #e4edf8;
}

.mode-desc {
  font-weight: 400;
  font-size: 0.78rem;
  color: #8da4be;
  margin-left: 2px;
}

/* Custom Toggle Switch */
.toggle-switch {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
}

.toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-slider {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background-color: #1e2c3d;
  border: 1px solid #334a66;
  border-radius: 24px;
  transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.toggle-slider:before {
  position: absolute;
  content: "";
  height: 18px;
  width: 18px;
  left: 2px;
  bottom: 2px;
  background-color: #6a829e;
  border-radius: 50%;
  transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

input:checked + .toggle-slider {
  background-color: rgba(0, 240, 255, 0.2);
  border-color: var(--cyan-neon);
  box-shadow: 0 0 10px rgba(0, 240, 255, 0.4);
}

input:checked + .toggle-slider:before {
  transform: translateX(20px);
  background-color: var(--cyan-neon);
  box-shadow: 0 0 8px var(--cyan-neon);
}

/* Small Toggle for Mode D & E */
.switch-small {
  width: 36px;
  height: 20px;
}

.switch-small .toggle-slider:before {
  height: 14px;
  width: 14px;
  left: 2px;
  bottom: 2px;
}

.switch-small input:checked + .toggle-slider:before {
  transform: translateX(16px);
}

/* Mode D & Mode E Row */
.modes-de-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.mode-mini-card {
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 14px;
}

.mode-mini-label {
  font-size: 0.88rem;
  font-weight: 600;
  color: #d8e5f2;
}

/* LAYOUT SEJAJAR: TABEL HITUNGAN MUNDUR, STATUS TEMP ALARM, DAN TABEL SUHU */
.sensors-side-by-side {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

/* Dedicated Timer 2D Card */
.timer2d-card {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  align-items: center;
  padding: 12px 6px;
  text-align: center;
  border: 1px solid rgba(0, 240, 255, 0.25);
  background: rgba(13, 24, 38, 0.75);
  min-height: 118px;
}

.timer2d-card-title {
  font-family: var(--font-tech);
  font-size: 0.74rem;
  color: var(--cyan-neon);
  letter-spacing: 0.3px;
  margin-bottom: 4px;
}

.timer2d-time-display {
  font-family: 'Courier New', Courier, monospace;
  font-size: 1.35rem;
  font-weight: 700;
  color: #ffffff;
  letter-spacing: 0.5px;
  text-shadow: 0 0 10px rgba(0, 240, 255, 0.5);
  margin-bottom: 6px;
}

.timer2d-status-pill {
  font-size: 0.65rem;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 12px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  white-space: nowrap;
}

.timer2d-status-pill.standby {
  background: #1c2a3a;
  color: #8da4be;
  border: 1px solid #2e435c;
}

.timer2d-status-pill.active {
  background: rgba(0, 240, 255, 0.2);
  color: var(--cyan-neon);
  border: 1px solid var(--cyan-neon);
  box-shadow: 0 0 8px rgba(0, 240, 255, 0.4);
}

/* Dedicated Temp Alarm Card (Mode C - Relay 1B) */
.temp-alarm-card {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  align-items: center;
  padding: 12px 6px;
  text-align: center;
  border: 1px solid rgba(255, 170, 0, 0.3);
  background: rgba(13, 24, 38, 0.75);
  min-height: 118px;
}

.temp-alarm-card-title {
  font-family: var(--font-tech);
  font-size: 0.74rem;
  color: #ffaa00;
  letter-spacing: 0.3px;
  margin-bottom: 4px;
}

.temp-alarm-value-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-bottom: 6px;
}

.temp-alarm-sublabel {
  font-size: 0.62rem;
  color: #8da4be;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.temp-alarm-val-box {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 2px;
}

.temp-alarm-num {
  font-family: var(--font-main);
  font-size: 1.6rem;
  font-weight: 700;
  color: #ffc107;
  line-height: 1.1;
  text-shadow: 0 0 10px rgba(255, 170, 0, 0.4);
}

.temp-alarm-deg {
  font-size: 0.95rem;
  color: #94a3b8;
  font-weight: 600;
}

.temp-alarm-status-pill {
  font-size: 0.65rem;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 12px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  white-space: nowrap;
}

.temp-alarm-status-pill.standby {
  background: #1c2a3a;
  color: #8da4be;
  border: 1px solid #2e435c;
}

.temp-alarm-status-pill.monitoring {
  background: rgba(56, 239, 125, 0.15);
  color: #38ef7d;
  border: 1px solid #38ef7d;
  box-shadow: 0 0 6px rgba(56, 239, 125, 0.3);
}

.temp-alarm-status-pill.triggered {
  background: rgba(239, 68, 68, 0.25);
  color: #ff4d4f;
  border: 1px solid #ff4d4f;
  box-shadow: 0 0 10px rgba(255, 77, 79, 0.6);
  animation: pulse-alarm 1.2s infinite ease-in-out;
}

@keyframes pulse-alarm {
  0%, 100% { transform: scale(1); box-shadow: 0 0 6px rgba(255, 77, 79, 0.5); }
  50% { transform: scale(1.04); box-shadow: 0 0 14px rgba(255, 77, 79, 0.9); }
}

/* DHT22 Card */
.dht22-card {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  align-items: center;
  padding: 12px 6px;
  text-align: center;
  border: 1px solid rgba(78, 216, 234, 0.25);
  background: rgba(13, 24, 38, 0.75);
  min-height: 118px;
}

.dht22-label {
  font-size: 0.74rem;
  color: #4ed8ea;
  font-family: var(--font-tech);
  letter-spacing: 0.3px;
  margin-bottom: 4px;
}

.dht22-value-wrap {
  display: flex;
  align-items: baseline;
  justify-content: center;
}

.dht22-val {
  font-family: var(--font-main);
  font-size: 1.6rem;
  font-weight: 700;
  color: #ffffff;
  line-height: 1.1;
}

.dht22-deg {
  font-size: 0.95rem;
  color: #79a5c9;
  margin-left: 2px;
}

.dht22-humidity {
  font-size: 0.7rem;
  color: #8da5bf;
  margin-top: 4px;
}

/* DI BAWAH KEDUA TABEL: MQ-2 Gas Card */
.mq2-card {
  display: flex;
  flex-direction: column;
  padding: 12px 18px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(13, 24, 38, 0.7);
}

.mq2-flex-container {
  display: flex;
  align-items: center;
  justify-content: space-around;
  gap: 16px;
}

.gauge-wrapper {
  width: 110px;
  height: 65px;
  position: relative;
}

.gauge-svg {
  width: 100%;
  height: 100%;
  overflow: visible;
}

.gauge-needle-group {
  transition: transform 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
  transform-origin: 50px 55px;
}

.mq2-text-info {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
}

.mq2-label {
  font-family: var(--font-tech);
  font-size: 0.85rem;
  color: #8da4be;
  font-weight: 600;
}

.mq2-ppm-val {
  font-size: 1.35rem;
  color: #38ef7d;
  font-weight: 700;
  font-family: var(--font-tech);
}

.mq2-status-note {
  font-size: 0.75rem;
  color: #7995b4;
}

.pzem-branch-tag {
  font-size: 0.72rem;
  color: #8fa2b8;
  font-weight: normal;
  margin-left: 4px;
}

/* ==========================================================================
   SLIDE-OUT MENU DRAWER (Requirement 6)
   ========================================================================= */
.menu-drawer {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: 320px;
  max-width: 85vw;
  background: rgba(11, 18, 28, 0.95);
  border-right: 1px solid var(--card-border);
  backdrop-filter: blur(20px);
  z-index: 2000;
  transform: translateX(-100%);
  transition: transform 0.35s cubic-bezier(0.16, 1, 0.3, 1);
  display: flex;
  flex-direction: column;
  box-shadow: 10px 0 40px rgba(0, 0, 0, 0.7);
}

.menu-drawer.open {
  transform: translateX(0);
}

.drawer-header {
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  border-bottom: 1px solid var(--card-border);
}

.drawer-title-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
}

.drawer-title-wrap h3 {
  font-family: var(--font-tech);
  font-size: 1.1rem;
  color: var(--cyan-neon);
  letter-spacing: 1px;
}

.close-btn {
  background: none;
  border: none;
  color: #8aa0bb;
  font-size: 1.8rem;
  cursor: pointer;
  line-height: 1;
}

.drawer-content {
  flex: 1;
  overflow-y: auto;
  padding: 14px 12px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.drawer-section {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.section-title {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.72rem;
  letter-spacing: 1.5px;
  color: #6481a1;
  font-weight: 700;
  padding: 0 6px;
}

.node-count-pill {
  background: rgba(0, 240, 255, 0.15);
  color: var(--cyan-neon);
  padding: 2px 6px;
  border-radius: 10px;
  font-size: 0.65rem;
}

.menu-items-list, .nodes-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.drawer-item {
  background: rgba(18, 27, 40, 0.6);
  border: 1px solid rgba(46, 75, 105, 0.35);
  border-radius: 8px;
  padding: 10px 12px;
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  color: var(--text-main);
  text-align: left;
  transition: all 0.2s ease;
}

.drawer-item:hover, .drawer-item.active {
  background: rgba(28, 43, 64, 0.8);
  border-color: var(--cyan-neon);
}

.item-icon-box {
  color: var(--cyan-neon);
}

.item-text {
  flex: 1;
  display: flex;
  flex-direction: column;
}

.primary-text {
  font-size: 0.88rem;
  font-weight: 600;
  color: #e2eefb;
}

.secondary-text {
  font-size: 0.72rem;
  color: #7b94b0;
}

.chevron {
  color: #557291;
  font-size: 1.2rem;
}

/* Node Item in Menu */
.node-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(18, 27, 40, 0.5);
  border: 1px solid rgba(46, 75, 105, 0.3);
  border-radius: 8px;
  padding: 8px 12px;
  cursor: pointer;
  transition: all 0.2s;
}

.node-item:hover {
  background: rgba(26, 40, 58, 0.7);
}

.node-item.selected {
  border-color: var(--cyan-neon);
  box-shadow: 0 0 10px rgba(0, 240, 255, 0.25);
  background: rgba(20, 36, 54, 0.8);
}

.node-info-left {
  display: flex;
  align-items: center;
  gap: 8px;
}

.node-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #38ef7d;
  box-shadow: 0 0 6px #38ef7d;
}

.node-dot.offline {
  background: #5a6d80;
  box-shadow: none;
}

.node-name {
  font-size: 0.84rem;
  font-weight: 500;
  color: #e2edf8;
}

.node-status-tag {
  font-size: 0.68rem;
  color: #7894b0;
}

/* ==========================================================================
   MODAL DIALOGS (WiFi, Timeout, Database Query)
   ========================================================================== */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(6px);
  z-index: 3000;
}

.modal-backdrop.hidden,
.custom-modal.hidden,
.custom-modal.modal-wide.hidden {
  display: none !important;
}

.custom-modal {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 480px;
  max-width: 94vw;
  max-height: 88vh;
  display: flex;
  flex-direction: column;
  background: #0f1826;
  border: 1px solid var(--card-border);
  border-radius: 14px;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.85);
  z-index: 3100;
  overflow: hidden;
}

.custom-modal.modal-wide {
  width: 800px;
  max-width: 96vw;
  max-height: 88vh;
  display: flex;
  flex-direction: column;
}

.custom-modal.modal-wide.hidden {
  display: none !important;
}

.modal-header {
  flex-shrink: 0;
  padding: 14px 20px;
  border-bottom: 1px solid var(--card-border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-header h4 {
  font-family: var(--font-tech);
  font-size: 1.15rem;
  color: var(--cyan-neon);
  letter-spacing: 0.5px;
}

.modal-close {
  background: none;
  border: none;
  color: #7c94b0;
  font-size: 1.8rem;
  line-height: 1;
  padding: 4px 8px;
  cursor: pointer;
  transition: color 0.2s, transform 0.2s;
  pointer-events: auto;
  z-index: 3200;
}

.modal-close:hover {
  color: #ff5555;
  transform: scale(1.15);
}

.modal-body {
  flex: 1 1 auto;
  min-height: 0;
  padding: 18px 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  overflow-y: auto;
}

.modal-desc {
  font-size: 0.84rem;
  color: #92a9c3;
  line-height: 1.4;
}

.input-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.input-group label {
  font-size: 0.78rem;
  color: #7995b4;
}

.input-group input, select, input[type="datetime-local"] {
  background: rgba(22, 34, 50, 0.8);
  border: 1px solid var(--card-border);
  border-radius: 6px;
  padding: 8px 12px;
  color: #ffffff;
  font-family: var(--font-main);
  outline: none;
}

.input-group input:focus, select:focus {
  border-color: var(--cyan-neon);
}

/* WiFi scan list */
.wifi-scan-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.8rem;
  color: #7995b4;
}

.btn-refresh {
  background: rgba(0, 240, 255, 0.1);
  border: 1px solid rgba(0, 240, 255, 0.3);
  color: var(--cyan-neon);
  padding: 4px 10px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.76rem;
}

.wifi-list {
  max-height: 140px;
  overflow-y: auto;
  border: 1px solid var(--card-border);
  border-radius: 6px;
  background: rgba(14, 22, 33, 0.6);
}

.wifi-item {
  padding: 8px 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid rgba(46, 75, 105, 0.2);
  cursor: pointer;
  font-size: 0.82rem;
}

.wifi-item:hover, .wifi-item.selected {
  background: rgba(0, 240, 255, 0.12);
  color: var(--cyan-neon);
}

/* Timeout Radio Options */
.timeout-options-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.radio-option {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 12px;
  background: rgba(20, 31, 46, 0.6);
  border: 1px solid rgba(46, 75, 105, 0.3);
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s;
}

.radio-option:hover {
  background: rgba(30, 47, 69, 0.8);
}

.radio-option input {
  display: none;
}

.custom-radio {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 2px solid #587392;
  position: relative;
}

.radio-option input:checked + .custom-radio {
  border-color: var(--cyan-neon);
  box-shadow: 0 0 6px var(--cyan-glow);
}

.radio-option input:checked + .custom-radio:after {
  content: "";
  position: absolute;
  width: 8px;
  height: 8px;
  background: var(--cyan-neon);
  border-radius: 50%;
  top: 2px;
  left: 2px;
}

.opt-label {
  font-size: 0.88rem;
  color: #e0ecf8;
}

/* Database Query Controls */
.filter-controls-card {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  padding: 12px;
  background: rgba(18, 29, 44, 0.6);
  border-radius: 8px;
  border: 1px solid var(--card-border);
}

.filter-col {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
  min-width: 140px;
}

.filter-col label {
  font-size: 0.72rem;
  color: #7995b4;
}

.filter-actions {
  display: flex;
  align-items: flex-end;
  gap: 8px;
}

.btn-primary, .btn-export, .btn-cancel {
  padding: 8px 16px;
  border-radius: 6px;
  font-weight: 600;
  font-size: 0.82rem;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-primary {
  background: linear-gradient(135deg, #00d2ff 0%, #0077ff 100%);
  border: none;
  color: #ffffff;
  box-shadow: 0 0 10px rgba(0, 210, 255, 0.3);
}

.btn-primary:hover {
  filter: brightness(1.15);
}

.btn-export {
  background: rgba(56, 239, 125, 0.15);
  border: 1px solid #38ef7d;
  color: #38ef7d;
}

.btn-cancel {
  background: transparent;
  border: 1px solid #4a6380;
  color: #8da4be;
}

.modal-footer {
  flex-shrink: 0;
  padding: 14px 20px;
  border-top: 1px solid var(--card-border);
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  background: #0c1422;
}

/* Database Table */
.db-table-wrapper {
  max-height: 280px;
  overflow-y: auto;
  border: 1px solid var(--card-border);
  border-radius: 6px;
}

.db-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.76rem;
}

.db-table th {
  background: #142030;
  color: #7da0c5;
  padding: 8px 10px;
  text-align: left;
  position: sticky;
  top: 0;
}

.db-table td {
  padding: 7px 10px;
  border-top: 1px solid rgba(46, 75, 105, 0.2);
  color: #d8e5f2;
}

.db-table tr:hover {
  background: rgba(0, 240, 255, 0.05);
}

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

::-webkit-scrollbar-track {
  background: rgba(10, 16, 24, 0.5);
}

::-webkit-scrollbar-thumb {
  background: #2b4563;
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--cyan-neon);
}

/* ==========================================================================
   Relay 2D Mode E Countdown Timer & Spinner Styles
   ========================================================================== */
.timer2d-badge {
  display: flex;
  align-items: center;
  gap: 4px;
  background: rgba(0, 240, 255, 0.12);
  border: 1px solid rgba(0, 240, 255, 0.4);
  border-radius: 6px;
  padding: 2px 6px;
  margin-bottom: 4px;
  font-family: var(--font-tech, monospace);
  animation: pulse-border 2s infinite ease-in-out;
}

.timer2d-badge.hidden {
  display: none !important;
}

.timer2d-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #00f0ff;
  box-shadow: 0 0 6px #00f0ff;
  animation: blink-dot 1s infinite alternate;
}

@keyframes blink-dot {
  from { opacity: 0.3; }
  to { opacity: 1; }
}

@keyframes pulse-border {
  0%, 100% { border-color: rgba(0, 240, 255, 0.4); box-shadow: 0 0 4px rgba(0, 240, 255, 0.2); }
  50% { border-color: rgba(0, 240, 255, 0.8); box-shadow: 0 0 10px rgba(0, 240, 255, 0.4); }
}

.timer2d-txt {
  font-size: 0.58rem;
  font-weight: 700;
  color: #00f0ff;
  letter-spacing: 0.5px;
}

.timer2d-clock {
  font-size: 0.68rem;
  font-weight: 800;
  color: #ffffff;
  letter-spacing: 0.5px;
}

/* Spinner Controls in Modal */
.time-spinner-row {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 16px;
  background: #0a111b;
  border: 1px solid #1e334d;
  border-radius: 12px;
  padding: 20px 16px;
  margin: 10px auto;
  max-width: 440px;
}

.spinner-unit {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  width: 80px;
}

.spinner-arrow-btn {
  background: #192b40;
  border: 1px solid #00f0ff;
  color: #00f0ff;
  font-size: 1.1rem;
  width: 100%;
  height: 38px;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.15s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.spinner-arrow-btn:hover {
  background: #00f0ff;
  color: #04101e;
  box-shadow: 0 0 10px rgba(0, 240, 255, 0.5);
}

.spinner-arrow-btn:active {
  transform: scale(0.95);
}

.spinner-num-box {
  background: #0e1a2b;
  border: 1px solid #233b59;
  border-radius: 8px;
  width: 100%;
  height: 54px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  font-weight: 800;
  color: #ffffff;
  font-family: var(--font-tech, monospace);
  box-shadow: inset 0 2px 6px rgba(0, 0, 0, 0.6);
}

.spinner-unit-label {
  font-size: 0.72rem;
  font-weight: 700;
  color: #8fa2b8;
  letter-spacing: 1px;
}

.spinner-colon {
  font-size: 2.2rem;
  font-weight: 800;
  color: #00f0ff;
  margin-top: -24px;
}

/* ==========================================================================
   RESPONSIVE DESIGN (FLEXIBLE MOBILE, TABLET & DESKTOP SUPPORT)
   Allows touch scrolling & pinch-to-zoom with optimized handphone layouts
   ========================================================================== */

@media (max-width: 1024px) {
  .app-container {
    max-width: 100%;
    padding: 10px 12px 24px 12px;
  }

  .dashboard-grid {
    grid-template-columns: 280px 190px 1fr;
    gap: 10px;
  }
}

@media (max-width: 860px) {
  .dashboard-grid {
    grid-template-columns: 1fr;
    gap: 14px;
  }

  .col-middle {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
  }

  .relay-card {
    min-height: 54px;
  }

  .top-bar {
    height: auto;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: space-between;
  }

  .clock-widget {
    order: 3;
    width: 100%;
    margin-top: 4px;
    padding: 6px 0;
    border-top: 1px solid rgba(46, 75, 105, 0.25);
    border-bottom: 1px solid rgba(46, 75, 105, 0.25);
  }
}

@media (max-width: 600px) {
  body {
    padding: 4px;
  }

  .app-container {
    padding: 8px 8px 24px 8px;
    border-radius: 8px;
  }

  .brand-text {
    font-size: 1.35rem;
  }

  .status-group {
    gap: 6px;
  }

  .status-item {
    padding: 3px 6px;
  }

  .blynk-sub, .sd-sub {
    display: none;
  }

  .time-display {
    font-size: 1.45rem;
  }

  .col-middle {
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }

  .relay-label {
    font-size: 0.92rem;
  }

  .relay-pill-btn {
    width: 60px;
    height: 32px;
  }

  .pzem-metrics-grid {
    gap: 8px;
  }

  .digital-num {
    font-size: 1.7rem;
  }

  .digital-seven {
    font-size: 1.45rem;
  }

  /* Tiga Card Sejajar: Hitungan Mundur, Temp Alarm, Suhu & Kelembaban */
  .sensors-side-by-side {
    grid-template-columns: repeat(3, 1fr);
    gap: 6px;
  }

  .timer2d-card,
  .temp-alarm-card,
  .dht22-card {
    padding: 8px 4px;
    min-height: 108px;
  }

  .timer2d-card-title,
  .temp-alarm-card-title,
  .dht22-label {
    font-size: 0.62rem;
    letter-spacing: 0;
  }

  .timer2d-time-display {
    font-size: 1.05rem;
  }

  .temp-alarm-num,
  .dht22-val {
    font-size: 1.3rem;
  }

  .timer2d-status-pill,
  .temp-alarm-status-pill {
    font-size: 0.58rem;
    padding: 2px 4px;
  }

  .dht22-humidity {
    font-size: 0.62rem;
  }

  /* Modals on Mobile */
  .custom-modal,
  .custom-modal.modal-wide {
    width: 95vw;
    max-width: 95vw;
    max-height: 90vh;
  }

  .modal-header {
    padding: 12px 14px;
  }

  .modal-body {
    padding: 14px 14px;
  }

  .time-spinner-row {
    gap: 6px;
    padding: 12px 6px;
  }

  .spinner-unit {
    width: 65px;
  }

  .spinner-num-box {
    font-size: 1.6rem;
    height: 48px;
  }

  .spinner-colon {
    font-size: 1.6rem;
    margin-top: -16px;
  }

  .modal-footer {
    padding: 10px 14px;
    flex-wrap: wrap;
  }

  .btn-primary, .btn-cancel, .btn-export {
    flex: 1;
    min-height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
  }
}

@media (max-width: 380px) {
  .sensors-side-by-side {
    display: flex;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    gap: 8px;
    padding-bottom: 4px;
  }

  .timer2d-card,
  .temp-alarm-card,
  .dht22-card {
    flex: 0 0 115px;
    min-width: 115px;
  }

  .col-middle {
    grid-template-columns: 1fr;
  }
}

