:root {
  --bg-primary: #0f172a;
  --bg-card: rgba(30, 41, 59, 0.85);
  --bg-card-hover: #1e293b;
  --border-color: rgba(255, 255, 255, 0.1);
  --accent-primary: #3b82f6;
  --accent-hover: #2563eb;
  --accent-glow: rgba(59, 130, 246, 0.25);
  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;
  --info: #06b6d4;
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --sidebar-width: 260px;
}

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

body {
  font-family: var(--font-family);
  background-color: var(--bg-primary);
  color: var(--text-main);
  min-height: 100vh;
  display: flex;
  overflow-x: hidden;
}

/* Scrollbar */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
::-webkit-scrollbar-track {
  background: #090d16;
}
::-webkit-scrollbar-thumb {
  background: #334155;
  border-radius: 4px;
}

/* Layout Principal */
#app-container {
  display: flex;
  width: 100vw;
  min-height: 100vh;
}

/* Sidebar */
.sidebar {
  width: var(--sidebar-width);
  background: rgba(15, 23, 42, 0.95);
  backdrop-filter: blur(12px);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  padding: 1.25rem 1rem;
  position: fixed;
  height: 100vh;
  z-index: 100;
  transition: transform 0.3s ease;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.5rem;
  margin-bottom: 1.5rem;
}

