:root {
  --bg-primary: #070a12;
  --bg-secondary: #0d1527;
  --bg-card: rgba(18, 28, 48, 0.55);
  --border-color: rgba(255, 255, 255, 0.08);
  --border-glow: rgba(56, 189, 248, 0.35);
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --text-dim: #64748b;
  --accent-color: #38bdf8;
  --accent-hover: #0284c7;
  --accent-glow: rgba(56, 189, 248, 0.25);
  --success-color: #10b981;
  --warning-color: #f59e0b;
  --danger-color: #ef4444;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 18px;
  --radius-pill: 9999px;
  --shadow-sm: 0 4px 14px rgba(0, 0, 0, 0.35);
  --shadow-lg: 0 16px 40px -4px rgba(0, 0, 0, 0.6);
  --shadow-glass: 0 12px 32px 0 rgba(0, 0, 0, 0.45);
  --glass-bg: rgba(10, 16, 28, 0.78);
  --glass-surface: rgba(15, 24, 44, 0.58);
  --glass-border: 1px solid rgba(255, 255, 255, 0.08);
  --glass-border-hover: 1px solid rgba(56, 189, 248, 0.35);
  --glass-highlight: inset 0 1px 0 0 rgba(255, 255, 255, 0.12);
  --glass-blur: blur(22px) saturate(190%);
  --sidebar-w-expanded: 260px;
  --sidebar-w-collapsed: 72px;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-tap-highlight-color: transparent;
}

body {
  background-color: var(--bg-primary);
  background-image: 
    radial-gradient(circle at 10% 10%, rgba(56, 189, 248, 0.07) 0%, transparent 40%),
    radial-gradient(circle at 90% 20%, rgba(99, 102, 241, 0.06) 0%, transparent 45%),
    radial-gradient(circle at 50% 85%, rgba(16, 185, 129, 0.04) 0%, transparent 50%);
  background-attachment: fixed;
  color: var(--text-main);
  height: 100vh;
  max-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ==========================================
   APP LAYOUT & LIQUID GLASS SIDEBAR
   ========================================== */
.app-layout {
  display: flex;
  min-height: 100vh;
  width: 100%;
  position: relative;
}

/* Backdrop escuro e translúcido para mobile */
.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 58;
  opacity: 0;
  transition: opacity 0.25s ease;
  pointer-events: none;
}

.sidebar-backdrop.active {
  display: block;
  opacity: 1;
  pointer-events: auto;
}

/* Sidebar Liquid Glass Retrátil */
.app-sidebar {
  width: var(--sidebar-w-expanded);
  background: var(--glass-bg);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border-right: var(--glass-border);
  box-shadow: 4px 0 30px rgba(0, 0, 0, 0.45), inset -1px 0 0 rgba(255, 255, 255, 0.04);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  z-index: 60;
  transition: width 0.28s cubic-bezier(0.2, 0.9, 0.3, 1), transform 0.28s cubic-bezier(0.2, 0.9, 0.3, 1);
  overflow: hidden;
  user-select: none;
}

.app-sidebar.collapsed {
  width: var(--sidebar-w-collapsed);
}

.sidebar-header {
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  flex-shrink: 0;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  cursor: pointer;
  min-width: 0;
  overflow: hidden;
}

.sidebar-logo-glow {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.sidebar-logo-glow::after {
  content: '';
  position: absolute;
  inset: -2px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(56, 189, 248, 0.45) 0%, transparent 70%);
  z-index: 0;
  opacity: 0.8;
}

.brand-logo-img-sidebar {
  width: 36px;
  height: 36px;
  object-fit: contain;
  border-radius: 50%;
  position: relative;
  z-index: 1;
  filter: drop-shadow(0 2px 8px rgba(0, 0, 0, 0.6));
}

.sidebar-brand-text {
  display: flex;
  flex-direction: column;
  white-space: nowrap;
  transition: opacity 0.2s ease;
}

.app-sidebar.collapsed .sidebar-brand-text {
  opacity: 0;
  pointer-events: none;
  width: 0;
}

.sidebar-brand-text .brand-name {
  font-size: 0.98rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--text-main);
}

.sidebar-brand-text .brand-badge-sub {
  font-size: 0.65rem;
  font-weight: 600;
  color: var(--accent-color);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

/* Botão de Recolher Sidebar */
.sidebar-collapse-btn {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: var(--text-muted);
  width: 30px;
  height: 30px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
  flex-shrink: 0;
}

.sidebar-collapse-btn:hover {
  background: rgba(56, 189, 248, 0.15);
  border-color: rgba(56, 189, 248, 0.35);
  color: var(--accent-color);
}

.sidebar-toggle-icon {
  transition: transform 0.28s cubic-bezier(0.2, 0.9, 0.3, 1);
}

.app-sidebar.collapsed .sidebar-toggle-icon {
  transform: rotate(180deg);
}

/* Links da Sidebar */
.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 0.85rem 0.65rem;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  -webkit-overflow-scrolling: touch;
}

.sidebar-section-label {
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--text-dim);
  padding: 0.6rem 0.65rem 0.25rem;
  white-space: nowrap;
  transition: opacity 0.2s ease;
}

.app-sidebar.collapsed .sidebar-section-label {
  opacity: 0;
  height: 0;
  padding: 0;
  margin: 0;
  overflow: hidden;
}

.sidebar-nav-item {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 0.85rem;
  padding: 0.65rem 0.75rem;
  border-radius: var(--radius-md);
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-muted);
  font-size: 0.86rem;
  font-weight: 600;
  cursor: pointer;
  text-align: left;
  transition: all 0.2s ease;
  position: relative;
  white-space: nowrap;
  overflow: hidden;
}

.sidebar-nav-item:hover {
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(255, 255, 255, 0.1);
  color: var(--text-main);
  transform: translateX(2px);
}

.app-sidebar.collapsed .sidebar-nav-item:hover {
  transform: none;
}

.sidebar-nav-item.active {
  background: linear-gradient(135deg, rgba(56, 189, 248, 0.16) 0%, rgba(14, 165, 233, 0.06) 100%);
  border: 1px solid rgba(56, 189, 248, 0.35);
  box-shadow: 0 4px 18px rgba(56, 189, 248, 0.18), inset 0 1px 0 rgba(255, 255, 255, 0.15);
  color: var(--accent-color);
}

.sidebar-item-icon {
  width: 22px;
  height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: transform 0.2s;
}

.sidebar-nav-item:hover .sidebar-item-icon {
  transform: scale(1.08);
}

.sidebar-item-label {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: opacity 0.2s ease;
}

.app-sidebar.collapsed .sidebar-item-label {
  opacity: 0;
  width: 0;
  pointer-events: none;
}

.sidebar-item-badge.dot-live {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background-color: var(--success-color);
  box-shadow: 0 0 8px var(--success-color);
  flex-shrink: 0;
}

.app-sidebar.collapsed .sidebar-item-badge.dot-live {
  position: absolute;
  top: 8px;
  right: 12px;
}

.app-sidebar.collapsed .badge-mini-dot {
  position: absolute;
  top: 6px;
  right: 8px;
}

/* Rodapé do Usuário na Sidebar */
.sidebar-footer {
  padding: 0.75rem 0.65rem;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-shrink: 0;
  background: rgba(0, 0, 0, 0.2);
}

.sidebar-user-pill {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.4rem 0.5rem;
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.07);
  cursor: pointer;
  min-width: 0;
  overflow: hidden;
  transition: all 0.2s ease;
}

.sidebar-user-pill:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(56, 189, 248, 0.3);
}

.user-avatar-badge {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: linear-gradient(135deg, #0284c7, #38bdf8);
  color: #fff;
  font-weight: 700;
  font-size: 0.85rem;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
}

.sidebar-user-meta {
  display: flex;
  flex-direction: column;
  min-width: 0;
  overflow: hidden;
  transition: opacity 0.2s;
}

.app-sidebar.collapsed .sidebar-user-meta {
  opacity: 0;
  width: 0;
  pointer-events: none;
}

.sidebar-user-name {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-user-status {
  font-size: 0.68rem;
  color: var(--success-color);
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.sidebar-logout-icon {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.25);
  color: var(--danger-color);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
  flex-shrink: 0;
}

.sidebar-logout-icon:hover {
  background: var(--danger-color);
  color: #fff;
}

/* ==========================================
   VIEWPORT PRINCIPAL & TOPBAR LIQUID GLASS
   ========================================== */
.app-main-viewport {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  margin-left: var(--sidebar-w-expanded);
  transition: margin-left 0.28s cubic-bezier(0.2, 0.9, 0.3, 1);
  height: 100vh;
  max-height: 100vh;
  overflow: hidden;
}

.app-sidebar.collapsed ~ .app-main-viewport {
  margin-left: var(--sidebar-w-collapsed);
}

.app-content-scroll {
  flex: 1;
  display: flex;
  flex-direction: column;
  height: calc(100vh - 64px);
  max-height: calc(100vh - 64px);
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
}

/* Topbar Liquid Glass */
.topbar-glass {
  height: 64px;
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(8, 12, 22, 0.74);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border-bottom: var(--glass-border);
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.08);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.25rem;
  padding-top: max(env(safe-area-inset-top, 0px), 0px);
  gap: 0.75rem;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.topbar-brand {
  display: none;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
}

.topbar-brand-title-box {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.topbar-brand-title {
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--text-main);
  white-space: nowrap;
}

.mobile-menu-toggle {
  display: none;
}

.topbar-status-group {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* Relógio Operacional NOC no Topbar */
.topbar-center {
  display: flex;
  align-items: center;
  justify-content: center;
}

.topbar-clock-card {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.35rem 0.85rem;
  border-radius: var(--radius-pill);
  background: rgba(15, 23, 42, 0.5);
  border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08);
  color: var(--text-muted);
  font-size: 0.8rem;
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}

.clock-live-indicator {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent-color);
  box-shadow: 0 0 8px var(--accent-color);
  animation: pulseDot 2s infinite ease-in-out;
}

.clock-time {
  font-weight: 700;
  color: var(--text-main);
  letter-spacing: 0.04em;
}

.clock-separator {
  color: var(--text-dim);
}

.clock-date {
  color: var(--text-muted);
}

/* Controles à Direita do Topbar */
.topbar-right {
  display: flex;
  align-items: center;
  gap: 0.65rem;
}

/* Grade de Câmeras em Vidro Líquido */
.grid-controls-glass {
  display: inline-flex;
  align-items: center;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-md);
  padding: 3px;
  gap: 2px;
}

.grid-glass-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  width: 32px;
  height: 30px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
}

.grid-glass-btn:hover {
  color: var(--text-main);
  background: rgba(255, 255, 255, 0.06);
}

.grid-glass-btn.active {
  background: rgba(56, 189, 248, 0.2);
  color: var(--accent-color);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.15);
}

