:root {
    --primary: #0C3782;
    --primary-hover: #08265c;
    --white: #ffffff;
    --bg-light: #f4f7f6;
    --text-dark: #2c3e50;
    --text-muted: #95a5a6;
    --border-color: #e2e8f0;
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.1);
    --shadow-md: 0 4px 6px rgba(0,0,0,0.1);
    --radius: 8px;
}

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

body { background-color: var(--bg-light); color: var(--text-dark); height: 100vh; overflow: hidden; }

/* Utilities */
.hidden { display: none !important; }
.btn { padding: 10px 16px; border: none; border-radius: var(--radius); cursor: pointer; font-weight: 500; transition: all 0.2s; font-size: 0.9rem; }
.btn-primary { background-color: var(--primary); color: var(--white); }
.btn-primary:hover { background-color: var(--primary-hover); }
.btn-accent { background-color: var(--accent); color: var(--white); }
.btn-secondary {
    background-color: #fff;
    color: #64748b;
    border: 1px solid #cbd5e0;
    font-weight: 500;
}
.btn-secondary:hover {
    background-color: #f1f5f9;
    color: #334155;
    border-color: #94a3b8;
}
.modal-footer .btn {
    min-width: 100px;
    padding: 8px 16px;
    font-size: 0.9rem;
}

input:disabled, input[readonly] {
    background-color: #f1f5f9;
    color: #64748b;
    cursor: not-allowed;
}
.btn-block { width: 100%; }
.btn-sm { padding: 6px 12px; font-size: 0.8rem; }
.btn-icon { background: none; border: none; color: var(--white); cursor: pointer; font-size: 1.2rem; }

/* Login View */
#login-view { height: 100vh; display: flex; align-items: center; justify-content: center; background: linear-gradient(135deg, var(--bg-light) 0%, #e6f7ff 100%); }
.login-box { background: var(--white); padding: 40px; border-radius: var(--radius); box-shadow: var(--shadow-md); width: 100%; max-width: 400px; text-align: center; }
.brand-logo { display: flex; align-items: center; justify-content: center; gap: 10px; margin-bottom: 10px; }
.brand-logo { display: flex; align-items: center; justify-content: center; gap: 10px; margin-bottom: 20px; }
.logo-img {
    width: 50px;
    height: 50px;
    object-fit: cover; /* Garante que a imagem não distorça */
    border-radius: 50%; /* Deixa redonda */
    border: 2px solid var(--primary);
    background-color: var(--white);
}
.sidebar .logo-img {
    border: 2px solid var(--white);
    width: 40px;
    height: 40px;
}
.brand-logo.white h1 { color: var(--white); font-size: 1.5rem; margin: 0; }
.subtitle { color: var(--text-muted); margin-bottom: 30px; font-size: 0.9rem; }

/* Forms */
.form-group { text-align: left; margin-bottom: 15px; }
.form-group label { display: block; margin-bottom: 5px; font-size: 0.85rem; font-weight: 600; color: var(--text-dark); }
input, select, textarea { width: 100%; padding: 10px; border: 1px solid var(--border-color); border-radius: var(--radius); outline: none; transition: border 0.2s; font-size: 0.9rem; }
input:focus, select:focus, textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 2px rgba(6, 147, 227, 0.1); }

/* App Dashboard Layout */
#app-view { display: flex; height: 100vh; }

/* Sidebar */
.sidebar { width: 250px; background: var(--primary); color: var(--white); display: flex; flex-direction: column; padding: 20px; box-shadow: 4px 0 10px rgba(0,0,0,0.05); }
.brand-logo.white h1 { color: var(--white); font-size: 1.5rem; }
.logo-icon.white-bg { background: var(--white); color: var(--primary); }
.nav-menu { margin-top: 40px; flex: 1; display: flex; flex-direction: column; gap: 5px; }
.nav-link { text-decoration: none; color: rgba(255,255,255,0.7); padding: 12px 15px; border-radius: var(--radius); transition: all 0.2s; display: flex; align-items: center; }
.nav-link:hover, .nav-link.active { background: rgba(255,255,255,0.15); color: var(--white); font-weight: 600; }
.user-profile { margin-top: auto; padding-top: 20px; border-top: 1px solid rgba(255,255,255,0.2); display: flex; align-items: center; gap: 10px; }
.avatar { width: 32px; height: 32px; background: var(--accent); border-radius: 50%; display: flex; align-items: center; justify-content: center; font-weight: bold; font-size: 14px; }
.user-info { flex: 1; display: flex; flex-direction: column; }
.user-info small { opacity: 0.7; font-size: 0.75rem; }

