/* =======================================================
   EZVIZ CÁMARAS (+) DASHBOARD
   Design System: Glassmorphism, Neon Accents, Dark Theme
   ======================================================= */

:root {
  --bg-main: #0a0e17;
  --bg-surface: #0f172a;
  --bg-card: #131d31;
  --bg-card-hover: #192640;
  --bg-card-glass: rgba(19, 29, 49, 0.85);
  --bg-pill: rgba(255, 255, 255, 0.06);

  --border-color: rgba(255, 255, 255, 0.08);
  --border-subtle: rgba(255, 255, 255, 0.05);
  --border-active: rgba(59, 130, 246, 0.4);

  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;

  --primary: #3b82f6;
  --primary-hover: #2563eb;
  --primary-glow: rgba(59, 130, 246, 0.35);

  --success: #10b981;
  --success-glow: rgba(16, 185, 129, 0.35);

  --warning: #f59e0b;
  --warning-glow: rgba(245, 158, 11, 0.35);

  --danger: #ef4444;
  --danger-glow: rgba(239, 68, 68, 0.35);

  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --radius-pill: 9999px;

  --font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, 'Roboto Mono', Menlo, Monaco, Consolas, monospace;
}

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

body {
  font-family: var(--font-family);
  background-color: var(--bg-main);
  color: var(--text-primary);
  min-height: 100vh;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

.ambient-glow {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 400px;
  background: radial-gradient(circle at 50% -40px, rgba(59, 130, 246, 0.16), transparent 70%);
  pointer-events: none;
  z-index: 0;
}

.dashboard-container {
  position: relative;
  z-index: 1;
  max-width: 1600px;
  margin: 0 auto;
  padding: 16px 20px 60px;
}

/* --- HEADER --- */
.top-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 16px;
  padding: 14px 20px;
  background: var(--bg-card-glass);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  margin-bottom: 16px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.35);
}

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

.brand-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 46px;
  height: 46px;
  background: linear-gradient(135deg, #1e3a8a, #2563eb);
  border-radius: var(--radius-md);
  font-size: 24px;
  box-shadow: 0 4px 14px var(--primary-glow);
}

.header-title-box h1 {
  font-size: 1.3rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  background: linear-gradient(to right, #ffffff, #93c5fd);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

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

/* Header Center: Mode Segmented Toggle */
.header-center {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.monitoring-segmented-control {
  display: inline-flex;
  background: #090e1a;
  padding: 4px;
  border-radius: var(--radius-pill);
  border: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.5);
  position: relative;
}

.segment-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 16px;
  border-radius: var(--radius-pill);
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.22s cubic-bezier(0.16, 1, 0.3, 1);
  white-space: nowrap;
}

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

.segment-btn.active {
  background: linear-gradient(135deg, #2563eb, #1d4ed8);
  color: #fff;
  box-shadow: 0 3px 12px var(--primary-glow);
}

.segment-btn.active.continuous {
  background: linear-gradient(135deg, #059669, #047857);
  box-shadow: 0 3px 12px var(--success-glow);
}

.mode-status-note {
  font-size: 0.74rem;
  color: #38bdf8;
  font-family: var(--font-mono);
  font-weight: 500;
  text-align: center;
}

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

.clock-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
  font-size: 0.84rem;
  color: #38bdf8;
  font-weight: 600;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-size: 0.84rem;
  font-weight: 600;
  border: none;
  cursor: pointer;
  transition: all 0.2s ease;
  text-decoration: none;
}

.btn-primary {
  background: linear-gradient(135deg, #2563eb, #1d4ed8);
  color: #fff;
  box-shadow: 0 4px 14px var(--primary-glow);
}

.btn-primary:hover {
  background: linear-gradient(135deg, #3b82f6, #2563eb);
  transform: translateY(-1px);
}

.btn-secondary {
  background: var(--bg-pill);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
}

.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.15);
  transform: translateY(-1px);
}

.btn-nav-link {
  background: rgba(59, 130, 246, 0.12);
  color: #60a5fa;
  border: 1px solid rgba(59, 130, 246, 0.25);
}

.btn-nav-link:hover {
  background: rgba(59, 130, 246, 0.22);
  color: #93c5fd;
}

/* --- MAIN TABS (CÁMARAS / CONFIGURACIÓN) --- */
.view-tabs-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 20px;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 12px;
}

.view-tab-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 20px;
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-secondary);
  font-size: 0.9rem;
  font-weight: 600;
  border-radius: var(--radius-pill);
  cursor: pointer;
  transition: all 0.2s ease;
}

