:root {
  /* Color Palette - Light Theme (Default) */
  --bg-body: #f4f6fb;
  --bg-surface: #ffffff;
  --bg-surface-elevated: #ffffff;
  --bg-subtle: #edf2f7;
  --bg-card-hover: #f8fafc;
  
  --border-color: #e2e8f0;
  --border-focus: #3b82f6;
  
  --text-primary: #1e293b;
  --text-secondary: #64748b;
  --text-muted: #94a3b8;
  
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --primary-light: #dbeafe;
  --primary-text: #1e40af;
  
  --danger: #ef4444;
  --danger-hover: #dc2626;
  --danger-light: #fee2e2;
  --danger-text: #991b1b;
  
  --success: #10b981;
  --success-light: #d1fae5;
  --success-text: #065f46;

  --warning: #f59e0b;
  --warning-light: #fef3c7;
  --warning-text: #92400e;
  
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-full: 9999px;
  
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.05), 0 1px 2px rgba(0, 0, 0, 0.03);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.06), 0 2px 4px -1px rgba(0, 0, 0, 0.04);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.08), 0 4px 6px -2px rgba(0, 0, 0, 0.04);
  --shadow-hover: 0 12px 20px -3px rgba(37, 99, 235, 0.12), 0 4px 6px -2px rgba(0, 0, 0, 0.05);

  --font-family: 'Plus Jakarta Sans', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
  --transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

/* Dark Theme (Optional toggle) */
[data-theme="dark"] {
  --bg-body: #0f172a;
  --bg-surface: #1e293b;
  --bg-surface-elevated: #334155;
  --bg-subtle: #243248;
  --bg-card-hover: #273549;
  
  --border-color: #334155;
  --border-focus: #60a5fa;
  
  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  
  --primary: #3b82f6;
  --primary-hover: #60a5fa;
  --primary-light: #1e3a8a;
  --primary-text: #93c5fd;
  
  --danger: #f87171;
  --danger-hover: #ef4444;
  --danger-light: #7f1d1d;
  --danger-text: #fecaca;
  
  --success: #34d399;
  --success-light: #064e3b;
  --success-text: #a7f3d0;

  --warning: #fbbf24;
  --warning-light: #78350f;
  --warning-text: #fde68a;
  
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.4);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.5);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.6);
  --shadow-hover: 0 12px 24px -3px rgba(59, 130, 246, 0.25);
}

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

html, body {
  max-width: 100vw;
  overflow-x: hidden;
}

body {
  font-family: var(--font-family);
  background-color: var(--bg-body);
  color: var(--text-primary);
  line-height: 1.5;
  min-height: 100vh;
  transition: background-color 0.3s ease, color 0.3s ease;
  -webkit-font-smoothing: antialiased;
}

/* Container */
.container {
  width: 85%;
  max-width: 1800px;
  margin: 0 auto;
  padding: 24px 16px 80px;
  box-sizing: border-box;
}

/* Header */
.app-header {
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-color);
  position: sticky;
  top: 0;
  z-index: 40;
  backdrop-filter: blur(8px);
  transition: var(--transition);
}

.header-content {
  width: 85%;
  max-width: 1800px;
  margin: 0 auto;
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  box-sizing: border-box;
}

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

.brand-icon {
  width: 42px;
  height: 42px;
  background: linear-gradient(135deg, var(--primary), #6366f1);
  color: #ffffff;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.25);
}

.brand-text h1 {
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 8px;
}

.badge-version {
  font-size: 0.7rem;
  font-weight: 600;
  background: var(--primary-light);
  color: var(--primary-text);
  padding: 2px 8px;
  border-radius: var(--radius-full);
}

.brand-text p {
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 9px 16px;
  font-size: 0.875rem;
  font-weight: 600;
  font-family: inherit;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  cursor: pointer;
  transition: var(--transition);
  text-decoration: none;
  white-space: nowrap;
}

.btn-primary {
  background-color: var(--primary);
  color: #ffffff;
  box-shadow: 0 2px 8px rgba(37, 99, 235, 0.25);
}

.btn-primary:hover {
  background-color: var(--primary-hover);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.35);
}

.btn-secondary {
  background-color: var(--bg-surface);
  color: var(--text-primary);
  border-color: var(--border-color);
}

.btn-secondary:hover {
  background-color: var(--bg-subtle);
  border-color: var(--text-muted);
}

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
}

.btn-ghost:hover {
  background: var(--bg-subtle);
  color: var(--text-primary);
}

.btn-danger-ghost {
  background: transparent;
  color: var(--danger);
}

.btn-danger-ghost:hover {
  background: var(--danger-light);
  color: var(--danger-text);
}

.btn-icon-only {
  width: 38px;
  height: 38px;
  padding: 0;
  border-radius: var(--radius-md);
}

/* Navigation Tabs (Home vs Configurazione) */
.nav-tabs-wrapper {
  margin-bottom: 24px;
  width: 100%;
}

.main-nav-tabs {
  display: flex;
  width: 100%;
  box-sizing: border-box;
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  padding: 5px;
  border-radius: var(--radius-lg);
  gap: 6px;
  box-shadow: var(--shadow-sm);
  flex-wrap: wrap;
}

.nav-tab-btn {
  flex: 1 0 auto;
  min-width: max-content;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 14px;
  font-size: 0.88rem;
  font-weight: 700;
  font-family: inherit;
  border: none;
  border-radius: var(--radius-md);
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  transition: var(--transition);
  white-space: nowrap;
  box-sizing: border-box;
}

.nav-tab-btn:hover {
  color: var(--text-primary);
  background: var(--bg-subtle);
}

.nav-tab-btn.active {
  background: var(--primary);
  color: #ffffff;
  box-shadow: 0 2px 8px rgba(37, 99, 235, 0.3);
}

.tab-badge {
  font-size: 0.72rem;
  font-weight: 700;
  padding: 1px 7px;
  border-radius: var(--radius-full);
  background: rgba(255, 255, 255, 0.25);
  color: #ffffff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  line-height: 1.3;
}

.nav-tab-btn:not(.active) .tab-badge {
  background: var(--bg-subtle);
  color: var(--text-secondary);
  border: 1px solid var(--border-color);
}

/* Home View Room Sections (Full-width horizontal rows) */
.home-sections-container {
  display: flex;
  flex-direction: column;
  gap: 28px;
  width: 100%;
}

.home-room-section {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 22px;
  box-shadow: var(--shadow-sm);
  width: 100%;
  box-sizing: border-box;
}

.home-room-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.btn-room-order {
  background: var(--bg-subtle);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 5px 9px;
  font-size: 0.85rem;
  cursor: pointer;
  color: var(--text-secondary);
  transition: var(--transition-fast);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

.btn-room-order:hover:not(:disabled) {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
  transform: translateY(-1px);
}

.btn-room-order:disabled {
  opacity: 0.28;
  cursor: not-allowed;
}

.home-room-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
  padding-bottom: 12px;
  border-bottom: 1px dashed var(--border-color);
}

.home-room-title {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 1.2rem;
  font-weight: 800;
  color: var(--text-primary);
  margin: 0;
  letter-spacing: -0.01em;
}

.home-room-count {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-muted);
  background: var(--bg-subtle);
  padding: 3px 10px;
  border-radius: var(--radius-full);
  border: 1px solid var(--border-color);
}

.favorite-btn {
  color: var(--text-muted);
  font-size: 1.15rem;
  transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1), color 0.2s ease;
}

.favorite-btn:hover {
  transform: scale(1.2);
  color: #eab308;
}

.favorite-btn.is-fav {
  color: #eab308;
  filter: drop-shadow(0 2px 4px rgba(234, 179, 8, 0.35));
}

/* Stats / Banner Row */
.stats-banner {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
  box-shadow: var(--shadow-sm);
  display: flex;
  align-items: center;
  gap: 16px;
}

.stat-icon {
  width: 46px;
  height: 46px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
}

.stat-icon.blue {
  background: var(--primary-light);
  color: var(--primary-text);
}
.stat-icon.green {
  background: var(--success-light);
  color: var(--success-text);
}
.stat-icon.amber {
  background: var(--warning-light);
  color: var(--warning-text);
}

.stat-info .stat-value {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.2;
}

.stat-info .stat-label {
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-secondary);
}

/* Sync Bar (JSON / OneDrive status) */
.sync-bar {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 12px 18px;
  margin-bottom: 24px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  box-shadow: var(--shadow-sm);
}

.sync-status {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--success);
  box-shadow: 0 0 0 3px var(--success-light);
}

.status-dot.unsaved {
  background: var(--warning);
  box-shadow: 0 0 0 3px var(--warning-light);
}

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

/* Controls Bar (Search + Filter Chips) */
.controls-bar {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-bottom: 24px;
}

.search-wrapper {
  position: relative;
  width: 100%;
}

.search-icon {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  pointer-events: none;
  font-size: 16px;
}

.search-input {
  width: 100%;
  padding: 12px 16px 12px 42px;
  font-size: 0.95rem;
  font-family: inherit;
  background: var(--bg-surface);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  transition: var(--transition);
}

.search-input:focus {
  outline: none;
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

.clear-search-btn {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px;
  font-size: 14px;
  display: none;
}

.clear-search-btn:hover {
  color: var(--text-primary);
}

/* Filter Chips */
.filter-scroll-container {
  display: flex;
  align-items: center;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 4px;
  scrollbar-width: thin;
}

.filter-chip {
  padding: 6px 14px;
  font-size: 0.8rem;
  font-weight: 600;
  font-family: inherit;
  background: var(--bg-surface);
  color: var(--text-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-full);
  cursor: pointer;
  transition: var(--transition);
  white-space: nowrap;
}

.filter-chip:hover {
  border-color: var(--primary);
  color: var(--primary);
}

.filter-chip.active {
  background: var(--primary);
  color: #ffffff;
  border-color: var(--primary);
  box-shadow: 0 2px 6px rgba(37, 99, 235, 0.25);
}

/* Devices Grid (True Masonry Flex Column Layout) */
.devices-grid {
  display: flex;
  gap: 16px;
  align-items: flex-start;
  width: 100%;
}

.devices-masonry-col {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* Device Card */
.device-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: var(--shadow-sm);
  transition: var(--transition);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  width: 100%;
  box-sizing: border-box;
  position: relative;
  overflow: hidden;
  margin: 0;
}

.device-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-hover);
  border-color: rgba(37, 99, 235, 0.3);
}

.card-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.card-title-group {
  flex: 1;
}

.device-name {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 4px;
  line-height: 1.3;
  display: flex;
  align-items: center;
  gap: 8px;
}

.device-status-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
  transition: var(--transition);
}

.device-status-dot.online {
  background-color: #22c55e;
  box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.25);
  animation: pulseStatusDot 3s infinite ease-in-out;
}

.device-status-dot.offline {
  background-color: #ef4444;
  box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.2);
}

@keyframes pulseStatusDot {
  0%, 100% {
    box-shadow: 0 0 0 2px rgba(34, 197, 94, 0.35);
  }
  50% {
    box-shadow: 0 0 0 5px rgba(34, 197, 94, 0.08);
  }
}

.device-room {
  font-size: 0.8rem;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 4px;
}

.card-actions {
  display: flex;
  align-items: center;
  gap: 4px;
}

/* Badges */
.badge-group {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 14px;
}

.app-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border-radius: var(--radius-full);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.01em;
}

/* App-specific color themes */
.app-badge.smart-life, .app-badge.tuya {
  background: #ffedd5;
  color: #c2410c;
  border: 1px solid #fed7aa;
}
[data-theme="dark"] .app-badge.smart-life, [data-theme="dark"] .app-badge.tuya {
  background: #7c2d12;
  color: #ffedd5;
  border-color: #9a3412;
}

.app-badge.shelly {
  background: #e0f2fe;
  color: #0369a1;
  border: 1px solid #bae6fd;
}
[data-theme="dark"] .app-badge.shelly {
  background: #0c4a6e;
  color: #e0f2fe;
  border-color: #075985;
}

.app-badge.meross {
  background: #dcfce7;
  color: #15803d;
  border: 1px solid #bbf7d0;
}
[data-theme="dark"] .app-badge.meross {
  background: #14532d;
  color: #dcfce7;
  border-color: #166534;
}

.app-badge.home-assistant {
  background: #e0e7ff;
  color: #4338ca;
  border: 1px solid #c7d2fe;
}
[data-theme="dark"] .app-badge.home-assistant {
  background: #312e81;
  color: #e0e7ff;
  border-color: #3730a3;
}

.app-badge.philips-hue {
  background: #fae8ff;
  color: #86198f;
  border: 1px solid #f5d0fe;
}
[data-theme="dark"] .app-badge.philips-hue {
  background: #581c87;
  color: #fae8ff;
  border-color: #6b21a8;
}

.app-badge.alexa, .app-badge.amazon-alexa {
  background: #cffafe;
  color: #0e7490;
  border: 1px solid #a5f3fc;
}

.app-badge.generic {
  background: var(--bg-subtle);
  color: var(--text-secondary);
  border: 1px solid var(--border-color);
}

.category-tag {
  font-size: 0.72rem;
  font-weight: 500;
  padding: 3px 8px;
  border-radius: var(--radius-sm);
  background: var(--bg-subtle);
  color: var(--text-secondary);
}

/* Card Body / Notes */
.card-notes {
  background: var(--bg-card-hover);
  border-radius: var(--radius-md);
  padding: 10px 12px;
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-bottom: 12px;
  border-left: 3px solid var(--primary);
  line-height: 1.4;
  word-break: break-word;
}

.card-notes.empty {
  font-style: italic;
  color: var(--text-muted);
  border-left-color: var(--border-color);
}

.card-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  font-size: 0.75rem;
  color: var(--text-muted);
  padding-top: 8px;
  border-top: 1px dashed var(--border-color);
}

.protocol-tag {
  display: flex;
  align-items: center;
  gap: 4px;
  font-weight: 500;
  color: var(--text-secondary);
}

/* Empty State */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  background: var(--bg-surface);
  border: 2px dashed var(--border-color);
  border-radius: var(--radius-lg);
  grid-column: 1 / -1;
}

.empty-icon {
  font-size: 48px;
  margin-bottom: 16px;
  opacity: 0.7;
}

.empty-state h3 {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 6px;
}

.empty-state p {
  color: var(--text-secondary);
  max-width: 400px;
  margin: 0 auto 20px;
  font-size: 0.9rem;
}

/* Modal Dialog */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.65);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  z-index: 5000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: var(--transition);
}

.modal-overlay.open {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  z-index: 5000;
}

#mapCustomizerModal.open {
  z-index: 5100;
}

#cameraLiveModal.open {
  z-index: 5500;
}

.modal-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  max-width: 580px;
  width: 100%;
  max-height: 90vh;
  max-height: 90dvh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  transform: translateY(12px) scale(0.98);
  transition: var(--transition);
  box-sizing: border-box;
}

/* Finestra Configurazione Dispositivo & Gruppi Entità Ampia su Desktop */
#deviceModal .modal-card {
  max-width: 920px;
  width: 92vw;
}

@media (min-width: 1280px) {
  #deviceModal .modal-card {
    max-width: 980px;
  }
}

.modal-overlay.open .modal-card {
  transform: translateY(0) scale(1);
}

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

.modal-title {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 8px;
}

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

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

.form-label {
  font-size: 0.825rem;
  font-weight: 600;
  color: var(--text-primary);
}

.form-input, .form-select, .form-textarea {
  width: 100%;
  padding: 10px 14px;
  font-size: 0.9rem;
  font-family: inherit;
  background: var(--bg-surface);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  transition: var(--transition);
}

.form-input:focus, .form-select:focus, .form-textarea:focus {
  outline: none;
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

.form-textarea {
  resize: vertical;
  min-height: 80px;
}

.form-hint {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  background: var(--bg-card-hover);
}

/* Toast Notifications */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9000;
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
}

.toast {
  pointer-events: auto;
  background: var(--bg-surface);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 12px 18px;
  box-shadow: var(--shadow-lg);
  font-size: 0.875rem;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 10px;
  animation: slideUp 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  min-width: 260px;
  max-width: 360px;
}

.toast.success {
  border-left: 4px solid var(--success);
}
.toast.info {
  border-left: 4px solid var(--primary);
}
.toast.danger {
  border-left: 4px solid var(--danger);
}

@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateY(16px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Home Assistant Live Integrations & Multi-Sensors */
.ha-live-container {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 12px;
}

.ha-sensors-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 8px;
}

/* ==========================================
 * LCD Digital Display Style (Sensori a Cristalli Liquidi)
 * ========================================== */
.ha-lcd-screen {
  background: #101c15;
  border: 2px solid #23382b;
  border-radius: 8px;
  padding: 3px;
  box-shadow: inset 0 2px 6px rgba(0, 0, 0, 0.6), 0 2px 4px rgba(0, 0, 0, 0.12);
  position: relative;
  overflow: hidden;
  transition: var(--transition);
}

[data-theme="dark"] .ha-lcd-screen {
  background: #08140e;
  border-color: #173322;
  box-shadow: inset 0 2px 8px rgba(0, 0, 0, 0.9), 0 2px 8px rgba(0, 0, 0, 0.4);
}

[data-theme="light"] .ha-lcd-screen {
  background: #202b24;
  border-color: #35453a;
}

.ha-lcd-glass {
  background: linear-gradient(135deg, #2b4533 0%, #1f3525 60%, #2b4533 100%);
  border-radius: 5px;
  padding: 8px 10px;
  position: relative;
  border: 1px solid #3c5e47;
  overflow: hidden;
  box-shadow: inset 0 1px 3px rgba(0,0,0,0.5);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-height: 64px;
}

[data-theme="light"] .ha-lcd-glass {
  background: linear-gradient(135deg, #cde3d1 0%, #b8d4bd 60%, #c4dfca 100%);
  border: 1px solid #9bbd9f;
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.2), inset 0 -1px 2px rgba(255, 255, 255, 0.4);
}

/* Subtle glossy reflection over LCD screen */
.ha-lcd-glass::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 40%;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.16) 0%, rgba(255, 255, 255, 0.01) 100%);
  pointer-events: none;
  border-radius: 4px 4px 0 0;
}

.ha-lcd-header {
  display: flex;
  align-items: center;
  width: 100%;
  margin-bottom: 4px;
  min-width: 0;
}

.ha-lcd-label {
  font-family: 'Share Tech Mono', monospace;
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #55e688;
  text-shadow: 0 0 5px rgba(85, 230, 136, 0.4);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  width: 100%;
  display: block;
}

[data-theme="light"] .ha-lcd-label {
  color: #244b30;
  text-shadow: none;
}

.ha-lcd-mode {
  font-family: 'Share Tech Mono', monospace;
  font-size: 0.6rem;
  font-weight: 700;
  color: #398c56;
  background: rgba(0, 0, 0, 0.25);
  padding: 1px 5px;
  border-radius: 3px;
  letter-spacing: 0.05em;
  flex-shrink: 0;
}

[data-theme="light"] .ha-lcd-mode {
  color: #3b6647;
  background: rgba(0, 0, 0, 0.08);
}

.ha-lcd-body {
  display: flex;
  align-items: baseline;
  justify-content: flex-end;
  gap: 3px;
  min-width: 0;
  width: 100%;
}

.ha-lcd-digits {
  display: flex;
  align-items: baseline;
  justify-content: flex-end;
  gap: 2px;
  width: 100%;
  min-width: 0;
  overflow: visible;
}

.ha-lcd-val {
  font-family: 'Orbitron', 'Share Tech Mono', monospace;
  font-size: 1.25rem;
  font-weight: 800;
  color: #72ff9f;
  text-shadow: 0 0 8px rgba(114, 255, 159, 0.6), 0 0 2px rgba(114, 255, 159, 0.9);
  letter-spacing: 0.01em;
  line-height: 1.1;
  white-space: nowrap;
  max-width: 100%;
  flex-shrink: 1;
  min-width: 0;
  transition: font-size 0.2s ease, color var(--transition-fast);
}

[data-theme="light"] .ha-lcd-val {
  color: #16361e;
  text-shadow: 1px 1px 0 rgba(255, 255, 255, 0.5);
}

.ha-lcd-unit {
  font-family: 'Share Tech Mono', 'Orbitron', monospace;
  font-size: 0.68rem;
  font-weight: 700;
  color: #55e688;
  opacity: 0.88;
  margin-left: 2px;
  flex-shrink: 0;
  align-self: flex-end;
  padding-bottom: 2px;
  letter-spacing: 0.01em;
  white-space: nowrap;
}

[data-theme="light"] .ha-lcd-unit {
  color: #2b5637;
  opacity: 0.95;
}

/* ==========================================
 * Vertical Rocker / Lever Switch (Levetta Verticale | / O)
 * ========================================== */
.ha-switch-unit {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: var(--bg-card-hover);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 10px 14px;
  transition: var(--transition);
  grid-column: 1 / -1; /* Spans full width of sensors container for elegance */
}

.ha-switch-unit:hover {
  border-color: var(--primary);
}

.ha-switch-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
  min-width: 0;
}

