:root {
    --bg-color: #0f172a;
    --text-color: #f8fafc;
    --primary: #ef4444;
    /* Claro Red */
    --primary-glow: rgba(239, 68, 68, 0.4);
    --glass-bg: rgba(30, 41, 59, 0.7);
    --glass-border: rgba(255, 255, 255, 0.1);
}

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

body {
    background-color: var(--bg-color);
    color: var(--text-color);
    min-height: 100vh;
}

/* Glassmorphism Utilities */
.glass-panel {
    background: var(--glass-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--glass-border);
    border-radius: 16px;
    box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.3);
}

/* Typography */
.glow-text {
    color: var(--primary);
    text-shadow: 0 0 10px var(--primary-glow);
}

/* Login Page */
.login-body {
    display: flex;
    justify-content: center;
    align-items: center;
    background: radial-gradient(circle at top left, #1e293b, #0f172a);
}

.login-box {
    width: 100%;
    max-width: 400px;
    padding: 3rem;
    text-align: center;
}

.logo-area {
    margin-bottom: 2rem;
}

.logo-area h1 {
    font-size: 3rem;
    font-weight: 800;
}

.input-group {
    margin-bottom: 1.5rem;
    text-align: left;
}

.input-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-size: 0.875rem;
    color: #cbd5e1;
}

.input-group input {
    width: 100%;
    padding: 0.75rem 1rem;
    border-radius: 8px;
    background: rgba(15, 23, 42, 0.5);
    border: 1px solid var(--glass-border);
    color: white;
    outline: none;
    transition: all 0.3s ease;
}

.input-group input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 2px var(--primary-glow);
}

.btn-primary {
    width: 100%;
    padding: 0.75rem;
    border-radius: 8px;
    background: var(--primary);
    color: white;
    border: none;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.btn-primary:hover {
    background: #dc2626;
    box-shadow: 0 0 15px var(--primary-glow);
}

/* Main Header */
.main-header {
    height: 70px;
    width: calc(100% - 260px);
    position: fixed;
    top: 0;
    left: 260px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 1.5rem;
    z-index: 1000;
    background: rgba(15, 23, 42, 0.95);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--glass-border);
    transition: left 0.3s cubic-bezier(0.4, 0, 0.2, 1), width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    border-radius: 0; /* Removendo bordas arredondadas */
}

.nav-sidebar.collapsed ~ .main-header {
    left: 80px;
    width: calc(100% - 80px);
}

