:root {
    /* Enterprise Grade Color Palette - Refined & Professional */
    --primary: #0f172a;
    --primary-light: #1e293b;
    --accent: #3b82f6;
    --accent-hover: #2563eb;
    --accent-soft: rgba(59, 130, 246, 0.1);
    
    --success: #10b981;
    --success-soft: rgba(16, 185, 129, 0.1);
    --warning: #f59e0b;
    --warning-soft: rgba(245, 158, 11, 0.1);
    --danger: #ef4444;
    --danger-soft: rgba(239, 68, 68, 0.1);
    
    --bg-main: #f8fafc;
    --bg-card: #ffffff;
    --bg-sidebar: #ffffff;
    
    --text-main: #0f172a;
    --text-muted: #64748b;
    --text-on-accent: #ffffff;
    
    --border: #e2e8f0;
    --border-light: #f1f5f9;
    
    --radius-sm: 6px;
    --radius-md: 12px;
    --radius-lg: 20px;
    --radius-full: 9999px;
    
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --shadow-premium: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);

    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    
    /* Original Dashboard Variables - Legacy Support */
    --primary-color: var(--accent);
    --secondary-color: var(--accent-soft);
    --success-color: var(--success);
    --danger-color: var(--danger);
    --bg-color: var(--bg-main);
    --card-bg: var(--bg-card);
    --border-color: var(--border);
    --radius: var(--radius-md);
    --sidebar-bg: var(--bg-sidebar);
    --sidebar-text: var(--text-muted);
}

/* Global Smoothness */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background-color: var(--bg-main);
    color: var(--text-main);
    height: 100vh;
    overflow: hidden;
    line-height: 1.5;
}

/* Modern Scrollbar */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}
::-webkit-scrollbar-track {
    background: transparent;
}
::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 10px;
}
::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

.hidden {
    display: none !important;
}

#app-root {
    height: 100%;
}

/* Premium Login Experience */
#auth-view {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
    position: relative;
    overflow: hidden;
}

/* Animated Background Graphics for Login */
#auth-view::before {
    content: '';
    position: absolute;
    width: 1000px;
    height: 1000px;
    background: radial-gradient(circle, rgba(59, 130, 246, 0.1) 0%, transparent 70%);
    top: -200px;
    right: -200px;
    z-index: 0;
}

#auth-view::after {
    content: '';
    position: absolute;
    width: 800px;
    height: 800px;
    background: radial-gradient(circle, rgba(16, 185, 129, 0.05) 0%, transparent 70%);
    bottom: -100px;
    left: -100px;
    z-index: 0;
}

.login-card {
    background: rgba(255, 255, 255, 0.03);
    backdrop-filter: blur(20px);
    padding: 3.5rem;
    border-radius: var(--radius-lg);
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: var(--shadow-premium);
    text-align: center;
    max-width: 440px;
    width: 90%;
    z-index: 10;
    animation: fadeInScale 0.6s ease-out;
}

@keyframes fadeInScale {
    from { opacity: 0; transform: scale(0.95) translateY(10px); }
    to { opacity: 1; transform: scale(1) translateY(0); }
}

.login-card h1 {
    font-size: 2rem;
    font-weight: 800;
    color: white;
    margin-bottom: 0.75rem;
    letter-spacing: -0.025em;
}

.login-logo-container {
    display: flex;
    justify-content: center;
    margin-bottom: 2rem;
}

.login-logo {
    width: 64px;
    height: 64px;
    background: var(--accent);
    border-radius: 16px;
    box-shadow: 0 0 30px rgba(59, 130, 246, 0.5);
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}

.login-logo::after {
    content: 'S';
    color: white;
    font-weight: 900;
    font-size: 2rem;
}

.login-footer {
    margin-top: 2rem;
    font-size: 0.75rem;
    color: rgba(255, 255, 255, 0.4);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.1em;
}

.login-card p {
    color: rgba(255, 255, 255, 0.6);
    margin-bottom: 2.5rem;
    font-size: 1rem;
}

.primary-btn {
    background: var(--accent);
    color: white;
    border: none;
    padding: 1rem 1.5rem;
    border-radius: var(--radius-md);
    font-weight: 600;
    font-size: 1rem;
    cursor: pointer;
    width: 100%;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
}

.primary-btn:hover {
    background: var(--accent-hover);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
}

