:root {
    --bg: #f4f7fe;
    --sidebar: #ffffff;
    --primary: #4361ee;
    --primary-hover: #3451d1;
    --text: #2b3674;
    --text-light: #a3aed0;
    --card: #ffffff;
    --border: #e0e5f2;
    --success: #05cd99;
    --danger: #ee5d50;
    --shadow: 0 4px 12px rgba(0,0,0,0.05);
}

.dark-theme {
    --bg: #0b1437;
    --sidebar: #111c44;
    --text: #ffffff;
    --text-light: #8f9bba;
    --card: #111c44;
    --border: #1b254b;
    --shadow: 0 4px 12px rgba(0,0,0,0.2);
}

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

body {
    background: var(--bg);
    color: var(--text);
    display: flex;
    min-height: 100vh;
    transition: background 0.3s;
}

/* Sidebar */
.sidebar {
    width: 280px;
    background: var(--sidebar);
    padding: 30px 20px;
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    transition: background 0.3s;
}

.logo {
    font-size: 26px;
    font-weight: 800;
    margin-bottom: 50px;
    text-align: center;
    letter-spacing: -1px;
}

.logo span {
    color: var(--primary);
}

.nav-menu {
    flex: 1;
}

.nav-btn {
    width: 100%;
    padding: 14px 18px;
    margin-bottom: 12px;
    border: none;
    background: none;
    text-align: left;
    cursor: pointer;
    color: var(--text-light);
    font-weight: 600;
    border-radius: 12px;
    transition: all 0.2s;
    font-size: 15px;
}

.nav-btn:hover {
    background: var(--bg);
    color: var(--text);
}

.nav-btn.active {
    background: var(--primary);
    color: white;
    box-shadow: 0 4px 12px rgba(67, 97, 238, 0.3);
}

/* Main Content */
.main-content {
    flex: 1;
    padding: 40px;
    overflow-y: auto;
    max-height: 100vh;
}

.top-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 35px;
}

#view-title {
    font-size: 28px;
    font-weight: 700;
}

.actions {
    display: flex;
    gap: 12px;
}

/* Buttons */
.btn-primary {
    background: var(--primary);
    color: white;
    border: none;
    padding: 10px 22px;
    border-radius: 10px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
}

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

.btn-outline {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text);
    padding: 10px 20px;
    border-radius: 10px;
    font-weight: 600;
    cursor: pointer;
}

.btn-outline:hover { background: var(--border); }

/* KPI Cards */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 20px;
    margin-bottom: 35px;
}

.kpi-card {
    background: var(--card);
    padding: 24px;
    border-radius: 20px;
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
}

.kpi-card .label {
    font-size: 13px;
    color: var(--text-light);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.kpi-card h2 {
    margin-top: 8px;
    font-size: 22px;
    font-weight: 700;
}

.kpi-card.highlight h2 {
    color: var(--primary);
}

/* Charts */
.charts-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 25px;
}

.chart-box {
    background: var(--card);
    padding: 25px;
    border-radius: 20px;
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
    min-height: 400px;
    display: flex;
    flex-direction: column;
}

.chart-box h3 {
    margin-bottom: 20px;
    font-size: 18px;
}

.canvas-wrapper {
    flex: 1;
    position: relative;
    width: 100%;
    height: 300px;
}

/* Views Management */
.view-section { display: none; }
.view-section.active { display: block; animation: fadeIn 0.3s ease-out; }

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Table */
.data-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.table-container {
    background: var(--card);
    border-radius: 20px;
    padding: 10px;
    border: 1px solid var(--border);
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
}

th {
    text-align: left;
    padding: 16px;
    color: var(--text-light);
    font-size: 13px;
    border-bottom: 1px solid var(--border);
    font-weight: 600;
}

td {
    padding: 16px;
    border-bottom: 1px solid var(--border);
    font-size: 14px;
}

.btn-delete {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 16px;
    opacity: 0.6;
}

.btn-delete:hover { opacity: 1; }

/* Report View */
.report-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 25px;
    margin-top: 20px;
}

.report-card {
    background: var(--card);
    border-radius: 20px;
    padding: 25px;
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
}

.report-card h3 {
    color: var(--primary);
    border-bottom: 2px solid var(--bg);
    padding-bottom: 15px;
    margin-bottom: 15px;
    font-size: 20px;
    text-transform: capitalize;
}

.report-item {
    display: flex;
    justify-content: space-between;
    margin-bottom: 12px;
    font-size: 14px;
}

.report-item span { color: var(--text-light); }
.report-item b { font-weight: 600; }

