:root {
  /* ================== TOKENS DE CORES (THEME DARK PREMIUM) ================== */
  --color-bg-base: #0a0a0f;      /* Fundo principal escuro profundo */
  --color-bg-surface: #12121a;   /* Fundo de painéis e cards */
  --color-bg-elevated: #1a1a2e;  /* Fundo de popups e elementos elevados */
  
  --color-primary: #3b82f6;      /* Azul vibrante moderno */
  --color-primary-dim: rgba(59, 130, 246, 0.2);
  --color-primary-hover: #60a5fa;
  
  --color-danger: #ef4444;       /* Vermelho intenso */
  --color-danger-dim: rgba(239, 68, 68, 0.2);
  
  --color-success: #22c55e;      /* Verde vibrante */
  --color-warning: #f59e0b;      /* Amarelo alerta */

  --color-text-primary: #F0F0F5; /* Texto principal claro */
  --color-text-secondary: #888888; /* Texto secundário */
  --color-text-muted: #555555;     /* Texto desativado */

  --color-border: rgba(255, 255, 255, 0.08); /* Bordas translúcidas */
  --color-border-focus: #3b82f6;

  /* Aliases usados nos componentes */
  --color-surface: #12121a;        
  --color-surface-hover: #1a1a2e;  

  /* ================== TIPOGRAFIA ================== */
  --font-family-base: 'Inter', system-ui, -apple-system, sans-serif;
  --font-family-heading: 'Outfit', var(--font-family-base);
  
  /* ================== ESPAÇAMENTOS E BORDAS ================== */
  --spacing-xs: 4px;
  --spacing-sm: 8px;
  --spacing-md: 16px;
  --spacing-lg: 24px;
  --spacing-xl: 32px;
  
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-full: 9999px;

  /* ================== SOMBRAS E TRANSIÇÕES ================== */
  --shadow-sm: 0 2px 8px rgba(0,0,0,0.3);
  --shadow-md: 0 8px 24px rgba(0,0,0,0.4);
  --shadow-glow-primary: 0 4px 15px rgba(59, 130, 246, 0.3);
  --shadow-glow-danger: 0 4px 15px rgba(239, 68, 68, 0.3);
  
  --transition-fast: 0.15s ease;
  --transition-normal: 0.25s ease;
}

/* ================== RESET BÁSICO ================== */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  user-select: none;
}

body {
  font-family: var(--font-family-base);
  background-color: var(--color-bg-base);
  color: var(--color-text-primary);
  font-size: 14px;
  line-height: 1.5;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-family-heading);
  font-weight: 600;
  letter-spacing: -0.02em;
}

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

/* ================== LAYOUT PRINCIPAL ================== */
.app-container {
  display: flex;
  width: 100vw;
  height: 100vh;
}

/* ================== COMPONENTES GENÉRICOS ================== */

/* Botões */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 16px;
  border-radius: var(--radius-md);
  border: none;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-fast);
  letter-spacing: 0.3px;
}

.btn:active { transform: scale(0.96); }

