:root {
  --bg-dark: #0a0e14;
  --bg-card: #131b26;
  --bg-card-hover: #1c2636;
  --border-color: #222d3d;
  --accent-red: #e53935;
  --accent-red-hover: #d32f2f;
  --accent-blue: #2563eb;
  --accent-green: #10b981;
  --text-main: #f3f4f6;
  --text-muted: #9ca3af;
  --text-sub: #6b7280;
  --radius: 10px;
  --font-main: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
}

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

body {
  font-family: var(--font-main);
  background-color: var(--bg-dark);
  color: var(--text-main);
  min-height: 100vh;
  overflow-x: hidden;
  user-select: none;
}

.screen {
  width: 100vw;
  height: 100vh;
  position: relative;
  display: flex;
}

.hidden {
  display: none !important;
}

/* Tela de Login de Administrador */
.auth-screen-wrapper {
  align-items: center;
  justify-content: center;
  background: radial-gradient(circle at 50% 30%, #172435 0%, #0a0e14 75%);
}

.auth-card {
  width: 100%;
  max-width: 420px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  padding: 32px;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.6);
  position: relative;
}

.auth-card .brand {
  margin-bottom: 24px;
}

.auth-card-footer {
  margin-top: 24px;
  padding-top: 16px;
  border-top: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  text-align: center;
}

.auth-card-footer span {
  font-size: 0.78rem;
  color: var(--text-muted);
}

.btn-download-small {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: #192433;
  color: var(--accent-green);
  border: 1px solid rgba(16, 185, 129, 0.4);
  text-decoration: none;
  font-size: 0.8rem;
  font-weight: 600;
  padding: 6px 14px;
  border-radius: 6px;
  transition: all 0.2s;
}

.btn-download-small:hover {
  background: rgba(16, 185, 129, 0.15);
  border-color: var(--accent-green);
}

/* Layout do Dashboard */
.dashboard-layout {
  flex-direction: column;
  overflow-y: auto;
  background: radial-gradient(circle at 50% 0%, #151f2e 0%, #0a0e14 70%);
}

/* Header Principal */
.main-header {
  height: 64px;
  background: rgba(19, 27, 38, 0.95);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 50;
}

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

.brand-icon {
  width: 40px;
  height: 40px;
  background: linear-gradient(135deg, var(--accent-red), #ff6b6b);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
}

.header-brand h1 {
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: -0.3px;
}

.tagline {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 16px;
}

.server-status-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: #0f151f;
  border: 1px solid var(--border-color);
  padding: 6px 12px;
  border-radius: 20px;
  font-size: 0.78rem;
}

.status-indicator {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: #f59e0b;
}

.status-indicator.online {
  background-color: var(--accent-green);
  box-shadow: 0 0 8px rgba(16, 185, 129, 0.6);
}

.status-indicator.offline {
  background-color: var(--accent-red);
}

/* Botão de Download do Executável */
.btn-download {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: linear-gradient(135deg, #059669, var(--accent-green));
  color: #fff;
  text-decoration: none;
  font-size: 0.85rem;
  font-weight: 600;
  padding: 9px 16px;
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3);
  transition: transform 0.15s, box-shadow 0.15s;
}

.btn-download:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgba(16, 185, 129, 0.45);
}