/* Botão de Qualidade em Vidro Líquido */
.quality-glass-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.42rem 0.85rem;
  border-radius: var(--radius-pill);
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.09);
  color: var(--text-main);
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.quality-glass-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(56, 189, 248, 0.35);
  box-shadow: 0 0 16px rgba(56, 189, 248, 0.15);
}

.btn-icon-glass {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.09);
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  position: relative;
  transition: all 0.2s ease;
}

.btn-icon-glass:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(56, 189, 248, 0.35);
  color: var(--accent-color);
  transform: translateY(-1px);
}

/* Navbar com suporte total a Safe Area (iPhone Notch, Status Bar & Dynamic Island) */
.navbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: max(env(safe-area-inset-top, 0px), 0.75rem);
  padding-bottom: 0.75rem;
  padding-left: max(env(safe-area-inset-left, 0px), 1.25rem);
  padding-right: max(env(safe-area-inset-right, 0px), 1.25rem);
  background-color: var(--bg-secondary);
  border-bottom: 1px solid var(--border-color);
  position: sticky;
  top: 0;
  z-index: 50;
  gap: 1rem;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.brand-logo-img-nav {
  width: 38px;
  height: 38px;
  object-fit: contain;
  border-radius: 50%;
  filter: drop-shadow(0 2px 6px rgba(0, 0, 0, 0.6));
  flex-shrink: 0;
}

.brand-title-box {
  display: flex;
  align-items: center;
  gap: 0.45rem;
}

.brand-live-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: var(--success-color);
  box-shadow: 0 0 8px var(--success-color);
  animation: pulseDot 2s infinite ease-in-out;
  display: inline-block;
  flex-shrink: 0;
}

@keyframes pulseDot {
  0% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.35; transform: scale(0.8); }
  100% { opacity: 1; transform: scale(1); }
}

.brand-icon {
  width: 38px;
  height: 38px;
  background: linear-gradient(135deg, #0284c7, #38bdf8);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
}

.brand-title {
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.brand-subtitle {
  font-size: 0.75rem;
  color: var(--text-muted);
  display: block;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.35rem 0.75rem;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.badge-success {
  background-color: rgba(16, 185, 129, 0.15);
  color: var(--success-color);
  border: 1px solid rgba(16, 185, 129, 0.3);
}

.badge-warning {
  background-color: rgba(245, 158, 11, 0.15);
  color: var(--warning-color);
  border: 1px solid rgba(245, 158, 11, 0.3);
}

.badge-danger {
  background-color: rgba(239, 68, 68, 0.15);
  color: var(--danger-color);
  border: 1px solid rgba(239, 68, 68, 0.3);
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: currentColor;
  display: inline-block;
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.4; transform: scale(0.9); }
  100% { opacity: 1; transform: scale(1); }
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.9rem;
  border-radius: var(--radius-md);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: all 0.2s ease;
}

.btn-primary {
  background-color: var(--accent-color);
  color: #0f172a;
}
.btn-primary:hover {
  background-color: var(--accent-hover);
}

.btn-secondary {
  background-color: var(--bg-card);
  color: var(--text-main);
  border: 1px solid var(--border-color);
}
.btn-secondary:hover {
  background-color: var(--border-color);
}

.btn-icon {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  color: var(--text-muted);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all 0.2s ease;
}
.btn-icon:hover, .btn-icon.active {
  color: var(--accent-color);
  border-color: var(--accent-color);
}

.grid-controls {
  display: flex;
  gap: 0.25rem;
}

/* Main Content & Camera Grid */
.main-content {
  flex: 1;
  padding: 1rem;
  max-width: 1600px;
  margin: 0 auto;
  width: 100%;
}

.camera-grid {
  display: grid;
  gap: 1rem;
}

.grid-2 {
  grid-template-columns: repeat(auto-fit, minmax(420px, 1fr));
}

.grid-1 {
  grid-template-columns: 1fr;
  max-width: 900px;
  margin: 0 auto;
}

@media (max-width: 768px) {
  .camera-grid {
    gap: 0.5rem;
  }

  /* Mobile respeita a classe de grid selecionada (grid-1, grid-2, grid-3, grid-4, grid-6) */
  .camera-grid {
    gap: 0.45rem;
  }

  .camera-grid.grid-2 .camera-card {
    border-radius: 8px;
  }

  .camera-grid.grid-2 .camera-top-bar {
    padding: 0.3rem 0.45rem;
  }

  .camera-grid.grid-2 .camera-title {
    font-size: 0.72rem;
    max-width: 58%;
  }

  .camera-grid.grid-2 .camera-title svg {
    width: 12px;
    height: 12px;
  }

  .camera-grid.grid-2 .badge {
    padding: 0.15rem 0.35rem;
    font-size: 0.58rem;
  }

  .camera-grid.grid-2 .quality-badge {
    display: none;
  }

  .camera-grid.grid-2 .camera-overlay .overlay-btn {
    padding: 0.25rem 0.45rem;
    font-size: 0.65rem;
  }

  .camera-grid.grid-2 .camera-overlay .overlay-btn svg {
    width: 12px;
    height: 12px;
  }
}

/* Camera Card Liquid Glass */
.camera-card {
  background: rgba(14, 22, 38, 0.65);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-lg);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: 0 8px 24px -2px rgba(0, 0, 0, 0.45), inset 0 1px 0 rgba(255, 255, 255, 0.08);
  transition: transform 0.22s ease, border-color 0.22s ease, box-shadow 0.22s ease;
  position: relative;
}

.camera-card:hover {
  border-color: rgba(56, 189, 248, 0.45);
  box-shadow: 0 16px 36px -4px rgba(0, 0, 0, 0.6), 0 0 24px rgba(56, 189, 248, 0.18), inset 0 1px 0 rgba(255, 255, 255, 0.15);
  transform: translateY(-2px);
}

/* Camera Top Bar Overlay (Seamless, inside video) */
.camera-top-bar {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 4;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.45rem 0.75rem;
  background: linear-gradient(to bottom, rgba(0, 0, 0, 0.82) 0%, rgba(0, 0, 0, 0.4) 65%, transparent 100%);
  pointer-events: none;
}

.camera-top-bar .camera-title,
.camera-top-bar .camera-header-right {
  pointer-events: auto;
}

.camera-title {
  font-size: 0.85rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  color: #fff;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.9);
  max-width: 62%;
  overflow: hidden;
}

.cam-title-short {
  display: none;
}

.cam-title-full {
  display: inline-block;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cam-title-text {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.camera-header-right {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.cam-status-text {
  letter-spacing: 0.02em;
}

.camera-video-container {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  background-color: #000;
  overflow: hidden;
  cursor: pointer;
}

.camera-video-container img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* Otimização específica para WebKit/iOS: aceleração por hardware e retenção de VRAM contra flicker */
.camera-video-container img.stream-img-ios,
.fullscreen-video-wrapper img.stream-img-ios,
img.stream-img-ios,
#fullscreen-stream.stream-img-ios {
  -webkit-transform: translate3d(0, 0, 0);
  transform: translate3d(0, 0, 0);
  -webkit-backface-visibility: hidden;
  backface-visibility: hidden;
  -webkit-perspective: 1000;
  perspective: 1000;
  image-rendering: -webkit-optimize-contrast;
  -webkit-user-select: none;
  user-select: none;
}

.camera-overlay {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 0.5rem 0.75rem;
  background: linear-gradient(to top, rgba(0,0,0,0.85), transparent);
  display: flex;
  align-items: center;
  justify-content: space-between;
  opacity: 0;
  transition: opacity 0.2s ease;
}

.camera-video-container:hover .camera-overlay {
  opacity: 1;
}

.overlay-btn {
  background: rgba(15, 23, 42, 0.75);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: #fff;
  padding: 0.35rem 0.6rem;
  border-radius: 6px;
  font-size: 0.75rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  backdrop-filter: blur(4px);
}
.overlay-btn:hover {
  background: var(--accent-color);
  color: #0f172a;
}

/* Modals */
.modal {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.72);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 100;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.modal.active {
  display: flex;
}

.modal-content {
  background: rgba(13, 20, 36, 0.88);
  backdrop-filter: blur(28px) saturate(190%);
  -webkit-backdrop-filter: blur(28px) saturate(190%);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--radius-lg);
  max-width: 480px;
  width: 100%;
  padding: 1.5rem;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.75), inset 0 1px 0 rgba(255, 255, 255, 0.12);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.25rem;
}

.modal-header h2 {
  font-size: 1.15rem;
  font-weight: 700;
}

.modal-close {
  background: transparent;
  border: none;
  font-size: 1.5rem;
  color: var(--text-muted);
  cursor: pointer;
}

.form-group {
  margin-bottom: 1rem;
}

.form-group label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 0.4rem;
  color: var(--text-main);
}

.form-group input {
  width: 100%;
  padding: 0.6rem 0.75rem;
  background-color: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  color: #fff;
  font-size: 0.9rem;
}

.form-group input:focus {
  outline: none;
  border-color: var(--accent-color);
}

.form-group small {
  display: block;
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 0.3rem;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
  margin-top: 1.5rem;
}

/* Fullscreen Modal */
.fullscreen-modal .fullscreen-container {
  max-width: 1200px;
  width: 100%;
  background: var(--bg-secondary);
  border-radius: var(--radius-lg);
  overflow: hidden;
  border: 1px solid var(--border-color);
  position: relative;
  display: flex;
  flex-direction: column;
}

.fullscreen-title-box {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.fullscreen-title-box .status-dot {
  color: var(--success-color);
}

.fullscreen-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.65rem 1.15rem;
  border-bottom: 1px solid var(--border-color);
  background: var(--bg-secondary);
  z-index: 10;
}

.fullscreen-video-wrapper {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  background: #000;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  -webkit-transform: translate3d(0, 0, 0);
  transform: translate3d(0, 0, 0);
}

.fullscreen-video-wrapper img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  user-select: none;
}

/* Floating Toolbar inside Fullscreen Video */
.fullscreen-floating-toolbar {
  position: absolute;
  bottom: 1.25rem;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: rgba(15, 23, 42, 0.85);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  padding: 0.35rem 0.75rem;
  border-radius: 9999px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.7);
  z-index: 25;
}

.fs-float-btn {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: #f8fafc;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
}

.fs-float-btn:hover, .fs-float-btn:active {
  background: var(--accent-color);
  color: #0f172a;
  transform: scale(1.08);
}

#fs-floating-quality-badge {
  font-size: 0.72rem;
  font-weight: 800;
}

/* True Native Fullscreen Mode (100vw x 100vh) */
.fullscreen-container.is-native-fullscreen,
:fullscreen .fullscreen-container,
:-webkit-full-screen .fullscreen-container {
  max-width: 100vw !important;
  width: 100vw !important;
  height: 100vh !important;
  border-radius: 0 !important;
  border: none !important;
  background: #000 !important;
}

