:root {
    --primary: #024BCB;
    --primary-hover: #023ca1;
    --sidebar-bg: #002047;
    --main-bg: #F5F9FC;
    --header-bg: #F6FAFD;
    --card-bg: #FFFFFF;
    --text-main: #111827;
    --text-muted: #6B7280;
    --border-color: #E5E7EB;
    
    --c-blue: #1C5BB8;
    --c-green: #25A14D;
    --c-purple: #6236B5;
    --c-orange: #E6821F;
    --c-red: #D52A30;
    --c-teal: #199A9A;
    --c-success-bg: #DCFCE7;
    --c-success-text: #166534;
}

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

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

/* Layout */
.layout {
    display: flex;
    min-height: 100vh;
    position: relative;
}

/* Sidebar */
.sidebar {
    width: 260px;
    background-color: var(--sidebar-bg);
    color: white;
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    height: 100vh;
    position: sticky;
    top: 0;
    z-index: 40;
    transition: transform 0.3s ease;
}

.sidebar-header {
    padding: 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.logo {
    display: flex;
    align-items: center;
    gap: 12px;
}

.logo i {
    font-size: 32px;
    color: #4CAF50;
}

.logo h1 {
    font-size: 15px;
    font-weight: 700;
    line-height: 1.2;
    letter-spacing: 0.5px;
}

.logo p {
    font-size: 11px;
    color: #9CA3AF;
}

.close-sidebar {
    display: none;
    background: transparent;
    border: none;
    color: white;
    font-size: 24px;
    cursor: pointer;
}

.sidebar-nav {
    display: flex;
    flex-direction: column;
    padding: 0 16px;
    gap: 4px;
    flex-grow: 1;
    overflow-y: auto;
}

.sidebar-nav::-webkit-scrollbar {
    width: 4px;
}
.sidebar-nav::-webkit-scrollbar-thumb {
    background: rgba(255,255,255,0.2);
    border-radius: 4px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    color: #9CA3AF;
    text-decoration: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s ease;
}

.nav-item i {
    font-size: 20px;
}

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

.nav-item.active {
    background-color: var(--primary);
    color: white;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

.sidebar-upload {
    padding: 24px;
}

.upload-box {
    background-color: rgba(255, 255, 255, 0.03);
    border-radius: 12px;
    padding: 16px;
    border: 1px dashed rgba(255, 255, 255, 0.15);
    transition: border-color 0.3s;
}

.upload-box:hover {
    border-color: rgba(255, 255, 255, 0.3);
}

.upload-title {
    font-size: 11px;
    font-weight: 600;
    text-align: center;
    margin-bottom: 4px;
    letter-spacing: 0.5px;
}

.upload-format {
    font-size: 11px;
    color: #9CA3AF;
    text-align: center;
    margin-bottom: 16px;
}

.drop-zone {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    margin-bottom: 16px;
    padding: 10px;
}

.drop-zone i {
    font-size: 32px;
    color: #9CA3AF;
}

.drop-zone p {
    font-size: 11px;
    text-align: center;
    color: #9CA3AF;
    line-height: 1.4;
}

.btn-primary {
    background-color: var(--primary);
    color: white;
    border: none;
    border-radius: 8px;
    padding: 10px 16px;
    font-weight: 600;
    font-size: 13px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all 0.2s;
    box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
}

.btn-primary:hover {
    background-color: var(--primary-hover);
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

.drop-zone .btn-primary {
    width: 100%;
    margin-top: 4px;
}

.file-name {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 11px;
    margin-bottom: 8px;
    background: rgba(0,0,0,0.25);
    padding: 8px 10px;
    border-radius: 6px;
    overflow: hidden;
}

.file-name span {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.text-success {
    color: #4CAF50;
    margin-left: auto;
    font-size: 16px;
}

.last-upload {
    font-size: 10px;
    color: #9CA3AF;
    line-height: 1.4;
}

/* Main Content */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0; /* Important for flex child truncating */
}

/* Header */
.top-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 32px;
    background-color: var(--header-bg);
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    z-index: 30;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 16px;
}

.mobile-menu-btn {
    display: none;
    background: transparent;
    border: none;
    font-size: 24px;
    color: var(--text-main);
    cursor: pointer;
}

.header-titles h2 {
    font-size: 20px;
    font-weight: 700;
    margin-bottom: 4px;
    color: #111827;
}

.header-titles p {
    font-size: 13px;
    color: var(--text-muted);
}

.header-actions {
    display: flex;
    gap: 12px;
    align-items: center;
}

.filter-group {
    display: flex;
    align-items: center;
    gap: 8px;
    background: white;
    border: 1px solid var(--border-color);
    padding: 8px 12px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 500;
    box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
}

.filter-group i {
    color: var(--text-muted);
    font-size: 16px;
}

.filter-group select {
    border: none;
    outline: none;
    font-weight: 600;
    background: transparent;
    cursor: pointer;
    color: var(--text-main);
}

/* Metrics Grid */
.metrics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    padding: 24px 32px;
}

@media (min-width: 1400px) {
    .metrics-grid {
        grid-template-columns: repeat(6, 1fr);
    }
}
@media (min-width: 1024px) and (max-width: 1399px) {
    .metrics-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

.metric-card {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 20px 16px;
    display: grid;
    grid-template-columns: 44px 1fr;
    grid-template-rows: auto auto auto;
    column-gap: 12px;
    row-gap: 6px;
    box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.05);
    transition: transform 0.2s, box-shadow 0.2s;
}

.metric-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

.metric-header {
    display: contents;
}

.icon-box {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 24px;
    grid-column: 1;
    grid-row: 1 / 4;
    align-self: flex-start;
}

.bg-blue { background-color: var(--c-blue); }
.bg-green { background-color: var(--c-green); }
.bg-purple { background-color: var(--c-purple); }
.bg-orange { background-color: var(--c-orange); }
.bg-red { background-color: var(--c-red); }
.bg-teal { background-color: var(--c-teal); }

.metric-header h3 {
    font-size: 11px;
    font-weight: 800;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    grid-column: 2;
    grid-row: 1;
    display: flex;
    align-items: flex-start;
    margin: 0;
    padding-top: 2px;
}

.icon-box.bg-blue + h3 { color: var(--c-blue); }
.icon-box.bg-green + h3 { color: var(--c-green); }
.icon-box.bg-purple + h3 { color: var(--c-purple); }
.icon-box.bg-orange + h3 { color: var(--c-orange); }
.icon-box.bg-red + h3 { color: var(--c-red); }
.icon-box.bg-teal + h3 { color: var(--c-teal); }

.metric-value {
    font-size: 19px;
    font-weight: 800;
    color: #111827;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    grid-column: 2;
    grid-row: 2;
    align-self: flex-start;
}

.metric-trend {
    font-size: 12px;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 4px;
    grid-column: 2;
    grid-row: 3;
    align-self: flex-start;
}

.metric-trend.positive { color: var(--c-green); }
.metric-trend.negative { color: var(--c-red); }
.trend-label { color: var(--text-muted); font-weight: 500; font-size: 11px; margin-left: 2px;}

/* Middle & Bottom Grid */
.middle-grid, .bottom-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 24px;
    padding: 0 32px 24px;
}