.btn-update-all {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: #1e293b;
  border: 1px solid var(--border-color);
  color: var(--text-main);
  font-size: 0.85rem;
  font-weight: 600;
  padding: 8px 14px;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-update-all:hover {
  background: #334155;
  border-color: #64748b;
  color: #fff;
}

.btn-update-all:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.card-version-badge {
  font-size: 0.72rem;
  padding: 2px 7px;
  border-radius: 4px;
  background: #1e293b;
  color: #94a3b8;
  font-family: var(--font-mono);
  border: 1px solid #334155;
  font-weight: 500;
}

.user-profile {
  display: flex;
  align-items: center;
  gap: 10px;
}

.user-badge {
  font-size: 0.8rem;
  color: var(--text-muted);
  background: #111822;
  border: 1px solid var(--border-color);
  padding: 5px 10px;
  border-radius: 6px;
  font-family: var(--font-mono);
}

.btn-logout {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(229, 57, 53, 0.15);
  color: #ff8a80;
  border: 1px solid var(--accent-red);
  font-size: 0.8rem;
  font-weight: 600;
  padding: 6px 12px;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-logout:hover {
  background: var(--accent-red);
  color: #fff;
}

/* Navegação por Abas */
.mode-tabs {
  display: flex;
  gap: 8px;
  padding: 16px 24px 0 24px;
  border-bottom: 1px solid var(--border-color);
  background: #0d121a;
}

.tab-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 0.88rem;
  font-weight: 500;
  padding: 10px 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  border-bottom: 2px solid transparent;
  transition: all 0.2s;
}

.tab-btn:hover {
  color: #fff;
}

.tab-btn.active {
  color: #fff;
  font-weight: 600;
  border-bottom-color: var(--accent-red);
}

/* Conteúdo das Abas */
.tab-content {
  flex: 1;
  padding: 24px;
}

/* Mosaico de Máquinas */
.mosaic-header-info {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}

.mosaic-header-info h2 {
  font-size: 1.2rem;
  font-weight: 700;
}

.mosaic-header-info p {
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-top: 2px;
}

.legend-badge.live {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--accent-green);
  background: rgba(16, 185, 129, 0.15);
  border: 1px solid rgba(16, 185, 129, 0.3);
  padding: 4px 10px;
  border-radius: 20px;
}

.pulse-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent-green);
  animation: pulse 1.5s infinite;
}

@keyframes pulse {
  0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7); }
  70% { transform: scale(1); box-shadow: 0 0 0 6px rgba(16, 185, 129, 0); }
  100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}

/* Grid CCTV */
.mosaic-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(360px, 1fr));
  gap: 20px;
}

/* Card Individual da Máquina (Estilo Monitor CCTV) */
.machine-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: transform 0.2s, border-color 0.2s, box-shadow 0.2s;
  cursor: pointer;
  position: relative;
}

.machine-card:hover {
  transform: translateY(-3px);
  border-color: var(--accent-red);
  box-shadow: 0 12px 24px rgba(0, 0, 0, 0.4);
}

.card-header {
  padding: 10px 14px;
  background: #0f151f;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.card-title-group {
  display: flex;
  align-items: center;
  gap: 8px;
}

.card-machine-name {
  font-weight: 700;
  font-size: 0.9rem;
  color: #fff;
}

.card-host-id {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--text-sub);
  background: #192230;
  padding: 2px 6px;
  border-radius: 4px;
}

.card-video-wrapper {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  background: #000;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.card-video-wrapper canvas {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.card-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(2px);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.2s;
}

.machine-card:hover .card-overlay {
  opacity: 1;
}

.btn-expand-control {
  background: var(--accent-red);
  color: #fff;
  border: none;
  font-size: 0.85rem;
  font-weight: 600;
  padding: 10px 18px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  gap: 8px;
  box-shadow: 0 4px 14px rgba(229, 57, 53, 0.4);
}

.card-footer {
  padding: 8px 14px;
  background: #0f151f;
  border-top: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.empty-mosaic {
  grid-column: 1 / -1;
  text-align: center;
  padding: 60px 20px;
  background: rgba(19, 27, 38, 0.5);
  border: 2px dashed var(--border-color);
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.empty-icon {
  color: var(--text-sub);
}

.empty-mosaic h3 {
  font-size: 1.1rem;
}

.empty-mosaic p {
  font-size: 0.85rem;
  color: var(--text-muted);
  max-width: 480px;
}

.btn-primary-inline {
  display: inline-block;
  margin-top: 8px;
  background: var(--accent-red);
  color: #fff;
  text-decoration: none;
  padding: 10px 20px;
  border-radius: 8px;
  font-size: 0.85rem;
  font-weight: 600;
}

/* Conexão Manual */
.direct-connect-wrapper {
  display: flex;
  justify-content: center;
  padding-top: 30px;
}

.login-card {
  width: 100%;
  max-width: 440px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  padding: 32px;
}

.login-card h3 {
  font-size: 1.2rem;
  margin-bottom: 4px;
}

.form-group {
  margin-top: 18px;
}

.form-group label {
  display: block;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.input-with-icon {
  position: relative;
  display: flex;
  align-items: center;
}

.input-with-icon input {
  width: 100%;
  background: #0f151f;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 12px 60px 12px 14px;
  color: #fff;
  font-size: 1rem;
  font-family: var(--font-mono);
  outline: none;
}

.input-with-icon input:focus {
  border-color: var(--accent-red);
}

.input-badge {
  position: absolute;
  right: 12px;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-sub);
  background: var(--border-color);
  padding: 2px 8px;
  border-radius: 4px;
}

.btn-primary {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  background: var(--accent-red);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 13px;
  font-size: 0.95rem;
  font-weight: 600;
  margin-top: 20px;
  cursor: pointer;
}

.error-banner {
  margin-top: 14px;
  background: rgba(229, 57, 53, 0.15);
  border: 1px solid var(--accent-red);
  color: #ff8a80;
  padding: 10px;
  border-radius: 6px;
  font-size: 0.85rem;
  text-align: center;
}

/* Tela Remota (Sessão Ativa em Tela Cheia) */
#remote-screen {
  flex-direction: column;
  background-color: #000;
}

.remote-toolbar {
  height: 48px;
  background: rgba(19, 27, 38, 0.95);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  z-index: 100;
}

.toolbar-left, .toolbar-center, .toolbar-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.back-btn {
  background: #253347 !important;
  color: #fff !important;
  font-weight: 600 !important;
}

.session-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
}

