@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700&family=Inter:wght@300;400;500;600;700&display=swap');

/* ==========================================================================
   🎨 DESIGN SYSTEM PREMIUM - SISTEMA OS (SA ENGENHARIA CLÍNICA)
   ========================================================================== */

/* 1. VARIÁVEIS E CONFIGURAÇÕES DE TEMA */
:root {
  --primary: #2563eb;         /* Azul Cobalto */
  --primary-hover: #1d4ed8;
  --primary-light: #eff6ff;
  --secondary: #0f172a;       /* Slate Escuro (Sidebar) */
  --secondary-hover: #1e293b;
  --accent: #38bdf8;          /* Azul Céu */
  --bg-app: #f8fafc;          /* Fundo Limpo */
  --bg-card: #ffffff;         /* Fundo de Elementos */
  --text-main: #334155;       /* Texto Geral */
  --text-muted: #64748b;      /* Texto Secundário */
  --border: #e2e8f0;          /* Divisores */
  
  /* Estados */
  --success: #10b981;
  --success-bg: #ecfdf5;
  --success-border: #a7f3d0;
  
  --warning: #f59e0b;
  --warning-bg: #fffbeb;
  --warning-border: #fde68a;
  
  --error: #ef4444;
  --error-bg: #fef2f2;
  --error-border: #fca5a5;
  
  /* Efeitos */
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -2px rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -4px rgba(0, 0, 0, 0.1);
  --transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

/* 2. RESET E BASE GERAL */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: "Outfit", "Inter", "Segoe UI", Roboto, sans-serif;
  background-color: var(--bg-app);
  color: var(--text-main);
  display: flex;
  height: 100vh;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  transition: background-color 0.3s ease, color 0.3s ease;
}

/* 3. ESTRUTURA DE LAYOUT PRINCIPAL */
.container {
  display: flex;
  width: 100%;
  height: 100%;
}

/* ======== SIDEBAR ======== */
.sidebar {
  width: 260px;
  background: var(--secondary);
  color: #fff;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  transition: var(--transition);
  box-shadow: 4px 0 25px rgba(0, 0, 0, 0.15);
  z-index: 100;
  flex-shrink: 0;
}

.sidebar h2 {
  text-align: center;
  padding: 24px 16px;
  font-size: 1.3rem;
  font-weight: 700;
  letter-spacing: 0.8px;
  background: rgba(255, 255, 255, 0.03);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  color: #fff;
}

.sidebar nav {
  display: flex;
  flex-direction: column;
  padding: 15px 12px;
  gap: 6px;
  flex-grow: 1;
  overflow-y: auto;
}

.sidebar a {
  display: flex;
  align-items: center;
  color: #94a3b8; /* Texto esmaecido na barra lateral */
  text-decoration: none;
  padding: 12px 18px;
  border-radius: var(--radius-sm);
  transition: var(--transition);
  font-weight: 500;
  font-size: 0.95rem;
  gap: 10px;
}

.sidebar a:hover {
  background: rgba(255, 255, 255, 0.06);
  color: #fff;
  padding-left: 24px;
}

.sidebar a.active, .sidebar a:active {
  background: var(--primary);
  color: #fff;
  font-weight: 600;
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.3);
}

.sidebar .logout {
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.2);
  color: #f87171;
  text-align: center;
  margin: 15px 12px;
  padding: 12px;
  border-radius: var(--radius-sm);
  transition: var(--transition);
  font-weight: 600;
  display: block;
}

.sidebar .logout:hover {
  background: #ef4444;
  color: white;
  box-shadow: 0 4px 12px rgba(239, 68, 68, 0.3);
}

/* ======== CONTEÚDO PRINCIPAL ======== */
.main-content {
  flex: 1;
  padding: 30px;
  overflow-y: auto;
  transition: var(--transition);
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 25px;
}

/* ======== CABEÇALHO / HEADER ======== */
.header {
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-main);
  padding: 20px 28px;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.header h1 {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--secondary);
  margin-bottom: 4px;
}

.header p {
  font-size: 0.9rem;
  color: var(--text-muted);
}

.toggle-menu {
  display: none;
  background: var(--primary-light);
  color: var(--primary);
  border: 1px solid rgba(37, 99, 235, 0.15);
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 1.2rem;
  transition: var(--transition);
}

