:root {
  --bg-dark: #0a0a0e;
  --card-bg: rgba(22, 22, 29, 0.7);
  --card-border: rgba(255, 255, 255, 0.08);
  --card-border-hover: rgba(255, 255, 255, 0.2);
  --text-main: #f9fafb;
  --text-muted: #9ca3af;
  --indigo: #6366f1;
  --amber: #f59e0b;
  --emerald: #10b981;
  --danger: #ef4444;
  --font-heading: 'Outfit', -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'Segoe UI', Roboto, sans-serif;
  --font-body: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'Segoe UI', Roboto, sans-serif;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  background-color: var(--bg-dark);
  color: var(--text-main);
  font-family: var(--font-body);
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
  position: relative;
  overflow-x: hidden;
  padding: 24px;
}

/* Ambient glow orbs */
.ambient-glow {
  position: fixed;
  border-radius: 50%;
  filter: blur(70px);
  -webkit-filter: blur(70px);
  pointer-events: none;
  z-index: 0;
  opacity: 0.28;
}

.glow-1 {
  width: 500px;
  height: 500px;
  background: radial-gradient(circle, rgba(16, 185, 129, 0.5) 0%, transparent 70%);
  top: -120px;
  left: 5%;
}

.glow-2 {
  width: 500px;
  height: 500px;
  background: radial-gradient(circle, rgba(99, 102, 241, 0.4) 0%, transparent 70%);
  bottom: -100px;
  right: 5%;
}

.view-container {
  width: 100%;
  position: relative;
  z-index: 1;
  display: flex;
  justify-content: center;
  align-items: center;
}

.hidden {
  display: none !important;
}

/* Glass Card */
.glass-card {
  background: var(--card-bg);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--card-border);
  border-radius: 24px;
  padding: 32px;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.4);
}

/* BRAND BADGE */
.brand-badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 14px;
  border-radius: 9999px;
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  background: rgba(16, 185, 129, 0.12);
  color: var(--emerald);
  border: 1px solid rgba(16, 185, 129, 0.25);
  margin-bottom: 12px;
}

.portal-title {
  font-family: var(--font-heading);
  font-size: 2.2rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  margin-bottom: 6px;
}

.portal-subtitle {
  color: var(--text-muted);
  font-size: 0.95rem;
}

/* LOGIN VIEW */
.login-card {
  width: 100%;
  max-width: 420px;
  text-align: center;
}

.login-form {
  margin-top: 28px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  text-align: left;
}

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

.form-group label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
}

.text-input {
  width: 100%;
  background: rgba(10, 10, 14, 0.6);
  border: 1px solid var(--card-border);
  border-radius: 12px;
  padding: 14px 16px;
  color: var(--text-main);
  font-family: var(--font-body);
  font-size: 1rem;
  transition: all 0.2s ease;
}

.text-input:focus {
  outline: none;
  border-color: var(--emerald);
  box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.15);
}

.password-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

.toggle-pwd-btn {
  position: absolute;
  right: 14px;
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.toggle-pwd-btn svg {
  width: 20px;
  height: 20px;
}

.alert-box {
  background: rgba(239, 68, 68, 0.12);
  border: 1px solid rgba(239, 68, 68, 0.25);
  color: #fca5a5;
  border-radius: 12px;
  padding: 12px 14px;
  font-size: 0.88rem;
  text-align: center;
}

.submit-btn {
  margin-top: 8px;
  background: linear-gradient(135deg, var(--emerald) 0%, #059669 100%);
  color: white;
  border: none;
  border-radius: 12px;
  padding: 16px;
  font-family: var(--font-heading);
  font-size: 1.05rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  box-shadow: 0 4px 16px rgba(16, 185, 129, 0.3);
}

.submit-btn:hover {
  filter: brightness(1.1);
  transform: translateY(-1px);
}

.submit-btn:active {
  transform: translateY(0);
}

/* SPINNER */
.spinner {
  width: 18px;
  height: 18px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

/* DASHBOARD */
.portal-container {
  width: 100%;
  max-width: 680px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.dashboard-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  padding-bottom: 8px;
}

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

.user-pill {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--card-border);
  border-radius: 9999px;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.logout-btn {
  background: transparent;
  border: 1px solid var(--card-border);
  border-radius: 9999px;
  color: var(--text-muted);
  padding: 6px 14px;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: all 0.2s ease;
}

.logout-btn svg {
  width: 14px;
  height: 14px;
}

.logout-btn:hover {
  background: rgba(239, 68, 68, 0.12);
  border-color: rgba(239, 68, 68, 0.3);
  color: #fca5a5;
}

/* DEVICE CARD */
.device-card {
  position: relative;
  background: var(--card-bg);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--card-border);
  border-radius: 28px;
  padding: 32px;
  overflow: hidden;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.35);
}

.device-card-glow {
  position: absolute;
  top: 0;
  right: 0;
  width: 300px;
  height: 300px;
  background: radial-gradient(circle, rgba(16, 185, 129, 0.12) 0%, transparent 70%);
  pointer-events: none;
}

.device-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 28px;
  flex-wrap: wrap;
  gap: 16px;
}

