/* ==========================================================================
   NexHome — Smart Living, Simplified
   Design Specification: Ambient Dark Glassmorphism & Bento Grid
   ========================================================================== */

:root {
  /* Surface & Canvas Tokens */
  --canvas-bg: #0A1017;
  --canvas-bg-end: #0E1722;
  --surface-header: rgba(18, 26, 36, 0.85);
  --surface-sidebar: #121A24;
  --surface-card: #131D29;
  --surface-glass: rgba(18, 24, 34, 0.65);
  --border-subtle: rgba(255, 255, 255, 0.08);
  --border-specular: inset 0 1px 0 0 rgba(255, 255, 255, 0.12);
  
  /* Brand Tokens */
  --brand-orange: #F27A24;
  --brand-orange-light: #FF923E;
  --brand-orange-dark: #D95B16;
  --brand-gradient: linear-gradient(135deg, #FF923E 0%, #D95B16 100%);
  --brand-glow: 0px 8px 24px rgba(242, 122, 36, 0.35);

  /* Semantic Palettes */
  --emerald-accent: #4ADE80;
  --emerald-glow: rgba(74, 222, 128, 0.25);
  --cyan-accent: #38BDF8;
  --cyan-glow: rgba(56, 189, 248, 0.25);
  --amber-accent: #F59E0B;
  --amber-glow: rgba(245, 158, 11, 0.25);
  --purple-accent: #A78BFA;
  --purple-glow: rgba(167, 139, 250, 0.25);
  --danger-red: #EF4444;

  /* Typography Colors */
  --text-primary: #FFFFFF;
  --text-secondary: #CBD5E1;
  --text-muted: #7E8C9F;
  --text-dim: #4B5563;

  /* Typography Fonts */
  --font-sans: 'Plus Jakarta Sans', 'Inter', -apple-system, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
  --font-script: 'Caveat', cursive;

  /* Elevation */
  --shadow-card: 0 12px 32px rgba(0, 0, 0, 0.35);
  --shadow-floating: 0 16px 40px rgba(0, 0, 0, 0.5);
  --radius-xl: 24px;
  --radius-lg: 20px;
  --radius-md: 14px;
  --radius-pill: 9999px;
}

/* Reset & Box Sizing */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  background: radial-gradient(circle at 10% 15%, #131E2C 0%, #0A1017 45%, #070B10 100%);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.45;
  min-height: 100vh;
  overflow-x: hidden;
  position: relative;
  -webkit-font-smoothing: antialiased;
}

/* Ambient Backdrop Glows */
.ambient-glow {
  position: fixed;
  border-radius: 50%;
  filter: blur(140px);
  pointer-events: none;
  z-index: 0;
}
.glow-top-left {
  top: -100px;
  left: 5%;
  width: 500px;
  height: 500px;
  background: rgba(242, 122, 36, 0.12);
}
.glow-bottom-right {
  bottom: -150px;
  right: 5%;
  width: 600px;
  height: 600px;
  background: rgba(56, 189, 248, 0.08);
}
.glow-center-warm {
  top: 40%;
  left: 45%;
  width: 450px;
  height: 450px;
  background: rgba(74, 222, 128, 0.06);
}

/* App Outer Container */
.app-container {
  max-width: 1720px;
  margin: 0 auto;
  padding: 16px 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-height: 100vh;
  position: relative;
  z-index: 1;
}

/* ==========================================================================
   1. TOP HEADER BAR (72px)
   ========================================================================== */
.top-header {
  height: 72px;
  background: var(--surface-header);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  box-shadow: var(--border-specular), 0 8px 24px rgba(0,0,0,0.25);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  gap: 20px;
}

/* Brand Cluster */
.brand-group {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-icon-box {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: linear-gradient(135deg, rgba(242, 122, 36, 0.2) 0%, rgba(242, 122, 36, 0.05) 100%);
  border: 1px solid rgba(242, 122, 36, 0.35);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  box-shadow: 0 0 16px rgba(242, 122, 36, 0.25);
}

.brand-svg {
  width: 24px;
  height: 24px;
  color: var(--brand-orange);
}

.brand-accent-dot {
  position: absolute;
  bottom: 8px;
  right: 8px;
  width: 6px;
  height: 6px;
  background: #FFF;
  border-radius: 50%;
  box-shadow: 0 0 8px #FFF;
}

.brand-title {
  font-size: 20px;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: #FFFFFF;
  line-height: 1.1;
}

.brand-subtitle {
  font-size: 11px;
  font-weight: 500;
  color: var(--text-muted);
}

/* Global Search Bar */
.search-bar {
  width: 420px;
  height: 44px;
  background: #141C27;
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-radius: var(--radius-pill);
  display: flex;
  align-items: center;
  padding: 0 14px;
  gap: 10px;
  transition: all 0.25s ease;
}

.search-bar:focus-within {
  border-color: rgba(242, 122, 36, 0.5);
  box-shadow: 0 0 16px rgba(242, 122, 36, 0.15);
  background: #172230;
}

.search-icon {
  width: 18px;
  height: 18px;
  color: var(--text-muted);
}

.search-bar input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: #FFF;
  font-size: 13px;
  font-family: inherit;
}

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

.search-filter-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  padding: 4px;
  border-radius: 6px;
  transition: color 0.2s;
}

.search-filter-btn:hover {
  color: #FFF;
}

.search-filter-btn svg {
  width: 16px;
  height: 16px;
}

/* User & Action Cluster */
.header-actions {
  display: flex;
  align-items: center;
  gap: 14px;
}

.connection-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.07);
  padding: 6px 14px;
  border-radius: var(--radius-pill);
  font-size: 12px;
  color: var(--text-secondary);
}

.status-indicator-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #64748B;
}

.status-indicator-dot.online {
  background: #10B981;
  box-shadow: 0 0 10px #10B981;
}

.status-indicator-dot.offline {
  background: #EF4444;
  box-shadow: 0 0 10px #EF4444;
}

.icon-circle-btn {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: #141C27;
  border: 1px solid rgba(255, 255, 255, 0.07);
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  cursor: pointer;
  transition: all 0.2s ease;
}

.icon-circle-btn:hover {
  background: #1B2636;
  color: #FFF;
  border-color: rgba(255, 255, 255, 0.15);
  transform: translateY(-1px);
}

.icon-circle-btn svg {
  width: 20px;
  height: 20px;
}

.badge-count {
  position: absolute;
  top: 6px;
  right: 6px;
  background: var(--brand-orange);
  color: #FFF;
  font-size: 10px;
  font-weight: 700;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 8px rgba(242, 122, 36, 0.6);
}

.user-pill {
  display: flex;
  align-items: center;
  gap: 10px;
  background: #141C27;
  border: 1px solid rgba(255, 255, 255, 0.07);
  padding: 4px 14px 4px 5px;
  border-radius: var(--radius-pill);
  cursor: pointer;
  transition: all 0.2s;
}

.user-pill:hover {
  background: #1A2535;
  border-color: rgba(255, 255, 255, 0.15);
}