.toggle-menu:hover {
  background: var(--primary);
  color: white;
}

/* ======== CARDS DE RESUMO / DASHBOARD ======== */
.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 20px;
}

.card {
  background: var(--bg-card);
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  padding: 24px;
  transition: var(--transition);
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-lg);
  border-color: rgba(37, 99, 235, 0.2);
}

.card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 4px;
  background: linear-gradient(90deg, var(--primary), var(--accent));
}

.card h3 {
  font-size: 0.9rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  font-weight: 600;
}

.card p {
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--secondary);
}

.card p a {
  color: inherit;
  text-decoration: none;
  display: block;
}

/* ======== FILTROS / BUSCA ======== */
.filter-bar, .filter-card, .search-box {
  background: var(--bg-card);
  padding: 20px 24px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  display: flex;
  align-items: flex-end;
  gap: 15px;
  flex-wrap: wrap;
}

.filter-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1;
  min-width: 180px;
}

.filter-group label, .filter-bar label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-main);
}

select, input[type="text"], input[type="email"], input[type="password"], input[type="date"], input[type="time"], input[type="number"], textarea {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: #fff;
  color: var(--text-main);
  font-size: 0.95rem;
  transition: var(--transition);
  outline: none;
}

select:focus, input:focus, textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

/* ======== BOTÕES ======== */
.btn, button, a.button-voltar, input[type="submit"] {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 10px 18px;
  font-weight: 600;
  font-size: 0.9rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: var(--transition);
  text-decoration: none;
  border: none;
  gap: 8px;
}

button, input[type="submit"] {
  background: var(--primary);
  color: #fff;
}

button:hover, input[type="submit"]:hover {
  background: var(--primary-hover);
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.2);
}

.btn-add {
  background: var(--success);
  color: #fff;
}
.btn-add:hover {
  background: #059669;
  box-shadow: 0 4px 12px rgba(16, 185, 129, 0.2);
}

.btn-edit {
  background: var(--primary);
  color: #fff;
  padding: 6px 12px;
  font-size: 0.85rem;
}
.btn-edit:hover {
  background: var(--primary-hover);
}

.btn-delete {
  background: var(--error);
  color: #fff;
  padding: 6px 12px;
  font-size: 0.85rem;
}
.btn-delete:hover {
  background: #dc2626;
  box-shadow: 0 4px 12px rgba(239, 68, 68, 0.2);
}

a.button-voltar {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border);
}

a.button-voltar:hover {
  background: var(--bg-app);
  color: var(--text-main);
  border-color: var(--text-muted);
}

/* ======== TABELAS ======== */
.table-container {
  background: var(--bg-card);
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  overflow-x: auto;
  overflow-y: auto !important; /* Permite scroll vertical se redimensionado menor */
  padding-bottom: 8px; /* Espaço para a barra de rolagem não sobrepor a última linha */
  resize: vertical; /* Permite esticar verticalmente com o mouse no canto inferior direito */
  min-height: 150px;
}

/* Customização premium da barra de rolagem horizontal da tabela */
.table-container::-webkit-scrollbar {
  height: 6px; /* Barra de rolagem mais fina e elegante */
}

.table-container::-webkit-scrollbar-track {
  background: transparent;
  margin: 0 10px;
}

.table-container::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 10px;
}

.table-container::-webkit-scrollbar-thumb:hover {
  background: var(--primary);
}

table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
}

th {
  background: #f8fafc;
  color: var(--text-muted);
  font-weight: 600;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
}

td {
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  font-size: 0.92rem;
  color: var(--text-main);
}

tr:last-child td {
  border-bottom: none;
}

tr:hover td {
  background: #f8fafc;
}

/* ======== FORMULÁRIOS ======== */
.form-container {
  background: var(--bg-card);
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  padding: 30px;
  max-width: 900px;
  margin: 0 auto;
  width: 100%;
}

.form-container h2 {
  font-size: 1.3rem;
  color: var(--secondary);
  font-weight: 700;
  margin-bottom: 20px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 10px;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 20px;
  margin-bottom: 25px;
}

.form-grid > div {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-grid label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-main);
}

