/* ============================================================
   SMARTLIGHT IoT — Main Stylesheet
   Tema: Industrial-Tech Dark
   Font: Syne (display) + Outfit (body)
   ============================================================ */

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

/* ============================================================
   CSS CUSTOM PROPERTIES
   ============================================================ */
:root {
  /* Core palette */
  --bg-base:      #080c14;
  --bg-surface:   #0d1424;
  --bg-card:      #111d32;
  --bg-card-alt:  #0f1a2e;
  --bg-inset:     #0a1020;

  /* Borders */
  --border-dim:   #1e2e48;
  --border-mid:   #263650;
  --border-bright:#334d70;

  /* Accent — Amber/Gold */
  --amber:        #f5a623;
  --amber-dark:   #c47d10;
  --amber-glow:   rgba(245, 166, 35, 0.18);
  --amber-subtle: rgba(245, 166, 35, 0.07);

  /* Accent 2 — Cyan */
  --cyan:         #38bdf8;
  --cyan-dark:    #0ea5e9;
  --cyan-glow:    rgba(56, 189, 248, 0.15);
  --cyan-subtle:  rgba(56, 189, 248, 0.06);

  /* Semantic colors */
  --green:        #34d399;
  --green-glow:   rgba(52, 211, 153, 0.15);
  --green-subtle: rgba(52, 211, 153, 0.08);
  --red:          #f87171;
  --red-glow:     rgba(248, 113, 113, 0.15);
  --red-subtle:   rgba(248, 113, 113, 0.07);
  --orange:       #fb923c;

  /* Typography */
  --text-primary:  #dde6f5;
  --text-secondary:#8ba3c7;
  --text-muted:    #4d6484;
  --text-faint:    #2d4060;

  /* Shadows */
  --shadow-sm:  0 2px 8px rgba(0,0,0,0.4);
  --shadow-md:  0 8px 24px rgba(0,0,0,0.5);
  --shadow-lg:  0 20px 60px rgba(0,0,0,0.6);
  --shadow-amber: 0 0 40px rgba(245,166,35,0.25);
  --shadow-cyan:  0 0 40px rgba(56,189,248,0.2);

  /* Spacing */
  --radius-sm:  8px;
  --radius-md:  12px;
  --radius-lg:  16px;
  --radius-xl:  20px;

  /* Transitions */
  --ease-out:   cubic-bezier(0.16, 1, 0.3, 1);
  --ease-in:    cubic-bezier(0.4, 0, 1, 1);
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
}

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

html {
  scroll-behavior: smooth;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: 'Outfit', sans-serif;
  background-color: var(--bg-base);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
  overflow-x: hidden;
}

a { text-decoration: none; color: inherit; }
button { font-family: inherit; cursor: pointer; }
input { font-family: inherit; }

/* ============================================================
   GLOBAL BACKGROUND TEXTURE
   ============================================================ */
.bg-texture {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
}

/* Animated dot grid */
.bg-texture::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image: radial-gradient(circle, rgba(56,189,248,0.06) 1px, transparent 1px);
  background-size: 32px 32px;
  animation: gridDrift 25s linear infinite;
}

/* Diagonal scan line */
.bg-texture::after {
  content: '';
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(
    -45deg,
    transparent,
    transparent 2px,
    rgba(56,189,248,0.015) 2px,
    rgba(56,189,248,0.015) 4px
  );
}

@keyframes gridDrift {
  from { transform: translateY(0); }
  to   { transform: translateY(32px); }
}

/* Ambient glow blobs */
.glow-orb {
  position: fixed;
  border-radius: 50%;
  filter: blur(100px);
  pointer-events: none;
  z-index: 0;
  will-change: transform, opacity;
}

.glow-orb-1 {
  width: 600px; height: 600px;
  top: -200px; right: -150px;
  background: radial-gradient(circle, rgba(245,166,35,0.08) 0%, transparent 70%);
  animation: orbFloat 12s ease-in-out infinite;
}