.ha-switch-title {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ha-switch-domain {
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.ha-vertical-rocker-wrapper {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}

.ha-vertical-rocker {
  position: relative;
  width: 38px;
  height: 64px;
  background: #1e293b;
  border-radius: 8px;
  padding: 4px;
  border: 2px solid #334155;
  box-shadow: inset 0 3px 6px rgba(0, 0, 0, 0.5), 0 2px 5px rgba(0, 0, 0, 0.2);
  cursor: pointer;
  outline: none;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  align-items: center;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  user-select: none;
}

.ha-vertical-rocker:hover {
  border-color: #475569;
  transform: scale(1.04);
}

.rocker-track {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  align-items: center;
  position: relative;
}

.rocker-sym {
  font-family: 'Orbitron', 'Share Tech Mono', sans-serif;
  font-size: 0.75rem;
  font-weight: 900;
  line-height: 1;
  pointer-events: none;
  z-index: 2;
  transition: all 0.25s ease;
}

.rocker-sym.on-sym {
  color: #22c55e; /* Green */
  opacity: 0.4;
  text-shadow: none;
}

.rocker-sym.off-sym {
  color: #ef4444; /* Red */
  opacity: 0.4;
  text-shadow: none;
}

/* Lever knob moving up and down */
.rocker-lever {
  position: absolute;
  left: 1px;
  right: 1px;
  height: 26px;
  border-radius: 5px;
  background: linear-gradient(180deg, #64748b 0%, #334155 100%);
  box-shadow: 0 3px 6px rgba(0, 0, 0, 0.4), inset 0 1px 1px rgba(255, 255, 255, 0.4);
  border: 1px solid #475569;
  transition: transform 0.22s cubic-bezier(0.34, 1.56, 0.64, 1), background 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 3;
}

.lever-knob {
  display: flex;
  align-items: center;
  justify-content: center;
}

.lever-indicator {
  width: 12px;
  height: 3px;
  border-radius: 2px;
  background: #94a3b8;
  transition: background 0.2s ease, box-shadow 0.2s ease;
}

/* ON State: Lever is at TOP */
.ha-vertical-rocker.is-on {
  border-color: rgba(34, 197, 94, 0.7);
  box-shadow: inset 0 2px 6px rgba(0, 0, 0, 0.4), 0 0 12px rgba(34, 197, 94, 0.3);
}

.ha-vertical-rocker.is-on .rocker-sym.on-sym {
  opacity: 1;
  color: #22c55e;
  text-shadow: 0 0 8px rgba(34, 197, 94, 0.9), 0 0 12px rgba(34, 197, 94, 0.6);
}

.ha-vertical-rocker.is-on .rocker-lever {
  transform: translateY(-2px);
  background: linear-gradient(180deg, #15803d 0%, #166534 100%);
  border-color: #22c55e;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3), inset 0 1px 2px rgba(255, 255, 255, 0.5), 0 0 6px rgba(34, 197, 94, 0.5);
}

.ha-vertical-rocker.is-on .lever-indicator {
  background: #86efac;
  box-shadow: 0 0 6px #22c55e;
}

/* OFF State: Lever is at BOTTOM */
.ha-vertical-rocker.is-off {
  border-color: rgba(239, 68, 68, 0.5);
}

.ha-vertical-rocker.is-off .rocker-sym.off-sym {
  opacity: 1;
  color: #ef4444;
  text-shadow: 0 0 8px rgba(239, 68, 68, 0.9), 0 0 12px rgba(239, 68, 68, 0.6);
}

.ha-vertical-rocker.is-off .rocker-lever {
  transform: translateY(24px);
  background: linear-gradient(180deg, #991b1b 0%, #7f1d1d 100%);
  border-color: #ef4444;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.4), inset 0 1px 2px rgba(255, 255, 255, 0.3), 0 0 6px rgba(239, 68, 68, 0.4);
}

.ha-vertical-rocker.is-off .lever-indicator {
  background: #fca5a5;
  box-shadow: 0 0 6px #ef4444;
}

/* STANDBY State: Lever is at CENTER */
.ha-vertical-rocker.is-standby {
  border-color: rgba(245, 158, 11, 0.6);
}

.ha-vertical-rocker.is-standby .rocker-lever {
  transform: translateY(11px);
  background: linear-gradient(180deg, #b45309 0%, #92400e 100%);
  border-color: #f59e0b;
  box-shadow: 0 3px 6px rgba(0, 0, 0, 0.35), inset 0 1px 2px rgba(255, 255, 255, 0.4), 0 0 6px rgba(245, 158, 11, 0.4);
}

.ha-vertical-rocker.is-standby .lever-indicator,
.lever-indicator.amber {
  background: #fde68a !important;
  box-shadow: 0 0 6px #f59e0b !important;
}

.ha-rocker-status-label {
  font-family: 'Share Tech Mono', monospace;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  min-width: 64px;
  text-align: center;
}

.ha-rocker-status-label.on {
  background: rgba(34, 197, 94, 0.15);
  color: #16a34a;
  border: 1px solid rgba(34, 197, 94, 0.35);
}

[data-theme="dark"] .ha-rocker-status-label.on {
  color: #4ade80;
  background: rgba(34, 197, 94, 0.2);
}

.ha-rocker-status-label.standby {
  background: rgba(245, 158, 11, 0.15);
  color: #d97706;
  border: 1px solid rgba(245, 158, 11, 0.4);
}

[data-theme="dark"] .ha-rocker-status-label.standby {
  color: #fbbf24;
  background: rgba(245, 158, 11, 0.22);
}

.ha-rocker-status-label.off {
  background: rgba(239, 68, 68, 0.12);
  color: #dc2626;
  border: 1px solid rgba(239, 68, 68, 0.3);
}

[data-theme="dark"] .ha-rocker-status-label.off {
  color: #f87171;
  background: rgba(239, 68, 68, 0.2);
}

/* Lightbulb Controls (for Categoria Illuminazione or light domain) */
.ha-bulb-control-wrapper {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}

.ha-bulb-btn {
  position: relative;
  width: 46px;
  height: 46px;
  border-radius: 50%;
  border: 2px solid var(--border-color);
  cursor: pointer;
  outline: none;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  padding: 0;
  user-select: none;
  font-size: 1.45rem;
}

.ha-bulb-btn:hover {
  transform: scale(1.12);
}

.ha-bulb-btn:active {
  transform: scale(0.92);
}

.ha-bulb-btn.is-off {
  background: #1e293b;
  border-color: #475569;
}

.ha-bulb-btn.is-off .map-bulb-emoji {
  opacity: 0.35;
  filter: grayscale(100%) brightness(0.65);
}

[data-theme="light"] .ha-bulb-btn.is-off {
  background: #f1f5f9;
  border-color: #cbd5e1;
}

[data-theme="light"] .ha-bulb-btn.is-off .map-bulb-emoji {
  opacity: 0.45;
  filter: grayscale(100%) brightness(0.85);
}

.ha-bulb-btn.is-on {
  background: radial-gradient(circle, #fef08a 0%, #f59e0b 70%, #d97706 100%);
  border-color: #fbbf24;
  box-shadow: 0 0 20px rgba(245, 158, 11, 0.8), 0 0 35px rgba(251, 191, 36, 0.45);
}

.ha-bulb-btn.is-on .map-bulb-emoji {
  opacity: 1;
  filter: drop-shadow(0 0 4px #ffffff) drop-shadow(0 0 8px #fbbf24);
  transform: scale(1.12);
}

[data-theme="light"] .ha-bulb-btn.is-on {
  background: radial-gradient(circle, #fef9c3 0%, #fde047 80%, #eab308 100%);
  border-color: #f59e0b;
  box-shadow: 0 0 18px rgba(234, 179, 8, 0.75), 0 2px 8px rgba(0, 0, 0, 0.12);
}

.ha-bulb-status-label {
  font-family: 'Share Tech Mono', monospace;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  min-width: 64px;
  text-align: center;
}

.ha-bulb-status-label.on {
  background: rgba(245, 158, 11, 0.18);
  color: #d97706;
  border: 1px solid rgba(245, 158, 11, 0.4);
}

[data-theme="dark"] .ha-bulb-status-label.on {
  color: #fbbf24;
  background: rgba(245, 158, 11, 0.25);
  border-color: rgba(251, 191, 36, 0.5);
}

.ha-bulb-status-label.off {
  background: rgba(100, 116, 139, 0.12);
  color: var(--text-muted);
  border: 1px solid var(--border-color);
}

/* Heater Controls (for Categoria Riscaldamento & Stufette or Caldobagno) */
.ha-heater-control-wrapper {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
  position: relative;
}

.ha-heater-btn {
  position: relative;
  width: 54px;
  height: 44px;
  border-radius: 8px;
  border: 1.5px solid var(--border-color);
  background: var(--bg-surface);
  cursor: pointer;
  outline: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 6px;
  gap: 5px;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: var(--shadow-sm);
  user-select: none;
}

.ha-heater-btn:hover {
  transform: scale(1.06);
  border-color: #f97316;
}

.ha-heater-btn:active {
  transform: scale(0.95);
}

.ha-heater-btn.is-off {
  background: #1e293b;
  border-color: #475569;
}

[data-theme="light"] .ha-heater-btn.is-off {
  background: #f1f5f9;
  border-color: #cbd5e1;
}

.ha-heater-btn.is-on {
  background: radial-gradient(circle at center, #291b18 0%, #1e1b2e 100%);
  border-color: #f97316;
  box-shadow: 0 0 14px rgba(249, 115, 22, 0.6), 0 0 24px rgba(239, 68, 68, 0.25);
}

[data-theme="light"] .ha-heater-btn.is-on {
  background: radial-gradient(circle at center, #fff7ed 0%, #ffedd5 100%);
  border-color: #ea580c;
  box-shadow: 0 0 12px rgba(234, 88, 12, 0.45);
}

.heater-mini-grill {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2.5px;
  background: rgba(0, 0, 0, 0.25);
  padding: 3px;
  border-radius: 4px;
}

[data-theme="light"] .heater-mini-grill {
  background: rgba(0, 0, 0, 0.06);
}

.hm-coil {
  height: 3.5px;
  border-radius: 2px;
  background: #475569;
  transition: all 0.3s ease;
}

[data-theme="light"] .hm-coil {
  background: #94a3b8;
}

.hm-coil.hot {
  background: linear-gradient(90deg, #ea580c 0%, #f97316 35%, #fef08a 50%, #f97316 65%, #ea580c 100%);
  box-shadow: 0 0 4px #f97316, 0 0 7px #ef4444;
  animation: coilPulse 2s ease-in-out infinite alternate;
}

.ha-heater-status-label {
  font-family: 'Share Tech Mono', monospace;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  min-width: 64px;
  text-align: center;
}

.ha-heater-status-label.on {
  background: rgba(234, 88, 12, 0.18);
  color: #ea580c;
  border: 1px solid rgba(234, 88, 12, 0.4);
}

[data-theme="dark"] .ha-heater-status-label.on {
  color: #fb923c;
  background: rgba(234, 88, 12, 0.25);
  border-color: rgba(251, 146, 60, 0.5);
}

.ha-heater-status-label.off {
  background: rgba(100, 116, 139, 0.12);
  color: var(--text-muted);
  border: 1px solid var(--border-color);
}

/* Boiler Controls (for Scaldabagno / Boiler / Scaldaacqua) */
.ha-boiler-control-wrapper {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
  position: relative;
}

.ha-boiler-btn {
  position: relative;
  width: 58px;
  height: 44px;
  border-radius: 8px;
  border: 1.5px solid var(--border-color);
  background: var(--bg-surface);
  cursor: pointer;
  outline: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 6px;
  gap: 6px;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: var(--shadow-sm);
  user-select: none;
}

.ha-boiler-btn:hover {
  transform: scale(1.06);
  border-color: #ef4444;
}

.ha-boiler-btn:active {
  transform: scale(0.95);
}

.ha-boiler-btn.is-off {
  background: #1e293b;
  border-color: #475569;
}

[data-theme="light"] .ha-boiler-btn.is-off {
  background: #f1f5f9;
  border-color: #cbd5e1;
}

.ha-boiler-btn.is-on {
  background: radial-gradient(circle at center, #2e1414 0%, #1e1b2e 100%);
  border-color: #ef4444;
  box-shadow: 0 0 14px rgba(239, 68, 68, 0.6), 0 0 24px rgba(249, 115, 22, 0.25);
}

[data-theme="light"] .ha-boiler-btn.is-on {
  background: radial-gradient(circle at center, #fef2f2 0%, #fee2e2 100%);
  border-color: #dc2626;
  box-shadow: 0 0 12px rgba(220, 38, 38, 0.45);
}

.ha-boiler-status-label {
  font-family: 'Share Tech Mono', monospace;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  min-width: 64px;
  text-align: center;
}

.ha-boiler-status-label.on {
  background: rgba(239, 68, 68, 0.18);
  color: #ef4444;
  border: 1px solid rgba(239, 68, 68, 0.4);
}

[data-theme="dark"] .ha-boiler-status-label.on {
  color: #f87171;
  background: rgba(239, 68, 68, 0.25);
  border-color: rgba(248, 113, 113, 0.5);
}

.ha-boiler-status-label.off {
  background: rgba(100, 116, 139, 0.12);
  color: var(--text-muted);
  border: 1px solid var(--border-color);
}

.ha-boiler-status-label.standby,
.ha-heater-status-label.standby {
  background: rgba(34, 197, 94, 0.15);
  color: #16a34a;
  border: 1px solid rgba(34, 197, 94, 0.35);
}

[data-theme="dark"] .ha-boiler-status-label.standby,
[data-theme="dark"] .ha-heater-status-label.standby {
  color: #4ade80;
  background: rgba(34, 197, 94, 0.2);
  border-color: rgba(74, 222, 128, 0.4);
}

/* Fallback & State Pills */
.ha-state-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.75rem;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: var(--radius-full);
  text-transform: uppercase;
  letter-spacing: 0.02em;
  white-space: nowrap;
  flex-shrink: 0;
}

.ha-state-pill.on {
  background: #dcfce7;
  color: #15803d;
  border: 1px solid #bbf7d0;
}
[data-theme="dark"] .ha-state-pill.on {
  background: #14532d;
  color: #dcfce7;
  border-color: #166534;
}

.ha-state-pill.off {
  background: var(--bg-subtle);
  color: var(--text-muted);
  border: 1px solid var(--border-color);
}

.ha-state-pill.sensor {
  background: #e0f2fe;
  color: #0369a1;
  border: 1px solid #bae6fd;
}
[data-theme="dark"] .ha-state-pill.sensor {
  background: #0c4a6e;
  color: #e0f2fe;
  border-color: #075985;
}

/* Modal Multi-Entity List Management & Grouping */
.ha-quick-device-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--bg-card-hover);
  padding: 10px 14px;
  border-radius: var(--radius-md);
  border: 1.5px dashed rgba(37, 99, 235, 0.4);
  margin-bottom: 12px;
}

.ha-quick-device-bar select {
  border-color: var(--border-color);
  font-size: 0.9rem;
  font-weight: 600;
  padding: 10px 14px;
  flex: 1;
}

.ha-quick-device-bar button {
  font-size: 0.88rem;
  font-weight: 700;
  padding: 10px 16px;
  white-space: nowrap;
}

.ha-modal-entity-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
  background: var(--bg-card-hover);
  padding: 8px 12px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  transition: var(--transition);
}

.ha-modal-entity-row:focus-within {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.ha-modal-entity-row .ha-reorder-handle-group {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}

.ha-modal-entity-row .form-select.ha-entity-select {
  flex: 1.6;
  min-width: 280px;
  padding: 9px 12px;
  font-size: 0.88rem;
  font-weight: 600;
}

.ha-modal-entity-row .form-input.ha-entity-icon-input {
  width: 54px;
  flex-shrink: 0;
  text-align: center;
  font-size: 1.15rem;
  padding: 8px 4px;
}

.ha-modal-entity-row .form-input.ha-entity-label-input {
  flex: 1.0;
  min-width: 150px;
  padding: 9px 12px;
  font-size: 0.88rem;
}

.ha-modal-entity-row .btn-danger-ghost {
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  font-size: 1rem;
}

.ha-entity-confirm-label {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 0.76rem;
  font-weight: 700;
  cursor: pointer;
  background: var(--bg-surface);
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  white-space: nowrap;
  user-select: none;
  transition: var(--transition);
}

.ha-entity-confirm-label:hover {
  border-color: var(--primary);
  background: var(--bg-card-hover);
}

.ha-entity-confirm-label input:checked + span {
  color: #d97706;
}

[data-theme="dark"] .ha-entity-confirm-label input:checked + span {
  color: #fbbf24;
}

.ha-entity-select optgroup {
  font-weight: 800;
  font-size: 0.9rem;
  color: var(--primary-text);
  background: var(--bg-subtle);
  padding: 6px 4px;
}

.ha-entity-select option {
  font-weight: 500;
  font-size: 0.88rem;
  color: var(--text-primary);
  background: var(--bg-surface);
  padding: 6px 10px;
}

.ha-status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #94a3b8;
}

.ha-status-dot.online {
  background: var(--success);
  box-shadow: 0 0 0 2px var(--success-light);
}

.ha-status-dot.offline {
  background: var(--danger);
  box-shadow: 0 0 0 2px var(--danger-light);
}

/* Lock Screen Overlay & Authentication UI */
html.auth-locked,
body.auth-locked {
  overflow: hidden !important;
  height: 100vh !important;
  height: 100dvh !important;
  width: 100vw !important;
  position: fixed !important;
  top: 0 !important;
  left: 0 !important;
  touch-action: none !important;
  overscroll-behavior: none !important;
}

.auth-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  background: #090d16;
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  box-sizing: border-box;
  overflow: hidden;
  touch-action: none;
  overscroll-behavior: none;
  transition: opacity 0.3s ease, visibility 0.3s ease;
}

.auth-overlay.hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.auth-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 24px 20px;
  max-width: 350px;
  width: 100%;
  max-height: 94dvh;
  margin: auto;
  box-sizing: border-box;
  box-shadow: 0 16px 36px rgba(0, 0, 0, 0.45);
  text-align: center;
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: center;
  overflow: hidden;
}

.auth-spinner-wrapper {
  position: relative;
  width: 72px;
  height: 72px;
  margin: 12px auto 6px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.auth-brand-badge {
  font-size: 30px;
  animation: pulse-auth-badge 2s ease-in-out infinite;
  z-index: 2;
  line-height: 1;
  user-select: none;
}

.auth-spinner-ring {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  border: 3px solid rgba(59, 130, 246, 0.18);
  border-top-color: var(--primary, #3b82f6);
  border-right-color: var(--primary, #3b82f6);
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
  box-sizing: border-box;
}

@keyframes pulse-auth-badge {
  0%, 100% {
    transform: scale(1);
    opacity: 0.9;
  }
  50% {
    transform: scale(1.12);
    opacity: 1;
  }
}

.auth-icon {
  width: 52px;
  height: 52px;
  margin: 0 auto 12px;
  background: var(--primary-light);
  color: var(--primary);
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.15);
  flex-shrink: 0;
}

.auth-title {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.auth-subtitle {
  font-size: 0.8rem;
  color: var(--text-secondary);
  margin-bottom: 16px;
}

.pin-display {
  display: flex;
  justify-content: center;
  width: 100%;
  margin-bottom: 16px;
  box-sizing: border-box;
}

.pin-input {
  width: 100%;
  box-sizing: border-box;
  padding: 10px 12px;
  font-size: 1.4rem;
  font-weight: 700;
  letter-spacing: 0.25em;
  text-indent: 0.25em;
  text-align: center;
  background: var(--bg-subtle);
  border: 2px solid var(--border-color);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-family: inherit;
  transition: var(--transition);
}

.pin-input:focus {
  outline: none;
  border-color: var(--border-focus);
  box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.15);
}

.auth-error {
  background: var(--danger-light);
  color: var(--danger-text);
  border: 1px solid var(--danger);
  border-radius: var(--radius-md);
  padding: 8px 12px;
  font-size: 0.8rem;
  font-weight: 600;
  margin-bottom: 12px;
  display: none;
  animation: shake 0.4s ease;
}

/* Keypad */
.keypad-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 14px;
  width: 100%;
  box-sizing: border-box;
}

.keypad-btn {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 11px 0;
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text-primary);
  cursor: pointer;
  transition: var(--transition);
  font-family: inherit;
  box-sizing: border-box;
}

.keypad-btn:hover {
  background: var(--bg-subtle);
  border-color: var(--text-muted);
  transform: translateY(-1px);
}

.keypad-btn:active {
  transform: translateY(1px);
  background: var(--primary-light);
  color: var(--primary);
}

.keypad-btn.action {
  font-size: 1rem;
  color: var(--text-secondary);
}

.auth-security-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 8px;
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20%, 60% { transform: translateX(-8px); }
  40%, 80% { transform: translateX(8px); }
}

/* Ha Modal Entity Rows & Reordering */
.ha-quick-device-bar {
  display: flex;
  gap: 8px;
  margin-bottom: 8px;
}

#haEntityRowsContainer {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 8px;
}

.ha-modal-entity-row {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-card-hover);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 8px 10px;
  transition: transform 0.15s ease, opacity 0.15s ease, background-color 0.15s ease, box-shadow 0.15s ease;
}

.ha-modal-entity-row.dragging {
  opacity: 0.45;
  border-style: dashed;
  border-color: var(--primary);
  background: var(--primary-light);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.ha-reorder-handle-group {
  display: flex;
  align-items: center;
  gap: 3px;
  flex-shrink: 0;
}

.ha-drag-grip {
  cursor: grab;
  font-size: 1.1rem;
  color: var(--text-muted);
  padding: 2px 3px;
  line-height: 1;
  border-radius: var(--radius-sm);
  transition: color 0.15s ease;
  user-select: none;
}

.ha-drag-grip:hover {
  color: var(--text-primary);
}

.ha-drag-grip:active {
  cursor: grabbing;
}

.ha-reorder-btn-col {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.ha-reorder-btn {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 4px;
  color: var(--text-secondary);
  font-size: 0.62rem;
  width: 22px;
  height: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
  line-height: 1;
  transition: all 0.15s ease;
}

.ha-reorder-btn:hover {
  background: var(--primary);
  color: #ffffff;
  border-color: var(--primary);
  transform: scale(1.05);
}

.ha-reorder-btn:active {
  transform: scale(0.95);
}

/* ==========================================
   Dashboard Matrix Table (Dense Live View)
   ========================================== */
.dashboard-table-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  margin-bottom: 24px;
}

.dashboard-table-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  background: var(--bg-card-hover);
}

.dashboard-table-title {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
}

.dashboard-table-subtitle {
  font-size: 0.8rem;
  color: var(--text-muted);
  display: block;
  margin-top: 2px;
}

.table-search-input {
  max-width: 260px;
  padding: 6px 12px;
  font-size: 0.825rem;
  border-radius: var(--radius-md);
}

.table-responsive-container {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.dashboard-matrix-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 0.825rem;
  white-space: nowrap;
}

.dashboard-matrix-table thead th {
  background: var(--bg-subtle);
  color: var(--text-secondary);
  font-weight: 700;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 8px 10px;
  border-bottom: 2px solid var(--border-color);
  white-space: nowrap;
}

.dashboard-matrix-table thead th.sortable-th {
  cursor: pointer;
  user-select: none;
  transition: background-color 0.15s ease, color 0.15s ease;
}

.dashboard-matrix-table thead th.sortable-th:hover {
  background: var(--bg-card-hover);
  color: var(--text-primary);
}

.dashboard-matrix-table thead th.sortable-th.active-sort {
  color: var(--primary);
  background: var(--bg-card-hover);
}

.dashboard-matrix-table thead th .th-content {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.th-sort-icon {
  font-size: 0.65rem;
  opacity: 0.35;
  transition: opacity 0.15s ease;
  display: inline-block;
  vertical-align: middle;
}

.dashboard-matrix-table thead th.sortable-th:hover .th-sort-icon {
  opacity: 0.75;
}

.th-sort-icon.active {
  opacity: 1;
  color: var(--primary);
  font-weight: 800;
}

.dashboard-matrix-table tbody tr {
  border-bottom: 1px solid var(--border-color);
  transition: background-color 0.15s ease;
  white-space: nowrap;
}

.dashboard-matrix-table tbody tr:last-child {
  border-bottom: none;
}

.dashboard-matrix-table tbody tr:hover {
  background: var(--bg-card-hover);
}

.dashboard-matrix-table tbody td {
  padding: 6px 10px;
  vertical-align: middle;
  white-space: nowrap;
}

/* LED Online/Offline Indicators */
.table-led-cell {
  text-align: center;
}

.table-led-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  display: inline-block;
  vertical-align: middle;
  transition: all 0.25s ease;
}

.table-led-dot.online {
  background-color: #22c55e;
  box-shadow: 0 0 8px #22c55e, 0 0 14px rgba(34, 197, 94, 0.5);
  animation: ledPulseGreen 2.2s infinite ease-in-out;
}

.table-led-dot.offline {
  background-color: #ef4444;
  box-shadow: 0 0 6px rgba(239, 68, 68, 0.7);
}

.table-led-dot.no-ha {
  background-color: #94a3b8;
  opacity: 0.5;
}

@keyframes ledPulseGreen {
  0%, 100% {
    transform: scale(1);
    box-shadow: 0 0 6px #22c55e;
  }
  50% {
    transform: scale(1.15);
    box-shadow: 0 0 12px #22c55e, 0 0 18px rgba(34, 197, 94, 0.6);
  }
}

/* Table Device Info */
.table-device-name {
  font-weight: 700;
  color: var(--text-primary);
  font-size: 0.85rem;
  white-space: nowrap;
  line-height: 1.2;
}

.table-device-subnotes {
  font-size: 0.7rem;
  color: var(--text-muted);
  white-space: nowrap;
  max-width: 170px;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 2px;
}

.table-room-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 7px;
  border-radius: var(--radius-sm);
  background: var(--bg-subtle);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  font-size: 0.75rem;
  font-weight: 600;
  white-space: nowrap;
}

.table-app-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 7px;
  border-radius: var(--radius-sm);
  background: var(--bg-subtle);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  font-size: 0.75rem;
  font-weight: 600;
  white-space: nowrap;
}

.table-category-tag {
  display: inline-flex;
  align-items: center;
  padding: 2px 7px;
  border-radius: var(--radius-sm);
  background: var(--bg-subtle);
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  font-size: 0.72rem;
  font-weight: 600;
  white-space: nowrap;
}

.table-rate-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 3px;
  font-family: 'Share Tech Mono', monospace;
  font-size: 0.75rem;
  font-weight: 700;
  background: var(--bg-subtle);
  border: 1px solid var(--border-color);
  padding: 2px 7px;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  white-space: nowrap;
}

/* Compact Entity Chips Container & Drilldown */
.table-entities-wrapper {
  display: inline-flex;
  flex-direction: column;
  gap: 3px;
}

.table-entities-flex {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  white-space: nowrap;
}

.table-entities-extra {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px;
  margin-top: 3px;
  padding-top: 3px;
  border-top: 1px dashed var(--border-color);
  animation: fadeIn 0.15s ease;
}

.table-entities-drilldown-btn {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 2px 6px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  background: var(--bg-subtle);
  color: var(--primary);
  font-size: 0.68rem;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  outline: none;
  transition: all 0.15s ease;
  white-space: nowrap;
  user-select: none;
}

.table-entities-drilldown-btn:hover {
  background: var(--bg-card-hover);
  border-color: var(--primary);
}

.table-entities-drilldown-btn.active {
  background: var(--primary);
  color: #ffffff;
  border-color: var(--primary);
}

.table-row-actions {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 3px;
  flex-wrap: nowrap;
  white-space: nowrap;
}

.table-row-actions .btn {
  width: 26px;
  height: 26px;
  min-width: 26px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  border-radius: var(--radius-sm);
}

/* Mini Sensor Badge / Pill (Theme Adaptive) */
.table-sensor-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: var(--bg-subtle);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 2px 7px;
  font-family: 'Share Tech Mono', monospace;
  box-shadow: var(--shadow-sm);
  transition: all 0.2s ease;
  white-space: nowrap;
}

.table-sensor-pill:hover {
  border-color: var(--primary);
  transform: translateY(-1px);
}

.table-sensor-label {
  font-size: 0.68rem;
  color: var(--text-secondary);
  font-weight: 600;
  text-transform: uppercase;
  max-width: 100px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  letter-spacing: 0.02em;
}

.table-sensor-val {
  font-size: 0.8rem;
  font-weight: 800;
  color: var(--primary);
  letter-spacing: 0.02em;
}

[data-theme="dark"] .table-sensor-val {
  color: #38bdf8; /* Vibrant Cyan in dark mode */
}

.table-sensor-unit {
  font-size: 0.68rem;
  color: var(--text-muted);
  font-weight: 600;
}

[data-theme="dark"] .table-sensor-unit {
  color: #7dd3fc;
}

/* Mini Switch & Bulb Toggle Buttons in Table */
.table-toggle-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  background: var(--bg-surface);
  font-size: 0.75rem;
  font-weight: 700;
  cursor: pointer;
  outline: none;
  transition: all 0.15s ease;
  user-select: none;
  font-family: 'Share Tech Mono', monospace;
  box-shadow: var(--shadow-sm);
}