.section-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--primary);
  margin: 25px 0 12px 0;
  border-left: 4px solid var(--primary);
  padding-left: 10px;
}

/* ======== CANVAS DE ASSINATURA ======== */
.canvas-container {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: #fafafa;
  overflow: hidden;
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
}

.signature-canvas {
  background: #fff;
  border-bottom: 1px solid var(--border);
  cursor: crosshair;
  width: 100%;
  height: 200px;
  touch-action: none; /* Previne scroll no mobile durante desenho */
}

.canvas-buttons {
  display: flex;
  gap: 10px;
  padding: 10px;
  width: 100%;
  justify-content: flex-end;
  background: #f8fafc;
}

/* ======== ALERTAS ANIMAÇÕES ======== */
.message, .alert {
  padding: 14px 20px;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 0.9rem;
  display: flex;
  align-items: center;
  gap: 10px;
  animation: slideIn 0.3s ease forwards;
  border: 1px solid;
}

@keyframes slideIn {
  from { transform: translateY(-10px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

.message.success, .alert.sucesso, .alert-success {
  background-color: var(--success-bg);
  color: var(--success);
  border-color: var(--success-border);
}

.message.error, .alert.erro, .alert-error {
  background-color: var(--error-bg);
  color: var(--error);
  border-color: var(--error-border);
}

/* ======== FOOTER ======== */
.login-footer {
  text-align: center;
  padding: 20px 0;
  font-size: 0.8rem;
  color: var(--text-muted);
  width: 100%;
  margin-top: auto;
}

/* ======== FILTRO SEÇÃO GERAL (DASHBOARD) ======== */
.section-header {
  font-size: 1.15rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--secondary);
  margin-top: 20px;
  display: flex;
  align-items: center;
  gap: 8px;
  border-bottom: 2px solid var(--border);
  padding-bottom: 8px;
}

.charts-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(340px, 1fr));
  gap: 20px;
}

.chart-box {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  padding: 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.chart-box h2 {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--text-muted);
  margin-bottom: 15px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.chart-container-inner {
  position: relative;
  height: 250px;
  width: 100%;
}

.span-2 {
  grid-column: span 2;
}

/* ==========================================================================
   📱 RESPONSIVIDADE E EFEITOS MOBILE
   ========================================================================== */
.overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(15, 23, 42, 0.4); /* Slate com opacidade */
  -webkit-backdrop-filter: blur(2px);
  backdrop-filter: blur(2px);
  z-index: 99;
}

@media (max-width: 1024px) {
  .span-2 {
    grid-column: span 1;
  }
}

@media (max-width: 768px) {
  body {
    flex-direction: column;
  }
  
  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    height: 100vh;
    transform: translateX(-100%);
    width: 260px;
  }
  
  .sidebar.active {
    transform: translateX(0);
  }
  
  .overlay.active {
    display: block;
  }
  
  .toggle-menu {
    display: block;
  }
  
  .main-content {
    padding: 15px;
  }
  
  .header {
    padding: 15px 20px;
    margin-bottom: 15px;
  }
  
  .charts-grid {
    grid-template-columns: 1fr;
  }
}

/* ==========================================================================
   📱 3 PERFIS DE VISUALIZAÇÃO E NORMAS DE USABILIDADE PWA
   ========================================================================== */

/* --- PERFIL 1: PC / DESKTOP (Largura > 1024px) --- */
@media (min-width: 1025px) {
  .main-content {
    max-width: 100%;
  }
}

/* --- PERFIL 2: TABLET (Largura 769px até 1024px) --- */
@media (min-width: 769px) and (max-width: 1024px) {
  .main-content {
    padding: 20px;
  }
  .form-container {
    max-width: 100%;
  }
}

