*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    /* LIGHT THEME (default) */
    --bg: #f8f9fc;
    --bg-sidebar: #ffffff;
    --bg-card: #ffffff;
    --bg-input: #f1f3f8;
    --bg-hover: #eef0f6;
    --border: #e2e5ee;
    --text: #1a1d2e;
    --text-muted: #6b7280;
    --primary: #fe8511;
    --primary-hover: #e67600;
    --sidebar-width: 260px;
    --topbar-height: 64px;
    --radius: 10px;
}

[data-theme="dark"] {
    --bg: #0f1119;
    --bg-sidebar: #131624;
    --bg-card: #1a1d2e;
    --bg-input: #141725;
    --bg-hover: #1e2133;
    --border: #2a2d3e;
    --text: #e2e4ed;
    --text-muted: #8b8fa8;
    --primary: #fe8511;
    --primary-hover: #e67600;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    overflow-x: hidden;
}

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

/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 100;
    transition: transform 0.3s ease;
}

.sidebar-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 13.5px 20px;
    border-bottom: 1px solid var(--border);
}

.sidebar-logo {
    width: 36px;
    height: 36px;
    flex-shrink: 0;
}

.sidebar-brand {
    display: flex;
    flex-direction: column;
    flex: 1;
}

.brand-name {
    font-size: 15px;
    font-weight: 700;
    color: var(--text);
    letter-spacing: -0.2px;
}

.brand-version {
    font-size: 11px;
    color: var(--text-muted);
}

.sidebar-toggle-mobile {
    display: none;
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 6px;
}

.sidebar-toggle-mobile svg {
    width: 20px;
    height: 20px;
}

.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    padding: 12px 10px;
}

.nav-section {
    margin-bottom: 8px;
}

.nav-section-title {
    display: block;
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1.2px;
    color: var(--text-muted);
    padding: 8px 12px 6px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: 8px;
    color: var(--text-muted);
    text-decoration: none;
    font-size: 13.5px;
    font-weight: 500;
    transition: all 0.15s;
}

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

.nav-item.active {
    background: rgba(99,102,241,0.15);
    color: var(--primary);
}

.nav-item svg {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
}

.nav-item.active svg {
    color: var(--primary);
}

/* Main Area */
.main-area {
    flex: 1;
    margin-left: var(--sidebar-width);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    min-width: 0;
}

/* Topbar */
.topbar {
    height: var(--topbar-height);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    padding: 0 24px;
    gap: 16px;
    background: var(--bg);
    position: sticky;
    top: 0;
    z-index: 50;
}

.sidebar-toggle {
    display: none;
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 6px;
}

.sidebar-toggle svg {
    width: 22px;
    height: 22px;
}

.topbar-breadcrumb {
    flex: 1;
}

.topbar-breadcrumb span {
    font-size: 16px;
    font-weight: 600;
    color: var(--text);
}

.topbar-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.topbar-btn {
    position: relative;
    background: none;
    border: 1px solid var(--border);
    color: var(--text-muted);
    cursor: pointer;
    padding: 8px;
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    transition: all 0.15s;
}

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

.topbar-btn svg {
    width: 20px;
    height: 20px;
}

.theme-toggle {
    margin-right: 8px;
}

.badge { color:#fff; 
    position: absolute;
    top: 4px;
    right: 4px;
    background: var(--primary);
    color: var(--text);
    font-size: 10px;
    font-weight: 700;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.user-menu {
    position: relative;
}

.user-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px 6px 6px;
}

.avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--primary);
    color: var(--text);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    font-weight: 700;
    flex-shrink: 0;
}