/* Main Content */
.main-content { flex: 1; display: flex; flex-direction: column; overflow: hidden; }
.top-bar { background: var(--white); padding: 15px 30px; border-bottom: 1px solid var(--border-color); display: flex; justify-content: space-between; align-items: center; height: 70px; }
.content-wrapper { padding: 30px; overflow-y: auto; height: calc(100vh - 70px); }

/* Tables */
.table-container { background: var(--white); border-radius: var(--radius); box-shadow: var(--shadow-sm); overflow: hidden; border: 1px solid var(--border-color); }
table { width: 100%; border-collapse: collapse; }
th { background: #f8fafc; text-align: left; padding: 12px 20px; font-size: 0.85rem; color: var(--text-muted); font-weight: 600; border-bottom: 1px solid var(--border-color); }
td { padding: 15px 20px; border-bottom: 1px solid var(--border-color); font-size: 0.9rem; color: var(--text-dark); }
tr:last-child td { border-bottom: none; }
tr:hover { background-color: #fcfcfc; }

/* Modal */
.modal-overlay { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.5); display: flex; align-items: center; justify-content: center; z-index: 1000; }
.modal {
    background: var(--white);
    width: 95%;
    max-width: 900px;
    border-radius: var(--radius);
    box-shadow: var(--shadow-md);
    animation: slideIn 0.3s ease;
}
.modal-header { padding: 20px; border-bottom: 1px solid var(--border-color); display: flex; justify-content: space-between; align-items: center; }
.modal-body { padding: 20px; max-height: 70vh; overflow-y: auto; }
.modal-footer {
    background-color: #f8fafc;
    border-top: 1px solid #e2e8f0;
    padding: 15px 20px;
}
.close-modal { background: none; border: none; font-size: 1.5rem; cursor: pointer; color: var(--text-muted); }

/* Loading & Toasts */
#loading-overlay { position: fixed; inset: 0; background: rgba(255,255,255,0.8); z-index: 2000; display: flex; justify-content: center; align-items: center; }
.spinner { width: 40px; height: 40px; border: 4px solid #f3f3f3; border-top: 4px solid var(--primary); border-radius: 50%; animation: spin 1s linear infinite; }
#toast-container { position: fixed; bottom: 20px; right: 20px; z-index: 3000; display: flex; flex-direction: column; gap: 10px; }
.toast { background: var(--text-dark); color: var(--white); padding: 12px 20px; border-radius: var(--radius); font-size: 0.9rem; box-shadow: var(--shadow-md); min-width: 250px; display: flex; align-items: center; justify-content: space-between; animation: slideUp 0.3s; }
.toast.success { border-left: 4px solid var(--accent); }
.toast.error { border-left: 4px solid #e74c3c; }

/* Animation */
@keyframes spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }
@keyframes slideIn { from { transform: translateY(-20px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
@keyframes slideUp { from { transform: translateY(20px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

/* Cards Dashboard */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 20px; margin-bottom: 30px; }
.stat-card { background: var(--white); padding: 20px; border-radius: var(--radius); box-shadow: var(--shadow-sm); border: 1px solid var(--border-color); }
.stat-card h3 { font-size: 0.85rem; color: var(--text-muted); margin-bottom: 10px; text-transform: uppercase; letter-spacing: 0.5px; }
.stat-card .value { font-size: 2rem; font-weight: 600; color: var(--primary); }

/* Grid para formulários complexos */
.form-grid-3 {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 15px;
    margin-bottom: 15px;
}

.form-grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
    margin-bottom: 15px;
}

.form-section-title {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--primary);
    border-bottom: 1px solid #e2e8f0;
    padding-bottom: 5px;
    margin: 20px 0 15px 0;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.checkbox-wrapper {
    display: flex;
    align-items: center;
    gap: 8px;
    height: 100%;
    padding-top: 15px;
}

@media (max-width: 768px) {
    .form-grid-3, .form-grid-2 {
        grid-template-columns: 1fr;
    }
    .modal {
        width: 95%;
        max-width: 100%;
    }
}

/* Botão de Logout (Sair) */
.logout-btn {
    background-color: #fee2e2;
    color: #ef4444;
    border: 1px solid #fecaca;
    border-radius: 8px;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 1.2rem;
}
.logout-btn:hover {
    background-color: #ef4444;
    color: white;
    border-color: #ef4444;
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(239, 68, 68, 0.2);
}

/* Botões de Ação nas Tabelas (Olhinho) */
.btn-action {
    background: white;
    border: 1px solid #e2e8f0;
    color: #64748b;
    width: 32px;
    height: 32px;
    border-radius: 6px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 1rem;
}
.btn-action:hover {
    background: #f1f5f9;
    color: #0ea5e9;
    border-color: #cbd5e0;
}
.btn-action.primary:hover {
    color: #0ea5e9;
    background: #f0f9ff;
    border-color: #bae6fd;
}