/* --- PERFIL 3: MOBILE (Largura <= 768px) + DIRETRIZES PWA --- */
@media (max-width: 768px) {
  /* Prevenção de overflow e melhora no tap do mobile */
  html, body {
    overflow-x: hidden;
    position: relative;
    max-width: 100%;
    -webkit-tap-highlight-color: transparent; /* Remove contorno de toque azul nos navegadores móveis */
  }

  /* Otimização PWA: Área mínima de toque (44px) recomendada pelas diretrizes WCAG/Apple/Google */
  input, select, textarea, button, .btn, .sidebar a {
    min-height: 44px;
    touch-action: manipulation; /* Remove o delay nativo de 300ms nos cliques do mobile */
  }

  /* Suporte a Safe Area (Evita que o botão inferior seja coberto pela barra inicial do iOS/Android) */
  body {
    padding-bottom: env(safe-area-inset-bottom, 20px);
  }

  /* Scroll macio e inercial nativo em painéis móveis */
  .main-content, .table-container {
    overflow-y: auto;
  }
}

/* ==========================================================================
   🎯 ESTILO DE ALINHAMENTO DO GOOGLE MATERIAL SYMBOLS
   ========================================================================== */
.material-symbols-outlined {
  display: inline-flex;
  vertical-align: middle;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  line-height: 1;
  width: 1.5rem;
  height: 1.5rem;
}

.sidebar nav a .material-symbols-outlined {
  font-size: 1.3rem;
  width: 1.5rem;
  height: 1.5rem;
  flex-shrink: 0;
  opacity: 0.7;
  transition: opacity 0.25s ease;
}

.sidebar nav a:hover .material-symbols-outlined,
.sidebar nav a.active .material-symbols-outlined {
  opacity: 1;
}

.sidebar .logout .material-symbols-outlined {
  font-size: 1.2rem;
  vertical-align: middle;
}

/* ==========================================================================
   🛠️ SIMULADORES DE LAYOUT E MUDANÇA DE TEMA GLOBAL
   ========================================================================== */

/* --- Classes do Body para Simulação de Layout --- */
body.layout-mobile {
  flex-direction: column !important;
}

body.layout-mobile .sidebar {
  position: fixed !important;
  left: 0 !important;
  top: 0 !important;
  height: 100vh !important;
  transform: translateX(-100%) !important;
  width: 260px !important;
  z-index: 999 !important;
}

body.layout-mobile .sidebar.active {
  transform: translateX(0) !important;
}

body.layout-mobile .overlay.active {
  display: block !important;
}

/* Responsividade Nativa para Dispositivos Móveis (@media) */
@media (max-width: 768px) {
  .toggle-menu {
    display: block !important;
  }

  .main-content {
    padding: 15px !important;
  }

  .table-container,
  .table-responsive {
    display: none !important;
  }

  .mobile-cards {
    display: flex !important;
    flex-direction: column !important;
    gap: 15px !important;
  }
}

body.layout-mobile .toggle-menu {
  display: block !important;
}

body.layout-mobile .main-content {
  padding: 15px !important;
}

body.layout-mobile .table-container {
  display: none !important;
}

body.layout-mobile .mobile-cards {
  display: flex !important;
  flex-direction: column !important;
  gap: 15px !important;
}

body.layout-tablet .main-content {
  padding: 20px !important;
}

body.layout-tablet .form-container {
  max-width: 100% !important;
}

/* --- Tema Escuro (Dark Mode) --- */
body.theme-dark {
  --bg-app: #0b0f19;
  --bg-card: #151f32;
  --text-main: #cbd5e1;
  --text-muted: #94a3b8;
  --border: #1e293b;
  --secondary: #1e293b;
  --secondary-hover: #334155;
}

body.theme-dark .sidebar {
  background: #0f172a !important;
  border-right: 1px solid #1e293b;
}

body.theme-dark th {
  background: rgba(255, 255, 255, 0.02) !important;
  color: #94a3b8 !important;
  border-bottom-color: #1e293b !important;
}

body.theme-dark td {
  color: #cbd5e1 !important;
  border-bottom-color: #1e293b !important;
}

body.theme-dark tr:hover td {
  background: rgba(255, 255, 255, 0.02) !important;
}

body.theme-dark input, 
body.theme-dark select, 
body.theme-dark textarea {
  background: #151f32 !important;
  color: #cbd5e1 !important;
  border-color: #1e293b !important;
}

body.theme-dark .btn-upload {
  background: #1e293b !important;
  border-color: #334155 !important;
  color: #94a3b8 !important;
}

body.theme-dark .btn-upload:hover {
  background: #2563eb1a !important;
  border-color: #2563eb !important;
  color: #38bdf8 !important;
}