.header-left {
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

.header-logo {
    font-size: 1.8rem;
    font-weight: 800;
}

.header-title {
    font-size: 1.25rem;
    font-weight: 600;
    color: #f8fafc;
    white-space: nowrap;
}

.header-center {
    flex-grow: 1;
    display: flex;
    justify-content: flex-start;
    margin-left: 2rem;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 1rem;
}

/* Dashboard Layout */
.dashboard-layout {
    display: flex;
    margin-left: 260px;
    padding-top: 70px;
    min-height: 100vh;
    transition: margin-left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.nav-sidebar.collapsed ~ .dashboard-layout {
    margin-left: 80px;
}

/* Main Navigation Sidebar */
.nav-sidebar {
    width: 260px;
    height: 100vh;
    padding: 0;
    display: flex;
    flex-direction: column;
    border-radius: 0;
    border-right: 1px solid var(--glass-border);
    position: fixed;
    top: 0;
    left: 0;
    transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 1100;
    background: #0f172a;
}

.sidebar-header {
    height: 70px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1.5rem;
    border-bottom: 1px solid var(--glass-border);
}

.nav-sidebar.collapsed .header-logo {
    display: none;
}

.nav-sidebar.collapsed {
    width: 80px;
}

.nav-sidebar.collapsed .nav-text {
    display: none;
}

.nav-sidebar.collapsed .nav-link {
    justify-content: center;
    padding: 1rem 0;
}

.nav-menu {
    margin-top: 0.5rem;
    list-style: none;
    flex-grow: 1;
}

.nav-item {
    margin-bottom: 0.25rem;
}

.nav-link {
    display: flex;
    align-items: center;
    padding: 0.75rem 1rem;
    color: #94a3b8;
    text-decoration: none;
    border-radius: 12px;
    transition: all 0.2s;
    gap: 1rem;
}

.nav-link i {
    font-size: 1.25rem;
    min-width: 24px;
    text-align: center;
}

.nav-link:hover {
    background: rgba(255, 255, 255, 0.05);
    color: white;
}

.nav-link.active {
    background: rgba(239, 68, 68, 0.1);
    color: var(--primary);
    font-weight: 600;
}

/* Sidebar para Filtros (Opcional, pode ser mostrada/escondida) */
.filter-sidebar {
    width: 250px;
    min-width: 250px;
    max-width: 250px;
    padding: 1.5rem 1rem;
    display: flex;
    flex-direction: column;
    border-radius: 0;
    border-right: 1px solid var(--glass-border);
    height: calc(100vh - 70px);
    position: sticky;
    top: 70px;
    overflow-y: auto;
    background: rgba(15, 23, 42, 0.2);
}

.filter-sidebar.hidden {
    display: none;
}

.filter-group label {
    display: block;
    font-size: 0.8rem;
    color: #cbd5e1;
    margin-bottom: 0.4rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Custom Multi-Select */
.multi-select-custom {
    position: relative;
    width: 100%;
    user-select: none;
}

.ms-header {
    background: rgba(15, 23, 42, 0.8);
    border: 1px solid var(--glass-border);
    padding: 0.5rem 0.75rem;
    border-radius: 6px;
    font-size: 0.85rem;
    color: white;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    min-height: 38px;
    transition: all 0.2s;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.ms-header span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    margin-right: 5px;
}

.ms-header:hover {
    border-color: rgba(255, 255, 255, 0.3);
}

.ms-header::after {
    content: '';
    width: 0;
    height: 0;
    border-left: 5px solid transparent;
    border-right: 5px solid transparent;
    border-top: 5px solid #94a3b8;
    transition: transform 0.3s;
}

.multi-select-custom.open .ms-header::after {
    transform: rotate(180deg);
}

.ms-options {
    display: none;
    position: absolute;
    top: calc(100% + 5px);
    left: 0;
    width: 100%;
    max-height: 250px;
    background: #1e293b;
    border: 1px solid var(--glass-border);
    border-radius: 8px;
    z-index: 1000;
    overflow-y: auto;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5);
    padding: 5px;
}

.multi-select-custom.open .ms-options {
    display: block;
}

.ms-option {
    padding: 8px 12px;
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    border-radius: 4px;
    font-size: 0.85rem;
    transition: background 0.2s;
}

.ms-option:hover {
    background: rgba(255, 255, 255, 0.05);
}

.ms-option.selected {
    background: rgba(239, 68, 68, 0.1);
    color: var(--primary);
}

.ms-checkbox {
    width: 16px;
    height: 16px;
    border: 2px solid #475569;
    border-radius: 3px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.ms-option.selected .ms-checkbox {
    background: var(--primary);
    border-color: var(--primary);
}

.ms-option.selected .ms-checkbox::after {
    content: '✓';
    color: white;
    font-size: 10px;
    font-weight: bold;
}

.ms-options::-webkit-scrollbar {
    width: 4px;
}

.ms-options::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 10px;
}

.mt-auto {
    margin-top: auto;
}

.btn-outline {
    padding: 0.5rem;
    border-radius: 6px;
    background: transparent;
    border: 1px solid var(--glass-border);
    color: #cbd5e1;
    cursor: pointer;
    transition: all 0.3s ease;
}

.btn-outline:hover {
    background: rgba(255, 255, 255, 0.1);
    color: white;
}

/* Main Content Area */
.main-content {
    flex-grow: 1;
    padding: 1.5rem;
    height: calc(100vh - 70px);
    overflow-y: auto;
}

.kpi-header {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.kpi-card {
    padding: 1.5rem;
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: 16px;
}

.kpi-card h4 {
    color: #94a3b8;
    font-weight: 400;
    font-size: 0.9rem;
    margin-bottom: 0.5rem;
}

.kpi-card h2 {
    font-size: 2.2rem;
    font-weight: 700;
    color: white;
}

.charts-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1.5rem;
    padding-bottom: 2rem;
}

.chart-container {
    padding: 1.5rem;
    min-height: 350px;
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: 16px;
}

.chart-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.chart-header h3 {
    font-size: 1.1rem;
    font-weight: 600;
    color: #e2e8f0;
}

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

.period-toggle {
    display: flex;
    background: rgba(15, 23, 42, 0.6);
    border: 1px solid var(--glass-border);
    border-radius: 10px;
    padding: 3px;
    gap: 2px;
}

.period-btn {
    padding: 0.4rem 0.8rem;
    border-radius: 7px;
    border: none;
    background: none;
    color: #94a3b8;
    font-size: 0.75rem;
    font-weight: 600;
    cursor: pointer;
    transition: 0.2s;
}

.period-btn.active {
    background: var(--primary);
    color: white;
}

/* ApexCharts Adjustments */
.apexcharts-tooltip { background: #1e293b !important; color: white !important; }

.metric-toggle {
    display: flex;
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    padding: 4px;
}

.toggle-btn {
    padding: 0.6rem 1.2rem;
    border-radius: 8px;
    border: none;
    background: transparent;
    color: #94a3b8;
    font-weight: 600;
    font-size: 0.875rem;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.toggle-btn:hover {
    color: white;
}

.toggle-btn.active {
    background: var(--primary);
    color: white;
    box-shadow: 0 4px 12px var(--primary-glow);
}

.data-ref {
    font-size: 0.875rem;
    color: #94a3b8;
    background: rgba(255, 255, 255, 0.05);
    padding: 0.5rem 1rem;
    border-radius: 8px;
}

.data-ref span {
    color: white;
    font-weight: 600;
}


/* Modals e Login Footer */
.login-footer {
    margin-top: 1.5rem;
    text-align: center;
    font-size: 0.9rem;
    color: rgba(255, 255, 255, 0.7);
}

.login-footer a {
    color: #ef4444;
    text-decoration: none;
    font-weight: 600;
}

.modal {
    display: none;
    position: fixed;
    z-index: 2000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(5px);
    display: none; /* Default hidden */
    align-items: center; /* Centraliza verticalmente */
    justify-content: center; /* Centraliza horizontalmente */
}

.modal-content {
    width: 90%;
    max-width: 600px;
    max-height: 90vh; /* Não ultrapassa 90% da altura da tela */
    overflow-y: auto; /* Scroll interno se necessário */
    padding: 2.5rem;
    position: relative;
    animation: slideDown 0.3s ease-out;
}

@keyframes slideDown {
    from {
        transform: translateY(-50px);
        opacity: 0;
    }

    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.close {
    position: absolute;
    right: 1.5rem;
    top: 1rem;
    font-size: 1.5rem;
    cursor: pointer;
    color: rgba(255, 255, 255, 0.5);
}

.close:hover {
    color: #fff;
}

.msg {
    margin: 1rem 0;
    font-size: 0.9rem;
}

.msg.error {
    color: #ef4444;
}

.msg.success {
    color: #10b981;
}


/* Botão Exportar */
.data-ref-container {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.btn-export {
    background: rgba(16, 185, 129, 0.2);
    color: #10b981;
    border: 1px solid rgba(16, 185, 129, 0.3);
    padding: 0.4rem 0.8rem;
    border-radius: 8px;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 600;
    transition: 0.3s;
}

.btn-export:hover {
    background: #10b981;
    color: white;
    transform: translateY(-2px);
}

.btn-export svg {
    stroke: currentColor;
}

/* Tables Management */
.table-container {
    margin-top: 1rem;
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    font-size: 0.9rem;
}

th {
    text-align: left;
    padding: 1rem;
    background: rgba(15, 23, 42, 0.4);
    color: #94a3b8;
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.75rem;
    letter-spacing: 0.5px;
    border-bottom: 1px solid var(--glass-border);
}

td {
    padding: 1rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    color: #e2e8f0;
}

tr:hover td {
    background: rgba(255, 255, 255, 0.02);
}

.action-btn:hover {
    color: var(--primary);
}

.status-badge {
    padding: 0.25rem 0.6rem;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
}

.status-active {
    background: rgba(16, 185, 129, 0.2);
    color: #10b981;
}

.status-inactive {
    background: rgba(239, 68, 68, 0.2);
    color: #ef4444;
}

/* Forms */
.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

.form-group {
    margin-bottom: 1.25rem;
}

.form-group.full {
    grid-column: span 2;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-size: 0.8rem;
    color: #94a3b8;
}

.form-group input, .form-group select, .filter-group input {
    width: 100%;
    padding: 0.65rem 1rem;
    border-radius: 8px;
    background: rgba(15, 23, 42, 0.5);
    border: 1px solid var(--glass-border);
    color: white;
    outline: none;
    box-sizing: border-box; /* Garante que o padding não quebre o tamanho */
}

.form-group input:focus, .filter-group input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 2px var(--primary-glow);
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 1rem;
    margin-top: 1.5rem;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Alertas */
.alert-warning {
    background: rgba(245, 158, 11, 0.15);
    border: 1px solid rgba(245, 158, 11, 0.3);
    color: #f59e0b;
    padding: 1rem 1.5rem;
    border-radius: 12px;
    margin-bottom: 1.5rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    backdrop-filter: blur(5px);
    animation: fadeIn 0.5s ease-out;
}

.alert-warning i {
    font-size: 1.5rem;
}

.alert-warning p {
    margin: 0;
    font-size: 0.95rem;
    line-height: 1.4;
}

/* --- Tema Claro (Light Mode) --- */
:root.light-theme {
    --bg-color: #f8fafc;
    --text-color: #2d291c; /* PRETO CLARO */
    --primary: #da291c; /* PANTONE CLARO */
    --primary-glow: rgba(218, 41, 28, 0.3);
    --glass-bg: rgba(255, 255, 255, 0.85);
    --glass-border: rgba(167, 168, 170, 0.3); /* CINZA CLARO */
}

.light-theme body {
    background-color: var(--bg-color);
}

.light-theme .login-body {
    background: radial-gradient(circle at top left, #e2e8f0, #f8fafc);
}

.light-theme .input-group label {
    color: #475569;
}

.light-theme .input-group input {
    background: #ffffff;
    border: 1px solid #a7a8aa;
    color: #2d291c;
}

.light-theme .main-header {
    background: rgba(255, 255, 255, 0.95);
    border-bottom: 1px solid var(--glass-border);
}

.light-theme .header-title {
    color: #2d291c;
}

.light-theme .nav-sidebar {
    background: #ffffff;
    border-right: 1px solid var(--glass-border);
}

.light-theme .sidebar-header {
    border-bottom: 1px solid var(--glass-border);
}

.light-theme .nav-link {
    color: #475569;
}

.light-theme .nav-link:hover {
    background: #f1f5f9;
    color: #2d291c;
}

.light-theme .nav-link.active {
    background: rgba(218, 41, 28, 0.1);
    color: var(--primary);
}

.light-theme .filter-sidebar {
    background: rgba(255, 255, 255, 0.5);
    border-right: 1px solid var(--glass-border);
}

.light-theme .filter-group label {
    color: #475569;
}

.light-theme .ms-header {
    background: #ffffff;
    border: 1px solid #a7a8aa;
    color: #2d291c;
}

.light-theme .ms-options {
    background: #ffffff;
    border: 1px solid #a7a8aa;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
}

.light-theme .ms-option {
    color: #2d291c;
}

.light-theme .ms-option:hover {
    background: #f1f5f9;
}

.light-theme .ms-checkbox {
    border: 2px solid #a7a8aa;
}

.light-theme .btn-outline {
    border: 1px solid #a7a8aa;
    color: #475569;
}

.light-theme .btn-outline:hover {
    background: #f1f5f9;
    color: #2d291c;
}

.light-theme .kpi-card h4 {
    color: #475569;
}

.light-theme .kpi-card h2 {
    color: #2d291c;
}

.light-theme .chart-header h3 {
    color: #2d291c;
}

.light-theme .period-toggle {
    background: rgba(255, 255, 255, 0.9);
    border: 1px solid #a7a8aa;
}

.light-theme .period-btn {
    color: #475569;
}

.light-theme .period-btn.active {
    color: white;
}

.light-theme .metric-toggle {
    background: rgba(255, 255, 255, 0.9);
    border: 1px solid #a7a8aa;
}

.light-theme .toggle-btn {
    color: #475569;
}

.light-theme .toggle-btn:hover {
    color: #2d291c;
}

.light-theme .toggle-btn.active {
    color: white;
}

.light-theme .data-ref {
    color: #475569;
    background: #f1f5f9;
}

.light-theme .data-ref span {
    color: #2d291c;
}

.light-theme th {
    background: #f8fafc;
    color: #475569;
    border-bottom: 1px solid #a7a8aa;
}

.light-theme td {
    color: #2d291c;
    border-bottom: 1px solid #e2e8f0;
}

.light-theme tr:hover td {
    background: #f1f5f9;
}

.light-theme .form-group label {
    color: #475569;
}

.light-theme .form-group input, .light-theme .form-group select, .light-theme .filter-group input {
    background: #ffffff;
    border: 1px solid #a7a8aa;
    color: #2d291c;
}

.light-theme .apexcharts-tooltip { background: #ffffff !important; color: #2d291c !important; border: 1px solid #a7a8aa !important; }
.light-theme .apexcharts-tooltip-title { border-bottom: 1px solid #a7a8aa !important; }
.light-theme .apexcharts-theme-light { background: transparent !important; }

.light-theme .modal-content {
    background: #ffffff;
    border: 1px solid var(--glass-border);
}
.light-theme .modal-content h2, .light-theme .modal-content h3 {
    color: #2d291c;
}
.light-theme .close {
    color: #475569;
}