.glow-orb-2 {
  width: 500px; height: 500px;
  bottom: -150px; left: -150px;
  background: radial-gradient(circle, rgba(56,189,248,0.07) 0%, transparent 70%);
  animation: orbFloat 15s ease-in-out infinite reverse;
  animation-delay: -5s;
}

.glow-orb-3 {
  width: 300px; height: 300px;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  background: radial-gradient(circle, rgba(56,189,248,0.04) 0%, transparent 70%);
  animation: orbPulse 8s ease-in-out infinite;
}

@keyframes orbFloat {
  0%, 100% { transform: translateY(0) scale(1); opacity: 0.6; }
  33%       { transform: translateY(-30px) scale(1.05); opacity: 1; }
  66%       { transform: translateY(20px) scale(0.97); opacity: 0.7; }
}

@keyframes orbPulse {
  0%, 100% { opacity: 0.4; transform: translate(-50%, -50%) scale(1); }
  50%       { opacity: 0.8; transform: translate(-50%, -50%) scale(1.2); }
}

/* ============================================================
   TYPOGRAPHY HELPERS
   ============================================================ */
.font-display { font-family: 'Syne', sans-serif; }
.font-mono    { font-family: 'JetBrains Mono', monospace; }

.text-amber   { color: var(--amber); }
.text-cyan    { color: var(--cyan); }
.text-green   { color: var(--green); }
.text-red     { color: var(--red); }
.text-muted   { color: var(--text-muted); }

/* ============================================================
   ===  PAGE: LOGIN  ===
   ============================================================ */
.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 24px;
}

/* Brand header above the card */
.login-brand {
  text-align: center;
  margin-bottom: 36px;
  animation: revealUp 0.7s var(--ease-out) both;
}

.login-brand-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 72px; height: 72px;
  border-radius: var(--radius-lg);
  background: linear-gradient(135deg, var(--amber) 0%, var(--amber-dark) 100%);
  box-shadow: var(--shadow-amber), inset 0 1px 0 rgba(255,255,255,0.2);
  margin-bottom: 20px;
  position: relative;
  overflow: hidden;
}

.login-brand-mark::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(255,255,255,0.15), transparent);
}

.login-brand-mark svg,
.login-brand-mark .icon-inner {
  font-size: 32px;
  position: relative;
  z-index: 1;
}

.login-brand h1 {
  font-family: 'Syne', sans-serif;
  font-size: 1.9rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  color: var(--text-primary);
  line-height: 1.1;
}

.login-brand h1 .highlight {
  color: var(--amber);
}