.device-title-group {
  display: flex;
  align-items: center;
  gap: 16px;
}

.device-icon-box {
  width: 52px;
  height: 52px;
  border-radius: 16px;
  background: rgba(16, 185, 129, 0.15);
  border: 1px solid rgba(16, 185, 129, 0.3);
  color: var(--emerald);
  display: flex;
  align-items: center;
  justify-content: center;
}

.device-icon-box svg {
  width: 28px;
  height: 28px;
}

.device-name {
  font-family: var(--font-heading);
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.device-ip {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.device-status-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px;
  border-radius: 9999px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--card-border);
  font-size: 0.85rem;
  color: var(--text-muted);
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #6b7280;
}

.status-dot.online {
  background: var(--emerald);
  box-shadow: 0 0 10px var(--emerald);
}

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

/* CONTROLS GRID */
.controls-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
}

.action-btn {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--card-border);
  border-radius: 20px;
  padding: 24px 20px;
  color: var(--text-main);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 16px;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  text-align: left;
  user-select: none;
}

.action-btn:hover {
  transform: translateY(-2px);
  border-color: var(--card-border-hover);
  background: rgba(255, 255, 255, 0.06);
}

.action-btn:active {
  transform: translateY(0) scale(0.98);
}

.btn-clean {
  grid-column: span 2;
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.2) 0%, rgba(5, 150, 105, 0.1) 100%);
  border-color: rgba(16, 185, 129, 0.35);
  padding: 28px 24px;
}

.btn-clean:hover {
  border-color: var(--emerald);
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.3) 0%, rgba(5, 150, 105, 0.15) 100%);
  box-shadow: 0 8px 24px rgba(16, 185, 129, 0.2);
}

.btn-stop:hover {
  border-color: var(--danger);
  background: rgba(239, 68, 68, 0.12);
  box-shadow: 0 8px 24px rgba(239, 68, 68, 0.15);
}

.btn-dock:hover {
  border-color: var(--indigo);
  background: rgba(99, 102, 241, 0.12);
  box-shadow: 0 8px 24px rgba(99, 102, 241, 0.15);
}

.btn-spot {
  grid-column: span 2;
}

.btn-spot:hover {
  border-color: var(--amber);
  background: rgba(245, 158, 11, 0.12);
  box-shadow: 0 8px 24px rgba(245, 158, 11, 0.15);
}

.action-icon {
  font-size: 2rem;
  line-height: 1;
}

.action-details {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.action-title {
  font-family: var(--font-heading);
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.action-sub {
  font-size: 0.82rem;
  color: var(--text-muted);
}

/* FEEDBACK BANNER */
.feedback-banner {
  margin-top: 20px;
  background: rgba(16, 185, 129, 0.12);
  border: 1px solid rgba(16, 185, 129, 0.25);
  color: #a7f3d0;
  border-radius: 12px;
  padding: 12px 16px;
  font-size: 0.9rem;
  display: flex;
  align-items: center;
  gap: 10px;
  animation: fadeIn 0.2s ease;
}

.feedback-banner.error {
  background: rgba(239, 68, 68, 0.12);
  border-color: rgba(239, 68, 68, 0.25);
  color: #fca5a5;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}

/* LOG CARD */
.log-card {
  padding: 24px;
}

.log-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.log-title {
  font-family: var(--font-heading);
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--text-muted);
}

.clear-log-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 0.8rem;
  cursor: pointer;
  text-decoration: underline;
}

.clear-log-btn:hover {
  color: var(--text-main);
}

.log-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 180px;
  overflow-y: auto;
}

.log-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: rgba(10, 10, 14, 0.4);
  border: 1px solid var(--card-border);
  padding: 10px 14px;
  border-radius: 10px;
  font-size: 0.85rem;
}

