:root {
    --bg-primary: #f8fafc;
    --bg-secondary: #ffffff;
    --bg-card: #ffffff;
    --bg-card-hover: #f1f5f9;
    --border-subtle: rgba(99, 102, 241, 0.08);
    --border-hover: rgba(99, 102, 241, 0.16);
    --text-primary: #0f172a;
    --text-secondary: #475569;
    --text-muted: #64748b;
    --accent-primary: #6366f1;
    --accent-secondary: #8b5cf6;
    --accent-glow: rgba(99, 102, 241, 0.15);
    --accent-gradient: linear-gradient(135deg, #6366f1, #8b5cf6);
    --success: #10b981;
    --success-bg: rgba(16, 185, 129, 0.08);
    --danger: #f43f5e;
    --danger-bg: rgba(244, 63, 94, 0.08);
    --radius-sm: 8px;
    --radius-md: 14px;
    --radius-lg: 20px;
    --transition-smooth: 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background-color: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
    /* Soft premium glowing blobs behind dashboard */
    background-image: radial-gradient(circle at 10% 20%, rgba(99, 102, 241, 0.04), transparent 30%),
                      radial-gradient(circle at 90% 80%, rgba(139, 92, 246, 0.03), transparent 30%);
}

.dashboard-container {
    display: flex;
    height: 100vh;
    overflow: hidden;
}

/* Sidebar */
.sidebar {
    width: 280px;
    background: var(--bg-secondary);
    border-right: 1px solid var(--border-subtle);
    display: flex;
    flex-direction: column;
    padding: 32px 24px;
    justify-content: space-between;
    z-index: 10;
    box-shadow: 4px 0 24px rgba(99, 102, 241, 0.02);
}

.logo h2 {
    font-family: 'Outfit', sans-serif;
    font-size: 24px;
    font-weight: 800;
    letter-spacing: -0.8px;
    color: var(--text-primary);
    margin-bottom: 40px;
}

.logo span {
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.menu {
    display: flex;
    flex-direction: column;
    gap: 6px;
    flex-grow: 1;
}

.menu-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    color: var(--text-secondary);
    text-decoration: none;
    border-radius: var(--radius-md);
    font-weight: 500;
    font-size: 14px;
    transition: all 0.2s ease;
}

.menu-item svg {
    transition: transform 0.2s ease;
}

.menu-item:hover {
    background: var(--bg-card-hover);
    color: var(--text-primary);
}

.menu-item:hover svg {
    transform: scale(1.05);
}

.menu-item.active {
    background: var(--accent-gradient);
    color: white;
    box-shadow: 0 8px 20px rgba(99, 102, 241, 0.2);
}

/* AI Copilot Widget in Sidebar */
.ai-copilot-widget {
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.03), rgba(139, 92, 246, 0.05));
    border: 1px solid rgba(99, 102, 241, 0.12);
    border-radius: var(--radius-md);
    padding: 18px;
    margin-top: auto;
    position: relative;
    overflow: hidden;
}

.ai-copilot-widget::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle, rgba(139, 92, 246, 0.05) 0%, transparent 60%);
    pointer-events: none;
    animation: rotateGlow 10s linear infinite;
}

@keyframes rotateGlow {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.ai-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
}

.ai-header h4 {
    font-size: 14px;
    font-weight: 600;
    color: var(--accent-primary);
}

.ai-header svg {
    color: var(--accent-secondary);
    animation: pulseGlow 2s infinite ease-in-out;
}

@keyframes pulseGlow {
    0%, 100% { opacity: 0.6; transform: scale(1); }
    50% { opacity: 1; transform: scale(1.1); }
}

.ai-content {
    font-size: 12px;
    line-height: 1.5;
    color: var(--text-secondary);
    margin-bottom: 12px;
    min-height: 54px;
}

.btn-ai-audit {
    width: 100%;
    background: var(--bg-card);
    border: 1px solid rgba(99, 102, 241, 0.2);
    color: var(--accent-primary);
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.btn-ai-audit:hover {
    background: var(--accent-gradient);
    color: white;
    border-color: transparent;
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.15);
}

/* Main Content */
.main-content {
    flex: 1;
    padding: 40px 48px;
    overflow-y: auto;
    height: 100vh;
}

.topbar {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    margin-bottom: 36px;
}

.title-area h1 {
    font-family: 'Outfit', sans-serif;
    font-size: 28px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 6px;
}

.title-area p {
    color: var(--text-muted);
    font-size: 14px;
}