.login-brand .tagline {
  margin-top: 8px;
  font-size: 0.82rem;
  font-weight: 300;
  color: var(--text-muted);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

/* Login card wrapper */
.login-wrapper {
  position: relative;
  z-index: 10;
  width: 100%;
  max-width: 440px;
}

/* Card */
.login-card {
  background: var(--bg-card);
  border: 1px solid var(--border-mid);
  border-radius: var(--radius-xl);
  padding: 40px 36px;
  box-shadow: var(--shadow-lg),
              inset 0 1px 0 rgba(255,255,255,0.04);
  position: relative;
  overflow: hidden;
  animation: revealUp 0.7s var(--ease-out) 0.1s both;
}

/* Subtle corner accent */
.login-card::before {
  content: '';
  position: absolute;
  top: 0; right: 0;
  width: 120px; height: 120px;
  background: conic-gradient(from 180deg at 100% 0%, var(--amber-glow) 0%, transparent 60%);
  pointer-events: none;
}

/* Card heading */
.login-card-heading {
  font-family: 'Syne', sans-serif;
  font-size: 1.15rem;
  font-weight: 700;
  margin-bottom: 6px;
  color: var(--text-primary);
}

.login-card-sub {
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-bottom: 28px;
}

/* Error alert */
.alert-error {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  background: var(--red-subtle);
  border: 1px solid rgba(248,113,113,0.25);
  border-left: 3px solid var(--red);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  margin-bottom: 22px;
  font-size: 0.84rem;
  color: var(--red);
  animation: shakeX 0.4s var(--ease-out);
}

.alert-error-icon { font-size: 16px; flex-shrink: 0; margin-top: 1px; }

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

/* Form fields */
.form-group { margin-bottom: 20px; }

.form-label {
  display: block;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.68rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.input-shell {
  position: relative;
  display: flex;
  align-items: center;
}

.input-shell .field-icon {
  position: absolute;
  left: 14px;
  font-size: 16px;
  color: var(--text-muted);
  pointer-events: none;
  transition: color 0.2s;
  z-index: 1;
}

.form-input {
  width: 100%;
  background: var(--bg-inset);
  border: 1.5px solid var(--border-dim);
  border-radius: var(--radius-sm);
  padding: 13px 14px 13px 44px;
  font-size: 0.92rem;
  font-weight: 400;
  color: var(--text-primary);
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s, background 0.2s;
}

.form-input::placeholder {
  color: var(--text-faint);
  font-size: 0.88rem;
}

.form-input:hover {
  border-color: var(--border-bright);
  background: var(--bg-surface);
}

.form-input:focus {
  border-color: var(--amber);
  background: var(--bg-surface);
  box-shadow: 0 0 0 3px var(--amber-glow), var(--shadow-sm);
}

.form-input:focus ~ .field-icon,
.input-shell:focus-within .field-icon {
  color: var(--amber);
}

/* Submit button */
.btn-submit {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 14px 20px;
  background: linear-gradient(135deg, var(--amber) 0%, #e8940a 100%);
  color: #1a0e00;
  border: none;
  border-radius: var(--radius-sm);
  font-family: 'Syne', sans-serif;
  font-size: 0.9rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  cursor: pointer;
  transition: transform 0.2s var(--ease-spring), box-shadow 0.2s, filter 0.2s;
  box-shadow: 0 4px 16px rgba(245,166,35,0.3), inset 0 1px 0 rgba(255,255,255,0.2);
  margin-top: 4px;
  position: relative;
  overflow: hidden;
}

.btn-submit::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(255,255,255,0.15), transparent);
  pointer-events: none;
}

.btn-submit:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 28px rgba(245,166,35,0.45), inset 0 1px 0 rgba(255,255,255,0.2);
  filter: brightness(1.05);
}

.btn-submit:active {
  transform: translateY(0);
  box-shadow: 0 2px 8px rgba(245,166,35,0.3);
}

.btn-submit .arrow {
  transition: transform 0.2s var(--ease-spring);
}
.btn-submit:hover .arrow {
  transform: translateX(4px);
}

/* Divider */
.login-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 24px 0;
}

.login-divider::before,
.login-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border-dim);
}

.login-divider span {
  font-size: 0.72rem;
  color: var(--text-faint);
  font-family: 'JetBrains Mono', monospace;
  letter-spacing: 0.08em;
}

/* Demo credentials */
.demo-creds {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 14px;
  background: var(--cyan-subtle);
  border: 1px solid rgba(56,189,248,0.15);
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
  color: var(--text-muted);
}

.demo-creds code {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.78rem;
  color: var(--cyan);
  background: rgba(56,189,248,0.1);
  padding: 2px 7px;
  border-radius: 4px;
}

/* System status footer */
.login-footer {
  margin-top: 28px;
  text-align: center;
  font-size: 0.73rem;
  color: var(--text-muted);
  animation: revealUp 0.7s var(--ease-out) 0.3s both;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  background: var(--green-subtle);
  border: 1px solid rgba(52,211,153,0.2);
  border-radius: 20px;
  font-size: 0.72rem;
  color: var(--green);
  margin-bottom: 8px;
  font-family: 'JetBrains Mono', monospace;
}