.primary-btn:active {
    transform: translateY(0);
}

/* Sidebar - Enterprise Refinement */
.side-nav {
    width: 260px;
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    z-index: 100;
    transition: width 0.3s ease;
    height: 100vh;
}

.nav-brand-section {
    display: flex;
    flex-direction: column;
    flex: 1;
}

.nav-header {
    padding: 2rem 1.5rem;
    font-weight: 800;
    font-size: 1.25rem;
    color: var(--primary);
    letter-spacing: -0.02em;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.nav-header::before {
    content: '';
    width: 32px;
    height: 32px;
    background: var(--accent);
    border-radius: 8px;
    display: inline-block;
}

.nav-links {
    list-style: none;
    padding: 0 0.75rem;
}

.nav-links li {
    padding: 0.75rem 1rem;
    margin-bottom: 0.25rem;
    color: var(--text-muted);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: var(--transition);
    font-size: 0.95rem;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.nav-links li:hover {
    background: var(--bg-main);
    color: var(--primary);
}

.nav-links li.active {
    background: var(--accent-soft);
    color: var(--accent);
    font-weight: 600;
}

.nav-label {
    padding: 1.5rem 1rem 0.5rem 1rem !important;
    font-size: 0.7rem !important;
    text-transform: uppercase;
    font-weight: 700;
    color: #94a3b8 !important;
    letter-spacing: 0.1em;
    cursor: default !important;
}

.nav-footer {
    padding: 1.5rem;
    border-top: 1px solid var(--border-light);
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

#distributor-selector-container {
    width: 100%;
}

#distributor-select {
    width: 100%;
    padding: 0.6rem 1rem;
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
    background: var(--bg-main);
    font-weight: 600;
    color: var(--text-main);
    cursor: pointer;
    transition: var(--transition);
}

#logout-btn {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-muted);
    padding: 0.75rem 1rem;
    border-radius: var(--radius-md);
    cursor: pointer;
    width: 100%;
    font-weight: 500;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
}

#logout-btn:hover {
    background: var(--danger-soft);
    color: var(--danger);
    border-color: var(--danger-soft);
}

/* Top Bar Refinement */
.top-bar {
    height: 72px;
    background: #ffffff;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 2rem;
}

.top-bar-left {
    display: flex;
    align-items: center;
}

.user-profile {
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

#user-email {
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--text-muted);
}

.small-btn {
    padding: 0.5rem 1rem;
    font-size: 0.85rem;
    font-weight: 600;
    border-radius: var(--radius-md);
    border: 1px solid var(--accent);
    background: var(--accent-soft);
    color: var(--accent);
    cursor: pointer;
    transition: var(--transition);
}

.small-btn:hover {
    background: var(--accent);
    color: white;
}

/* View Content Container */
#view-content {
    padding: 2rem;
    overflow-y: auto;
    background: var(--bg-main);
    height: calc(100vh - 72px);
    flex: 1;
}

/* Dashboard Component Styles */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.kpi-card {
    background: var(--bg-card);
    padding: 1.5rem;
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
    transition: var(--transition);
    position: relative;
    overflow: hidden;
}

.kpi-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-md);
    border-color: var(--accent-soft);
}

.kpi-label {
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.5rem;
}

.kpi-value-row h2 {
    font-size: 1.75rem;
    font-weight: 800;
    color: var(--text-main);
    letter-spacing: -0.02em;
}

/* Chart Cards */
.chart-card {
    background: var(--bg-card);
    padding: 1.5rem;
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
    margin-bottom: 1.5rem;
    animation: slideUp 0.4s ease-out;
}

@keyframes slideUp {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.card-header h3 {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-main);
    text-transform: uppercase;
    letter-spacing: 0.025em;
}

/* Sticky Header & Navigation */
.sticky-header-container {
    background: rgba(255, 255, 255, 0.8);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border);
    margin: -2rem -2rem 2rem -2rem;
    padding: 0 2rem;
    position: sticky;
    top: 0;
    z-index: 50;
}

.month-tabs {
    padding: 1rem 0;
    border-bottom: 1px solid var(--border-light);
    display: flex;
    gap: 0.5rem;
    overflow-x: auto;
}