.btn-primary {
  background: linear-gradient(135deg, var(--color-primary), #6366f1);
  color: #FFF;
  box-shadow: var(--shadow-glow-primary);
}
.btn-primary:hover { 
  background: linear-gradient(135deg, var(--color-primary-hover), #818cf8); 
  box-shadow: 0 6px 20px rgba(59, 130, 246, 0.4);
}

.btn-danger {
  background: linear-gradient(135deg, var(--color-danger), #b91c1c);
  color: #FFF;
  box-shadow: var(--shadow-glow-danger);
}

.btn-surface {
  background: var(--color-bg-elevated);
  color: var(--color-text-primary);
  border: 1px solid var(--color-border);
}
.btn-surface:hover {
  border-color: var(--color-primary);
  background: var(--color-primary-dim);
}

/* Inputs */
.input-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 16px;
}

.input-group label {
  color: var(--color-text-secondary);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.input-control {
  width: 100%;
  background: var(--color-bg-elevated);
  border: 1px solid var(--color-border);
  color: var(--color-text-primary);
  padding: 12px 14px;
  border-radius: var(--radius-md);
  transition: all var(--transition-fast);
  user-select: text;
}
.input-control:focus {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px var(--color-primary-dim);
  background: var(--color-bg-surface);
}

/* Inputs genéricos usados nos modais de configuração */
.form-input {
  width: 100%;
  background: var(--color-bg-elevated);
  border: 1px solid var(--color-border);
  color: var(--color-text-primary);
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  transition: all var(--transition-fast);
  user-select: text;
}
.form-input:focus {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px var(--color-primary-dim);
}
.form-input::placeholder {
  color: var(--color-text-muted);
}
select.form-input {
  cursor: pointer;
  appearance: auto;
}

/* Cards */
.card {
  background: var(--color-bg-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--spacing-lg);
  box-shadow: var(--shadow-md);
  backdrop-filter: blur(10px);
}

/* ================== TELA DE LOGIN ================== */
.view-login {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(ellipse at 50% 20%, rgba(59,130,246,0.08) 0%, transparent 60%), var(--color-bg-base);
  position: relative;
  overflow: hidden;
}

.login-glass-box {
  width: 400px;
  padding: 40px;
  background: rgba(18, 18, 26, 0.85); 
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-lg);
  box-shadow: 0 24px 48px rgba(0, 0, 0, 0.5);
  display: flex;
  flex-direction: column;
  position: relative;
  z-index: 10;
}

.login-header {
  text-align: center;
  margin-bottom: 32px;
}

.login-header h1 {
  font-size: 32px;
  color: #FFF;
  margin-bottom: 4px;
  text-shadow: 0 2px 10px rgba(59,130,246,0.3);
}

.login-header p {
  color: var(--color-text-secondary);
  font-size: 14px;
}

.error-msg {
  color: var(--color-danger);
  background: var(--color-danger-dim);
  padding: 10px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  margin-bottom: 16px;
  text-align: center;
  display: none;
}

/* Decorações visuais de fundo no login */
.bg-glow-1, .bg-glow-2 {
  position: absolute;
  border-radius: 50%;
  filter: blur(100px);
  z-index: 1;
  opacity: 0.15;
}
.bg-glow-1 {
  width: 600px; height: 600px;
  background: var(--color-primary);
  top: -100px; left: -100px;
}
.bg-glow-2 {
  width: 500px; height: 500px;
  background: var(--color-danger);
  bottom: -100px; right: -100px;
}

/* ================== SHELL (LOGADO) ================== */
.view-main {
  display: flex;
  width: 100%;
  height: 100%;
}

.sidebar {
  width: 260px;
  background: var(--color-bg-surface);
  border-right: 1px solid var(--color-border);
  display: flex;
  flex-direction: column;
  z-index: 50;
}

.sidebar-header {
  height: 64px;
  display: flex;
  align-items: center;
  padding: 0 var(--spacing-md);
  border-bottom: 1px solid var(--color-border);
}

.sidebar-header h2 {
  font-size: 20px;
  color: var(--color-primary);
  display: flex;
  align-items: center;
  gap: 8px;
}

.sidebar-menu {
  padding: var(--spacing-md) 0;
  flex-shrink: 0;
}

.menu-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px var(--spacing-lg);
  color: var(--color-text-secondary);
  cursor: pointer;
  transition: all var(--transition-fast);
  border-left: 3px solid transparent;
}

.menu-item:hover {
  background: rgba(255, 255, 255, 0.03); 
  color: var(--color-text-primary);
}

.menu-item.active {
  color: var(--color-primary);
  background: var(--color-primary-dim);
  border-left-color: var(--color-primary);
}

.menu-item i { font-size: 20px; }

.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: var(--color-bg-base);
  position: relative;
}