.pulse-dot {
  width: 7px; height: 7px;
  background: var(--green);
  border-radius: 50%;
  animation: pulseDot 2s ease-in-out infinite;
}

@keyframes pulseDot {
  0%, 100% { opacity: 1; box-shadow: 0 0 0 0 rgba(52,211,153,0.4); }
  50%       { opacity: 0.7; box-shadow: 0 0 0 4px rgba(52,211,153,0); }
}

/* ============================================================
   ===  PAGE: DASHBOARD  ===
   ============================================================ */

/* -- Topbar/Header -- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 200;
  height: 62px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 28px;
  background: rgba(8, 12, 20, 0.85);
  backdrop-filter: blur(16px) saturate(160%);
  -webkit-backdrop-filter: blur(16px) saturate(160%);
  border-bottom: 1px solid var(--border-dim);
  box-shadow: 0 1px 0 rgba(255,255,255,0.03);
}

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

.topbar-logo {
  width: 38px; height: 38px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--amber) 0%, var(--amber-dark) 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  box-shadow: 0 0 16px rgba(245,166,35,0.35);
  flex-shrink: 0;
}

.topbar-title {
  font-family: 'Syne', sans-serif;
  font-size: 1.05rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1;
}

.topbar-title .accent { color: var(--amber); }

.topbar-subtitle {
  font-size: 0.65rem;
  color: var(--text-muted);
  font-family: 'JetBrains Mono', monospace;
  letter-spacing: 0.06em;
  margin-top: 2px;
}

/* Topbar center live indicator */
.topbar-center {
  display: flex;
  align-items: center;
  gap: 6px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.7rem;
  color: var(--green);
  padding: 5px 14px;
  background: var(--green-subtle);
  border: 1px solid rgba(52,211,153,0.18);
  border-radius: 20px;
}

/* Topbar right user info */
.topbar-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.topbar-user {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 14px;
  background: var(--bg-card);
  border: 1px solid var(--border-dim);
  border-radius: var(--radius-sm);
  font-size: 0.83rem;
  font-weight: 500;
}

.user-avatar {
  width: 26px; height: 26px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--cyan), var(--cyan-dark));
  display: flex; align-items: center; justify-content: center;
  font-size: 13px;
  font-weight: 700;
  color: #0a1428;
  font-family: 'Syne', sans-serif;
}

.btn-logout {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  background: transparent;
  border: 1px solid rgba(248,113,113,0.3);
  border-radius: var(--radius-sm);
  color: var(--red);
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  cursor: pointer;
  transition: all 0.2s;
  text-decoration: none;
}

.btn-logout:hover {
  background: var(--red-subtle);
  border-color: var(--red);
  transform: translateY(-1px);
}

/* -- Main content area -- */
.dashboard-main {
  position: relative;
  z-index: 1;
  max-width: 960px;
  margin: 0 auto;
  padding: 28px 24px 80px;
}

/* -- Section label -- */
.section-label {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}

.section-label-text {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.68rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--text-muted);
}

.section-label-icon {
  font-size: 14px;
}

.section-label-line {
  flex: 1;
  height: 1px;
  background: linear-gradient(to right, var(--border-mid), transparent);
}

/* -- Alert Banner -- */
.alert-banner {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  background: linear-gradient(135deg, rgba(248,113,113,0.08), rgba(248,113,113,0.04));
  border: 1px solid rgba(248,113,113,0.3);
  border-left: 3px solid var(--red);
  border-radius: var(--radius-md);
  padding: 16px 18px;
  margin-bottom: 24px;
  animation: slideDownFade 0.3s var(--ease-out);
}

.alert-banner.hidden { display: none; }

.alert-banner-icon {
  font-size: 20px;
  flex-shrink: 0;
  margin-top: 1px;
}

.alert-banner-body { flex: 1; }

.alert-banner-title {
  font-family: 'Syne', sans-serif;
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--red);
  margin-bottom: 3px;
}

.alert-banner-text {
  font-size: 0.82rem;
  color: var(--text-secondary);
}

