:root {
    --primary: #0061FF;
    --primary-soft: #E0EBFF;
    --secondary: #4E5D78;
    --bg-body: #F8FAFC;
    --bg-sidebar: #FFFFFF;
    --text-dark: #1E293B;
    --text-muted: #64748B;
    --border: #E2E8F0;
    --white: #FFFFFF;
    --success: #10B981;
    --warning: #F59E0B;
    --danger: #EF4444;
    --radius: 12px;
    --shadow: 0 1px 3px rgba(0,0,0,0.1);
}

[data-theme="dark"] {
    --bg-body: #0F172A;
    --bg-sidebar: #1E293B;
    --text-dark: #F8FAFC;
    --text-muted: #94A3B8;
    --border: #334155;
    --white: #1E293B;
    --primary-soft: #1E293B;
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.3);
}

* { box-sizing: border-box; }
html, body { width: 100%; overflow-x: hidden; -webkit-text-size-adjust: 100%; -ms-text-size-adjust: 100%; }

body { font-family: 'Inter', sans-serif; background: var(--bg-body); color: var(--text-dark); display: flex; min-height: 100vh; margin: 0; transition: background 0.3s, color 0.3s; }

/* --- LOGIN PAGE --- */
.login-body { display: flex; align-items: center; justify-content: center; background: #F1F4F9; width: 100%; min-height: 100vh; margin: 0; padding: 20px; }
.login-container { background: #FFF; padding: 48px; border-radius: 16px; box-shadow: 0 10px 30px rgba(0,0,0,0.08); width: 100%; max-width: 400px; text-align: center; }
.login-logo { margin-bottom: 32px; }
.login-logo img { width: 180px; }
.login-container h2 { margin-bottom: 32px; color: #1E293B; font-weight: 800; font-size: 24px; }
.form-group { text-align: left; margin-bottom: 20px; }
.form-group label { display: block; margin-bottom: 8px; font-weight: 700; font-size: 13px; color: #64748B; text-transform: uppercase; }
.form-group input { width: 100%; padding: 14px; border: 1px solid #E2E8F0; border-radius: 10px; outline: none; font-size: 16px; background: #F8FAFC; transition: all 0.2s; }
.form-group input:focus { border-color: var(--primary); background: #FFF; box-shadow: 0 0 0 4px var(--primary-soft); }
.btn-primary-login { width: 100%; padding: 14px; background: var(--primary); color: #FFF; border: none; border-radius: 10px; font-size: 16px; font-weight: 700; cursor: pointer; transition: transform 0.2s, background 0.2s; }
.btn-primary-login:hover { background: #0056E0; transform: translateY(-1px); }
.error-msg { background: #FEE2E2; color: #991B1B; padding: 12px; border-radius: 8px; margin-bottom: 24px; font-size: 14px; }

.mobile-only { display: none !important; }

/* --- SIDEBAR --- */
.sidebar { width: 240px; background: var(--bg-sidebar); border-right: 1px solid var(--border); display: flex; flex-direction: column; padding: 24px 0; position: fixed; height: 100vh; z-index: 1000; transition: all 0.3s ease; }
.sidebar-logo { padding: 0 24px; margin-bottom: 32px; display: flex; justify-content: center; }
.sidebar-logo img { max-height: 80px; width: 100%; object-fit: contain; }

[data-theme="dark"] .logo-light { display: none !important; }
[data-theme="dark"] .logo-dark { display: block !important; }
[data-theme="light"] .logo-dark { display: none !important; }
[data-theme="light"] .logo-light { display: block !important; }

.sidebar-handle {
    position: absolute;
    right: -32px;
    top: 50%;
    transform: translateY(-50%);
    background: var(--bg-sidebar);
    border: 1px solid var(--border);
    border-left: none;
    border-radius: 0 12px 12px 0;
    padding: 20px 6px;
    color: var(--primary);
    cursor: pointer;
    box-shadow: 4px 0 10px rgba(0,0,0,0.05);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1001;
}

.nav-menu { list-style: none; flex-grow: 1; display: flex; flex-direction: column; }
.nav-item { margin-bottom: 4px; padding: 0 12px; }
.nav-link { display: flex; align-items: center; gap: 12px; padding: 12px 16px; color: var(--secondary); font-weight: 500; font-size: 14px; border-radius: 8px; transition: all 0.2s; cursor: pointer; text-decoration: none; }
.nav-link:hover, .nav-link.active { background: var(--primary-soft); color: var(--primary); }
.nav-link.active { font-weight: 700; background: var(--primary-soft) !important; }

/* --- MAIN CONTENT --- */
.main-content { flex-grow: 1; margin-left: 240px; padding: 32px 48px; width: calc(100% - 240px); transition: margin-left 0.3s ease; }
.top-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 32px; gap: 16px; }
.page-title { font-size: 24px; font-weight: 800; margin: 0; }
.header-actions { display: flex; align-items: center; gap: 16px; }
.hidden { display: none !important; }

/* Filter Bar */
.filter-bar { background: var(--white); padding: 16px 24px; border-radius: var(--radius); border: 1px solid var(--border); margin-bottom: 32px; display: flex; align-items: center; gap: 12px; flex-wrap: wrap; box-shadow: var(--shadow); }
.filter-btn { padding: 8px 16px; background: #FAFAFA; border: 1px solid var(--border); border-radius: 50px; font-size: 13px; font-weight: 600; cursor: pointer; transition: all 0.2s; text-decoration: none; color: inherit; }
[data-theme="dark"] .filter-btn { background: #334155; }
.filter-btn:hover, .filter-btn.active { background: var(--primary); color: white; border-color: var(--primary); }

/* Stats & Cards */
.stats-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 24px; margin-bottom: 32px; }
.stat-card { background: var(--white); padding: 24px; border-radius: var(--radius); box-shadow: var(--shadow); border-top: 4px solid var(--primary); }
.stat-card.green { border-top-color: var(--success); }
.stat-card.danger { border-top-color: var(--danger); }
.stat-header { font-size: 13px; font-weight: 700; color: var(--text-muted); text-transform: uppercase; margin-bottom: 8px; }
.stat-body { font-size: 32px; font-weight: 800; }
.stat-body span { font-size: 14px; color: var(--text-muted); font-weight: 500; }

/* Dashboard Tables */
.card-table { background: var(--white); border-radius: var(--radius); box-shadow: var(--shadow); margin-bottom: 32px; overflow: hidden; }
.card-header { padding: 20px 24px; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; }
.table-responsive { overflow-x: auto; width: 100%; }

table { width: 100%; border-collapse: collapse; }
.card-table table { min-width: 800px; }

th { background: rgba(0,0,0,0.02); padding: 16px 24px; text-align: left; font-size: 12px; font-weight: 700; color: var(--text-muted); text-transform: uppercase; border-bottom: 1px solid var(--border); }
td { padding: 12px 16px; border-bottom: 1px solid var(--border); font-size: 14px; }
td a { color: var(--primary); text-decoration: none; font-weight: 600; }
[data-theme="dark"] td { color: #CBD5E1; }
[data-theme="dark"] td a { color: #60A5FA; }

.lead-alert { background: #FEE2E2 !important; color: #991B1B !important; }
[data-theme="dark"] .lead-alert { background: #450A0A !important; color: #FECACA !important; }
.lead-disqualified { background: #F1F5F9 !important; color: #94A3B8 !important; opacity: 0.5; }
[data-theme="dark"] .lead-disqualified { background: #1E293B !important; color: #475569 !important; }

/* Checkbox Button (ache+) */
.checkbox-btn { width: 28px; height: 28px; border: 1.5px solid #CBD5E1; border-radius: 6px; cursor: pointer; background: #F8FAFC; transition: all 0.2s; display: flex; align-items: center; justify-content: center; flex-shrink: 0; color: #94A3B8; }
[data-theme="dark"] .checkbox-btn { border-color: #475569; background: #334155; }
.checkbox-btn.checked { background: var(--success) !important; border-color: var(--success) !important; opacity: 1; }
.checkbox-btn.checked svg path { fill: white !important; }

/* Disqualify Button (X) */
.disqualify-btn { width: 28px; height: 28px; background: #F8FAFC; color: #94A3B8; border: 1.5px solid #CBD5E1; border-radius: 6px; cursor: pointer; display: flex; align-items: center; justify-content: center; transition: all 0.2s; flex-shrink: 0; }
.disqualify-btn:hover { background: #E2E8F0; color: #1E293B; }
.disqualify-btn.active { background: #475569 !important; color: white !important; border-color: #475569 !important; }
[data-theme="dark"] .disqualify-btn { background: #334155; border-color: #475569; }

/* Tabs */
.tab-content { display: none; }
.tab-content.active { display: block; animation: fadeIn 0.3s ease-out; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }

.theme-toggle { background: var(--white); border: 1px solid var(--border); padding: 8px; border-radius: 12px; cursor: pointer; color: var(--text-dark); }
.user-avatar { width: 32px; height: 32px; background: var(--primary); color: white; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 14px; }

/* --- IMAGE MODAL --- */
.modal-image { position: fixed; z-index: 9999; padding: 40px 20px; left: 0; top: 0; width: 100%; height: 100%; overflow: auto; background-color: rgba(0,0,0,0.95); backdrop-filter: blur(8px); display: flex; align-items: center; justify-content: center; opacity: 0; visibility: hidden; transition: opacity 0.3s, visibility 0.3s; }
.modal-image.open { opacity: 1; visibility: visible; }
.modal-content-img { margin: auto; display: block; width: auto; max-width: 95%; max-height: 85vh; border-radius: 12px; box-shadow: 0 0 50px rgba(0,0,0,0.8); transform: scale(0.8); transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1); }
.modal-image.open .modal-content-img { transform: scale(1); }
.modal-close { position: absolute; top: 20px; right: 25px; color: #fff; font-size: 36px; font-weight: bold; cursor: pointer; padding: 10px; line-height: 1; text-shadow: 0 0 10px rgba(0,0,0,0.5); }

/* --- TABLE TWEAKS --- */
.ache-plus-cell { white-space: nowrap !important; width: 95px !important; min-width: 95px !important; vertical-align: middle; }
.ache-plus-wrapper { display: flex !important; flex-direction: row !important; align-items: center !important; gap: 8px !important; justify-content: flex-start !important; }

/* Thumbs */
.thumb-container { flex-shrink: 0; transition: transform 0.2s; }
.thumb-container:hover { transform: scale(1.1); }

/* Mobile Reponsiveness */
@media (max-width: 1024px) {
    .sidebar { width: 80px; }
    .sidebar-logo span, .nav-link span { display: none; }
    .main-content { margin-left: 80px; width: calc(100% - 80px); }
}

@media (max-width: 768px) {
    .mobile-only { display: block !important; }
    #mobile-toggle { display: block !important; }
    
    .sidebar { 
        width: 260px; 
        left: -260px; 
        transition: left 0.3s cubic-bezier(0.4, 0, 0.2, 1); 
        box-shadow: 10px 0 30px rgba(0,0,0,0.2);
        z-index: 2000;
        visibility: visible;
        padding: 24px 0;
    }
    .sidebar.sidebar-open { left: 0; }
    .sidebar.sidebar-open .sidebar-handle { display: flex !important; }

    /* Overlay ao abrir sidebar */
    .sidebar-overlay { 
        display: none; 
        position: fixed; 
        top: 0; left: 0; right: 0; bottom: 0; 
        background: rgba(0,0,0,0.5); 
        z-index: 1500; 
        backdrop-filter: blur(2px);
    }
    .sidebar.sidebar-open ~ .sidebar-overlay { display: block; }

    .main-content { margin-left: 0; width: 100%; padding: 16px; min-width: 100vw; overflow-x: hidden; }
    .top-header { flex-direction: row; justify-content: space-between; align-items: center; margin-bottom: 20px; }
    .filter-bar { flex-direction: column; align-items: stretch; gap: 8px; padding: 12px; }
    .page-title { font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 150px; }
    .stats-row { grid-template-columns: 1fr; gap: 16px; }
    .card-table table { min-width: 600px; }
    table { font-size: 11px; }
    th, td { padding: 10px 8px; }
    .sidebar-logo span, .nav-link span { display: inline-block; }
    
    /* Logo Restored logic for mobile */
    .logo-container span.logo-text { display: block !important; }
}