.view-tab-btn:hover {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-primary);
}

.view-tab-btn.active {
  background: var(--bg-card);
  color: #fff;
  border-color: var(--primary);
  box-shadow: 0 2px 10px var(--primary-glow);
}

.view-tab-badge {
  background: rgba(59, 130, 246, 0.25);
  color: #93c5fd;
  padding: 2px 8px;
  border-radius: var(--radius-pill);
  font-size: 0.75rem;
  font-weight: 700;
}

.view-tab-badge.config-badge {
  background: rgba(16, 185, 129, 0.2);
  color: #34d399;
}

/* --- STATS GRID AS CLICKABLE FILTERS --- */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px;
  margin-bottom: 20px;
}

.stat-card {
  background: var(--bg-card-glass);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 14px 18px;
  display: flex;
  align-items: center;
  gap: 14px;
  box-shadow: 0 4px 14px rgba(0,0,0,0.25);
  cursor: pointer;
  text-align: left;
  font-family: inherit;
  color: inherit;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  position: relative;
  outline: none;
}

.stat-card:hover {
  transform: translateY(-2px);
  border-color: rgba(255, 255, 255, 0.2);
  background: var(--bg-card-hover);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
}

.stat-card.active {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.4), 0 8px 24px rgba(59, 130, 246, 0.2);
  background: rgba(25, 38, 64, 0.95);
}

.stat-card.active[data-filter="with-image"] {
  border-color: var(--success);
  box-shadow: 0 0 0 2px rgba(16, 185, 129, 0.4), 0 8px 24px rgba(16, 185, 129, 0.2);
}

.stat-card.active[data-filter="without-image"] {
  border-color: var(--danger);
  box-shadow: 0 0 0 2px rgba(239, 68, 68, 0.4), 0 8px 24px rgba(239, 68, 68, 0.2);
}

.stat-card.active[data-filter="encrypted"] {
  border-color: var(--warning);
  box-shadow: 0 0 0 2px rgba(245, 158, 11, 0.4), 0 8px 24px rgba(245, 158, 11, 0.2);
}

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

.stat-icon.total { background: rgba(59, 130, 246, 0.15); color: #60a5fa; }
.stat-icon.with-image { background: rgba(16, 185, 129, 0.15); color: #34d399; }
.stat-icon.without-image { background: rgba(239, 68, 68, 0.15); color: #f87171; }
.stat-icon.encrypted { background: rgba(245, 158, 11, 0.15); color: #fbbf24; }

.stat-info {
  display: flex;
  flex-direction: column;
  flex: 1;
}

.stat-value {
  font-size: 1.45rem;
  font-weight: 800;
  line-height: 1.2;
}

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

.stat-active-indicator {
  position: absolute;
  top: 10px;
  right: 12px;
  font-size: 0.65rem;
  font-weight: 800;
  letter-spacing: 0.05em;
  padding: 2px 7px;
  border-radius: var(--radius-pill);
  background: var(--primary);
  color: #fff;
  display: none;
}

.stat-card.active .stat-active-indicator {
  display: block;
}

.stat-card.active[data-filter="with-image"] .stat-active-indicator {
  background: var(--success);
}
.stat-card.active[data-filter="without-image"] .stat-active-indicator {
  background: var(--danger);
}
.stat-card.active[data-filter="encrypted"] .stat-active-indicator {
  background: var(--warning);
  color: #000;
}

/* --- TOOLBAR: SEARCH & SECONDARY FILTERS --- */
.toolbar-section {
  display: flex;
  flex-direction: column;
  gap: 14px;
  background: var(--bg-card-glass);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 14px 18px;
  margin-bottom: 24px;
}

.toolbar-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 14px;
}

.search-box {
  position: relative;
  flex: 1;
  min-width: 260px;
  max-width: 480px;
}

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

.search-input {
  width: 100%;
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  padding: 9px 36px 9px 38px;
  border-radius: var(--radius-sm);
  font-size: 0.88rem;
  outline: none;
  transition: border-color 0.2s;
}

.search-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 10px rgba(59, 130, 246, 0.25);
}

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

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

.sort-box {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.sort-select {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  font-size: 0.84rem;
  outline: none;
  cursor: pointer;
}

.filter-chips {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.chip-btn {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  padding: 6px 14px;
  border-radius: var(--radius-pill);
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.chip-btn:hover {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-primary);
}

.chip-btn.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
  box-shadow: 0 2px 10px var(--primary-glow);
}

.chip-badge {
  background: rgba(0, 0, 0, 0.3);
  padding: 1px 7px;
  border-radius: var(--radius-pill);
  font-size: 0.75rem;
}

/* --- CAMERAS GRID --- */
.cameras-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 20px;
}

@media (min-width: 1400px) {
  .cameras-grid {
    grid-template-columns: repeat(4, 1fr);
  }
}

@media (max-width: 768px) {
  .cameras-grid {
    grid-template-columns: 1fr;
  }
}

/* --- CAMERA CARD --- */
.cam-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3);
  position: relative;
}