.empty-log {
  color: var(--text-muted);
  justify-content: center;
  border-style: dashed;
}

.log-action {
  font-weight: 600;
}

.log-time {
  color: var(--text-muted);
  font-size: 0.78rem;
}

/* CLEANING BANNER */
.cleaning-banner {
  display: flex;
  align-items: center;
  gap: 12px;
  background: rgba(245, 158, 11, 0.15);
  border: 1px solid rgba(245, 158, 11, 0.35);
  color: #fde68a;
  padding: 12px 18px;
  border-radius: 16px;
  margin-bottom: 20px;
  font-size: 0.95rem;
  font-weight: 600;
  animation: fadeIn 0.3s ease;
}

.pulsing-beacon {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #f59e0b;
  box-shadow: 0 0 12px #f59e0b;
  animation: beaconPulse 1.4s infinite;
}

@keyframes beaconPulse {
  0% { transform: scale(0.95); opacity: 0.8; }
  50% { transform: scale(1.35); opacity: 1; }
  100% { transform: scale(0.95); opacity: 0.8; }
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}

/* PRIMARY TOGGLE BUTTON */
.primary-control-row {
  margin-bottom: 16px;
}

.btn-primary-clean {
  width: 100%;
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.22) 0%, rgba(5, 150, 105, 0.12) 100%);
  border-color: rgba(16, 185, 129, 0.4);
  padding: 26px 22px;
  position: relative;
  overflow: hidden;
  justify-content: flex-start;
}

.btn-primary-clean:hover {
  border-color: var(--emerald);
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.32) 0%, rgba(5, 150, 105, 0.18) 100%);
  box-shadow: 0 8px 28px rgba(16, 185, 129, 0.25);
}

.btn-primary-clean.is-cleaning {
  background: linear-gradient(135deg, rgba(239, 68, 68, 0.25) 0%, rgba(220, 38, 38, 0.12) 100%);
  border-color: rgba(239, 68, 68, 0.45);
}

.btn-primary-clean.is-cleaning:hover {
  border-color: var(--danger);
  background: linear-gradient(135deg, rgba(239, 68, 68, 0.35) 0%, rgba(220, 38, 38, 0.2) 100%);
  box-shadow: 0 8px 28px rgba(239, 68, 68, 0.3);
}

.toggle-icon-wrap {
  width: 52px;
  height: 52px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.05);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.6rem;
  flex-shrink: 0;
}

.cleaning-wave {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 4px;
}

.cleaning-wave span {
  width: 4px;
  height: 18px;
  background: #f87171;
  border-radius: 2px;
  animation: wave 1s ease-in-out infinite;
}

.cleaning-wave span:nth-child(2) { animation-delay: 0.2s; }
.cleaning-wave span:nth-child(3) { animation-delay: 0.4s; }

@keyframes wave {
  0%, 100% { height: 8px; }
  50% { height: 22px; }
}

/* SECONDARY CONTROLS */
.secondary-controls-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-bottom: 8px;
}

.action-btn-sm {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--card-border);
  border-radius: 16px;
  padding: 16px 10px;
  color: var(--text-main);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  font-size: 0.85rem;
  font-weight: 600;
  user-select: none;
}

.action-btn-sm:hover {
  background: rgba(255, 255, 255, 0.07);
  border-color: var(--card-border-hover);
  transform: translateY(-2px);
}

.action-btn-sm:active {
  transform: translateY(0);
}

.btn-wake:hover {
  border-color: #fbbf24;
  box-shadow: 0 4px 16px rgba(251, 191, 36, 0.15);
}

.btn-dock:hover {
  border-color: var(--indigo);
  box-shadow: 0 4px 16px rgba(99, 102, 241, 0.15);
}

.btn-spot:hover {
  border-color: #38bdf8;
  box-shadow: 0 4px 16px rgba(56, 189, 248, 0.15);
}

.btn-sm-icon {
  font-size: 1.4rem;
}

/* TELEMETRY CARD */
.telemetry-card {
  padding: 24px;
  border-radius: 24px;
}

.telemetry-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 18px;
  flex-wrap: wrap;
  gap: 10px;
}

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

.telemetry-icon {
  font-size: 1.25rem;
}

.telemetry-title {
  font-family: var(--font-heading);
  font-size: 1.2rem;
  font-weight: 700;
}

.telemetry-badge {
  font-size: 0.78rem;
  color: var(--text-muted);
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--card-border);
  padding: 4px 12px;
  border-radius: 9999px;
}