.topbar {
  height: 64px;
  background: rgba(10, 10, 15, 0.85); 
  color: #FFFFFF; 
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--spacing-lg);
  position: absolute;
  top: 0; left: 0; right: 0;
  z-index: 40;
}

.view-container {
  flex: 1;
  padding-top: 64px; 
  overflow: auto;
  position: relative;
}

/* ================== LIVE VIEW ================== */
.live-view {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
}

.grid-controls {
  padding: 12px 24px;
  display: flex;
  gap: 8px;
  background: var(--color-bg-surface);
  border-bottom: 1px solid var(--color-border);
}

.grid-btn {
  background: var(--color-bg-base);
  border: 1px solid var(--color-border);
  color: var(--color-text-secondary);
  width: 36px; height: 36px;
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  transition: all var(--transition-fast);
}
.grid-btn:hover {
  border-color: rgba(255, 255, 255, 0.2);
  color: var(--color-text-primary);
}
.grid-btn.active {
  color: var(--color-primary);
  border-color: var(--color-primary);
  background: var(--color-primary-dim);
}

.video-grid {
  flex: 1;
  display: grid;
  gap: 2px;
  background: #000; 
  padding: 2px;
}
.grid-1x1 { grid-template-columns: 1fr; grid-template-rows: 1fr; }
.grid-2x2 { grid-template-columns: repeat(2, 1fr); grid-template-rows: repeat(2, 1fr); }
.grid-3x2 { grid-template-columns: repeat(3, 1fr); grid-template-rows: repeat(2, 1fr); }
.grid-3x3 { grid-template-columns: repeat(3, 1fr); grid-template-rows: repeat(3, 1fr); }
.grid-4x4 { grid-template-columns: repeat(4, 1fr); grid-template-rows: repeat(4, 1fr); }

.cam-slot {
  background: var(--color-bg-surface);
  position: relative;
  overflow: hidden;
  border: 1px solid transparent;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 0;
  min-height: 0;
}

.cam-slot.focused {
  border-color: var(--color-primary);
  box-shadow: inset 0 0 0 1px var(--color-primary);
  z-index: 10;
}

.cam-slot.cam-selected {
  border: 2px solid var(--color-primary);
  box-shadow: inset 0 0 0 1px var(--color-primary), 0 0 16px rgba(59, 130, 246, 0.4);
  z-index: 10;
}

/* ================== SIDEBAR: LISTA DE CÂMERAS ================== */
.sidebar-cam-section {
  flex: 1;
  display: flex;
  flex-direction: column;
  border-top: 1px solid var(--color-border);
  min-height: 0;
  overflow: hidden;
}

.sidebar-cam-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px var(--spacing-lg);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--color-text-secondary);
  flex-shrink: 0;
  background: rgba(255,255,255,0.02);
  border-bottom: 1px solid var(--color-border);
}

.sidebar-cam-header i {
  font-size: 16px;
  color: var(--color-primary);
}

.sidebar-cam-count {
  margin-left: auto;
  background: var(--color-primary);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  min-width: 20px;
  height: 20px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 6px;
}

.sidebar-cam-list {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 4px 0;
}

.sidebar-cam-list::-webkit-scrollbar {
  width: 5px;
}
.sidebar-cam-list::-webkit-scrollbar-track {
  background: transparent;
}
.sidebar-cam-list::-webkit-scrollbar-thumb {
  background: rgba(255,255,255,0.1);
  border-radius: 3px;
}
.sidebar-cam-list::-webkit-scrollbar-thumb:hover {
  background: rgba(255,255,255,0.2);
}

.sidebar-cam-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px var(--spacing-lg);
  cursor: pointer;
  transition: all var(--transition-fast);
  border-left: 3px solid transparent;
  font-size: 13px;
  color: var(--color-text-secondary);
}

.sidebar-cam-item:hover {
  background: rgba(255, 255, 255, 0.03);
  color: var(--color-text-primary);
}