.fullscreen-container.is-native-fullscreen .fullscreen-video-wrapper,
:fullscreen .fullscreen-video-wrapper,
:-webkit-full-screen .fullscreen-video-wrapper {
  flex: 1;
  aspect-ratio: auto;
  height: 100%;
}

.fullscreen-container.is-native-fullscreen .fullscreen-video-wrapper img,
:fullscreen .fullscreen-video-wrapper img,
:-webkit-full-screen .fullscreen-video-wrapper img {
  object-fit: contain;
  width: 100%;
  height: 100%;
}

/* Login Screen */
.login-screen {
  position: fixed;
  inset: 0;
  background: radial-gradient(circle at 50% 20%, #1e293b 0%, #090d16 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  z-index: 1000;
}

.login-card {
  background: rgba(13, 20, 36, 0.84);
  backdrop-filter: blur(28px) saturate(190%);
  -webkit-backdrop-filter: blur(28px) saturate(190%);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: var(--radius-lg);
  padding: 2.5rem 2rem;
  max-width: 420px;
  width: 100%;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.75), inset 0 1px 0 rgba(255, 255, 255, 0.15);
  animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(-10px); }
  to { opacity: 1; transform: translateY(0); }
}

.login-header {
  text-align: center;
  margin-bottom: 2rem;
}

.brand-logo-wrapper.large {
  display: flex;
  justify-content: center;
  margin-bottom: 1rem;
}

.brand-logo-img {
  width: 88px;
  height: 88px;
  object-fit: contain;
  border-radius: 50%;
  filter: drop-shadow(0 6px 20px rgba(234, 179, 8, 0.4));
  animation: pulseLogo 3s infinite ease-in-out;
}

@keyframes pulseLogo {
  0%, 100% { transform: scale(1); filter: drop-shadow(0 6px 20px rgba(234, 179, 8, 0.4)); }
  50% { transform: scale(1.03); filter: drop-shadow(0 8px 25px rgba(234, 179, 8, 0.6)); }
}

.brand-icon.large {
  width: 60px;
  height: 60px;
  margin: 0 auto 1rem auto;
  border-radius: 14px;
}

.login-header h2 {
  font-size: 1.4rem;
  font-weight: 700;
}

.login-header p {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-top: 0.25rem;
}

.btn-block {
  width: 100%;
  justify-content: center;
  padding: 0.75rem;
  font-size: 1rem;
  margin-top: 1.25rem;
}

.login-error {
  background-color: rgba(239, 68, 68, 0.15);
  border: 1px solid rgba(239, 68, 68, 0.4);
  color: #fca5a5;
  padding: 0.6rem 0.8rem;
  border-radius: var(--radius-md);
  font-size: 0.85rem;
  margin-bottom: 1rem;
  text-align: center;
}

.login-options-row {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  margin-top: 0.25rem;
  margin-bottom: 1rem;
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-size: 0.85rem;
  color: var(--text-muted);
  cursor: pointer;
  user-select: none;
  transition: color 0.2s;
}

.checkbox-label input[type="checkbox"] {
  width: 17px;
  height: 17px;
  accent-color: var(--accent-color);
  cursor: pointer;
}

.checkbox-label:hover {
  color: var(--text-main);
}

/* Modal Large & Users Management */
.modal-large {
  max-width: 720px;
}

.user-create-box {
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1.2rem;
}

.user-create-box h3 {
  font-size: 0.95rem;
  margin-bottom: 0.8rem;
  color: var(--accent-color);
}

.form-row {
  display: flex;
  gap: 0.75rem;
  align-items: flex-end;
  flex-wrap: wrap;
}

.flex-1 {
  flex: 1;
  min-width: 140px;
}

.form-btn-align {
  margin-bottom: 1rem;
}

.form-select {
  width: 100%;
  padding: 0.6rem 0.75rem;
  background-color: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  color: #fff;
  font-size: 0.85rem;
}

.form-select:focus {
  outline: none;
  border-color: var(--accent-color);
}

.table-container {
  overflow-x: auto;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
}

.users-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 0.9rem;
}

.users-table th, .users-table td {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border-color);
}

.users-table th {
  background-color: var(--bg-card);
  color: var(--text-muted);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.users-table tr:last-child td {
  border-bottom: none;
}

.btn-sm {
  padding: 0.3rem 0.6rem;
  font-size: 0.75rem;
  border-radius: 6px;
}

.btn-danger {
  background-color: rgba(239, 68, 68, 0.15);
  color: var(--danger-color);
  border: 1px solid rgba(239, 68, 68, 0.3);
}

.btn-danger:hover {
  background-color: var(--danger-color);
  color: #fff;
}

/* Quality Toggles and Badges */
.quality-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  display: inline-block;
}

.quality-dot.sd {
  background-color: var(--accent-color);
}

.quality-dot.hd {
  background-color: #34d399;
  box-shadow: 0 0 8px #34d399;
}

.quality-badge {
  font-size: 0.65rem;
  font-weight: 700;
  padding: 0.15rem 0.4rem;
  border-radius: 4px;
  background-color: rgba(56, 189, 248, 0.15);
  color: var(--accent-color);
  border: 1px solid rgba(56, 189, 248, 0.3);
  letter-spacing: 0.05em;
}

/* Mini Dot Badge & Helpers */
.badge-mini-dot {
  background-color: var(--success-color);
  color: #0f172a;
  font-size: 0.7rem;
  font-weight: 700;
  padding: 0.1rem 0.4rem;
  border-radius: 9999px;
  margin-left: 0.3rem;
}

@media (max-width: 640px) {
  .hide-mobile {
    display: none;
  }
}

/* Chat Drawer */
.chat-drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: 400px;
  max-width: 100vw;
  background-color: var(--bg-secondary);
  border-left: 1px solid var(--border-color);
  z-index: 90;
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: -10px 0 25px rgba(0, 0, 0, 0.5);
}

.chat-drawer.active {
  transform: translateX(0);
}

.chat-header {
  padding-top: max(env(safe-area-inset-top, 0px), 1rem);
  padding-bottom: 1rem;
  padding-left: 1.25rem;
  padding-right: 1.25rem;
  background-color: rgba(15, 23, 42, 0.85);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.chat-notif-banner {
  background: rgba(56, 189, 248, 0.15);
  border-bottom: 1px solid rgba(56, 189, 248, 0.3);
  padding: 0.6rem 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  font-size: 0.8rem;
  color: #bae6fd;
}

.chat-notif-banner button {
  white-space: nowrap;
  padding: 0.25rem 0.65rem;
  font-size: 0.75rem;
}

.chat-header-info h3 {
  font-size: 1.05rem;
  font-weight: 700;
}

.chat-status-sub {
  font-size: 0.75rem;
  color: var(--success-color);
  display: flex;
  align-items: center;
  gap: 0.35rem;
  margin-top: 0.2rem;
}

.section-micro-title {
  display: block;
  font-size: 0.65rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin-bottom: 0.4rem;
  text-transform: uppercase;
}

/* Online Users Bar */
.online-users-section {
  padding: 0.75rem 1rem;
  background-color: rgba(24, 34, 52, 0.6);
  border-bottom: 1px solid var(--border-color);
}

.online-users-list {
  display: flex;
  gap: 0.5rem;
  overflow-x: auto;
  padding-bottom: 0.25rem;
}

.user-online-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.3rem 0.6rem;
  border-radius: 9999px;
  background-color: var(--bg-primary);
  border: 1px solid var(--border-color);
  font-size: 0.75rem;
  white-space: nowrap;
}

.user-online-pill .dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background-color: var(--success-color);
  box-shadow: 0 0 6px var(--success-color);
}

/* Quick Alerts Bar */
.quick-alerts-bar {
  padding: 0.6rem 1rem;
  border-bottom: 1px solid var(--border-color);
  background-color: rgba(17, 24, 39, 0.4);
}

.chips-wrap-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  padding: 0.35rem 0;
  width: 100%;
}

.chips-container {
  display: flex;
  gap: 0.4rem;
  overflow-x: auto;
  padding-bottom: 0.2rem;
}

.chip {
  padding: 0.35rem 0.65rem;
  border-radius: 8px;
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all 0.2s;
  flex: 1 1 auto;
  text-align: center;
}

.chip-alert {
  background: rgba(239, 68, 68, 0.2);
  color: #fca5a5;
  border-color: rgba(239, 68, 68, 0.4);
}
.chip-alert:hover {
  background: rgba(239, 68, 68, 0.35);
}

.chip-warning {
  background: rgba(245, 158, 11, 0.2);
  color: #fde68a;
  border-color: rgba(245, 158, 11, 0.4);
}

.chip-info {
  background: rgba(56, 189, 248, 0.2);
  color: #bae6fd;
  border-color: rgba(56, 189, 248, 0.4);
}

.chip-success {
  background: rgba(16, 185, 129, 0.2);
  color: #a7f3d0;
  border-color: rgba(16, 185, 129, 0.4);
}

/* Chat Messages Feed */
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
}

.chat-bubble {
  max-width: 82%;
  padding: 0.65rem 0.9rem;
  border-radius: 12px;
  font-size: 0.85rem;
  line-height: 1.35;
  position: relative;
  word-break: break-word;
}

.chat-bubble.mine {
  align-self: flex-end;
  background: linear-gradient(135deg, #0284c7, #0369a1);
  color: #fff;
  border-bottom-right-radius: 3px;
}

.chat-bubble.other {
  align-self: flex-start;
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  border-bottom-left-radius: 3px;
}

.chat-bubble.alert {
  max-width: 100%;
  align-self: stretch;
  background-color: rgba(239, 68, 68, 0.2);
  border: 1px solid rgba(239, 68, 68, 0.5);
  color: #fee2e2;
  font-weight: 600;
  border-radius: 8px;
  animation: pulseAlert 2s infinite;
}

@keyframes pulseAlert {
  0% { box-shadow: 0 0 0 rgba(239, 68, 68, 0.4); }
  50% { box-shadow: 0 0 10px rgba(239, 68, 68, 0.6); }
  100% { box-shadow: 0 0 0 rgba(239, 68, 68, 0.4); }
}

.bubble-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
  margin-bottom: 0.25rem;
  font-size: 0.7rem;
  opacity: 0.8;
}

.bubble-author {
  font-weight: 700;
}

.bubble-time {
  font-size: 0.68rem;
}

.btn-delete-msg {
  background: transparent;
  border: none;
  color: #fca5a5;
  cursor: pointer;
  padding: 1px 5px;
  font-size: 0.95rem;
  line-height: 1;
  border-radius: 4px;
  opacity: 0.7;
  transition: opacity 0.2s, background 0.2s;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-left: 0.4rem;
}