.user-name {
    font-size: 13px;
    font-weight: 500;
    color: var(--text);
    max-width: 120px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.chevron {
    width: 16px;
    height: 16px;
}

.user-dropdown {
    display: none;
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 8px;
    width: 260px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: 0 8px 32px rgba(0,0,0,0.5);
    z-index: 200;
    overflow: hidden;
}

.user-dropdown.show {
    display: block;
}

.dropdown-user-info {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px;
}

.avatar-lg {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: var(--primary);
    color: var(--text);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    font-weight: 700;
    flex-shrink: 0;
}

.dropdown-name {
    display: block;
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
}

.dropdown-email {
    display: block;
    font-size: 12px;
    color: var(--text-muted);
}

.dropdown-role {
    display: inline-block;
    font-size: 9px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    color: var(--primary);
    background: rgba(99,102,241,0.15);
    padding: 2px 6px;
    border-radius: 4px;
    margin-top: 4px;
}

.user-dropdown hr {
    border: none;
    border-top: 1px solid var(--border);
    margin: 0;
}

.dropdown-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    color: var(--text);
    text-decoration: none;
    font-size: 13.5px;
    transition: background 0.15s;
    cursor: pointer;
}

.dropdown-item:hover {
    background: var(--bg-hover);
}

.dropdown-item svg {
    width: 18px;
    height: 18px;
    color: var(--text-muted);
}

/* Content */
.content {
    flex: 1;
    padding: 28px 24px;
    min-width: 0;
}

.page-title {
    font-size: 24px;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 24px;
    letter-spacing: -0.4px;
}

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 16px;
    margin-bottom: 28px;
}

.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 16px;
}

.stat-icon {
    width: 48px;
    height: 48px;
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.stat-icon svg {
    width: 24px;
    height: 24px;
}

.folders-icon {
    background: rgba(99,102,241,0.12);
    color: var(--primary);
}

.docs-icon {
    background: rgba(34,197,94,0.12);
    color: #22c55e;
}

.events-icon {
    background: rgba(250,204,21,0.12);
    color: #facc15;
}

.status-icon {
    background: rgba(6,182,212,0.12);
    color: #06b6d4;
}

.size-icon {
    background: rgba(168,85,247,0.12);
    color: #a855f7;
}

.stat-value {
    display: block;
    font-size: 26px;
    font-weight: 700;
    color: var(--text);
    line-height: 1.1;
}

.stat-label {
    display: block;
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 4px;
}

/* Charts Section */
.charts-section {
    margin-bottom: 28px;
}

.charts-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
    flex-wrap: wrap;
    gap: 12px;
}

.charts-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--text);
}

.charts-controls {
    display: flex;
    align-items: center;
    gap: 10px;
}

.chart-select {
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg-card);
    color: var(--text);
    font-size: 13px;
    font-family: inherit;
    cursor: pointer;
    outline: none;
    min-width: 180px;
}

.chart-select:focus {
    border-color: var(--primary);
}

.btn {
    padding: 8px 18px;
    border: none;
    border-radius: var(--radius);
    font-size: 13px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.15s;
}

.btn-primary {
    background: var(--primary);
    color: #fff;
}

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

.charts-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
}

.chart-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
    display: flex;
    flex-direction: column;
}

.chart-canvas-wrapper {
    width: 100%;
    min-height: 380px;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}

.chart-canvas-wrapper canvas {
    width: 100% !important;
    height: 100% !important;
}

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

.panel {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}

.panel-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
}

.panel-header h3 {
    font-size: 15px;
    font-weight: 600;
    color: var(--text);
}

.panel-body {
    padding: 20px;
}

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

/* API Status */
.api-status {
    display: flex;
    align-items: center;
    gap: 10px;
}

.status-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #22c55e;
    box-shadow: 0 0 8px rgba(34,197,94,0.4);
}

/* Overlay */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.6);
    z-index: 90;
}

/* Responsive */
@media (max-width: 1024px) {
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    .charts-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    .panel-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
    }
    .sidebar.open {
        transform: translateX(0);
    }
    .sidebar-toggle-mobile {
        display: block;
    }
    .sidebar-toggle {
        display: flex;
    }
    .main-area {
        margin-left: 0;
    }
    .topbar {
        padding: 0 16px;
    }
    .content {
        padding: 20px 16px;
    }
    .stats-grid {
        grid-template-columns: 1fr;
    }
    .charts-grid {
        grid-template-columns: 1fr;
    }
    .sidebar-overlay.show {
        display: block;
    }
    .user-name {
        display: none;
    }
}