.month-btn {
    padding: 0.5rem 1rem;
    font-size: 0.75rem;
    font-weight: 700;
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
    background: white;
    color: var(--text-muted);
    transition: var(--transition);
    white-space: nowrap;
}

.month-btn.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

.filter-bar {
    padding: 1.25rem 0;
    display: flex;
    gap: 2rem;
    overflow-x: auto;
}

.filter-group {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.filter-group label {
    font-size: 0.65rem;
    font-weight: 800;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.filter-group select {
    padding: 0.5rem 0.75rem;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: white;
    font-weight: 600;
    font-size: 0.85rem;
    min-width: 140px;
}

/* Enterprise Tabs */
.tabs {
    display: flex;
    gap: 0.5rem;
    padding: 0.5rem 0;
    overflow-x: auto;
    -ms-overflow-style: none;
    scrollbar-width: none;
}

.tabs::-webkit-scrollbar {
    display: none;
}

.tab-btn {
    padding: 0.6rem 1.25rem;
    font-weight: 600;
    font-size: 0.9rem;
    border-radius: var(--radius-md);
    color: var(--text-muted);
    transition: var(--transition);
    border: none;
    background: transparent;
    cursor: pointer;
    white-space: nowrap;
}

.tab-btn:hover {
    background: var(--bg-main);
    color: var(--primary);
}

.tab-btn.active {
    background: var(--primary);
    color: white;
    box-shadow: var(--shadow-md);
}

/* AI Insights Specific Styles */
.ai-card {
    transition: var(--transition);
}

.ai-card:hover {
    box-shadow: var(--shadow-lg);
}

.briefing-card {
    position: relative;
    overflow: hidden;
}

.briefing-card::after {
    content: '';
    position: absolute;
    top: -50%;
    right: -20%;
    width: 300px;
    height: 300px;
    background: radial-gradient(circle, rgba(255, 255, 255, 0.1) 0%, transparent 70%);
    border-radius: 50%;
}

.chat-msg {
    margin-bottom: 1.5rem;
    display: flex;
    gap: 1rem;
    animation: fadeIn 0.3s ease-out;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(5px); }
    to { opacity: 1; transform: translateY(0); }
}

.msg-avatar {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    flex-shrink: 0;
}

.user-msg .msg-avatar { background: var(--bg-main); border: 1px solid var(--border); }
.ai-msg .msg-avatar { background: var(--primary); color: white; }

.msg-bubble {
    padding: 1rem 1.25rem;
    border-radius: var(--radius-md);
    max-width: 85%;
    font-size: 0.95rem;
    line-height: 1.6;
}

.user-msg .msg-bubble { background: white; border: 1px solid var(--border); color: var(--text-main); }
.ai-msg .msg-bubble { background: var(--bg-main); color: var(--text-main); }

.suggest-btn {
    transition: var(--transition);
}

.suggest-btn:hover {
    background: var(--accent-soft) !important;
    color: var(--accent) !important;
}

/* Tables Refinement */
.ds-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
}

.ds-table th {
    background: var(--bg-main);
    padding: 1rem;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    color: var(--text-muted);
    border-bottom: 2px solid var(--border);
    text-align: left;
}

.ds-table td {
    padding: 1rem;
    border-bottom: 1px solid var(--border-light);
    font-size: 0.9rem;
    color: var(--text-main);
}

.ds-table tr:hover td {
    background: var(--bg-main);
}

/* Animations & Micro-interactions */
.primary-btn, .small-btn, .tab-btn, .month-btn, #logout-btn, .nav-links li {
    position: relative;
    overflow: hidden;
}

.primary-btn::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 5px;
    height: 5px;
    background: rgba(255, 255, 255, 0.5);
    opacity: 0;
    border-radius: 100%;
    transform: scale(1, 1) translate(-50%);
    transform-origin: 50% 50%;
}

@keyframes ripple {
    0% { transform: scale(0, 0); opacity: 1; }
    20% { transform: scale(25, 25); opacity: 1; }
    100% { opacity: 0; transform: scale(40, 40); }
}

.primary-btn:focus:not(:active)::after {
    animation: ripple 1s ease-out;
}

/* Status Badge Animation */
.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
    margin-right: 6px;
    position: relative;
}

.status-dot::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    background: inherit;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% { transform: scale(1); opacity: 1; }
    100% { transform: scale(2.5); opacity: 0; }
}
