/* ==========================================================================
   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ÃO FLUTUANTE DE RETORNO AO MENU
   ========================================================================== */
.floating-menu-btn {
  position: fixed;
  bottom: 20px;
  left: 20px;
  z-index: 80;
  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;
}

/* ==========================================================================
   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; }

.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 {
  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); }

.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 img, .tile video.tile-video {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}
.tile video.tile-video[hidden] { display: none; }
.tile-ai {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 4;
}
.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;
}
.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 {
  display: flex;
  flex-direction: column;
  align-items: center;
  color: var(--text-dim);
  gap: 12px;
  text-align: center;
  padding: 20px;
}
.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;
}

/* ==========================================================================
   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;
}