.btn-delete-msg:hover {
  opacity: 1;
  background: rgba(239, 68, 68, 0.35);
}

.chat-input-bar {
  padding: 0.75rem 1rem;
  background-color: rgba(15, 23, 42, 0.95);
  border-top: 1px solid var(--border-color);
  display: flex;
  gap: 0.5rem;
}

.chat-input-bar input {
  flex: 1;
  padding: 0.65rem 0.85rem;
  background-color: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  color: #fff;
  font-size: 0.85rem;
}

.chat-input-bar input:focus {
  outline: none;
  border-color: var(--accent-color);
}

/* Install Modal Tabs and Steps */
.install-tabs {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1.25rem;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 0.5rem;
}

.install-tab-btn {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.6rem 1rem;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  border-radius: var(--radius-md);
  transition: all 0.2s;
}

.install-tab-btn.active {
  background-color: var(--bg-card);
  color: var(--accent-color);
}

.guide-step {
  display: flex;
  gap: 1rem;
  margin-bottom: 1.25rem;
  align-items: flex-start;
}

.step-num {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--accent-color);
  color: #0f172a;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.step-desc {
  font-size: 0.9rem;
  line-height: 1.45;
}

.step-desc strong {
  display: block;
  margin-bottom: 0.25rem;
  color: #fff;
}

.step-desc p {
  color: var(--text-muted);
}

/* Security Overview Card */
.security-overview-card {
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1rem;
}

/* Modal Extra Large for Playback */
.modal-extra-large {
  max-width: 980px;
  width: 95vw;
  max-height: 90vh;
  overflow-y: auto;
}

/* Playback Filters Bar */
.playback-filters-box {
  display: flex;
  gap: 1rem;
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1rem 1.25rem;
  align-items: flex-end;
  flex-wrap: wrap;
  margin-bottom: 1.5rem;
}

.filter-field {
  flex: 1;
  min-width: 170px;
}

.filter-field label {
  display: block;
  font-size: 0.8rem;
  font-weight: 700;
  margin-bottom: 0.35rem;
  color: var(--text-main);
}

.form-input-date {
  width: 100%;
  padding: 0.6rem 0.75rem;
  background-color: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  color: #fff;
  font-size: 0.85rem;
}

.form-input-date:focus {
  outline: none;
  border-color: var(--accent-color);
}

.filter-btn-align {
  margin-bottom: 0.05rem;
}

/* 24-Hour Visual Timeline with Infinite Zoom */
.timeline-wrapper {
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1rem 1.25rem;
  margin-bottom: 1.5rem;
}