.alert-banner-close {
  cursor: pointer;
  color: var(--text-muted);
  font-size: 18px;
  line-height: 1;
  transition: color 0.2s;
  background: none;
  border: none;
  padding: 0;
}

.alert-banner-close:hover { color: var(--red); }

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

/* -- KPI Stats Row -- */
.stats-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 28px;
}

.stat-tile {
  background: var(--bg-card);
  border: 1px solid var(--border-dim);
  border-radius: var(--radius-md);
  padding: 16px 18px;
  display: flex;
  align-items: center;
  gap: 14px;
  position: relative;
  overflow: hidden;
  transition: border-color 0.2s, transform 0.2s;
  animation: revealUp 0.5s var(--ease-out) both;
}

.stat-tile:nth-child(1) { animation-delay: 0.05s; }
.stat-tile:nth-child(2) { animation-delay: 0.10s; }
.stat-tile:nth-child(3) { animation-delay: 0.15s; }
.stat-tile:nth-child(4) { animation-delay: 0.20s; }

.stat-tile:hover {
  border-color: var(--border-bright);
  transform: translateY(-2px);
}

.stat-tile-icon {
  width: 42px; height: 42px;
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 19px;
  flex-shrink: 0;
}

.icon-amber { background: var(--amber-subtle); border: 1px solid rgba(245,166,35,0.2); }
.icon-cyan  { background: var(--cyan-subtle);  border: 1px solid rgba(56,189,248,0.2); }
.icon-green { background: var(--green-subtle); border: 1px solid rgba(52,211,153,0.2); }
.icon-red   { background: var(--red-subtle);   border: 1px solid rgba(248,113,113,0.2); }

.stat-tile-info { flex: 1; min-width: 0; }

.stat-tile-label {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.63rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  display: block;
  margin-bottom: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.stat-tile-value {
  font-family: 'Syne', sans-serif;
  font-size: 1.25rem;
  font-weight: 800;
  line-height: 1;
  letter-spacing: -0.02em;
}

.val-amber  { color: var(--amber); }
.val-cyan   { color: var(--cyan); }
.val-green  { color: var(--green); }
.val-red    { color: var(--red); }

/* Corner accent on stat tiles */
.stat-tile::after {
  content: '';
  position: absolute;
  bottom: 0; right: 0;
  width: 40px; height: 40px;
  border-radius: var(--radius-md) 0 var(--radius-md) 0;
  opacity: 0.4;
}

/* -- Monitoring Cards -- */
.monitoring-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px;
  margin-bottom: 28px;
}

.lamp-card {
  background: var(--bg-card);
  border: 1px solid var(--border-dim);
  border-radius: var(--radius-lg);
  padding: 20px;
  position: relative;
  overflow: hidden;
  transition: border-color 0.3s, box-shadow 0.3s, transform 0.2s;
  animation: revealUp 0.5s var(--ease-out) both;
}

.lamp-card:nth-child(1) { animation-delay: 0.1s; }
.lamp-card:nth-child(2) { animation-delay: 0.15s; }
.lamp-card:nth-child(3) { animation-delay: 0.2s; }
.lamp-card:nth-child(4) { animation-delay: 0.25s; }

.lamp-card:hover { transform: translateY(-2px); }

/* Card state variants */
.lamp-card.state-on {
  border-color: rgba(245,166,35,0.35);
  box-shadow: 0 0 0 1px rgba(245,166,35,0.06) inset, 0 8px 30px rgba(245,166,35,0.06);
}

.lamp-card.state-off {
  border-color: var(--border-dim);
}

.lamp-card.state-error {
  border-color: rgba(248,113,113,0.45);
  box-shadow: 0 0 0 1px rgba(248,113,113,0.06) inset, 0 8px 30px rgba(248,113,113,0.08);
  animation: errorPulse 2.5s ease-in-out infinite;
}