.sidebar-cam-item.selected {
  background: var(--color-primary-dim);
  border-left-color: var(--color-primary);
  color: var(--color-text-primary);
}

.sidebar-cam-item.selected .sidebar-cam-name {
  font-weight: 600;
  color: var(--color-primary-hover);
}

.cam-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.cam-dot-online {
  background: var(--color-success);
  box-shadow: 0 0 8px rgba(34, 197, 94, 0.5);
}

.cam-dot-offline {
  background: var(--color-text-muted);
  opacity: 0.5;
}

.sidebar-cam-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  transition: all var(--transition-fast);
}

.cam-video {
  width: 100%;
  height: 100%;
  object-fit: contain; /* Ajusta a imagem inteira no slot, mantendo o aspecto nativo e adicionando letterbox */
}

/* ================== DUAL-LENS (Câmera dupla no mesmo slot) ================== */
.dual-lens-slot {
  padding: 0 !important;
}

.dual-lens-container {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: row;
  gap: 2px;
  background: #000;
}

.dual-lens-canvas {
  flex: 1;
  min-width: 0;
  height: 100%;
  object-fit: contain;
  background: #111;
}

.cam-overlay {
  position: absolute;
  top: 0; left: 0; right: 0;
  padding: 10px;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  pointer-events: none;
  background: linear-gradient(to bottom, rgba(0,0,0,0.8) 0%, transparent 100%);
  opacity: 1; /* SEMPRE VISÍVEL para que o usuário veja os controles de áudio */
}

.cam-slot:hover .cam-overlay, .cam-slot.focused .cam-overlay {
  opacity: 1;
}

.cam-name {
  color: #FFF;
  font-weight: 500;
  font-size: 13px;
  text-shadow: 0 1px 2px #000;
  background: rgba(0,0,0,0.5);
  padding: 4px 8px;
  border-radius: 4px;
}

.cam-status {
  display: flex; gap: 8px;
}

.status-badge {
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  pointer-events: none;
}

/* Badge REC Ativo — vermelho piscante */
.status-rec-active {
  background: rgba(220, 38, 38, 0.85);
  color: #FFF;
  box-shadow: 0 0 8px rgba(220, 38, 38, 0.5);
  animation: recPulse 1.5s ease-in-out infinite;
}
.status-rec-active::before { content: '● '; }

/* Badge Standby — verde discreto */
.status-rec-standby {
  background: rgba(34, 197, 94, 0.7);
  color: #FFF;
  font-size: 10px;
}

@keyframes recPulse {
  0% { opacity: 1; }
  50% { opacity: 0.4; }
  100% { opacity: 1; }
}

.status-motion { 
  background: rgba(0,0,0,0.5);
  color: var(--color-warning); 
  border: 1px solid var(--color-warning); 
}

@keyframes blink {
  0% { opacity: 1; }
  50% { opacity: 0; }
  100% { opacity: 1; }
}

.empty-slot-msg {
  color: var(--color-text-muted);
  font-size: 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}
.empty-slot-msg span { font-size: 12px; text-transform: uppercase; letter-spacing: 1px; }

/* Status de eventos HUD (canto inferior direito do slot) */
.cam-events-hud {
  position: absolute;
  bottom: 10px; right: 10px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  pointer-events: none;
}
.hud-item {
  background: rgba(0,0,0,0.7);
  border-left: 2px solid var(--color-primary);
  color: #FFF;
  font-size: 11px;
  padding: 4px 8px;
  border-radius: 2px;
  animation: slideInRight 0.3s ease;
}

@keyframes slideInRight {
  from { transform: translateX(20px); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

/* ================== TABELAS E MODAIS ================== */
.data-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
}

.data-table thead {
  position: sticky;
  top: 0;
  z-index: 5;
}

.data-table thead tr {
  background: var(--color-bg-base);
  border-bottom: 2px solid var(--color-border);
}

.data-table th {
  padding: 14px 16px;
  text-align: left;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--color-text-muted);
  white-space: nowrap;
  background: rgba(255,255,255,0.02);
  position: sticky;
  top: 0;
  z-index: 1;
}