.timeline-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.85rem;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.timeline-header-left {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.timeline-title {
  font-size: 0.95rem;
  font-weight: 700;
}

.timeline-legend {
  display: flex;
  gap: 1rem;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.legend-color {
  width: 12px;
  height: 12px;
  border-radius: 3px;
  display: inline-block;
}

.legend-regular {
  background-color: #0284c7;
}

.legend-motion {
  background-color: #ef4444;
  box-shadow: 0 0 6px #ef4444;
}

/* Timeline Zoom Controls Bar */
.timeline-zoom-bar {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-wrap: wrap;
}

.timeline-zoom-presets {
  display: flex;
  background-color: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 2px;
  gap: 2px;
}

.btn-xs {
  padding: 0.2rem 0.45rem !important;
  font-size: 0.72rem !important;
  line-height: 1 !important;
  border-radius: 4px !important;
}

.timeline-zoom-presets button {
  background: transparent;
  color: var(--text-muted);
  border: none;
  font-weight: 600;
  transition: all 0.15s ease;
}

.timeline-zoom-presets button:hover {
  color: var(--text-primary);
  background-color: rgba(255, 255, 255, 0.05);
}

.timeline-zoom-presets button.active {
  background-color: var(--accent-color);
  color: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

.timeline-zoom-stepper {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.timeline-zoom-badge {
  font-family: monospace;
  font-size: 0.75rem;
  font-weight: 700;
  background-color: var(--bg-primary);
  border: 1px solid var(--border-color);
  padding: 0.2rem 0.45rem;
  border-radius: 4px;
  color: var(--text-primary);
  min-width: 38px;
  text-align: center;
}

/* Scrollable Viewport with Zoom */
.timeline-scroll-viewport {
  width: 100%;
  overflow-x: auto;
  overflow-y: hidden;
  background-color: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  position: relative;
  scrollbar-width: thin;
  scrollbar-color: var(--border-color) var(--bg-primary);
  cursor: grab;
  user-select: none;
  -webkit-user-select: none;
}

.timeline-scroll-viewport.is-dragging {
  cursor: grabbing;
}

.timeline-scroll-viewport::-webkit-scrollbar {
  height: 6px;
}

.timeline-scroll-viewport::-webkit-scrollbar-track {
  background: var(--bg-primary);
}

.timeline-scroll-viewport::-webkit-scrollbar-thumb {
  background-color: var(--border-color);
  border-radius: 3px;
}

.timeline-scroll-viewport::-webkit-scrollbar-thumb:hover {
  background-color: var(--accent-color);
}

.timeline-content-layer {
  position: relative;
  width: 100%;
  min-width: 100%;
  height: 80px;
  transition: width 0.12s ease-out;
}

.timeline-track {
  position: absolute;
  top: 8px;
  left: 0;
  right: 0;
  height: 40px;
  background-color: #0b1120;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  overflow: visible;
  cursor: pointer;
}

.timeline-segment {
  position: absolute;
  top: 0;
  bottom: 0;
  border-radius: 2px;
  transition: filter 0.15s;
}

.timeline-segment.regular {
  background: linear-gradient(180deg, #0284c7, #0369a1);
  opacity: 0.88;
}

.timeline-segment.motion {
  background: linear-gradient(180deg, #ef4444, #dc2626);
  z-index: 2;
  box-shadow: 0 0 6px rgba(239, 68, 68, 0.9);
}

.timeline-segment:hover {
  filter: brightness(1.3) contrast(1.1);
  z-index: 5;
}

/* Dynamic Ruler under track */
.timeline-ruler {
  position: absolute;
  top: 48px;
  left: 0;
  right: 0;
  height: 30px;
  pointer-events: none;
}

.timeline-ruler-mark {
  position: absolute;
  bottom: 6px;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  font-size: 0.68rem;
  font-family: monospace;
  color: var(--text-muted);
  white-space: nowrap;
}

.timeline-ruler-tick {
  width: 1px;
  height: 8px;
  background-color: rgba(255, 255, 255, 0.25);
  margin-bottom: 2px;
}

.timeline-ruler-mark.is-major .timeline-ruler-tick {
  height: 12px;
  background-color: var(--accent-color);
  width: 2px;
}

.timeline-ruler-mark.is-major span {
  color: var(--text-primary);
  font-weight: 700;
}

.timeline-needle {
  position: absolute;
  top: 0;
  bottom: -32px;
  width: 2px;
  background-color: #38bdf8;
  box-shadow: 0 0 8px #38bdf8, 0 0 14px var(--accent-color);
  z-index: 15;
  left: 0%;
  pointer-events: none;
  transition: left 0.1s linear;
}

.timeline-needle::before {
  content: '';
  position: absolute;
  top: 0;
  left: -5px;
  width: 12px;
  height: 10px;
  background-color: #38bdf8;
  clip-path: polygon(0% 0%, 100% 0%, 50% 100%);
}

.timeline-needle::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: -4px;
  width: 10px;
  height: 8px;
  background-color: #38bdf8;
  clip-path: polygon(50% 0%, 100% 100%, 0% 100%);
}

/* Clock / Time Picker Seek */
.seek-clock-box {
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 0.9rem 1.2rem;
  margin-top: 1rem;
  margin-bottom: 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1rem;
}

.seek-clock-info {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.seek-clock-info strong {
  font-size: 0.9rem;
  color: #fff;
}

.seek-clock-info span {
  font-size: 0.78rem;
  color: var(--text-muted);
}

.seek-clock-controls {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.form-input-time {
  background-color: var(--bg-primary);
  border: 1px solid var(--border-color);
  color: #fff;
  padding: 0.5rem 0.8rem;
  border-radius: var(--radius-md);
  font-size: 0.95rem;
  font-family: monospace;
  font-weight: 600;
  outline: none;
  transition: border-color 0.2s;
}

.form-input-time:focus {
  border-color: var(--accent-color);
}

/* Playback Player Embedded */
.playback-player-box {
  background-color: #000;
  border: 1px solid var(--accent-color);
  border-radius: var(--radius-md);
  margin-bottom: 1.5rem;
  overflow: hidden;
  animation: fadeIn 0.3s ease;
}

.player-header {
  padding: 0.6rem 1rem;
  background-color: var(--bg-secondary);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.85rem;
  font-weight: 700;
}

.player-video-wrapper {
  width: 100%;
  aspect-ratio: 16 / 9;
  max-height: 440px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #000;
}

.player-video-wrapper img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

/* Playback Player Controls Bar */
.player-controls-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1rem;
  background-color: var(--bg-secondary);
  border-top: 1px solid var(--border-color);
  flex-wrap: wrap;
  gap: 0.75rem;
}

.player-controls-left,
.player-controls-right {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-wrap: wrap;
}

.speed-selector-group {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin-left: 0.5rem;
}

.speed-selector-group select {
  padding: 0.25rem 0.5rem;
  font-size: 0.8rem;
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
}

/* Timeline Tooltip */
.timeline-track-container {
  position: relative;
}

.timeline-tooltip {
  position: absolute;
  top: -28px;
  transform: translateX(-50%);
  background-color: #0f172a;
  color: #38bdf8;
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
  font-size: 0.75rem;
  font-family: monospace;
  font-weight: 700;
  border: 1px solid #38bdf8;
  pointer-events: none;
  z-index: 20;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.4);
}

/* Playback Events Grid */
.playback-results-header {
  margin-bottom: 0.75rem;
}

.playback-results-header h3 {
  font-size: 1rem;
  font-weight: 700;
}

.playback-events-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 0.85rem;
}

.event-card {
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 0.9rem;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  transition: all 0.2s ease;
}

.event-card:hover {
  border-color: var(--accent-color);
  box-shadow: var(--shadow-sm);
}

.event-card.is-checkpoint {
  border-left: 4px solid var(--danger-color);
  background: linear-gradient(135deg, rgba(239, 68, 68, 0.08), var(--bg-card));
}

.event-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.event-time-range {
  font-family: monospace;
  font-size: 0.95rem;
  font-weight: 700;
  color: #fff;
}

.event-meta-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.event-actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.25rem;
}

/* ==========================================
   SUPER ADMIN DVR TABS & PANEL
   ========================================== */
.admin-tabs {
  display: flex;
  gap: 0.5rem;
  border-bottom: 1px solid var(--border-color);
  margin-bottom: 1.25rem;
  overflow-x: auto;
  padding-bottom: 0.5rem;
  -webkit-overflow-scrolling: touch;
}

.admin-tab-btn {
  background: none;
  border: 1px solid var(--border-color);
  color: var(--text-muted);
  padding: 0.5rem 1rem;
  border-radius: var(--radius-md);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
}

.admin-tab-btn:hover {
  background-color: rgba(255, 255, 255, 0.05);
  color: var(--text-main);
}

.admin-tab-btn.active {
  background-color: var(--accent-color);
  color: #0f172a;
  border-color: var(--accent-color);
  font-weight: 700;
}

/* Indicador de Modo de Rede (Wi-Fi Local vs Remoto) */
.network-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.65rem;
  font-weight: 700;
  padding: 0.15rem 0.45rem;
  border-radius: 9999px;
  letter-spacing: 0.02em;
}

.network-badge.badge-lan {
  background: rgba(16, 185, 129, 0.18);
  color: #34d399;
  border: 1px solid rgba(16, 185, 129, 0.4);
}

.network-badge.badge-wan {
  background: rgba(59, 130, 246, 0.18);
  color: #93c5fd;
  border: 1px solid rgba(59, 130, 246, 0.4);
}

.dvr-panel-tab {
  animation: fadeIn 0.2s ease;
}

/* ==========================================
   MOBILE BOTTOM NAVIGATION & RESPONSIVE LAYOUT
   ========================================== */
.mobile-bottom-nav {
  display: none;
}

@media (max-width: 1024px) {
  .app-sidebar {
    transform: translateX(-100%);
    width: 270px !important;
    z-index: 90;
  }

  .app-sidebar.mobile-open {
    transform: translateX(0);
    box-shadow: 10px 0 40px rgba(0, 0, 0, 0.85);
  }

  .app-main-viewport {
    margin-left: 0 !important;
  }

  .mobile-menu-toggle {
    display: flex;
  }

  .topbar-brand {
    display: flex;
  }

  .mobile-bottom-nav {
    display: flex;
  }
}

@media (max-width: 768px) {
  .hide-mobile {
    display: none !important;
  }

  .main-content {
    padding-bottom: calc(5rem + env(safe-area-inset-bottom, 0px));
  }

  .mobile-bottom-nav {
    display: flex;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: calc(3.8rem + env(safe-area-inset-bottom, 0px));
    padding-bottom: env(safe-area-inset-bottom, 0px);
    background: rgba(9, 14, 26, 0.88);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    z-index: 80;
    align-items: center;
    justify-content: space-around;
    box-shadow: 0 -4px 24px rgba(0, 0, 0, 0.6);
  }

  .mobile-bottom-nav .nav-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.25rem;
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 0.72rem;
    font-weight: 600;
    cursor: pointer;
    position: relative;
    padding: 0.4rem 0;
    transition: color 0.2s;
  }

  .mobile-bottom-nav .nav-item.active,
  .mobile-bottom-nav .nav-item:active {
    color: var(--accent-color);
  }

  .mobile-bottom-nav .nav-item svg {
    transition: transform 0.2s;
  }

  .mobile-bottom-nav .nav-item.active svg {
    transform: scale(1.1);
  }

  /* Oculta terminantemente o badge textual de DVR no topo mobile */
  #dvr-status-badge {
    display: none !important;
  }

  .chat-drawer {
    width: 100vw !important;
  }

  .chat-input-bar {
    padding-bottom: max(0.85rem, env(safe-area-inset-bottom)) !important;
  }

  /* Ajustes da Grade de Câmeras no Celular */
  .camera-grid.grid-2 .cam-title-full {
    display: none !important;
  }

  .camera-grid.grid-2 .cam-title-short {
    display: inline-block !important;
    white-space: nowrap !important;
    font-size: 0.74rem !important;
    font-weight: 700 !important;
  }

  .camera-grid.grid-2 .camera-title {
    max-width: 66% !important;
    gap: 0.25rem !important;
  }

  .camera-grid.grid-2 .badge {
    padding: 0.15rem 0.35rem !important;
    font-size: 0.6rem !important;
  }

  /* Modal de Vídeo Ampliado: 100% Edge-to-Edge no Celular */
  .fullscreen-modal {
    padding: 0 !important;
    background: #000 !important;
  }

  .fullscreen-modal .fullscreen-container {
    width: 100vw !important;
    height: 100vh !important;
    max-width: 100vw !important;
    max-height: 100vh !important;
    border-radius: 0 !important;
    border: none !important;
    display: flex !important;
    flex-direction: column !important;
    justify-content: space-between !important;
    background: #000 !important;
  }

  .fullscreen-modal .fullscreen-header {
    padding: 0.5rem 0.75rem !important;
    background: rgba(15, 23, 42, 0.9) !important;
    backdrop-filter: blur(8px) !important;
    -webkit-backdrop-filter: blur(8px) !important;
  }

  .fullscreen-modal .fullscreen-video-wrapper {
    flex: 1 !important;
    aspect-ratio: auto !important;
    height: auto !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
  }

  .fullscreen-modal .fullscreen-video-wrapper img {
    max-width: 100% !important;
    max-height: 100% !important;
    object-fit: contain !important;
  }

  .fullscreen-modal .fullscreen-floating-toolbar {
    bottom: calc(1.5rem + env(safe-area-inset-bottom, 0px)) !important;
    padding: 0.35rem 0.65rem !important;
    gap: 0.6rem !important;
  }

  /* Modais Gerais Responsivos no Celular */
  .modal-content.modal-extra-large,
  .modal-content.modal-large,
  .modal-content {
    max-height: 88vh !important;
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch !important;
    padding: 1.25rem 1rem !important;
  }

  .form-row {
    flex-direction: column !important;
    gap: 0.5rem !important;
  }

  .table-container {
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch !important;
  }

  /* Filtros de Gravação no Celular */
  .playback-filters-box {
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 0.65rem !important;
    padding: 0.85rem !important;
  }

  .playback-filters-box .filter-field {
    width: 100% !important;
  }

  .playback-filters-box .filter-btn-align,
  .playback-filters-box .filter-btn-align button {
    width: 100% !important;
  }

  /* Linha do Tempo no Celular: Ticks Essenciais */
  .timeline-hours span:nth-child(2),
  .timeline-hours span:nth-child(4),
  .timeline-hours span:nth-child(6),
  .timeline-hours span:nth-child(8) {
    display: none !important;
  }

  .seek-clock-box {
    flex-direction: column !important;
    align-items: stretch !important;
    padding: 0.85rem !important;
  }

  .seek-clock-controls {
    justify-content: stretch !important;
  }

  .seek-clock-controls input,
  .seek-clock-controls button {
    flex: 1 !important;
  }

  /* Barra Superior Sleek no Celular com Safe Area Top (iPhone 8 Plus, Notch & Dynamic Island) */
  .navbar,
  .topbar-glass {
    padding-top: max(env(safe-area-inset-top, 0px), 0.85rem) !important;
    padding-bottom: 0.5rem !important;
    padding-left: max(env(safe-area-inset-left, 0px), 0.75rem) !important;
    padding-right: max(env(safe-area-inset-right, 0px), 0.75rem) !important;
    flex-wrap: nowrap !important;
    gap: 0.5rem !important;
    height: auto !important;
    min-height: 54px !important;
  }

  .brand {
    gap: 0.45rem !important;
    min-width: 0 !important;
  }

  .brand-logo-img-nav {
    width: 32px !important;
    height: 32px !important;
  }

  .brand-title {
    font-size: 0.98rem !important;
    white-space: nowrap !important;
  }

  .header-actions {
    gap: 0.35rem !important;
    flex-wrap: nowrap !important;
  }

  .quality-pill-btn {
    padding: 0.35rem 0.55rem !important;
    font-size: 0.75rem !important;
  }

  .grid-controls .btn-icon {
    width: 32px !important;
    height: 32px !important;
  }

  /* Bottom Sheet do Menu "Mais" */
  .modal-bottom-sheet {
    align-items: flex-end !important;
    padding: 0 !important;
  }

  .modal-bottom-sheet .sheet-content {
    border-radius: 20px 20px 0 0 !important;
    max-width: 100vw !important;
    width: 100vw !important;
    padding: 0.75rem 1.25rem calc(1.5rem + env(safe-area-inset-bottom, 0px)) 1.25rem !important;
    background: var(--bg-secondary) !important;
    border-bottom: none !important;
    animation: sheetSlideUp 0.25s ease-out !important;
    max-height: 85vh !important;
    overflow-y: auto !important;
  }

  @keyframes sheetSlideUp {
    from { transform: translateY(100%); }
    to { transform: translateY(0); }
  }

  .sheet-drag-handle {
    width: 36px !important;
    height: 4px !important;
    border-radius: 2px !important;
    background: rgba(255, 255, 255, 0.2) !important;
    margin: 0 auto 0.75rem auto !important;
  }

  .sheet-subtitle {
    font-size: 0.72rem !important;
    color: var(--text-muted) !important;
    display: block !important;
  }

  .mobile-menu-list {
    display: flex !important;
    flex-direction: column !important;
    gap: 0.5rem !important;
    margin-top: 0.5rem !important;
  }

  .mobile-menu-item {
    display: flex !important;
    align-items: center !important;
    gap: 0.85rem !important;
    padding: 0.75rem 0.85rem !important;
    background: var(--bg-card) !important;
    border: 1px solid var(--border-color) !important;
    border-radius: var(--radius-md) !important;
    color: var(--text-main) !important;
    cursor: pointer !important;
    text-align: left !important;
    width: 100% !important;
    transition: background 0.15s ease !important;
  }

  .mobile-menu-item:active {
    background: rgba(255, 255, 255, 0.08) !important;
  }

  .m-item-icon {
    width: 36px !important;
    height: 36px !important;
    border-radius: 10px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    flex-shrink: 0 !important;
  }

  .m-item-icon.blue { background: rgba(56, 189, 248, 0.15) !important; color: var(--accent-color) !important; }
  .m-item-icon.purple { background: rgba(168, 85, 247, 0.15) !important; color: #c084fc !important; }
  .m-item-icon.green { background: rgba(16, 185, 129, 0.15) !important; color: var(--success-color) !important; }
  .m-item-icon.gold { background: rgba(245, 158, 11, 0.15) !important; color: var(--warning-color) !important; }
  .m-item-icon.red { background: rgba(239, 68, 68, 0.15) !important; color: var(--danger-color) !important; }

  .m-item-text {
    flex: 1 !important;
    min-width: 0 !important;
  }

  .m-item-text strong {
    display: block !important;
    font-size: 0.85rem !important;
    font-weight: 600 !important;
    color: #fff !important;
  }

  .m-item-text span {
    display: block !important;
    font-size: 0.7rem !important;
    color: var(--text-muted) !important;
  }

  .m-item-arrow {
    font-size: 1.2rem !important;
    color: var(--text-muted) !important;
  }

  .mobile-menu-item.item-danger {
    border-color: rgba(239, 68, 68, 0.3) !important;
    background: rgba(239, 68, 68, 0.05) !important;
  }

  .mobile-menu-item.item-danger strong {
    color: var(--danger-color) !important;
  }
}

/* Floating PWA Install Banner (Mobile) */
.pwa-install-banner {
  position: fixed;
  bottom: calc(4.6rem + env(safe-area-inset-bottom, 0px));
  left: 0.85rem;
  right: 0.85rem;
  max-width: 480px;
  margin: 0 auto;
  background: rgba(17, 24, 39, 0.95);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(56, 189, 248, 0.35);
  border-radius: var(--radius-lg);
  padding: 0.65rem 0.9rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.7);
  z-index: 1500;
  animation: slideUp 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.pwa-banner-content {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  flex: 1;
  min-width: 0;
  cursor: pointer;
}

.pwa-banner-icon {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  object-fit: contain;
  flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.5);
}