@keyframes errorPulse {
  0%, 100% { box-shadow: 0 0 0 1px rgba(248,113,113,0.06) inset, 0 8px 30px rgba(248,113,113,0.08); }
  50%       { box-shadow: 0 0 0 1px rgba(248,113,113,0.1) inset, 0 8px 40px rgba(248,113,113,0.18); }
}

/* Top-right decorative corner glow */
.lamp-card::before {
  content: '';
  position: absolute;
  top: -20px; right: -20px;
  width: 80px; height: 80px;
  border-radius: 50%;
  pointer-events: none;
  transition: opacity 0.4s;
  opacity: 0;
}

.lamp-card.state-on::before  { background: radial-gradient(circle, rgba(245,166,35,0.2), transparent 70%); opacity: 1; }
.lamp-card.state-error::before { background: radial-gradient(circle, rgba(248,113,113,0.2), transparent 70%); opacity: 1; }

/* Lamp card header */
.lamp-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.lamp-card-name {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: 'Syne', sans-serif;
  font-size: 0.98rem;
  font-weight: 700;
}

.lamp-bulb {
  font-size: 22px;
  transition: filter 0.3s;
  line-height: 1;
}

.state-on  .lamp-bulb { filter: drop-shadow(0 0 8px rgba(245,166,35,0.9)); }
.state-off .lamp-bulb { filter: grayscale(1) opacity(0.5); }

/* Status badge */
.chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border-radius: 20px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.06em;
}

.chip-on {
  background: var(--green-subtle);
  color: var(--green);
  border: 1px solid rgba(52,211,153,0.3);
}

.chip-off {
  background: rgba(77,100,132,0.15);
  color: var(--text-muted);
  border: 1px solid var(--border-dim);
}

.chip-error {
  background: var(--red-subtle);
  color: var(--red);
  border: 1px solid rgba(248,113,113,0.35);
}

.chip-dot {
  width: 5px; height: 5px;
  border-radius: 50%;
  background: currentColor;
  animation: pulseDot 1.5s ease-in-out infinite;
}

/* Lamp stats row */
.lamp-stats {
  display: flex;
  gap: 0;
  margin-bottom: 14px;
}

.lamp-stat-item {
  flex: 1;
  padding: 10px 12px;
  background: var(--bg-inset);
  border: 1px solid var(--border-dim);
}

.lamp-stat-item:first-child {
  border-radius: var(--radius-sm) 0 0 var(--radius-sm);
  border-right: none;
}

.lamp-stat-item:last-child {
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}

.lamp-stat-label {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.6rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  display: block;
  margin-bottom: 3px;
}

.lamp-stat-value {
  font-family: 'Syne', sans-serif;
  font-size: 0.96rem;
  font-weight: 700;
}

.lamp-stat-value.green { color: var(--green); }
.lamp-stat-value.red   { color: var(--red); }
.lamp-stat-value.cyan  { color: var(--cyan); }
.lamp-stat-value.dim   { color: var(--text-muted); }

/* Current bar */
.current-track {
  height: 5px;
  background: var(--bg-inset);
  border-radius: 3px;
  overflow: hidden;
  border: 1px solid var(--border-dim);
}

.current-fill {
  height: 100%;
  border-radius: 3px;
  transition: width 0.6s var(--ease-out);
  position: relative;
}

.state-on  .current-fill { background: linear-gradient(90deg, var(--cyan-dark), var(--amber)); }
.state-off .current-fill { background: var(--border-mid); width: 0 !important; }
.state-error .current-fill { background: var(--red); width: 5% !important; }

.current-fill::after {
  content: '';
  position: absolute;
  top: 0; right: 0; bottom: 0;
  width: 20px;
  background: linear-gradient(to right, transparent, rgba(255,255,255,0.3));
}

/* -- Mode Panel -- */
.mode-panel {
  background: var(--bg-card);
  border: 1px solid var(--border-dim);
  border-radius: var(--radius-lg);
  padding: 22px 24px;
  margin-bottom: 28px;
  animation: revealUp 0.5s var(--ease-out) 0.2s both;
}