.user-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  object-fit: cover;
  border: 1.5px solid rgba(242, 122, 36, 0.5);
}

.user-info {
  display: flex;
  flex-direction: column;
}

.user-name {
  font-size: 13px;
  font-weight: 600;
  color: #FFF;
  line-height: 1.2;
}

.user-role {
  font-size: 11px;
  color: var(--text-muted);
}

.chevron-down {
  width: 14px;
  height: 14px;
  color: var(--text-muted);
}

/* ==========================================================================
   2. BODY LAYOUT (Sidebar + Main Bento)
   ========================================================================== */
.app-body {
  display: flex;
  gap: 20px;
  flex: 1;
}

/* Sidebar Rail (84px) */
.sidebar-rail {
  width: 84px;
  background: var(--surface-sidebar);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-xl);
  box-shadow: var(--border-specular), 0 8px 30px rgba(0,0,0,0.3);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  align-items: center;
  padding: 24px 0 20px 0;
  flex-shrink: 0;
}

.nav-stack {
  display: flex;
  flex-direction: column;
  gap: 16px;
  width: 100%;
  align-items: center;
}

.nav-item {
  width: 60px;
  height: 64px;
  border-radius: 18px;
  background: transparent;
  border: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
}

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

.nav-item.active {
  background: linear-gradient(135deg, rgba(242, 122, 36, 0.22) 0%, rgba(217, 91, 22, 0.08) 100%);
  border: 1px solid rgba(242, 122, 36, 0.4);
  color: #FFA552;
  box-shadow: 0 4px 20px rgba(242, 122, 36, 0.25);
}

.nav-item.active::before {
  content: '';
  position: absolute;
  left: -12px;
  top: 18px;
  bottom: 18px;
  width: 4px;
  border-radius: 0 4px 4px 0;
  background: var(--brand-orange);
  box-shadow: 0 0 12px var(--brand-orange);
}

.nav-icon-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
}

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

.nav-label {
  font-size: 11px;
  font-weight: 500;
}

.sidebar-footer-quote {
  padding: 8px 4px;
  text-align: center;
}

.script-quote {
  font-family: var(--font-script);
  font-size: 17px;
  color: #E07A38;
  display: block;
  transform: rotate(-10deg);
  letter-spacing: 0.5px;
  opacity: 0.85;
}

/* ==========================================================================
   3. MAIN BENTO WORKSPACE (12 Columns)
   ========================================================================== */
.bento-workspace {
  flex: 1;
  display: grid;
  grid-template-columns: 4.2fr 7.8fr;
  gap: 20px;
}

/* Common Bento Card Styles */
.bento-card {
  background: var(--surface-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-xl);
  box-shadow: var(--border-specular), var(--shadow-card);
  position: relative;
  overflow: hidden;
  transition: transform 0.25s ease, box-shadow 0.25s ease, border-color 0.25s ease;
}

.bento-card:hover {
  border-color: rgba(255, 255, 255, 0.13);
  box-shadow: var(--border-specular), 0 16px 40px rgba(0, 0, 0, 0.45);
}

.card-header-flex {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 22px 10px 22px;
}

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

.card-title {
  font-size: 16px;
  font-weight: 700;
  color: #FFFFFF;
  line-height: 1.2;
}

.card-subtitle {
  font-size: 11px;
  color: var(--text-muted);
}

