:root {
    --primary: #2563eb;       
    --primary-hover: #1d4ed8; 
    --bg-body: #f3f4f6;       
    --bg-sidebar: #111827;    
    --surface: #ffffff;       
    --text-main: #1f2937;     
    --text-muted: #6b7280;    
    --border: #e5e7eb;        
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
}

* { box-sizing: border-box; margin: 0; padding: 0; font-family: 'Inter', sans-serif; -webkit-font-smoothing: antialiased; }

/* CORREÇÃO AQUI: Removemos o display:flex do body */
body { 
    background-color: var(--bg-body); 
    color: var(--text-main); 
    height: 100vh; 
    overflow: hidden; 
    /* display: flex;  <-- REMOVIDO */
}

/* Garante que o container do App ocupe tudo */
#app {
    width: 100%;
    height: 100%;
}

/* ================= UTILS ================= */
.hidden { display: none !important; }

/* ... (Mantenha os estilos de botões .btn-primary, .btn-secondary, .icon-btn iguais) ... */
.btn-primary { background: var(--primary); color: white; padding: 0.6rem 1.2rem; border: none; border-radius: 6px; cursor: pointer; font-weight: 500; font-size: 0.875rem; transition: all 0.2s; display: inline-flex; align-items: center; gap: 8px; justify-content: center; }
.btn-primary:hover { background: var(--primary-hover); transform: translateY(-1px); }
.btn-secondary { background: white; color: var(--text-main); border: 1px solid var(--border); padding: 0.6rem 1.2rem; border-radius: 6px; cursor: pointer; font-weight: 500; font-size: 0.875rem; transition: all 0.2s; display: inline-flex; align-items: center; gap: 8px; }
.btn-secondary:hover { background: #f9fafb; border-color: #d1d5db; }
.icon-btn { padding: 6px; border-radius: 6px; border: 1px solid var(--border); cursor: pointer; background: white; color: var(--text-muted); transition: 0.2s; display: inline-flex; align-items: center; justify-content: center; }
.icon-btn:hover { background: #f3f4f6; color: var(--primary); border-color: var(--primary); }
.icon-btn.whatsapp:hover { color: #10b981; border-color: #10b981; background: #ecfdf5; }
.icon-btn.email:hover { color: #3b82f6; border-color: #3b82f6; background: #eff6ff; }


/* ================= LAYOUTS DE TELA ================= */

/* 1. TELA DE LOGIN (Centralizada Corretamente) */
#auth-screen { 
    width: 100%; 
    height: 100vh; 
    display: flex;       /* Flex apenas aqui para centralizar o box */
    justify-content: center; 
    align-items: center; 
    background: var(--bg-body);
}

.auth-box { 
    background: white; 
    padding: 2rem; 
    width: 100%; 
    max-width: 400px; 
    border-radius: 8px; 
    box-shadow: var(--shadow-sm); 
    border: 1px solid var(--border); 
}

/* 2. DASHBOARD (Menu + Conteúdo) */
#dashboard-screen { 
    display: flex;       /* Flex aqui para colocar Menu ao lado do Conteúdo */
    width: 100%; 
    height: 100%; 
}

/* ... (O restante do CSS para .sidebar, .content, tabelas, etc. continua igual) ... */
/* ================= LAYOUT PRINCIPAL ================= */
#dashboard-screen { display: flex; width: 100%; height: 100%; }

/* SIDEBAR (Menu Lateral) */
.sidebar { 
    width: 260px; background: var(--bg-sidebar); color: white; 
    display: flex; flex-direction: column; border-right: 1px solid #1f2937;
    flex-shrink: 0; 
}

.brand { 
    height: 70px; display: flex; align-items: center; padding: 0 1.5rem; 
    font-size: 1.25rem; font-weight: 700; color: white; border-bottom: 1px solid #1f2937; gap: 12px;
}

.sidebar nav { flex: 1; padding: 1.5rem 1rem; overflow-y: auto; }

.sidebar ul { list-style: none; display: flex; flex-direction: column; gap: 4px; }

.menu-divider { 
    font-size: 0.75rem; color: #9ca3af; margin: 1.5rem 0 0.5rem 0.8rem; 
    font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; 
}

.sidebar li { 
    padding: 0.75rem 1rem; border-radius: 6px; cursor: pointer; 
    display: flex; align-items: center; gap: 12px; color: #d1d5db; 
    font-size: 0.9rem; transition: all 0.2s;
}
.sidebar li:hover { background: rgba(255,255,255,0.05); color: white; }
.sidebar li.active { background: var(--primary); color: white; font-weight: 500; }
.sidebar li i { font-size: 1.2rem; }

/* Rodapé do Menu Fixo */
.sidebar-footer {
    padding: 1rem; border-top: 1px solid #1f2937; background: rgba(0,0,0,0.2); margin-top: auto;
}
.user-info { font-size: 0.8rem; color: #9ca3af; margin-bottom: 0.5rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.logout-link { 
    display: flex; align-items: center; gap: 8px; color: #ef4444; 
    text-decoration: none; font-size: 0.9rem; font-weight: 500; cursor: pointer;
}
.logout-link:hover { text-decoration: underline; }

/* CONTEÚDO PRINCIPAL */
.content { 
    flex: 1; padding: 2rem; overflow-y: auto; overflow-x: hidden; 
    background: var(--bg-body); display: flex; flex-direction: column; gap: 2rem;
    width: 100%; /* Garante que o conteúdo ocupe todo o resto */
}

.view header { 
    display: flex; justify-content: space-between; align-items: center; 
    margin-bottom: 1rem; width: 100%;
}
.view header h2 { font-size: 1.5rem; font-weight: 700; color: #111827; }

/* ================= TABELAS (CORREÇÃO DE LARGURA) ================= */
.table-container {
    background: var(--surface);
    border-radius: 8px;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border);
    overflow: hidden; 
    width: 100%; /* Ocupa 100% do container pai */
}

table { 
    width: 100%; /* Força a tabela a esticar */
    border-collapse: collapse; 
    text-align: left;
}

thead { background: #f9fafb; border-bottom: 1px solid var(--border); }

th { 
    padding: 1rem 1.5rem; font-size: 0.75rem; font-weight: 600; 
    text-transform: uppercase; color: var(--text-muted); letter-spacing: 0.05em;
}

td { 
    padding: 1rem 1.5rem; font-size: 0.9rem; color: var(--text-main); 
    border-bottom: 1px solid var(--border); vertical-align: middle;
}

tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: #f9fafb; }

/* ================= FORMULÁRIOS & MODAIS ================= */
.grid-form { 
    background: var(--surface); padding: 2rem; border-radius: 8px; 
    box-shadow: var(--shadow-sm); border: 1px solid var(--border); width: 100%;
}

.section-title { 
    font-size: 1rem; font-weight: 600; color: #111827; 
    margin: 1.5rem 0 1rem 0; padding-bottom: 0.5rem; border-bottom: 1px solid var(--border); 
}
.section-title:first-child { margin-top: 0; }

.form-row { display: flex; gap: 1.5rem; margin-bottom: 1rem; flex-wrap: wrap; width: 100%; }
.field { flex: 1; min-width: 200px; } 
.field.full { width: 100%; flex: 100%; }

.field label { 
    display: block; font-size: 0.875rem; font-weight: 500; 
    color: #374151; margin-bottom: 0.4rem; 
}

.field input, .field select, .input-group input { 
    width: 100%; padding: 0.6rem 0.8rem; font-size: 0.95rem;
    border: 1px solid #d1d5db; border-radius: 6px; background: #fff;
}
.field input:focus { border-color: var(--primary); outline: none; box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1); }

/* Modais Bonitos */
dialog { 
    margin: auto; padding: 0; border: none; border-radius: 12px; 
    width: 100%; max-width: 480px; box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1); 
}
dialog::backdrop { background: rgba(0,0,0,0.6); backdrop-filter: blur(2px); }

dialog form { padding: 2rem; display: flex; flex-direction: column; gap: 1rem; }
dialog h3 { font-size: 1.25rem; font-weight: 600; margin-bottom: 0.5rem; color: #111827; }

.actions { 
    display: flex; justify-content: flex-end; gap: 12px; margin-top: 1.5rem; padding-top: 1rem; border-top: 1px solid var(--border); 
}
.flex-row { display: flex; gap: 10px; width: 100%; }

/* KPIs Dashboard (Grid Responsivo) */
.kpi-grid { 
    display: grid; 
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); /* Cria colunas automáticas */
    gap: 1.5rem; 
    width: 100%;
}
.kpi-card { 
    background: white; padding: 1.5rem; border-radius: 8px; border: 1px solid var(--border); 
    display: flex; align-items: center; gap: 1.5rem; box-shadow: var(--shadow-sm);
}
.kpi-card i { font-size: 2rem; padding: 12px; background: #eff6ff; color: var(--primary); border-radius: 8px; }
.kpi-info h3 { font-size: 0.875rem; color: var(--text-muted); font-weight: 500; margin-bottom: 4px; }
.kpi-info span { font-size: 1.875rem; font-weight: 700; color: #111827; }

/* Auth */
#auth-screen { background: #f9fafb; width: 100%; height: 100vh; display: flex; justify-content: center; align-items: center; }
.auth-box { background: white; padding: 2rem; width: 100%; max-width: 400px; border-radius: 8px; box-shadow: var(--shadow-sm); border: 1px solid var(--border); }
.input-group { margin-bottom: 1rem; width: 100%; }
.input-group label { display: block; margin-bottom: 0.5rem; font-size: 0.9rem; }
/* Estilo do Dropdown Admin */
#admin-company-select:focus { outline: none; border: 1px solid var(--primary); }