.telemetry-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px;
}

.telemetry-item {
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 16px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.item-label {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  font-weight: 600;
}

.item-value {
  font-family: var(--font-heading);
  font-size: 1.45rem;
  font-weight: 700;
  color: var(--text-main);
}

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

.battery-bar-track {
  width: 100%;
  height: 6px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 9999px;
  overflow: hidden;
  margin-top: 4px;
  margin-bottom: 2px;
}

.battery-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, #10b981, #34d399);
  border-radius: 9999px;
  transition: width 0.4s ease;
}

/* FOOTER */
.portal-footer {
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 12px 0 24px;
  font-size: 0.82rem;
  color: var(--text-muted);
}

.footer-status {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 4px 12px;
  border-radius: 9999px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--card-border);
}

/* DASHBOARD GRID & TABS */
.dashboard-grid,
.tab-panel {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.device-tabs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  background: rgba(15, 15, 22, 0.75);
  border: 1px solid var(--card-border);
  border-radius: 18px;
  padding: 6px;
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
}

.device-tab {
  background: transparent;
  border: 1px solid transparent;
  border-radius: 13px;
  padding: 12px 12px;
  color: var(--text-muted);
  font-family: var(--font-heading);
  font-size: 0.94rem;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  user-select: none;
}

.device-tab:hover {
  color: var(--text-main);
  background: rgba(255, 255, 255, 0.04);
}

.device-tab.active {
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.18) 0%, rgba(99, 102, 241, 0.14) 100%);
  border-color: rgba(16, 185, 129, 0.38);
  color: var(--text-main);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.28);
}

.tab-icon {
  font-size: 1.2rem;
  line-height: 1;
  display: inline-flex;
}

/* FAN SPECIFIC CONTROLS & ANIMATIONS */
.fan-glow {
  background: radial-gradient(circle, rgba(56, 189, 248, 0.15) 0%, transparent 70%);
}

.fan-icon-box {
  background: rgba(56, 189, 248, 0.14);
  border-color: rgba(56, 189, 248, 0.32);
  color: #38bdf8;
}

.fan-spinning {
  animation: fanSpin 1.1s linear infinite;
}

.fan-spinning-fast {
  animation: fanSpin 0.45s linear infinite;
}

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

.fan-active-banner {
  background: rgba(56, 189, 248, 0.14);
  border-color: rgba(56, 189, 248, 0.35);
  color: #bae6fd;
}

.fan-beacon {
  background: #38bdf8;
  box-shadow: 0 0 12px #38bdf8;
}

.fan-slider-box {
  background: rgba(255, 255, 255, 0.025);
  border: 1px solid var(--card-border);
  border-radius: 20px;
  padding: 20px 22px;
  margin-bottom: 16px;
}

.fan-slider-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
}

.fan-slider-label {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text-muted);
}

.fan-slider-val {
  font-family: var(--font-heading);
  font-size: 1.45rem;
  font-weight: 800;
  color: #38bdf8;
}

.fan-range-slider {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 10px;
  border-radius: 999px;
  background: linear-gradient(90deg, rgba(16, 185, 129, 0.35) 0%, rgba(56, 189, 248, 0.7) 100%);
  outline: none;
  cursor: pointer;
}

.fan-range-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: #f9fafb;
  border: 3px solid #38bdf8;
  box-shadow: 0 0 14px rgba(56, 189, 248, 0.6);
  cursor: pointer;
  transition: transform 0.15s ease;
}

.fan-range-slider::-webkit-slider-thumb:hover {
  transform: scale(1.12);
}

.fan-slider-ticks {
  display: flex;
  justify-content: space-between;
  margin-top: 10px;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.fan-presets-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin-bottom: 16px;
}

.fan-preset-btn.active-preset {
  border-color: #38bdf8;
  background: rgba(56, 189, 248, 0.14);
  box-shadow: 0 4px 16px rgba(56, 189, 248, 0.15);
}

.fan-timer-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--card-border);
  border-radius: 16px;
  padding: 12px 16px;
}

.fan-timer-label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
}