/* Modal */
.modal {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.6);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    backdrop-filter: blur(4px);
}

.modal.active { display: flex; }

.modal-content {
    background: var(--card);
    padding: 35px;
    border-radius: 25px;
    width: 100%;
    max-width: 650px;
    max-height: 90vh;
    overflow-y: auto;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 25px;
}

.btn-close-x {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: var(--text-light);
}

.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

.input-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.input-group label {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-light);
}

.full-width { grid-column: span 2; }

input, select {
    padding: 12px 16px;
    border-radius: 12px;
    border: 1px solid var(--border);
    background: var(--bg);
    color: var(--text);
    font-size: 14px;
}

.modal-footer {
    margin-top: 30px;
    display: flex;
    justify-content: flex-end;
    gap: 12px;
}

/* Switch Toggle */
.theme-switch-container {
    padding-top: 20px;
    border-top: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-light);
}

.switch {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
}

.switch input { opacity: 0; width: 0; height: 0; }

.slider {
    position: absolute;
    cursor: pointer;
    inset: 0;
    background-color: #cbd5e0;
    transition: .4s;
    border-radius: 34px;
}

.slider:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: .4s;
    border-radius: 50%;
}

input:checked + .slider { background-color: var(--primary); }
input:checked + .slider:before { transform: translateX(20px); }

/* =========================
   GLOBAL RESPONSIVE TWEAKS
========================= */

html {
    font-size: 16px;
}

@media (max-width: 480px) {
    html {
        font-size: 14px;
    }
}

body {
    overflow-x: hidden;
}

/* =========================
   MENU MOBILE - SIDEBAR
========================= */

.menu-toggle {
    display: none;
    background: var(--primary);
    border: none;
    width: 42px;
    height: 40px;
    border-radius: 12px;
    cursor: pointer;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 4px;
}

.menu-toggle span {
    width: 22px;
    height: 2px;
    background: white;
    border-radius: 2px;
}

/* Overlay */
.sidebar-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.45);
    z-index: 1100;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s;
}

/* Mobile */
@media (max-width: 1024px) {

    .menu-toggle {
        display: flex;
    }

    .sidebar {
        position:fixed;
        top: 0;
        left: 0;
        bottom: 0;
        width: 280px;
        transform: translateX(-100%);
        transition: transform 0.3s ease;
        z-index: 1200;
    }

    .sidebar.active {
        transform: translateX(0);
    }

    .sidebar-overlay.active {
        opacity: 1;
        pointer-events: all;
    }

    .main-content {
        padding-left: 20px;
    }
}
/* =========================
   MAIN CONTENT
========================= */

@media (max-width: 768px) {
    .main-content {
        padding: 20px;
    }

    .top-bar {
        flex-direction: column;
        align-items: flex-start;
        gap: 15px;
    }

    #view-title {
        font-size: 22px;
    }
}

/* =========================
   KPI CARDS
========================= */

@media (max-width: 768px) {
    .kpi-grid {
        grid-template-columns: 1fr 1fr;
    }
}

@media (max-width: 480px) {
    .kpi-grid {
        grid-template-columns: 1fr;
    }

    .kpi-card {
        padding: 20px;
    }
}

/* =========================
   CHARTS
========================= */

@media (max-width: 1024px) {
    .charts-container {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 480px) {
    .chart-box {
        padding: 20px;
        min-height: 320px;
    }

    .canvas-wrapper {
        height: 250px;
    }
}

/* =========================
   TABLE RESPONSIVA
========================= */

@media (max-width: 768px) {
    table {
        min-width: 700px;
    }

    .table-container {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
}

/* =========================
   REPORT CARDS
========================= */

@media (max-width: 480px) {
    .report-grid {
        grid-template-columns: 1fr;
    }

    .report-card {
        padding: 20px;
    }

    .report-card h3 {
        font-size: 18px;
    }
}

/* =========================
   MODAL
========================= */

@media (max-width: 768px) {
    .modal-content {
        max-width: 95%;
        padding: 25px;
        border-radius: 20px;
    }

    .form-grid {
        grid-template-columns: 1fr;
    }

    .full-width {
        grid-column: span 1;
    }
}

/* =========================
   BUTTONS
========================= */

@media (max-width: 480px) {
    .btn-primary,
    .btn-outline {
        width: 100%;
        padding: 14px;
    }

    .actions {
        width: 100%;
        flex-direction: column;
    }
}

/* =========================
   THEME SWITCH
========================= */

@media (max-width: 768px) {
    .theme-switch-container {
        justify-content: center;
    }
}