/* Switch ON */
.table-toggle-btn.is-on {
  background: #dcfce7;
  border-color: #86efac;
  color: #15803d;
}

[data-theme="dark"] .table-toggle-btn.is-on {
  background: rgba(34, 197, 94, 0.22);
  border-color: #22c55e;
  color: #4ade80;
}

/* Switch OFF */
.table-toggle-btn.is-off {
  background: #fee2e2;
  border-color: #fca5a5;
  color: #b91c1c;
}

[data-theme="dark"] .table-toggle-btn.is-off {
  background: rgba(239, 68, 68, 0.18);
  border-color: #ef4444;
  color: #f87171;
}

/* Light specific toggle ON */
.table-toggle-btn.light.is-on {
  background: #fef3c7;
  border-color: #fde047;
  color: #b45309;
  box-shadow: 0 0 8px rgba(245, 158, 11, 0.25);
}

[data-theme="dark"] .table-toggle-btn.light.is-on {
  color: #fbbf24;
  background: rgba(245, 158, 11, 0.25);
  border-color: #fbbf24;
  box-shadow: 0 0 10px rgba(251, 191, 36, 0.35);
}

/* Heater specific toggle ON */
.table-toggle-btn.heater.is-on {
  background: #ffedd5;
  border-color: #fdba74;
  color: #c2410c;
  box-shadow: 0 0 8px rgba(234, 88, 12, 0.25);
}

[data-theme="dark"] .table-toggle-btn.heater.is-on {
  color: #fb923c;
  background: rgba(234, 88, 12, 0.25);
  border-color: #f97316;
  box-shadow: 0 0 10px rgba(249, 115, 22, 0.35);
}

/* Boiler specific toggle ON */
.table-toggle-btn.boiler.is-on {
  background: #fee2e2;
  border-color: #fca5a5;
  color: #dc2626;
  box-shadow: 0 0 8px rgba(239, 68, 68, 0.25);
}

[data-theme="dark"] .table-toggle-btn.boiler.is-on {
  color: #f87171;
  background: rgba(239, 68, 68, 0.25);
  border-color: #ef4444;
  box-shadow: 0 0 10px rgba(239, 68, 68, 0.35);
}

/* Media specific toggle ON */
.table-toggle-btn.media.is-on {
  background: #dbeafe;
  border-color: #93c5fd;
  color: #2563eb;
  box-shadow: 0 0 8px rgba(59, 130, 246, 0.25);
}

[data-theme="dark"] .table-toggle-btn.media.is-on {
  color: #60a5fa;
  background: rgba(59, 130, 246, 0.25);
  border-color: #3b82f6;
  box-shadow: 0 0 10px rgba(59, 130, 246, 0.35);
}

.table-toggle-btn:hover {
  transform: scale(1.04);
}

.table-toggle-btn:active {
  transform: scale(0.96);
}

.table-empty-entities {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-style: italic;
}

/* ==========================================
   CAMERA ENTITY & LIVE STREAM STYLES
   ========================================== */
.ha-camera-card-wrapper {
  grid-column: 1 / -1;
  width: 100%;
  margin-top: 4px;
}

.ha-camera-preview-box {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  background: #090d16;
  border-radius: var(--radius-md);
  overflow: hidden;
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-sm);
  display: flex;
  align-items: center;
  justify-content: center;
}

.ha-camera-preview-box:hover .ha-camera-snapshot-img {
  transform: scale(1.02);
}

.ha-camera-preview-box:hover .ha-camera-live-trigger-btn {
  background: rgba(3, 105, 161, 0.9);
  border-color: #38bdf8;
  box-shadow: 0 4px 14px rgba(3, 105, 161, 0.4);
}

.ha-camera-snapshot-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.3s ease;
}

.ha-camera-overlay-top {
  position: absolute;
  top: 8px;
  left: 8px;
  right: 8px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  pointer-events: none;
  z-index: 2;
}

.ha-camera-badge {
  background: rgba(15, 23, 42, 0.75);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  color: #f8fafc;
  padding: 3px 8px;
  border-radius: var(--radius-sm);
  font-size: 0.7rem;
  font-weight: 700;
  font-family: 'Share Tech Mono', monospace;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.3);
}

.ha-camera-pulse-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #22c55e;
  box-shadow: 0 0 6px #22c55e;
  display: inline-block;
  animation: cameraPulse 2s infinite;
}

@keyframes cameraPulse {
  0% { transform: scale(0.95); opacity: 0.8; }
  50% { transform: scale(1.25); opacity: 1; box-shadow: 0 0 10px #22c55e; }
  100% { transform: scale(0.95); opacity: 0.8; }
}

.ha-camera-overlay-bottom {
  position: absolute;
  bottom: 8px;
  left: 8px;
  right: 8px;
  display: flex;
  justify-content: flex-end;
  z-index: 3;
}

.ha-camera-live-trigger-btn {
  background: rgba(15, 23, 42, 0.8);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid rgba(255, 255, 255, 0.25);
  color: #ffffff;
  padding: 6px 14px;
  border-radius: var(--radius-md);
  font-size: 0.8rem;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all 0.2s ease;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
}

.ha-camera-live-trigger-btn:hover {
  transform: translateY(-2px);
}

.ha-camera-live-trigger-btn:active {
  transform: translateY(0);
}

/* Dashboard Table Camera Entity Button */
.table-camera-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  border-radius: var(--radius-sm);
  border: 1px solid #38bdf8;
  background: rgba(14, 165, 233, 0.12);
  color: #0284c7;
  font-size: 0.75rem;
  font-weight: 700;
  cursor: pointer;
  outline: none;
  transition: all 0.15s ease;
  user-select: none;
  font-family: 'Share Tech Mono', monospace;
  box-shadow: var(--shadow-sm);
}

[data-theme="dark"] .table-camera-btn {
  background: rgba(14, 165, 233, 0.22);
  color: #38bdf8;
  border-color: #0284c7;
}

.table-camera-btn:hover {
  background: #0284c7;
  color: #ffffff;
  transform: scale(1.04);
}

.table-camera-live-badge {
  font-size: 0.65rem;
  background: #ef4444;
  color: #fff;
  padding: 1px 4px;
  border-radius: 3px;
  font-weight: 800;
  letter-spacing: 0.03em;
}

/* Live Stream Modal Styles */
.camera-live-badge-pulse {
  font-size: 0.72rem;
  font-weight: 800;
  background: rgba(239, 68, 68, 0.2);
  color: #ef4444;
  border: 1px solid rgba(239, 68, 68, 0.4);
  padding: 2px 8px;
  border-radius: 12px;
  font-family: 'Share Tech Mono', monospace;
  animation: liveBadgePulse 1.8s infinite ease-in-out;
}

@keyframes liveBadgePulse {
  0% { transform: scale(0.98); opacity: 0.85; }
  50% { transform: scale(1.05); opacity: 1; box-shadow: 0 0 10px rgba(239, 68, 68, 0.4); }
  100% { transform: scale(0.98); opacity: 0.85; }
}

.camera-stream-spinner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  color: #94a3b8;
  font-size: 0.85rem;
  font-weight: 600;
  padding: 40px;
}

.camera-stream-spinner .spinner-ring {
  width: 38px;
  height: 38px;
  border: 3px solid rgba(255, 255, 255, 0.15);
  border-top-color: #38bdf8;
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ==========================================
   GESTIONE APP & SERVIZI CLOUD STYLES
   ========================================== */
.apps-view-card {
  padding: 24px;
}

.apps-summary-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin: 18px 0 24px;
}

.apps-stat-box {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  padding: 16px 20px;
  border-radius: var(--radius-lg);
  display: flex;
  flex-direction: column;
  gap: 4px;
  box-shadow: var(--shadow-sm);
  transition: transform 0.2s ease, border-color 0.2s ease;
}

.apps-stat-box:hover {
  transform: translateY(-2px);
  border-color: var(--primary);
}

.apps-stat-num {
  font-size: 1.8rem;
  font-weight: 800;
  font-family: 'Orbitron', 'Plus Jakarta Sans', sans-serif;
  color: var(--primary);
  line-height: 1.1;
}

.apps-stat-lbl {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.apps-cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(360px, 1fr));
  gap: 20px;
  align-items: start;
}

.app-manage-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: 16px;
  transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
  position: relative;
  overflow: hidden;
}

.app-manage-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-md);
  border-color: rgba(37, 99, 235, 0.4);
}

.app-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.app-card-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.app-brand-avatar {
  width: 46px;
  height: 46px;
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.12);
  flex-shrink: 0;
  color: #ffffff;
}

.app-brand-info {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.app-brand-name {
  font-size: 1.12rem;
  font-weight: 800;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.app-brand-count-badge {
  font-size: 0.76rem;
  font-weight: 700;
  color: var(--text-secondary);
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.app-card-top-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

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

.app-section-title {
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.app-devices-chips-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  max-height: 140px;
  overflow-y: auto;
  padding: 2px;
}

.app-device-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  background: var(--bg-subtle);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-full);
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-primary);
  cursor: pointer;
  transition: all 0.15s ease;
  user-select: none;
}

.app-device-chip:hover {
  background: var(--primary-light);
  border-color: var(--primary);
  color: var(--primary-text);
  transform: translateY(-1px);
}

.app-device-chip .chip-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #94a3b8;
}

.app-device-chip .chip-dot.online {
  background: #10b981;
  box-shadow: 0 0 6px rgba(16, 185, 129, 0.6);
}