.cam-card:hover {
  transform: translateY(-3px);
  border-color: rgba(59, 130, 246, 0.3);
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.45), 0 0 20px rgba(59, 130, 246, 0.1);
}

.cam-card.is-offline {
  border-color: rgba(239, 68, 68, 0.25);
}

.cam-card.is-offline:hover {
  border-color: rgba(239, 68, 68, 0.45);
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.45), 0 0 20px rgba(239, 68, 68, 0.12);
}

/* Card Header */
.cam-card-header {
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  background: rgba(15, 23, 42, 0.7);
  border-bottom: 1px solid var(--border-subtle);
}

.cam-meta-left {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.cam-number-badge {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 32px;
  height: 28px;
  padding: 0 6px;
  background: linear-gradient(135deg, #1e3a8a, #2563eb);
  color: #fff;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  font-weight: 800;
  border-radius: var(--radius-sm);
  box-shadow: 0 2px 6px rgba(37, 99, 235, 0.35);
}

.cam-card.is-offline .cam-number-badge {
  background: linear-gradient(135deg, #7f1d1d, #b91c1c);
  box-shadow: 0 2px 6px rgba(185, 28, 28, 0.35);
}

.cam-title-box {
  overflow: hidden;
}

.cam-name {
  font-size: 0.95rem;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--text-primary);
}

.cam-plus-tag {
  color: #38bdf8;
  font-weight: 800;
}

.cam-status-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: var(--radius-pill);
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  white-space: nowrap;
}

.cam-status-pill.online {
  background: rgba(16, 185, 129, 0.15);
  color: #34d399;
  border: 1px solid rgba(16, 185, 129, 0.3);
}

.cam-status-pill.offline {
  background: rgba(239, 68, 68, 0.15);
  color: #f87171;
  border: 1px solid rgba(239, 68, 68, 0.3);
}

.cam-status-pill.encrypted {
  background: rgba(245, 158, 11, 0.15);
  color: #fbbf24;
  border: 1px solid rgba(245, 158, 11, 0.3);
}

/* --- VIEWPORT: IMAGE OR COUNTER --- */
.cam-viewport {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  background: #090d16;
  overflow: hidden;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.cam-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.3s ease, filter 0.3s ease;
  display: block;
}

.cam-viewport:hover .cam-img {
  transform: scale(1.03);
}

/* Image Badges Overlay */
.viewport-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(to top, rgba(0,0,0,0.7) 0%, transparent 40%, transparent 70%, rgba(0,0,0,0.6) 100%);
  pointer-events: none;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 10px 12px;
}

.overlay-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

.overlay-bottom {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 8px;
}