.pwa-banner-info {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.pwa-banner-info strong {
  font-size: 0.85rem;
  color: var(--text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.pwa-banner-info span {
  font-size: 0.72rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.pwa-banner-actions {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex-shrink: 0;
}

.pwa-banner-close {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 1.3rem;
  cursor: pointer;
  padding: 0.1rem 0.3rem;
  line-height: 1;
  transition: color 0.15s ease;
}

.pwa-banner-close:hover {
  color: var(--text-main);
}

@keyframes slideUp {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ==========================================
   CENTRAL DE CONTROLE E MONITORAMENTO RÁPIDO
   ========================================== */
.cctv-quick-dashboard {
  margin-top: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.cctv-status-card {
  background: rgba(14, 22, 38, 0.65);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-lg);
  padding: 0.95rem 1.15rem;
  box-shadow: 0 8px 24px -2px rgba(0, 0, 0, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

.cctv-status-card-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}

.cctv-status-icon-box {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: rgba(16, 185, 129, 0.15);
  color: var(--success-color);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.cctv-status-meta h4 {
  font-size: 0.88rem;
  font-weight: 700;
  color: #fff;
  margin-bottom: 0.15rem;
}

.cctv-status-meta span {
  font-size: 0.72rem;
  color: var(--text-muted);
  display: block;
}

.cctv-quick-stats-row {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.cctv-stat-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.3rem 0.65rem;
  background: rgba(15, 23, 42, 0.6);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 9999px;
  font-size: 0.72rem;
  color: var(--text-main);
}

.stat-indicator {
  width: 7px;
  height: 7px;
  border-radius: 50%;
}

.stat-indicator.green {
  background-color: var(--success-color);
  box-shadow: 0 0 6px var(--success-color);
}

.stat-indicator.blue {
  background-color: var(--accent-color);
  box-shadow: 0 0 6px var(--accent-color);
}

.quick-command-card,
.quick-alerts-card {
  background: rgba(14, 22, 38, 0.65);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-lg);
  padding: 0.95rem 1.15rem;
  box-shadow: 0 8px 24px -2px rgba(0, 0, 0, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

.card-title-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 0.65rem;
}

.dash-section-title {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--text-muted);
  letter-spacing: 0.05em;
}

.dash-subtitle {
  font-size: 0.68rem;
  color: var(--text-muted);
}

.dash-quick-actions-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.5rem;
}

.dash-action-btn {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 0.65rem 0.75rem;
  display: flex;
  align-items: center;
  gap: 0.65rem;
  cursor: pointer;
  transition: all 0.2s ease;
  text-align: left;
}

.dash-action-btn:active {
  transform: scale(0.98);
  background: rgba(56, 189, 248, 0.1);
  border-color: var(--accent-color);
}

.dash-action-icon {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.dash-action-icon.blue { background: rgba(56, 189, 248, 0.15); color: var(--accent-color); }
.dash-action-icon.green { background: rgba(16, 185, 129, 0.15); color: var(--success-color); }
.dash-action-icon.gold { background: rgba(245, 158, 11, 0.15); color: var(--warning-color); }
.dash-action-icon.red { background: rgba(239, 68, 68, 0.15); color: var(--danger-color); }

.dash-action-text strong {
  display: block;
  font-size: 0.78rem;
  font-weight: 700;
  color: #fff;
}

.dash-action-text span {
  display: block;
  font-size: 0.68rem;
  color: var(--text-muted);
}

/* ==========================================================================
   Página Completa de Configurações do DVR (Menu em Página Cheia)
   ========================================================================== */
.page-view {
  width: 100%;
  animation: fadeIn 0.2s ease-in-out;
}

.settings-page-container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 1.5rem 1rem 5rem;
}

.settings-page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.5rem;
  padding-bottom: 1.25rem;
  border-bottom: 1px solid var(--border-color);
  flex-wrap: wrap;
  gap: 1rem;
}

.settings-header-left {
  display: flex;
  align-items: center;
  gap: 1.25rem;
  flex-wrap: wrap;
}

.btn-back-cams {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
  padding: 0.65rem 1.15rem;
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  transition: all 0.2s ease;
}

.btn-back-cams:hover,
.btn-back-cams:active {
  background: var(--accent-color);
  color: #fff;
  border-color: var(--accent-color);
}

.settings-page-title {
  font-size: 1.35rem;
  font-weight: 700;
  margin: 0;
  color: var(--text-main);
}

.settings-page-subtitle {
  font-size: 0.85rem;
  color: var(--text-muted);
  display: block;
  margin-top: 0.25rem;
}

.settings-tabs-page {
  margin-bottom: 1.5rem;
}

.settings-page-container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 1.5rem 1.25rem 5rem;
}

.settings-page-body {
  background: rgba(14, 22, 38, 0.72);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-lg);
  padding: 1.75rem;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

@media (max-width: 768px) {
  .settings-page-container {
    padding: 1rem 0.75rem 6rem;
  }
  .settings-page-body {
    padding: 1.2rem 0.9rem;
  }
  .settings-page-title {
    font-size: 1.15rem;
  }
}

/* ==========================================================================
   Barra de Progresso Real (%) para Downloads e Conversões MP4
   ========================================================================== */
.progress-container {
  background: rgba(255, 255, 255, 0.08);
  border-radius: 999px;
  height: 18px;
  overflow: hidden;
  margin: 1.25rem 0 0.75rem;
  border: 1px solid rgba(255, 255, 255, 0.15);
  position: relative;
}

.progress-bar-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #38bdf8, #2563eb);
  border-radius: 999px;
  transition: width 0.3s ease;
  box-shadow: 0 0 10px rgba(56, 189, 248, 0.5);
}


/* ==========================================================================
   MATRIZ DE CÂMERAS EXPANSÍVEL (1x1, 2x2, 3x3, 4x4, 6x6)
   ========================================================================== */
.camera-grid.grid-1 {
  grid-template-columns: 1fr !important;
}
.camera-grid.grid-2 {
  grid-template-columns: repeat(2, 1fr) !important;
}
.camera-grid.grid-3 {
  grid-template-columns: repeat(3, 1fr) !important;
}
.camera-grid.grid-4 {
  grid-template-columns: repeat(4, 1fr) !important;
}
.camera-grid.grid-6 {
  grid-template-columns: repeat(6, 1fr) !important;
}

/* Ajustes visuais para grids densos (3x3, 4x4, 6x6) */
.camera-grid.grid-3 .camera-top-bar,
.camera-grid.grid-4 .camera-top-bar,
.camera-grid.grid-6 .camera-top-bar {
  padding: 0.35rem 0.5rem;
}
.camera-grid.grid-3 .cam-title-full,
.camera-grid.grid-4 .cam-title-full,
.camera-grid.grid-6 .cam-title-full {
  display: none !important;
}
.camera-grid.grid-3 .cam-title-short,
.camera-grid.grid-4 .cam-title-short,
.camera-grid.grid-6 .cam-title-short {
  display: inline-block !important;
  font-size: 0.72rem;
}
.camera-grid.grid-4 .badge,
.camera-grid.grid-6 .badge,
.camera-grid.grid-4 .quality-badge,
.camera-grid.grid-6 .quality-badge {
  font-size: 0.62rem;
  padding: 1px 5px;
}
.camera-grid.grid-6 .overlay-btn {
  font-size: 0.65rem;
  padding: 0.25rem 0.4rem;
}
.camera-grid.grid-6 .overlay-btn svg {
  display: none;
}

/* Regras de Matriz Responsiva para Mobile (Respeita 1x1, 2x2, 3x3, 4x4, 6x6) */
@media (max-width: 1024px) {
  .camera-grid.grid-1 {
    grid-template-columns: 1fr !important;
    gap: 0.65rem !important;
  }
  .camera-grid.grid-2 {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 0.45rem !important;
  }
  .camera-grid.grid-3 {
    grid-template-columns: repeat(3, 1fr) !important;
    gap: 0.35rem !important;
  }
  .camera-grid.grid-4 {
    grid-template-columns: repeat(4, 1fr) !important;
    gap: 0.25rem !important;
  }
  .camera-grid.grid-6 {
    grid-template-columns: repeat(6, 1fr) !important;
    gap: 0.2rem !important;
  }

  /* Ajustes visuais específicos de cada grid no celular */
  .camera-grid.grid-1 .camera-card {
    border-radius: 12px;
  }
  .camera-grid.grid-1 .cam-title-full {
    display: inline-block !important;
  }
  .camera-grid.grid-1 .cam-title-short {
    display: none !important;
  }

  .camera-grid.grid-2 .camera-card {
    border-radius: 8px;
  }
  .camera-grid.grid-2 .camera-top-bar {
    padding: 0.28rem 0.45rem;
  }
  .camera-grid.grid-2 .cam-title-full {
    display: none !important;
  }
  .camera-grid.grid-2 .cam-title-short {
    display: inline-block !important;
    font-size: 0.72rem;
  }
  .camera-grid.grid-2 .quality-badge {
    display: none !important;
  }

  .camera-grid.grid-3 .camera-card {
    border-radius: 6px;
  }
  .camera-grid.grid-3 .camera-top-bar {
    padding: 0.2rem 0.35rem;
  }
  .camera-grid.grid-3 .cam-title-full {
    display: none !important;
  }
  .camera-grid.grid-3 .cam-title-short {
    display: inline-block !important;
    font-size: 0.62rem;
  }
  .camera-grid.grid-3 .badge {
    padding: 1px 4px;
    font-size: 0.52rem;
  }
  .camera-grid.grid-3 .cam-status-text {
    display: none !important;
  }
  .camera-grid.grid-3 .camera-overlay {
    display: none !important;
  }

  .camera-grid.grid-4 .camera-card,
  .camera-grid.grid-6 .camera-card {
    border-radius: 4px;
  }
  .camera-grid.grid-4 .camera-top-bar,
  .camera-grid.grid-6 .camera-top-bar {
    padding: 1px 3px;
  }
  .camera-grid.grid-4 .cam-title-full,
  .camera-grid.grid-6 .cam-title-full,
  .camera-grid.grid-4 .cam-title-short,
  .camera-grid.grid-6 .cam-title-short {
    display: none !important;
  }
  .camera-grid.grid-4 .camera-title svg,
  .camera-grid.grid-6 .camera-title svg {
    display: none !important;
  }
  .camera-grid.grid-4 .camera-title::after {
    content: attr(title);
    font-size: 0.52rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .camera-grid.grid-4 .badge,
  .camera-grid.grid-6 .badge {
    padding: 1px 2px;
  }
  .camera-grid.grid-4 .cam-status-text,
  .camera-grid.grid-6 .cam-status-text,
  .camera-grid.grid-4 .quality-badge,
  .camera-grid.grid-6 .quality-badge,
  .camera-grid.grid-4 .camera-overlay,
  .camera-grid.grid-6 .camera-overlay {
    display: none !important;
  }

  .camera-grid.grid-4 .empty-slot-content svg,
  .camera-grid.grid-6 .empty-slot-content svg {
    width: 16px;
    height: 16px;
  }
  .camera-grid.grid-4 .empty-slot-title,
  .camera-grid.grid-6 .empty-slot-title {
    font-size: 0.55rem;
  }
  .camera-grid.grid-4 .empty-slot-sub,
  .camera-grid.grid-6 .empty-slot-sub {
    display: none !important;
  }
}

/* Slots de Câmeras Vazias / Livres na Matriz */
.camera-card-empty {
  background: rgba(14, 20, 32, 0.42);
  border: 1px dashed rgba(255, 255, 255, 0.12);
  border-radius: 12px;
  overflow: hidden;
  transition: all 0.25s ease;
  position: relative;
}
.camera-card-empty:hover {
  border-color: rgba(96, 165, 250, 0.35);
  background: rgba(14, 20, 32, 0.6);
}
.empty-slot-box {
  display: flex;
  flex-direction: column;
  aspect-ratio: 16 / 9;
  width: 100%;
  justify-content: space-between;
  background: rgba(0, 0, 0, 0.32);
  position: relative;
}
.empty-slot-badge {
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  padding: 2px 7px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.06);
  color: #64748b;
  border: 1px solid rgba(255, 255, 255, 0.08);
}
.empty-slot-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  gap: 0.35rem;
  color: #475569;
  padding: 1rem 0.5rem;
}
.empty-slot-content svg {
  color: #334155;
  transition: color 0.2s ease;
}
.camera-card-empty:hover .empty-slot-content svg {
  color: #60a5fa;
}
.empty-slot-title {
  font-size: 0.8rem;
  font-weight: 600;
  color: #94a3b8;
}
.empty-slot-sub {
  font-size: 0.68rem;
  color: #64748b;
}

/* ==========================================================================
   LAYOUT EM PALCO (STAGE) & COMMAND MENU LATERAL DOCKED
   ========================================================================== */
.cctv-stage-layout {
  display: flex;
  gap: 1.15rem;
  align-items: flex-start;
  width: 100%;
  max-width: 1920px;
  margin: 0 auto;
}

.cctv-grid-column {
  flex: 1 1 0;
  min-width: 0;
}

.cctv-command-panel {
  width: 310px;
  flex-shrink: 0;
  position: sticky;
  top: 0;
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  max-height: calc(100vh - 86px);
  overflow-y: auto;
  padding-right: 2px;
}

.cctv-command-panel::-webkit-scrollbar {
  width: 4px;
}
.cctv-command-panel::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.15);
  border-radius: 4px;
}