body.theme-dark .file-selected {
  background-color: #064e3b !important;
  border-color: #10b981 !important;
  color: #a7f3d0 !important;
}

body.theme-dark .canvas-container {
  background: #0f172a !important;
  border-color: #1e293b !important;
}

body.theme-dark .signature-canvas {
  background: #ffffff !important; /* Mantém a lona branca para visibilidade do traço */
  border-bottom-color: #1e293b !important;
}

body.theme-dark .canvas-buttons {
  background: #151f32 !important;
}

body.theme-dark .form-container {
  background: #151f32 !important;
  border-color: #1e293b !important;
}

body.theme-dark .card, 
body.theme-dark .report-card, 
body.theme-dark .mobile-card,
body.theme-dark .kpi-card,
body.theme-dark .action-card {
  background: #151f32 !important;
  border-color: #1e293b !important;
}

body.theme-dark .action-card:hover {
  background: #1e293b !important;
}

body.theme-dark .kpi-info p {
  color: #f1f5f9 !important;
}

body.theme-dark .progress-circle {
  background: radial-gradient(#151f32 55%, transparent 56%),
              conic-gradient(#2563eb calc(var(--percent) * 1%), #1e293b 0) !important;
}

body.theme-dark .advanced-filters {
  background: #151f32 !important;
  border-color: #1e293b !important;
}

/* Força contraste adequado para todos os cabeçalhos, textos e rótulos no modo escuro */
body.theme-dark h1,
body.theme-dark h2,
body.theme-dark h3,
body.theme-dark h4,
body.theme-dark h5,
body.theme-dark h6,
body.theme-dark .header h2,
body.theme-dark .main-content h2,
body.theme-dark .main-content h3 {
  color: #f1f5f9 !important; /* Branco fosco de alto contraste */
}

body.theme-dark p,
body.theme-dark span:not(.badge):not(.status-selo):not(.material-symbols-outlined),
body.theme-dark strong,
body.theme-dark label {
  color: #cbd5e1 !important; /* Cinza claro legível */
}

body.theme-dark .text-muted,
body.theme-dark p[style*="color"] {
  color: #94a3b8 !important; /* Muted contrastado */
}


/* --- Correção de Grid e Flex em células <td> de Ações das Tabelas --- */
td.action-links {
  display: table-cell !important;
  white-space: nowrap !important;
  vertical-align: middle !important;
  text-align: left !important;
}

td.action-links .btn, 
td.action-links a, 
td.action-links button {
  display: inline-flex !important;
  vertical-align: middle !important;
  margin-right: 8px !important;
}

td.action-links .btn:last-child, 
td.action-links a:last-child, 
td.action-links button:last-child {
  margin-right: 0 !important;
}

/* ==========================================================================
   📱 MENU INFERIOR PWA / BOTTOM NAVIGATION BAR (Mobile First)
   ========================================================================== */
.bottom-nav {
  display: none; /* Escondido por padrão no desktop */
}

@media (max-width: 768px) {
  .bottom-nav {
    display: flex !important;
    position: fixed !important;
    bottom: 0 !important;
    left: 0 !important;
    width: 100% !important;
    height: 65px !important;
    background: var(--bg-card) !important;
    border-top: 1px solid var(--border) !important;
    box-shadow: 0 -3px 15px rgba(0, 0, 0, 0.06) !important;
    z-index: 998 !important; /* Mantém abaixo da sidebar overlays que é 999 */
    justify-content: space-around !important;
    align-items: center !important;
    padding-bottom: env(safe-area-inset-bottom, 0px) !important;
  }

  .bottom-nav-item {
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    justify-content: center !important;
    color: var(--text-muted) !important;
    text-decoration: none !important;
    font-size: 0.72rem !important;
    font-weight: 600 !important;
    gap: 3px !important;
    flex: 1 !important;
    height: 100% !important;
    transition: var(--transition) !important;
  }

  .bottom-nav-item:hover, .bottom-nav-item.active {
    color: var(--primary) !important;
  }

  .bottom-nav-item .material-symbols-outlined {
    font-size: 1.45rem !important;
  }

  body {
    padding-bottom: calc(75px + env(safe-area-inset-bottom, 0px)) !important;
  }
}

/* Sobrescrita manual da classe de simulação .layout-mobile */
body.layout-mobile .bottom-nav {
  display: flex !important;
  position: fixed !important;
  bottom: 0 !important;
  left: 0 !important;
  width: 100% !important;
  height: 65px !important;
  background: var(--bg-card) !important;
  border-top: 1px solid var(--border) !important;
  box-shadow: 0 -3px 15px rgba(0, 0, 0, 0.06) !important;
  z-index: 998 !important;
  justify-content: space-around !important;
  align-items: center !important;
  padding-bottom: env(safe-area-inset-bottom, 0px) !important;
}

body.layout-mobile .bottom-nav-item {
  display: flex !important;
  flex-direction: column !important;
  align-items: center !important;
  justify-content: center !important;
  color: var(--text-muted) !important;
  text-decoration: none !important;
  font-size: 0.72rem !important;
  font-weight: 600 !important;
  gap: 3px !important;
  flex: 1 !important;
  height: 100% !important;
  transition: var(--transition) !important;
}

body.layout-mobile .bottom-nav-item:hover, 
body.layout-mobile .bottom-nav-item.active {
  color: var(--primary) !important;
}

body.layout-mobile .bottom-nav-item .material-symbols-outlined {
  font-size: 1.45rem !important;
}

body.layout-mobile {
  padding-bottom: 80px !important;
}

/* Suporte de cor escura para o Bottom Nav */
body.theme-dark .bottom-nav {
  background: #151f32 !important;
  border-top-color: #1e293b !important;
}

/* ==========================================================================
   CENTRALIZED COMPONENTS (PHASE 1, 2 & 3)
   ========================================================================== */

/* 1.1 Modal Styles */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(15, 23, 42, 0.6);
    -webkit-backdrop-filter: blur(4px);
    backdrop-filter: blur(4px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    transition: opacity 0.3s ease;
}
.modal.active {
    display: flex;
    opacity: 1;
}
.modal-content {
    background: var(--bg-card);
    border-radius: var(--radius-md);
    width: 100%;
    max-width: 600px;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    padding: 25px;
    position: relative;
    transform: scale(0.9);
    transition: transform 0.3s ease;
}
.modal.active .modal-content {
    transform: scale(1);
}
.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border);
    padding-bottom: 15px;
    margin-bottom: 20px;
}
.modal-header h3 {
    margin: 0;
    font-size: 20px;
    color: var(--secondary);
}
.close-btn {
    background: none;
    border: none;
    font-size: 20px;
    cursor: pointer;
    color: var(--text-muted);
    transition: color 0.2s;
}
.close-btn:hover {
    color: var(--text-main);
}
.detail-row {
    display: flex;
    justify-content: space-between;
    padding: 10px 0;
    border-bottom: 1px solid var(--border);
}
.detail-label {
    font-weight: 600;
    color: var(--text-muted);
}
.detail-value {
    color: var(--text-main);
}
.modal-footer {
    margin-top: 25px;
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

body.theme-dark .modal { background: rgba(0, 0, 0, 0.7); }
body.theme-dark .modal-content { background: var(--bg-card); border: 1px solid var(--border); }
body.theme-dark .modal-header h3 { color: var(--text-main); }
body.theme-dark .close-btn { color: var(--text-muted); }
body.theme-dark .close-btn:hover { color: var(--text-main); }

/* 1.2 Instant Search Bar */
.instant-search {
    width: 100%;
    padding: 10px 15px;
    font-size: 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-card);
    color: var(--text-main);
    outline: none;
    margin-bottom: 20px;
    box-shadow: inset 0 1px 2px rgba(0,0,0,0.05);
}

