:root {
    --bg-main: #0f172a;
    /* Slate 900 */
    --bg-secondary: rgba(30, 41, 59, 0.7);
    /* Slate 800 */
    --text-main: #f8fafc;
    /* Slate 50 */
    --text-muted: #94a3b8;
    /* Slate 400 */

    --accent-blue: #3b82f6;
    /* Blue 500 */
    --accent-red: #ef4444;
    /* Red 500 */
    --accent-teal: #06b6d4;
    /* Cyan 500 */
    --accent-green: #10b981;
    /* Emerald 500 */

    --border-color: rgba(255, 255, 255, 0.1);
}

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

body.dark-theme,
body {
    font-family: 'Inter', system-ui, sans-serif;
    background-color: var(--bg-main);
    color: var(--text-main);
    display: flex;
    min-height: 100vh;
    overflow: hidden;
    /* Prevent double scrollbar, let internal containers scroll */
}

/* Glassmorphism Classes */
.glass {
    background: var(--bg-secondary);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--border-color);
    box-shadow: 0 4px 30px rgba(0, 0, 0, 0.1);
}

.app-container {
    display: flex;
    width: 100%;
}

/* Sidebar */
.sidebar {
    width: 250px;
    padding: 1.5rem 1rem;
    display: flex;
    flex-direction: column;
    gap: 2rem;
    border-right: 1px solid var(--border-color);
}

.logo-container {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0 1rem;
}

.logo-circle {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent-blue), #8b5cf6);
}

.logo-text {
    font-weight: 700;
    font-size: 1.25rem;
    color: var(--text-main);
    letter-spacing: -0.025em;
}

.nav-menu {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    color: var(--text-muted);
    text-decoration: none;
    border-radius: 0.5rem;
    font-weight: 500;
    transition: all 0.2s ease;
}

.nav-item svg {
    width: 20px;
    height: 20px;
}

.nav-item:hover,
.nav-item.active {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-main);
}

.nav-item.active {
    background: linear-gradient(90deg, rgba(59, 130, 246, 0.1) 0%, transparent 100%);
    border-left: 3px solid var(--accent-blue);
}

/* Main Content */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    height: 100vh;
}

.topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 2rem;
    border-bottom: 1px solid var(--border-color);
}

.page-title {
    font-size: 1.5rem;
    font-weight: 600;
}

.user-profile {
    display: flex;
    align-items: center;
    gap: 1.25rem;
}

.avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: 2px solid var(--border-color);
}

.logout-btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--text-muted);
    text-decoration: none;
    font-size: 0.875rem;
    font-weight: 500;
    transition: color 0.2s, transform 0.2s;
}

.logout-btn:hover {
    color: var(--accent-red);
    transform: translateY(-1px);
}

.logout-btn svg {
    width: 18px;
    height: 18px;
}

/* Dashboard Wrappers */
.dashboard-content {
    padding: 2rem;
    max-width: 1400px;
    margin: 0 auto;
    width: 100%;
    flex: 1;
    /* Take all available height from main-content */
    overflow-y: auto;
}

.dashboard-title {
    font-size: 1.5rem;
    margin-bottom: 1.5rem;
    font-weight: 600;
}

/* Top Stats Cards Layout */
.top-stats-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1.5rem;
    margin-bottom: 1.5rem;
}

.stat-box {
    padding: 1.5rem;
    border-radius: 1rem;
    display: flex;
    flex-direction: column;
    transition: transform 0.2s;
}

.stat-box:hover {
    transform: translateY(-2px);
}

.stat-box.blue {
    border-bottom: 4px solid var(--accent-blue);
}

.stat-box.red {
    border-bottom: 4px solid var(--accent-red);
}

.stat-box.teal {
    border-bottom: 4px solid var(--accent-teal);
}

.stat-box .number {
    font-size: 2.5rem;
    font-weight: 700;
    line-height: 1;
    margin-bottom: 0.5rem;
}

.stat-box.blue .number {
    color: var(--accent-blue);
}

.stat-box.red .number {
    color: var(--accent-red);
}

.stat-box.teal .number {
    color: var(--accent-teal);
}

.stat-box .label {
    font-size: 0.875rem;
    color: var(--text-muted);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* Control Panel */
.control-panel {
    border-radius: 1rem;
    padding: 1rem 1.5rem;
    margin-bottom: 1.5rem;
    display: flex;
    flex-direction: column;
}

.control-panel label {
    display: block;
    font-size: 0.875rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: var(--text-muted);
}

.styled-select {
    width: 100%;
    padding: 0.75rem 1rem;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--border-color);
    border-radius: 0.5rem;
    color: var(--text-main);
    font-family: inherit;
    outline: none;
    appearance: none;
}

/* Charts Grid */
.charts-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1.5rem;
}

.chart-card {
    border-radius: 1rem;
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
}

.chart-card.span-full {
    grid-column: 1 / -1;
}

.chart-title {
    font-size: 1.25rem;
    font-weight: 600;
}

.chart-subtitle {
    font-size: 0.875rem;
    color: var(--text-muted);
    margin-bottom: 1rem;
}

.chart-averages {
    margin-top: 1rem;
    font-size: 0.875rem;
    font-weight: 500;
    display: flex;
    gap: 1rem;
}

.chart-averages .tx {
    color: var(--accent-blue);
}

.chart-averages .rx {
    color: var(--accent-red);
}

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

/* Custom Premium Scrollbar */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.05);
}

::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    border: 2px solid transparent;
    background-clip: content-box;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.2);
    border: 2px solid transparent;
    background-clip: content-box;
}

/* Firefox Support */
* {
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.1) rgba(0, 0, 0, 0.05);
}