@media (max-width: 1100px) {
  .cctv-stage-layout {
    flex-direction: column;
    gap: 1.25rem;
  }
  .cctv-command-panel {
    width: 100%;
    position: static;
    max-height: none;
    overflow-y: visible;
  }
}

/* Cards do Command Menu (Obsidian Liquid Glass) */
.cmd-panel-card {
  background: rgba(14, 20, 32, 0.72);
  backdrop-filter: blur(24px) saturate(190%);
  -webkit-backdrop-filter: blur(24px) saturate(190%);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 14px;
  padding: 0.95rem;
  box-shadow: 0 10px 32px rgba(0, 0, 0, 0.38), inset 0 1px 0 rgba(255, 255, 255, 0.1);
  transition: border-color 0.25s ease;
}
.cmd-panel-card:hover {
  border-color: rgba(255, 255, 255, 0.14);
}

.cmd-card-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}
.cmd-icon-box {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.cmd-icon-box.green {
  background: rgba(16, 185, 129, 0.15);
  color: #34d399;
  border: 1px solid rgba(16, 185, 129, 0.25);
}
.cmd-meta {
  display: flex;
  flex-direction: column;
}
.cmd-meta h4 {
  font-size: 0.92rem;
  font-weight: 600;
  color: #f1f5f9;
  margin: 0;
  line-height: 1.2;
}
.cmd-subtext {
  font-size: 0.7rem;
  color: #94a3b8;
  margin-top: 2px;
}

.cmd-telemetry-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(90px, 1fr));
  gap: 0.45rem;
  margin-top: 0.8rem;
}
.cmd-telemetry-pill {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.4rem 0.6rem;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.06);
  font-size: 0.72rem;
  color: #cbd5e1;
  transition: background 0.2s;
}
.cmd-telemetry-pill:hover {
  background: rgba(255, 255, 255, 0.06);
}

.stat-indicator {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  display: inline-block;
}
.stat-indicator.green {
  background: #10b981;
  box-shadow: 0 0 7px rgba(16, 185, 129, 0.7);
}
.stat-indicator.blue {
  background: #38bdf8;
  box-shadow: 0 0 7px rgba(56, 189, 248, 0.7);
}

.cmd-card-label {
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #64748b;
  margin-bottom: 0.6rem;
}

.cmd-grid-selector {
  display: flex;
  gap: 0.35rem;
}
.cmd-grid-btn {
  flex: 1;
  padding: 0.5rem 0.2rem;
  text-align: center;
  font-size: 0.78rem;
  font-weight: 600;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.04);
  color: #94a3b8;
  cursor: pointer;
  transition: all 0.2s ease;
}
.cmd-grid-btn:hover {
  background: rgba(255, 255, 255, 0.09);
  color: #f8fafc;
}
.cmd-grid-btn.active {
  background: linear-gradient(135deg, rgba(59, 130, 246, 0.85), rgba(37, 99, 235, 0.95));
  color: #ffffff;
  border-color: rgba(96, 165, 250, 0.6);
  box-shadow: 0 4px 14px rgba(37, 99, 235, 0.4);
}

.cmd-actions-list {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}
.cmd-action-item {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  width: 100%;
  padding: 0.55rem 0.75rem;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.06);
  color: #e2e8f0;
  cursor: pointer;
  text-align: left;
  transition: all 0.2s ease;
}
.cmd-action-item:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.14);
  transform: translateY(-1px);
}
.cmd-action-icon {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.cmd-action-icon.blue {
  background: rgba(59, 130, 246, 0.16);
  color: #60a5fa;
}
.cmd-action-icon.green {
  background: rgba(16, 185, 129, 0.16);
  color: #34d399;
}
.cmd-action-icon.gold {
  background: rgba(245, 158, 11, 0.16);
  color: #fbbf24;
}
.cmd-action-icon.red {
  background: rgba(239, 68, 68, 0.16);
  color: #f87171;
}
.cmd-action-info {
  display: flex;
  flex-direction: column;
  line-height: 1.25;
}
.cmd-action-info strong {
  font-size: 0.82rem;
  color: #f1f5f9;
}
.cmd-action-info span {
  font-size: 0.7rem;
  color: #94a3b8;
}

.cmd-chips-wrap {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}
.cmd-chip {
  padding: 0.38rem 0.7rem;
  border-radius: 20px;
  font-size: 0.73rem;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all 0.2s ease;
  background: rgba(255, 255, 255, 0.05);
  color: #cbd5e1;
}
.cmd-chip:hover {
  transform: translateY(-1px);
}
.chip-alert {
  border-color: rgba(239, 68, 68, 0.35);
  background: rgba(239, 68, 68, 0.14);
  color: #fca5a5;
}
.chip-warning {
  border-color: rgba(245, 158, 11, 0.35);
  background: rgba(245, 158, 11, 0.14);
  color: #fcd34d;
}
.chip-info {
  border-color: rgba(59, 130, 246, 0.35);
  background: rgba(59, 130, 246, 0.14);
  color: #93c5fd;
}
.chip-success {
  border-color: rgba(16, 185, 129, 0.35);
  background: rgba(16, 185, 129, 0.14);
  color: #6ee7b7;
}

/* ==========================================================================
   PÁGINAS DEDICADAS (LIQUID GLASS CONTAINERS)
   ========================================================================== */
.page-liquid-container {
  width: 100%;
  max-width: 1400px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}
.page-header-liquid {
  display: flex;
  align-items: center;
  gap: 1.15rem;
  padding: 1.1rem 1.4rem;
  background: rgba(14, 20, 32, 0.72);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 14px;
  backdrop-filter: blur(24px) saturate(190%);
  -webkit-backdrop-filter: blur(24px) saturate(190%);
  box-shadow: 0 10px 32px rgba(0, 0, 0, 0.38), inset 0 1px 0 rgba(255, 255, 255, 0.1);
}
.page-title-liquid {
  font-size: 1.25rem;
  font-weight: 700;
  color: #f8fafc;
  margin: 0;
  line-height: 1.25;
}
.page-subtitle-liquid {
  font-size: 0.8rem;
  color: #94a3b8;
  display: block;
  margin-top: 3px;
}
.page-body-liquid {
  background: rgba(14, 20, 32, 0.65);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 14px;
  padding: 1.4rem;
  backdrop-filter: blur(24px) saturate(190%);
  -webkit-backdrop-filter: blur(24px) saturate(190%);
  box-shadow: 0 10px 32px rgba(0, 0, 0, 0.38), inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

.btn-back-cams {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.55rem 0.95rem;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.05);
  color: #cbd5e1;
  font-size: 0.82rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  flex-shrink: 0;
}
.btn-back-cams:hover {
  background: rgba(255, 255, 255, 0.12);
  color: #ffffff;
  border-color: rgba(255, 255, 255, 0.25);
  transform: translateX(-2px);
}

@media (max-width: 768px) {
  .page-header-liquid {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.75rem;
    padding: 1rem;
  }
  .page-body-liquid {
    padding: 1rem;
  }
}


/* ==========================================================================
   ENCAIXE RESPONSIVO DO GRID DE CÂMERAS NO COMPUTADOR (SEM SCROLL)
   ========================================================================== */
@media (min-width: 1025px) {
  #view-cameras {
    height: 100%;
    max-height: 100%;
    padding: 0.65rem 0.85rem;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    min-height: 0;
  }

  .cctv-stage-layout {
    height: 100%;
    max-height: 100%;
    display: flex;
    gap: 0.85rem;
    align-items: stretch;
    min-height: 0;
    width: 100%;
    max-width: 1920px;
    margin: 0 auto;
  }

  .cctv-grid-column {
    flex: 1 1 0;
    min-width: 0;
    height: 100%;
    max-height: 100%;
    min-height: 0;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    overflow: hidden;
  }

  #camera-grid {
    width: 100%;
    height: 100%;
    max-height: 100%;
    min-height: 0;
    display: grid;
    gap: 0.5rem;
  }

  .camera-grid.grid-1 {
    grid-template-columns: 1fr !important;
    grid-template-rows: 1fr !important;
  }
  .camera-grid.grid-2 {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    grid-template-rows: repeat(2, minmax(0, 1fr)) !important;
  }
  .camera-grid.grid-3 {
    grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
    grid-template-rows: repeat(3, minmax(0, 1fr)) !important;
  }
  .camera-grid.grid-4 {
    grid-template-columns: repeat(4, minmax(0, 1fr)) !important;
    grid-template-rows: repeat(4, minmax(0, 1fr)) !important;
  }
  .camera-grid.grid-6 {
    grid-template-columns: repeat(6, minmax(0, 1fr)) !important;
    grid-template-rows: repeat(6, minmax(0, 1fr)) !important;
  }

  .cctv-grid-column .camera-card {
    height: 100%;
    width: 100%;
    min-height: 0;
    min-width: 0;
    display: flex;
    flex-direction: column;
    border-radius: 10px;
    overflow: hidden;
    position: relative;
    background: #000;
  }

  .cctv-grid-column .camera-video-container {
    width: 100%;
    height: 100%;
    min-height: 0;
    min-width: 0;
    aspect-ratio: unset !important;
    position: relative;
    overflow: hidden;
    background-color: #000;
  }

  .cctv-grid-column .camera-video-container img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
  }

  .cctv-grid-column .camera-card-empty .empty-slot-box {
    width: 100%;
    height: 100%;
    min-height: 0;
    min-width: 0;
    aspect-ratio: unset !important;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    background: rgba(0, 0, 0, 0.35);
  }

  .cctv-command-panel {
    width: 300px;
    flex-shrink: 0;
    height: 100%;
    max-height: 100%;
    overflow-y: auto;
    overflow-x: hidden;
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
    padding-right: 3px;
  }

  .cmd-panel-card {
    padding: 0.75rem 0.85rem;
  }
  .cmd-telemetry-grid {
    margin-top: 0.55rem;
    gap: 0.35rem;
  }
  .cmd-card-label {
    margin-bottom: 0.45rem;
  }
  .cmd-actions-list {
    gap: 0.35rem;
  }
  .cmd-action-item {
    padding: 0.45rem 0.65rem;
  }
}