.highlight {
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.actions {
    display: flex;
    gap: 16px;
}

.date-picker {
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    color: var(--text-secondary);
    padding: 10px 16px;
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-weight: 500;
    font-size: 14px;
    outline: none;
    cursor: pointer;
    transition: border-color 0.2s;
}

.date-picker:focus {
    border-color: var(--accent-primary);
}

.btn-primary {
    background: var(--accent-gradient);
    color: white;
    border: none;
    padding: 10px 22px;
    border-radius: var(--radius-sm);
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 8px;
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 15px rgba(99, 102, 241, 0.25);
}

.btn-primary svg.spin {
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Glassmorphism Cards */
.glass {
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    padding: 28px;
    box-shadow: 0 10px 30px rgba(99, 102, 241, 0.02), 0 1px 8px rgba(99, 102, 241, 0.01);
    transition: transform var(--transition-smooth), border-color var(--transition-smooth), box-shadow var(--transition-smooth);
}

.glass:hover {
    border-color: var(--border-hover);
    box-shadow: 0 16px 40px rgba(99, 102, 241, 0.04), 0 2px 10px rgba(99, 102, 241, 0.02);
}

.glow {
    position: relative;
}

.glow::after {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: var(--radius-lg);
    box-shadow: 0 0 30px rgba(99, 102, 241, 0.05);
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.glow:hover::after {
    opacity: 1;
}

/* KPI Grid */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 24px;
    margin-bottom: 32px;
}

.kpi-card {
    display: flex;
    flex-direction: column;
}

.kpi-card:hover {
    transform: translateY(-2px);
}

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

.kpi-header h3 {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.badge {
    font-size: 11px;
    font-weight: 700;
    padding: 4px 10px;
    border-radius: 20px;
}

.badge.positive {
    background: var(--success-bg);
    color: var(--success);
}

.badge.negative {
    background: var(--danger-bg);
    color: var(--danger);
}

.kpi-value {
    font-family: 'Outfit', sans-serif;
    font-size: 34px;
    font-weight: 800;
    color: var(--text-primary);
    margin-bottom: 6px;
    letter-spacing: -1px;
    transition: color 0.3s;
}

.highlight-green { color: var(--success); }
.highlight-red { color: var(--danger); }
.highlight-blue { color: var(--accent-primary); }

.kpi-sub {
    font-size: 13px;
    color: var(--text-secondary);
}

/* Charts Grid */
.charts-grid {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 24px;
}

.chart-card.large {
    grid-column: 1 / 3;
}

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

.chart-header h3 {
    font-size: 16px;
    font-weight: 700;
    color: var(--text-primary);
}

.canvas-container {
    position: relative;
    width: 100%;
    height: 320px;
}

/* Tables */
.table-container {
    overflow-x: auto;
    margin-top: 12px;
}

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

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

.data-table th {
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    font-size: 11px;
    letter-spacing: 0.8px;
    background: rgba(99, 102, 241, 0.01);
}

.data-table tbody tr {
    transition: background-color 0.2s;
}

.data-table tbody tr:hover {
    background: rgba(99, 102, 241, 0.02);
}

.data-table td strong {
    color: var(--text-primary);
}

/* Connections Grid */
.connection-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 24px;
}

.status-indicator {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: var(--success);
    background: var(--success-bg);
    padding: 4px 10px;
    border-radius: 12px;
    font-weight: 600;
}

.status-dot {
    width: 6px;
    height: 6px;
    background-color: var(--success);
    border-radius: 50%;
    box-shadow: 0 0 10px var(--success);
    animation: blink 2.5s infinite;
}

@keyframes blink {
    0%, 100% { opacity: 0.5; }
    50% { opacity: 1; }
}

/* Tabs */
.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
    animation: fadeInUp 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(15px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Responsive */
@media (max-width: 1400px) {
    .kpi-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    .charts-grid {
        grid-template-columns: 1fr;
    }
    .chart-card.large {
        grid-column: 1;
    }
}

@media (max-width: 1024px) {
    .dashboard-container {
        flex-direction: column;
    }
    .sidebar {
        width: 100%;
        height: auto;
        padding: 20px 24px;
        border-right: none;
        border-bottom: 1px solid var(--border-subtle);
    }
    .main-content {
        padding: 24px;
        height: auto;
        overflow-y: visible;
    }
    .logo h2 {
        margin-bottom: 16px;
    }
    .menu {
        flex-direction: row;
        flex-wrap: wrap;
    }
    .ai-copilot-widget {
        display: none;
    }
    .connection-grid {
        grid-template-columns: 1fr;
    }
}