.mode-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
}

.mode-panel-title {
  font-family: 'Syne', sans-serif;
  font-size: 0.95rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Mode toggle buttons */
.mode-toggle-group {
  display: flex;
  gap: 10px;
  margin-bottom: 18px;
}

.mode-btn {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 20px;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--border-mid);
  background: var(--bg-inset);
  color: var(--text-muted);
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  cursor: pointer;
  transition: all 0.25s var(--ease-out);
}

.mode-btn:hover {
  border-color: var(--border-bright);
  color: var(--text-primary);
  transform: translateY(-1px);
}

.mode-btn.is-active-auto {
  background: var(--cyan-subtle);
  border-color: var(--cyan);
  color: var(--cyan);
  box-shadow: 0 0 16px rgba(56,189,248,0.12), inset 0 1px 0 rgba(56,189,248,0.1);
}

.mode-btn.is-active-manual {
  background: var(--amber-subtle);
  border-color: var(--amber);
  color: var(--amber);
  box-shadow: 0 0 16px rgba(245,166,35,0.12), inset 0 1px 0 rgba(245,166,35,0.1);
}

/* LDR info bar */
.ldr-bar {
  display: flex;
  align-items: center;
  gap: 0;
  background: var(--bg-inset);
  border: 1px solid var(--border-dim);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.ldr-item {
  flex: 1;
  padding: 12px 16px;
  border-right: 1px solid var(--border-dim);
  text-align: center;
}

.ldr-item:last-child { border-right: none; }

.ldr-label {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.6rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  display: block;
  margin-bottom: 4px;
}

.ldr-value {
  font-family: 'Syne', sans-serif;
  font-size: 1.02rem;
  font-weight: 700;
  color: var(--cyan);
}

/* -- Control Cards -- */
.control-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px;
  margin-bottom: 16px;
}

.control-card {
  background: var(--bg-card);
  border: 1px solid var(--border-dim);
  border-radius: var(--radius-md);
  padding: 16px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  transition: border-color 0.2s, transform 0.2s;
  animation: revealUp 0.5s var(--ease-out) both;
}

.control-card:nth-child(1) { animation-delay: 0.25s; }
.control-card:nth-child(2) { animation-delay: 0.30s; }
.control-card:nth-child(3) { animation-delay: 0.35s; }
.control-card:nth-child(4) { animation-delay: 0.40s; }

.control-card:hover { border-color: var(--border-bright); transform: translateY(-1px); }

.control-card-name {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 500;
  font-size: 0.9rem;
}

/* LED indicator */
.led-dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
  transition: all 0.3s;
}

.led-on {
  background: var(--green);
  box-shadow: 0 0 0 2px rgba(52,211,153,0.2), 0 0 10px var(--green);
}

.led-off {
  background: var(--text-faint);
  box-shadow: none;
}

/* ON/OFF button pair */
.btn-pair {
  display: flex;
  gap: 6px;
}

.btn-ctrl {
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  border: 1.5px solid transparent;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  cursor: pointer;
  transition: all 0.18s var(--ease-spring);
}

.btn-ctrl-on {
  background: var(--green-subtle);
  border-color: rgba(52,211,153,0.35);
  color: var(--green);
}

.btn-ctrl-on:hover,
.btn-ctrl-on.is-active {
  background: var(--green);
  border-color: var(--green);
  color: #041a10;
  box-shadow: 0 4px 14px rgba(52,211,153,0.35);
  transform: scale(1.03);
}

.btn-ctrl-off {
  background: var(--red-subtle);
  border-color: rgba(248,113,113,0.3);
  color: var(--red);
}

.btn-ctrl-off:hover,
.btn-ctrl-off.is-active {
  background: var(--red);
  border-color: var(--red);
  color: #fff;
  box-shadow: 0 4px 14px rgba(248,113,113,0.35);
  transform: scale(1.03);
}