.data-table td {
  padding: 14px 16px;
  font-size: 14px;
  color: var(--color-text-primary);
  border-bottom: 1px solid var(--color-border);
  vertical-align: middle;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.data-table tbody tr {
  background: var(--color-bg-elevated);
  transition: background 0.15s ease;
}

.data-table tbody tr:nth-child(even) {
  background: var(--color-bg-surface);
}

.data-table tbody tr:hover {
  background: var(--color-primary-dim);
}

/* Colunas com largura proporcional */
.data-table th:nth-child(1),
.data-table td:nth-child(1) { width: 110px; }

.data-table th:nth-child(2),
.data-table td:nth-child(2) { width: 22%; }

.data-table th:nth-child(3),
.data-table td:nth-child(3) { width: 16%; }

.data-table th:nth-child(4),
.data-table td:nth-child(4) { width: 12%; }

.data-table th:nth-child(5),
.data-table td:nth-child(5) { width: 12%; }

.data-table th:nth-child(6),
.data-table td:nth-child(6) { width: 14%; }

.data-table th:nth-child(7),
.data-table td:nth-child(7) { width: 110px; text-align: right; }

.modal-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.8);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-content {
  background: var(--color-bg-surface);
  box-shadow: 0 24px 48px rgba(0,0,0,0.8);
  border: 1px solid var(--color-border-focus);
  border-radius: var(--radius-lg);
}

.btn-sm {
  padding: 6px 12px;
  font-size: 13px;
}

/* ================== PLAYBACK VIEW ================== */
.playback-view {
  display: flex;
  flex-direction: column;
  height: 100%;
  background: #000;
}

.pb-toolbar {
  padding: 12px 24px;
  background: var(--color-bg-surface);
  display: flex;
  gap: 16px;
  border-bottom: 1px solid var(--color-border);
  align-items: center;
  flex-shrink: 0;
}

.player-container {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
  background: #000;
  min-height: 0;
  cursor: pointer;
}

.video-player {
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #000;
}

/* ================== PLAYER CONTROLS OVERLAY ================== */
.player-controls-overlay {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  pointer-events: none;
  opacity: 1;
  transition: opacity 0.3s ease;
  z-index: 10;
}

.player-top-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  background: linear-gradient(to bottom, rgba(0,0,0,0.8) 0%, transparent 100%);
  pointer-events: auto;
}

.player-title {
  color: #FFF;
  font-weight: 600;
  font-size: 15px;
  text-shadow: 0 1px 4px rgba(0,0,0,0.9);
}

.player-time-badge {
  color: rgba(255,255,255,0.8);
  font-size: 12px;
  background: rgba(0,0,0,0.6);
  padding: 4px 10px;
  border-radius: 4px;
  backdrop-filter: blur(4px);
}

.player-bottom-bar {
  background: linear-gradient(to top, rgba(0,0,0,0.9) 0%, transparent 100%);
  padding: 16px 20px 12px;
  pointer-events: auto;
}

/* Barra de progresso */
.player-progress-container {
  width: 100%;
  height: 6px;
  background: rgba(255,255,255,0.15);
  border-radius: 3px;
  cursor: pointer;
  position: relative;
  margin-bottom: 12px;
  transition: height 0.15s ease;
}

.player-progress-container:hover {
  height: 10px;
}

.player-progress-bar {
  height: 100%;
  background: var(--color-primary);
  border-radius: 3px;
  width: 0%;
  transition: width 0.1s linear;
}

.player-progress-thumb {
  position: absolute;
  top: 50%;
  left: 0%;
  width: 14px;
  height: 14px;
  background: #FFF;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  box-shadow: 0 0 8px rgba(0,0,0,0.6);
  opacity: 0;
  transition: opacity 0.15s ease;
}

.player-progress-container:hover .player-progress-thumb {
  opacity: 1;
}