.app-account-row {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.app-notes-wrapper {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.app-notes-textarea {
  width: 100%;
  min-height: 96px;
  max-height: 240px;
  padding: 10px 12px;
  font-family: inherit;
  font-size: 0.86rem;
  line-height: 1.45;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  background: var(--bg-subtle);
  color: var(--text-primary);
  resize: vertical;
  box-sizing: border-box;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.app-notes-textarea:focus {
  outline: none;
  border-color: var(--primary);
  background: var(--bg-surface);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

.app-card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding-top: 8px;
  border-top: 1px dashed var(--border-color);
  font-size: 0.74rem;
  color: var(--text-muted);
}

.app-save-indicator {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-weight: 600;
  transition: opacity 0.3s;
}

.app-save-indicator.saved {
  color: #10b981;
}

.apps-empty-state {
  text-align: center;
  padding: 48px 20px;
  color: var(--text-secondary);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.apps-empty-icon {
  font-size: 3rem;
  opacity: 0.6;
}

/* ==========================================
   INTERACTIVE MAP / PIANTINA STYLES
   ========================================== */
.map-view-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.map-toolbar {
  padding: 14px 18px;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.map-toolbar-main-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  width: 100%;
}

.map-toolbar-title-box {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  flex: 1 1 auto;
}

.map-toolbar-title {
  font-size: 1.15rem;
  font-weight: 800;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  white-space: nowrap;
}

.map-toolbar-subtitle {
  font-size: 0.8rem;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

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

.map-mode-toggle-group {
  display: inline-flex;
  background: var(--bg-subtle);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 3px;
  gap: 3px;
}

.map-mode-btn {
  padding: 5px 12px;
  border-radius: var(--radius-sm);
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-size: 0.8rem;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all 0.2s ease;
}

.map-mode-btn.active {
  background: var(--primary);
  color: #ffffff;
  box-shadow: 0 2px 6px rgba(37, 99, 235, 0.3);
}

.map-edit-tools-subbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  padding-top: 10px;
  border-top: 1px dashed var(--border-color);
  width: 100%;
}

.map-edit-tools-hint {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--primary);
  display: flex;
  align-items: center;
  gap: 6px;
}

.map-edit-tools-buttons {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.map-zoom-group {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.map-workspace {
  position: relative;
  display: flex;
  flex: 1;
  min-height: 0;
  background: var(--bg-card);
  overflow: hidden;
  align-items: stretch;
}

.map-workspace.map-mode-edit {
  min-height: 480px;
  height: calc(100vh - 180px);
  max-height: 900px;
}

/* Devices Drawer (Edit Mode) */
.map-devices-drawer {
  width: 270px;
  max-width: 270px;
  height: 100%;
  max-height: 100%;
  background: var(--bg-surface);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  z-index: 10;
  flex-shrink: 0;
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.map-drawer-header {
  padding: 12px 14px 8px;
  border-bottom: 1px solid var(--border-color);
}

.map-drawer-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 2px;
}

.map-drawer-title {
  font-size: 0.92rem;
  font-weight: 800;
  margin: 0;
  display: flex;
  align-items: center;
  gap: 6px;
}

.map-drawer-hint {
  font-size: 0.72rem;
  color: var(--text-muted);
}

.map-floating-drawer-toggle {
  position: absolute;
  top: 18px;
  left: 18px;
  z-index: 25;
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  padding: 8px 14px;
  border-radius: 20px;
  font-size: 0.8rem;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.25);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.map-floating-drawer-toggle:hover {
  background: var(--bg-card-hover);
  border-color: var(--primary);
  transform: translateY(-2px) scale(1.02);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.35);
}

.map-drawer-search {
  padding: 8px 14px;
}

.map-drawer-list {
  flex: 1;
  overflow-y: auto;
  padding: 6px 10px 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-height: 0;
}

.map-drawer-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  cursor: grab;
  transition: all 0.2s ease;
  user-select: none;
}

.map-drawer-item:hover {
  border-color: var(--primary);
  transform: translateX(2px);
  background: var(--bg-card-hover);
}

.map-drawer-item:active {
  cursor: grabbing;
}

.map-drawer-item.is-placed {
  opacity: 0.75;
  border-style: dashed;
}

.map-drawer-item-icon {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  flex-shrink: 0;
}

.map-drawer-item-info {
  flex: 1;
  min-width: 0;
}

.map-drawer-item-name {
  font-size: 0.82rem;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.map-drawer-item-room {
  font-size: 0.7rem;
  color: var(--text-muted);
}

/* Map Viewport & Canvas */
.map-viewport {
  flex: 1;
  position: relative;
  overflow: hidden;
  scrollbar-width: none;
  -ms-overflow-style: none;
  min-height: 0;
  height: 100%;
  /* Default / View Mode: Outdoor Garden / Lawn Green */
  background-color: #11261b;
  background-image: 
    radial-gradient(ellipse at 50% 50%, #1a3828 0%, #12281c 65%, #0b1a12 100%);
  display: block;
  padding: 0;
  cursor: default;
  transition: background-color 0.4s ease;
}

.map-viewport::-webkit-scrollbar {
  display: none;
}

[data-theme="light"] .map-viewport {
  background-color: #c5e6cb;
  background-image: 
    radial-gradient(ellipse at 50% 50%, #d8f3dc 0%, #bde7c5 65%, #9fd8ab 100%);
}

/* Edit / Design Mode: Technical Blueprint Grid & Canvas */
.map-viewport.map-mode-edit {
  background: #090d16;
  background-image: 
    radial-gradient(rgba(56, 189, 248, 0.1) 1px, transparent 1px),
    radial-gradient(rgba(56, 189, 248, 0.05) 1px, transparent 1px);
  background-size: 20px 20px, 100px 100px;
}

[data-theme="light"] .map-viewport.map-mode-edit {
  background: #f1f5f9;
  background-image: 
    radial-gradient(rgba(14, 165, 233, 0.18) 1px, transparent 1px),
    radial-gradient(rgba(14, 165, 233, 0.08) 1px, transparent 1px);
  background-size: 20px 20px, 100px 100px;
}

.map-stage {
  position: absolute;
  top: 0;
  left: 0;
  width: 1000px;
  min-width: 1000px;
  max-width: 1000px;
  height: 640px;
  min-height: 640px;
  max-height: 640px;
  flex-shrink: 0;
  box-sizing: border-box;
  transform-origin: 0 0;
  transition: transform 0.28s cubic-bezier(0.25, 1, 0.5, 1);
  margin: 0;
  background: transparent;
  border: none;
  box-shadow: none;
}

/* Edit / Design Mode: Technical Blueprint Stage */
.map-stage.map-mode-edit {
  background: rgba(15, 23, 42, 0.65);
  background-image: none;
  border: 1.5px solid rgba(56, 189, 248, 0.35);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
  border-radius: var(--radius-md);
}

[data-theme="light"] .map-stage.map-mode-edit {
  background: rgba(255, 255, 255, 0.75);
  background-image: none;
  border-color: rgba(14, 165, 233, 0.35);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.08);
}

/* Grid Squares: Hidden in View Mode, Visible in Edit Mode */
.map-grid-bg {
  display: none;
  opacity: 0;
  color: #38bdf8;
  transition: opacity 0.25s ease;
}

.map-stage.map-mode-edit .map-grid-bg {
  display: block;
  opacity: 1;
}

[data-theme="light"] .map-grid-bg {
  color: #0ea5e9;
}

/* Indoor Room Floor Base */
.map-room-floor-base {
  fill: #0c1322;
  stroke: none !important;
  shape-rendering: geometricPrecision;
  pointer-events: none;
  transition: fill 0.3s ease;
}

[data-theme="light"] .map-room-floor-base {
  fill: #f8fafc;
  stroke: none !important;
}

.map-svg-layer {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: all;
}

.map-viewport,
.map-stage,
.map-svg-layer,
.map-room-group,
.map-room-fill,
.map-room-shape,
.map-room-wall {
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
  user-select: none;
  -webkit-user-select: none;
}

.map-room-group {
  cursor: pointer;
  pointer-events: all;
}

.map-room-fill {
  cursor: pointer;
  pointer-events: all;
  shape-rendering: geometricPrecision;
  transition: fill 0.2s ease, filter 0.2s ease;
}

.map-room-shape {
  cursor: pointer;
  pointer-events: all;
  transition: fill 0.2s ease, stroke 0.2s ease, stroke-width 0.2s ease, filter 0.2s ease;
  stroke-linejoin: round;
}

.map-room-group.map-room-hovered .map-room-fill,
.map-room-group.map-room-hovered .map-room-shape {
  filter: brightness(1.22);
}

@media (hover: hover) and (pointer: fine) {
  .map-room-group:hover .map-room-fill,
  .map-room-group:hover .map-room-shape {
    filter: brightness(1.22);
  }
}

.map-room-shape.selected {
  stroke-width: 2.5px;
  filter: drop-shadow(0 0 6px rgba(56, 189, 248, 0.45));
}

@keyframes mapRoomFlashAnim {
  0% {
    filter: brightness(1);
  }
  35% {
    filter: brightness(1.65);
  }
  100% {
    filter: brightness(1);
  }
}

.map-room-group.map-room-flash .map-room-fill,
.map-room-group.map-room-flash .map-room-shape {
  animation: mapRoomFlashAnim 0.55s cubic-bezier(0.2, 0.8, 0.2, 1);
}

/* ==========================================
   MAP LIGHTING EFFECTS (INTERIOR & EXTERIOR)
   ========================================== */
.map-exterior-halo-circle {
  pointer-events: none;
  opacity: 0.95;
  filter: drop-shadow(0 0 16px rgba(245, 158, 11, 0.45));
}

.map-room-light-fill {
  pointer-events: none;
  shape-rendering: geometricPrecision;
  mix-blend-mode: screen;
  opacity: 0.95;
}

[data-theme="light"] .map-room-light-fill {
  mix-blend-mode: normal;
  opacity: 0.88;
}

.map-interior-core-flare {
  pointer-events: none;
  mix-blend-mode: screen;
  opacity: 0.95;
  filter: drop-shadow(0 0 10px rgba(254, 240, 138, 0.6));
}

[data-theme="light"] .map-interior-core-flare {
  mix-blend-mode: normal;
  opacity: 0.85;
}

.map-room-group.map-room-illuminated .map-room-fill {
  transition: fill 0.4s ease;
}

.map-room-group.map-room-illuminated .map-room-wall,
.map-room-wall-group.map-room-illuminated .map-room-wall {
  stroke: #f59e0b !important;
  filter: drop-shadow(0 0 5px rgba(245, 158, 11, 0.7));
  transition: stroke 0.4s ease, filter 0.4s ease;
}

/* Modalità Notturna / Dopo il Tramonto per Esterno e Stanze */
.map-viewport.map-is-night:not(.map-mode-edit) {
  background-color: #0a1710;
  background-image: 
    radial-gradient(ellipse at 50% 50%, #0e2318 0%, #08160f 65%, #040c08 100%);
}

[data-theme="light"] .map-viewport.map-is-night:not(.map-mode-edit) {
  background-color: #7d9a84;
  background-image: 
    radial-gradient(ellipse at 50% 50%, #8ea995 0%, #76927d 65%, #5f7a66 100%);
}

.map-stage.map-is-night .map-room-group:not(.map-room-illuminated) .map-room-floor-base {
  fill: #060912;
  stroke: none !important;
}

[data-theme="light"] .map-stage.map-is-night .map-room-group:not(.map-room-illuminated) .map-room-floor-base {
  fill: #1e293b;
  stroke: none !important;
}

.map-stage.map-is-night .map-room-group:not(.map-room-illuminated) .map-room-fill,
.map-stage.map-is-night .map-room-group:not(.map-room-illuminated) .map-room-shape {
  fill: rgba(8, 12, 22, 0.84) !important;
  transition: fill 0.5s ease;
}

[data-theme="light"] .map-stage.map-is-night .map-room-group:not(.map-room-illuminated) .map-room-fill,
[data-theme="light"] .map-stage.map-is-night .map-room-group:not(.map-room-illuminated) .map-room-shape {
  fill: rgba(30, 41, 59, 0.65) !important;
  transition: fill 0.5s ease;
}

.map-stage.map-is-night .map-room-group:not(.map-room-illuminated) .map-room-label-tag {
  opacity: 0.6;
  transition: opacity 0.5s ease;
}

.map-stage.map-is-night .map-room-group.map-room-illuminated .map-room-label-tag {
  opacity: 1;
  color: #fffbeb;
}

.map-labels-container {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 45;
}

.map-room-label-tag {
  position: absolute;
  transform: translate(-50%, -50%);
  pointer-events: auto;
  background: transparent;
  color: #f8fafc;
  padding: 3px 6px;
  border-radius: 8px;
  border: none;
  box-shadow: none;
  cursor: pointer;
  user-select: none;
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  text-align: center;
  max-width: 220px;
  z-index: 45;
  transition: transform 0.15s ease, filter 0.15s ease, opacity 0.2s ease;
}

[data-theme="light"] .map-room-label-tag {
  background: transparent;
  color: #0f172a;
  border: none;
  box-shadow: none;
}

.map-stage.map-mode-edit .map-room-label-tag {
  cursor: grab;
}

.map-stage.map-mode-edit .map-room-label-tag:hover {
  filter: brightness(1.15);
  background: rgba(56, 189, 248, 0.12);
  outline: 1.5px dashed rgba(56, 189, 248, 0.7);
  outline-offset: 3px;
  border-radius: 8px;
}

.map-room-title {
  font-size: 0.82rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
  color: #f8fafc;
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.85), 0 0 2px rgba(0, 0, 0, 0.95);
}

[data-theme="light"] .map-room-title {
  color: #0f172a;
  text-shadow: 0 1px 3px rgba(255, 255, 255, 0.95), 0 0 4px rgba(255, 255, 255, 0.9);
}

/* Room HVAC Active Animations (Heating Waves & Cooling Flakes) */
.room-hvac-effect {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 3px;
  line-height: 1;
  pointer-events: none;
  margin-bottom: -1px;
  animation: hvacFadeIn 0.35s ease-out;
}

@keyframes hvacFadeIn {
  0% {
    opacity: 0;
    transform: translateY(3px) scale(0.85);
  }
  100% {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* 1. Heating Waves (Warm heat rising animation) */
.room-hvac-effect.heating {
  color: #ea580c;
}

.room-heat-wave {
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-size: 0.92rem;
  font-weight: 900;
  display: inline-block;
  color: #ea580c;
  filter: drop-shadow(0 0 4px rgba(249, 115, 22, 0.85)) drop-shadow(0 0 8px rgba(239, 68, 68, 0.5));
  animation: roomHeatWaveFloat 1.2s ease-in-out infinite alternate;
  line-height: 0.7;
}

.room-heat-wave.w1 {
  animation-delay: 0s;
  color: #ea580c;
}

.room-heat-wave.w2 {
  animation-delay: 0.25s;
  font-size: 1.05rem;
  color: #f97316;
}

.room-heat-wave.w3 {
  animation-delay: 0.5s;
  color: #ea580c;
}

@keyframes roomHeatWaveFloat {
  0% {
    transform: translateY(1px) scale(0.9) rotate(-4deg);
    opacity: 0.7;
    filter: drop-shadow(0 0 3px rgba(234, 88, 12, 0.6));
  }
  50% {
    filter: drop-shadow(0 0 7px rgba(249, 115, 22, 0.95)) drop-shadow(0 0 12px rgba(239, 68, 68, 0.6));
  }
  100% {
    transform: translateY(-4px) scale(1.18) rotate(5deg);
    opacity: 1;
    filter: drop-shadow(0 0 8px #f97316) drop-shadow(0 0 14px #ef4444);
  }
}

[data-theme="light"] .room-heat-wave {
  filter: drop-shadow(0 0 3px rgba(234, 88, 12, 0.75));
}

/* 2. Cooling Breeze / Snow Crystals (Crisp fresh cooling animation) */
.room-hvac-effect.cooling {
  color: #0284c7;
}

.room-cool-flake {
  font-size: 0.82rem;
  display: inline-block;
  color: #38bdf8;
  filter: drop-shadow(0 0 5px rgba(56, 189, 248, 0.9)) drop-shadow(0 0 9px rgba(14, 165, 233, 0.5));
  animation: roomCoolBreeze 1.8s ease-in-out infinite alternate;
  line-height: 0.8;
}

.room-cool-flake.f1 {
  animation-delay: 0s;
  font-size: 0.78rem;
  color: #38bdf8;
}

.room-cool-flake.f2 {
  animation-delay: 0.35s;
  font-size: 0.7rem;
  color: #7dd3fc;
}

.room-cool-flake.f3 {
  animation-delay: 0.7s;
  font-size: 0.78rem;
  color: #38bdf8;
}

@keyframes roomCoolBreeze {
  0% {
    transform: translateY(0px) rotate(-8deg) scale(0.9);
    opacity: 0.65;
    filter: drop-shadow(0 0 3px rgba(56, 189, 248, 0.6));
  }
  50% {
    filter: drop-shadow(0 0 7px rgba(56, 189, 248, 0.95)) drop-shadow(0 0 12px rgba(14, 165, 233, 0.6));
  }
  100% {
    transform: translateY(3px) rotate(12deg) scale(1.15);
    opacity: 1;
    filter: drop-shadow(0 0 9px #38bdf8) drop-shadow(0 0 14px #0284c7);
  }
}

[data-theme="light"] .room-cool-flake {
  color: #0284c7;
  filter: drop-shadow(0 0 3px rgba(2, 132, 199, 0.7));
}

/* Room Climate Telemetry Ticker & Carousel */
.map-room-climate-ticker {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  width: 100%;
  min-height: 18px;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: normal;
  text-transform: none;
  margin-top: 3px;
}

.map-room-climate-ticker.layout-horizontal {
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 4px;
}

.map-room-climate-ticker.layout-vertical {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
}

.map-room-climate-ticker.layout-carousel,
.map-room-climate-carousel {
  display: grid;
  grid-template-columns: 1fr;
  grid-template-rows: 1fr;
  align-items: center;
  justify-items: center;
  position: relative;
  min-height: 22px;
  overflow: hidden;
  padding: 2px 4px;
}

.map-room-climate-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 7px;
  border-radius: 10px;
  background: #0f172a;
  border: 1px solid rgba(255, 255, 255, 0.2);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  color: #f8fafc;
  font-size: 0.68rem;
  font-weight: 700;
  white-space: nowrap;
  line-height: 1.2;
  box-sizing: border-box;
}

.map-room-climate-chip.type-temp {
  background: linear-gradient(rgba(245, 158, 11, 0.32), rgba(245, 158, 11, 0.32)), #0f172a;
  border-color: rgba(245, 158, 11, 0.65);
  color: #fef08a;
}

.map-room-climate-chip.type-humidity {
  background: linear-gradient(rgba(14, 165, 233, 0.32), rgba(14, 165, 233, 0.32)), #0f172a;
  border-color: rgba(14, 165, 233, 0.65);
  color: #bae6fd;
}

.map-room-climate-chip.type-climate {
  background: linear-gradient(rgba(168, 85, 247, 0.32), rgba(168, 85, 247, 0.32)), #0f172a;
  border-color: rgba(168, 85, 247, 0.65);
  color: #e9d5ff;
}

.map-room-climate-chip.type-air {
  background: linear-gradient(rgba(16, 185, 129, 0.32), rgba(16, 185, 129, 0.32)), #0f172a;
  border-color: rgba(16, 185, 129, 0.65);
  color: #a7f3d0;
}

.map-room-climate-chip.type-battery {
  background: linear-gradient(rgba(34, 197, 94, 0.32), rgba(34, 197, 94, 0.32)), #0f172a;
  border-color: rgba(34, 197, 94, 0.65);
  color: #bbf7d0;
}

.map-room-climate-chip.type-power {
  background: linear-gradient(rgba(234, 179, 8, 0.32), rgba(234, 179, 8, 0.32)), #0f172a;
  border-color: rgba(234, 179, 8, 0.65);
  color: #fef08a;
}

[data-theme="light"] .map-room-climate-chip {
  background: rgba(255, 255, 255, 0.95);
  border-color: rgba(0, 0, 0, 0.15);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.12);
  color: #0f172a;
}

[data-theme="light"] .map-room-climate-chip.type-temp {
  background: #fef3c7;
  border-color: rgba(245, 158, 11, 0.5);
  color: #92400e;
}

[data-theme="light"] .map-room-climate-chip.type-humidity {
  background: #e0f2fe;
  border-color: rgba(14, 165, 233, 0.5);
  color: #075985;
}

[data-theme="light"] .map-room-climate-chip.type-climate {
  background: #f3e8ff;
  border-color: rgba(168, 85, 247, 0.5);
  color: #6b21a8;
}

[data-theme="light"] .map-room-climate-chip.type-air {
  background: #d1fae5;
  border-color: rgba(16, 185, 129, 0.5);
  color: #065f46;
}

[data-theme="light"] .map-room-climate-chip.type-battery {
  background: #dcfce7;
  border-color: rgba(34, 197, 94, 0.5);
  color: #166534;
}

[data-theme="light"] .map-room-climate-chip.type-power {
  background: #fef9c3;
  border-color: rgba(234, 179, 8, 0.5);
  color: #854d0e;
}

.map-room-carousel-item {
  grid-area: 1 / 1 / 2 / 2;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.45s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.45s ease, visibility 0.45s ease;
  opacity: 0;
  transform: translateY(100%);
  pointer-events: none;
  visibility: hidden;
  width: max-content;
}

.map-room-carousel-item.active {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
  visibility: visible;
}

.map-room-carousel-item.slide-out {
  opacity: 0;
  transform: translateY(-100%);
  visibility: visible;
}

.map-room-label-tag:hover {
  filter: brightness(1.15);
}

.map-room-label-tag.dragging {
  opacity: 0.9;
  transform: translate(-50%, -50%) scale(1.08);
  cursor: grabbing !important;
  z-index: 50;
}

.map-standalone-label {
  background: rgba(15, 23, 42, 0.85);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  padding: 4px 10px;
  border-radius: 12px;
  border: 1px solid rgba(56, 189, 248, 0.45);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.35);
  color: #38bdf8;
}

[data-theme="light"] .map-standalone-label {
  background: rgba(240, 249, 255, 0.95);
  border: 1px solid rgba(2, 132, 199, 0.4);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
  color: #0284c7;
}

.map-room-label-tag.selected {
  outline: 2px dashed #38bdf8;
  outline-offset: 4px;
}

/* Combo-Dropdown Component */
.combo-input-wrapper {
  position: relative;
  display: flex;
  align-items: center;
  width: 100%;
}

.combo-input-wrapper .form-input {
  width: 100%;
  padding-right: 32px;
}

.combo-toggle-btn {
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 0.65rem;
  padding: 4px 6px;
  cursor: pointer;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.15s ease, background 0.15s ease, transform 0.15s ease;
  user-select: none;
  z-index: 2;
}

.combo-toggle-btn:hover {
  color: var(--primary);
  background: var(--bg-hover);
}

.combo-toggle-btn.open {
  transform: translateY(-50%) rotate(180deg);
  color: var(--primary);
}

.combo-dropdown-menu {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  max-height: 220px;
  overflow-y: auto;
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm, 6px);
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.4);
  z-index: 6000;
  display: none;
  flex-direction: column;
  padding: 4px;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

[data-theme="light"] .combo-dropdown-menu {
  background: rgba(255, 255, 255, 0.98);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.14);
}

.combo-dropdown-menu.open {
  display: flex;
}

.combo-dropdown-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 7px 10px;
  font-size: 0.84rem;
  font-weight: 500;
  color: var(--text-main);
  border-radius: 4px;
  cursor: pointer;
  transition: background 0.12s ease, color 0.12s ease;
  user-select: none;
}

.combo-dropdown-item:hover,
.combo-dropdown-item.focused {
  background: var(--bg-hover);
  color: var(--primary);
}

.combo-dropdown-item.active {
  background: rgba(59, 130, 246, 0.12);
  color: var(--primary);
  font-weight: 700;
}

.combo-dropdown-item-check {
  font-size: 0.8rem;
  color: var(--primary);
  font-weight: 800;
}

.combo-dropdown-empty {
  padding: 10px 12px;
  font-size: 0.8rem;
  color: var(--text-muted);
  text-align: center;
}

/* Customizer Climate Selector List Styles */
.room-climate-selector-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.room-climate-option,
.pin-badge-option {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 6px 8px;
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
  user-select: none;
}

.room-climate-option:hover,
.pin-badge-option:hover {
  background: var(--bg-hover);
  border-color: var(--primary-light);
}

.room-climate-option.selected,
.pin-badge-option.selected {
  border-color: var(--primary);
  background: rgba(59, 130, 246, 0.1);
}

.room-climate-option-left,
.pin-badge-option-left {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  flex: 1;
}

.room-climate-option input[type="checkbox"],
.pin-badge-option input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--primary);
  cursor: pointer;
  flex-shrink: 0;
}

.room-climate-option-info,
.pin-badge-option-info {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.room-climate-option-title,
.pin-badge-option-title {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.room-climate-option-id,
.pin-badge-option-id {
  font-size: 0.68rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.room-climate-val-badge,
.pin-badge-val-badge {
  font-size: 0.72rem;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 10px;
  background: var(--bg-subtle);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  flex-shrink: 0;
  white-space: nowrap;
}

.room-climate-option:hover {
  background: var(--bg-hover);
  border-color: var(--primary-light);
}

.room-climate-option.selected {
  border-color: var(--primary);
  background: rgba(59, 130, 246, 0.1);
}

.room-climate-option-left {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  flex: 1;
}

.room-climate-option input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--primary);
  cursor: pointer;
  flex-shrink: 0;
}

.room-climate-option-info {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.room-climate-option-title {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.room-climate-option-id {
  font-size: 0.68rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.room-climate-val-badge {
  font-size: 0.72rem;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 10px;
  background: var(--bg-subtle);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  flex-shrink: 0;
  white-space: nowrap;
}

/* Map Device Markers / Pins */
.map-pins-container {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.map-pin {
  position: absolute;
  transform: translate(-50%, -50%);
  pointer-events: auto;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  touch-action: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1), filter 0.2s ease;
  z-index: 5;
}

.map-stage.map-mode-edit .map-pin,
.map-room-label-tag,
.map-standalone-label,
.map-transform-box,
.transform-handle {
  touch-action: none;
  -webkit-touch-callout: none;
  user-select: none;
  -webkit-user-select: none;
}

.map-pin:hover {
  transform: translate(-50%, -50%) scale(1.18);
  z-index: 20;
}

.map-pin.dragging {
  opacity: 0.85;
  transform: translate(-50%, -50%) scale(1.25);
  cursor: grabbing;
  z-index: 50;
}

/* Standard Pin Avatar */
.map-pin-avatar {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: var(--bg-surface);
  border: 2px solid #3b82f6;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.35);
  position: relative;
  transition: all 0.25s ease;
}

[data-theme="light"] .map-pin-avatar {
  background: #ffffff;
  border-color: #cbd5e1;
  color: #0f172a;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
}

.map-pin-avatar.is-on:not(.map-bulb-avatar):not(.map-boiler-avatar):not(.map-heater-avatar):not(.map-switch-avatar) {
  border-color: #3b82f6;
  box-shadow: 0 0 16px rgba(59, 130, 246, 0.6), 0 2px 8px rgba(0, 0, 0, 0.2);
}

[data-theme="light"] .map-pin-avatar.is-on:not(.map-bulb-avatar):not(.map-boiler-avatar):not(.map-heater-avatar):not(.map-switch-avatar) {
  border-color: #3b82f6;
  box-shadow: 0 0 14px rgba(59, 130, 246, 0.45), 0 2px 8px rgba(0, 0, 0, 0.1);
}

/* Bulb Pin Avatar (Map) - Simple & Clean */
.map-pin-avatar.map-bulb-avatar {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  font-size: 1.3rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.25s ease;
}

.map-bulb-emoji {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  transition: all 0.25s ease;
}

.map-pin-avatar.map-bulb-avatar.is-off {
  background: #1e293b;
  border-color: #475569;
}

.map-pin-avatar.map-bulb-avatar.is-off .map-bulb-emoji {
  opacity: 0.35;
  filter: grayscale(100%) brightness(0.65);
}

[data-theme="light"] .map-pin-avatar.map-bulb-avatar.is-off {
  background: #f1f5f9;
  border-color: #cbd5e1;
}

[data-theme="light"] .map-pin-avatar.map-bulb-avatar.is-off .map-bulb-emoji {
  opacity: 0.45;
  filter: grayscale(100%) brightness(0.85);
}

.map-pin-avatar.map-bulb-avatar.is-on {
  background: radial-gradient(circle, #fef08a 0%, #f59e0b 70%, #d97706 100%);
  border-color: #fbbf24;
  box-shadow: 0 0 20px rgba(245, 158, 11, 0.8), 0 0 35px rgba(251, 191, 36, 0.45);
}

.map-pin-avatar.map-bulb-avatar.is-on .map-bulb-emoji {
  opacity: 1;
  filter: drop-shadow(0 0 4px #ffffff) drop-shadow(0 0 8px #fbbf24);
  transform: scale(1.12);
}

[data-theme="light"] .map-pin-avatar.map-bulb-avatar.is-on {
  background: radial-gradient(circle, #fef9c3 0%, #fde047 80%, #eab308 100%);
  border-color: #f59e0b;
  box-shadow: 0 0 18px rgba(234, 179, 8, 0.75), 0 2px 8px rgba(0, 0, 0, 0.12);
}

/* Vertical Dimmer Slider beside Map Pin Bulb */
.map-pin-body-row {
  display: flex;
  align-items: center;
  gap: 6px;
  position: relative;
}

.map-pin-dimmer-slider {
  width: 14px;
  height: 42px;
  background: rgba(15, 23, 42, 0.78);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1.5px solid rgba(251, 191, 36, 0.35);
  border-radius: 8px;
  position: relative;
  cursor: pointer;
  padding: 2px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.45);
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  pointer-events: auto;
  transition: border-color 0.2s ease, box-shadow 0.2s ease, opacity 0.25s ease, transform 0.2s ease;
  z-index: 15;
  touch-action: none;
}

[data-theme="light"] .map-pin-dimmer-slider {
  background: rgba(255, 255, 255, 0.9);
  border-color: rgba(217, 119, 6, 0.4);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.map-pin-dimmer-slider.is-off {
  opacity: 0.35;
  border-color: rgba(148, 163, 184, 0.3);
}

.map-pin-dimmer-slider:hover,
.map-pin:hover .map-pin-dimmer-slider,
.map-pin-dimmer-slider.is-sliding {
  opacity: 1;
  border-color: #fbbf24;
  box-shadow: 0 0 12px rgba(245, 158, 11, 0.65);
}

.map-pin-dimmer-slider .dimmer-slider-track {
  width: 100%;
  height: 100%;
  position: relative;
  border-radius: 5px;
  overflow: hidden;
  background: rgba(0, 0, 0, 0.4);
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
}

[data-theme="light"] .map-pin-dimmer-slider .dimmer-slider-track {
  background: rgba(0, 0, 0, 0.12);
}

.map-pin-dimmer-slider .dimmer-slider-fill {
  width: 100%;
  border-radius: 4px;
  transition: height 0.05s ease-out;
  box-shadow: 0 0 6px rgba(245, 158, 11, 0.7);
}

.map-pin-dimmer-slider .dimmer-slider-tooltip {
  position: absolute;
  left: 20px;
  top: 50%;
  transform: translateY(-50%);
  background: rgba(15, 23, 42, 0.95);
  color: #fbbf24;
  border: 1px solid rgba(251, 191, 36, 0.5);
  border-radius: 6px;
  font-size: 0.7rem;
  font-weight: 800;
  padding: 3px 6px;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.15s ease, transform 0.15s ease;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.5);
  z-index: 25;
}

[data-theme="light"] .map-pin-dimmer-slider .dimmer-slider-tooltip {
  background: #ffffff;
  color: #b45309;
  border-color: rgba(217, 119, 6, 0.45);
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.15);
}

.map-pin-dimmer-slider:hover .dimmer-slider-tooltip,
.map-pin-dimmer-slider.is-sliding .dimmer-slider-tooltip {
  opacity: 1;
  transform: translateY(-50%) translateX(2px);
}

/* Horizontal Dimmer Slider in Cards and Popovers */
.ha-dimmer-slider-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  margin-top: 6px;
}

[data-theme="light"] .ha-dimmer-slider-row {
  background: rgba(0, 0, 0, 0.03);
}

.ha-dimmer-icon {
  font-size: 1rem;
  flex-shrink: 0;
}

.ha-dimmer-range {
  flex: 1;
  height: 6px;
  -webkit-appearance: none;
  appearance: none;
  background: var(--bg-surface-elevated);
  border-radius: 4px;
  outline: none;
  cursor: pointer;
}

.ha-dimmer-range::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fbbf24;
  border: 2px solid #ffffff;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.35);
  cursor: pointer;
  transition: transform 0.15s ease, background-color 0.15s ease;
}

.ha-dimmer-range::-webkit-slider-thumb:hover {
  transform: scale(1.2);
  background: #f59e0b;
}

.ha-dimmer-val {
  font-size: 0.8rem;
  font-weight: 700;
  color: #fbbf24;
  min-width: 38px;
  text-align: right;
  font-family: var(--font-mono, monospace);
}

[data-theme="light"] .ha-dimmer-val {
  color: #d97706;
}

/* Switch Pin Avatar (Map Rocker) */
.map-pin-avatar.map-switch-avatar {
  width: 30px;
  height: 46px;
  border-radius: 6px;
  background: #1e293b;
  border: 2px solid #334155;
  padding: 2px;
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.5), 0 2px 6px rgba(0, 0, 0, 0.3);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  margin-bottom: 2px;
}

[data-theme="light"] .map-pin-avatar.map-switch-avatar {
  background: #f8fafc;
  border-color: #cbd5e1;
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.15), 0 2px 6px rgba(0, 0, 0, 0.08);
}

.map-pin-avatar.map-switch-avatar.is-on {
  border-color: rgba(34, 197, 94, 0.8);
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.4), 0 0 14px rgba(34, 197, 94, 0.5);
}

[data-theme="light"] .map-pin-avatar.map-switch-avatar.is-on {
  background: #f0fdf4;
  border-color: #16a34a;
  box-shadow: 0 0 12px rgba(22, 163, 74, 0.35);
}

.map-pin-avatar.map-switch-avatar.is-off {
  border-color: rgba(239, 68, 68, 0.7);
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.4), 0 0 10px rgba(239, 68, 68, 0.35);
}

[data-theme="light"] .map-pin-avatar.map-switch-avatar.is-off {
  background: #fef2f2;
  border-color: #dc2626;
  box-shadow: 0 0 8px rgba(220, 38, 38, 0.25);
}

.map-pin.heater.is-active .map-heater-avatar.is-on {
  border-color: #f97316;
  box-shadow: 0 0 16px rgba(249, 115, 22, 0.7), 0 0 28px rgba(239, 68, 68, 0.35);
}

/* Heater Pin Avatar (Map Heater with Radiant Waves + Mini Rocker) */
.map-pin-avatar.map-heater-avatar {
  width: 46px;
  height: 46px;
  border-radius: 8px;
  background: #1e293b;
  border: 2px solid #334155;
  padding: 2px 4px;
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.5), 0 2px 8px rgba(0, 0, 0, 0.3);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: visible;
  transition: all 0.25s ease;
}