.fan-timer-pills {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.timer-pill {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--card-border);
  border-radius: 999px;
  color: var(--text-muted);
  padding: 5px 12px;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.timer-pill:hover {
  color: var(--text-main);
  border-color: var(--card-border-hover);
}

.timer-pill.active {
  background: rgba(16, 185, 129, 0.18);
  border-color: var(--emerald);
  color: #a7f3d0;
}

/* AUTO MODE PRIMARY BUTTON */
.btn-auto-mode {
  background: linear-gradient(135deg, rgba(56, 189, 248, 0.18) 0%, rgba(16, 185, 129, 0.12) 100%);
  border-color: rgba(56, 189, 248, 0.38);
}

.btn-auto-mode:hover {
  background: linear-gradient(135deg, rgba(56, 189, 248, 0.26) 0%, rgba(16, 185, 129, 0.18) 100%);
  border-color: #38bdf8;
}

.btn-auto-mode.is-auto-active {
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.28) 0%, rgba(56, 189, 248, 0.22) 100%);
  border-color: #10b981;
  box-shadow: 0 8px 28px rgba(16, 185, 129, 0.22);
}

/* DUAL-ENDED RANGE SLIDER */
.dual-range-wrap {
  position: relative;
  width: 100%;
  height: 28px;
  display: flex;
  align-items: center;
}

.dual-range-track {
  position: absolute;
  left: 0;
  right: 0;
  height: 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
}

.dual-range-fill {
  position: absolute;
  height: 10px;
  border-radius: 999px;
  background: linear-gradient(90deg, #10b981 0%, #38bdf8 100%);
  pointer-events: none;
}

.dual-range-input {
  position: absolute;
  left: 0;
  width: 100%;
  height: 10px;
  margin: 0;
  background: none;
  pointer-events: none;
  -webkit-appearance: none;
  appearance: none;
  outline: none;
}

.dual-range-input::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  pointer-events: auto;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: #f9fafb;
  border: 3px solid #10b981;
  box-shadow: 0 0 14px rgba(16, 185, 129, 0.65);
  cursor: pointer;
  transition: transform 0.15s ease;
}

#fanCo2MaxSlider::-webkit-slider-thumb {
  border-color: #38bdf8;
  box-shadow: 0 0 14px rgba(56, 189, 248, 0.65);
}

.dual-range-input::-webkit-slider-thumb:hover {
  transform: scale(1.14);
}

.dual-range-input::-moz-range-thumb {
  pointer-events: auto;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #f9fafb;
  border: 3px solid #10b981;
  box-shadow: 0 0 14px rgba(16, 185, 129, 0.65);
  cursor: pointer;
}

#fanCo2MaxSlider::-moz-range-thumb {
  border-color: #38bdf8;
  box-shadow: 0 0 14px rgba(56, 189, 248, 0.65);
}

/* INLINE BLE REFRESH ICON BUTTON IN TELEMETRY TILE */
.telemetry-label-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 6px;
}

.ble-refresh-icon-btn {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--card-border);
  color: var(--text-muted);
  width: 24px;
  height: 24px;
  border-radius: 7px;
  font-size: 0.9rem;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
  padding: 0;
}

.ble-refresh-icon-btn:hover {
  color: #38bdf8;
  border-color: #38bdf8;
  background: rgba(56, 189, 248, 0.12);
}

.ble-refresh-icon-btn.spinning {
  color: #38bdf8;
  border-color: #38bdf8;
  animation: fanRotorSpin 1s linear infinite;
}

/* PORTABLE CLIMATE SENSOR SPECIFIC STYLES */
.sensor-glow {
  background: radial-gradient(circle, rgba(245, 158, 11, 0.14) 0%, rgba(16, 185, 129, 0.08) 50%, transparent 70%);
}

.sensor-icon-box {
  background: rgba(245, 158, 11, 0.14);
  border-color: rgba(245, 158, 11, 0.35);
  color: #fbbf24;
}

.sensor-sleep-banner {
  background: rgba(99, 102, 241, 0.15);
  border-color: rgba(99, 102, 241, 0.38);
  color: #c7d2fe;
}

.sensor-beacon {
  background: #818cf8;
  box-shadow: 0 0 12px #818cf8;
}

.sensor-hero-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-bottom: 6px;
}

.sensor-hero-tile {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--card-border);
  border-radius: 18px;
  padding: 16px 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  transition: border-color 0.2s ease;
}

.sensor-hero-tile:hover {
  border-color: var(--card-border-hover);
}