/* Linha de controles */
.player-controls-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.player-controls-left,
.player-controls-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.player-btn {
  background: none;
  border: none;
  color: #FFF;
  cursor: pointer;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: all 0.15s ease;
}

.player-btn:hover {
  background: rgba(255,255,255,0.15);
}

.player-btn:active {
  transform: scale(0.9);
}

.player-time {
  color: rgba(255,255,255,0.9);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  margin-left: 8px;
  user-select: none;
}

.player-vol-slider {
  width: 80px;
  height: 4px;
  cursor: pointer;
  accent-color: var(--color-primary);
}

.player-speed {
  background: rgba(255,255,255,0.1);
  color: #FFF;
  border: 1px solid rgba(255,255,255,0.2);
  border-radius: 4px;
  padding: 4px 6px;
  font-size: 12px;
  cursor: pointer;
  outline: none;
  backdrop-filter: blur(4px);
}

.player-speed option {
  background: var(--color-bg-surface);
  color: #FFF;
}

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

/* ================== TIMELINE ================== */
.timeline-wrapper {
  height: 180px;
  background: var(--color-bg-surface);
  border-top: 1px solid var(--color-border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}

.timeline-toolbar {
  height: 48px;
  display: flex;
  align-items: center;
  padding: 0 var(--spacing-lg);
  gap: 16px;
  background: var(--color-bg-elevated);
  border-bottom: 1px solid var(--color-border);
}

.timeline-canvas-container {
  flex: 1;
  position: relative;
  overflow: hidden;
  cursor: col-resize;
}

#timeline-canvas {
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
}

.timeline-playhead {
  position: absolute;
  top: 0; bottom: 0;
  width: 2px;
  background: var(--color-danger);
  left: 50%;
  pointer-events: none;
  z-index: 10;
  box-shadow: 0 0 12px var(--color-danger);
}
.timeline-playhead::after {
  content: '';
  position: absolute;
  top: 0;
  left: -5px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--color-danger);
  box-shadow: 0 0 8px rgba(239, 68, 68, 0.5);
}

/* View de câmeras */
.view-cameras h2 {
  color: var(--color-text-primary) !important;
}

/* ================== REPORTS VIEW ================== */