.overlay-badge {
  background: rgba(10, 14, 23, 0.82);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid rgba(255, 255, 255, 0.12);
  padding: 3px 8px;
  border-radius: var(--radius-sm);
  font-size: 0.74rem;
  font-weight: 600;
  color: #f1f5f9;
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.overlay-badge.time {
  font-family: var(--font-mono);
  color: #38bdf8;
}

.overlay-badge.relative {
  color: #34d399;
}

.overlay-badge.event {
  background: rgba(245, 158, 11, 0.22);
  border-color: rgba(245, 158, 11, 0.4);
  color: #fef08a;
}

.overlay-badge.zoom-hint {
  opacity: 0.7;
  font-size: 0.8rem;
}

.cam-viewport:hover .overlay-badge.zoom-hint {
  opacity: 1;
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

/* --- OFFLINE / COUNTER VIEWPORT --- */
.offline-viewport {
  width: 100%;
  height: 100%;
  background: radial-gradient(circle at 50% 50%, #151a2d 0%, #070a12 100%);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 16px;
  text-align: center;
  position: relative;
  overflow: hidden;
}

.radar-sweep {
  position: absolute;
  width: 180px;
  height: 180px;
  border-radius: 50%;
  border: 1px dashed rgba(239, 68, 68, 0.25);
  animation: rotate-radar 6s linear infinite;
  pointer-events: none;
}

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

.offline-icon {
  font-size: 30px;
  margin-bottom: 6px;
  filter: drop-shadow(0 0 10px rgba(239, 68, 68, 0.4));
  z-index: 1;
}

.offline-title {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #f87171;
  margin-bottom: 6px;
  z-index: 1;
}

.offline-timer {
  font-family: var(--font-mono);
  font-size: 1.35rem;
  font-weight: 900;
  color: #ffffff;
  background: rgba(239, 68, 68, 0.15);
  border: 1px solid rgba(239, 68, 68, 0.4);
  padding: 6px 14px;
  border-radius: var(--radius-sm);
  margin-bottom: 8px;
  box-shadow: 0 0 18px rgba(239, 68, 68, 0.25);
  letter-spacing: 0.04em;
  z-index: 1;
  text-shadow: 0 0 12px rgba(239, 68, 68, 0.5);
}

.offline-since {
  font-size: 0.73rem;
  color: var(--text-secondary);
  z-index: 1;
  line-height: 1.3;
}

/* --- ENCRYPTED VIEWPORT OVERLAY --- */
.encrypted-card-banner {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: rgba(15, 23, 42, 0.92);
  backdrop-filter: blur(8px);
  padding: 8px 12px;
  border-top: 1px solid rgba(245, 158, 11, 0.3);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.encrypted-text {
  font-size: 0.75rem;
  color: #fbbf24;
  font-weight: 600;
}

.btn-unlock-small {
  background: rgba(245, 158, 11, 0.2);
  border: 1px solid rgba(245, 158, 11, 0.4);
  color: #fef08a;
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  font-size: 0.72rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-unlock-small:hover {
  background: #f59e0b;
  color: #000;
}

/* --- CARD FOOTER --- */
.cam-card-footer {
  padding: 10px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  background: rgba(15, 23, 42, 0.5);
  border-top: 1px solid var(--border-subtle);
  font-size: 0.78rem;
  color: var(--text-muted);
}

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

.card-btn {
  background: var(--bg-pill);
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  padding: 5px 10px;
  border-radius: var(--radius-sm);
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  transition: all 0.2s;
  text-decoration: none;
}

.card-btn:hover {
  background: rgba(255, 255, 255, 0.12);
  color: var(--text-primary);
  border-color: rgba(255, 255, 255, 0.2);
}

/* --- CONFIGURATION VIEW STYLES --- */
.config-container {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.config-card {
  background: var(--bg-card-glass);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
}

.config-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  border-bottom: 1px solid var(--border-subtle);
  padding-bottom: 14px;
  flex-wrap: wrap;
  gap: 12px;
}

.config-card-header h2 {
  font-size: 1.15rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 10px;
}

.config-card-header p {
  font-size: 0.82rem;
  color: var(--text-secondary);
  margin-top: 2px;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 18px;
  margin-bottom: 20px;
}

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

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

.form-control {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  outline: none;
  font-family: inherit;
}

.form-control:focus {
  border-color: var(--primary);
  box-shadow: 0 0 10px var(--primary-glow);
}

/* Days Selector */
.days-selector {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.day-btn {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-sm);
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.day-btn:hover {
  border-color: var(--primary-light);
  color: #fff;
}

.day-btn.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
  box-shadow: 0 2px 10px var(--primary-glow);
}

.quick-days-presets {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}

.quick-preset-btn {
  background: none;
  border: none;
  color: #38bdf8;
  font-size: 0.78rem;
  cursor: pointer;
  text-decoration: underline;
}

/* Cameras Selection Grid inside Config */
.camera-selection-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 16px;
  background: rgba(15, 23, 42, 0.6);
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
}

.camera-selection-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 12px;
  max-height: 480px;
  overflow-y: auto;
  padding-right: 6px;
}

.camera-select-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.18s ease;
  user-select: none;
}

.camera-select-item:hover {
  border-color: rgba(59, 130, 246, 0.4);
  background: rgba(25, 38, 64, 0.7);
}

.camera-select-item.selected {
  border-color: var(--primary);
  background: rgba(30, 58, 138, 0.25);
}

.camera-select-checkbox {
  width: 18px;
  height: 18px;
  accent-color: var(--primary);
  cursor: pointer;
}

.camera-select-meta {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.camera-select-name {
  font-size: 0.88rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.camera-select-status {
  font-size: 0.72rem;
  color: var(--text-muted);
}

/* Floating / Sticky Save Bar */
.config-save-bar {
  position: sticky;
  bottom: 20px;
  background: rgba(15, 23, 42, 0.95);
  backdrop-filter: blur(14px);
  border: 1px solid var(--border-active);
  border-radius: var(--radius-md);
  padding: 16px 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.6);
  z-index: 100;
}

/* Modals & Popups */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(5, 8, 15, 0.94);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  transition: all 0.25s ease;
  padding: 20px;
}

.modal-backdrop.open {
  opacity: 1;
  visibility: visible;
}

.lightbox-content {
  position: relative;
  max-width: 95vw;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.8);
}

.lightbox-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 20px;
  background: rgba(15, 23, 42, 0.8);
  border-bottom: 1px solid var(--border-color);
}