.sensor-hero-label {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.sensor-hero-val {
  font-family: var(--font-heading);
  font-size: 1.55rem;
  font-weight: 800;
  color: var(--text-main);
  letter-spacing: -0.02em;
}

.sensor-hero-sub {
  font-size: 0.76rem;
  color: var(--text-muted);
}

.status-dot.sleeping {
  background: #818cf8;
  box-shadow: 0 0 10px #818cf8;
}

/* BATTERY REMAINING & RUNTIME ESTIMATOR BOX */
.sensor-battery-box {
  background: rgba(255, 255, 255, 0.025);
  border: 1px solid var(--card-border);
  border-radius: 18px;
  padding: 15px 18px;
  margin-top: 12px;
}

.sensor-battery-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

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

.sensor-battery-icon {
  font-size: 1.45rem;
  line-height: 1;
}

.sensor-battery-title-row {
  display: flex;
  align-items: baseline;
  gap: 10px;
}

.sensor-battery-title {
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--text-main);
}

.sensor-battery-pct {
  font-family: var(--font-heading);
  font-size: 1.15rem;
  font-weight: 800;
  color: var(--emerald);
}

.sensor-battery-sub {
  font-size: 0.78rem;
  color: var(--text-muted);
  display: block;
  margin-top: 2px;
}

.sensor-battery-reset-btn {
  background: rgba(16, 185, 129, 0.12);
  border: 1px solid rgba(16, 185, 129, 0.35);
  color: #a7f3d0;
  border-radius: 11px;
  padding: 7px 12px;
  font-size: 0.78rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
}

.sensor-battery-reset-btn:hover {
  background: rgba(16, 185, 129, 0.22);
  border-color: var(--emerald);
  color: #fff;
}

.sensor-battery-meta {
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* CLIMATE HISTORY GRAPH CARD */
.sensor-chart-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 14px;
}

.sensor-chart-controls {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.sensor-metric-tabs {
  display: flex;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--card-border);
  border-radius: 12px;
  padding: 3px;
  gap: 4px;
}

.chart-metric-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  padding: 6px 12px;
  border-radius: 9px;
  font-size: 0.8rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s ease;
}

.chart-metric-btn:hover {
  color: var(--text-main);
}

.chart-metric-btn.active {
  background: rgba(255, 255, 255, 0.09);
  color: var(--text-main);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
}

.sensor-range-pills {
  display: flex;
  gap: 4px;
}

.chart-range-btn {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--card-border);
  color: var(--text-muted);
  border-radius: 9px;
  padding: 5px 10px;
  font-size: 0.76rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.18s ease;
}

.chart-range-btn:hover {
  color: var(--text-main);
}

.chart-range-btn.active {
  background: rgba(56, 189, 248, 0.16);
  border-color: #38bdf8;
  color: #bae6fd;
}

.sensor-chart-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin-bottom: 14px;
}

.chart-stat-pill {
  background: rgba(255, 255, 255, 0.025);
  border: 1px solid var(--card-border);
  border-radius: 12px;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.chart-stat-label {
  font-size: 0.72rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.chart-stat-val {
  font-family: var(--font-heading);
  font-size: 1.05rem;
  font-weight: 800;
  color: var(--text-main);
}

.sensor-chart-container {
  position: relative;
  background: rgba(0, 0, 0, 0.22);
  border: 1px solid var(--card-border);
  border-radius: 16px;
  padding: 14px 12px 10px 12px;
}

.sensor-chart-svg {
  width: 100%;
  height: 210px;
  display: block;
  overflow: visible;
  cursor: crosshair;
}

.sensor-chart-xaxis {
  display: flex;
  justify-content: space-between;
  margin-top: 6px;
  padding: 0 6px;
  font-size: 0.72rem;
  color: var(--text-muted);
}

.sensor-chart-tooltip {
  position: absolute;
  top: 10px;
  right: 12px;
  background: rgba(15, 16, 24, 0.92);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 10px;
  padding: 6px 11px;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-main);
  pointer-events: none;
  z-index: 5;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.4);
}

@media (max-width: 600px) {
  body {
    padding: 16px;
  }
  .device-tabs {
    grid-template-columns: 1fr;
  }
  .sensor-hero-grid {
    grid-template-columns: 1fr;
  }
  .sensor-chart-stats {
    grid-template-columns: repeat(2, 1fr);
  }
  .controls-grid {
    grid-template-columns: 1fr;
  }
  .btn-clean, .btn-spot {
    grid-column: span 1;
  }
  .telemetry-grid {
    grid-template-columns: 1fr;
  }
  .secondary-controls-grid {
    grid-template-columns: 1fr;
  }
  .fan-presets-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}
