/* ==========================================================================
   CODEXIAVISION — INTELLIGENT VMS & AI ANALYTICS (DESIGN SYSTEM 8 MÓDULOS)
   ========================================================================== */

:root {
  --bg-base:        #0a0c10;
  --bg-surface:     #11141b;
  --bg-card:        #151922;
  --bg-card-hover:  #1b212d;
  --bg-input:       #0c0f15;

  --border-subtle:  rgba(255, 255, 255, 0.06);
  --border-medium:  rgba(255, 255, 255, 0.12);
  --border-focus:   rgba(150, 213, 7, 0.45);

  --text-main:      #f8fafc;
  --text-muted:     #94a3b8;
  --text-dim:       #64748b;

  /* Paleta Oficial CodexiaVision (Lime Accent & Deep Neutral) */
  --ai-green:       #96d507;
  --ai-green-hover: #a6ea15;
  --ai-green-glow:  rgba(150, 213, 7, 0.20);
  --ai-green-subtle: rgba(150, 213, 7, 0.08);
  --ai-blue:        #3b82f6;
  --ai-cyan:        #06b6d4;
  --ai-amber:       #f59e0b;
  --ai-red:         #ef4444;
  --ai-purple:      #a855f7;
  --ai-indigo:      #6366f1;
  --ai-pink:        #ec4899;

  --header-height:  52px;
  --toolbar-height: 48px;
  --radius-sm:      4px;
  --radius-md:      8px;
  --radius-lg:      14px;
  --transition:     all 0.18s cubic-bezier(0.4, 0, 0.2, 1);
}

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

[hidden] {
  display: none !important;
}

html, body {
  width: 100%;
  height: 100%;
  background: var(--bg-base);
  color: var(--text-main);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 13px;
  line-height: 1.45;
  overflow: hidden;
  user-select: none;
  -webkit-font-smoothing: antialiased;
}

button, input, select, textarea {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
}

/* Scrollbars customizadas */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.12);
  border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.24);
}

/* ==========================================================================
   HEADER SUPERIOR GLOBAL
   ========================================================================== */
.topbar {
  height: var(--header-height);
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 18px;
  z-index: 50;
  position: relative;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  transition: opacity 0.15s;
}
.brand:hover {
  opacity: 0.9;
}

.brand-pulse {
  width: 10px;
  height: 10px;
  background: var(--ai-green);
  border-radius: 50%;
  box-shadow: 0 0 10px var(--ai-green);
  animation: pulse-live 2s infinite ease-in-out;
}
@keyframes pulse-live {
  0% { transform: scale(0.95); box-shadow: 0 0 4px var(--ai-green); }
  50% { transform: scale(1.25); box-shadow: 0 0 16px var(--ai-green); }
  100% { transform: scale(0.95); box-shadow: 0 0 4px var(--ai-green); }
}

.brand-info {
  display: flex;
  flex-direction: column;
}
.brand-name {
  font-size: 15px;
  font-weight: 800;
  letter-spacing: -0.4px;
}
.brand-accent {
  color: var(--ai-green);
  margin-left: 1px;
}
.brand-sub {
  font-size: 10px;
  color: var(--text-dim);
  font-weight: 500;
  letter-spacing: 0.3px;
}

.brand-logo-img {
  height: 22px;
  width: auto;
  object-fit: contain;
  display: block;
}

.top-brand-right {
  display: flex;
  align-items: center;
  padding-left: 12px;
  margin-left: 4px;
  border-left: 1px solid var(--border-subtle);
  cursor: pointer;
  transition: opacity 0.15s;
}
.top-brand-right:hover {
  opacity: 0.85;
}
.brand-logo-right-img {
  height: 22px;
  width: auto;
  object-fit: contain;
  display: block;
}
@media (max-width: 1100px) {
  .top-brand-right { display: none; }
}

/* Breadcrumb SPA */
.nav-breadcrumb {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-subtle);
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 12px;
}
.nav-home-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 5px;
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 4px;
  font-weight: 600;
  transition: var(--transition);
}
.nav-home-btn svg {
  width: 13px;
  height: 13px;
}
.nav-home-btn:hover {
  color: var(--text-main);
  background: rgba(255, 255, 255, 0.08);
}
.crumb-sep {
  width: 12px;
  height: 12px;
  stroke: var(--text-dim);
}
.crumb-current {
  color: var(--ai-green);
  font-weight: 600;
}

/* Status strip */
.top-status-strip {
  display: flex;
  align-items: center;
  gap: 8px;
}

.status-pill {
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border-subtle);
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 11.5px;
  color: var(--text-muted);
}
.status-pill svg {
  width: 13px;
  height: 13px;
  stroke: var(--text-dim);
}
.status-pill b {
  color: var(--text-main);
  font-weight: 600;
}
.status-pill-ai {
  background: rgba(16, 185, 129, 0.06);
  border-color: rgba(16, 185, 129, 0.3);
}
.status-pill-ai svg { stroke: var(--ai-green); }
.status-pill-ai b { color: var(--ai-green); }

/* Quick actions */
.top-quick-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}
.top-quick-btn {
  width: 32px;
  height: 32px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  position: relative;
  transition: var(--transition);
}
.top-quick-btn svg {
  width: 15px;
  height: 15px;
}
.top-quick-btn:hover {
  background: var(--bg-card-hover);
  color: var(--text-main);
  border-color: var(--border-medium);
}
.quick-badge-count {
  position: absolute;
  top: -4px;
  right: -4px;
  background: var(--ai-amber);
  color: #000;
  font-size: 9px;
  font-weight: 800;
  padding: 1px 4px;
  border-radius: 8px;
}

.user-profile-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-subtle);
  padding: 3px 10px 3px 4px;
  border-radius: 20px;
  cursor: pointer;
  transition: var(--transition);
}
.user-profile-pill:hover {
  background: var(--bg-card-hover);
  border-color: var(--border-medium);
}
.avatar-circle {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: #334155;
  color: #e2e8f0;
  font-size: 10px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}
.user-profile-pill span {
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text-main);
}
.btn-logout-mini {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 3px 5px;
  border-radius: 4px;
  transition: var(--transition);
  margin-left: 2px;
}
.btn-logout-mini:hover {
  color: #ef4444;
  background: rgba(239, 68, 68, 0.15);
}
.btn-logout-mini svg {
  width: 13px;
  height: 13px;
}

/* ==========================================================================
   BOTÕES FLUTUANTES DE RETORNO (MENU & HUB DE CÂMERAS)
   ========================================================================== */
.floating-nav-group {
  position: fixed;
  bottom: 20px;
  left: 20px;
  z-index: 80;
  display: flex;
  align-items: center;
  gap: 10px;
}
.floating-menu-btn {
  background: rgba(20, 23, 32, 0.94);
  backdrop-filter: blur(8px);
  border: 1px solid var(--border-medium);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.6);
  color: var(--text-main);
  padding: 8px 16px;
  border-radius: 30px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  font-size: 12px;
  letter-spacing: 0.5px;
  cursor: pointer;
  transition: var(--transition);
}
.floating-menu-btn svg {
  width: 15px;
  height: 15px;
  stroke: var(--ai-green);
}
.floating-menu-btn:hover {
  background: var(--bg-card-hover);
  border-color: var(--ai-green);
  transform: translateY(-2px);
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.8);
}
.floating-menu-btn.hidden-on-dashboard {
  display: none !important;
}

.floating-hub-btn {
  background: rgba(34, 197, 94, 0.16);
  backdrop-filter: blur(8px);
  border: 1px solid var(--ai-green);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.6);
  color: #ffffff;
  padding: 8px 16px;
  border-radius: 30px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  font-size: 12px;
  letter-spacing: 0.5px;
  cursor: pointer;
  transition: var(--transition);
}
.floating-hub-btn svg {
  width: 15px;
  height: 15px;
  stroke: var(--ai-green);
}
.floating-hub-btn:hover {
  background: var(--ai-green);
  color: #0b1118;
  transform: translateY(-2px);
  box-shadow: 0 12px 28px rgba(34, 197, 94, 0.4);
}
.floating-hub-btn.hidden-on-live {
  display: none !important;
}

/* Botão Hub Câmeras no Breadcrumb */
.nav-hub-btn {
  background: rgba(34, 197, 94, 0.12);
  border: 1px solid rgba(34, 197, 94, 0.4);
  color: var(--ai-green);
  display: inline-flex;
  align-items: center;
  gap: 5px;
  cursor: pointer;
  padding: 3px 8px;
  border-radius: 6px;
  font-weight: 700;
  font-size: 11px;
  transition: var(--transition);
}
.nav-hub-btn svg {
  width: 13px;
  height: 13px;
  stroke: var(--ai-green);
}
.nav-hub-btn:hover {
  background: var(--ai-green);
  color: #0b1118;
  border-color: var(--ai-green);
}
.nav-hub-btn:hover svg {
  stroke: #0b1118;
}
.nav-hub-btn.active {
  background: rgba(34, 197, 94, 0.25);
  border-color: var(--ai-green);
  color: #ffffff;
}

/* Botões de retorno ao Hub Câmeras dentro das visões */
.btn-back-to-hub {
  background: rgba(34, 197, 94, 0.12) !important;
  border: 1px solid rgba(34, 197, 94, 0.35) !important;
  color: var(--ai-green) !important;
  font-weight: 700 !important;
  display: inline-flex !important;
  align-items: center !important;
  gap: 6px !important;
  cursor: pointer !important;
  transition: var(--transition) !important;
}
.btn-back-to-hub:hover {
  background: var(--ai-green) !important;
  color: #0b1118 !important;
  border-color: var(--ai-green) !important;
}
.btn-back-to-hub:hover svg {
  stroke: #0b1118 !important;
}