.card-panel {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 20px 24px;
    box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.05);
    display: flex;
    flex-direction: column;
}

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

.panel-header h3 {
    font-size: 14px;
    font-weight: 700;
    color: #111827;
}

.panel-header i {
    color: var(--text-muted);
    font-size: 20px;
    cursor: pointer;
}

.chart-container {
    position: relative;
    height: 320px;
    width: 100%;
    flex-grow: 1;
}

.pie-container {
    height: 360px;
}

/* Tables */
.table-responsive {
    overflow-x: auto;
    border-radius: 8px;
    border: 1px solid var(--border-color);
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.data-table th, .data-table td {
    padding: 14px 16px;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

.data-table th {
    background-color: #F9FAFB;
    font-weight: 600;
    color: var(--text-muted);
    white-space: nowrap;
}

.data-table tbody tr:hover {
    background-color: #F9FAFB;
}

.data-table tbody tr:last-child td {
    border-bottom: none;
}

.data-table tfoot td {
    padding: 14px 16px;
    background-color: #F9FAFB;
    border-top: 2px solid var(--border-color);
}

.text-right { text-align: right !important; }
.text-center { text-align: center !important; }
.font-bold { font-weight: 700; color: #111827; }

.status-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 4px 10px;
    border-radius: 9999px;
    font-size: 11px;
    font-weight: 600;
    background: var(--c-success-bg);
    color: var(--c-success-text);
}

.trend-up { color: var(--c-green); font-weight: 600; }
.trend-down { color: var(--c-red); font-weight: 600; }

.table-note {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 16px;
    font-style: italic;
}

/* Footer Info */
.footer-info {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 0 32px 24px;
    color: var(--primary);
    font-size: 13px;
    font-weight: 500;
}

.footer-info i {
    font-size: 20px;
    margin-top: -2px;
}

/* Overlay for Mobile Sidebar */
.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 35;
    opacity: 0;
    transition: opacity 0.3s;
}

/* Responsive Breakpoints */
@media (max-width: 1200px) {
    .middle-grid, .bottom-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 992px) {
    .sidebar {
        position: fixed;
        transform: translateX(-100%);
    }
    
    .sidebar.active {
        transform: translateX(0);
    }
    
    .sidebar-overlay.active {
        display: block;
        opacity: 1;
    }
    
    .mobile-menu-btn {
        display: block;
    }

    .close-sidebar {
        display: block;
    }
}

@media (max-width: 768px) {
    .top-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 16px;
        padding: 16px 20px;
    }
    
    .header-actions {
        width: 100%;
        justify-content: space-between;
    }
    
    .metrics-grid {
        padding: 16px 20px;
    }
    
    .middle-grid, .bottom-grid {
        padding: 0 20px 16px;
    }

    .footer-info {
        padding: 0 20px 24px;
    }
}