[data-theme="light"] .map-pin-avatar.map-heater-avatar {
  background: #f8fafc;
  border-color: #cbd5e1;
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.15), 0 2px 6px rgba(0, 0, 0, 0.08);
}

.map-pin-avatar.map-heater-avatar.is-on {
  border-color: #f97316;
  background: radial-gradient(circle at center, #291b18 0%, #1e1b2e 100%);
  box-shadow: inset 0 1px 4px rgba(249, 115, 22, 0.3), 0 0 16px rgba(249, 115, 22, 0.65), 0 0 26px rgba(239, 68, 68, 0.3);
}

[data-theme="light"] .map-pin-avatar.map-heater-avatar.is-on {
  background: radial-gradient(circle at center, #fff7ed 0%, #ffedd5 100%);
  border-color: #ea580c;
  box-shadow: 0 0 14px rgba(234, 88, 12, 0.5), 0 2px 6px rgba(0, 0, 0, 0.08);
}

.map-heater-body {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  position: relative;
}

/* Heat Waves on Top of Heater */
.heater-heat-waves {
  position: absolute;
  top: -11px;
  left: 3px;
  display: flex;
  gap: 2px;
  line-height: 1;
  font-family: 'Share Tech Mono', sans-serif;
  font-size: 0.85rem;
  font-weight: 900;
  pointer-events: none;
  transition: opacity 0.3s cubic-bezier(0.4, 0, 0.2, 1), transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), visibility 0.3s;
  opacity: 0;
  visibility: hidden;
  transform: translateY(3px);
}

.heater-heat-waves .heat-wave {
  display: inline-block;
  transform: rotate(-90deg);
  transition: all 0.25s ease;
}

.heater-heat-waves.is-off {
  opacity: 0 !important;
  visibility: hidden !important;
  transform: translateY(3px) !important;
  pointer-events: none;
}

.heater-heat-waves.is-on {
  opacity: 1 !important;
  visibility: visible !important;
  transform: translateY(0) !important;
  color: #f97316;
  text-shadow: 0 0 5px #ea580c, 0 0 8px #f59e0b;
}

.heater-heat-waves.is-on .wave-1 {
  animation: heatShimmer 1.2s ease-in-out infinite alternate;
}
.heater-heat-waves.is-on .wave-2 {
  animation: heatShimmer 1.2s ease-in-out 0.4s infinite alternate;
}
.heater-heat-waves.is-on .wave-3 {
  animation: heatShimmer 1.2s ease-in-out 0.8s infinite alternate;
}

@keyframes heatShimmer {
  0% {
    transform: rotate(-90deg) translateY(0) scale(0.9);
    opacity: 0.7;
  }
  100% {
    transform: rotate(-90deg) translateY(-3px) scale(1.15);
    opacity: 1;
    color: #fbbf24;
  }
}

/* Front panel: grill + mini rocker */
.heater-front-panel {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 4px;
}

.heater-grill {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 3px;
  background: rgba(0, 0, 0, 0.25);
  padding: 3px 4px;
  border-radius: 4px;
  border: 1px solid rgba(255, 255, 255, 0.05);
}

[data-theme="light"] .heater-grill {
  background: rgba(0, 0, 0, 0.05);
  border-color: rgba(0, 0, 0, 0.08);
}

.heater-coil {
  height: 3.5px;
  border-radius: 2px;
  background: #334155;
  transition: all 0.3s ease;
}

[data-theme="light"] .heater-coil {
  background: #94a3b8;
}

.map-heater-body.is-on .heater-coil {
  background: linear-gradient(90deg, #ea580c 0%, #f97316 35%, #fef08a 50%, #f97316 65%, #ea580c 100%);
  box-shadow: 0 0 5px #f97316, 0 0 9px #ef4444;
  animation: coilPulse 2s ease-in-out infinite alternate;
}

.map-heater-body.is-on .heater-coil.c2 {
  animation-delay: 0.3s;
}
.map-heater-body.is-on .heater-coil.c3 {
  animation-delay: 0.6s;
}

@keyframes coilPulse {
  0% {
    opacity: 0.85;
    filter: brightness(0.95);
  }
  100% {
    opacity: 1;
    filter: brightness(1.25);
  }
}

.heater-switch-col {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

/* Mini Rocker Switch (Inside Heater Avatar & Cards) */
.map-pin-rocker.mini {
  width: 14px;
  height: 28px;
  border-radius: 4px;
  background: #0f172a;
  border: 1px solid #334155;
  padding: 1px;
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.6);
}

[data-theme="light"] .map-pin-rocker.mini {
  background: #e2e8f0;
  border-color: #cbd5e1;
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.15);
}

.map-pin-rocker.mini .rocker-sym {
  font-size: 0.5rem;
  line-height: 1;
}

.map-pin-rocker.mini .rocker-lever {
  height: 14px;
  border-radius: 3px;
  left: 0;
  right: 0;
}

.map-pin-rocker.mini .lever-indicator {
  width: 6px;
  height: 2px;
}

.map-pin-rocker.mini.is-on .rocker-lever {
  transform: translateY(-1px);
}

.map-pin-rocker.mini.is-off .rocker-lever {
  transform: translateY(12px);
}

/* Boiler Pin Avatar (Cylindrical Tank with glowing red LED + Mini Rocker) */
.map-pin.boiler.is-active .map-boiler-avatar.is-on {
  border-color: #ef4444;
  box-shadow: 0 0 16px rgba(239, 68, 68, 0.7), 0 0 26px rgba(249, 115, 22, 0.35);
}

.map-pin-avatar.map-boiler-avatar {
  width: 46px;
  height: 46px;
  border-radius: 8px;
  background: #1e293b;
  border: 2px solid #334155;
  padding: 3px 4px;
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.5), 0 2px 8px rgba(0, 0, 0, 0.3);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: visible;
  transition: all 0.25s ease;
}

[data-theme="light"] .map-pin-avatar.map-boiler-avatar {
  background: #f8fafc;
  border-color: #cbd5e1;
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.15), 0 2px 6px rgba(0, 0, 0, 0.08);
}

.map-pin-avatar.map-boiler-avatar.is-on {
  border-color: #ef4444;
  background: radial-gradient(circle at center, #2e1414 0%, #1e1b2e 100%);
  box-shadow: inset 0 1px 4px rgba(239, 68, 68, 0.3), 0 0 16px rgba(239, 68, 68, 0.65), 0 0 24px rgba(249, 115, 22, 0.3);
}

[data-theme="light"] .map-pin-avatar.map-boiler-avatar.is-on {
  background: radial-gradient(circle at center, #fef2f2 0%, #fee2e2 100%);
  border-color: #dc2626;
  box-shadow: 0 0 14px rgba(220, 38, 38, 0.5), 0 2px 6px rgba(0, 0, 0, 0.08);
}

.map-boiler-body {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 4px;
  position: relative;
}

.boiler-tank-col {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
}

.boiler-tank {
  width: 20px;
  height: 36px;
  display: flex;
  flex-direction: column;
  align-items: center;
  position: relative;
}

.boiler-top-cap {
  width: 17px;
  height: 4px;
  background: linear-gradient(90deg, #475569 0%, #94a3b8 40%, #475569 100%);
  border-radius: 6px 6px 0 0;
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-bottom: none;
}

[data-theme="light"] .boiler-top-cap {
  background: linear-gradient(90deg, #cbd5e1 0%, #f1f5f9 40%, #cbd5e1 100%);
  border-color: rgba(0, 0, 0, 0.15);
}

.boiler-tank-core {
  width: 19px;
  flex: 1;
  background: linear-gradient(90deg, #334155 0%, #64748b 35%, #475569 70%, #1e293b 100%);
  border-left: 1px solid rgba(255, 255, 255, 0.2);
  border-right: 1px solid rgba(0, 0, 0, 0.4);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-around;
  padding: 2px 0;
  position: relative;
}

[data-theme="light"] .boiler-tank-core {
  background: linear-gradient(90deg, #e2e8f0 0%, #ffffff 35%, #f1f5f9 70%, #cbd5e1 100%);
  border-left-color: rgba(255, 255, 255, 0.9);
  border-right-color: rgba(0, 0, 0, 0.15);
}

.map-boiler-body.is-on .boiler-tank-core {
  box-shadow: inset 0 0 6px rgba(239, 68, 68, 0.35);
}

.boiler-heat-led {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #334155;
  border: 1px solid #1e293b;
  transition: all 0.3s ease;
}

[data-theme="light"] .boiler-heat-led {
  background: #cbd5e1;
  border-color: #94a3b8;
}

.boiler-heat-led.is-off {
  background: #451a1a;
  border-color: #2e1010;
  box-shadow: none;
}

.boiler-heat-led.is-on {
  background: #ef4444;
  border-color: #fee2e2;
  box-shadow: 0 0 6px #ef4444, 0 0 10px #f87171, 0 0 14px #dc2626;
  animation: boilerLedPulse 1.4s ease-in-out infinite alternate;
}

@keyframes boilerLedPulse {
  0% {
    box-shadow: 0 0 4px #ef4444, 0 0 8px #f87171;
    filter: brightness(0.9);
  }
  100% {
    box-shadow: 0 0 8px #ef4444, 0 0 14px #f87171, 0 0 18px #dc2626;
    filter: brightness(1.3);
  }
}

.boiler-accent-lines {
  display: flex;
  flex-direction: column;
  gap: 2px;
  width: 11px;
}

.boiler-accent-lines .b-line {
  height: 1.5px;
  background: rgba(255, 255, 255, 0.2);
  border-radius: 1px;
}

[data-theme="light"] .boiler-accent-lines .b-line {
  background: rgba(0, 0, 0, 0.12);
}

.boiler-bottom-cap {
  width: 17px;
  height: 3px;
  background: linear-gradient(90deg, #475569 0%, #94a3b8 40%, #475569 100%);
  border-radius: 0 0 5px 5px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-top: none;
}

[data-theme="light"] .boiler-bottom-cap {
  background: linear-gradient(90deg, #cbd5e1 0%, #f1f5f9 40%, #cbd5e1 100%);
  border-color: rgba(0, 0, 0, 0.15);
}

.boiler-pipes {
  display: flex;
  gap: 4px;
  margin-top: 1px;
}

.boiler-pipe {
  width: 2.5px;
  height: 3px;
  border-radius: 0 0 1px 1px;
}

.boiler-pipe.hot {
  background: #ef4444;
}

.boiler-pipe.cold {
  background: #3b82f6;
}

.boiler-switch-col {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.map-pin-rocker {
  width: 100%;
  height: 100%;
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  align-items: center;
}

.map-pin-rocker .rocker-track {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  align-items: center;
  position: relative;
}

.map-pin-rocker .rocker-sym {
  font-family: 'Orbitron', 'Share Tech Mono', sans-serif;
  font-size: 0.6rem;
  font-weight: 900;
  line-height: 1;
  pointer-events: none;
  z-index: 2;
  transition: all 0.2s ease;
}

.map-pin-rocker.is-on .rocker-sym.on-sym {
  color: #22c55e;
  opacity: 1;
  text-shadow: 0 0 6px rgba(34, 197, 94, 0.9);
}

.map-pin-rocker.is-on .rocker-sym.off-sym {
  color: #ef4444;
  opacity: 0.25;
}

.map-pin-rocker.is-off .rocker-sym.on-sym {
  color: #22c55e;
  opacity: 0.25;
}

.map-pin-rocker.is-off .rocker-sym.off-sym {
  color: #ef4444;
  opacity: 1;
  text-shadow: 0 0 6px rgba(239, 68, 68, 0.9);
}

[data-theme="light"] .map-pin-rocker.is-on .rocker-sym.on-sym {
  color: #16a34a;
}

[data-theme="light"] .map-pin-rocker.is-off .rocker-sym.off-sym {
  color: #dc2626;
}

.map-pin-rocker .rocker-lever {
  position: absolute;
  left: 0;
  right: 0;
  height: 18px;
  border-radius: 3px;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 3;
  transition: transform 0.22s cubic-bezier(0.34, 1.56, 0.64, 1), background 0.2s ease;
}

.map-pin-rocker.is-on .rocker-lever {
  transform: translateY(-1px);
  background: linear-gradient(180deg, #15803d 0%, #166534 100%);
  border: 1px solid #22c55e;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3), 0 0 6px rgba(34, 197, 94, 0.6);
}

[data-theme="light"] .map-pin-rocker.is-on .rocker-lever {
  background: linear-gradient(180deg, #16a34a 0%, #15803d 100%);
  border-color: #15803d;
}

.map-pin-rocker.is-on .lever-indicator {
  width: 9px;
  height: 2px;
  border-radius: 2px;
  background: #86efac;
  box-shadow: 0 0 4px #22c55e;
}

.map-pin-rocker.is-off .rocker-lever {
  transform: translateY(18px);
  background: linear-gradient(180deg, #991b1b 0%, #7f1d1d 100%);
  border: 1px solid #ef4444;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3), 0 0 6px rgba(239, 68, 68, 0.5);
}

[data-theme="light"] .map-pin-rocker.is-off .rocker-lever {
  background: linear-gradient(180deg, #dc2626 0%, #b91c1c 100%);
  border-color: #b91c1c;
}

.map-pin-rocker.is-off .lever-indicator {
  width: 9px;
  height: 2px;
  border-radius: 2px;
  background: #fca5a5;
  box-shadow: 0 0 4px #ef4444;
}

/* Glowing active status aura for pins */
.map-pin.is-active:not(.is-standby) .map-pin-avatar:not(.map-bulb-avatar):not(.map-switch-avatar):not(.map-heater-avatar):not(.map-boiler-avatar) {
  border-color: #22c55e;
  box-shadow: 0 0 16px rgba(34, 197, 94, 0.7), 0 4px 12px rgba(0, 0, 0, 0.4);
}

[data-theme="light"] .map-pin.is-active:not(.is-standby) .map-pin-avatar:not(.map-bulb-avatar):not(.map-switch-avatar):not(.map-heater-avatar):not(.map-boiler-avatar) {
  border-color: #16a34a;
  box-shadow: 0 0 14px rgba(22, 163, 74, 0.5), 0 2px 8px rgba(0, 0, 0, 0.12);
}

.map-pin.is-standby .map-pin-avatar {
  border-color: #334155;
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.5), 0 2px 8px rgba(0, 0, 0, 0.3);
}

[data-theme="light"] .map-pin.is-standby .map-pin-avatar {
  border-color: #cbd5e1;
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.15), 0 2px 6px rgba(0, 0, 0, 0.08);
}

.map-pin-status-dot {
  position: absolute;
  top: -3px;
  right: -3px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #22c55e;
  border: 2px solid var(--bg-surface, #0f172a);
  box-shadow: 0 0 4px rgba(0, 0, 0, 0.4);
  z-index: 10;
  pointer-events: none;
}

[data-theme="light"] .map-pin-status-dot {
  border-color: #ffffff;
}

.map-pin-status-dot.online {
  background: #22c55e !important;
  box-shadow: 0 0 6px rgba(34, 197, 94, 0.7);
}

.map-pin-status-dot.offline {
  background: #ef4444 !important;
  box-shadow: 0 0 6px rgba(239, 68, 68, 0.7);
}

.map-pin.is-offline .map-pin-avatar {
  opacity: 0.75;
  filter: grayscale(0.4);
}

/* Pending / Switching State Styles for Pins, Rockers & Buttons */
.map-pin.is-pending {
  cursor: wait !important;
}

.map-pin-pending-spinner {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(15, 23, 42, 0.42);
  backdrop-filter: blur(1.5px);
  border-radius: inherit;
  z-index: 15;
  pointer-events: none;
  animation: fadeIn 0.15s ease;
}

.map-pin-pending-spinner .spinner-ring {
  width: 20px;
  height: 20px;
  border: 2.5px solid rgba(56, 189, 248, 0.25);
  border-top-color: #38bdf8;
  border-right-color: #38bdf8;
  border-radius: 50%;
  animation: spinFast 0.65s linear infinite;
  box-shadow: 0 0 10px rgba(56, 189, 248, 0.5);
}

[data-theme="light"] .map-pin-pending-spinner {
  background: rgba(255, 255, 255, 0.55);
}

[data-theme="light"] .map-pin-pending-spinner .spinner-ring {
  border-color: rgba(2, 132, 199, 0.2);
  border-top-color: #0284c7;
  border-right-color: #0284c7;
  box-shadow: 0 0 8px rgba(2, 132, 199, 0.4);
}

@keyframes spinFast {
  to { transform: rotate(360deg); }
}

/* Rockers & Buttons in Pending Transition */
.map-pin-rocker.is-pending,
.ha-vertical-rocker.is-pending,
.ha-bulb-btn.is-pending,
.ha-boiler-btn.is-pending,
.ha-heater-btn.is-pending,
.table-toggle-btn.is-pending {
  position: relative;
  cursor: wait !important;
  opacity: 0.9;
}

.map-pin-rocker.is-pending .lever-indicator,
.ha-vertical-rocker.is-pending .lever-indicator,
.ha-boiler-btn.is-pending .lever-indicator,
.ha-heater-btn.is-pending .lever-indicator {
  animation: leverPendingPulse 0.55s ease-in-out infinite alternate !important;
}

@keyframes leverPendingPulse {
  0% {
    opacity: 0.35;
    transform: scale(0.85);
    filter: brightness(0.8);
  }
  100% {
    opacity: 1;
    transform: scale(1.2);
    box-shadow: 0 0 8px #38bdf8;
    filter: brightness(1.4);
  }
}

.table-toggle-btn.is-pending {
  background: rgba(56, 189, 248, 0.15) !important;
  border-color: #38bdf8 !important;
  color: #38bdf8 !important;
}

.map-pin.is-offline .map-pin-status-dot {
  background: #ef4444 !important;
  box-shadow: 0 0 6px rgba(239, 68, 68, 0.8) !important;
}

.map-pin-badge-container {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  z-index: 6;
  pointer-events: auto;
}

.map-pin-badge-container.layout-single {
  bottom: -9px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.map-pin-badge-container.layout-vertical {
  top: calc(100% - 7px);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  white-space: nowrap;
}

.map-pin-badge-container.layout-horizontal {
  bottom: -9px;
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: center;
  gap: 3px;
  white-space: nowrap;
}

.map-pin-badge-container.layout-alternate {
  bottom: -9px;
  min-height: 20px;
  display: grid;
  grid-template-columns: 1fr;
  grid-template-rows: 1fr;
  align-items: center;
  justify-items: center;
  position: absolute;
  overflow: hidden;
  padding: 2px 4px;
}

.map-pin-carousel-item {
  grid-area: 1 / 1 / 2 / 2;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.45s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.45s ease, visibility 0.45s ease;
  opacity: 0;
  transform: translateY(100%);
  pointer-events: none;
  visibility: hidden;
  width: max-content;
}

.map-pin-carousel-item.active {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
  visibility: visible;
}

.map-pin-carousel-item.slide-out {
  opacity: 0;
  transform: translateY(-100%);
  visibility: visible;
}

.map-pin-badge-text {
  background: #0f172a;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  color: #38bdf8;
  border: 1px solid rgba(56, 189, 248, 0.4);
  border-radius: 8px;
  padding: 1px 6px;
  font-size: 0.65rem;
  font-weight: 800;
  font-family: 'Share Tech Mono', monospace;
  white-space: nowrap;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.4);
  display: inline-flex;
  align-items: center;
  gap: 3px;
  line-height: 1.2;
}

.map-pin-badge-text.type-temp {
  background: linear-gradient(rgba(245, 158, 11, 0.32), rgba(245, 158, 11, 0.32)), #0f172a;
  border-color: rgba(245, 158, 11, 0.65);
  color: #fef08a;
}

.map-pin-badge-text.type-humidity {
  background: linear-gradient(rgba(14, 165, 233, 0.32), rgba(14, 165, 233, 0.32)), #0f172a;
  border-color: rgba(14, 165, 233, 0.65);
  color: #bae6fd;
}

.map-pin-badge-text.type-climate {
  background: linear-gradient(rgba(168, 85, 247, 0.32), rgba(168, 85, 247, 0.32)), #0f172a;
  border-color: rgba(168, 85, 247, 0.65);
  color: #e9d5ff;
}

.map-pin-badge-text.type-air {
  background: linear-gradient(rgba(16, 185, 129, 0.32), rgba(16, 185, 129, 0.32)), #0f172a;
  border-color: rgba(16, 185, 129, 0.65);
  color: #a7f3d0;
}

.map-pin-badge-text.type-battery {
  background: linear-gradient(rgba(34, 197, 94, 0.32), rgba(34, 197, 94, 0.32)), #0f172a;
  border-color: rgba(34, 197, 94, 0.65);
  color: #bbf7d0;
}

.map-pin-badge-text.type-power {
  background: linear-gradient(rgba(234, 179, 8, 0.32), rgba(234, 179, 8, 0.32)), #0f172a;
  border-color: rgba(234, 179, 8, 0.65);
  color: #fef08a;
}

[data-theme="light"] .map-pin-badge-text {
  background: rgba(255, 255, 255, 0.95);
  color: #0284c7;
  border-color: rgba(2, 132, 199, 0.35);
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.12);
}

[data-theme="light"] .map-pin-badge-text.type-temp {
  background: #fef3c7;
  border-color: rgba(245, 158, 11, 0.5);
  color: #92400e;
}

[data-theme="light"] .map-pin-badge-text.type-humidity {
  background: #e0f2fe;
  border-color: rgba(14, 165, 233, 0.5);
  color: #075985;
}

[data-theme="light"] .map-pin-badge-text.type-climate {
  background: #f3e8ff;
  border-color: rgba(168, 85, 247, 0.5);
  color: #6b21a8;
}

[data-theme="light"] .map-pin-badge-text.type-air {
  background: #d1fae5;
  border-color: rgba(16, 185, 129, 0.5);
  color: #065f46;
}

[data-theme="light"] .map-pin-badge-text.type-battery {
  background: #dcfce7;
  border-color: rgba(34, 197, 94, 0.5);
  color: #166534;
}

[data-theme="light"] .map-pin-badge-text.type-power {
  background: #fef9c3;
  border-color: rgba(234, 179, 8, 0.5);
  color: #854d0e;
}

.map-pin-label {
  margin-top: 8px;
  background: rgba(15, 23, 42, 0.85);
  backdrop-filter: blur(4px);
  color: #ffffff;
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 0.68rem;
  font-weight: 700;
  white-space: nowrap;
  max-width: 110px;
  overflow: hidden;
  text-overflow: ellipsis;
  border: 1px solid rgba(255, 255, 255, 0.15);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.4);
}

[data-theme="light"] .map-pin-label {
  background: rgba(255, 255, 255, 0.9);
  color: #0f172a;
  border-color: rgba(0, 0, 0, 0.15);
}

.map-pins-container.hide-device-labels .map-pin-label {
  display: none !important;
}

/* Transform & Resize Handles */
.map-transform-box {
  position: absolute;
  border: 2px dashed #38bdf8;
  border-radius: 8px;
  box-sizing: border-box;
  pointer-events: auto;
  cursor: move;
  z-index: 30;
  transition: none;
}

.transform-handle {
  position: absolute;
  width: 12px;
  height: 12px;
  background: #38bdf8;
  border: 2px solid #ffffff;
  border-radius: 2px;
  pointer-events: auto;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.4);
}

.transform-handle.nw { top: -6px; left: -6px; cursor: nwse-resize; }
.transform-handle.ne { top: -6px; right: -6px; cursor: nesw-resize; }
.transform-handle.sw { bottom: -6px; left: -6px; cursor: nesw-resize; }
.transform-handle.se { bottom: -6px; right: -6px; cursor: nwse-resize; }

.transform-toolbar {
  position: absolute;
  top: -56px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  padding: 4px 8px;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  pointer-events: auto;
  white-space: nowrap;
  z-index: 40;
}

.transform-name {
  font-size: 0.75rem;
  font-weight: 700;
  max-width: 90px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.color-picker-input {
  width: 24px;
  height: 24px;
  border: none;
  padding: 0;
  background: transparent;
  cursor: pointer;
  border-radius: 4px;
}

/* Popover Card & Icon Selector */
.map-popover-icon-box {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--bg-subtle);
  border: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
  flex-shrink: 0;
}

.icon-selector-grid {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 6px;
}

.icon-choice-btn {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  background: var(--bg-surface);
  font-size: 1.2rem;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.15s ease;
}

.icon-choice-btn:hover {
  background: var(--bg-card-hover);
  border-color: var(--primary);
  transform: scale(1.1);
}

.icon-choice-btn.selected {
  border-color: var(--primary);
  background: rgba(37, 99, 235, 0.15);
  box-shadow: 0 0 0 2px var(--primary);
}

#customizerUseDefaultIconBtn {
  border: 1.5px solid var(--border-color);
  background: var(--bg-surface);
  transition: all 0.2s ease;
}

#customizerUseDefaultIconBtn:hover {
  background: var(--bg-card-hover);
  border-color: var(--primary);
}

#customizerUseDefaultIconBtn.selected-default {
  border-color: var(--primary);
  background: rgba(37, 99, 235, 0.12);
  box-shadow: 0 0 0 2px var(--primary);
  color: var(--primary);
}

/* Room Wall Selector Grid */
.room-walls-grid {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  padding: 16px;
  border-radius: var(--radius-md);
  margin-top: 6px;
}

.walls-middle-row {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
}

.walls-center-preview {
  flex: 1;
  height: 60px;
  background: rgba(59, 130, 246, 0.08);
  border: 1px dashed rgba(59, 130, 246, 0.3);
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text-secondary);
}

.wall-toggle-btn {
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: all 0.2s ease;
  background: var(--bg-card);
  border: 1.5px solid var(--border-color);
  color: var(--text-main);
  user-select: none;
}

.wall-toggle-btn.wall-top,
.wall-toggle-btn.wall-bottom {
  width: 100%;
}

.wall-toggle-btn.wall-left,
.wall-toggle-btn.wall-right {
  flex: 1;
}

.wall-toggle-btn.is-wall-closed {
  border-color: #22c55e;
  background: rgba(34, 197, 94, 0.12);
  color: #16a34a;
}

[data-theme="dark"] .wall-toggle-btn.is-wall-closed {
  color: #4ade80;
  border-color: #16a34a;
}

.wall-toggle-btn.is-wall-open {
  border-color: #f59e0b;
  border-style: dashed;
  background: rgba(245, 158, 11, 0.08);
  color: #d97706;
}

[data-theme="dark"] .wall-toggle-btn.is-wall-open {
  color: #fbbf24;
  border-color: #d97706;
}

.wall-toggle-btn:hover {
  transform: scale(1.02);
  filter: brightness(1.1);
}

/* Responsive adjustments */
@media (max-width: 768px) {
  .container {
    width: 100%;
    max-width: 100vw;
    padding: 14px 10px 80px;
  }

  .header-content {
    width: 100%;
    padding: 8px 10px;
    gap: 8px;
    flex-wrap: wrap;
    justify-content: space-between;
  }

  .brand {
    gap: 8px;
  }

  .brand-icon {
    width: 34px;
    height: 34px;
    font-size: 18px;
  }

  .brand-text h1 {
    font-size: 1.05rem;
    gap: 6px;
  }

  .brand-text p {
    display: none;
  }

  .header-actions {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-wrap: wrap;
    justify-content: flex-end;
  }

  .header-actions .btn {
    padding: 6px 8px;
    font-size: 0.78rem;
    gap: 4px;
  }

  .header-actions .btn-icon-only {
    width: 34px;
    height: 34px;
    padding: 0;
  }

  /* Compact Home Assistant Link & API buttons on mobile */
  #haLinkBtn span:not(:first-child),
  #openHaSettingsBtn span:not(:first-child) {
    display: none;
  }

  #haLinkBtn, #openHaSettingsBtn {
    padding: 6px 8px;
    min-width: 34px;
    height: 34px;
  }

  #logoutBtn {
    padding: 6px 8px;
    font-size: 0.75rem;
  }

  #openAddModalBtn {
    padding: 6px 10px;
    font-size: 0.8rem;
    font-weight: 700;
  }

  /* Mobile Navigation Tabs: 5-Column Grid, No Overflow */
  .nav-tabs-wrapper {
    margin-bottom: 14px;
    width: 100%;
    max-width: 100%;
  }

  .main-nav-tabs {
    width: 100%;
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 3px;
    padding: 3px;
    box-sizing: border-box;
    border-radius: var(--radius-md);
  }

  .nav-tab-btn {
    padding: 5px 1px 4px;
    font-size: 0.68rem;
    gap: 2px;
    flex-direction: column;
    justify-content: center;
    text-align: center;
    border-radius: 8px;
    min-width: 0;
  }

  .nav-tab-btn span:first-child {
    font-size: 1.05rem;
    line-height: 1;
  }

  .tab-badge {
    font-size: 0.62rem;
    padding: 1px 4px;
    margin-top: 1px;
  }

  .sync-bar {
    flex-direction: column;
    align-items: flex-start;
  }
  
  .form-row {
    grid-template-columns: 1fr;
  }
  
  .devices-grid {
    column-count: 1;
  }

  /* Map Mobile Adjustments */
  .map-card {
    border-radius: var(--radius-md);
  }

  .map-toolbar {
    padding: 10px 12px;
    gap: 8px;
  }

  .map-toolbar-actions {
    width: 100%;
    justify-content: space-between;
    gap: 6px;
  }

  .map-workspace {
    min-height: 180px;
    height: auto;
    max-height: none;
    overflow: hidden;
    transition: height 0.25s ease;
  }

  .map-viewport {
    min-height: 180px;
    height: auto;
    padding: 0;
    overflow: hidden;
    scrollbar-width: none;
    transition: height 0.25s ease;
  }

  .map-stage {
    margin: auto;
  }

  .map-devices-drawer {
    position: absolute;
    top: 0;
    left: 0;
    bottom: 0;
    width: 240px;
    z-index: 30;
    box-shadow: 4px 0 16px rgba(0, 0, 0, 0.45);
  }

  .auth-overlay {
    padding: 12px;
  }
  .auth-card {
    padding: 20px 14px;
    max-width: 100%;
    margin: auto;
  }
  .keypad-btn {
    padding: 10px 0;
    font-size: 1.1rem;
  }
}

@media (max-width: 480px) {
  #openAddModalBtn span:last-child {
    display: inline;
  }
}