@media (max-width: 1024px) {
  body {
    height: auto;
    min-height: 100vh;
    max-height: none;
    overflow-y: auto;
    overflow-x: hidden;
  }
  .app-main-viewport {
    height: auto;
    min-height: 100vh;
    max-height: none;
    overflow: visible;
  }
  .app-content-scroll {
    height: auto;
    max-height: none;
    overflow: visible;
  }
}


/* ==========================================================================
   REDESENHO DA TELA DE CELULAR (RESPONSIVIDADE TOTAL, GRID E IPHONE SAFE-AREA)
   ========================================================================== */
@media (max-width: 768px) {
  /* Topbar compacta com Safe Area superior para iPhone */
  .topbar-glass {
    height: calc(56px + env(safe-area-inset-top, 0px));
    padding-top: max(env(safe-area-inset-top, 0px), 8px);
    padding-left: 0.65rem;
    padding-right: 0.65rem;
    gap: 0.4rem;
  }

  /* Oculta o texto Casa Castino no celular dando espaco prioritario aos grids */
  .topbar-brand-title {
    display: none !important;
  }
  .brand-logo-img-nav {
    width: 28px;
    height: 28px;
  }
  .brand-live-dot {
    margin-left: 2px;
  }

  .topbar-right {
    gap: 0.35rem;
  }

  /* Grid selector compacto no topbar mobile */
  .grid-controls-glass {
    padding: 2px;
    gap: 2px;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.05);
  }
  .grid-glass-btn {
    width: 28px;
    height: 26px;
    font-size: 0.68rem;
    font-weight: 700;
    padding: 0;
    border-radius: 6px;
  }
  .quality-glass-btn {
    padding: 0.32rem 0.55rem;
    font-size: 0.72rem;
    border-radius: 8px;
  }

  /* Conteudo do Viewport de Cameras no Celular */
  #view-cameras {
    padding: 0.5rem 0.5rem calc(5.5rem + env(safe-area-inset-bottom, 0px));
    width: 100%;
  }

  .cctv-stage-layout {
    display: flex;
    flex-direction: column;
    gap: 0.85rem;
    width: 100%;
  }

  .cctv-grid-column {
    width: 100%;
  }

  /* Oculta o Command Menu dentro da aba de Câmeras no celular (movido para aba dedicada Métricas) */
  #view-cameras .cctv-command-panel {
    display: none !important;
  }

  .metrics-page-container {
    max-width: 1100px;
    margin: 0 auto;
    padding: 0.75rem 0.5rem calc(5.5rem + env(safe-area-inset-bottom, 0px));
  }
  .metrics-content-grid {
    display: flex;
    flex-direction: column;
    gap: 0.85rem;
    width: 100%;
  }

  /* Command Menu na Página de Métricas */
  .metrics-content-grid .cmd-panel-card {
    width: 100% !important;
    position: static !important;
    border-radius: 14px;
    padding: 0.95rem 1rem;
    background: rgba(15, 23, 42, 0.75);
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
  }

  .cmd-panel-card {
    border-radius: 12px;
    padding: 0.85rem 0.95rem;
  }

  .cmd-telemetry-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.35rem;
  }
  .cmd-telemetry-pill {
    padding: 0.4rem 0.35rem;
    font-size: 0.7rem;
    justify-content: center;
  }

  .cmd-grid-selector {
    display: flex;
    gap: 0.35rem;
    width: 100%;
  }
  .cmd-grid-btn {
    flex: 1;
    padding: 0.55rem 0.2rem;
    font-size: 0.8rem;
    font-weight: 700;
    border-radius: 8px;
  }

  /* Acoes rapidas em grade 2x2 moderna no celular */
  .cmd-actions-list {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.45rem;
  }
  .cmd-action-item {
    padding: 0.5rem 0.6rem;
    border-radius: 10px;
  }
  .cmd-action-icon {
    width: 30px;
    height: 30px;
  }
  .cmd-action-info strong {
    font-size: 0.78rem;
  }
  .cmd-action-info span {
    font-size: 0.67rem;
  }

  .cmd-chips-wrap {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
  }
  .cmd-chip {
    padding: 0.35rem 0.65rem;
    font-size: 0.72rem;
  }
}


/* ==========================================================================
   LAYOUT HORIZONTAL NO CELULAR & SMARTPHONE (APROVEITAMENTO MÁXIMO DE TELA)
   ========================================================================== */
@media (max-width: 1024px) {
  #view-cameras {
    padding: 0.35rem 0.25rem calc(4.8rem + env(safe-area-inset-bottom, 0px)) !important;
  }
}

@media (max-width: 1024px) and (orientation: landscape) {
  /* Oculta barra de navegacao inferior em modo horizontal para dar 100% de tela */
  .mobile-bottom-nav {
    display: none !important;
  }

  /* Topbar ultra slim para nao roubar espaço vertical */
  .topbar-glass {
    height: 38px !important;
    padding-top: 2px !important;
    padding-bottom: 2px !important;
    padding-left: max(env(safe-area-inset-left, 0px), 8px) !important;
    padding-right: max(env(safe-area-inset-right, 0px), 8px) !important;
    gap: 0.35rem !important;
  }

  .topbar-brand-title {
    display: none !important;
  }
  .brand-logo-img-nav {
    width: 22px !important;
    height: 22px !important;
  }

  .grid-glass-btn {
    width: 28px !important;
    height: 24px !important;
    font-size: 0.65rem !important;
  }
  .quality-glass-btn {
    padding: 0.2rem 0.45rem !important;
    font-size: 0.68rem !important;
  }

  /* Viewport de Câmeras ocupa 100% da altura restante sem scrollbars */
  #view-cameras {
    padding: 2px max(env(safe-area-inset-right, 0px), 4px) 2px max(env(safe-area-inset-left, 0px), 4px) !important;
    height: calc(100vh - 38px) !important;
    max-height: calc(100vh - 38px) !important;
    overflow: hidden !important;
    display: flex !important;
    flex-direction: column !important;
  }

  .cctv-stage-layout {
    height: 100% !important;
    max-height: 100% !important;
    flex-direction: row !important;
    gap: 0 !important;
    width: 100% !important;
  }

  .cctv-grid-column {
    height: 100% !important;
    max-height: 100% !important;
    width: 100% !important;
    overflow: hidden !important;
  }

  #camera-grid {
    height: 100% !important;
    max-height: 100% !important;
    width: 100% !important;
    gap: 4px !important;
    display: grid !important;
  }

  .camera-grid.grid-1 {
    grid-template-columns: 1fr !important;
    grid-template-rows: 1fr !important;
  }
  .camera-grid.grid-2 {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    grid-template-rows: repeat(2, minmax(0, 1fr)) !important;
  }
  .camera-grid.grid-3 {
    grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
    grid-template-rows: repeat(3, minmax(0, 1fr)) !important;
  }
  .camera-grid.grid-4 {
    grid-template-columns: repeat(4, minmax(0, 1fr)) !important;
    grid-template-rows: repeat(4, minmax(0, 1fr)) !important;
  }
  .camera-grid.grid-6 {
    grid-template-columns: repeat(6, minmax(0, 1fr)) !important;
    grid-template-rows: repeat(6, minmax(0, 1fr)) !important;
  }

  .cctv-grid-column .camera-card {
    height: 100% !important;
    border-radius: 6px !important;
    overflow: hidden !important;
  }

  .cctv-grid-column .camera-video-container {
    height: 100% !important;
    aspect-ratio: unset !important;
  }

  .cctv-grid-column .camera-video-container img {
    height: 100% !important;
    object-fit: cover !important;
  }
}
