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

body {
    height: 100vh;
}

/* ========================= 
   CSS CUSTOM PROPERTIES (THEME VARIABLES)
========================= */

:root {
    /* Light theme (default) */
    --bg-content: #f5f6fa;
    --bg-card: #ffffff;
    --bg-card-hover: rgba(28, 74, 160, 0.04);
    --text-primary: #1a1a2e;
    --text-secondary: #555;
    --text-meta: #777;
    --border-color: #e0e0e0;
    --header-bg: #ffffff;
    --header-border: #e8e8e8;
    --page-title-color: #1a1a2e;
    --page-subtitle-color: #666;
    --chart-bg: #ffffff;
    --table-header-bg: #1c4aa0;
    --table-header-color: #ffffff;
    --kpi-label-color: #555;
    --kpi-value-color: #1a1a2e;
    --kpi-meta-color: #777;
    --kpi-border-color: #e0e0e0;
    --kpi-positive-border: #28a745;
    --download-btn-bg: #1c4aa0;
    --download-btn-color: #ffffff;
    --download-btn-hover: #163b7a;
    --toggle-bg: rgba(255,255,255,0.15);
    --toggle-border: rgba(255,255,255,0.3);
    --toggle-color: #ffffff;
}

/* Dark theme applied to <body> */
body.dark-mode {
    --bg-content: #0f1117;
    --bg-card: #1a1d27;
    --bg-card-hover: rgba(100, 160, 255, 0.08);
    --text-primary: #e8eaf0;
    --text-secondary: #b0b8cc;
    --text-meta: #8892a4;
    --border-color: #2a2f3e;
    --header-bg: #1a1d27;
    --header-border: #2a2f3e;
    --page-title-color: #e8eaf0;
    --page-subtitle-color: #8892a4;
    --chart-bg: #1a1d27;
    --table-header-bg: #1c3a7a;
    --table-header-color: #e8eaf0;
    --kpi-label-color: #8892a4;
    --kpi-value-color: #e8eaf0;
    --kpi-meta-color: #6b7a90;
    --kpi-border-color: #2a2f3e;
    --kpi-positive-border: #28a745;
    --download-btn-bg: #1c4aa0;
    --download-btn-color: #ffffff;
    --download-btn-hover: #2255b8;
    --toggle-bg: rgba(255,255,255,0.1);
    --toggle-border: rgba(255,255,255,0.2);
    --toggle-color: #ffffff;
}

/* ========================= 
   MAIN LAYOUT
========================= */
.dashboard-container {
    display: flex;
    height: 100vh;
    background: url("main.png") center/cover no-repeat;
}

/* SIDEBAR */
.sidebar {
    position: relative;
    width: 260px;
    height: 100vh;
    background: url("main.png") center/cover no-repeat;
    flex-shrink: 0;
}

/* DARK OVERLAY */
.sidebar-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
    z-index: 1;
}

/* MENU */
.menu {
    position: absolute;
    top: 0;
    bottom: 0;
    left: 0;
    right: 0;

    z-index: 2;
    padding: 40px 35px;

    display: flex;
    flex-direction: column;

    padding-top: 230px;
}

/* MENU LINKS */
.menu a {
    color: #ffffff;
    text-decoration: none;
    font-size: 18px;
    font-weight: 500;
    line-height: 1.1;

    display: inline-block;
    margin-bottom: 30px;

    position: relative;
    z-index: 1;
}

/* BLUE HOVER / ACTIVE BACKGROUND */
.menu a::before {
    content: "";
    position: absolute;
    top: -6px;
    bottom: -6px;
    left: -45px;
    right: -35px;

    background: rgba(0, 140, 255, 0.35);
    border-radius: 6px;

    opacity: 0;
    z-index: -1;
    transition: opacity 0.2s ease;
}

.menu a:hover::before {
    opacity: 1;
}

.menu a.active {
    font-weight: 700;
}

.menu a.active::before {
    opacity: 1;
}

/* LOGOUT AT BOTTOM */
.menu a.logout {
    margin-top: auto;
    margin-bottom: 12px;
    font-weight: 700;
}

/* THEME TOGGLE BUTTON */
.theme-toggle-btn {
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--toggle-bg);
    border: 1px solid var(--toggle-border);
    border-radius: 30px;
    padding: 8px 16px;
    cursor: pointer;
    color: var(--toggle-color);
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 20px;
    width: 100%;
    transition: background 0.2s ease, border-color 0.2s ease;
    z-index: 2;
    position: relative;
}

.theme-toggle-btn:hover {
    background: rgba(255, 255, 255, 0.25);
}

.theme-toggle-btn .toggle-track {
    width: 36px;
    height: 20px;
    background: rgba(255,255,255,0.25);
    border-radius: 10px;
    position: relative;
    flex-shrink: 0;
    transition: background 0.3s ease;
}

.theme-toggle-btn .toggle-thumb {
    position: absolute;
    top: 2px;
    left: 2px;
    width: 16px;
    height: 16px;
    background: #ffffff;
    border-radius: 50%;
    transition: transform 0.3s ease;
    box-shadow: 0 1px 4px rgba(0,0,0,0.3);
}

body.dark-mode .theme-toggle-btn .toggle-track {
    background: #4a90d9;
}