/* ==========================================
   MAP PIN CONTEXT MENU & POSTPONE ACTION MODAL
   ========================================== */
.map-context-menu {
  position: fixed;
  z-index: 10000;
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.4), 0 8px 10px -6px rgba(0, 0, 0, 0.3);
  min-width: 220px;
  max-width: 280px;
  padding: 6px;
  display: flex;
  flex-direction: column;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  animation: ctxMenuFadeIn 0.15s cubic-bezier(0.16, 1, 0.3, 1);
  transform-origin: top left;
}

[data-theme="dark"] .map-context-menu {
  background: rgba(30, 41, 59, 0.95);
  border-color: rgba(71, 85, 105, 0.6);
}

[data-theme="light"] .map-context-menu {
  background: rgba(255, 255, 255, 0.96);
  border-color: rgba(203, 213, 225, 0.8);
  box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.15), 0 8px 10px -6px rgba(0, 0, 0, 0.1);
}

@keyframes ctxMenuFadeIn {
  from {
    opacity: 0;
    transform: scale(0.94);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

.map-context-menu-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px 6px 10px;
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--text-main);
}

.ctx-pin-icon {
  font-size: 1.15rem;
  line-height: 1;
}

.ctx-pin-title {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
}

.map-context-menu-divider {
  height: 1px;
  background: var(--border-color);
  margin: 4px 0;
  opacity: 0.6;
}

.map-context-menu-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 8px 10px;
  border: none;
  background: transparent;
  color: var(--text-main);
  border-radius: var(--radius-sm);
  cursor: pointer;
  text-align: left;
  transition: all 0.15s ease;
  user-select: none;
}

.map-context-menu-item:hover {
  background: rgba(59, 130, 246, 0.12);
  color: var(--primary);
  transform: translateX(2px);
}

[data-theme="dark"] .map-context-menu-item:hover {
  background: rgba(59, 130, 246, 0.2);
}

.ctx-item-icon {
  font-size: 1.1rem;
  flex-shrink: 0;
}

.ctx-item-info {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.ctx-item-title {
  font-size: 0.82rem;
  font-weight: 700;
}

.ctx-item-desc {
  font-size: 0.7rem;
  color: var(--text-muted);
}

/* Modal Postpone Styles */
.modal-card-postpone {
  max-width: 480px;
  width: 92%;
}

.postpone-device-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  background: var(--bg-surface-secondary, rgba(0, 0, 0, 0.04));
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
}

[data-theme="dark"] .postpone-device-card {
  background: rgba(15, 23, 42, 0.6);
  border-color: rgba(51, 65, 85, 0.8);
}

.postpone-device-avatar {
  width: 42px;
  height: 42px;
  border-radius: 10px;
  background: rgba(59, 130, 246, 0.12);
  border: 1.5px solid rgba(59, 130, 246, 0.3);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.3rem;
  flex-shrink: 0;
}

.postpone-device-meta {
  flex: 1;
  overflow: hidden;
}

.postpone-device-name {
  font-size: 0.95rem;
  font-weight: 800;
  margin: 0 0 4px 0;
  color: var(--text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.postpone-device-badges {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.postpone-room-badge {
  font-size: 0.72rem;
  padding: 2px 6px;
  border-radius: 4px;
  background: rgba(100, 116, 139, 0.12);
  color: var(--text-muted);
  border: 1px solid var(--border-color);
}

.postpone-status-badge {
  font-size: 0.72rem;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 4px;
}

.postpone-status-badge.is-on {
  background: rgba(34, 197, 94, 0.15);
  color: #16a34a;
  border: 1px solid rgba(34, 197, 94, 0.4);
}

.postpone-status-badge.is-off {
  background: rgba(239, 68, 68, 0.12);
  color: #dc2626;
  border: 1px solid rgba(239, 68, 68, 0.35);
}

/* Action Toggle Buttons */
.postpone-action-toggle-group {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 4px;
}

.postpone-action-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--border-color);
  background: var(--bg-surface);
  cursor: pointer;
  font-size: 0.88rem;
  font-weight: 700;
  transition: all 0.2s ease;
  user-select: none;
}

.postpone-action-btn input[type="radio"] {
  display: none;
}

.postpone-action-btn.turn-on:has(input:checked) {
  border-color: #22c55e;
  background: rgba(34, 197, 94, 0.15);
  color: #15803d;
  box-shadow: 0 0 10px rgba(34, 197, 94, 0.25);
}

[data-theme="dark"] .postpone-action-btn.turn-on:has(input:checked) {
  color: #4ade80;
}

.postpone-action-btn.turn-off:has(input:checked) {
  border-color: #ef4444;
  background: rgba(239, 68, 68, 0.15);
  color: #b91c1c;
  box-shadow: 0 0 10px rgba(239, 68, 68, 0.25);
}

[data-theme="dark"] .postpone-action-btn.turn-off:has(input:checked) {
  color: #f87171;
}

/* Timing Tabs */
.postpone-mode-tabs {
  display: flex;
  background: var(--bg-surface-secondary, rgba(0, 0, 0, 0.06));
  padding: 3px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  gap: 4px;
  margin-bottom: 12px;
}

.postpone-tab-btn {
  flex: 1;
  padding: 7px 12px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 0.8rem;
  font-weight: 700;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.postpone-tab-btn.active {
  background: var(--bg-surface);
  color: var(--primary);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.15);
}

/* Quick time buttons */
.postpone-quick-buttons {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 12px;
}

.btn-quick-time {
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  background: var(--bg-surface);
  color: var(--text-main);
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-quick-time:hover {
  border-color: var(--primary);
  color: var(--primary);
  transform: scale(1.02);
}

.btn-quick-time.active {
  border-color: var(--primary);
  background: rgba(59, 130, 246, 0.12);
  color: var(--primary);
  box-shadow: 0 0 6px rgba(59, 130, 246, 0.25);
}

.postpone-custom-minutes-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 10px;
  background: var(--bg-surface-secondary, rgba(0, 0, 0, 0.03));
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
}

.postpone-input-stepper {
  display: flex;
  align-items: center;
  gap: 6px;
}

.postpone-input-stepper input {
  width: 70px;
  text-align: center;
  font-weight: 800;
  font-size: 0.95rem;
}

.stepper-unit {
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* Active Schedules in Postpone Modal */
.postpone-active-section {
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px dashed var(--border-color);
}

.postpone-section-heading {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 8px;
}

.postpone-schedules-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.postpone-schedule-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  font-size: 0.8rem;
}

.postpone-schedule-info {
  display: flex;
  align-items: center;
  gap: 8px;
}

.schedule-action-badge {
  font-size: 0.72rem;
  font-weight: 800;
  padding: 2px 6px;
  border-radius: 4px;
}

.schedule-action-badge.turn_on {
  background: rgba(34, 197, 94, 0.15);
  color: #16a34a;
}

.schedule-action-badge.turn_off {
  background: rgba(239, 68, 68, 0.15);
  color: #dc2626;
}

.schedule-time-text {
  font-family: 'Share Tech Mono', monospace;
  font-weight: 700;
  color: var(--primary);
}

/* ==========================================
 * Light Dimmer & Brightness Sliders (Map & Cards)
 * ========================================== */

/* Map Pin Vertical Slider */
.map-pin-body-row {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  position: relative;
}

.map-pin-dimmer-slider {
  position: relative;
  width: 10px;
  height: 38px;
  background: rgba(15, 23, 42, 0.85);
  border: 1.5px solid rgba(255, 255, 255, 0.22);
  border-radius: 6px;
  padding: 2px;
  box-sizing: border-box;
  cursor: pointer;
  touch-action: none;
  user-select: none;
  transition: width 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
  z-index: 5;
}

.map-pin-dimmer-slider:hover,
.map-pin-dimmer-slider.is-sliding {
  width: 15px;
  border-color: #fbbf24;
  box-shadow: 0 0 10px rgba(251, 191, 36, 0.6);
}

.dimmer-slider-track {
  width: 100%;
  height: 100%;
  border-radius: 4px;
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  overflow: hidden;
  background: rgba(0, 0, 0, 0.5);
  pointer-events: none;
}

.dimmer-slider-fill {
  width: 100%;
  border-radius: 3px;
  background: linear-gradient(to top, #d97706, #f59e0b, #fef08a);
  transition: height 0.05s linear;
  pointer-events: none;
}

.dimmer-slider-tooltip {
  position: absolute;
  left: 100%;
  top: 50%;
  transform: translateY(-50%) translateX(6px);
  background: rgba(15, 23, 42, 0.95);
  border: 1px solid rgba(251, 191, 36, 0.6);
  color: #fbbf24;
  font-size: 0.72rem;
  font-weight: 800;
  font-family: 'Share Tech Mono', monospace;
  padding: 2px 6px;
  border-radius: 4px;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.15s ease, transform 0.15s ease;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.7);
  z-index: 20;
}

.map-pin-dimmer-slider:hover .dimmer-slider-tooltip,
.map-pin-dimmer-slider.is-sliding .dimmer-slider-tooltip {
  opacity: 1;
  transform: translateY(-50%) translateX(8px);
}

/* Card & Popover Horizontal Slider */
.ha-dimmer-slider-row {
  grid-column: 1 / -1 !important;
  width: 100%;
  box-sizing: border-box;
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(15, 23, 42, 0.5);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 8px 12px;
  margin-top: 2px;
  transition: var(--transition);
}

[data-theme="light"] .ha-dimmer-slider-row {
  background: rgba(241, 245, 249, 0.85);
}

.ha-dimmer-slider-row:hover {
  border-color: rgba(251, 191, 36, 0.5);
}

.ha-dimmer-icon {
  font-size: 1rem;
  line-height: 1;
  opacity: 0.85;
  user-select: none;
}

.ha-dimmer-range {
  flex: 1;
  -webkit-appearance: none;
  appearance: none;
  height: 6px;
  background: rgba(255, 255, 255, 0.15);
  border-radius: 3px;
  outline: none;
  cursor: pointer;
  margin: 0;
  transition: background 0.15s ease;
}

[data-theme="light"] .ha-dimmer-range {
  background: #cbd5e1;
}

.ha-dimmer-range::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #fbbf24;
  border: 2px solid #ffffff;
  box-shadow: 0 0 8px rgba(251, 191, 36, 0.7);
  cursor: pointer;
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}

.ha-dimmer-range::-webkit-slider-thumb:hover,
.ha-dimmer-range:active::-webkit-slider-thumb {
  transform: scale(1.25);
  box-shadow: 0 0 12px rgba(251, 191, 36, 1);
}

.ha-dimmer-range::-moz-range-thumb {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #fbbf24;
  border: 2px solid #ffffff;
  box-shadow: 0 0 8px rgba(251, 191, 36, 0.7);
  cursor: pointer;
}

.ha-dimmer-val {
  min-width: 42px;
  text-align: right;
  font-family: 'Share Tech Mono', 'Orbitron', monospace;
  font-size: 0.85rem;
  font-weight: 700;
  color: #fbbf24;
  text-shadow: 0 0 6px rgba(251, 191, 36, 0.4);
  user-select: none;
}

/* HA Reload Button & Animation */
.reload-btn {
  transition: transform 0.2s cubic-bezier(0.4, 0, 0.2, 1), color 0.2s ease, background-color 0.2s ease;
}

.reload-btn:hover {
  color: var(--primary);
  transform: rotate(45deg);
}

.spinning-btn {
  pointer-events: none !important;
  opacity: 0.6 !important;
  animation: spinReload 0.8s linear infinite !important;
}

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

/* ===================================================
   🌡️ CLIMATIZZATORI & TERMOSTATI (HISENSE / CONNECTLIFE / HA)
   =================================================== */

.ha-climate-card-unit {
  position: relative;
  background: var(--card-bg, rgba(20, 24, 33, 0.75));
  border: 1px solid var(--border-color, rgba(255, 255, 255, 0.08));
  border-radius: 12px;
  padding: 12px 14px;
  margin-bottom: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  transition: border-color 0.25s ease, box-shadow 0.25s ease, background 0.25s ease;
  backdrop-filter: blur(8px);
}

.ha-climate-card-unit.mode-cool {
  border-color: rgba(56, 189, 248, 0.4);
  box-shadow: 0 4px 18px rgba(56, 189, 248, 0.08);
}
.ha-climate-card-unit.mode-heat {
  border-color: rgba(249, 115, 22, 0.4);
  box-shadow: 0 4px 18px rgba(249, 115, 22, 0.08);
}
.ha-climate-card-unit.mode-dry {
  border-color: rgba(6, 182, 212, 0.4);
  box-shadow: 0 4px 18px rgba(6, 182, 212, 0.08);
}
.ha-climate-card-unit.mode-fan_only {
  border-color: rgba(168, 85, 247, 0.4);
  box-shadow: 0 4px 18px rgba(168, 85, 247, 0.08);
}
.ha-climate-card-unit.mode-auto {
  border-color: rgba(16, 185, 129, 0.4);
  box-shadow: 0 4px 18px rgba(16, 185, 129, 0.08);
}
.ha-climate-card-unit.mode-off {
  opacity: 0.82;
}

.ha-climate-main-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

.ha-climate-info {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
  flex: 1;
}

.ha-climate-title {
  font-size: 0.92rem;
  font-weight: 700;
  color: var(--text-main, #f8fafc);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ha-climate-subbadges {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.ha-climate-mode-badge {
  font-size: 0.72rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-muted, #94a3b8);
  border: 1px solid rgba(255, 255, 255, 0.08);
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.ha-climate-mode-badge.mode-cool {
  background: rgba(56, 189, 248, 0.15);
  color: #38bdf8;
  border-color: rgba(56, 189, 248, 0.3);
}
.ha-climate-mode-badge.mode-heat {
  background: rgba(249, 115, 22, 0.15);
  color: #fb923c;
  border-color: rgba(249, 115, 22, 0.3);
}
.ha-climate-mode-badge.mode-dry {
  background: rgba(6, 182, 212, 0.15);
  color: #22d3ee;
  border-color: rgba(6, 182, 212, 0.3);
}
.ha-climate-mode-badge.mode-fan_only {
  background: rgba(168, 85, 247, 0.15);
  color: #c084fc;
  border-color: rgba(168, 85, 247, 0.3);
}
.ha-climate-mode-badge.mode-auto {
  background: rgba(16, 185, 129, 0.15);
  color: #34d399;
  border-color: rgba(16, 185, 129, 0.3);
}

.ha-climate-ambient-badge {
  font-size: 0.72rem;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.04);
  color: #e2e8f0;
  border: 1px solid rgba(255, 255, 255, 0.06);
}

.ha-climate-power-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
}

.ha-climate-power-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-muted, #94a3b8);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 1.1rem;
  transition: all 0.2s ease;
}

.ha-climate-power-btn:hover {
  transform: scale(1.06);
  filter: brightness(1.2);
}

.ha-climate-power-btn.is-on {
  background: linear-gradient(135deg, rgba(34, 197, 94, 0.25), rgba(16, 185, 129, 0.45));
  border-color: #10b981;
  color: #ffffff;
  box-shadow: 0 0 12px rgba(16, 185, 129, 0.4);
}

.ha-climate-power-btn.is-off {
  background: rgba(255, 255, 255, 0.04);
  color: #64748b;
  border-color: rgba(255, 255, 255, 0.08);
}

.ha-climate-modal-btn {
  font-size: 0.95rem;
  padding: 4px 6px;
  border-radius: 6px;
}

/* Temperature Section & Stepper */
.ha-climate-temp-section {
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: rgba(0, 0, 0, 0.2);
  border-radius: 8px;
  padding: 8px 10px;
  border: 1px solid rgba(255, 255, 255, 0.04);
}

.ha-climate-temp-display-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.ha-climate-temp-box {
  display: flex;
  align-items: center;
  gap: 8px;
}

.ha-climate-temp-label {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted, #94a3b8);
  font-weight: 600;
}