body.theme-dark .instant-search {
    background: var(--bg-card);
    color: var(--text-main);
    border-color: var(--border);
}

/* 1.3 Tabs System */
.tabs-container {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
    flex-wrap: wrap;
    border-bottom: 1px solid var(--border);
    padding-bottom: 10px;
}
.tab-btn {
    padding: 8px 16px;
    background: var(--bg-app);
    color: var(--text-muted);
    border: 1px solid var(--border);
    border-radius: 6px;
    cursor: pointer;
    font-weight: 600;
    font-size: 14px;
    transition: all 0.2s ease;
}
.tab-btn.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}
.tab-btn:hover:not(.active) {
    background: var(--border);
}

body.theme-dark .tab-btn {
    background: var(--bg-card);
    color: var(--text-muted);
    border-color: var(--border);
}
body.theme-dark .tab-btn:hover:not(.active) {
    background: var(--bg-app);
}

/* 1.4 Mobile Cards */
.mobile-cards {
    display: none;
}
.mobile-card, .report-card, .ticket-card, .client-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 20px;
    box-shadow: var(--shadow-sm);
    transition: transform 0.2s, box-shadow 0.2s;
    cursor: pointer;
}
.mobile-card:hover, .report-card:hover, .ticket-card:hover, .client-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}
.mobile-card p, .report-card p, .ticket-card p, .client-card p {
    margin: 6px 0;
    font-size: 13px;
    color: var(--text-muted);
}
.mobile-card p i, .report-card p i, .ticket-card p i, .client-card p i {
    width: 20px;
    color: var(--primary);
}