body.dark-mode .theme-toggle-btn .toggle-thumb {
    transform: translateX(16px);
}

.toggle-label {
    flex: 1;
    text-align: left;
}

.toggle-icon {
    font-size: 15px;
}

/* MAIN CONTENT */
.content {
    flex: 1;
    background-color: var(--bg-content);
    overflow-y: auto;
    transition: background-color 0.3s ease;
    padding: 30px 40px;
}

/* PAGE HEADER */
.page-header {
    margin-bottom: 24px;
}

.page-header h1 {
    font-size: 28px;
    font-weight: 700;
    color: var(--page-title-color);
    transition: color 0.3s ease;
}

.page-header p {
    font-size: 14px;
    color: var(--page-subtitle-color);
    margin-top: 4px;
    transition: color 0.3s ease;
}

/* DOWNLOAD BUTTON */
.download-btn {
    display: inline-block;
    margin-bottom: 24px;
    padding: 10px 20px;
    background-color: var(--download-btn-bg);
    color: var(--download-btn-color);
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.2s ease;
    float: right;
    margin-top: -60px;
}

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

/* KPI CARDS */
.kpi-container {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 20px;
    margin-bottom: 28px;
    clear: both;
}

.kpi-card {
    background: var(--bg-card);
    border-radius: 12px;
    padding: 20px 22px;
    border-left: 4px solid var(--kpi-border-color);
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
    transition: background 0.3s ease, border-color 0.3s ease, box-shadow 0.3s ease;
}

body.dark-mode .kpi-card {
    box-shadow: 0 2px 12px rgba(0,0,0,0.3);
}

.kpi-card.positive {
    border-left-color: var(--kpi-positive-border);
}

.kpi-label {
    font-size: 13px;
    font-weight: 600;
    color: var(--kpi-label-color);
    margin-bottom: 8px;
    transition: color 0.3s ease;
}

.kpi-icon {
    margin-right: 4px;
}

.kpi-value {
    font-size: 30px;
    font-weight: 700;
    color: var(--kpi-value-color);
    margin-bottom: 6px;
    transition: color 0.3s ease;
}

.kpi-value.positive {
    color: #28a745;
}

.kpi-meta {
    font-size: 12px;
    color: var(--kpi-meta-color);
    transition: color 0.3s ease;
}

/* CHART CONTAINER */
.chart-container {
    background: var(--chart-bg);
    border-radius: 12px;
    padding: 24px;
    margin-bottom: 24px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
    transition: background 0.3s ease, box-shadow 0.3s ease;
}

body.dark-mode .chart-container {
    box-shadow: 0 2px 12px rgba(0,0,0,0.3);
}

.chart-title {
    font-size: 16px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 18px;
    transition: color 0.3s ease;
}

.chart-wrapper {
    height: 320px;
    position: relative;
}

/* GRID */
.grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

/* TABLES INSIDE CHART CONTAINERS */
.chart-container table {
    width: 100%;
    border-collapse: collapse;
}

.chart-container table tr {
    border-bottom: 1px solid var(--border-color);
    transition: background 0.2s ease, border-color 0.3s ease;
}

.chart-container table tr:last-child {
    border-bottom: none;
}

.chart-container table tr:hover {
    background: var(--bg-card-hover);
}

.chart-container table td {
    padding: 12px 8px;
    font-size: 14px;
    color: var(--text-primary);
    transition: color 0.3s ease;
}

/* LOGO ABOVE MENU */
.menu-logo {
    width: 100%;
    margin-bottom: 45px;
    margin-top: -200px;
    text-align: center;
}

.menu-logo img {
    width: 180px;
    max-width: 100%;
    height: auto;
}

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

.modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    justify-content: center;
    align-items: center;
    z-index: 9999;
}

.modal-box {
    background: var(--bg-card);
    padding: 30px 40px;
    border-radius: 12px;
    text-align: center;
    width: 350px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.2);
    transition: background 0.3s ease;
}

.modal-box h2 {
    font-size: 18px;
    margin-bottom: 20px;
    color: var(--text-primary);
    transition: color 0.3s ease;
}

.modal-buttons {
    display: flex;
    justify-content: space-between;
    gap: 10px;
}

.confirm-btn {
    flex: 1;
    padding: 10px;
    background-color: #1c4aa0;
    color: white;
    text-decoration: none;
    border-radius: 6px;
    text-align: center;
}

.confirm-btn:hover {
    background-color: #163b7a;
}

.cancel-btn {
    flex: 1;
    padding: 10px;
    border: none;
    background-color: #ccc;
    border-radius: 6px;
    cursor: pointer;
}

.cancel-btn:hover {
    background-color: #b5b5b5;
}

/* HISTORY TABLE */
.history-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 20px;
    background: var(--bg-card);
    border-radius: 10px;
    overflow: hidden;
    transition: background 0.3s ease;
}

.history-table th,
.history-table td {
    padding: 14px;
    text-align: center;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-primary);
    transition: color 0.3s ease, border-color 0.3s ease;
}

.history-table th {
    background-color: var(--table-header-bg);
    color: var(--table-header-color);
    font-weight: 600;
    transition: background-color 0.3s ease;
}

.history-table tr:hover {
    background-color: var(--bg-card-hover);
}