:root {
    --bg-body: #f4f6f9;
    --bg-card: #ffffff;
    --primary-text: #1f2937;
    --secondary-text: #64748b;
    --color-green: #10b981;
    --color-blue: #001970;
    --color-blue-light: #e0e7ff;
    --color-dark: #1e293b;
    --color-red: #ef4444;
    --radius: 16px;
    --shadow-soft: 0 10px 25px -5px rgb(0 0 0 / 0.05), 0 8px 10px -6px rgb(0 0 0 / 0.01);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-body); 
    color: var(--primary-text);
    padding-bottom: 40px;
    min-height: 100vh;
}

/* =========================================
   NAVBAR & MENU
   ========================================= */
.navbar {
    background-color: #001970;
    padding: 1rem 2rem;
    display: flex; justify-content: space-between; align-items: center;
    box-shadow: 0 4px 15px rgba(0, 25, 112, 0.3);
    position: relative; z-index: 100;
}

.logo-img { 
    height: 45px; width: auto; display: block;
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.3));
}

.user-menu-container { position: relative; }

.regional-badge {
    background-color: #ffffff;
    color: #001970;
    padding: 8px 16px; border-radius: 50px;
    font-weight: 700; font-size: 0.9rem;
    display: flex; align-items: center; gap: 10px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
    cursor: pointer; transition: background-color 0.2s, transform 0.2s;
}
.regional-badge:hover { background-color: #f1f5f9; transform: translateY(-1px); }
.arrow-icon { font-size: 0.8rem; color: #64748b; transition: transform 0.2s; }
.regional-badge.active .arrow-icon { transform: rotate(180deg); }

.dropdown-menu {
    position: absolute; top: 120%; right: 0;
    background: white; width: 200px; border-radius: 12px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.15);
    padding: 10px; display: none; flex-direction: column;
    z-index: 200; border: 1px solid #f1f5f9;
}
.dropdown-menu.show { display: flex; animation: fadeIn 0.2s ease; }
.dropdown-header { padding: 10px; display: flex; flex-direction: column; }
.dropdown-header strong { font-size: 0.9rem; color: var(--primary-text); }
.dropdown-header span { font-size: 0.75rem; color: var(--secondary-text); }
.dropdown-menu hr { border: none; border-top: 1px solid #f1f5f9; margin: 5px 0; }

.dropdown-item {
    padding: 10px; color: var(--color-red); text-decoration: none;
    font-size: 0.9rem; font-weight: 600; border-radius: 8px;
    display: flex; align-items: center; gap: 8px; transition: background 0.2s;
}
.dropdown-item:hover { background-color: #fef2f2; }

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* =========================================
   BARRA DE TOTAIS (TOPO)
   ========================================= */
.summary-stats-bar {
    max-width: 1600px;
    margin: 30px auto;
    padding: 0 20px;
    display: grid; 
    grid-template-columns: repeat(2, 1fr); /* 2 Colunas no Desktop */
    gap: 30px;
}

.stat-card {
    background: var(--bg-card); 
    border-radius: var(--radius);
    box-shadow: var(--shadow-soft);
    padding: 35px 30px;
    text-align: left;
    height: auto;
    display: flex; flex-direction: column; justify-content: center;
    border: 1px solid #f1f5f9;
    transition: transform 0.2s ease;
}
.stat-card:hover { transform: translateY(-3px); box-shadow: 0 4px 6px rgba(0,0,0,0.05); }

.stat-label {
    font-size: 1.1rem;
    color: var(--color-blue);
    margin-bottom: 10px;
    font-family: 'Poppins', sans-serif;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.stat-value { 
    font-size: 2.2rem;
    font-weight: 700; 
    font-family: 'Poppins', sans-serif; 
    color: var(--color-dark); 
    display: block;
}
.text-success { color: var(--color-green); }

/* =========================================
   GRID PRINCIPAL (LISTAS)
   ========================================= */
.dashboard-wrapper {
    max-width: 1600px;
    margin: 0 auto; 
    padding: 0 20px;
    display: grid; 
    grid-template-columns: repeat(auto-fit, minmax(380px, 1fr));
    gap: 30px;
    align-items: stretch;
}

.card {
    background: var(--bg-card); border-radius: var(--radius);
    box-shadow: 0 4px 6px -1px rgb(0 0 0 / 0.05); overflow: hidden; 
    display: flex; flex-direction: column; border: 1px solid rgba(0,0,0,0.03);
    transition: transform 0.2s ease, box-shadow 0.2s ease; height: 100%;
}
.card:hover { transform: translateY(-3px); box-shadow: var(--shadow-soft); }

.card-header { padding: 20px; display: flex; align-items: center; gap: 15px; color: white; flex-shrink: 0; }
.header-icon {
    background: rgba(255,255,255,0.2); width: 42px; height: 42px;
    border-radius: 12px; display: flex; align-items: center; justify-content: center;
    font-size: 1.2rem; backdrop-filter: blur(5px);
}
.card-header h2 { font-family: 'Poppins', sans-serif; font-size: 1.1rem; font-weight: 600; letter-spacing: 0.5px; }

.header-green { background: linear-gradient(135deg, #10b981 0%, #059669 100%); }
.header-blue { background: linear-gradient(135deg, #001970 0%, #002299 100%); } 
.header-dark { background: linear-gradient(135deg, #334155 0%, #0f172a 100%); }

.card-body.scrollable-area {
    padding: 0; 
    height: 340px; 
    overflow-y: auto; 
    position: relative;
    /* Faz a lista crescer para ocupar espaço até o rodapé */
    flex-grow: 1; 
}
.scrollable-area::-webkit-scrollbar { width: 6px; }
.scrollable-area::-webkit-scrollbar-thumb { background-color: #cbd5e1; border-radius: 10px; }

/* LIST HEADER (RODAPÉ DO CARD) */
.list-header {
    display: grid;
    /* Grid de 3 colunas */
    grid-template-columns: 2fr 0.8fr 1.2fr; 
    padding: 15px 30px;
    background-color: #f8fafc;
    border-top: 1px solid #e2e8f0;
    font-size: 0.85rem;
    font-weight: 700;
    color: #94a3b8;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-top: auto;
}

/* ITENS DA LISTA */
.client-list { list-style: none; }
.client-list li {
    padding: 22px 30px; 
    border-bottom: 1px solid #f1f5f9;
    display: grid; 
    /* Mesma grid do cabeçalho */
    grid-template-columns: 2fr 0.8fr 1.2fr; 
    align-items: center;
    transition: background 0.1s;
}
.client-list li:hover { background-color: #f8fafc; }

.client-info { display: flex; flex-direction: column; overflow: hidden; }
.client-name { 
    font-weight: 600; 
    color: var(--primary-text); 
    font-size: 0.9rem;
    padding: 4px 0; /* Ajuste padding */
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis; 
}
.client-percent {
    text-align: center;
    font-size: 0.85rem;
    font-weight: 600;
    color: #64748b;
    background: #f1f5f9; padding: 2px 8px; border-radius: 4px;
    justify-self: center;
}
.client-val { 
    font-weight: 700; 
    color: var(--color-dark); 
    font-family: 'Poppins', sans-serif; 
    font-size: 1.1rem; 
    text-align: right;
}

/* =========================================
   LOGIN
   ========================================= */
.login-body {
    background: linear-gradient(135deg, #001970 0%, #002299 100%);
    height: 100vh; width: 100vw; overflow: hidden;
    display: flex; justify-content: center; align-items: center; padding: 0; margin: 0;
}
.login-wrapper { width: 100%; max-width: 400px; padding: 20px; }
.login-card {
    background: white; padding: 40px; border-radius: 24px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.3); text-align: center;
}
.login-header { margin-bottom: 30px; }
.login-logo { height: 60px; width: auto; margin: 0 auto 20px; display: block; }
.login-header h2 { font-family: 'Poppins', sans-serif; color: var(--color-blue); font-size: 1.5rem; margin-bottom: 5px; }
.login-header p { color: var(--secondary-text); font-size: 0.9rem; }
.input-group { margin-bottom: 20px; text-align: left; }
.input-group label { display: block; font-size: 0.85rem; font-weight: 600; color: var(--color-dark); margin-bottom: 8px; }
.input-box { position: relative; display: flex; align-items: center; }
.input-box i { position: absolute; left: 15px; color: #9ca3af; font-size: 1rem; }
.input-box input {
    width: 100%; padding: 12px 15px 12px 45px; border: 1px solid #e2e8f0;
    border-radius: 12px; font-family: 'Inter', sans-serif; font-size: 0.95rem;
    color: var(--primary-text); transition: all 0.3s; background: #f8fafc;
}
.input-box input:focus { outline: none; border-color: var(--color-blue); background: white; box-shadow: 0 0 0 4px var(--color-blue-light); }
.forgot-pass { text-align: right; margin-bottom: 25px; }
.forgot-pass a { color: var(--color-blue); font-size: 0.85rem; font-weight: 500; text-decoration: none; }
.forgot-pass a:hover { text-decoration: underline; }
.btn-login {
    width: 100%; padding: 14px; background-color: var(--color-blue); color: white;
    border: none; border-radius: 12px; font-size: 1rem; font-weight: 600;
    cursor: pointer; transition: all 0.2s; font-family: 'Poppins', sans-serif;
}
.btn-login:hover { background-color: #002299; transform: translateY(-2px); box-shadow: 0 5px 15px rgba(0, 25, 112, 0.3); }
.btn-login:disabled { background-color: #94a3b8; cursor: not-allowed; }
.error-msg {
    background-color: #fef2f2; color: var(--color-red);
    border: 1px solid #fee2e2; padding: 12px; border-radius: 12px;
    font-size: 0.9rem; font-weight: 600; margin-bottom: 20px;
    text-align: center; animation: fadeIn 0.3s ease;
}

/* =========================================
   RESPONSIVIDADE (MOBILE & TABLET)
   ========================================= */

/* Tablet (max 1024px) */
@media (max-width: 1024px) {
    .dashboard-wrapper {
        grid-template-columns: 1fr 1fr; /* 2 colunas no tablet */
    }
}

/* Mobile (max 768px) */
@media (max-width: 768px) {
    /* Navbar empilhada */
    .navbar { flex-direction: column; gap: 15px; align-items: flex-start; padding: 1rem; }
    
    /* Barra de Totais (Topo) - Vira coluna única */
    .summary-stats-bar {
        grid-template-columns: 1fr; 
        gap: 20px;
        margin: 20px auto;
    }
    .stat-card { padding: 25px 20px; }
    .stat-value { font-size: 1.8rem; }

    /* Grid Principal - Vira coluna única */
    .dashboard-wrapper {
        grid-template-columns: 1fr;
        gap: 20px;
    }

    /* Listas Internas - Ajuste de espaço para não quebrar */
    .client-list li, .list-header {
        padding: 15px; /* Menos padding lateral */
        grid-template-columns: 1.5fr 0.8fr 1.2fr; /* Coluna nome menor, valor maior */
        font-size: 0.8rem;
    }

    .client-val { font-size: 0.95rem; }
    .client-name { font-size: 0.85rem; }

    /* Login */
    .login-body { padding: 0; }
    .login-wrapper { max-width: 100%; }
}