.ha-climate-temp-stepper {
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 8px;
  padding: 2px 4px;
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.btn-climate-step {
  width: 26px;
  height: 26px;
  border-radius: 6px;
  border: none;
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-main, #f8fafc);
  font-weight: 700;
  font-size: 1rem;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-climate-step:hover {
  background: var(--primary, #3b82f6);
  color: #fff;
  transform: scale(1.08);
}

.btn-climate-step:active {
  transform: scale(0.94);
}

.ha-climate-temp-value {
  font-family: 'Share Tech Mono', 'Orbitron', monospace;
  font-size: 1.15rem;
  font-weight: 700;
  color: #38bdf8;
  min-width: 58px;
  text-align: center;
  text-shadow: 0 0 8px rgba(56, 189, 248, 0.35);
}

.ha-climate-room-ambient-box {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
}

.ha-climate-ambient-label {
  font-size: 0.68rem;
  text-transform: uppercase;
  color: var(--text-muted, #94a3b8);
  font-weight: 600;
}

.ha-climate-ambient-val {
  font-family: 'Share Tech Mono', 'Orbitron', monospace;
  font-size: 0.95rem;
  font-weight: 600;
  color: #e2e8f0;
}

/* ⏳ Climate Temp Syncing / Waiting State */
.ha-climate-temp-stepper.is-syncing-temp {
  border-color: rgba(56, 189, 248, 0.6) !important;
  box-shadow: 0 0 12px rgba(56, 189, 248, 0.4) !important;
  animation: climateStepperPulse 1.4s infinite ease-in-out;
}

.ha-climate-temp-value.is-syncing-temp {
  color: #7dd3fc;
  animation: climateTempBlink 1.4s infinite ease-in-out;
}

.ha-climate-range.is-syncing-temp {
  filter: brightness(1.25);
}

/* ⏳ Climate Power & Mode Syncing */
.ha-climate-power-btn.is-syncing {
  animation: climateBtnPulse 1.2s infinite ease-in-out;
  opacity: 0.85;
}

.climate-dial-power-btn.is-syncing {
  animation: climateBtnPulse 1.2s infinite ease-in-out;
  opacity: 0.85;
}

.ha-climate-mode-chip.is-syncing {
  animation: climateChipPulse 1.2s infinite ease-in-out;
  border-color: rgba(56, 189, 248, 0.85) !important;
  box-shadow: 0 0 12px rgba(56, 189, 248, 0.5) !important;
}

.climate-modal-opt-btn.is-syncing {
  animation: climateChipPulse 1.2s infinite ease-in-out;
  border-color: rgba(56, 189, 248, 0.85) !important;
  box-shadow: 0 0 12px rgba(56, 189, 248, 0.5) !important;
}

@keyframes climateBtnPulse {
  0%, 100% {
    transform: scale(1);
    box-shadow: 0 0 4px rgba(56, 189, 248, 0.25);
  }
  50% {
    transform: scale(1.08);
    box-shadow: 0 0 14px rgba(56, 189, 248, 0.65);
  }
}

@keyframes climateChipPulse {
  0%, 100% {
    opacity: 0.85;
    transform: scale(1);
  }
  50% {
    opacity: 1;
    transform: scale(1.05);
  }
}

@keyframes climateStepperPulse {
  0%, 100% {
    border-color: rgba(56, 189, 248, 0.35);
    box-shadow: 0 0 6px rgba(56, 189, 248, 0.2);
  }
  50% {
    border-color: rgba(56, 189, 248, 0.85);
    box-shadow: 0 0 14px rgba(56, 189, 248, 0.55);
  }
}

@keyframes climateTempBlink {
  0%, 100% { opacity: 0.85; transform: scale(1); }
  50% { opacity: 1; transform: scale(1.04); }
}

/* Climate Range Slider */
.ha-climate-slider-row {
  width: 100%;
  padding: 2px 0;
}

.ha-climate-range {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 6px;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.12);
  outline: none;
  cursor: pointer;
  transition: background 0.2s ease;
}

.ha-climate-range::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #38bdf8;
  cursor: pointer;
  box-shadow: 0 0 10px rgba(56, 189, 248, 0.6);
  border: 2px solid #ffffff;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.ha-climate-range.mode-heat::-webkit-slider-thumb {
  background: #f97316;
  box-shadow: 0 0 10px rgba(249, 115, 22, 0.6);
}

.ha-climate-range::-webkit-slider-thumb:hover {
  transform: scale(1.2);
}

/* Quick Mode Chips */
.ha-climate-modes-row {
  display: flex;
  gap: 5px;
  overflow-x: auto;
  padding-bottom: 2px;
  scrollbar-width: none;
}

.ha-climate-modes-row::-webkit-scrollbar {
  display: none;
}

.ha-climate-mode-chip {
  flex: 1;
  min-width: 48px;
  padding: 5px 6px;
  border-radius: 7px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-muted, #94a3b8);
  font-size: 0.72rem;
  font-weight: 600;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  cursor: pointer;
  transition: all 0.18s ease;
  white-space: nowrap;
}

.ha-climate-mode-chip .mode-icon {
  font-size: 0.95rem;
  line-height: 1;
}

.ha-climate-mode-chip:hover {
  background: rgba(255, 255, 255, 0.09);
  color: #fff;
  transform: translateY(-1px);
}

.ha-climate-mode-chip.active {
  color: #ffffff;
  font-weight: 700;
}

.ha-climate-mode-chip.active.cool {
  background: linear-gradient(135deg, rgba(2, 132, 199, 0.4), rgba(56, 189, 248, 0.6));
  border-color: #38bdf8;
  box-shadow: 0 0 10px rgba(56, 189, 248, 0.35);
}

.ha-climate-mode-chip.active.heat {
  background: linear-gradient(135deg, rgba(234, 88, 12, 0.4), rgba(249, 115, 22, 0.6));
  border-color: #f97316;
  box-shadow: 0 0 10px rgba(249, 115, 22, 0.35);
}

.ha-climate-mode-chip.active.dry {
  background: linear-gradient(135deg, rgba(8, 145, 178, 0.4), rgba(6, 182, 212, 0.6));
  border-color: #06b6d4;
  box-shadow: 0 0 10px rgba(6, 182, 212, 0.35);
}

.ha-climate-mode-chip.active.fan_only {
  background: linear-gradient(135deg, rgba(126, 34, 206, 0.4), rgba(168, 85, 247, 0.6));
  border-color: #a855f7;
  box-shadow: 0 0 10px rgba(168, 85, 247, 0.35);
}

.ha-climate-mode-chip.active.auto {
  background: linear-gradient(135deg, rgba(5, 150, 105, 0.4), rgba(16, 185, 129, 0.6));
  border-color: #10b981;
  box-shadow: 0 0 10px rgba(16, 185, 129, 0.35);
}

.ha-climate-mode-chip.active.off {
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(255, 255, 255, 0.25);
}

/* Fan row */
.ha-climate-fan-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 0.78rem;
  color: var(--text-muted, #94a3b8);
}

.ha-climate-fan-select {
  flex: 1;
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: var(--text-main, #f8fafc);
  font-size: 0.76rem;
  border-radius: 6px;
  padding: 3px 6px;
  outline: none;
  cursor: pointer;
}

/* ===================================================
   🌡️ MODAL TERMOSTATO DIGITALE (CLIMATE MODAL)
   =================================================== */

.modal-card-climate {
  max-width: 440px;
  width: 95%;
  background: var(--card-bg, #1e2430);
  border: 1px solid var(--border-color, rgba(255, 255, 255, 0.1));
  border-radius: 16px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.5);
  overflow: hidden;
}

.climate-dial-container {
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 18px 0 10px;
}

.climate-dial-circle {
  width: 200px;
  height: 200px;
  border-radius: 50%;
  background: radial-gradient(circle at center, rgba(30, 41, 59, 0.9) 0%, rgba(15, 23, 42, 0.95) 100%);
  border: 3px solid rgba(56, 189, 248, 0.4);
  box-shadow: 0 0 24px rgba(56, 189, 248, 0.2), inset 0 0 16px rgba(0, 0, 0, 0.5);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  position: relative;
  transition: all 0.3s ease;
}

.climate-dial-container.mode-heat .climate-dial-circle {
  border-color: rgba(249, 115, 22, 0.5);
  box-shadow: 0 0 24px rgba(249, 115, 22, 0.25), inset 0 0 16px rgba(0, 0, 0, 0.5);
}
.climate-dial-container.mode-dry .climate-dial-circle {
  border-color: rgba(6, 182, 212, 0.5);
  box-shadow: 0 0 24px rgba(6, 182, 212, 0.25), inset 0 0 16px rgba(0, 0, 0, 0.5);
}
.climate-dial-container.mode-fan_only .climate-dial-circle {
  border-color: rgba(168, 85, 247, 0.5);
  box-shadow: 0 0 24px rgba(168, 85, 247, 0.25), inset 0 0 16px rgba(0, 0, 0, 0.5);
}
.climate-dial-container.mode-auto .climate-dial-circle {
  border-color: rgba(16, 185, 129, 0.5);
  box-shadow: 0 0 24px rgba(16, 185, 129, 0.25), inset 0 0 16px rgba(0, 0, 0, 0.5);
}
.climate-dial-container.mode-off .climate-dial-circle {
  border-color: rgba(148, 163, 184, 0.2);
  box-shadow: inset 0 0 16px rgba(0, 0, 0, 0.5);
  opacity: 0.8;
}

.climate-dial-mode-badge {
  position: absolute;
  top: 12px;
  font-size: 0.72rem;
  font-weight: 700;
  color: #38bdf8;
  text-shadow: 0 0 6px rgba(56, 189, 248, 0.4);
}

.climate-dial-center {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.climate-dial-target-label {
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--text-muted, #94a3b8);
  margin-bottom: 2px;
}

.climate-dial-target-value-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
}

.climate-dial-temp {
  font-family: 'Share Tech Mono', 'Orbitron', monospace;
  font-size: 2.2rem;
  font-weight: 800;
  color: #ffffff;
  line-height: 1;
  text-shadow: 0 0 12px rgba(255, 255, 255, 0.4);
}

.climate-dial-deg {
  font-size: 1.1rem;
  font-weight: 700;
  color: #94a3b8;
  margin-left: -4px;
}

.climate-dial-btn {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.15);
  background: rgba(255, 255, 255, 0.08);
  color: #ffffff;
  font-size: 1.1rem;
  font-weight: 700;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.15s ease;
}

.climate-dial-btn:hover {
  background: var(--primary, #3b82f6);
  transform: scale(1.12);
}

.climate-dial-ambient-row {
  margin-top: 4px;
  font-size: 0.74rem;
  color: var(--text-muted, #94a3b8);
  display: flex;
  align-items: center;
  gap: 4px;
}

.climate-dial-ambient-row .ambient-val {
  font-weight: 700;
  color: #f8fafc;
}

.climate-dial-power-btn-wrap {
  position: absolute;
  bottom: 8px;
}

.climate-dial-power-btn {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.15);
  background: rgba(255, 255, 255, 0.08);
  color: #94a3b8;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 1rem;
  transition: all 0.2s ease;
}

.climate-dial-power-btn.is-on {
  background: #10b981;
  color: #fff;
  border-color: #10b981;
  box-shadow: 0 0 10px rgba(16, 185, 129, 0.5);
}

/* Climate Modal Grids */
.climate-modal-modes-grid,
.climate-modal-fan-grid,
.climate-modal-swing-grid,
.climate-modal-preset-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(90px, 1fr));
  gap: 6px;
  margin-top: 6px;
}

.climate-modal-opt-btn {
  padding: 8px 6px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-muted, #94a3b8);
  font-size: 0.76rem;
  font-weight: 600;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  cursor: pointer;
  transition: all 0.18s ease;
  text-align: center;
}

.climate-modal-opt-btn:hover {
  background: rgba(255, 255, 255, 0.09);
  color: #fff;
  transform: translateY(-1px);
}

.climate-modal-opt-btn.active {
  background: var(--primary, #3b82f6);
  color: #ffffff;
  border-color: var(--primary, #3b82f6);
  box-shadow: 0 0 10px rgba(59, 130, 246, 0.4);
  font-weight: 700;
}

.climate-modal-opt-btn.active.cool {
  background: linear-gradient(135deg, #0284c7, #38bdf8);
  border-color: #38bdf8;
  box-shadow: 0 0 10px rgba(56, 189, 248, 0.4);
}
.climate-modal-opt-btn.active.heat {
  background: linear-gradient(135deg, #ea580c, #f97316);
  border-color: #f97316;
  box-shadow: 0 0 10px rgba(249, 115, 22, 0.4);
}
.climate-modal-opt-btn.active.dry {
  background: linear-gradient(135deg, #0891b2, #06b6d4);
  border-color: #06b6d4;
  box-shadow: 0 0 10px rgba(6, 182, 212, 0.4);
}
.climate-modal-opt-btn.active.fan_only {
  background: linear-gradient(135deg, #7e22ce, #a855f7);
  border-color: #a855f7;
  box-shadow: 0 0 10px rgba(168, 85, 247, 0.4);
}
.climate-modal-opt-btn.active.auto {
  background: linear-gradient(135deg, #059669, #10b981);
  border-color: #10b981;
  box-shadow: 0 0 10px rgba(16, 185, 129, 0.4);
}

/* ===================================================
   🌡️ CLIMATE SPLIT WALL UNIT & AIRFLOW ANIMATIONS
   =================================================== */

/* Container Stage per lo Split a Muro all'interno della Card / Popover */
.split-wall-stage {
  width: 100%;
  background: radial-gradient(circle at 50% 30%, rgba(30, 41, 59, 0.8) 0%, rgba(15, 23, 42, 0.95) 100%);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  padding: 10px 12px 6px;
  margin-bottom: 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  position: relative;
  overflow: hidden;
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.5), 0 4px 12px rgba(0, 0, 0, 0.2);
  transition: all 0.3s ease;
}

[data-theme="light"] .split-wall-stage {
  background: radial-gradient(circle at 50% 30%, #ffffff 0%, #f1f5f9 100%);
  border-color: rgba(0, 0, 0, 0.08);
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.04), 0 4px 12px rgba(0, 0, 0, 0.05);
}

/* Header con Temperatura Impostata (Target Temp) sopra lo split */
.split-target-header {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
  padding: 0 4px;
}

.split-target-label {
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-size: 0.65rem;
  font-weight: 800;
  letter-spacing: 0.8px;
  color: #94a3b8;
  text-transform: uppercase;
}

[data-theme="light"] .split-target-label {
  color: #64748b;
}

.split-target-value {
  font-family: 'Share Tech Mono', 'Orbitron', monospace;
  font-size: 1.15rem;
  font-weight: 900;
  color: #94a3b8;
  letter-spacing: 0.5px;
  transition: all 0.3s ease;
}

.split-wall-stage.mode-heat .split-target-value {
  color: #fdba74;
  text-shadow: 0 0 10px rgba(249, 115, 22, 0.8), 0 0 18px rgba(234, 88, 12, 0.4);
}

.split-wall-stage.mode-cool .split-target-value {
  color: #7dd3fc;
  text-shadow: 0 0 10px rgba(56, 189, 248, 0.8), 0 0 18px rgba(2, 132, 199, 0.4);
}

.split-wall-stage.mode-dry .split-target-value {
  color: #67e8f9;
  text-shadow: 0 0 10px rgba(6, 182, 212, 0.8), 0 0 18px rgba(8, 145, 178, 0.4);
}

.split-wall-stage.mode-fan_only .split-target-value,
.split-wall-stage.mode-fan .split-target-value {
  color: #c084fc;
  text-shadow: 0 0 10px rgba(168, 85, 247, 0.8), 0 0 18px rgba(147, 51, 234, 0.4);
}

.split-wall-stage.mode-auto .split-target-value {
  color: #6ee7b7;
  text-shadow: 0 0 10px rgba(16, 185, 129, 0.8), 0 0 18px rgba(5, 150, 105, 0.4);
}

.split-wall-stage.mode-off .split-target-value {
  color: #64748b;
  text-shadow: none;
}

/* Corpo Split a Muro Realistico */
.split-wall-unit {
  width: 100%;
  max-width: 320px;
  height: 54px;
  background: linear-gradient(180deg, #38465b 0%, #1e293b 60%, #0f172a 100%);
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 6px 6px 12px 12px;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.5), inset 0 1px 2px rgba(255, 255, 255, 0.25);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 4px 10px 0;
  position: relative;
  z-index: 3;
  transition: all 0.3s ease;
}

[data-theme="light"] .split-wall-unit {
  background: linear-gradient(180deg, #ffffff 0%, #f8fafc 55%, #e2e8f0 100%);
  border-color: #cbd5e1;
  box-shadow: 0 6px 14px rgba(0, 0, 0, 0.08), inset 0 1px 2px #ffffff;
}

/* Griglia Presa d'Aria Superiore */
.split-intake-grille {
  width: 100%;
  display: flex;
  justify-content: space-around;
  gap: 3px;
  padding: 0 4px;
}

.split-grille-fin {
  flex: 1;
  height: 2px;
  background: rgba(255, 255, 255, 0.12);
  border-radius: 2px;
}

[data-theme="light"] .split-grille-fin {
  background: rgba(0, 0, 0, 0.1);
}

/* Pannello Frontale dello Split */
.split-front-chassis {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 2px 4px;
  position: relative;
}

.split-brand-row {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.split-brand-badge {
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-size: 0.58rem;
  font-weight: 800;
  letter-spacing: 1.2px;
  color: rgba(255, 255, 255, 0.45);
}

[data-theme="light"] .split-brand-badge {
  color: #64748b;
}

.split-inverter-tag {
  font-family: 'Orbitron', monospace;
  font-size: 0.46rem;
  font-weight: 700;
  letter-spacing: 0.8px;
  color: rgba(56, 189, 248, 0.7);
}

[data-theme="light"] .split-inverter-tag {
  color: #0284c7;
}

/* Display LED Incassato nel Pannello Frontale */
.split-embedded-led {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  background: rgba(0, 0, 0, 0.45);
  border-radius: 4px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.7);
  transition: all 0.3s ease;
}

[data-theme="light"] .split-embedded-led {
  background: rgba(15, 23, 42, 0.85);
  border-color: rgba(0, 0, 0, 0.2);
}

.split-embedded-led.is-off {
  opacity: 0.45;
  filter: grayscale(1);
  justify-content: center;
}

.split-embedded-led.is-off .split-led-mode-icon {
  display: none !important;
}

.split-wall-stage.is-off .split-airflow-stage,
.split-wall-stage.mode-off .split-airflow-stage {
  display: none !important;
  opacity: 0 !important;
}

.split-led-mode-icon {
  font-size: 0.82rem;
  line-height: 1;
}

.split-led-temp {
  font-family: 'Share Tech Mono', 'Orbitron', monospace;
  font-size: 0.95rem;
  font-weight: 900;
  line-height: 1;
  color: #94a3b8;
  letter-spacing: 0.5px;
}

.split-wall-stage.mode-heat .split-led-temp {
  color: #fdba74;
  text-shadow: 0 0 6px #f97316;
}

.split-wall-stage.mode-cool .split-led-temp {
  color: #7dd3fc;
  text-shadow: 0 0 6px #38bdf8;
}

.split-wall-stage.mode-dry .split-led-temp {
  color: #67e8f9;
  text-shadow: 0 0 6px #06b6d4;
}

.split-wall-stage.mode-fan_only .split-led-temp,
.split-wall-stage.mode-fan .split-led-temp {
  color: #c084fc;
  text-shadow: 0 0 6px #a855f7;
}

.split-wall-stage.mode-auto .split-led-temp {
  color: #6ee7b7;
  text-shadow: 0 0 6px #10b981;
}

/* Deflettore / Aletta Louver Inferiore Motorizzata */
.split-bottom-flap-wrap {
  width: 100%;
  height: 6px;
  position: relative;
  overflow: visible;
}

.split-louver-flap {
  width: 100%;
  height: 5px;
  background: linear-gradient(180deg, #475569 0%, #1e293b 100%);
  border-radius: 0 0 6px 6px;
  border-top: 1px solid rgba(0, 0, 0, 0.5);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.4);
  transform-origin: top center;
  transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1), background 0.3s ease;
}

[data-theme="light"] .split-louver-flap {
  background: linear-gradient(180deg, #cbd5e1 0%, #94a3b8 100%);
}

.split-louver-flap.open {
  transform: translateY(3px) rotateX(32deg);
  animation: louverOscillate 3.2s ease-in-out infinite alternate;
}

.split-louver-flap.closed {
  transform: translateY(0) rotateX(0deg);
}

@keyframes louverOscillate {
  0% { transform: translateY(3px) rotateX(25deg); }
  100% { transform: translateY(4px) rotateX(42deg); }
}

/* Stage Erogazione Flusso d'Aria (Sotto lo Split) */
.split-airflow-stage {
  width: 88%;
  max-width: 290px;
  height: 52px;
  position: relative;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-top: -2px;
  overflow: hidden;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.4s ease;
  z-index: 1;
}

.split-airflow-stage.active {
  opacity: 1;
}

.split-air-beam {
  width: 28%;
  height: 100%;
  border-radius: 0 0 10px 10px;
  filter: blur(2px);
  opacity: 0.85;
}

/* Animazione 1: Calore (Heat) - Onde calde radianti */
.split-airflow-stage.mode-heat .split-air-beam {
  background: linear-gradient(180deg, rgba(249, 115, 22, 0.85) 0%, rgba(251, 146, 60, 0.45) 50%, rgba(249, 115, 22, 0) 100%);
  animation: heatBeamWave 1.4s ease-in-out infinite alternate;
}

.split-airflow-stage.mode-heat .beam-center {
  animation-delay: 0.25s;
  width: 34%;
}

.split-airflow-stage.mode-heat .beam-right {
  animation-delay: 0.5s;
}

@keyframes heatBeamWave {
  0% {
    transform: translateY(0) scaleY(0.75) scaleX(0.92);
    opacity: 0.55;
    filter: blur(2.5px);
  }
  100% {
    transform: translateY(6px) scaleY(1.08) scaleX(1.05);
    opacity: 0.95;
    filter: blur(1.5px);
  }
}

/* Animazione 2: Freddo (Cool) - Getto glaciale rapido */
.split-airflow-stage.mode-cool .split-air-beam {
  background: linear-gradient(180deg, rgba(56, 189, 248, 0.9) 0%, rgba(125, 211, 252, 0.5) 45%, rgba(56, 189, 248, 0) 100%);
  animation: coolBeamFlow 1.1s cubic-bezier(0.25, 0.8, 0.5, 1) infinite;
}

.split-airflow-stage.mode-cool .beam-center {
  animation-delay: 0.18s;
  width: 34%;
}

.split-airflow-stage.mode-cool .beam-right {
  animation-delay: 0.36s;
}

@keyframes coolBeamFlow {
  0% {
    transform: translateY(-4px) scaleY(0.4);
    opacity: 0.3;
  }
  50% {
    opacity: 0.9;
    transform: translateY(2px) scaleY(0.9);
  }
  100% {
    transform: translateY(8px) scaleY(1.15);
    opacity: 0.1;
  }
}

/* Animazione 3: Deumidifica (Dry) - Brezza con goccioline di condensa */
.split-airflow-stage.mode-dry .split-air-beam {
  background: linear-gradient(180deg, rgba(6, 182, 212, 0.75) 0%, rgba(34, 211, 238, 0.35) 50%, rgba(6, 182, 212, 0) 100%);
  animation: dryBeamPulse 1.9s ease-in-out infinite alternate;
}

.split-airflow-stage.mode-dry .beam-center {
  animation-delay: 0.35s;
  width: 34%;
}

@keyframes dryBeamPulse {
  0% { transform: translateY(0) scaleY(0.65); opacity: 0.45; }
  100% { transform: translateY(6px) scaleY(1); opacity: 0.8; }
}

/* Animazione 4: Ventilazione (Fan) - Raffiche dinamiche e veloci */
.split-airflow-stage.mode-fan_only .split-air-beam,
.split-airflow-stage.mode-fan .split-air-beam {
  background: linear-gradient(180deg, rgba(168, 85, 247, 0.85) 0%, rgba(192, 132, 252, 0.4) 45%, rgba(168, 85, 247, 0) 100%);
  animation: fanBreezeFlow 0.75s linear infinite;
}

.split-airflow-stage.mode-fan_only .beam-center,
.split-airflow-stage.mode-fan .beam-center {
  animation-delay: 0.12s;
  width: 34%;
}

@keyframes fanBreezeFlow {
  0% { transform: translateY(-3px) skewX(-4deg) scaleY(0.5); opacity: 0.4; }
  50% { transform: translateY(2px) skewX(4deg) scaleY(0.95); opacity: 0.85; }
  100% { transform: translateY(7px) skewX(-2deg) scaleY(1.1); opacity: 0.2; }
}

/* Animazione 5: Automatico (Auto) */
.split-airflow-stage.mode-auto .split-air-beam {
  background: linear-gradient(180deg, rgba(16, 185, 129, 0.85) 0%, rgba(52, 211, 153, 0.4) 50%, rgba(16, 185, 129, 0) 100%);
  animation: heatBeamWave 1.3s ease-in-out infinite alternate;
}

/* Particelle Fluttuanti dell'Aria */
.split-air-particles {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  pointer-events: none;
}

.air-particle {
  position: absolute;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  opacity: 0;
}

.split-airflow-stage.active .air-particle {
  animation: particleFloat 1.8s ease-in-out infinite;
}

.split-airflow-stage.mode-heat .air-particle {
  background: #f97316;
  box-shadow: 0 0 6px #fdba74;
}

.split-airflow-stage.mode-cool .air-particle {
  background: #38bdf8;
  box-shadow: 0 0 6px #bae6fd;
}

.split-airflow-stage.mode-dry .air-particle {
  background: #06b6d4;
  border-radius: 50% 50% 50% 0;
  transform: rotate(-45deg);
  box-shadow: 0 0 4px #67e8f9;
}

.split-airflow-stage.mode-fan_only .air-particle,
.split-airflow-stage.mode-fan .air-particle {
  background: #a855f7;
  box-shadow: 0 0 6px #e9d5ff;
}

.part-1 { left: 20%; animation-delay: 0s; }
.part-2 { left: 45%; animation-delay: 0.4s; }
.part-3 { left: 75%; animation-delay: 0.8s; }
.part-4 { left: 60%; animation-delay: 1.2s; }

@keyframes particleFloat {
  0% { transform: translateY(0) scale(0.5); opacity: 0; }
  30% { opacity: 0.9; }
  80% { opacity: 0.6; }
  100% { transform: translateY(38px) scale(1.1); opacity: 0; }
}

/* ===================================================
   📍 MAP PIN MINI-SPLIT AVATAR
   =================================================== */

.map-pin.climate.is-active .map-climate-avatar {
  border-color: #38bdf8;
  box-shadow: 0 0 16px rgba(56, 189, 248, 0.7), 0 0 24px rgba(2, 132, 199, 0.4);
}

.map-pin.climate.is-active .map-climate-avatar.mode-heat {
  border-color: #f97316;
  box-shadow: 0 0 16px rgba(249, 115, 22, 0.7), 0 0 24px rgba(234, 88, 12, 0.4);
}

.map-pin-avatar.map-climate-avatar {
  width: 48px;
  height: 48px;
  border-radius: 9px;
  background: #1e293b;
  border: 2px solid #334155;
  padding: 2px 3px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  position: relative;
  overflow: visible;
  transition: all 0.25s ease;
}

[data-theme="light"] .map-pin-avatar.map-climate-avatar {
  background: #f8fafc;
  border-color: #cbd5e1;
}

.map-pin-avatar.map-climate-avatar.is-on.mode-heat {
  border-color: #f97316;
  background: radial-gradient(circle at center, #2e1810 0%, #1a162b 100%);
}

.map-pin-avatar.map-climate-avatar.is-on.mode-cool {
  border-color: #38bdf8;
  background: radial-gradient(circle at center, #0c283d 0%, #12182b 100%);
}

.map-pin-avatar.map-climate-avatar.is-on.mode-dry {
  border-color: #06b6d4;
  background: radial-gradient(circle at center, #0a272e 0%, #12182b 100%);
}

.map-pin-avatar.map-climate-avatar.is-on.mode-fan_only,
.map-pin-avatar.map-climate-avatar.is-on.mode-fan {
  border-color: #a855f7;
  background: radial-gradient(circle at center, #251238 0%, #12182b 100%);
}

.map-pin-avatar.map-climate-avatar.is-on.mode-auto {
  border-color: #10b981;
  background: radial-gradient(circle at center, #0d2920 0%, #12182b 100%);
}

.map-climate-pin-split {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  position: relative;
}

/* Tag temperatura impostata sopra il mini-split */
.map-climate-pin-target-tag {
  font-family: 'Share Tech Mono', 'Orbitron', monospace;
  font-size: 0.65rem;
  font-weight: 900;
  line-height: 1;
  color: #94a3b8;
  margin-top: 1px;
  transition: all 0.2s ease;
}

.map-climate-pin-target-tag.is-on {
  color: #ffffff;
  text-shadow: 0 0 6px rgba(255, 255, 255, 0.8);
}

.map-climate-pin-split.mode-heat .map-climate-pin-target-tag.is-on {
  color: #fdba74;
  text-shadow: 0 0 6px #f97316;
}

.map-climate-pin-split.mode-cool .map-climate-pin-target-tag.is-on {
  color: #7dd3fc;
  text-shadow: 0 0 6px #38bdf8;
}

.map-climate-pin-split.mode-dry .map-climate-pin-target-tag.is-on {
  color: #67e8f9;
  text-shadow: 0 0 6px #06b6d4;
}

.map-climate-pin-split.mode-fan_only .map-climate-pin-target-tag.is-on,
.map-climate-pin-split.mode-fan .map-climate-pin-target-tag.is-on {
  color: #c084fc;
  text-shadow: 0 0 6px #a855f7;
}

/* Chassis Mini-Split */
.map-climate-mini-split {
  width: 38px;
  height: 20px;
  background: linear-gradient(180deg, #475569 0%, #1e293b 70%, #0f172a 100%);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 3px 3px 5px 5px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 1px 3px 0;
  position: relative;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.4);
  z-index: 2;
}

[data-theme="light"] .map-climate-mini-split {
  background: linear-gradient(180deg, #ffffff 0%, #f1f5f9 60%, #cbd5e1 100%);
  border-color: #94a3b8;
}

.mini-split-intake {
  width: 100%;
  height: 1.5px;
  background: rgba(255, 255, 255, 0.15);
  border-radius: 1px;
}

[data-theme="light"] .mini-split-intake {
  background: rgba(0, 0, 0, 0.12);
}

.mini-split-fascia {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 0 1px;
}

.mini-split-icon {
  font-size: 0.65rem;
  line-height: 1;
}

.map-climate-pin-split.is-off .mini-split-icon,
.map-climate-pin-split.mode-off .mini-split-icon {
  display: none !important;
}

.map-climate-pin-split.is-off .mini-split-fascia,
.map-climate-pin-split.mode-off .mini-split-fascia {
  justify-content: flex-end;
}

.map-climate-pin-split.is-off .mini-split-airflow,
.map-climate-pin-split.mode-off .mini-split-airflow {
  display: none !important;
  opacity: 0 !important;
}

.mini-split-led {
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: #334155;
  border: 1px solid rgba(255, 255, 255, 0.1);
  transition: all 0.2s ease;
}

.mini-split-led.is-on {
  background: #22c55e;
  box-shadow: 0 0 5px #22c55e;
}

.map-climate-pin-split.mode-heat .mini-split-led.is-on {
  background: #f97316;
  box-shadow: 0 0 5px #f97316;
}

.map-climate-pin-split.mode-cool .mini-split-led.is-on {
  background: #38bdf8;
  box-shadow: 0 0 5px #38bdf8;
}

.mini-split-flap {
  width: 100%;
  height: 2px;
  background: rgba(255, 255, 255, 0.25);
  border-radius: 0 0 2px 2px;
  transform-origin: top center;
  transition: transform 0.25s ease;
}

.mini-split-flap.open {
  transform: translateY(1.5px) rotateX(30deg);
}

/* Flusso aria mini emesso sotto lo split del pin */
.mini-split-airflow {
  width: 28px;
  height: 8px;
  display: flex;
  justify-content: space-around;
  opacity: 0;
  transition: opacity 0.25s ease;
}

.mini-split-airflow.active {
  opacity: 0.85;
}

.mini-air-stream {
  width: 10px;
  height: 100%;
  border-radius: 0 0 3px 3px;
}

.mini-split-airflow.mode-heat .mini-air-stream {
  background: linear-gradient(180deg, rgba(249, 115, 22, 0.8) 0%, transparent 100%);
  animation: heatBeamWave 1.2s ease-in-out infinite alternate;
}

.mini-split-airflow.mode-cool .mini-air-stream {
  background: linear-gradient(180deg, rgba(56, 189, 248, 0.8) 0%, transparent 100%);
  animation: coolBeamFlow 0.9s ease-in-out infinite;
}

.mini-split-airflow.mode-dry .mini-air-stream {
  background: linear-gradient(180deg, rgba(6, 182, 212, 0.8) 0%, transparent 100%);
  animation: dryBeamPulse 1.4s ease-in-out infinite alternate;
}

.mini-split-airflow.mode-fan_only .mini-air-stream,
.mini-split-airflow.mode-fan .mini-air-stream {
  background: linear-gradient(180deg, rgba(168, 85, 247, 0.8) 0%, transparent 100%);
  animation: fanBreezeFlow 0.7s linear infinite;
}

.mini-split-airflow.mode-auto .mini-air-stream {
  background: linear-gradient(180deg, rgba(16, 185, 129, 0.8) 0%, transparent 100%);
  animation: heatBeamWave 1.2s ease-in-out infinite alternate;
}

/* Table Climate Item */
.table-climate-item {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.table-toggle-btn.climate.is-on.mode-cool {
  background: rgba(56, 189, 248, 0.2);
  border-color: #38bdf8;
  color: #38bdf8;
}

.table-toggle-btn.climate.is-on.mode-heat {
  background: rgba(249, 115, 22, 0.2);
  border-color: #f97316;
  color: #fb923c;
}

/* Light theme overrides */
[data-theme="light"] .ha-climate-card-unit {
  background: #ffffff;
  border-color: rgba(0, 0, 0, 0.08);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}

[data-theme="light"] .ha-climate-temp-section {
  background: rgba(0, 0, 0, 0.03);
  border-color: rgba(0, 0, 0, 0.06);
}

[data-theme="light"] .ha-climate-title {
  color: #0f172a;
}

[data-theme="light"] .ha-climate-ambient-val {
  color: #1e293b;
}

[data-theme="light"] .btn-climate-step {
  background: rgba(0, 0, 0, 0.06);
  color: #1e293b;
}

[data-theme="light"] .ha-climate-range {
  background: rgba(0, 0, 0, 0.12);
}

[data-theme="light"] .modal-card-climate {
  background: #ffffff;
  border-color: rgba(0, 0, 0, 0.1);
}

[data-theme="light"] .climate-dial-circle {
  background: radial-gradient(circle at center, #f8fafc 0%, #e2e8f0 100%);
  border-color: #0284c7;
  box-shadow: 0 4px 20px rgba(2, 132, 199, 0.2);
}

[data-theme="light"] .climate-dial-temp {
  color: #0f172a;
  text-shadow: none;
}

[data-theme="light"] .climate-modal-opt-btn {
  background: rgba(0, 0, 0, 0.03);
  border-color: rgba(0, 0, 0, 0.08);
  color: #334155;
}

/* ==========================================================================
   🌀 MAP OUTDOOR UNIT (UNITÀ ESTERNA CLIMATIZZATORE / POMPA DI CALORE)
   ========================================================================== */

.map-outdoor-container {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 18;
}

.map-outdoor-unit-wrapper {
  position: absolute;
  pointer-events: auto;
  user-select: none;
  touch-action: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  transform: translate(-50%, -50%);
  cursor: pointer;
  transition: filter 0.25s ease, transform 0.15s ease;
  z-index: 20;
}

.map-mode-edit .map-outdoor-unit-wrapper {
  cursor: grab;
}

.map-mode-edit .map-outdoor-unit-wrapper.dragging {
  cursor: grabbing;
  z-index: 50;
  transform: translate(-50%, -50%) scale(1.08);
}

.map-outdoor-unit-wrapper:hover {
  filter: drop-shadow(0 0 12px rgba(56, 189, 248, 0.5));
}

/* 🌬️ Plume di Scarico Termodinamico (Dissipazione Calore o Espulsione Freddo) */
.outdoor-exhaust-plume {
  position: absolute;
  width: 60px;
  height: 34px;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.4s ease;
  z-index: 5;
}

.outdoor-exhaust-plume.active {
  opacity: 1;
}

/* Direzioni Getto Grafico */
.outdoor-exhaust-plume.dir-top {
  top: -30px;
  left: 50%;
  transform: translateX(-50%);
}

.outdoor-exhaust-plume.dir-bottom {
  top: auto;
  bottom: -30px;
  left: 50%;
  transform: translateX(-50%) rotate(180deg);
}

.outdoor-exhaust-plume.dir-left {
  top: 50%;
  left: -28px;
  transform: translateY(-50%) rotate(270deg);
}

.outdoor-exhaust-plume.dir-right {
  top: 50%;
  left: auto;
  right: -28px;
  transform: translateY(-50%) rotate(90deg);
}

/* Modalità Freddo Interno -> Dissipazione Calore all'Esterno (Onde Ambra/Rosse) */
.outdoor-exhaust-plume.heat .thermal-wave {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  width: 38px;
  height: 12px;
  border-radius: 50%;
  background: radial-gradient(ellipse at center, rgba(249, 115, 22, 0.7) 0%, rgba(239, 68, 68, 0.3) 60%, transparent 100%);
  filter: blur(2px);
  animation: outdoorHeatWave 1.4s infinite ease-out;
}

.outdoor-exhaust-plume.heat .thermal-wave.wave-1 { animation-delay: 0s; }
.outdoor-exhaust-plume.heat .thermal-wave.wave-2 { animation-delay: 0.45s; }
.outdoor-exhaust-plume.heat .thermal-wave.wave-3 { animation-delay: 0.9s; }

.outdoor-exhaust-plume.heat .particle {
  position: absolute;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: #fb923c;
  box-shadow: 0 0 6px #ea580c;
  animation: outdoorHeatParticle 1.6s infinite ease-out;
}

.outdoor-exhaust-plume.heat .particle.p-1 { left: 20%; animation-delay: 0.1s; }
.outdoor-exhaust-plume.heat .particle.p-2 { left: 45%; animation-delay: 0.5s; }
.outdoor-exhaust-plume.heat .particle.p-3 { left: 75%; animation-delay: 0.9s; }
.outdoor-exhaust-plume.heat .particle.p-4 { left: 35%; animation-delay: 1.3s; }

/* Modalità Caldo Interno -> Espulsione Freddo all'Esterno (Nebbia/Ghiaccio Ciano) */
.outdoor-exhaust-plume.cold .thermal-wave {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  width: 42px;
  height: 14px;
  border-radius: 50%;
  background: radial-gradient(ellipse at center, rgba(56, 189, 248, 0.8) 0%, rgba(14, 165, 233, 0.35) 60%, transparent 100%);
  filter: blur(2.5px);
  animation: outdoorColdWave 1.5s infinite ease-out;
}

.outdoor-exhaust-plume.cold .thermal-wave.wave-1 { animation-delay: 0s; }
.outdoor-exhaust-plume.cold .thermal-wave.wave-2 { animation-delay: 0.5s; }
.outdoor-exhaust-plume.cold .thermal-wave.wave-3 { animation-delay: 1.0s; }

.outdoor-exhaust-plume.cold .particle {
  position: absolute;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: #e0f2fe;
  box-shadow: 0 0 6px #38bdf8;
  animation: outdoorColdParticle 1.8s infinite ease-out;
}

.outdoor-exhaust-plume.cold .particle.p-1 { left: 22%; animation-delay: 0.2s; }
.outdoor-exhaust-plume.cold .particle.p-2 { left: 50%; animation-delay: 0.6s; }
.outdoor-exhaust-plume.cold .particle.p-3 { left: 78%; animation-delay: 1.1s; }
.outdoor-exhaust-plume.cold .particle.p-4 { left: 38%; animation-delay: 1.4s; }

@keyframes outdoorHeatWave {
  0% { transform: translateX(-50%) translateY(14px) scale(0.7); opacity: 0.9; }
  50% { opacity: 0.6; }
  100% { transform: translateX(-50%) translateY(-18px) scale(1.45); opacity: 0; }
}

@keyframes outdoorColdWave {
  0% { transform: translateX(-50%) translateY(14px) scale(0.75); opacity: 0.95; }
  50% { opacity: 0.65; }
  100% { transform: translateX(-50%) translateY(-20px) scale(1.5); opacity: 0; }
}

@keyframes outdoorHeatParticle {
  0% { transform: translateY(10px) scale(0.6); opacity: 0; }
  20% { opacity: 1; }
  100% { transform: translateY(-24px) scale(1.3); opacity: 0; }
}

@keyframes outdoorColdParticle {
  0% { transform: translateY(10px) scale(0.6); opacity: 0; }
  25% { opacity: 1; }
  100% { transform: translateY(-26px) scale(1.2); opacity: 0; }
}

/* 🏢 Chassis Unità Esterna */
.outdoor-cabinet {
  position: relative;
  width: 66px;
  height: 44px;
  background: linear-gradient(180deg, #334155 0%, #1e293b 60%, #0f172a 100%);
  border-radius: 6px;
  border: 1.5px solid rgba(255, 255, 255, 0.18);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.45), inset 0 1px 0 rgba(255, 255, 255, 0.2);
  display: flex;
  flex-direction: column;
  transition: border-color 0.3s ease, box-shadow 0.3s ease;
}

.map-outdoor-unit-wrapper.heat-exhaust .outdoor-cabinet {
  border-color: rgba(249, 115, 22, 0.7);
  box-shadow: 0 0 16px rgba(249, 115, 22, 0.35), inset 0 1px 0 rgba(251, 146, 60, 0.3);
}

.map-outdoor-unit-wrapper.cold-exhaust .outdoor-cabinet {
  border-color: rgba(56, 189, 248, 0.7);
  box-shadow: 0 0 16px rgba(56, 189, 248, 0.35), inset 0 1px 0 rgba(125, 211, 252, 0.3);
}

.cabinet-top-hood {
  height: 4px;
  width: 100%;
  background: linear-gradient(90deg, #475569, #64748b, #475569);
  border-top-left-radius: 5px;
  border-top-right-radius: 5px;
  border-bottom: 1px solid rgba(0, 0, 0, 0.3);
}

.cabinet-body {
  flex: 1;
  display: flex;
  align-items: center;
  padding: 2px 4px;
  gap: 4px;
}

/* Griglia & Ventola Assiale */
.cabinet-fan-section {
  position: relative;
  width: 34px;
  height: 34px;
}

.fan-shroud-outer {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  background: #090d16;
  border: 1.5px solid rgba(255, 255, 255, 0.12);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: inset 0 2px 6px rgba(0, 0, 0, 0.8);
  overflow: hidden;
  position: relative;
}

.fan-shroud-inner {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.outdoor-fan-blades {
  width: 28px;
  height: 28px;
  transform-origin: 50% 50%;
}

.outdoor-fan-blades .fan-hub {
  fill: #475569;
}

.outdoor-fan-blades .fan-blade {
  fill: #94a3b8;
  transition: fill 0.3s ease;
}

.map-outdoor-unit-wrapper.heat-exhaust .outdoor-fan-blades .fan-blade {
  fill: #fdba74;
}

.map-outdoor-unit-wrapper.cold-exhaust .outdoor-fan-blades .fan-blade {
  fill: #bae6fd;
}

.outdoor-fan-blades.is-spinning {
  animation: outdoorFanSpin 0.45s linear infinite;
}

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

/* Griglia di protezione a raggi concentrici */
.fan-wire-grille {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  pointer-events: none;
}

.fan-wire-grille .h-bar {
  position: absolute;
  top: 50%;
  left: 0;
  width: 100%;
  height: 1px;
  background: rgba(255, 255, 255, 0.2);
  transform: translateY(-50%);
}

.fan-wire-grille .v-bar {
  position: absolute;
  top: 0;
  left: 50%;
  width: 1px;
  height: 100%;
  background: rgba(255, 255, 255, 0.2);
  transform: translateX(-50%);
}

.fan-wire-grille .ring-1 {
  position: absolute;
  top: 15%;
  left: 15%;
  width: 70%;
  height: 70%;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.15);
}

.fan-wire-grille .ring-2 {
  position: absolute;
  top: 32%;
  left: 32%;
  width: 36%;
  height: 36%;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.25);
}

/* Sezione Inverter / Vano Tecnico (Clean Industrial) */
.cabinet-service-section {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  height: 100%;
  padding: 2px 0;
}

.service-louver-lines {
  display: flex;
  flex-direction: column;
  gap: 3px;
  width: 16px;
  margin-top: 2px;
}

.service-louver-lines span {
  display: block;
  width: 100%;
  height: 1.5px;
  background: rgba(255, 255, 255, 0.15);
  border-radius: 1px;
}

.outdoor-led-status {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #475569;
  align-self: flex-end;
  margin-right: 2px;
  transition: all 0.3s ease;
}

.outdoor-led-status.led-heat {
  background: #f97316;
  box-shadow: 0 0 8px #f97316, 0 0 12px #fb923c;
  animation: ledPulse 1.2s infinite alternate ease-in-out;
}

.outdoor-led-status.led-cool {
  background: #38bdf8;
  box-shadow: 0 0 8px #38bdf8, 0 0 12px #7dd3fc;
  animation: ledPulse 1.2s infinite alternate ease-in-out;
}

.outdoor-led-status.led-fan {
  background: #a855f7;
  box-shadow: 0 0 8px #a855f7;
}

.copper-pipes-accent {
  display: flex;
  flex-direction: column;
  gap: 2px;
  align-self: flex-end;
  margin-right: 2px;
}

.copper-pipes-accent .pipe {
  width: 8px;
  height: 2px;
  border-radius: 1px;
  background: linear-gradient(90deg, #b45309, #d97706);
}

.copper-pipes-accent .pipe-low {
  width: 6px;
}

/* Piedini Antivibranti */
.cabinet-feet {
  position: absolute;
  bottom: -4px;
  left: 0;
  width: 100%;
  display: flex;
  justify-content: space-between;
  padding: 0 6px;
  pointer-events: none;
}

.cabinet-feet .foot {
  width: 8px;
  height: 3px;
  background: #0f172a;
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 1px;
}

/* Popover Unità Esterna */
.outdoor-popover-banner {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-color);
}

.outdoor-popover-banner.heat-exhaust {
  background: linear-gradient(135deg, rgba(249, 115, 22, 0.12) 0%, rgba(239, 68, 68, 0.05) 100%);
  border-color: rgba(249, 115, 22, 0.3);
}

.outdoor-popover-banner.cold-exhaust {
  background: linear-gradient(135deg, rgba(56, 189, 248, 0.12) 0%, rgba(14, 165, 233, 0.05) 100%);
  border-color: rgba(56, 189, 248, 0.3);
}

.outdoor-popover-banner .banner-icon {
  font-size: 1.8rem;
  line-height: 1;
}

.outdoor-popover-banner .banner-title {
  font-weight: 800;
  font-size: 0.95rem;
  color: var(--text-main);
  margin-bottom: 2px;
}

.outdoor-popover-banner .banner-desc {
  font-size: 0.78rem;
  color: var(--text-muted);
  line-height: 1.35;
}

.outdoor-popover-banner .banner-desc strong {
  color: var(--text-main);
}

/* Popover Quick Controls for Direction & Rotation */
.outdoor-popover-controls {
  margin-top: 14px;
  padding: 10px 12px;
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.outdoor-popover-controls-label {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--text-main);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.outdoor-dir-btn-group {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.outdoor-dir-btn-group .btn {
  flex: 1;
  min-width: 54px;
  font-size: 0.75rem;
  padding: 4px 6px;
}

.outdoor-dir-btn-group .btn.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

/* Light Mode Overrides */
[data-theme="light"] .outdoor-cabinet {
  background: linear-gradient(180deg, #e2e8f0 0%, #cbd5e1 60%, #94a3b8 100%);
  border-color: rgba(0, 0, 0, 0.15);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
}

[data-theme="light"] .fan-shroud-outer {
  background: #f1f5f9;
  border-color: rgba(0, 0, 0, 0.1);
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.15);
}

[data-theme="light"] .service-louver-lines span {
  background: rgba(0, 0, 0, 0.15);
}