.brand-icon {
  width: 40px;
  height: 40px;
  background: linear-gradient(135deg, #3b82f6, #6366f1);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  box-shadow: 0 4px 12px var(--accent-glow);
}

.brand-title {
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: 0.5px;
  background: linear-gradient(90deg, #ffffff, #93c5fd);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.nav-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  flex: 1;
}

.nav-item button {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 0.85rem;
  padding: 0.75rem 1rem;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 8px;
  color: var(--text-muted);
  font-size: 0.95rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  text-align: left;
}

.nav-item button:hover {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-main);
}

.nav-item.active button {
  background: var(--accent-glow);
  border-color: rgba(59, 130, 246, 0.4);
  color: #60a5fa;
}

.nav-item button i {
  font-size: 1.1rem;
  width: 20px;
}

.empresa-badge-container {
  padding: 0.85rem;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  margin-top: auto;
}

.empresa-name {
  font-size: 0.9rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

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

.plano-tag {
  display: inline-block;
  padding: 0.15rem 0.5rem;
  font-size: 0.65rem;
  font-weight: 700;
  border-radius: 12px;
  margin-top: 0.4rem;
  text-transform: uppercase;
}

.plano-tag.ativa {
  background: rgba(16, 185, 129, 0.2);
  color: #34d399;
  border: 1px solid rgba(16, 185, 129, 0.4);
}

.plano-tag.pendente, .plano-tag.vencida {
  background: rgba(239, 68, 68, 0.2);
  color: #f87171;
  border: 1px solid rgba(239, 68, 68, 0.4);
}

/* Main Content Wrapper */
.main-content {
  margin-left: var(--sidebar-width);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  width: calc(100vw - var(--sidebar-width));
}

/* Header */
.top-header {
  height: 70px;
  background: rgba(15, 23, 42, 0.8);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 2rem;
  position: sticky;
  top: 0;
  z-index: 90;
}

.mobile-toggle {
  display: none;
  background: none;
  border: none;
  color: var(--text-main);
  font-size: 1.4rem;
  cursor: pointer;
}

.page-title {
  font-size: 1.25rem;
  font-weight: 700;
}

.user-actions {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.btn-icon {
  width: 38px;
  height: 38px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: 0.2s;
}

.btn-icon:hover {
  background: rgba(255, 255, 255, 0.1);
}

/* Content Container */
.content-body {
  padding: 2rem;
  flex: 1;
}

.tab-pane {
  display: none;
  animation: fadeIn 0.3s ease;
}

.tab-pane.active {
  display: block;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Stats Cards */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1.25rem;
  margin-bottom: 2rem;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 14px;
  padding: 1.25rem;
  display: flex;
  align-items: center;
  gap: 1.25rem;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
  transition: transform 0.2s ease, border-color 0.2s ease;
}

.stat-card:hover {
  transform: translateY(-2px);
  border-color: rgba(255, 255, 255, 0.2);
}

.stat-icon {
  width: 52px;
  height: 52px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
}

.stat-icon.blue { background: rgba(59, 130, 246, 0.15); color: #60a5fa; }
.stat-icon.green { background: rgba(16, 185, 129, 0.15); color: #34d399; }
.stat-icon.amber { background: rgba(245, 158, 11, 0.15); color: #fbbf24; }
.stat-icon.red { background: rgba(239, 68, 68, 0.15); color: #f87171; }
.stat-icon.cyan { background: rgba(6, 182, 212, 0.15); color: #22d3ee; }

.stat-info .stat-value {
  font-size: 1.6rem;
  font-weight: 700;
  line-height: 1.2;
}

.stat-info .stat-label {
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-top: 0.2rem;
}

/* Custom Cards & Tables */
.card-panel {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 14px;
  padding: 1.5rem;
  margin-bottom: 2rem;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.25rem;
  flex-wrap: wrap;
  gap: 1rem;
}

.card-title {
  font-size: 1.1rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.table-responsive {
  width: 100%;
  overflow-x: auto;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 0.9rem;
}

.data-table th {
  background: rgba(15, 23, 42, 0.6);
  padding: 0.85rem 1rem;
  color: var(--text-muted);
  font-weight: 600;
  border-bottom: 1px solid var(--border-color);
}

.data-table td {
  padding: 0.85rem 1rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  vertical-align: middle;
}

.data-table tbody tr:hover {
  background: rgba(255, 255, 255, 0.02);
}

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.25rem 0.6rem;
  border-radius: 6px;
  font-size: 0.75rem;
  font-weight: 600;
}

.badge-success { background: rgba(16, 185, 129, 0.2); color: #34d399; }
.badge-warning { background: rgba(245, 158, 11, 0.2); color: #fbbf24; }
.badge-danger { background: rgba(239, 68, 68, 0.2); color: #f87171; }
.badge-info { background: rgba(59, 130, 246, 0.2); color: #60a5fa; }

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.6rem 1.1rem;
  border-radius: 8px;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all 0.2s ease;
}

.btn-primary {
  background: var(--accent-primary);
  color: #fff;
  box-shadow: 0 4px 12px var(--accent-glow);
}
.btn-primary:hover { background: var(--accent-hover); }

.btn-success {
  background: var(--success);
  color: #fff;
}
.btn-success:hover { background: #059669; }

.btn-outline {
  background: transparent;
  border-color: var(--border-color);
  color: var(--text-main);
}
.btn-outline:hover { background: rgba(255, 255, 255, 0.05); }

.btn-sm {
  padding: 0.35rem 0.7rem;
  font-size: 0.8rem;
  border-radius: 6px;
}

/* Forms & Inputs */
.form-group {
  margin-bottom: 1.1rem;
}

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

.form-control {
  width: 100%;
  padding: 0.65rem 0.85rem;
  background: rgba(15, 23, 42, 0.8);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  color: var(--text-main);
  font-size: 0.9rem;
  transition: border-color 0.2s;
}

.form-control:focus {
  outline: none;
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.form-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
}

/* Canvas para Assinatura Touch/Desktop */
.signature-pad-container {
  border: 2px dashed rgba(255, 255, 255, 0.2);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.03);
  position: relative;
  overflow: hidden;
  touch-action: none;
}

canvas#signature-canvas {
  width: 100%;
  height: 160px;
  background: #ffffff;
  cursor: crosshair;
}

.signature-actions {
  display: flex;
  justify-content: space-between;
  padding: 0.5rem;
  background: rgba(15, 23, 42, 0.9);
}

/* Planos SaaS & Landing Cards */
.plans-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 1.5rem;
  margin-top: 1.5rem;
}

.plan-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  padding: 2rem 1.5rem;
  text-align: center;
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  transition: transform 0.25s ease, border-color 0.25s ease;
}

.plan-card:hover {
  transform: translateY(-4px);
  border-color: var(--accent-primary);
}

.plan-card.featured {
  border: 2px solid var(--accent-primary);
  box-shadow: 0 0 25px var(--accent-glow);
}

.plan-badge {
  position: absolute;
  top: -12px;
  left: 50%;
  transform: translateX(-50%);
  background: linear-gradient(135deg, #3b82f6, #6366f1);
  color: white;
  padding: 0.25rem 0.8rem;
  border-radius: 12px;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.5px;
}

.plan-title {
  font-size: 1.2rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
}

.plan-price {
  font-size: 2.2rem;
  font-weight: 800;
  color: #60a5fa;
  margin: 1rem 0;
}

.plan-price span {
  font-size: 0.9rem;
  color: var(--text-muted);
  font-weight: 400;
}

.plan-features {
  list-style: none;
  text-align: left;
  margin: 1.5rem 0;
  font-size: 0.88rem;
  color: var(--text-muted);
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.plan-features li {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.plan-features li i {
  color: var(--success);
}

/* Modals */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(6px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}

.modal-overlay.active {
  display: flex !important;
  opacity: 1 !important;
  pointer-events: all !important;
  z-index: 9999 !important;
}

.modal-card {
  background: #1e293b;
  border: 1px solid var(--border-color);
  border-radius: 16px;
  width: 90%;
  max-width: 600px;
  max-height: 90vh;
  overflow-y: auto;
  padding: 1.75rem;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
  transform: scale(0.95);
  transition: transform 0.25s ease;
}

.modal-overlay.active .modal-card {
  transform: scale(1);
}

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

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

/* Impressão Ficha NR-6 e Etiquetas QR Code */
@media print {
  body {
    background: #ffffff !important;
    color: #000000 !important;
    margin: 0 !important;
    padding: 0 !important;
  }
  
  #app-container, .sidebar, .top-header, .btn, .no-print, .modal-header, .modal-close {
    display: none !important;
  }

  .main-content {
    margin-left: 0 !important;
    width: 100% !important;
  }

  /* Exibe somente o modal ativo sem fundos pretos */
  .modal-overlay {
    display: none !important;
    position: static !important;
    background: none !important;
    backdrop-filter: none !important;
    opacity: 1 !important;
    width: 100% !important;
    height: auto !important;
    padding: 0 !important;
  }

  .modal-overlay.active {
    display: flex !important;
    justify-content: center !important;
    align-items: center !important;
  }

  .modal-card {
    background: #ffffff !important;
    border: none !important;
    box-shadow: none !important;
    width: 100% !important;
    max-width: 100% !important;
    padding: 0 !important;
    margin: 0 !important;
    transform: none !important;
  }

  .ficha-nr6-print {
    padding: 20px;
    background: #fff;
    color: #000;
  }
  .ficha-nr6-print table {
    border: 1px solid #000;
  }
  .ficha-nr6-print th, .ficha-nr6-print td {
    border: 1px solid #000;
    color: #000;
  }

  .etiqueta-print-container {
    display: flex !important;
    justify-content: center !important;
    align-items: center !important;
    padding: 20px 0 !important;
    margin: 0 auto !important;
  }

  .etiqueta-card {
    width: 320px !important;
    border: 2px solid #000000 !important;
    border-radius: 8px !important;
    background: #ffffff !important;
    color: #000000 !important;
    box-shadow: none !important;
    page-break-inside: avoid !important;
  }
}

/* Estilos de Etiquetas e Crachás QR Code */
.etiqueta-card {
  width: 320px;
  background: #ffffff;
  color: #000000;
  border: 2px solid #0f172a;
  border-radius: 12px;
  padding: 1rem;
  margin: 0 auto;
  text-align: center;
  box-shadow: 0 4px 15px rgba(0,0,0,0.3);
  font-family: var(--font-family);
  position: relative;
}

.etiqueta-header {
  border-bottom: 2px solid #0f172a;
  padding-bottom: 0.5rem;
  margin-bottom: 0.75rem;
}

.etiqueta-empresa {
  font-size: 0.85rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: #0f172a;
}

.etiqueta-title {
  font-size: 1rem;
  font-weight: 700;
  color: #1e293b;
  margin-top: 0.2rem;
}

.etiqueta-subtitle {
  font-size: 0.78rem;
  color: #475569;
  font-weight: 600;
}

.etiqueta-qrcode-img {
  width: 170px;
  height: 170px;
  margin: 0.5rem auto;
  display: block;
  border: 1px solid #cbd5e1;
  padding: 4px;
  background: #fff;
  border-radius: 6px;
}

.etiqueta-code-tag {
  font-family: monospace;
  font-size: 0.9rem;
  font-weight: 700;
  background: #f1f5f9;
  padding: 0.25rem 0.5rem;
  border-radius: 4px;
  border: 1px dashed #64748b;
  display: inline-block;
  margin-top: 0.2rem;
  color: #0f172a;
}

/* Responsividade Mobile */
@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
  }
  .sidebar.mobile-open {
    transform: translateX(0);
  }
  .main-content {
    margin-left: 0;
    width: 100vw;
  }
  .mobile-toggle {
    display: block;
  }
  .content-body {
    padding: 1rem;
  }
  .stats-grid {
    grid-template-columns: 1fr;
  }
}

/* Regras de Impressão Oficial de Relatórios */
@media print {
  html, body, #app-container, .main-content, .content-body {
    display: block !important;
    position: static !important;
    width: 100% !important;
    height: auto !important;
    min-height: 0 !important;
    overflow: visible !important;
    background: #ffffff !important;
    color: #000000 !important;
    float: none !important;
    margin: 0 !important;
    padding: 0 !important;
  }

  body {
    font-family: Arial, sans-serif !important;
  }

  .sidebar,
  .top-header,
  .btn,
  .no-print,
  .modal-overlay,
  .tab-pane:not(.active) {
    display: none !important;
  }

  .tab-pane.active {
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
    transform: none !important;
  }

  .card-panel {
    background: #ffffff !important;
    border: 1px solid #000000 !important;
    box-shadow: none !important;
    color: #000000 !important;
    page-break-inside: avoid;
    margin-bottom: 2rem !important;
    padding: 1.25rem !important;
  }

  .card-title {
    color: #000000 !important;
    font-weight: bold !important;
  }

  .data-table {
    border-collapse: collapse !important;
    width: 100% !important;
    color: #000000 !important;
  }

  .data-table th,
  .data-table td {
    border: 1px solid #000000 !important;
    color: #000000 !important;
    padding: 8px !important;
  }

  .data-table th {
    background: #f1f5f9 !important;
    font-weight: bold !important;
  }

  .badge {
    border: 1px solid #000 !important;
    color: #000 !important;
    background: transparent !important;
  }
}

/* Estilos para Módulo de Recusas & Lastro Jurídico (NR-6) */
.badge-recusa-registrado {
  background: rgba(148, 163, 184, 0.15);
  color: #94a3b8;
  border: 1px solid rgba(148, 163, 184, 0.3);
}

.badge-recusa-verbal {
  background: rgba(245, 158, 11, 0.15);
  color: #fbbf24;
  border: 1px solid rgba(245, 158, 11, 0.3);
}

.badge-recusa-escrita {
  background: rgba(239, 68, 68, 0.15);
  color: #f87171;
  border: 1px solid rgba(239, 68, 68, 0.35);
  font-weight: 700;
}

.badge-recusa-suspensao {
  background: rgba(220, 38, 38, 0.3);
  color: #fca5a5;
  border: 1px solid #ef4444;
  font-weight: 800;
}

.badge-recusa-arquivado {
  background: rgba(16, 185, 129, 0.15);
  color: #34d399;
  border: 1px solid rgba(16, 185, 129, 0.3);
}

.foto-thumb-btn {
  width: 44px;
  height: 44px;
  border-radius: 6px;
  object-fit: cover;
  border: 1px solid var(--border-color);
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s;
  display: block;
  margin: 0 auto;
}

.foto-thumb-btn:hover {
  transform: scale(1.15);
  box-shadow: 0 4px 12px rgba(239, 68, 68, 0.4);
  border-color: #ef4444;
}

.btn-xs {
  padding: 0.2rem 0.5rem;
  font-size: 0.72rem;
  border-radius: 4px;
}