/* Stat Cards */
.stat-card {
  background: var(--color-bg-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  transition: all 0.25s ease;
}
.stat-card:hover {
  border-color: rgba(255,255,255,0.12);
  transform: translateY(-2px);
}
.stat-card-glow {
  position: relative;
  overflow: hidden;
}
.stat-card-glow::before {
  content: '';
  position: absolute;
  top: -50%; left: -50%;
  width: 200%; height: 200%;
  background: radial-gradient(circle, rgba(59,130,246,0.05) 0%, transparent 70%);
  pointer-events: none;
}
.stat-icon {
  width: 48px; height: 48px;
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.stat-info {
  display: flex; flex-direction: column; gap: 2px;
}
.stat-value {
  font-size: 28px; font-weight: 700;
  font-family: var(--font-family-heading);
  letter-spacing: -0.03em;
}
.stat-label {
  font-size: 12px; color: var(--color-text-secondary);
  text-transform: uppercase; letter-spacing: 0.8px; font-weight: 500;
}

/* Tab Bar */
.reports-tab-bar {
  display: flex; gap: 4px;
  background: var(--color-bg-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 4px;
  margin-bottom: 16px;
}
.reports-tab {
  flex: 1; display: flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 16px;
  background: transparent; border: none;
  color: var(--color-text-secondary);
  font-size: 13px; font-weight: 600; font-family: inherit;
  border-radius: var(--radius-sm);
  cursor: pointer; transition: all 0.2s ease;
}
.reports-tab:hover {
  background: rgba(255,255,255,0.03);
  color: var(--color-text-primary);
}
.reports-tab.active {
  background: var(--color-primary-dim);
  color: var(--color-primary);
  box-shadow: 0 2px 8px rgba(59,130,246,0.2);
}

/* Filters */
.reports-filters {
  display: flex; gap: 8px; align-items: center;
  margin-bottom: 16px; flex-wrap: wrap;
}

/* Table */
.reports-table-wrap {
  overflow-x: auto;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-bg-surface);
}
.reports-table {
  width: 100%; border-collapse: collapse; table-layout: auto;
}
.reports-table thead tr {
  background: rgba(255,255,255,0.02);
  border-bottom: 1px solid var(--color-border);
}
.reports-table th {
  padding: 12px 16px; text-align: left;
  font-size: 11px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.8px; color: var(--color-text-muted);
  white-space: nowrap;
}
.reports-table td {
  padding: 12px 16px;
  font-size: 13px; color: var(--color-text-primary);
  border-bottom: 1px solid rgba(255,255,255,0.04);
  vertical-align: middle;
}
.reports-table tbody tr {
  transition: background 0.15s;
}
.reports-table tbody tr:hover {
  background: rgba(59,130,246,0.06);
}
.reports-table .row-online {
  background: rgba(34,197,94,0.04);
}
.reports-table .row-online:hover {
  background: rgba(34,197,94,0.08);
}

/* Status Badge */
.reports-table .status-badge,
.session-card .status-badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 10px; border-radius: 20px;
  font-size: 11px; font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.5px;
}
.status-online {
  background: rgba(34,197,94,0.15); color: #22c55e;
}
.status-offline {
  background: rgba(100,100,100,0.15); color: #888;
}
.status-dot {
  width: 6px; height: 6px; border-radius: 50%; flex-shrink: 0;
  background: currentColor;
}
.dot-pulse {
  animation: dotPulse 1.5s ease-in-out infinite;
}
@keyframes dotPulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.4; transform: scale(0.8); }
}