.badge-icon-sq {
  width: 38px;
  height: 38px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.badge-icon-sq svg {
  width: 20px;
  height: 20px;
}

.glow-emerald {
  background: rgba(74, 222, 128, 0.12);
  border: 1px solid rgba(74, 222, 128, 0.3);
  box-shadow: 0 0 14px rgba(74, 222, 128, 0.15);
}

.glow-orange {
  background: rgba(242, 122, 36, 0.12);
  border: 1px solid rgba(242, 122, 36, 0.3);
  box-shadow: 0 0 14px rgba(242, 122, 36, 0.15);
}

/* ==========================================================================
   LEFT COLUMN WIDGETS
   ========================================================================== */
.bento-col-left {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* 1. WEATHER CARD */
.card-weather {
  background: linear-gradient(150deg, #162B44 0%, #2A2438 50%, #121C2B 100%);
  min-height: 230px;
  display: flex;
  flex-direction: column;
  position: relative;
}

.weather-backdrop-art {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  opacity: 0.5;
  pointer-events: none;
  overflow: hidden;
}

.mountain-svg {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.card-weather .card-content-wrap {
  position: relative;
  z-index: 2;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  height: 100%;
  padding: 18px 22px;
}

.card-meta-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.location-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 600;
  color: #FFF;
  background: rgba(0, 0, 0, 0.25);
  backdrop-filter: blur(8px);
  padding: 4px 10px;
  border-radius: var(--radius-pill);
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.location-badge svg {
  width: 14px;
  height: 14px;
  color: #FBBF24;
}

.weather-date {
  font-size: 11px;
  color: var(--text-secondary);
}

.weather-main-row {
  display: flex;
  align-items: center;
  gap: 18px;
  margin: 12px 0;
}

.weather-illustration-box {
  width: 64px;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.weather-icon-3d {
  width: 60px;
  height: 60px;
}

.weather-hero-temp {
  display: flex;
  align-items: baseline;
  gap: 4px;
  flex-wrap: wrap;
}

.hero-temp-num {
  font-size: 46px;
  font-weight: 800;
  letter-spacing: -0.03em;
  color: #FFFFFF;
  line-height: 1;
}

.hero-temp-unit {
  font-size: 22px;
  font-weight: 600;
  color: #FDE68A;
  margin-right: 12px;
}

.hero-condition {
  font-size: 14px;
  font-weight: 600;
  color: #CBD5E1;
  background: rgba(255,255,255,0.06);
  padding: 3px 10px;
  border-radius: var(--radius-pill);
}

.weather-metrics-footer {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  background: rgba(14, 22, 33, 0.7);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 16px;
  padding: 10px 14px;
}

.metric-pill {
  display: flex;
  align-items: center;
  gap: 8px;
}

.metric-pill svg {
  width: 18px;
  height: 18px;
  color: #38BDF8;
  flex-shrink: 0;
}

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

.m-val {
  font-size: 12px;
  font-weight: 700;
  color: #FFF;
}

.m-lbl {
  font-size: 10px;
  color: var(--text-muted);
}

.text-emerald {
  color: #4ADE80 !important;
}

/* 2. AIR QUALITY WIDGET */
.card-airquality {
  background: linear-gradient(155deg, #0D4230 0%, #09221E 60%, #0A1817 100%);
  min-height: 190px;
}

.status-badge-emerald {
  background: #10B981;
  color: #064E3B;
  font-size: 11px;
  font-weight: 700;
  padding: 4px 12px;
  border-radius: var(--radius-pill);
  box-shadow: 0 0 12px rgba(16, 185, 129, 0.4);
}

.aqi-dual-zone {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  padding: 4px 20px 18px 20px;
  align-items: center;
}

.gauge-col {
  display: flex;
  justify-content: center;
}

.gauge-svg-wrap {
  position: relative;
  width: 140px;
  height: 100px;
}

.circular-gauge {
  width: 100%;
  height: 100%;
}

.gauge-inner-label {
  position: absolute;
  top: 36px;
  left: 0;
  right: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}

.gauge-sub {
  font-size: 10px;
  font-weight: 700;
  color: #6EE7B7;
  letter-spacing: 0.5px;
}

.gauge-metric-value {
  font-size: 28px;
  font-weight: 800;
  color: #FFF;
  line-height: 1.1;
}

.gauge-note {
  font-size: 9px;
  color: var(--text-muted);
}

.sparkline-col {
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-radius: 16px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.sparkline-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
}

.spark-icon-row {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  color: var(--text-secondary);
}

.spark-icon-row svg {
  width: 14px;
  height: 14px;
  color: #34D399;
}

.spark-number {
  font-size: 14px;
  font-weight: 700;
  color: #FFF;
}

.sparkline-graphic {
  width: 100%;
  height: 38px;
}

.spark-foot-sub {
  font-size: 10px;
  color: var(--text-muted);
}

/* 3. TEMPERATURE & THERMOSTAT DIAL */
.card-thermostat {
  background: linear-gradient(155deg, #4A2B13 0%, #201713 60%, #151110 100%);
  min-height: 220px;
}

.eco-pill {
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(74, 222, 128, 0.12);
  border: 1px solid rgba(74, 222, 128, 0.25);
  color: #4ADE80;
  padding: 4px 10px;
  border-radius: var(--radius-pill);
  font-size: 11px;
  font-weight: 600;
}

.eco-pill svg {
  width: 14px;
  height: 14px;
}

.thermostat-dial-box {
  padding: 6px 20px 18px 20px;
  display: flex;
  justify-content: center;
}

.dial-svg-wrap {
  position: relative;
  width: 220px;
  height: 145px;
  display: flex;
  justify-content: center;
}

.thermo-arc-svg {
  width: 100%;
  height: 100%;
}

.dial-center-content {
  position: absolute;
  top: 40px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}

.dial-temp-text {
  font-size: 32px;
  font-weight: 800;
  color: #FFF;
  line-height: 1;
}

.dial-temp-text small {
  font-size: 18px;
  color: #F97316;
}

.dial-status-chip {
  margin-top: 6px;
  display: flex;
  align-items: center;
  gap: 5px;
  background: rgba(56, 189, 248, 0.12);
  border: 1px solid rgba(56, 189, 248, 0.25);
  padding: 3px 10px;
  border-radius: var(--radius-pill);
  font-size: 11px;
  color: #38BDF8;
}

.dial-status-chip svg {
  width: 12px;
  height: 12px;
}

.dial-adj-btn {
  position: absolute;
  bottom: 0;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: #FFF;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
  backdrop-filter: blur(8px);
}

.dial-adj-btn:hover {
  background: rgba(255, 255, 255, 0.18);
  transform: scale(1.08);
}

.btn-minus {
  left: 10px;
}

.btn-plus {
  right: 10px;
}

.dial-adj-btn svg {
  width: 16px;
  height: 16px;
}

/* ==========================================================================
   RIGHT COLUMN: HERO CAM & BOTTOM SUBGRID
   ========================================================================== */
.bento-col-right {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* 4. HERO ROOM VISUALIZER (Living Room Camera / AR Hub) */
.card-cam-visualizer {
  height: 390px;
  position: relative;
  background: #000;
  border: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: var(--border-specular), 0 16px 40px rgba(0,0,0,0.5);
}

.camera-stage-bg {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-size: cover;
  background-position: center;
  z-index: 1;
}

.cam-vignette-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: radial-gradient(circle at center, rgba(10, 16, 23, 0.1) 0%, rgba(10, 16, 23, 0.75) 100%);
}

/* Top Room Selector Bar */
.cam-room-selector {
  position: absolute;
  top: 18px;
  left: 22px;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(14, 22, 33, 0.6);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  padding: 5px;
  border-radius: var(--radius-pill);
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.room-tab {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 500;
  padding: 6px 14px;
  border-radius: var(--radius-pill);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: all 0.2s ease;
}

.room-tab:hover {
  color: #FFF;
}

.room-tab.active {
  background: var(--brand-gradient);
  color: #FFF;
  font-weight: 700;
  box-shadow: 0 2px 12px rgba(242, 122, 36, 0.4);
}

.room-tab.active svg {
  width: 14px;
  height: 14px;
}

.chevron-sm {
  width: 12px;
  height: 12px;
}

/* Interactive IoT Node Stage */
.iot-node-stage {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 5;
  pointer-events: none;
}

.node-connector-svg {
  width: 100%;
  height: 100%;
  position: absolute;
  top: 0;
  left: 0;
}

.iot-node {
  position: absolute;
  pointer-events: auto;
  border-radius: 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
}

.iot-node:hover {
  transform: scale(1.08);
  border-color: rgba(255, 255, 255, 0.3) !important;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.6);
}

/* Center Core Gateway Node */
.hub-center-node {
  top: 48%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 64px;
  height: 64px;
  border-radius: 20px;
  background: rgba(18, 26, 38, 0.85);
  backdrop-filter: blur(14px);
  border: 1.5px solid rgba(56, 189, 248, 0.4);
}

.hub-center-node svg {
  width: 30px;
  height: 30px;
}

.node-pulse-ring {
  position: absolute;
  top: -6px;
  left: -6px;
  right: -6px;
  bottom: -6px;
  border-radius: 24px;
  border: 1px dashed rgba(56, 189, 248, 0.5);
  animation: spinSlow 20s linear infinite;
}

@keyframes spinSlow {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

/* Satellite Nodes (48px) */
.sat-node {
  width: 52px;
  height: 52px;
  background: rgba(18, 24, 34, 0.75);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.12);
  gap: 3px;
}

.sat-node svg {
  width: 20px;
  height: 20px;
}

.node-label {
  font-size: 9px;
  font-weight: 600;
  color: #CBD5E1;
}

.node-lighting {
  top: 25%;
  left: 25%;
}

.node-doorlock {
  top: 68%;
  left: 22%;
}

.node-tv {
  top: 74%;
  left: 48%;
  transform: translateX(-50%);
}

.node-wifi {
  top: 25%;
  right: 25%;
}

.node-ac {
  top: 68%;
  right: 23%;
}

/* Floating Vertical Brightness Slider */
.floating-slider-capsule {
  position: absolute;
  top: 50%;
  right: 22px;
  transform: translateY(-50%);
  z-index: 10;
  width: 48px;
  height: 250px;
  background: rgba(14, 22, 33, 0.75);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: var(--radius-pill);
  box-shadow: 0 10px 30px rgba(0,0,0,0.4);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  padding: 12px 6px;
}

.slider-top-icon svg {
  width: 18px;
  height: 18px;
}

.slider-pct-label {
  font-size: 11px;
  font-weight: 700;
  color: #FFF;
  margin: 2px 0;
}

.slider-track-wrap {
  width: 12px;
  flex: 1;
  background: rgba(255, 255, 255, 0.1);
  border-radius: var(--radius-pill);
  position: relative;
  margin: 8px 0;
  cursor: pointer;
  overflow: hidden;
}

.slider-fill-bar {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: linear-gradient(to top, #D95B16, #FF923E);
  border-radius: var(--radius-pill);
  transition: height 0.15s ease;
  box-shadow: 0 0 10px rgba(242, 122, 36, 0.5);
}

.slider-pwr-btn {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
}

.slider-pwr-btn.on {
  background: var(--brand-orange);
  color: #FFF;
  border-color: #FFA552;
  box-shadow: 0 0 12px rgba(242, 122, 36, 0.6);
}

.slider-pwr-btn svg {
  width: 15px;
  height: 15px;
}

/* Bottom Camera Action Controls */
.cam-bottom-actions {
  position: absolute;
  bottom: 16px;
  left: 22px;
  right: 22px;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.cam-pill-live {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(14, 22, 33, 0.7);
  backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  padding: 5px 14px;
  border-radius: var(--radius-pill);
  font-size: 12px;
  font-weight: 600;
  color: #FFF;
}

.live-dot-pulse {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #EF4444;
  box-shadow: 0 0 10px #EF4444;
  animation: pulseDot 1.5s infinite;
}

@keyframes pulseDot {
  0% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.4); opacity: 0.6; }
  100% { transform: scale(1); opacity: 1; }
}

.cam-pill-group {
  display: flex;
  align-items: center;
  gap: 10px;
}

.cam-action-pill {
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(14, 22, 33, 0.7);
  backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: var(--text-secondary);
  font-size: 12px;
  padding: 6px 14px;
  border-radius: var(--radius-pill);
  cursor: pointer;
  transition: all 0.2s ease;
}

.cam-action-pill:hover {
  background: rgba(255, 255, 255, 0.15);
  color: #FFF;
}

.cam-action-pill svg {
  width: 14px;
  height: 14px;
}

/* ==========================================================================
   ROW 2 (~44% Height): SPLIT SUBGRID (2x2 Toggles & Power Chart)
   ========================================================================== */
.bento-row-bottom {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

/* SUBGRID LEFT: 2x2 DEVICE TOGGLE MATRIX */
.device-matrix-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.dev-card {
  border-radius: var(--radius-lg);
  padding: 16px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-height: 135px;
  position: relative;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  border: 1px solid var(--border-subtle);
}

.dev-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.dev-icon-circle {
  width: 38px;
  height: 38px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.dev-icon-circle svg {
  width: 18px;
  height: 18px;
}

.dev-name {
  font-size: 15px;
  font-weight: 700;
  color: #FFF;
  line-height: 1.2;
}

.dev-room {
  font-size: 11px;
  color: var(--text-muted);
}

.dev-status-tag {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-secondary);
}

/* Device Semantic Tints when ACTIVE vs INACTIVE */
.card-lighting.active {
  background: linear-gradient(145deg, #523018 0%, #241914 70%, #171415 100%);
  border-color: rgba(245, 158, 11, 0.25);
  box-shadow: 0 8px 24px rgba(245, 158, 11, 0.15);
}
.icon-glow-amber {
  background: rgba(245, 158, 11, 0.15);
  color: #F59E0B;
}

.card-ac.active {
  background: linear-gradient(145deg, #123C4A 0%, #10212B 70%, #0C161C 100%);
  border-color: rgba(56, 189, 248, 0.25);
  box-shadow: 0 8px 24px rgba(56, 189, 248, 0.15);
}
.icon-glow-cyan {
  background: rgba(56, 189, 248, 0.15);
  color: #38BDF8;
}

.card-doorlock.active {
  background: linear-gradient(145deg, #2C225A 0%, #191630 70%, #11101C 100%);
  border-color: rgba(167, 139, 250, 0.25);
  box-shadow: 0 8px 24px rgba(167, 139, 250, 0.15);
}
.icon-glow-purple {
  background: rgba(167, 139, 250, 0.15);
  color: #A78BFA;
}

.card-water.active {
  background: linear-gradient(145deg, #103D2D 0%, #0E221D 70%, #0A1714 100%);
  border-color: rgba(52, 211, 153, 0.25);
  box-shadow: 0 8px 24px rgba(52, 211, 153, 0.15);
}
.icon-glow-emerald {
  background: rgba(52, 211, 153, 0.15);
  color: #34D399;
}

.water-mini-badge {
  background: rgba(52, 211, 153, 0.15);
  color: #34D399;
  font-size: 11px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: var(--radius-pill);
}

/* Inactive State */
.dev-card:not(.active) {
  background: #141C26 !important;
  border-color: rgba(255, 255, 255, 0.05) !important;
  box-shadow: none !important;
}

.dev-card:not(.active) .dev-icon-circle {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-muted);
}

.dev-card:not(.active) .dev-name {
  color: var(--text-muted);
}

/* Toggle Switch Component */
.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;
  top: 0; left: 0; right: 0; bottom: 0;
  background-color: rgba(255, 255, 255, 0.15);
  transition: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  border-radius: 24px;
}

.toggle-slider:before {
  position: absolute;
  content: "";
  height: 18px;
  width: 18px;
  left: 3px;
  bottom: 3px;
  background-color: #FFFFFF;
  transition: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  border-radius: 50%;
  box-shadow: 0 2px 5px rgba(0,0,0,0.4);
}

input:checked + .toggle-slider {
  background: var(--brand-gradient);
  box-shadow: 0 0 10px rgba(242, 122, 36, 0.5);
}

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

/* SUBGRID RIGHT: POWER CONSUMPTION ANALYTICS */
.card-power-chart {
  background: #111B27;
  padding: 16px 20px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.power-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.power-title-box {
  display: flex;
  align-items: center;
  gap: 10px;
}

.chart-mode-pill {
  display: flex;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-pill);
  padding: 2px;
}

.mode-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 600;
  padding: 4px 12px;
  border-radius: var(--radius-pill);
  cursor: pointer;
  transition: all 0.2s;
}

.mode-btn.active {
  background: var(--brand-orange);
  color: #FFF;
}

.power-metric-row {
  display: flex;
  align-items: baseline;
  gap: 16px;
  margin: 6px 0 2px 0;
}

.power-primary-number {
  display: flex;
  align-items: baseline;
  gap: 4px;
}

.num-bold {
  font-size: 30px;
  font-weight: 800;
  color: #FFF;
  line-height: 1;
}

.unit-text {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-secondary);
}

.power-trend-badge {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  font-weight: 600;
  color: #4ADE80;
}

.power-trend-badge svg {
  width: 14px;
  height: 14px;
}

.chart-canvas-container {
  height: 115px;
  position: relative;
  width: 100%;
}

/* ==========================================================================
   4. BOTTOM SUSTAINABILITY FOOTER (36px)
   ========================================================================== */
.bottom-footer {
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 8px;
  font-size: 12px;
  color: var(--text-muted);
}

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

.footer-left svg {
  width: 16px;
  height: 16px;
}

.footer-right {
  display: flex;
  align-items: center;
  gap: 16px;
}

.sync-clock {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-secondary);
}

.carousel-dots {
  display: flex;
  gap: 5px;
}

.carousel-dots .dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.2);
}

.carousel-dots .dot.active {
  background: var(--brand-orange);
  width: 16px;
  border-radius: 6px;
}

/* ==========================================================================
   DRAWER & MODALS
   ========================================================================== */
.drawer-backdrop,
.modal-backdrop {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  z-index: 100;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.drawer-backdrop.active,
.modal-backdrop.active {
  opacity: 1;
  pointer-events: auto;
}

/* Slideout Drawer */
.slideout-drawer {
  position: absolute;
  top: 0;
  right: -520px;
  bottom: 0;
  width: 500px;
  max-width: 90vw;
  background: #111A26;
  border-left: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: -10px 0 40px rgba(0,0,0,0.6);
  transition: right 0.35s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  flex-direction: column;
}

.drawer-backdrop.active .slideout-drawer {
  right: 0;
}

.drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.drawer-title-group {
  display: flex;
  align-items: center;
  gap: 10px;
}

.drawer-title-group h3 {
  font-size: 16px;
  font-weight: 700;
  color: #FFF;
}

.drawer-title-group svg {
  width: 20px;
  height: 20px;
}

.drawer-close-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 6px;
  border-radius: 8px;
}

.drawer-close-btn:hover {
  color: #FFF;
  background: rgba(255, 255, 255, 0.08);
}

.drawer-subbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 24px;
  background: rgba(0, 0, 0, 0.2);
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  font-size: 12px;
  color: var(--text-muted);
}

.drawer-subbar code {
  font-family: var(--font-mono);
  color: #F97316;
}

.btn-refresh-logs {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: #FFF;
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 11px;
  cursor: pointer;
}

.logs-list-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 16px 24px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.log-item-card {
  background: #152232;
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 12px;
  padding: 12px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.log-badge-tag {
  font-size: 10px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: var(--radius-pill);
  text-transform: uppercase;
}

.log-badge-tag.danger {
  background: rgba(239, 68, 68, 0.2);
  color: #F87171;
  border: 1px solid rgba(239, 68, 68, 0.3);
}

.log-badge-tag.warning {
  background: rgba(245, 158, 11, 0.2);
  color: #FBBF24;
  border: 1px solid rgba(245, 158, 11, 0.3);
}

.log-badge-tag.success {
  background: rgba(74, 222, 128, 0.2);
  color: #4ADE80;
  border: 1px solid rgba(74, 222, 128, 0.3);
}

.log-badge-tag.control {
  background: rgba(56, 189, 248, 0.2);
  color: #38BDF8;
  border: 1px solid rgba(56, 189, 248, 0.3);
}

.log-info-group {
  flex: 1;
}

.log-time {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-muted);
}

.log-msg {
  font-size: 12px;
  color: #FFF;
  margin-top: 2px;
}

/* Simulator Modal Card */
.sim-modal-card {
  width: 580px;
  max-width: 95vw;
  background: #111A26;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: var(--radius-xl);
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.7);
  overflow: hidden;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 24px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.modal-title-wrap {
  display: flex;
  align-items: center;
  gap: 12px;
}

.modal-title-wrap h3 {
  font-size: 16px;
  font-weight: 700;
  color: #FFF;
}

.modal-title-wrap span {
  font-size: 11px;
  color: var(--text-muted);
}

.modal-close-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 16px;
  cursor: pointer;
  padding: 4px 8px;
}

.sim-modal-body {
  padding: 20px 24px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.sim-panel {
  background: #152232;
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 14px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.sim-panel-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 13px;
  font-weight: 700;
  color: #FFF;
}

.sim-tag {
  font-family: var(--font-mono);
  font-size: 10px;
  color: #F97316;
  background: rgba(249, 115, 22, 0.12);
  padding: 2px 6px;
  border-radius: 4px;
}

.sim-inputs-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.sim-inputs-row input,
.sim-inputs-row select {
  background: #0E1622;
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: #FFF;
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 12px;
  font-family: inherit;
  outline: none;
}

.btn-sim-action {
  background: var(--brand-gradient);
  border: none;
  color: #FFF;
  font-weight: 600;
  font-size: 12px;
  padding: 8px 16px;
  border-radius: 8px;
  cursor: pointer;
  transition: opacity 0.2s;
}

.btn-sim-action:hover {
  opacity: 0.9;
}

.btn-danger-action {
  background: linear-gradient(135deg, #EF4444 0%, #DC2626 100%);
}

/* Doorbell Popup Alert Toast */
.doorbell-alert-banner {
  position: fixed;
  top: -120px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 200;
  transition: top 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.doorbell-alert-banner.active {
  top: 24px;
}

.doorbell-banner-content {
  background: linear-gradient(135deg, #7F1D1D 0%, #991B1B 100%);
  border: 1.5px solid #EF4444;
  box-shadow: 0 10px 40px rgba(239, 68, 68, 0.5);
  border-radius: var(--radius-pill);
  padding: 10px 24px;
  display: flex;
  align-items: center;
  gap: 16px;
}

.alert-icon-pulse {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: #DC2626;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: pulseBell 1s infinite alternate;
}

@keyframes pulseBell {
  from { transform: scale(1); box-shadow: 0 0 10px #EF4444; }
  to { transform: scale(1.15); box-shadow: 0 0 25px #EF4444; }
}

.alert-texts h4 {
  font-size: 14px;
  font-weight: 800;
  color: #FFF;
}

.alert-texts p {
  font-size: 11px;
  color: #FCA5A5;
}

.btn-ack-doorbell {
  background: #FFF;
  color: #7F1D1D;
  font-weight: 700;
  font-size: 12px;
  padding: 8px 18px;
  border-radius: var(--radius-pill);
  border: none;
  cursor: pointer;
  box-shadow: 0 2px 10px rgba(0,0,0,0.3);
}

/* ==========================================================================
   RESPONSIVE DESIGN GUIDELINES
   ========================================================================== */
@media (max-width: 1400px) {
  .bento-workspace {
    grid-template-columns: 1fr;
  }
  .card-cam-visualizer {
    height: 350px;
  }
}

@media (max-width: 992px) {
  .app-body {
    flex-direction: column;
  }
  .sidebar-rail {
    width: 100%;
    height: auto;
    flex-direction: row;
    padding: 10px 16px;
  }
  .nav-stack {
    flex-direction: row;
    justify-content: space-around;
  }
  .sidebar-footer-quote {
    display: none;
  }
  .top-header {
    height: auto;
    padding: 14px 18px;
  }
  .search-bar {
    width: 100%;
    order: 3;
  }
  .bento-row-bottom {
    grid-template-columns: 1fr;
  }
}

/* ==========================================================================
   PATCH & PENYESUAIAN: 3 LAMPU, ESP32-CAM LIVE FEED, AUTO FAN & BUG FIXES
   ========================================================================== */

/* Avatar Initial fallback (tidak bergantung gambar eksternal) */
.user-avatar-initial {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--brand-gradient);
  color: #FFF;
  font-size: 12px;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1.5px solid rgba(255, 255, 255, 0.25);
}

/* Fix bug hover meloncat pada node yang memakai translate */
.hub-center-node:hover {
  transform: translate(-50%, -50%) scale(1.08) !important;
}
.node-tv:hover {
  transform: translateX(-50%) scale(1.08) !important;
}

/* Status glow pada AR Sat Node saat aktif */
.sat-node.node-active {
  border-color: rgba(242, 122, 36, 0.65);
  box-shadow: 0 0 18px rgba(242, 122, 36, 0.35);
}
.iot-node-stage {
  transition: opacity 0.25s ease;
}
.iot-node-stage.hidden-overlay {
  opacity: 0;
  pointer-events: none;
}

/* Live Feed Image dari ESP32-CAM */
.camera-live-img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  z-index: 2;
  display: none;
}
.camera-live-img.visible {
  display: block;
}

/* Dot status live kamera (LIVE / STANDBY / OFF) */
.live-dot-pulse.standby {
  background: #F59E0B;
  box-shadow: 0 0 10px #F59E0B;
}
.live-dot-pulse.off {
  background: #64748B;
  box-shadow: none;
  animation: none;
}

/* Tombol Pemilih 3 Lampu di Slider Vertikal */
.floating-slider-capsule {
  height: 280px;
  padding: 10px 6px;
}
.slider-lamp-tabs {
  display: flex;
  flex-direction: column;
  gap: 4px;
  width: 100%;
  align-items: center;
}
.slider-lamp-btn {
  width: 28px;
  height: 20px;
  border-radius: 6px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-muted);
  font-size: 10px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s ease;
}
.slider-lamp-btn.active {
  background: var(--brand-gradient);
  color: #FFF;
  border-color: transparent;
  box-shadow: 0 0 8px rgba(242, 122, 36, 0.5);
}

/* Thumb Handle Slider Vertikal agar bisa di-drag mulus */
.slider-track-wrap {
  overflow: visible;
  touch-action: none;
}
.slider-thumb-handle {
  position: absolute;
  left: 50%;
  transform: translate(-50%, 50%);
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #FFFFFF;
  border: 2px solid var(--brand-orange);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.6);
  pointer-events: none;
  transition: bottom 0.08s ease;
}

/* Tombol Pemilih 3 Lampu di dalam Card Lighting */
.lamp-tabs-row {
  display: flex;
  gap: 6px;
  margin-top: 6px;
}
.lamp-tab-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(0, 0, 0, 0.25);
  color: var(--text-secondary);
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s ease;
}
.lamp-tab-btn.active {
  background: rgba(245, 158, 11, 0.25);
  border-color: rgba(245, 158, 11, 0.65);
  color: #FFF;
}
.lamp-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #64748B;
}
.lamp-dot.on {
  background: #F59E0B;
  box-shadow: 0 0 6px #F59E0B;
}

/* Mode Pill Thermostat (Interaktif AUTO vs MANUAL) */
button.eco-pill {
  cursor: pointer;
  font-family: inherit;
  transition: all 0.2s ease;
}
button.eco-pill:hover {
  transform: translateY(-1px);
  filter: brightness(1.15);
}
button.eco-pill.manual {
  background: rgba(245, 158, 11, 0.15);
  border-color: rgba(245, 158, 11, 0.35);
  color: #FBBF24;
}
.thermo-threshold-note {
  margin-top: 4px;
  font-size: 10px;
  color: var(--text-muted);
  white-space: nowrap;
}

/* RFID Monospace di Widget Kiri */
.uid-mono {
  font-family: var(--font-mono);
  font-size: 15px;
  letter-spacing: 0.05em;
  color: #34D399;
  margin: 4px 0;
}

/* Tombol Cepat Buka Pintu di Banner Bel */
.btn-doorbell-unlock {
  background: #10B981;
  color: #FFF;
  font-weight: 700;
  font-size: 12px;
  padding: 8px 16px;
  border-radius: var(--radius-pill);
  border: none;
  cursor: pointer;
  box-shadow: 0 2px 10px rgba(16, 185, 129, 0.4);
}
.btn-doorbell-unlock:hover {
  filter: brightness(1.1);
}

/* ==========================================================================
   3D PROTOTYPE VISUALIZER & DYNAMIC OVERLAY PINS
   ========================================================================== */

.hidden {
  display: none !important;
}

.prototype-3d-host {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  background: radial-gradient(circle at 50% 45%, #162436 0%, #0b131e 65%, #070c13 100%);
  z-index: 3;
  overflow: hidden;
}

.prototype-3d-canvas-mount,
.prototype-3d-canvas-mount canvas {
  width: 100% !important;
  height: 100% !important;
  display: block;
  outline: none;
}

.cam-standby-placeholder {
  position: absolute;
  inset: 0;
  z-index: 1;
  display: none;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 24px;
  color: var(--text-muted);
  font-size: 13px;
  background: radial-gradient(circle at center, #132032 0%, #091019 100%);
}

.card-cam-visualizer.mode-cam .prototype-3d-host {
  display: none;
}

.card-cam-visualizer.mode-cam .cam-standby-placeholder {
  display: flex;
}

/* Layer Tombol Overlay 3D yang Terproyeksi Mengikuti Komponen */
.overlay-3d-pins {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 6;
  transition: opacity 0.2s ease;
}

.iot-3d-pin {
  position: absolute;
  top: 0;
  left: 0;
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 5px 10px 5px 8px;
  border-radius: 999px;
  background: rgba(12, 19, 29, 0.78);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.14);
  color: #FFFFFF;
  cursor: pointer;
  font-family: inherit;
  white-space: nowrap;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.45);
  transition: border-color 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

.iot-3d-pin:hover {
  background: rgba(24, 36, 54, 0.92);
  border-color: rgba(255, 255, 255, 0.4);
  z-index: 20;
}

.pin-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #64748B;
  flex-shrink: 0;
}

.pin-text-col {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  line-height: 1.15;
}

.pin-title {
  font-size: 10px;
  font-weight: 700;
  color: #F8FAFC;
}

.pin-sub {
  font-size: 9px;
  color: var(--text-muted);
  font-family: var(--font-mono);
}

/* Warna status aktif per jenis komponen */
.iot-3d-pin.pin-amber.is-active {
  border-color: rgba(245, 158, 11, 0.75);
  box-shadow: 0 0 16px rgba(245, 158, 11, 0.35);
}
.iot-3d-pin.pin-amber.is-active .pin-dot {
  background: #F59E0B;
  box-shadow: 0 0 8px #F59E0B;
}

.iot-3d-pin.pin-cyan.is-active {
  border-color: rgba(56, 189, 248, 0.75);
  box-shadow: 0 0 16px rgba(56, 189, 248, 0.35);
}
.iot-3d-pin.pin-cyan.is-active .pin-dot {
  background: #38BDF8;
  box-shadow: 0 0 8px #38BDF8;
}

.iot-3d-pin.pin-purple.is-active {
  border-color: rgba(74, 222, 128, 0.75);
  box-shadow: 0 0 16px rgba(74, 222, 128, 0.35);
}
.iot-3d-pin.pin-purple.is-active .pin-dot {
  background: #4ADE80;
  box-shadow: 0 0 8px #4ADE80;
}

.iot-3d-pin.pin-emerald.is-active {
  border-color: rgba(239, 68, 68, 0.75);
  box-shadow: 0 0 16px rgba(239, 68, 68, 0.35);
}
.iot-3d-pin.pin-emerald.is-active .pin-dot {
  background: #EF4444;
  box-shadow: 0 0 8px #EF4444;
}

.iot-3d-pin.pin-orange.is-active {
  border-color: rgba(249, 115, 22, 0.75);
}
.iot-3d-pin.pin-orange .pin-dot {
  background: #F97316;
}

/* ==========================================================================
   TAB VISUALISASI 3D FULL WORKSPACE
   ========================================================================== */
.visualizer-full-workspace {
  flex: 1;
  display: flex;
  flex-direction: column;
}

.visualizer-stage-card {
  flex: 1;
  min-height: 680px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.viz-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  padding: 16px 22px;
  background: rgba(14, 22, 33, 0.85);
  border-bottom: 1px solid var(--border-subtle);
  z-index: 10;
}

.viz-title-group {
  display: flex;
  align-items: center;
  gap: 12px;
}

.viz-camera-presets {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.viz-preset-btn {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 600;
  padding: 6px 13px;
  border-radius: var(--radius-pill);
  cursor: pointer;
  font-family: inherit;
  transition: all 0.2s ease;
}

.viz-preset-btn:hover {
  background: rgba(255, 255, 255, 0.14);
  color: #FFF;
}

.viz-preset-btn.active {
  background: var(--brand-gradient);
  color: #FFF;
  border-color: transparent;
  box-shadow: 0 2px 12px rgba(242, 122, 36, 0.4);
}

.viz-preset-btn.accent {
  border-color: rgba(56, 189, 248, 0.35);
  color: #7DD3FC;
}

.viz-full-canvas-slot {
  position: relative;
  flex: 1;
  min-height: 520px;
}

.viz-bottom-dock {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 16px;
  padding: 14px 22px;
  background: rgba(14, 22, 33, 0.9);
  border-top: 1px solid var(--border-subtle);
  z-index: 10;
}

.viz-dock-item {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.07);
  padding: 6px 12px;
  border-radius: 12px;
}

.viz-dock-lbl {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
}

.viz-dock-val {
  font-size: 11px;
  font-family: var(--font-mono);
  color: #FBBF24;
  min-width: 34px;
  text-align: right;
}

.viz-range {
  width: 90px;
  accent-color: var(--brand-orange);
  cursor: pointer;
}

.viz-dock-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.viz-quick-btn {
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: #FFF;
  font-size: 12px;
  font-weight: 600;
  padding: 7px 14px;
  border-radius: 10px;
  cursor: pointer;
  font-family: inherit;
  transition: all 0.2s ease;
}

.viz-quick-btn:hover {
  background: rgba(255, 255, 255, 0.15);
}

.viz-quick-btn.active {
  background: rgba(242, 122, 36, 0.24);
  border-color: rgba(242, 122, 36, 0.65);
  color: #FDBA74;
}

/* ==========================================================================
   UPGRADE: DB ICON, ICON-ONLY 3D PINS, SINGLE LAMP SWITCH, CAM CARD & TELEMETRY TAB
   ========================================================================== */

/* 1. Indikator Koneksi Database di Top Header */
.db-status-btn {
  position: relative;
}
.db-dot-badge {
  position: absolute;
  bottom: 7px;
  right: 7px;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  border: 2px solid #141C27;
}
.db-status-btn.online {
  color: #4ADE80;
  border-color: rgba(74, 222, 128, 0.45);
  box-shadow: 0 0 14px rgba(74, 222, 128, 0.22);
}
.db-status-btn.online .db-dot-badge {
  background: #10B981;
  box-shadow: 0 0 8px #10B981;
}
.db-status-btn.offline {
  color: #F87171;
  border-color: rgba(239, 68, 68, 0.45);
  box-shadow: 0 0 14px rgba(239, 68, 68, 0.22);
}
.db-status-btn.offline .db-dot-badge {
  background: #EF4444;
  box-shadow: 0 0 8px #EF4444;
}

/* 2. Tombol Label 3D Berupa Logo / Ikon Saja */
.iot-3d-icon-pin {
  position: absolute;
  top: 0;
  left: 0;
  pointer-events: auto;
  width: 44px;
  height: 44px;
  border-radius: 14px;
  background: rgba(14, 22, 33, 0.78);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.16);
  color: #CBD5E1;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.48);
  transition: background 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease, color 0.2s ease;
}

.iot-3d-icon-pin svg {
  width: 20px;
  height: 20px;
}

.iot-3d-icon-pin:hover {
  background: rgba(26, 39, 58, 0.94);
  border-color: rgba(255, 255, 255, 0.45);
  color: #FFFFFF;
  z-index: 20;
}

.iot-3d-icon-pin.pin-purple { color: #A78BFA; }
.iot-3d-icon-pin.pin-purple.is-active {
  color: #4ADE80;
  border-color: rgba(74, 222, 128, 0.75);
  box-shadow: 0 0 18px rgba(74, 222, 128, 0.4);
}

.iot-3d-icon-pin.pin-cyan { color: #38BDF8; }
.iot-3d-icon-pin.pin-cyan.is-active {
  border-color: rgba(56, 189, 248, 0.8);
  box-shadow: 0 0 18px rgba(56, 189, 248, 0.45);
}

.iot-3d-icon-pin.pin-orange { color: #F97316; }
.iot-3d-icon-pin.pin-orange.is-active {
  border-color: rgba(249, 115, 22, 0.8);
  box-shadow: 0 0 18px rgba(249, 115, 22, 0.45);
}

.iot-3d-icon-pin.pin-danger { color: #FBBF24; }
.iot-3d-icon-pin.pin-danger.is-active {
  color: #FFFFFF;
  background: rgba(220, 38, 38, 0.88);
  border-color: #FCA5A5;
  box-shadow: 0 0 22px rgba(239, 68, 68, 0.65);
  animation: pulseBell 0.9s infinite alternate;
}

/* 3. Card Smart Lamp: 1 Tombol Switch Channel + Slider Intensitas Kondisional */
.lamp-header-inline {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 4px;
}

.lamp-cycle-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 9px;
  border-radius: 999px;
  border: 1px solid rgba(245, 158, 11, 0.45);
  background: rgba(245, 158, 11, 0.14);
  color: #FDE68A;
  font-size: 11px;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.2s ease;
}

.lamp-cycle-btn:hover {
  background: rgba(245, 158, 11, 0.28);
  color: #FFFFFF;
}

.lamp-cycle-btn svg {
  width: 11px;
  height: 11px;
  opacity: 0.85;
}

.lamp-intensity-inline {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.card-intensity-slider {
  flex: 1;
  accent-color: #F59E0B;
  cursor: pointer;
  height: 5px;
}

.card-intensity-val {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
  color: #FCD34D;
  min-width: 34px;
  text-align: right;
}

/* 4. Card Bel Pintu Interaktif */
.bell-trigger-btn {
  padding: 5px 12px;
  border-radius: 999px;
  border: 1px solid rgba(52, 211, 153, 0.45);
  background: rgba(52, 211, 153, 0.16);
  color: #6EE7B7;
  font-size: 11px;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.2s ease;
}

.bell-trigger-btn:hover {
  background: rgba(52, 211, 153, 0.3);
  color: #FFFFFF;
}

.bell-trigger-btn.ringing {
  background: linear-gradient(135deg, #EF4444 0%, #DC2626 100%);
  border-color: #FCA5A5;
  color: #FFFFFF;
  box-shadow: 0 0 14px rgba(239, 68, 68, 0.5);
}

/* 5. Card ESP32-CAM Live (Menggantikan Sensor Analytics di Home) */
.card-esp32-cam {
  background: #111B27;
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.cam-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.cam-card-controls {
  display: flex;
  align-items: center;
  gap: 10px;
}

.cam-mini-live-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.08);
  font-size: 11px;
  font-weight: 700;
  color: var(--text-secondary);
}

.cam-card-viewport {
  position: relative;
  flex: 1;
  min-height: 200px;
  border-radius: 16px;
  overflow: hidden;
  background: radial-gradient(circle at center, #142234 0%, #080E16 100%);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.cam-card-placeholder {
  position: absolute;
  inset: 0;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 20px;
  text-align: center;
  color: var(--text-muted);
  font-size: 12px;
}

.cam-card-placeholder svg {
  width: 34px;
  height: 34px;
  opacity: 0.45;
}

.cam-fs-mini-btn {
  position: absolute;
  bottom: 10px;
  right: 10px;
  z-index: 5;
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: rgba(10, 16, 23, 0.72);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(255, 255, 255, 0.14);
  color: #CBD5E1;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.cam-fs-mini-btn:hover {
  color: #FFFFFF;
  background: rgba(255, 255, 255, 0.16);
}

.cam-fs-mini-btn svg {
  width: 16px;
  height: 16px;
}

/* 6. Tab Telemetry Khusus (Sensor Analytics) */
.telemetry-full-workspace {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.telemetry-kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
}

.tele-kpi-card {
  padding: 18px 20px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.tele-kpi-label {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 600;
}

.tele-kpi-val {
  font-size: 28px;
  font-weight: 800;
  color: #FFFFFF;
  line-height: 1.1;
}

.tele-kpi-val.text-orange { color: #FB923C; }
.tele-kpi-val.text-cyan { color: #38BDF8; }
.tele-kpi-val.text-emerald { color: #4ADE80; }

.tele-kpi-sub {
  font-size: 11px;
  color: var(--text-muted);
}

.tele-chart-card {
  padding: 20px 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.tele-header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.tele-chart-canvas-wrap {
  height: 310px;
  position: relative;
  width: 100%;
}

.tele-table-card {
  padding: 18px 24px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.tele-table-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.tele-table-scroll {
  max-height: 240px;
  overflow-y: auto;
}

.tele-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}

.tele-table th,
.tele-table td {
  text-align: left;
  padding: 10px 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.tele-table th {
  color: var(--text-muted);
  font-weight: 600;
  position: sticky;
  top: 0;
  background: var(--surface-card);
}

.tele-table td {
  color: var(--text-secondary);
  font-family: var(--font-mono);
}

.tele-empty {
  text-align: center !important;
  color: var(--text-muted) !important;
}

@media (max-width: 1100px) {
  .telemetry-kpi-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* Warna Ikon Pin 3D Lampu (Amber) & Nomor Channel Kecil */
.iot-3d-icon-pin.pin-amber {
  color: #F59E0B;
}
.iot-3d-icon-pin.pin-amber.is-active {
  color: #FEF3C7;
  background: rgba(245, 158, 11, 0.28);
  border-color: rgba(245, 158, 11, 0.85);
  box-shadow: 0 0 18px rgba(245, 158, 11, 0.5);
}

.pin-lamp-num {
  position: absolute;
  top: -5px;
  right: -5px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #0F172A;
  border: 1px solid rgba(245, 158, 11, 0.65);
  color: #FCD34D;
  font-size: 9px;
  font-weight: 800;
  font-family: var(--font-mono);
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}
.iot-3d-icon-pin.pin-amber.is-active .pin-lamp-num {
  background: #F59E0B;
  color: #0F172A;
  border-color: #FEF3C7;
}

/* ==========================================================================
   DRAGGABLE 3D ICON PINS & LEADER LINES
   ========================================================================== */
.overlay-3d-leaders {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  overflow: visible;
}

.pin-leader-line {
  stroke: rgba(203, 213, 225, 0.38);
  stroke-width: 1.4;
  stroke-dasharray: 4 3;
  transition: stroke 0.2s ease, stroke-width 0.2s ease;
}

.pin-anchor-dot {
  fill: rgba(203, 213, 225, 0.85);
  stroke: rgba(10, 16, 23, 0.9);
  stroke-width: 1.5;
}

.pin-leader-line.pin-amber.is-active { stroke: rgba(245, 158, 11, 0.85); }
.pin-anchor-dot.pin-amber.is-active  { fill: #F59E0B; }

.pin-leader-line.pin-cyan.is-active  { stroke: rgba(56, 189, 248, 0.85); }
.pin-anchor-dot.pin-cyan.is-active   { fill: #38BDF8; }

.pin-leader-line.pin-purple.is-active { stroke: rgba(74, 222, 128, 0.85); }
.pin-anchor-dot.pin-purple.is-active  { fill: #4ADE80; }

.pin-leader-line.pin-danger.is-active { stroke: rgba(239, 68, 68, 0.9); }
.pin-anchor-dot.pin-danger.is-active  { fill: #EF4444; }

.pin-leader-line.pin-orange.is-active { stroke: rgba(249, 115, 22, 0.85); }
.pin-anchor-dot.pin-orange.is-active  { fill: #F97316; }

.iot-3d-icon-pin {
  touch-action: none;
  user-select: none;
  cursor: grab;
}

.iot-3d-icon-pin.is-dragging {
  cursor: grabbing;
  z-index: 30;
  border-color: rgba(255, 255, 255, 0.75) !important;
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.65);
}