.lightbox-title-box h3 {
  font-size: 1.1rem;
  font-weight: 700;
}

.lightbox-title-box p {
  font-size: 0.82rem;
  color: var(--text-secondary);
}

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

.lightbox-img-wrapper {
  flex: 1;
  overflow: auto;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #000;
  max-height: calc(90vh - 120px);
}

.lightbox-img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  transition: transform 0.2s ease;
}

.btn-close-modal {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.1);
  border: none;
  color: #fff;
  font-size: 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
}

.btn-close-modal:hover {
  background: rgba(239, 68, 68, 0.8);
}

.code-modal-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 480px;
  padding: 24px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.8);
}

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

.code-modal-header h3 {
  font-size: 1.15rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
}

.code-modal-body {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

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

.code-input-box label {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.code-input {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  color: #fff;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 1.2rem;
  font-family: var(--font-mono);
  text-align: center;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  outline: none;
}

.code-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 12px var(--primary-glow);
}

.code-hint {
  font-size: 0.78rem;
  color: var(--text-muted);
  line-height: 1.4;
  background: rgba(255, 255, 255, 0.03);
  padding: 10px;
  border-radius: var(--radius-sm);
  border-left: 3px solid var(--warning);
}

.code-modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 18px;
}

/* Animations */
.spin {
  animation: spin-anim 1s linear infinite;
  display: inline-block;
}

@keyframes spin-anim {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

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

.toast {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  padding: 12px 18px;
  border-radius: var(--radius-md);
  font-size: 0.85rem;
  box-shadow: 0 10px 30px rgba(0,0,0,0.5);
  display: flex;
  align-items: center;
  gap: 10px;
  animation: toast-in 0.3s ease;
}

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

@keyframes toast-in {
  from { transform: translateY(20px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}