/* ==========================================================================
   CONTAINER SPA E GERENCIAMENTO DE VIEWS
   ========================================================================== */
.spa-container {
  height: calc(100vh - var(--header-height));
  width: 100%;
  position: relative;
  overflow: hidden;
}

.spa-view {
  display: none;
  width: 100%;
  height: 100%;
  overflow: hidden;
  opacity: 0;
  transition: opacity 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}
.spa-view.active {
  display: flex;
  flex-direction: column;
  opacity: 1;
}

/* ==========================================================================
   MÓDULO 0: DASHBOARD / MENU PRINCIPAL (8 MÓDULOS SIMÉTRICOS)
   ========================================================================== */
#viewDashboard {
  overflow-y: auto;
  padding: 40px 60px;
  background: radial-gradient(circle at 50% 10%, rgba(16, 185, 129, 0.05) 0%, transparent 60%), var(--bg-base);
}

.dashboard-hero {
  text-align: center;
  margin-bottom: 36px;
}
.dashboard-title {
  font-size: 26px;
  font-weight: 800;
  letter-spacing: -0.6px;
  margin-bottom: 8px;
}
.dashboard-subtitle {
  font-size: 14px;
  color: var(--text-dim);
}

/* Grade simétrica de 8 cards */
.modules-grid-8 {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 20px;
  max-width: 1380px;
  margin: 0 auto 40px;
}

@media (max-width: 1200px) {
  .modules-grid-8 { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 680px) {
  .modules-grid-8 { grid-template-columns: 1fr; }
}

.module-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 22px;
  display: flex;
  flex-direction: column;
  cursor: pointer;
  transition: var(--transition);
  position: relative;
  overflow: hidden;
}
.module-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: transparent;
  transition: var(--transition);
}
.module-card:hover {
  background: var(--bg-card-hover);
  border-color: var(--border-medium);
  transform: translateY(-4px);
  box-shadow: 0 16px 36px rgba(0, 0, 0, 0.6);
}
.module-card:hover::before {
  background: var(--ai-green);
}

.card-icon-wrap {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 16px;
}
.card-icon-wrap svg {
  width: 22px;
  height: 22px;
}

