:root {
    /* Color Palette */
    --bg-dark: #0f1115;
    --bg-panel: rgba(26, 29, 36, 0.7);
    --border-color: rgba(255, 255, 255, 0.08);
    --text-primary: #ffffff;
    --text-secondary: #949ca9;
    --text-muted: #6b7280;
    
    /* Accents */
    --accent-blue: #3b82f6;
    --accent-gradient: linear-gradient(135deg, #3b82f6 0%, #10b981 100%);
    --accent-glow: rgba(59, 130, 246, 0.5);

    /* Typography */
    --font-family: 'Inter', sans-serif;

    /* Metrics & Effects */
    --radius-lg: 16px;
    --radius-md: 8px;
    --shadow-glass: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

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

body {
    font-family: var(--font-family);
    background-color: var(--bg-dark);
    color: var(--text-primary);
    -webkit-font-smoothing: antialiased;
    min-height: 100vh;
    overflow-x: hidden;
}

body::before {
    content: '';
    position: fixed;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle at 50% 50%, rgba(59, 130, 246, 0.05) 0%, transparent 40%);
    z-index: -1;
    pointer-events: none;
}

/* Utilities */
.hidden { display: none !important; }
.text-muted { color: var(--text-muted); }
.text-right { text-align: right; }
.highlight { 
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

/* Glassmorphism Panel */
.glass-panel {
    background: var(--bg-panel);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-glass);
}

/* Auth Overlay */
.overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(15, 17, 21, 0.95);
    backdrop-filter: blur(8px);
    z-index: 1000;
}
.flex-center {
    display: flex;
    align-items: center;
    justify-content: center;
}
.auth-card {
    background: var(--bg-panel);
    border: 1px solid var(--border-color);
    padding: 40px;
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 400px;
    text-align: center;
    box-shadow: 0 25px 50px -12px rgba(0,0,0,0.5);
    animation: slideUp 0.5s ease-out forwards;
}
.auth-card h2 { margin-bottom: 8px; font-weight: 600; }
.auth-card p { color: var(--text-secondary); margin-bottom: 24px; font-size: 0.9rem; }
.form-group { margin-bottom: 16px; }
input {
    width: 100%;
    padding: 12px 16px;
    background: rgba(0,0,0,0.3);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: 1rem;
    outline: none;
    transition: var(--transition);
}
input:focus {
    border-color: var(--accent-blue);
    box-shadow: 0 0 0 2px var(--accent-glow);
}
button {
    width: 100%;
    padding: 12px 16px;
    background: var(--accent-gradient);
    border: none;
    border-radius: var(--radius-md);
    color: #fff;
    font-weight: 600;
    font-size: 1rem;
    cursor: pointer;
    transition: var(--transition);
}
button:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 16px var(--accent-glow);
}
.error-text {
    color: #ef4444;
    margin-top: 16px;
    font-size: 0.85rem;
}

/* App Container */
.app-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 24px 32px;
    display: flex;
    flex-direction: column;
    gap: 24px;
}

/* Header */
.app-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border-color);
}
.header-left { display: flex; align-items: center; gap: 12px; }
.header-left h1 { font-size: 1.5rem; font-weight: 600; letter-spacing: -0.02em; }
.badge {
    background: rgba(16, 185, 129, 0.1);
    color: #10b981;
    padding: 4px 8px;
    border-radius: 99px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    border: 1px solid rgba(16, 185, 129, 0.2);
}
.header-right { display: flex; align-items: center; gap: 20px; }
.filter-group { display: flex; align-items: center; gap: 8px; }
.filter-group label {
    font-size: 0.85rem;
    color: var(--text-secondary);
    font-weight: 500;
}
.filter-group select {
    background: rgba(255,255,255,0.05);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 6px 12px;
    border-radius: var(--radius-md);
    outline: none;
    cursor: pointer;
    font-family: inherit;
    font-size: 0.9rem;
    transition: var(--transition);
}
.filter-group select:hover { border-color: var(--accent-blue); }
.filter-group select option { background: var(--bg-dark); }

.icon-button {
    width: 36px; height: 36px;
    padding: 0;
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    display: flex; align-items: center; justify-content: center;
    border-radius: var(--radius-md);
}
.icon-button:hover {
    background: rgba(255,255,255,0.05);
    color: var(--text-primary);
    transform: none;
    box-shadow: none;
}

/* Loading State */
.state-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 60vh;
    color: var(--text-secondary);
}
.spinner {
    width: 40px; height: 40px;
    border: 3px solid rgba(255,255,255,0.1);
    border-top-color: var(--accent-blue);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 16px;
}

/* Dashboard Grids */
.data-wrapper {
    display: flex;
    flex-direction: column;
    gap: 24px;
    animation: fadeIn 0.6s ease-out;
}

/* KPIs */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
}
.kpi-card {
    background: var(--bg-panel);
    border: 1px solid var(--border-color);
    padding: 24px;
    border-radius: var(--radius-lg);
    transition: var(--transition);
}
.kpi-card:hover {
    transform: translateY(-4px);
    border-color: rgba(255,255,255,0.2);
}
.kpi-title {
    color: var(--text-secondary);
    font-size: 0.85rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 12px;
}
.kpi-value {
    font-size: 2.5rem;
    font-weight: 700;
    line-height: 1;
}

/* Charts & Tables */
.charts-grid, .tables-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
}
.wide-span {
    grid-column: 1 / -1;
}
@media(min-width: 1024px) {
    .charts-grid { grid-template-columns: 2fr 1fr; }
    .wide-span { grid-column: auto; }
}

.chart-card, .table-card {
    padding: 24px;
    display: flex;
    flex-direction: column;
}
.chart-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
}
.chart-header h3 {
    margin-bottom: 0 !important;
}
.chart-actions {
    display: flex;
    gap: 12px;
}
.text-button {
    background: transparent;
    border: none;
    color: var(--accent-blue);
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 4px;
    transition: var(--transition);
}
.text-button:hover {
    background: rgba(59, 130, 246, 0.1);
    transform: none;
    box-shadow: none;
}
.chart-card h3, .table-card h3 {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 24px;
    color: var(--text-primary);
}
.canvas-container {
    position: relative;
    height: 300px;
    width: 100%;
}

/* Tables */
.table-responsive {
    overflow-x: auto;
}
table {
    width: 100%;
    border-collapse: collapse;
}
th, td {
    padding: 12px 16px;
    text-align: left;
    border-bottom: 1px solid rgba(255,255,255,0.05);
}
th {
    color: var(--text-secondary);
    font-weight: 500;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}
tr:last-child td { border-bottom: none; }
tr { transition: background 0.2s; }
tr:hover td { background: rgba(255,255,255,0.02); }

td { font-size: 0.95rem; }

/* Animations */
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes slideUp {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* Responsive */
@media (max-width: 768px) {
    .app-container { padding: 16px; }
    .charts-grid, .tables-grid { grid-template-columns: 1fr; }
    .header-left h1 { font-size: 1.2rem; }
    .icon-button { width: 32px; height: 32px; }
    .kpi-value { font-size: 2rem; }
}