/* 1.5 Badges/Status */
.badge {
    display: inline-block;
    padding: 4px 8px;
    font-size: 12px;
    font-weight: 600;
    border-radius: 12px;
    text-align: center;
}
/* Priority */
.priority-Alta { background: #fef2f2; color: #ef4444; border: 1px solid #fee2e2; }
.priority-Média { background: #fffbeb; color: #f59e0b; border: 1px solid #fef3c7; }
.priority-Baixa { background: #eff6ff; color: #2563eb; border: 1px solid #dbeafe; }
/* Status */
.status-Aberto { background: #fef2f2; color: #ef4444; border: 1px solid #fee2e2; }
.status-EmAndamento { background: #fffbeb; color: #f59e0b; border: 1px solid #fef3c7; }
.status-EmAtendimento { background: #faf5ff; color: #7c3aed; border: 1px solid #e9d5ff; }
.status-Agendado { background: #e0f2fe; color: #0369a1; border: 1px solid #bae6fd; }
.status-Pausado { background: #f1f5f9; color: #4b5563; border: 1px solid #cbd5e1; }
.status-Atrasado { background: #fef2f2; color: #b91c1c; border: 1px solid #fee2e2; }
.status-Concluído { background: #f0fdf4; color: #16a34a; border: 1px solid #dcfce7; }
.status-Cancelado { background: #fef2f2; color: #dc2626; border: 1px solid #fee2e2; }
/* Maint */
.maint-Corretiva { background: #fef2f2; color: #ef4444; border: 1px solid #fee2e2; }
.maint-Preventiva { background: #f0fdf4; color: #16a34a; border: 1px solid #dcfce7; }
.maint-Calibração { background: #eff6ff; color: #2563eb; border: 1px solid #dbeafe; }
.maint-Instalação { background: #faf5ff; color: #7c3aed; border: 1px solid #f3e8ff; }
.maint-Outros { background: #f3f4f6; color: #4b5563; border: 1px solid #e5e7eb; }

body.theme-dark .priority-Alta, body.theme-dark .status-Aberto, body.theme-dark .maint-Corretiva, body.theme-dark .status-Atrasado, body.theme-dark .status-Cancelado { background: rgba(239, 68, 68, 0.1); border-color: rgba(239, 68, 68, 0.2); color: #fca5a5; }
body.theme-dark .priority-Média, body.theme-dark .status-EmAndamento { background: rgba(245, 158, 11, 0.1); border-color: rgba(245, 158, 11, 0.2); color: #fcd34d; }
body.theme-dark .priority-Baixa, body.theme-dark .maint-Calibração, body.theme-dark .status-Agendado { background: rgba(37, 99, 235, 0.1); border-color: rgba(37, 99, 235, 0.2); color: #93c5fd; }
body.theme-dark .status-Concluído, body.theme-dark .maint-Preventiva { background: rgba(22, 163, 74, 0.1); border-color: rgba(22, 163, 74, 0.2); color: #86efac; }
body.theme-dark .maint-Instalação, body.theme-dark .status-EmAtendimento { background: rgba(124, 58, 237, 0.1); border-color: rgba(124, 58, 237, 0.2); color: #d8b4fe; }
body.theme-dark .maint-Outros, body.theme-dark .status-Pausado { background: rgba(75, 85, 99, 0.2); border-color: rgba(75, 85, 99, 0.3); color: #d1d5db; }

/* 1.6 Advanced Filters */
.advanced-filters {
    background: var(--bg-app);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 15px;
    margin-top: 15px;
    margin-bottom: 20px;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 12px;
    align-items: flex-end;
}
.filter-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.filter-group label {
    font-size: 12px;
    font-weight: 700;
    color: var(--text-muted);
}
.filter-group select, .filter-group input {
    padding: 8px 12px;
    font-size: 14px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--bg-card);
    color: var(--text-main);
    outline: none;
    transition: border-color 0.2s;
    width: 100%;
    box-sizing: border-box;
}
.filter-group select:focus, .filter-group input:focus {
    border-color: var(--primary);
}
.filter-actions {
    display: flex;
    gap: 8px;
}
.btn-filter-clear {
    background: var(--border);
    color: var(--text-main);
    padding: 8px 16px;
    font-size: 14px;
    font-weight: 600;
    border-radius: 6px;
    border: none;
    cursor: pointer;
    transition: background 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    height: 38px;
    box-sizing: border-box;
}
.btn-filter-clear:hover {
    background: var(--text-muted);
    color: white;
}
.filter-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
}

body.theme-dark .advanced-filters { background: var(--bg-card); }
body.theme-dark .filter-group select, body.theme-dark .filter-group input { background: var(--bg-app); border-color: var(--border); }
body.theme-dark .btn-filter-clear { background: var(--bg-app); color: var(--text-main); }
body.theme-dark .btn-filter-clear:hover { background: var(--primary); color: white; }

/* 1.7 Dashboard Components */
.dynamic-header {
    background: linear-gradient(135deg, var(--primary), var(--accent));
    padding: 25px;
    border-radius: var(--radius-md);
    color: white;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 10px 20px -5px rgba(37, 99, 235, 0.4);
    margin-bottom: 25px;
}
.live-clock {
    display: flex;
    align-items: center;
    gap: 10px;
    background: rgba(255, 255, 255, 0.15);
    padding: 10px 20px;
    border-radius: 20px;
    -webkit-backdrop-filter: blur(5px);
    backdrop-filter: blur(5px);
}
.live-clock span {
    font-size: 1.1rem;
    font-weight: 600;
    letter-spacing: 1px;
}
.kpi-section {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-bottom: 25px;
}
.kpi-card {
    background: var(--bg-card);
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
    padding: 25px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: var(--shadow-sm);
    transition: var(--transition);
}
.kpi-card:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow-md);
    border-color: rgba(37, 99, 235, 0.2);
}
.kpi-info h3 {
    font-size: 0.85rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 5px;
}
.kpi-info p {
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--secondary);
}
.progress-circle {
    width: 65px;
    height: 65px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.85rem;
    color: var(--text-main);
    background: radial-gradient(closest-side, var(--bg-card) 79%, transparent 80% 100%),
                conic-gradient(var(--color-progress, var(--primary)) calc(var(--percent, 0) * 1%), var(--border) 0);
}
.action-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 15px;
}
.action-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 20px;
    text-align: center;
    text-decoration: none;
    color: var(--text-main);
    transition: var(--transition);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
}
.action-card:hover {
    background: var(--primary-light);
    border-color: rgba(37, 99, 235, 0.3);
    color: var(--primary);
    transform: scale(1.02);
}

body.theme-dark .kpi-info p { color: var(--text-main); }
body.theme-dark .action-card:hover { background: rgba(37, 99, 235, 0.1); }

/* 2. Responsividade Mobile */
@media (max-width: 768px) {
    .table-container {
        display: none !important;
    }
    .mobile-cards {
        display: grid !important;
        grid-template-columns: 1fr;
        gap: 15px;
    }
    .modal-footer {
        flex-direction: column;
    }
    .modal-footer button, .modal-footer a {
        width: 100%;
        text-align: center;
        justify-content: center;
    }
}
@media (max-width: 360px) {
    .dynamic-header {
        flex-direction: column;
        text-align: center;
        gap: 15px;
    }
}