.icon-blue   { background: rgba(59, 130, 246, 0.12); color: #60a5fa; }
.icon-cyan   { background: rgba(6, 182, 212, 0.12);  color: #22d3ee; }
.icon-amber  { background: rgba(245, 158, 11, 0.12); color: #fbbf24; }
.icon-emerald{ background: rgba(16, 185, 129, 0.12); color: #34d399; }
.icon-purple { background: rgba(168, 85, 247, 0.12); color: #c084fc; }
.icon-indigo { background: rgba(99, 102, 241, 0.12); color: #818cf8; }
.icon-pink   { background: rgba(236, 72, 153, 0.12); color: #f472b6; }
.icon-green  { background: rgba(34, 197, 94, 0.12);  color: #4ade80; }

.card-content {
  flex: 1;
  display: flex;
  flex-direction: column;
}
.card-badge {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-dim);
  letter-spacing: 0.6px;
  margin-bottom: 4px;
}
.card-title {
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.3px;
  color: var(--text-main);
  margin-bottom: 8px;
}
.card-desc {
  font-size: 12.5px;
  color: var(--text-muted);
  line-height: 1.5;
  margin-bottom: 18px;
}

.card-footer {
  border-top: 1px solid var(--border-subtle);
  padding-top: 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.card-stat {
  font-size: 11.5px;
  color: var(--text-dim);
  display: flex;
  align-items: center;
  gap: 5px;
}
.card-stat svg {
  width: 13px;
  height: 13px;
}
.card-stat b {
  color: var(--text-muted);
}
.card-arrow {
  width: 15px;
  height: 15px;
  stroke: var(--text-dim);
  transition: transform 0.2s;
}
.module-card:hover .card-arrow {
  stroke: var(--ai-green);
  transform: translateX(4px);
}

/* ==========================================================================
   MÓDULO 1: VISUALIZAÇÃO AO VIVO
   ========================================================================== */
.live-layout {
  height: 100%;
  display: flex;
  position: relative;
  overflow: hidden;
}

/* Sidebar Esquerda */
.sidebar-devices {
  width: 290px;
  min-width: 290px;
  background: var(--bg-surface);
  border-right: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  transition: margin-left 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  z-index: 20;
}
.sidebar-devices.collapsed {
  margin-left: -290px;
  pointer-events: none;
}
.sidebar-header {
  height: 48px;
  padding: 0 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border-subtle);
}
.sidebar-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  font-size: 13px;
}
.sidebar-title svg {
  width: 16px;
  height: 16px;
  stroke: var(--ai-green);
}
.count-pill {
  font-size: 10.5px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-dim);
  padding: 1px 7px;
  border-radius: 10px;
}
.sidebar-toggle-btn {
  background: transparent;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  padding: 4px;
  display: flex;
  align-items: center;
  border-radius: 4px;
  transition: var(--transition);
}
.sidebar-toggle-btn svg { width: 16px; height: 16px; }
.sidebar-toggle-btn:hover { color: #fff; background: rgba(255, 255, 255, 0.06); }

.search-box {
  padding: 10px 14px;
  display: flex;
  align-items: center;
  gap: 8px;
  border-bottom: 1px solid var(--border-subtle);
  position: relative;
}
.search-icon {
  width: 14px;
  height: 14px;
  stroke: var(--text-dim);
  position: absolute;
  left: 24px;
  pointer-events: none;
}
.search-box input[type="search"] {
  flex: 1;
  height: 32px;
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 0 10px 0 30px;
  color: var(--text-main);
  font-size: 12px;
  outline: none;
}
.search-box input[type="search"]:focus {
  border-color: var(--border-focus);
}
.filter-verified-btn {
  height: 32px;
  width: 32px;
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  color: var(--text-dim);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.filter-verified-btn svg { width: 15px; height: 15px; }
.filter-verified-btn.active { color: var(--ai-green); border-color: var(--ai-green); }

.device-tree-container {
  flex: 1;
  overflow-y: auto;
  padding: 8px 6px;
}
.tree-group { margin-bottom: 8px; }
.tree-node-root {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  color: var(--text-muted);
  font-size: 11.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  cursor: pointer;
}
.tree-node-root .node-icon { width: 13px; height: 13px; stroke: var(--text-dim); }
.tree-node-root .tree-add-btn { margin-left: auto; cursor: pointer; }
.tree-children { list-style: none; padding-left: 12px; margin: 2px 0 0 0; }
.tree-children li { margin: 1px 0; }

/* Recolhimento real de câmeras por DVR */
ul.tree-children:not(.open):not(#treeDevices):not(#treeCustom) {
  display: none !important;
}

/* Ações rápidas de recolher/expandir todas as câmeras */
.tree-quick-collapse-actions {
  display: flex;
  gap: 6px;
  padding: 6px 12px 8px 12px;
  border-bottom: 1px solid var(--border-subtle);
}
.btn-tree-mini-action {
  flex: 1;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-subtle);
  color: var(--text-muted);
  border-radius: var(--radius-sm);
  padding: 5px 6px;
  font-size: 11px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  cursor: pointer;
  transition: var(--transition);
}
.btn-tree-mini-action:hover {
  background: rgba(150, 213, 7, 0.12);
  color: var(--ai-green);
  border-color: rgba(150, 213, 7, 0.35);
}
.btn-tree-mini-action svg {
  width: 13px;
  height: 13px;
}

/* Abas flutuantes de reabertura para sidebars recolhidas */
.sidebar-reopen-tab {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  background: var(--bg-surface);
  border: 1px solid var(--border-medium);
  color: var(--text-muted);
  display: none;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  z-index: 50;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.7);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.5px;
  transition: var(--transition);
}
.sidebar-reopen-tab:hover {
  background: var(--bg-card-hover);
  color: var(--ai-green);
  border-color: var(--ai-green);
}
.sidebar-reopen-tab.left {
  left: 0;
  border-left: none;
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
  padding: 12px 8px;
  flex-direction: column;
}
.sidebar-reopen-tab.right {
  right: 0;
  border-right: none;
  border-radius: var(--radius-md) 0 0 var(--radius-md);
  padding: 12px 8px;
  flex-direction: column;
}
.sidebar-reopen-tab span {
  writing-mode: vertical-lr;
  text-orientation: mixed;
  margin-top: 4px;
}
.sidebar-reopen-tab svg {
  width: 14px;
  height: 14px;
}

.tree-dev-item {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 8px;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  cursor: pointer;
  font-size: 12px;
}
.tree-dev-item:hover { background: var(--bg-card); color: #fff; }
.tree-chan-list { list-style: none; padding-left: 14px; margin: 2px 0; }
.tree-chan-item {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  color: var(--text-dim);
  font-size: 11.5px;
  cursor: pointer;
}
.tree-chan-item:hover { background: rgba(255, 255, 255, 0.05); color: #fff; }
.tree-chan-item.open { color: var(--ai-green); background: rgba(16, 185, 129, 0.08); font-weight: 600; }
.tree-chan-item .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--text-dim); }
.tree-chan-item.has-signal .dot { background: var(--ai-green); box-shadow: 0 0 6px var(--ai-green-glow); }

/* Workspace Central de Vídeo */
.workspace-center {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: var(--bg-base);
  position: relative;
  overflow: hidden;
}

.control-toolbar {
  height: var(--toolbar-height);
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 14px;
  gap: 10px;
  z-index: 10;
}
.tool-section { display: flex; align-items: center; gap: 8px; }
.tool-label { font-size: 9px; font-weight: 800; color: var(--text-dim); letter-spacing: 0.5px; }

.btn-group {
  display: inline-flex;
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 2px;
}
.layout-btn {
  background: transparent;
  border: none;
  color: var(--text-dim);
  height: 28px;
  width: 30px;
  border-radius: 3px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: var(--transition);
}
.layout-btn svg { width: 14px; height: 14px; }
.layout-btn:hover { color: #fff; }
.layout-btn.active { background: var(--bg-card-hover); color: var(--ai-green); }

.clean-select {
  height: 32px;
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  color: var(--text-main);
  padding: 0 10px;
  font-size: 12px;
  outline: none;
  cursor: pointer;
}
.tool-icon-btn {
  height: 32px;
  width: 32px;
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
}
.tool-icon-btn svg { width: 15px; height: 15px; }
.tool-icon-btn:hover { background: var(--bg-card-hover); color: #fff; }

/* Botão Central IA Visual Master */
.center-highlight { margin: 0 auto; }
.ai-toggle-master {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-subtle);
  height: 34px;
  padding: 0 14px;
  border-radius: 20px;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  transition: var(--transition);
}
.ai-toggle-master .ai-toggle-icon-wrap {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.08);
}
.ai-toggle-master svg { width: 13px; height: 13px; stroke: var(--text-dim); }
.ai-toggle-text { display: flex; flex-direction: column; text-align: left; }
.ai-toggle-tag { font-size: 8.5px; font-weight: 800; letter-spacing: 0.6px; color: var(--text-dim); }
.ai-toggle-state { font-size: 11px; font-weight: 700; color: var(--text-muted); }

.ai-toggle-master.on {
  background: rgba(16, 185, 129, 0.12);
  border-color: rgba(16, 185, 129, 0.4);
  box-shadow: 0 0 16px rgba(16, 185, 129, 0.15);
}
.ai-toggle-master.on .ai-toggle-icon-wrap { background: var(--ai-green); }
.ai-toggle-master.on svg { stroke: #000; }
.ai-toggle-master.on .ai-toggle-tag { color: var(--ai-green); }
.ai-toggle-master.on .ai-toggle-state { color: #fff; }

.right-aligned { margin-left: auto; }
.system-status-indicator { font-size: 11px; color: var(--text-dim); padding: 0 6px; }

/* Video Grid */
.video-grid-container {
  flex: 1;
  position: relative;
  overflow: hidden;
  background: #000;
}
.grid {
  position: relative;
  width: 100%;
  height: 100%;
  display: grid;
  gap: 2px;
  background: var(--bg-base);
  padding: 2px;
}
.grid.layout-1  { grid-template-columns: 1fr; grid-template-rows: 1fr; }
.grid.layout-4  { grid-template-columns: repeat(2, 1fr); grid-template-rows: repeat(2, 1fr); }
.grid.layout-9  { grid-template-columns: repeat(3, 1fr); grid-template-rows: repeat(3, 1fr); }
.grid.layout-16 { grid-template-columns: repeat(4, 1fr); grid-template-rows: repeat(4, 1fr); }
.grid.layout-25 { grid-template-columns: repeat(5, 1fr); grid-template-rows: repeat(5, 1fr); }
.grid.layout-32 { grid-template-columns: repeat(8, 1fr); grid-template-rows: repeat(4, 1fr); gap: 2px; }
@media (max-width: 1400px) {
  .grid.layout-32 { grid-template-columns: repeat(6, 1fr); grid-template-rows: repeat(6, 1fr); }
}

/* Modo Scroll Vertical (Expedição / Telas com Múltiplas Câmeras) */
.video-grid-container.scrollable {
  overflow-y: auto !important;
  overflow-x: hidden !important;
  height: 100%;
  scrollbar-width: thin;
  scrollbar-color: var(--ai-green) var(--bg-card);
}
.video-grid-container.scrollable::-webkit-scrollbar {
  width: 8px;
}
.video-grid-container.scrollable::-webkit-scrollbar-track {
  background: var(--bg-card);
}
.video-grid-container.scrollable::-webkit-scrollbar-thumb {
  background: var(--ai-green);
  border-radius: 4px;
}
.grid.scroll-grid {
  height: auto !important;
  min-height: 100%;
  grid-template-columns: repeat(4, 1fr) !important;
  grid-auto-rows: minmax(220px, auto) !important;
  gap: 6px !important;
  padding: 8px !important;
  padding-bottom: 60px !important;
}
.grid.scroll-grid > .tile {
  min-height: 220px !important;
  height: auto !important;
  aspect-ratio: 16 / 9;
}
@media (max-width: 1100px) {
  .grid.scroll-grid {
    grid-template-columns: repeat(2, 1fr) !important;
  }
}
@media (max-width: 700px) {
  .grid.scroll-grid {
    grid-template-columns: 1fr !important;
  }
}

/* Otimização de Câmeras em Scroll (Desconexão e Pausa Fora de Tela) */
.tile.tile-paused-offscreen {
  background: #090d16;
}
.tile.tile-paused-offscreen img,
.tile.tile-paused-offscreen video {
  filter: brightness(0.7) contrast(0.9);
}
.tile.tile-paused-offscreen .tile-status {
  display: flex !important;
  opacity: 1 !important;
  background: rgba(10, 15, 29, 0.88) !important;
  backdrop-filter: blur(4px);
  color: var(--text-muted) !important;
  font-size: 11px;
}

/* MODO PERSISTÊNCIA (SEGUIR PESSOA ENTRE CÂMERAS) */
.persist-toggle-btn {
  background: rgba(6, 182, 212, 0.08);
  border: 1px solid rgba(6, 182, 212, 0.3);
  margin-right: 6px;
}
.persist-toggle-btn:hover {
  background: rgba(6, 182, 212, 0.16);
  border-color: rgba(6, 182, 212, 0.6);
}
.persist-toggle-btn.on {
  background: rgba(6, 182, 212, 0.22);
  border-color: #06b6d4;
  box-shadow: 0 0 14px rgba(6, 182, 212, 0.35);
}
.persist-toggle-btn.on .ai-toggle-tag {
  color: #06b6d4;
}
.persist-toggle-btn.on .ai-toggle-state {
  color: #fff;
}
.tile.persistencia-foco {
  box-shadow: 0 0 0 3px #06b6d4, 0 0 18px rgba(6, 182, 212, 0.5) !important;
  border-radius: 4px;
  z-index: 5;
}
.badge-persist {
  background: #06b6d4;
  color: #000;
  font-weight: 800;
  font-size: 10px;
  padding: 1px 6px;
  border-radius: 3px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  display: inline-flex;
  align-items: center;
  gap: 3px;
  margin-left: 6px;
  animation: pulse-persist 1.5s infinite;
}
@keyframes pulse-persist {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.85; transform: scale(1.04); }
}

.layout-btn .btn-sub-label {
  font-size: 9px;
  font-weight: 700;
  margin-left: 2px;
}

/* AUTOMATICO: blocos 2x2 por DVR lado a lado (posicao de cada tile via JS) */
.grid.auto-dvr {
  grid-template-columns: repeat(4, 1fr);
  grid-template-rows: repeat(var(--auto-linhas, 2), 1fr);
  gap: 3px;
}
.grid.auto-dvr > .tile { min-height: 0; }
.dvr-grupo {
  position: relative;
  z-index: 8;
  pointer-events: none;
  border: 2px solid rgba(255, 255, 255, 0.16);
  border-radius: var(--radius-sm);
}
.dvr-grupo.com-pessoa { border-color: rgba(150, 213, 7, 0.75); }
.dvr-grupo-nome, .dvr-grupo-info {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  white-space: nowrap;
  font-size: 11px;
  padding: 2px 9px;
  border-radius: 0 0 6px 6px;
  background: rgba(8, 10, 12, 0.85);
}
.dvr-grupo-info { bottom: 0; border-radius: 6px 6px 0 0; color: var(--text-dim); }
.dvr-grupo-info b { color: #fff; font-weight: 700; }
.dvr-grupo.com-pessoa .dvr-grupo-info { color: #96d507; }

/* camera com zona de EXPEDICAO: moldura ambar + selo; com pessoa, mais forte */
.tile.exp-zona { box-shadow: inset 0 0 0 2px rgba(245, 158, 11, 0.75); }
.tile.exp-zona::after {
  content: "EXPEDIÇÃO";
  position: absolute;
  left: 8px;
  bottom: 6px;
  z-index: 6;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .06em;
  color: #111;
  background: #f59e0b;
  padding: 1px 6px;
  border-radius: 4px;
  pointer-events: none;
}
/* Automatico: por que esta camera esta na tela */
.tile-motivo {
  position: absolute;
  left: 8px;
  bottom: 6px;
  z-index: 6;
  font-size: 10px;
  font-weight: 600;
  color: #cbd5e1;
  background: rgba(0, 0, 0, 0.75);
  border: 1px solid rgba(255, 255, 255, 0.12);
  padding: 1px 6px;
  border-radius: 4px;
  pointer-events: none;
}
.tile-motivo[data-tipo="pessoa"] { color: #111; background: #96d507; border-color: transparent; }
.tile.exp-zona .tile-motivo { bottom: 26px; }
.tile.exp-pessoa { box-shadow: inset 0 0 0 3px #f59e0b, 0 0 14px rgba(245, 158, 11, 0.55); }
.tile.tem-pessoa:not(.exp-zona) { box-shadow: inset 0 0 0 2px rgba(150, 213, 7, 0.6); }

.tile {
  position: relative;
  background: #000;
  overflow: hidden;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(255, 255, 255, 0.05);
  display: flex;
  align-items: center;
  justify-content: center;
}
.tile.active-focus {
  border-color: rgba(16, 185, 129, 0.6);
  box-shadow: inset 0 0 0 1px rgba(16, 185, 129, 0.4);
}
.tile.maximized {
  position: absolute !important;
  top: 0 !important;
  left: 0 !important;
  width: 100% !important;
  height: 100% !important;
  z-index: 50 !important;
  border-radius: 0 !important;
  border: none !important;
}
.tile img, .tile video.tile-video {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
  transition: transform 0.2s ease-in-out;
}
.tile video.tile-video[hidden] { display: none; }
.tile-ai {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 4;
  transition: transform 0.2s ease-in-out;
}
/* Rotacao e orientacao de cameras */
.tile.rotated-90 img, .tile.rotated-90 video.tile-video, .tile.rotated-90 .tile-ai {
  transform: rotate(90deg);
}
.tile.rotated-180 img, .tile.rotated-180 video.tile-video, .tile.rotated-180 .tile-ai {
  transform: rotate(180deg);
}
.tile.rotated-270 img, .tile.rotated-270 video.tile-video, .tile.rotated-270 .tile-ai {
  transform: rotate(270deg);
}
.tile.tile-editing-zones {
  outline: 2px solid var(--ai-green);
  box-shadow: 0 0 20px rgba(16, 185, 129, 0.35);
}
.tile.tile-editing-zones .tile-ai {
  pointer-events: auto;
  cursor: crosshair;
  z-index: 10;
}
.tile-head {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 28px;
  background: linear-gradient(180deg, rgba(0, 0, 0, 0.8) 0%, transparent 100%);
  display: flex;
  align-items: center;
  padding: 0 8px;
  gap: 6px;
  z-index: 8;
  opacity: 0.85;
  transition: opacity 0.15s;
}
.tile:hover .tile-head { opacity: 1; }
.tile-head .ttl {
  font-size: 11px;
  font-weight: 600;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.tile-head .sp { margin-left: auto; display: flex; gap: 3px; }
.tile-head .mini {
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: #cbd5e1;
  width: 22px;
  height: 22px;
  border-radius: 3px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 10px;
}
.tile-head .mini:hover { background: rgba(255, 255, 255, 0.2); color: #fff; }
.tile-badge {
  position: absolute;
  bottom: 6px;
  right: 8px;
  z-index: 6;
  font-size: 9px;
  color: #cbd5e1;
  background: rgba(0, 0, 0, 0.75);
  border: 1px solid rgba(255, 255, 255, 0.1);
  padding: 2px 6px;
  border-radius: 3px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.tile-badge .badge-res {
  font-weight: 700;
  padding: 1px 4px;
  border-radius: 2px;
  font-size: 8.5px;
  line-height: 1.1;
  letter-spacing: 0.3px;
}
.tile-badge .badge-res.hd {
  color: #022c22;
  background: #34d399;
}
.tile-badge .badge-res.sd {
  color: #94a3b8;
  background: rgba(255, 255, 255, 0.12);
}
/* grade em ~720p (fluxo principal limitado); classe "720p" comeca com digito,
   por isso o seletor de atributo em vez de .720p */
.tile-badge .badge-res[class~="720p"] {
  color: #e0f2fe;
  background: #0369a1;
}
.tile-status {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 7;
  display: none;
  font-size: 11.5px;
  color: #e2e8f0;
  background: rgba(13, 15, 18, 0.88);
  border: 1px solid var(--border-medium);
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  pointer-events: none;
}
.tile-status.show { display: block; }
.tile-status.err  { color: #fca5a5; border-color: rgba(239, 68, 68, 0.4); }

.empty-state-card {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  pointer-events: none;
}
.empty-icon-wrap {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 12px;
}
.empty-icon-wrap svg { width: 24px; height: 24px; stroke: var(--text-dim); }

/* Sidebar Direita: Detecções ao Vivo */
.sidebar-detections {
  width: 310px;
  min-width: 310px;
  background: var(--bg-surface);
  border-left: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  transition: margin-right 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  z-index: 20;
}
.sidebar-detections.collapsed {
  margin-right: -310px;
  pointer-events: none;
}
.detections-header {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.det-title-row { display: flex; align-items: center; gap: 8px; }
.det-radar-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--ai-green);
  box-shadow: 0 0 8px var(--ai-green);
  animation: pulse-live 1.5s infinite ease-in-out;
}
.det-title { font-size: 13px; font-weight: 700; }
.det-counters-strip { display: flex; gap: 8px; }
.det-counter-pill {
  flex: 1;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 5px 8px;
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-weight: 600;
}
.det-counter-pill svg { width: 13px; height: 13px; stroke: var(--ai-green); }
.detections-feed-list {
  flex: 1;
  overflow-y: auto;
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.detections-empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 40px 16px;
  color: var(--text-dim);
  gap: 6px;
}
.detections-empty-state svg { width: 28px; height: 28px; stroke: var(--text-dim); opacity: 0.5; }

.det-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 8px 10px;
  display: flex;
  gap: 10px;
  cursor: pointer;
  transition: var(--transition);
}
.det-card:hover {
  background: var(--bg-card-hover);
  border-color: var(--border-medium);
  transform: translateY(-1px);
}
.det-card-thumb {
  width: 50px;
  height: 50px;
  border-radius: var(--radius-sm);
  background: #000;
  object-fit: cover;
  flex-shrink: 0;
  border: 1px solid rgba(255, 255, 255, 0.1);
}
.det-card-body { flex: 1; min-width: 0; display: flex; flex-direction: column; justify-content: center; }
.det-card-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 2px; }
.det-badge-tag {
  font-size: 8.5px;
  font-weight: 800;
  text-transform: uppercase;
  padding: 1px 6px;
  border-radius: 3px;
  letter-spacing: 0.4px;
}
.badge-person  { background: rgba(16, 185, 129, 0.15); color: #34d399; }
.badge-vehicle { background: rgba(59, 130, 246, 0.15); color: #60a5fa; }
.badge-cargo   { background: rgba(245, 158, 11, 0.15); color: #fbbf24; }
.badge-alert   { background: rgba(239, 68, 68, 0.2);  color: #f87171; }
.det-card-time { font-size: 10px; color: var(--text-dim); }
.det-card-title{ font-size: 12px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.det-card-desc { font-size: 11px; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Rodapé PTZ */
.footer-ptz-bar {
  height: 64px;
  background: var(--bg-surface);
  border-top: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  padding: 0 16px;
}
.ptz-compact-panel { display: flex; align-items: center; gap: 16px; }
.ptz-title { font-size: 12px; font-weight: 600; color: var(--text-muted); display: flex; align-items: center; gap: 6px; }
.ptz-controls-wrap { display: flex; align-items: center; gap: 16px; }
.ptz-dpad { display: flex; flex-direction: column; align-items: center; gap: 2px; }
.ptz-row { display: flex; gap: 2px; }
.ptz-btn {
  width: 24px;
  height: 22px;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: 3px;
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.ptz-btn svg { width: 12px; height: 12px; }
.ptz-btn:hover { background: var(--bg-card-hover); color: #fff; }
.ptz-stop { color: var(--ai-red); }
.ptz-zoom-group { display: flex; gap: 6px; }
.zoom-btn { width: auto; padding: 0 8px; font-size: 11px; gap: 4px; }

/* ==========================================================================
   MÓDULO 2: REPRODUÇÃO REMOTA (PLAYBACK)
   ========================================================================== */
.playback-container {
  height: 100%;
  display: flex;
  flex-direction: column;
  background: var(--bg-base);
}
.playback-header-bar {
  height: 52px;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  padding: 0 18px;
  gap: 16px;
}
.pb-filter-group {
  display: flex;
  align-items: center;
  gap: 6px;
}
.pb-filter-group label {
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text-dim);
  display: flex;
  align-items: center;
  gap: 4px;
}
.pb-filter-group label svg { width: 13px; height: 13px; }
.pb-status-text {
  margin-left: auto;
  font-size: 12px;
  color: var(--text-dim);
}

.playback-video-viewport {
  flex: 1;
  background: #000;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
}
.pb-screen-box {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  background: #000;
  border-radius: var(--radius-sm);
  overflow: hidden;
}
.pb-video-placeholder {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: var(--text-dim);
  gap: 12px;
  text-align: center;
  padding: 20px;
  background: #000;
  z-index: 2;
}
.pb-video-placeholder svg { width: 48px; height: 48px; stroke: var(--text-dim); }
.pb-player-video {
  max-width: 100%;
  max-height: 100%;
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #000;
}
.pb-loading-spin {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  color: var(--text-main);
}
.pb-loading-spin .spinner {
  width: 32px;
  height: 32px;
  border: 3px solid rgba(255, 255, 255, 0.1);
  border-top-color: var(--ai-green);
  border-radius: 50%;
  animation: pb-spin 0.8s linear infinite;
}
@keyframes pb-spin {
  to { transform: rotate(360deg); }
}

/* Timeline 24h */
.playback-timeline-bar {
  background: var(--bg-surface);
  border-top: 1px solid var(--border-subtle);
  padding: 12px 18px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.pb-controls-row {
  display: flex;
  align-items: center;
  gap: 10px;
}
.pb-ctrl-btn {
  height: 32px;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  color: #fff;
  padding: 0 12px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  font-weight: 600;
}
.pb-ctrl-btn svg { width: 14px; height: 14px; }
.pb-ctrl-btn:hover { background: var(--bg-card-hover); border-color: var(--border-medium); }
.pb-time-display {
  font-size: 13px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--ai-green);
  padding: 0 8px;
}
.pb-speed-group {
  display: flex;
  gap: 4px;
}
.pb-speed-btn {
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  color: var(--text-dim);
  padding: 4px 8px;
  border-radius: 3px;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
}
.pb-speed-btn.active {
  background: var(--bg-card-hover);
  color: var(--ai-green);
  border-color: var(--ai-green);
}

.timeline-ruler-container {
  display: flex;
  flex-direction: column;
  gap: 4px;
  user-select: none;
  padding-top: 14px;
}
.timeline-track {
  height: 38px;
  background: #090b0e;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  position: relative;
  cursor: pointer;
  user-select: none;
  transition: border-color 0.15s;
}
.timeline-track:hover,
.timeline-track.dragging {
  cursor: ew-resize;
  border-color: rgba(255, 255, 255, 0.25);
}
.timeline-segment-rec {
  position: absolute;
  top: 6px;
  bottom: 6px;
  background: rgba(16, 185, 129, 0.35);
  border-radius: 2px;
  border-left: 2px solid var(--ai-green);
  border-right: 2px solid var(--ai-green);
  pointer-events: none;
  z-index: 1;
}
.timeline-ai-event {
  position: absolute;
  top: 3px;
  bottom: 3px;
  background: #f59e0b;
  border-radius: 2px;
  box-shadow: 0 0 8px rgba(245, 158, 11, 0.7);
  z-index: 3;
  cursor: pointer;
  transition: transform 0.15s, background 0.15s;
}
.timeline-ai-event:hover {
  background: #ef4444;
  transform: scaleY(1.15);
  box-shadow: 0 0 10px rgba(239, 68, 68, 0.9);
}
.timeline-cursor {
  position: absolute;
  top: -6px;
  bottom: -2px;
  width: 2px;
  background: #ef4444;
  z-index: 10;
  pointer-events: none;
  box-shadow: 0 0 8px rgba(239, 68, 68, 0.9);
}
.cursor-flag {
  position: absolute;
  top: -20px;
  left: 50%;
  transform: translateX(-50%);
  background: #ef4444;
  color: #fff;
  font-size: 10px;
  font-weight: 800;
  padding: 2px 6px;
  border-radius: 3px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.6);
  white-space: nowrap;
  pointer-events: none;
}
.timeline-hours-ticks {
  display: flex;
  justify-content: space-between;
  font-size: 10px;
  color: var(--text-dim);
  padding: 0 2px;
}

/* ==========================================================================
   MÓDULO 3: CENTRAL DE EVENTOS (AUDITORIA)
   ========================================================================== */
.events-view-container {
  height: 100%;
  display: flex;
  flex-direction: column;
  padding: 20px 24px;
  background: var(--bg-base);
}
.events-filter-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}
.events-scroll-area {
  flex: 1;
  overflow-y: auto;
}
.exp-events-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}
.exp-event-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: var(--transition);
}
.exp-event-card:hover {
  background: var(--bg-card-hover);
  border-color: var(--border-medium);
  transform: translateY(-2px);
}
.exp-card-thumb-wrap {
  width: 100%;
  height: 145px;
  background: #000;
  overflow: hidden;
  cursor: pointer;
}
.exp-card-thumb-wrap img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.exp-card-body {
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.exp-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.exp-card-title {
  font-size: 13px;
  font-weight: 700;
}
.exp-card-meta {
  font-size: 11px;
  color: var(--text-dim);
}
.exp-card-actions {
  display: flex;
  gap: 6px;
  margin-top: 8px;
}
.exp-card-actions button {
  flex: 1;
  height: 28px;
  font-size: 11px;
  font-weight: 600;
}

.exp-badge {
  position: absolute;
  top: 8px;
  right: 8px;
  background: rgba(15, 23, 42, 0.85);
  color: #f1f5f9;
  padding: 3px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
  border: 1px solid rgba(255, 255, 255, 0.2);
  z-index: 2;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.5);
}
.exp-badge.carregando_na_expedicao, .exp-badge.carregando_prateleiras {
  background: rgba(220, 38, 38, 0.9);
  border-color: #ef4444;
  color: #fff;
}
.exp-badge.pessoa_na_expedicao, .exp-badge.pessoa_prateleiras {
  background: rgba(217, 119, 6, 0.9);
  border-color: #f59e0b;
  color: #fff;
}
.exp-badge.carregando_perto_veiculo, .exp-badge.veiculo_rapido {
  background: rgba(147, 51, 234, 0.9);
  border-color: #a855f7;
  color: #fff;
}

/* ==========================================================================
   MÓDULO 4: CONFIGURAÇÃO DE IA (CANVAS-FIRST)
   ========================================================================== */
.aiconfig-layout {
  height: 100%;
  display: flex;
}
.canvas-workspace-area {
  flex: 1;
  background: #000;
  display: flex;
  flex-direction: column;
  position: relative;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.canvas-floating-toolbar {
  position: absolute;
  top: 16px;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(13, 17, 23, 0.94);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: var(--radius-md);
  padding: 6px 12px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.7);
}
.float-tool-btn {
  background: #1e293b;
  border: 1px solid #334155;
  color: var(--text-muted);
  height: 30px;
  padding: 0 10px;
  border-radius: var(--radius-sm);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11.5px;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
}
.float-tool-btn:hover { background: #334155; color: #fff; }
.float-tool-btn.active-exp.active {
  background: rgba(46, 204, 113, 0.2);
  border-color: #2ecc71;
  color: #2ecc71;
}
.float-tool-btn.active-vei.active {
  background: rgba(52, 152, 219, 0.2);
  border-color: #3498db;
  color: #3498db;
}
.float-tool-sep {
  width: 1px;
  height: 18px;
  background: rgba(255, 255, 255, 0.14);
  margin: 0 4px;
}
.btn-danger-action {
  color: #f87171 !important;
  border-color: #7f1d1d !important;
}

.canvas-viewport {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}
.canvas-viewport canvas {
  max-width: 100%;
  max-height: calc(100vh - 180px);
  box-shadow: 0 0 30px rgba(0, 0, 0, 0.8);
  border-radius: 4px;
}
.canvas-overlay-loading {
  position: absolute;
  color: var(--text-dim);
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.canvas-instructions-bar {
  width: 100%;
  background: rgba(0, 0, 0, 0.7);
  padding: 8px 16px;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11.5px;
  color: var(--text-muted);
  border-top: 1px solid var(--border-subtle);
}
.canvas-instructions-bar svg { width: 14px; height: 14px; stroke: var(--ai-green); }

.calibration-settings-card {
  width: 320px;
  background: var(--bg-surface);
  border-left: 1px solid var(--border-subtle);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.card-section-title {
  font-size: 13px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border-subtle);
}
.card-section-title svg { width: 14px; height: 14px; stroke: var(--ai-green); }
.zona-status-badge {
  font-size: 11px;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  color: var(--text-dim);
  display: inline-block;
  margin-top: 4px;
}
.zona-status-badge.active {
  background: rgba(16, 185, 129, 0.12);
  border-color: rgba(16, 185, 129, 0.3);
  color: var(--ai-green);
  font-weight: 600;
}
.checkbox-row-group { display: flex; flex-direction: column; gap: 8px; margin-top: 4px; }
.clean-checkbox { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--text-muted); cursor: pointer; }
.clean-checkbox input { accent-color: var(--ai-green); }
.sensitivity-slider-wrap { display: flex; flex-direction: column; gap: 6px; }
.clean-range { accent-color: var(--ai-green); width: 100%; }
.range-labels { display: flex; justify-content: space-between; font-size: 10px; color: var(--text-dim); }
.card-spacer { flex: 1; }
.card-action-buttons { display: flex; flex-direction: column; gap: 8px; }

/* ==========================================================================
   MÓDULO 5: DISPOSITIVOS (HARDWARE & REDE)
   ========================================================================== */
.devices-mgmt-container {
  height: 100%;
  display: flex;
  flex-direction: column;
  padding: 24px 32px;
  overflow-y: auto;
}
.mgmt-header-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 20px;
}
.mgmt-title-group h2 { font-size: 20px; font-weight: 700; letter-spacing: -0.3px; margin-bottom: 4px; }
.mgmt-title-group p  { font-size: 13px; color: var(--text-dim); }
.mgmt-actions-group  { display: flex; gap: 8px; }

.devices-table-wrap {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  overflow: hidden;
}
.clean-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 12.5px;
}
.clean-table th {
  background: rgba(255, 255, 255, 0.02);
  border-bottom: 1px solid var(--border-subtle);
  padding: 12px 16px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-dim);
  letter-spacing: 0.5px;
}
.clean-table td {
  padding: 12px 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
  color: var(--text-muted);
}
.clean-table tr:hover td {
  background: rgba(255, 255, 255, 0.02);
  color: var(--text-main);
}

/* ==========================================================================
   MÓDULO 6: REGRAS E AUTOMAÇÕES
   ========================================================================== */
.automations-container {
  padding: 24px 32px;
  overflow-y: auto;
}
.rules-cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(360px, 1fr));
  gap: 16px;
}
.rule-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.rule-card-header { display: flex; align-items: center; justify-content: space-between; }
.rule-tag {
  font-size: 9.5px;
  font-weight: 800;
  padding: 2px 7px;
  border-radius: 4px;
}
.tag-active { background: rgba(16, 185, 129, 0.15); color: var(--ai-green); }
.rule-name { font-size: 13.5px; font-weight: 700; color: var(--text-main); }
.rule-flow {
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.flow-step { display: flex; gap: 8px; font-size: 12px; }
.flow-label { font-size: 9.5px; font-weight: 800; color: var(--ai-green); padding: 1px 4px; }
.step-then .flow-label { color: var(--ai-cyan); }
.flow-arrow { width: 14px; height: 14px; stroke: var(--text-dim); margin-left: 20px; }
.rule-card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 11px;
  color: var(--text-dim);
}
.rule-toggle-btn {
  background: rgba(16, 185, 129, 0.12);
  border: 1px solid rgba(16, 185, 129, 0.3);
  color: var(--ai-green);
  font-size: 11px;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 12px;
  cursor: pointer;
}

/* ==========================================================================
   MÓDULO 7: USUÁRIOS E GRUPOS
   ========================================================================== */
.users-container {
  padding: 24px 32px;
  overflow-y: auto;
}
.users-list-grid {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.user-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 16px 20px;
  display: flex;
  align-items: center;
  gap: 16px;
}
.user-avatar-big {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: #334155;
  color: #fff;
  font-size: 13px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}
.user-card-info h4 { font-size: 14px; font-weight: 700; margin-bottom: 2px; }
.user-card-info span { font-size: 12px; color: var(--text-dim); }
.user-permissions-strip { display: flex; gap: 6px; margin-top: 6px; }
.perm-pill {
  font-size: 10px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 10px;
}
.perm-pill.ok  { background: rgba(16, 185, 129, 0.12); color: var(--ai-green); }
.perm-pill.off { background: rgba(255, 255, 255, 0.05); color: var(--text-dim); }

/* ==========================================================================
   MÓDULO 8: SAÚDE DO SISTEMA (TELEMETRIA)
   ========================================================================== */
.health-container {
  padding: 24px 32px;
  overflow-y: auto;
}
.health-cards-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
}
.health-meter-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.meter-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.meter-top span { font-size: 12px; font-weight: 600; color: var(--text-dim); }
.meter-top b    { font-size: 16px; font-weight: 800; color: var(--text-main); }
.meter-bar-track {
  height: 6px;
  background: rgba(255, 255, 255, 0.06);
  border-radius: 3px;
  overflow: hidden;
}
.meter-bar-fill {
  height: 100%;
  background: var(--ai-blue);
  border-radius: 3px;
}
.meter-bar-fill.fill-green { background: var(--ai-green); }
.meter-bar-fill.fill-amber { background: var(--ai-amber); }
.health-meter-card small { font-size: 11px; color: var(--text-dim); }

/* ==========================================================================
   MODAIS & FORM CONTROLS
   ========================================================================== */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.78);
  backdrop-filter: blur(8px);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.modal-surface {
  background: var(--bg-surface);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-lg);
  box-shadow: 0 24px 50px rgba(0, 0, 0, 0.85);
  display: flex;
  flex-direction: column;
  max-height: 90vh;
  overflow: hidden;
}
.modal-compact { width: 480px; }
.modal-large   { width: 920px; }
.modal-lightbox-view { width: auto; max-width: 90vw; }

.modal-surface-header {
  padding: 14px 18px;
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.modal-heading-group { display: flex; align-items: center; gap: 10px; }
.modal-icon-badge {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  background: rgba(16, 185, 129, 0.12);
  display: flex;
  align-items: center;
  justify-content: center;
}
.modal-icon-badge svg { width: 17px; height: 17px; stroke: var(--ai-green); }
.modal-main-title { font-size: 14px; font-weight: 700; color: var(--text-main); }
.modal-sub-title  { font-size: 11px; color: var(--text-dim); display: block; }
.modal-close-icon {
  background: transparent;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  padding: 4px;
}
.modal-close-icon svg { width: 18px; height: 18px; }
.modal-close-icon:hover { color: #fff; }

.modal-surface-footer {
  padding: 12px 18px;
  border-top: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(0, 0, 0, 0.2);
}
.footer-hint { font-size: 11px; color: var(--text-dim); }
.footer-btn-group { display: flex; gap: 8px; }

.modal-form-scrollable {
  flex: 1;
  overflow-y: auto;
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.form-control-block { display: flex; flex-direction: column; gap: 6px; }
.form-control-block label { font-size: 11.5px; font-weight: 600; color: var(--text-muted); }
.form-control-row { display: flex; gap: 10px; }
.input-twin-row   { display: flex; gap: 8px; align-items: center; }
.form-buttons-row { display: flex; gap: 10px; }
.form-section-divider { display: flex; align-items: center; margin: 12px 0 4px; }
.form-section-divider span { font-size: 10px; font-weight: 700; color: var(--text-dim); letter-spacing: 0.6px; }
.form-section-divider::after { content: ''; flex: 1; height: 1px; background: var(--border-subtle); margin-left: 10px; }
.form-helper-text { font-size: 11.5px; color: var(--text-dim); }
.form-status-msg  { font-size: 11.5px; color: var(--ai-green); }
.credentials-inner-list {
  max-height: 120px;
  overflow-y: auto;
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 6px;
}

.clean-input {
  height: 34px;
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 0 10px;
  color: #fff;
  font-size: 12px;
  outline: none;
  width: 100%;
}
.clean-input:focus { border-color: var(--border-focus); }

.btn-primary-action {
  height: 34px;
  background: var(--ai-green);
  color: #000;
  border: none;
  border-radius: var(--radius-sm);
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 14px;
  cursor: pointer;
  transition: var(--transition);
}
.btn-primary-action svg { width: 14px; height: 14px; }
.btn-primary-action:hover { background: #34d399; }

.btn-clean-secondary {
  height: 32px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-subtle);
  color: var(--text-muted);
  border-radius: var(--radius-sm);
  padding: 0 12px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  font-weight: 500;
}
.btn-clean-secondary svg { width: 14px; height: 14px; }
.btn-clean-secondary:hover { background: var(--bg-card-hover); color: #fff; }

.btn-secondary-danger {
  height: 32px;
  background: transparent;
  color: #f87171;
  border: 1px solid rgba(239, 68, 68, 0.3);
  border-radius: var(--radius-sm);
  font-size: 11px;
  font-weight: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  cursor: pointer;
}
.btn-secondary-danger:hover { background: rgba(239, 68, 68, 0.12); border-color: #ef4444; }

.lightbox-image-container {
  padding: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #000;
}
.lightbox-image-container img {
  max-width: 82vw;
  max-height: 78vh;
  object-fit: contain;
}

.toast-notification {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: rgba(13, 17, 23, 0.95);
  backdrop-filter: blur(10px);
  border: 1px solid var(--border-medium);
  color: #fff;
  padding: 10px 16px;
  border-radius: var(--radius-md);
  font-size: 12.5px;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.8);
  z-index: 200;
}

.spin {
  animation: spin-anim 1s infinite linear;
}
@keyframes spin-anim {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

/* =========================================================================
   AUTH GATE (LOGIN SCREEN)
   ========================================================================= */
.auth-gate-overlay {
  position: fixed;
  inset: 0;
  background: radial-gradient(circle at 50% 30%, #151a23 0%, #0a0d12 100%);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.auth-gate-card {
  width: 100%;
  max-width: 420px;
  background: rgba(19, 24, 32, 0.95);
  backdrop-filter: blur(16px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--radius-lg);
  padding: 36px 32px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.85), 0 0 1px 1px rgba(255, 255, 255, 0.05);
  animation: authCardIn 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes authCardIn {
  from { opacity: 0; transform: translateY(12px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.auth-brand-header {
  text-align: center;
  margin-bottom: 24px;
}

.auth-gate-logo-img {
  height: 40px;
  width: auto;
  max-width: 80%;
  margin: 0 auto 12px;
  display: block;
  object-fit: contain;
  filter: drop-shadow(0 2px 14px rgba(150, 213, 7, 0.22));
}

.auth-logo-badge {
  width: 48px;
  height: 48px;
  margin: 0 auto 14px;
  border-radius: 14px;
  background: linear-gradient(135deg, rgba(150, 213, 7, 0.15), rgba(56, 189, 248, 0.10));
  border: 1px solid rgba(150, 213, 7, 0.35);
  display: flex;
  align-items: center;
  justify-content: center;
}

.auth-logo-badge svg {
  width: 24px;
  height: 24px;
  stroke: var(--ai-green);
}

.auth-brand-header h2 {
  font-size: 22px;
  font-weight: 700;
  color: #fff;
  margin: 0 0 6px;
  letter-spacing: -0.02em;
}

.auth-sub-desc {
  font-size: 12px;
  color: var(--text-muted);
  margin: 0 0 12px;
}

.auth-tag-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  font-weight: 600;
  color: #38bdf8;
  background: rgba(56, 189, 248, 0.08);
  border: 1px solid rgba(56, 189, 248, 0.2);
  padding: 3px 10px;
  border-radius: 20px;
}

.auth-tag-pill svg {
  width: 12px;
  height: 12px;
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

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

.auth-input-group label {
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text-dim);
  display: flex;
  align-items: center;
  gap: 6px;
}

.auth-input-group label svg {
  width: 13px;
  height: 13px;
}

.auth-input-group input {
  height: 40px;
  background: #0f131a;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: var(--radius-sm);
  padding: 0 12px;
  color: #fff;
  font-size: 13px;
  outline: none;
  transition: var(--transition);
}

.auth-input-group input:focus {
  border-color: var(--ai-green);
  box-shadow: 0 0 0 2px rgba(16, 185, 129, 0.18);
}

.auth-error-alert {
  background: rgba(239, 68, 68, 0.12);
  border: 1px solid rgba(239, 68, 68, 0.35);
  color: #f87171;
  font-size: 12px;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
}

.auth-submit-btn {
  height: 42px;
  font-size: 13.5px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-top: 6px;
}

.auth-card-footer {
  text-align: center;
  margin-top: 20px;
  font-size: 11px;
  color: #64748b;
  line-height: 1.4;
}

/* =========================================================================
   DETECTION CARD ACTION BUTTONS
   ========================================================================= */
.det-card-actions {
  display: flex;
  gap: 6px;
  margin-top: 8px;
}

.btn-det-action {
  flex: 1;
  height: 28px;
  background: rgba(150, 213, 7, 0.12);
  border: 1px solid rgba(150, 213, 7, 0.35);
  color: var(--ai-green);
  border-radius: var(--radius-sm);
  font-size: 11px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  cursor: pointer;
  transition: var(--transition);
}

.btn-det-action:hover {
  background: var(--ai-green);
  color: #0b0f02;
}

.btn-det-action svg {
  width: 13px;
  height: 13px;
}

.btn-det-photo {
  background: rgba(255, 255, 255, 0.05);
  border-color: var(--border-subtle);
  color: var(--text-muted);
}

.btn-det-photo:hover {
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
}

/* =========================================================================
   MOBILE FIRST & RESPONSIVE DESIGN SYSTEM
   ========================================================================= */
.top-mobile-menu-btn {
  display: none;
  background: transparent;
  border: none;
  color: var(--text-main);
  padding: 6px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  align-items: center;
  justify-content: center;
  margin-right: 6px;
}

.top-mobile-menu-btn svg {
  width: 20px;
  height: 20px;
}

.mobile-drawer-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
  z-index: 100;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}

.mobile-drawer-backdrop.active {
  opacity: 1;
  pointer-events: auto;
}

/* Telas Médias e Tablets (<= 992px) */
@media (max-width: 992px) {
  .top-mobile-menu-btn {
    display: inline-flex;
  }
  .nav-breadcrumb {
    display: none;
  }
  .top-status-strip {
    overflow-x: auto;
    scrollbar-width: none;
    max-width: 44vw;
    gap: 4px;
  }
  .top-status-strip::-webkit-scrollbar {
    display: none;
  }
  .top-status-strip .status-pill span span {
    display: none;
  }
  .top-brand-right {
    display: none;
  }
  .live-layout {
    position: relative;
    overflow: hidden;
  }
  .sidebar-devices {
    position: fixed;
    top: var(--header-height);
    bottom: 0;
    left: 0;
    width: 280px;
    max-width: 82vw;
    z-index: 110;
    transform: translateX(-100%);
    transition: transform 0.28s cubic-bezier(0.16, 1, 0.3, 1);
    background: var(--bg-surface);
    box-shadow: 12px 0 30px rgba(0, 0, 0, 0.85);
  }
  .sidebar-devices.mobile-drawer-open {
    transform: translateX(0);
  }
  .sidebar-detections {
    position: fixed;
    top: var(--header-height);
    bottom: 0;
    right: 0;
    width: 310px;
    max-width: 86vw;
    z-index: 110;
    transform: translateX(100%);
    transition: transform 0.28s cubic-bezier(0.16, 1, 0.3, 1);
    background: var(--bg-surface);
    box-shadow: -12px 0 30px rgba(0, 0, 0, 0.85);
  }
  .sidebar-detections.mobile-drawer-open {
    transform: translateX(0);
  }
  .workspace-center {
    width: 100% !important;
  }
}

/* Telas Pequenas e Smartphones (<= 768px) */
@media (max-width: 768px) {
  :root {
    --header-height: 48px;
    --toolbar-height: auto;
  }

  /* Ajustes gerais de inputs em mobile para evitar auto-zoom iOS */
  input, select, textarea {
    font-size: 16px !important;
  }

  .topbar {
    padding: 0 10px;
  }
  .brand-logo-img {
    height: 18px;
  }
  .top-status-strip {
    max-width: 32vw;
  }
  .status-pill {
    padding: 2px 6px;
    font-size: 11px;
  }
  .status-pill span span {
    display: none;
  }
  .user-profile-pill span {
    display: none;
  }

  /* Dashboard Cards em 1 Coluna */
  .modules-grid-8 {
    grid-template-columns: 1fr;
    gap: 12px;
    padding: 12px;
  }
  .module-card {
    padding: 16px;
    min-height: 90px;
  }
  .dashboard-hero {
    margin-bottom: 16px;
    padding: 0 12px;
  }
  .dashboard-title {
    font-size: 20px;
  }

  /* Toolbar de Vídeo ao Vivo */
  .control-toolbar {
    flex-wrap: wrap;
    height: auto;
    padding: 8px 10px;
    gap: 8px;
  }
  .tool-section {
    flex-wrap: wrap;
    gap: 4px;
  }
  .layout-btn {
    min-width: 38px;
    height: 34px;
  }

  /* Reprodução Remota Mobile */
  .pb-top-filter-bar {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
    padding: 10px 12px;
    height: auto;
  }
  .pb-filter-group {
    flex-direction: column;
    align-items: stretch;
    gap: 6px;
    width: 100%;
  }
  .pb-filter-group select,
  .pb-filter-group input {
    width: 100%;
    height: 42px;
  }
  #btnPbSearch {
    height: 44px;
    width: 100%;
    margin-top: 4px;
  }
  .pb-osd-info-badge {
    margin-left: 0 !important;
    justify-content: center;
  }
  .pb-controls-row {
    flex-wrap: wrap;
    gap: 8px;
  }
  .pb-ctrl-btn {
    height: 42px;
    min-width: 48px;
  }
  .pb-time-display {
    font-size: 12px;
  }
  .timeline-track {
    height: 46px;
    touch-action: none;
  }
  .cursor-flag {
    top: -24px;
    font-size: 11px;
    padding: 3px 8px;
  }

  /* Modais e Telas de Auth */
  .auth-gate-card {
    padding: 24px 18px;
    max-width: 95vw;
  }
  .modal-surface {
    max-width: 95vw;
    max-height: 92vh;
    padding: 16px;
  }
  .lightbox-image-container {
    max-height: 60vh;
  }
  .modal-surface-footer {
    flex-wrap: wrap;
    gap: 8px;
  }
  .modal-surface-footer button,
  .modal-surface-footer a {
    width: 100%;
  }

  .floating-menu-btn {
    bottom: 14px;
    right: 14px;
    padding: 10px 16px;
    border-radius: 30px;
    font-size: 12px;
  }
}


/* Botão Prateleiras e Treinamento de IA de Varejo */
.float-tool-btn.active-pra.active {
  background: rgba(243, 156, 18, 0.2);
  border-color: #f39c12;
  color: #f39c12;
}

.retail-training-card {
  margin-top: 16px;
  background: #111827;
  border: 1px solid #1f2937;
  border-radius: var(--radius-md);
  padding: 14px;
}
.retail-training-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
}
.retail-training-header h4 {
  font-size: 13px;
  font-weight: 700;
  color: #fff;
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 0;
}
.retail-training-desc {
  font-size: 11px;
  color: var(--text-muted);
  line-height: 1.4;
  margin-bottom: 12px;
}
.training-stats-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  margin-bottom: 12px;
}
.train-stat-item {
  background: #1e293b;
  border: 1px solid #334155;
  border-radius: var(--radius-sm);
  padding: 6px 10px;
  display: flex;
  flex-direction: column;
}
.train-stat-item .lbl {
  font-size: 10px;
  color: var(--text-muted);
  text-transform: uppercase;
}
.train-stat-item .val {
  font-size: 13px;
  font-weight: 700;
  color: #e2e8f0;
}
.training-progress-container {
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.progress-bar-bg {
  flex: 1;
  height: 8px;
  background: #1e293b;
  border-radius: 4px;
  overflow: hidden;
}
.progress-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, #74C043, #2ecc71);
  transition: width 0.3s ease;
}
.train-progress-txt {
  font-size: 11px;
  font-weight: 700;
  color: #74C043;
}
.training-btn-row {
  display: flex;
  gap: 8px;
  margin-bottom: 8px;
}
.btn-training-action {
  flex: 1;
  height: 32px;
  background: #1e293b;
  border: 1px solid #334155;
  border-radius: var(--radius-sm);
  color: #e2e8f0;
  font-size: 11px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  cursor: pointer;
  transition: var(--transition);
}
.btn-training-action:hover {
  background: #334155;
  color: #fff;
}
.btn-training-action.btn-train-start {
  background: rgba(116, 192, 67, 0.15);
  border-color: #74C043;
  color: #74C043;
}
.btn-training-action.btn-train-start:hover {
  background: #74C043;
  color: #0b0f19;
}
.btn-training-action.btn-train-stop {
  background: rgba(239, 68, 68, 0.15);
  border-color: #ef4444;
  color: #ef4444;
}
.train-log-mini {
  font-size: 10px;
  color: var(--text-muted);
  font-family: monospace;
  background: #090d16;
  border: 1px solid #1e293b;
  border-radius: 4px;
  padding: 4px 8px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* acoes do DVR na lista: ⊞ abre todas as cameras (sempre visivel); ⚙/✕ no hover */
.tree-node .dev-actions { margin-left: auto; display: inline-flex; gap: 2px; flex-shrink: 0; }
.tree-node .dev-act {
  background: transparent; border: 1px solid transparent; color: var(--text-dim);
  font-size: 12px; line-height: 1; padding: 2px 5px; border-radius: 4px; cursor: pointer;
}
.tree-node .dev-act:not(.dev-open) { display: none; }
.tree-node:hover .dev-act:not(.dev-open),
.tree-node:focus-within .dev-act:not(.dev-open) { display: inline-block; }
/* tela de toque nao tem "passar o mouse": as acoes do DVR ficam sempre a mostra */
@media (hover: none) {
  .tree-node .dev-act:not(.dev-open) { display: inline-block; }
  .tree-node .dev-act { padding: 6px 9px; font-size: 14px; }
  .tile-head { opacity: 1; }
  .tile-head .mini { min-width: 30px; min-height: 26px; }
}
.tree-node .dev-act:hover { color: #fff; border-color: var(--border-medium); background: var(--bg-card-hover); }
.tree-node .dev-open { color: var(--ai-green); font-size: 14px; }

/* editor de telas */
.telas-editor { display: flex; gap: 14px; min-height: 360px; }
.telas-editor .te-lista { width: 200px; display: flex; flex-direction: column; gap: 4px; }
.telas-editor .te-item {
  text-align: left; padding: 7px 9px; border-radius: 6px; cursor: pointer;
  background: transparent; border: 1px solid var(--border-subtle); color: var(--text-main); font-size: 12px;
}
.telas-editor .te-item.ativo { border-color: var(--ai-green); background: rgba(16, 185, 129, 0.08); }
.telas-editor .te-corpo { flex: 1; display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.telas-editor .te-linha { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.telas-editor .te-cams { flex: 1; overflow-y: auto; max-height: 46vh; border: 1px solid var(--border-subtle); border-radius: 6px; }
.telas-editor .te-cam { display: flex; align-items: center; gap: 8px; padding: 5px 8px; border-bottom: 1px solid var(--border-subtle); font-size: 12px; }
.telas-editor .te-cam:last-child { border-bottom: none; }
.telas-editor .te-cam .te-pos { color: var(--text-dim); width: 22px; text-align: right; }
.telas-editor .te-cam .te-nome { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.telas-editor .te-cam .te-dvr { color: var(--text-dim); }
.telas-editor .te-cam .te-falta { color: #fca5a5; }
.telas-editor .te-cam button, .telas-editor .te-mini {
  background: transparent; border: 1px solid var(--border-subtle); color: var(--text-dim);
  border-radius: 4px; padding: 2px 7px; cursor: pointer; font-size: 12px;
}
.telas-editor .te-cam button:hover, .telas-editor .te-mini:hover { color: #fff; border-color: var(--border-medium); }
.telas-editor .te-vazio { padding: 14px; color: var(--text-dim); font-size: 12px; }
.tree-node { display: flex; align-items: center; gap: 5px; cursor: pointer; padding: 3px 4px; border-radius: 4px; }
.tree-node:hover { background: rgba(255, 255, 255, 0.04); }
.tree-node .ch-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ==========================================================================
   CARTAO DE ALERTA (2026-11-11) -- aba de alertas da expedicao.
   O HTML usa .exp-card/.exp-card-head/...; as regras antigas (.exp-event-card)
   nao batiam com ele e o cartao saia sem estilo.
   ========================================================================== */
.exp-events-grid { grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 14px; align-items: start; }
.exp-card {
  background: var(--bg-card); border: 1px solid var(--border-subtle); border-radius: var(--radius-lg);
  overflow: hidden; display: flex; flex-direction: column; transition: var(--transition);
}
.exp-card:hover { border-color: var(--border-focus); box-shadow: 0 8px 26px rgba(0, 0, 0, .35); }
.exp-card-thumb-wrap { position: relative; width: 100%; height: auto; aspect-ratio: 16 / 9; background: #000; cursor: zoom-in; }
.exp-card-thumb-wrap img { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform .25s ease; }
.exp-card:hover .exp-card-thumb-wrap img { transform: scale(1.03); }
.exp-card-thumb-wrap::after { content: ""; position: absolute; inset: auto 0 0 0; height: 46%; background: linear-gradient(transparent, rgba(10, 12, 16, .75)); pointer-events: none; }
.exp-card-zoom {
  position: absolute; right: 8px; bottom: 8px; z-index: 2; width: 28px; height: 28px; border-radius: 50%;
  display: grid; place-items: center; background: rgba(10, 12, 16, .7); border: 1px solid var(--border-medium);
  color: var(--text-main); opacity: 0; transition: var(--transition);
}
.exp-card:hover .exp-card-zoom { opacity: 1; }
.exp-card-zoom svg { width: 14px; height: 14px; }
.exp-badge {
  top: 10px; left: 10px; right: auto; padding: 4px 9px; border-radius: 999px; font-size: 10.5px; font-weight: 700;
  letter-spacing: .02em; background: rgba(10, 12, 16, .82); border: 1px solid var(--border-medium); box-shadow: none;
  backdrop-filter: blur(6px);
}
.exp-badge::before { content: ""; display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: currentColor; margin-right: 6px; vertical-align: 1px; }
.exp-badge.carregando_na_expedicao, .exp-badge.carregando_prateleiras, .exp-badge.passou_a_carregar,
.exp-badge.carregando_veiculo, .exp-badge.carregando_saida, .exp-badge.pessoa_carregando_objeto {
  background: rgba(239, 68, 68, .16); border-color: rgba(239, 68, 68, .55); color: #fca5a5;
}
.exp-badge.pessoa_na_expedicao, .exp-badge.pessoa_prateleiras, .exp-badge.presenca_gaiola, .exp-badge.veiculo_entrada {
  background: rgba(245, 158, 11, .16); border-color: rgba(245, 158, 11, .55); color: #fcd34d;
}
.exp-badge.carregando_perto_veiculo, .exp-badge.veiculo_rapido {
  background: rgba(168, 85, 247, .18); border-color: rgba(168, 85, 247, .6); color: #d8b4fe;
}
.exp-card-body { padding: 12px 14px 14px; display: flex; flex-direction: column; gap: 6px; }
.exp-card-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.exp-card-id { font-family: "JetBrains Mono", ui-monospace, monospace; font-size: 11px; font-weight: 600; color: var(--ai-green); background: var(--ai-green-subtle); border: 1px solid rgba(150, 213, 7, .22); padding: 1px 7px; border-radius: 999px; }
.exp-card-time { display: inline-flex; align-items: center; gap: 5px; font-size: 11.5px; color: var(--text-muted); font-variant-numeric: tabular-nums; }
.exp-card-time svg { width: 12px; height: 12px; }
.exp-card-title { font-size: 14px; font-weight: 700; line-height: 1.3; color: var(--text-main); }
.exp-card-desc { font-size: 12.5px; line-height: 1.45; color: var(--text-muted); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.exp-card-cam { display: flex; align-items: center; gap: 6px; font-size: 11.5px; color: var(--text-dim); padding-top: 8px; margin-top: 2px; border-top: 1px solid var(--border-subtle); min-width: 0; }
.exp-card-cam svg { width: 13px; height: 13px; flex-shrink: 0; }
.exp-card-cam span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.exp-card-actions { display: flex; align-items: center; gap: 6px; margin-top: 8px; }
.exp-card-actions .exp-act, .exp-card-actions button.exp-act {
  flex: 0 0 auto; height: 34px; min-width: 34px; padding: 0 9px; display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  background: var(--bg-surface); border: 1px solid var(--border-medium); border-radius: var(--radius-md);
  color: var(--text-muted); font: inherit; font-size: 12px; font-weight: 600; text-decoration: none; cursor: pointer; transition: var(--transition);
}
.exp-card-actions .exp-act:hover { background: var(--bg-card-hover); border-color: var(--border-focus); color: var(--text-main); }
.exp-card-actions .exp-act svg { width: 15px; height: 15px; flex-shrink: 0; }
.exp-card-actions .exp-act.principal, .exp-card-actions button.exp-act.principal { flex: 1 1 auto; background: var(--ai-green); border-color: var(--ai-green); color: #0a0c10; }
.exp-card-actions .exp-act.principal:hover { background: var(--ai-green-hover); border-color: var(--ai-green-hover); color: #0a0c10; }
.exp-empty { grid-column: 1 / -1; padding: 44px 20px; text-align: center; font-size: 13px; color: var(--text-muted); border: 1px dashed var(--border-medium); border-radius: var(--radius-lg); }

/* ==========================================================================
   ARRASTAR PARA REORDENAR (editor de telas e grade do hub)
   ========================================================================== */
.telas-editor .te-item, .telas-editor .te-cam { cursor: grab; user-select: none; }
.telas-editor .te-item:active, .telas-editor .te-cam:active { cursor: grabbing; }
.telas-editor .te-alca { color: var(--text-dim); margin-right: 7px; font-size: 13px; line-height: 1; }
.telas-editor .te-cam .te-alca { margin-right: 0; }
.telas-editor .arr-origem { opacity: .4; }
.telas-editor .te-item.arr-antes { box-shadow: inset 0 2px 0 var(--ai-green); }
.telas-editor .te-item.arr-depois { box-shadow: inset 0 -2px 0 var(--ai-green); }
.telas-editor .te-cam.arr-antes { box-shadow: inset 0 2px 0 var(--ai-green); background: var(--ai-green-subtle); }
.telas-editor .te-cam.arr-depois { box-shadow: inset 0 -2px 0 var(--ai-green); background: var(--ai-green-subtle); }
.tile-head { cursor: grab; }
.tile-head .mini { cursor: pointer; }
.tile.arr-origem { opacity: .45; }
.tile.arr-sobre { outline: 2px dashed var(--ai-green); outline-offset: -2px; }
.tile.arr-sobre::after { content: "Soltar aqui para trocar de lugar"; position: absolute; inset: 0; display: grid; place-items: center;
  background: rgba(150, 213, 7, .12); color: var(--ai-green); font-size: 12px; font-weight: 700; pointer-events: none; z-index: 30; }

/* TEXTO DE RESERVA DA IMAGEM (2026-11-11): enquanto a camera nao tem quadro, o
   navegador desenhava o "alt" (nome da camera) no canto do quadrado -- parecia um
   titulo duplicado e deslocado, e girado na camera com inclinacao. */
.tile > img { color: transparent; font-size: 0; }
.tile > img:not([src]), .tile > img[src=""] { visibility: hidden; }

/* GRADE COM ROLAGEM: QUADRADO CABE NA COLUNA (2026-11-11). A tela Expedicao usava
   min-height 220px + aspect-ratio 16/9 no quadrado: o navegador converte a altura
   minima em LARGURA minima (391px) e o quadrado vazava da coluna (243px) -- a
   ultima coluna sumia atras do painel de deteccoes. Agora a altura vem da largura. */
.grid.scroll-grid { grid-template-rows: none !important; grid-auto-rows: auto !important; align-content: start; }
.grid.scroll-grid > .tile { min-width: 0; min-height: 0 !important; height: auto !important; aspect-ratio: 16 / 9; }
.grid > .tile { min-width: 0; min-height: 0; }