/* User Cell */
.user-cell {
  display: flex; align-items: center; gap: 10px;
}
.user-avatar {
  width: 32px; height: 32px;
  border-radius: 8px;
  background: linear-gradient(135deg, #3b82f6, #6366f1);
  color: #fff; font-weight: 700; font-size: 14px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.user-name {
  font-weight: 600; font-size: 13px; color: var(--color-text-primary);
}
.user-sub {
  font-size: 11px; color: var(--color-text-muted);
}

/* Device Badge */
.device-badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 10px; border-radius: 6px;
  font-size: 11px; font-weight: 600;
  background: rgba(255,255,255,0.06);
  color: var(--color-text-secondary);
}
.device-web { color: #60a5fa; background: rgba(96,165,250,0.1); }
.device-mobile-web { color: #a78bfa; background: rgba(167,139,250,0.1); }
.device-app { color: #34d399; background: rgba(52,211,153,0.1); }
.device-desktop-app { color: #fbbf24; background: rgba(251,191,36,0.1); }

/* IP Code */
.ip-code {
  font-family: 'JetBrains Mono', 'Fira Code', monospace;
  font-size: 12px; color: var(--color-text-secondary);
  background: rgba(255,255,255,0.04);
  padding: 3px 8px; border-radius: 4px;
  user-select: text;
}

/* Duration Badge */
.duration-badge {
  font-family: var(--font-family-heading);
  font-size: 13px; font-weight: 600;
  color: var(--color-primary);
}

/* Footer */
.reports-footer {
  padding: 12px 16px;
  font-size: 12px; color: var(--color-text-muted);
  text-align: right;
  border-top: 1px solid var(--color-border);
}

/* Loading & Empty */
.reports-loading, .reports-empty {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 12px; padding: 64px; color: var(--color-text-muted);
  font-size: 14px;
}

/* Sessions Grid */
.sessions-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 16px;
}
.session-card {
  background: var(--color-bg-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 20px;
  transition: all 0.2s ease;
}
.session-card:hover {
  border-color: rgba(34,197,94,0.3);
  box-shadow: 0 4px 20px rgba(34,197,94,0.1);
}
.session-header {
  display: flex; align-items: center; gap: 12px;
  margin-bottom: 16px; padding-bottom: 12px;
  border-bottom: 1px solid var(--color-border);
}
.session-avatar {
  width: 40px; height: 40px; border-radius: 10px;
  background: linear-gradient(135deg, #22c55e, #16a34a);
  color: #fff; font-weight: 700; font-size: 16px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.session-user-info { flex: 1; display: flex; flex-direction: column; gap: 2px; }
.session-user-name { font-weight: 600; font-size: 14px; }
.session-user-role { font-size: 11px; color: var(--color-text-muted); }
.session-details { display: flex; flex-direction: column; gap: 8px; margin-bottom: 16px; }
.session-detail-row {
  display: flex; align-items: center; gap: 8px;
  font-size: 12px; color: var(--color-text-secondary);
}
.session-detail-row code { user-select: text; }
.session-uptime {
  display: flex; justify-content: space-between; align-items: center;
  background: rgba(34,197,94,0.08); border-radius: 8px; padding: 10px 14px;
}
.uptime-label { font-size: 11px; color: var(--color-text-muted); text-transform: uppercase; letter-spacing: 0.5px; font-weight: 600; }
.uptime-value { font-size: 18px; font-weight: 700; color: #22c55e; font-family: var(--font-family-heading); }

/* Permissions Grid */
.permissions-grid {
  display: flex; flex-direction: column; gap: 16px;
}
.permission-card {
  background: var(--color-bg-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  transition: all 0.2s ease;
}
.permission-card:hover {
  border-color: rgba(255,255,255,0.1);
}
.permission-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px;
  background: rgba(255,255,255,0.02);
  border-bottom: 1px solid var(--color-border);
  flex-wrap: wrap; gap: 12px;
}
.permission-user { display: flex; align-items: center; gap: 12px; }
.perm-avatar {
  width: 38px; height: 38px; border-radius: 10px;
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  color: #fff; font-weight: 700; font-size: 15px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.perm-avatar-admin {
  background: linear-gradient(135deg, #f59e0b, #ef4444);
}
.perm-user-name { font-weight: 600; font-size: 14px; }
.perm-user-meta { font-size: 11px; color: var(--color-text-muted); display: flex; align-items: center; gap: 6px; }
.role-badge {
  padding: 2px 8px; border-radius: 4px;
  font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px;
}
.role-admin { background: rgba(245,158,11,0.15); color: #fbbf24; }
.role-operator, .role-user { background: rgba(99,102,241,0.15); color: #a5b4fc; }
.perm-stats {
  display: flex; gap: 12px; align-items: center;
}
.perm-stat {
  font-size: 12px; color: var(--color-text-secondary);
}
.perm-stat-num { font-weight: 700; font-size: 16px; color: var(--color-text-primary); margin-right: 2px; }
.stat-online .perm-stat-num { color: #22c55e; }
.perm-camera-list {
  padding: 8px 0;
}
.perm-no-cams {
  padding: 20px; text-align: center;
  font-size: 13px; color: var(--color-text-muted);
}
.perm-cam-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 20px;
  font-size: 13px;
  transition: background 0.15s;
}
.perm-cam-item:hover { background: rgba(255,255,255,0.02); }
.cam-status-dot {
  width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0;
}
.dot-on { background: #22c55e; box-shadow: 0 0 6px rgba(34,197,94,0.5); }
.dot-off { background: #555; }
.perm-cam-name { flex: 1; font-weight: 500; }
.perm-cam-ip {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px; color: var(--color-text-muted);
  background: rgba(255,255,255,0.04);
  padding: 2px 8px; border-radius: 4px;
}
.perm-cam-status {
  font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px;
  padding: 2px 8px; border-radius: 4px;
}
.cam-on { background: rgba(34,197,94,0.12); color: #22c55e; }
.cam-off { background: rgba(100,100,100,0.12); color: #888; }