/* -- Global control bar -- */
.global-bar {
  background: var(--bg-card);
  border: 1px solid var(--border-dim);
  border-radius: var(--radius-md);
  padding: 18px 22px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  animation: revealUp 0.5s var(--ease-out) 0.45s both;
}

.global-bar-info { flex: 1; }

.global-bar-title {
  font-family: 'Syne', sans-serif;
  font-size: 0.9rem;
  font-weight: 700;
  margin-bottom: 2px;
}

.global-bar-sub {
  font-size: 0.78rem;
  color: var(--text-muted);
}

.global-bar-btns {
  display: flex;
  gap: 10px;
  flex-shrink: 0;
}

.btn-global {
  padding: 11px 26px;
  border-radius: var(--radius-sm);
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  cursor: pointer;
  transition: all 0.2s var(--ease-spring);
  border: 1.5px solid transparent;
}

.btn-global-on {
  background: linear-gradient(135deg, rgba(52,211,153,0.15), rgba(52,211,153,0.08));
  border-color: rgba(52,211,153,0.4);
  color: var(--green);
}

.btn-global-on:hover {
  background: var(--green);
  border-color: var(--green);
  color: #041a10;
  box-shadow: 0 6px 20px rgba(52,211,153,0.35);
  transform: translateY(-2px);
}

.btn-global-off {
  background: linear-gradient(135deg, rgba(248,113,113,0.12), rgba(248,113,113,0.06));
  border-color: rgba(248,113,113,0.35);
  color: var(--red);
}

.btn-global-off:hover {
  background: var(--red);
  border-color: var(--red);
  color: #fff;
  box-shadow: 0 6px 20px rgba(248,113,113,0.35);
  transform: translateY(-2px);
}

/* -- Demo toolbar -- */
.demo-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 24px;
  padding: 12px 16px;
  background: var(--bg-surface);
  border: 1px dashed var(--border-dim);
  border-radius: var(--radius-sm);
}

.demo-toolbar-label {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.67rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-faint);
}

.btn-demo {
  padding: 6px 14px;
  border-radius: 6px;
  border: 1px dashed var(--border-bright);
  background: transparent;
  color: var(--text-muted);
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.68rem;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-demo:hover {
  border-color: var(--amber);
  color: var(--amber);
  background: var(--amber-subtle);
}

/* -- Footer timestamp -- */
.dashboard-footer {
  text-align: center;
  margin-top: 28px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.67rem;
  color: var(--text-faint);
  letter-spacing: 0.06em;
}

.dashboard-footer span { color: var(--text-muted); }

/* ============================================================
   ANIMATIONS
   ============================================================ */
@keyframes revealUp {
  from { opacity: 0; transform: translateY(14px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

/* ============================================================
   SCROLLBAR
   ============================================================ */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg-base); }
::-webkit-scrollbar-thumb { background: var(--border-mid); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--border-bright); }

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 768px) {
  .topbar { padding: 0 16px; }
  .topbar-subtitle { display: none; }
  .topbar-center { display: none; }
  .dashboard-main { padding: 20px 16px 60px; }

  .stats-row {
    grid-template-columns: repeat(2, 1fr);
  }

  .monitoring-grid,
  .control-grid {
    grid-template-columns: 1fr;
  }

  .global-bar {
    flex-direction: column;
    align-items: stretch;
  }

  .global-bar-btns { justify-content: stretch; }
  .btn-global { flex: 1; text-align: center; }

  .mode-toggle-group { flex-direction: column; }

  .login-card { padding: 28px 22px; }
}

@media (max-width: 480px) {
  .stats-row { grid-template-columns: 1fr 1fr; }
  .topbar-user span { display: none; }
  .ldr-bar { flex-wrap: wrap; }
  .ldr-item { min-width: 50%; border-bottom: 1px solid var(--border-dim); }
  .ldr-item:nth-child(3) { border-right: none; }
}