.stats-item {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--text-muted);
  background: #111822;
  padding: 4px 8px;
  border-radius: 4px;
}

.toolbar-control {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.toolbar-control select {
  background: #101620;
  color: #fff;
  border: 1px solid var(--border-color);
  padding: 4px 8px;
  border-radius: 4px;
  outline: none;
  font-size: 0.8rem;
}

.toolbar-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  background: #1a2332;
  color: var(--text-main);
  border: 1px solid var(--border-color);
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
}

.toolbar-btn:hover {
  background: #253347;
}

.btn-danger {
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(229, 57, 53, 0.2);
  color: #ff8a80;
  border: 1px solid var(--accent-red);
  padding: 6px 14px;
  border-radius: 6px;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
}

.btn-danger:hover {
  background: var(--accent-red);
  color: #fff;
}

/* Canvas Wrapper */
.canvas-wrapper {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
  background-color: #05070a;
}

#remote-canvas {
  max-width: 100%;
  max-height: 100%;
  outline: none;
  cursor: default;
}

.stream-loader {
  position: absolute;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  color: var(--text-muted);
  font-size: 0.9rem;
}

.spinner {
  width: 36px;
  height: 36px;
  border: 3px solid rgba(255, 255, 255, 0.1);
  border-top-color: var(--accent-red);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Modal de Arquivos */
.modal {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
}

.modal-content {
  position: relative;
  width: 90%;
  max-width: 580px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  overflow: hidden;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-color);
}

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

.close-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.5rem;
  cursor: pointer;
}

.modal-body {
  padding: 20px;
}

.drop-zone {
  border: 2px dashed var(--border-color);
  border-radius: 8px;
  padding: 28px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  background: rgba(255, 255, 255, 0.02);
}

.btn-secondary {
  margin-top: 8px;
  background: #202a3a;
  color: #fff;
  border: 1px solid var(--border-color);
  padding: 8px 16px;
  border-radius: 6px;
  font-size: 0.85rem;
  cursor: pointer;
}

.progress-box {
  margin-top: 16px;
  background: #101620;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 14px;
}

.progress-header, .progress-footer {
  display: flex;
  justify-content: space-between;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.progress-bar-bg {
  height: 8px;
  background: #202a3a;
  border-radius: 4px;
  overflow: hidden;
  margin: 8px 0;
}

.progress-bar-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--accent-red), #ff7961);
}

.files-list-section {
  margin-top: 20px;
}

.files-list-section h4 {
  font-size: 0.85rem;
  color: var(--text-sub);
  margin-bottom: 10px;
  text-transform: uppercase;
}

.files-list {
  max-height: 180px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.file-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #121822;
  border: 1px solid var(--border-color);
  padding: 10px 14px;
  border-radius: 6px;
  font-size: 0.85rem;
}

.file-item-info {
  display: flex;
  flex-direction: column;
}

.file-item-name {
  font-weight: 500;
  max-width: 320px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-item-size {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.file-item-action {
  background: var(--accent-blue);
  color: #fff;
  text-decoration: none;
  padding: 6px 12px;
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: 600;
}
