/* =====================================================
   OBSIDIAN ANALYTICS — Design System v1.0
   Direction artistique : Dark Premium SaaS
   ===================================================== */

@import url('https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@400;500;600;700;800&family=Inter:wght@400;500;600&display=swap');

/* =====================================================
   VARIABLES
   ===================================================== */
:root {
    /* Background layers */
    --bg-base:        #060D1F;
    --bg-elevated:    #0A1628;
    --bg-card:        rgba(14, 24, 52, 0.75);
    --bg-card-hover:  rgba(20, 34, 68, 0.85);
    --bg-input:       rgba(6, 13, 31, 0.8);

    /* Primary — Indigo/Violet */
    --primary:        #6366F1;
    --primary-dark:   #4F46E5;
    --primary-light:  #818CF8;
    --primary-glow:   rgba(99, 102, 241, 0.35);
    --gradient-1:     linear-gradient(135deg, #6366F1 0%, #8B5CF6 100%);

    /* Accent palette */
    --accent-cyan:    #22D3EE;
    --accent-emerald: #34D399;
    --accent-rose:    #FB7185;
    --accent-amber:   #FBBF24;
    --accent-violet:  #A78BFA;

    /* Semantic gradients */
    --gradient-cyan:    linear-gradient(135deg, #0891B2 0%, #22D3EE 100%);
    --gradient-emerald: linear-gradient(135deg, #059669 0%, #34D399 100%);
    --gradient-rose:    linear-gradient(135deg, #E11D48 0%, #FB7185 100%);
    --gradient-amber:   linear-gradient(135deg, #D97706 0%, #FBBF24 100%);
    --gradient-violet:  linear-gradient(135deg, #7C3AED 0%, #A78BFA 100%);
    --gradient-2:       var(--gradient-rose);
    --gradient-3:       var(--gradient-cyan);
    --gradient-4:       var(--gradient-emerald);
    --gradient-5:       var(--gradient-amber);

    /* Text */
    --text-primary:   #E2E8F0;
    --text-secondary: #8892B0;
    --text-muted:     #3D4A6B;

    /* Borders */
    --border:         rgba(99, 102, 241, 0.15);
    --border-bright:  rgba(99, 102, 241, 0.35);

    /* Shadows */
    --shadow:         0 4px 20px rgba(0, 0, 0, 0.5);
    --shadow-md:      0 8px 32px rgba(0, 0, 0, 0.6);
    --shadow-lg:      0 12px 48px rgba(0, 0, 0, 0.65);
    --shadow-xl:      0 20px 60px rgba(0, 0, 0, 0.7);
    --glow-primary:   0 0 40px rgba(99, 102, 241, 0.25);
    --glow-cyan:      0 0 30px rgba(34, 211, 238, 0.2);

    /* UI */
    --radius:    16px;
    --radius-sm: 10px;
    --radius-xs: 6px;

    /* Legacy compat for app.js-generated HTML */
    --surface:    var(--bg-card);
    --background: var(--bg-elevated);
    --success:    #34D399;
    --danger:     #FB7185;
    --warning:    #FBBF24;
    --secondary:  #8892B0;
}

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

/* =====================================================
   BODY & AURORA BACKGROUND
   ===================================================== */
body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--bg-base);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    overflow-x: hidden;
    position: relative;
}

/* Aurora layers */
body::before {
    content: '';
    position: fixed;
    inset: 0;
    z-index: 0;
    pointer-events: none;
    background:
        radial-gradient(ellipse 80% 60% at 20% 10%, rgba(99, 102, 241, 0.18) 0%, transparent 60%),
        radial-gradient(ellipse 60% 50% at 80% 80%, rgba(139, 92, 246, 0.12) 0%, transparent 55%),
        radial-gradient(ellipse 50% 40% at 50% 50%, rgba(34, 211, 238, 0.06) 0%, transparent 50%);
    animation: aurora 20s ease-in-out infinite alternate;
}

body::after {
    content: '';
    position: fixed;
    inset: 0;
    z-index: 0;
    pointer-events: none;
    background:
        radial-gradient(ellipse 70% 55% at 80% 20%, rgba(167, 139, 250, 0.1) 0%, transparent 55%),
        radial-gradient(ellipse 55% 45% at 10% 80%, rgba(52, 211, 153, 0.08) 0%, transparent 50%);
    animation: aurora 28s ease-in-out infinite alternate-reverse;
}

@keyframes aurora {
    0%   { transform: translate(0, 0) scale(1); }
    33%  { transform: translate(3%, 5%) scale(1.04); }
    66%  { transform: translate(-4%, -3%) scale(0.97); }
    100% { transform: translate(2%, -4%) scale(1.02); }
}

/* Grid dot pattern overlay */
body > .container {
    position: relative;
    z-index: 1;
}

/* =====================================================
   THEME VARIANTS (keep classes, remap gradients)
   ===================================================== */
body.theme-blue { --gradient-1: linear-gradient(135deg, #6366F1 0%, #8B5CF6 100%); }
body.theme-red  { --gradient-1: linear-gradient(135deg, #E11D48 0%, #FB7185 100%); }
body.theme-green{ --gradient-1: linear-gradient(135deg, #059669 0%, #34D399 100%); }

body.theme-blue::before  { background: radial-gradient(ellipse 80% 60% at 20% 10%, rgba(99, 102, 241, 0.18) 0%, transparent 60%), radial-gradient(ellipse 60% 50% at 80% 80%, rgba(139, 92, 246, 0.12) 0%, transparent 55%); }
body.theme-red::before   { background: radial-gradient(ellipse 80% 60% at 20% 10%, rgba(225, 29, 72, 0.18) 0%, transparent 60%), radial-gradient(ellipse 60% 50% at 80% 80%, rgba(251, 113, 133, 0.12) 0%, transparent 55%); }
body.theme-green::before { background: radial-gradient(ellipse 80% 60% at 20% 10%, rgba(5, 150, 105, 0.18) 0%, transparent 60%), radial-gradient(ellipse 60% 50% at 80% 80%, rgba(52, 211, 153, 0.12) 0%, transparent 55%); }

/* =====================================================
   CONTAINER
   ===================================================== */
.container {
    max-width: 1440px;
    margin: 0 auto;
    padding: 28px 28px 48px;
    position: relative;
    z-index: 1;
}

/* =====================================================
   GLASS CARD MIXIN (reusable base)
   ===================================================== */
.glass-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    backdrop-filter: blur(24px) saturate(1.4);
    -webkit-backdrop-filter: blur(24px) saturate(1.4);
    box-shadow: var(--shadow-lg);
    position: relative;
    overflow: hidden;
}

/* =====================================================
   HEADER
   ===================================================== */
.header {
    background: var(--bg-card);
    backdrop-filter: blur(24px) saturate(1.4);
    -webkit-backdrop-filter: blur(24px) saturate(1.4);
    border: 1px solid var(--border);
    padding: 24px 36px;
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg), var(--glow-primary);
    margin-bottom: 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 20px;
    position: relative;
    overflow: hidden;
}

/* Gradient top border */
.header::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 2px;
    background: var(--gradient-1);
    opacity: 0.9;
}

/* Subtle grid dot in header bg */
.header::after {
    content: '';
    position: absolute;
    inset: 0;
    background-image: radial-gradient(rgba(99,102,241,0.08) 1px, transparent 1px);
    background-size: 28px 28px;
    pointer-events: none;
    opacity: 0.6;
}

.header-logo {
    display: flex;
    align-items: center;
    gap: 14px;
    position: relative;
    z-index: 1;
}

.header-icon {
    width: 44px;
    height: 44px;
    object-fit: contain;
    filter: drop-shadow(0 0 12px rgba(99, 102, 241, 0.6));
}

.header-logo-text {
    display: flex;
    flex-direction: column;
}

.header h1 {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 22px;
    font-weight: 800;
    background: var(--gradient-1);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    letter-spacing: -0.5px;
    line-height: 1.2;
}

.header-subtitle {
    font-size: 11px;
    font-weight: 500;
    color: var(--text-secondary);
    letter-spacing: 0.8px;
    text-transform: uppercase;
    margin-top: 2px;
}

.header-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    align-items: center;
    position: relative;
    z-index: 1;
}

/* =====================================================
   THEME SELECTOR
   ===================================================== */
.theme-selector {
    display: flex;
    gap: 6px;
    padding: 5px;
    background: rgba(6, 13, 31, 0.6);
    border: 1px solid var(--border);
    border-radius: 12px;
}

.theme-btn {
    width: 32px;
    height: 32px;
    border: 2px solid transparent;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
}

.theme-btn::before {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: 6px;
    opacity: 1;
}

.theme-btn:hover {
    transform: scale(1.12);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
}

.theme-btn.active {
    border-color: rgba(255,255,255,0.5);
    box-shadow: 0 0 16px rgba(99, 102, 241, 0.5);
    transform: scale(1.05);
}

.theme-blue::before  { background: linear-gradient(135deg, #6366F1 0%, #8B5CF6 100%); }
.theme-red::before   { background: linear-gradient(135deg, #E11D48 0%, #FB7185 100%); }
.theme-green::before { background: linear-gradient(135deg, #059669 0%, #34D399 100%); }

/* =====================================================
   BUTTONS
   ===================================================== */
.btn {
    padding: 10px 20px;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 600;
    font-family: 'Inter', sans-serif;
    cursor: pointer;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    display: inline-flex;
    align-items: center;
    gap: 8px;
    position: relative;
    overflow: hidden;
    white-space: nowrap;
    letter-spacing: 0.2px;
}

.btn::after {
    content: '';
    position: absolute;
    inset: 0;
    background: rgba(255,255,255,0);
    transition: background 0.2s;
}

.btn:hover::after {
    background: rgba(255,255,255,0.07);
}

.btn-icon {
    width: 18px;
    height: 18px;
    object-fit: contain;
    filter: brightness(0) invert(1);
    flex-shrink: 0;
}

.btn-primary {
    background: var(--gradient-1);
    color: white;
    box-shadow: 0 4px 16px var(--primary-glow);
    border: 1px solid rgba(255,255,255,0.1);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px var(--primary-glow);
}

.btn-secondary {
    background: rgba(30, 40, 72, 0.9);
    color: var(--text-secondary);
    border: 1px solid var(--border);
}

.btn-secondary:hover {
    transform: translateY(-2px);
    color: var(--text-primary);
    border-color: var(--border-bright);
    box-shadow: var(--shadow-md);
}

.btn-danger {
    background: linear-gradient(135deg, #BE123C 0%, #FB7185 100%);
    color: white;
    box-shadow: 0 4px 16px rgba(251, 113, 133, 0.3);
    border: 1px solid rgba(255,255,255,0.08);
}

.btn-danger:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(251, 113, 133, 0.4);
}

.btn-small {
    padding: 6px 12px;
    font-size: 12px;
}

/* =====================================================
   NAVIGATION TABS
   ===================================================== */
.nav-tabs {
    display: flex;
    gap: 6px;
    margin-bottom: 24px;
    background: var(--bg-card);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    border: 1px solid var(--border);
    padding: 8px;
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    overflow-x: auto;
    scrollbar-width: none;
}

.nav-tabs::-webkit-scrollbar { display: none; }

.tab-btn {
    padding: 12px 24px;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    font-size: 14px;
    font-weight: 600;
    font-family: 'Inter', sans-serif;
    cursor: pointer;
    border-radius: var(--radius-sm);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    white-space: nowrap;
    display: flex;
    align-items: center;
    gap: 8px;
    position: relative;
    letter-spacing: 0.1px;
}

.tab-icon {
    width: 22px;
    height: 22px;
    object-fit: contain;
    transition: all 0.3s;
    opacity: 0.6;
    filter: brightness(0) invert(0.6);
}

.tab-btn:hover {
    background: rgba(99, 102, 241, 0.1);
    color: var(--text-primary);
}

.tab-btn:hover .tab-icon {
    opacity: 0.9;
    transform: scale(1.05);
    filter: brightness(0) invert(0.9);
}

.tab-btn.active {
    background: var(--gradient-1);
    color: white;
    box-shadow: 0 4px 20px var(--primary-glow);
}

.tab-btn.active .tab-icon {
    filter: brightness(0) invert(1);
    opacity: 1;
}

/* =====================================================
   TAB CONTENT
   ===================================================== */
.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
    animation: tabFadeIn 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

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

/* =====================================================
   STATS GRID
   ===================================================== */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
    margin-bottom: 20px;
}

@media (max-width: 1200px) { .stats-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 768px)  { .stats-grid { grid-template-columns: 1fr; } }

.stat-card {
    background: var(--bg-card);
    backdrop-filter: blur(24px) saturate(1.4);
    -webkit-backdrop-filter: blur(24px) saturate(1.4);
    border: 1px solid var(--border);
    padding: 24px;
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    display: flex;
    gap: 18px;
    align-items: center;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
    cursor: default;
}

/* Animated gradient accent line */
.stat-card::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 2px;
    transition: height 0.3s;
}

.stat-card:nth-child(1)::before { background: var(--gradient-1); }
.stat-card:nth-child(2)::before { background: var(--gradient-rose); }
.stat-card:nth-child(3)::before { background: var(--gradient-cyan); }
.stat-card:nth-child(4)::before { background: var(--gradient-emerald); }
.stat-card:nth-child(5)::before { background: var(--gradient-amber); }
.stat-card:nth-child(6)::before { background: var(--gradient-violet); }

/* Subtle glow blob in bg */
.stat-card::after {
    content: '';
    position: absolute;
    bottom: -30px;
    right: -20px;
    width: 90px;
    height: 90px;
    border-radius: 50%;
    opacity: 0.06;
    transition: opacity 0.3s, transform 0.3s;
    pointer-events: none;
}

.stat-card:nth-child(1)::after { background: #6366F1; }
.stat-card:nth-child(2)::after { background: #FB7185; }
.stat-card:nth-child(3)::after { background: #22D3EE; }
.stat-card:nth-child(4)::after { background: #34D399; }
.stat-card:nth-child(5)::after { background: #FBBF24; }
.stat-card:nth-child(6)::after { background: #A78BFA; }

.stat-card:hover {
    transform: translateY(-6px);
    border-color: var(--border-bright);
    box-shadow: var(--shadow-xl);
    background: var(--bg-card-hover);
}

.stat-card:hover::before { height: 3px; }
.stat-card:hover::after  { opacity: 0.14; transform: scale(1.3); }

/* Icon container */
.stat-icon {
    width: 64px;
    height: 64px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    position: relative;
    transition: all 0.3s;
}

.stat-card:nth-child(1) .stat-icon { background: rgba(99, 102, 241, 0.12); border: 1px solid rgba(99, 102, 241, 0.2); }
.stat-card:nth-child(2) .stat-icon { background: rgba(251, 113, 133, 0.12); border: 1px solid rgba(251, 113, 133, 0.2); }
.stat-card:nth-child(3) .stat-icon { background: rgba(34, 211, 238, 0.12);  border: 1px solid rgba(34, 211, 238, 0.2); }
.stat-card:nth-child(4) .stat-icon { background: rgba(52, 211, 153, 0.12);  border: 1px solid rgba(52, 211, 153, 0.2); }
.stat-card:nth-child(5) .stat-icon { background: rgba(251, 191, 36, 0.12);  border: 1px solid rgba(251, 191, 36, 0.2); }
.stat-card:nth-child(6) .stat-icon { background: rgba(167, 139, 250, 0.12); border: 1px solid rgba(167, 139, 250, 0.2); }

.stat-card:hover .stat-icon { transform: scale(1.08) rotate(4deg); }

.stat-icon img {
    width: 40px;
    height: 40px;
    object-fit: contain;
    filter: drop-shadow(0 2px 6px rgba(0,0,0,0.3));
}

.stat-info { flex: 1; min-width: 0; }

.stat-info h3 {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.8px;
    margin-bottom: 8px;
}

.stat-value {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 32px;
    font-weight: 800;
    line-height: 1;
    margin-bottom: 6px;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.stat-card:nth-child(1) .stat-value { background: var(--gradient-1); -webkit-background-clip: text; background-clip: text; }
.stat-card:nth-child(2) .stat-value { background: var(--gradient-rose); -webkit-background-clip: text; background-clip: text; }
.stat-card:nth-child(3) .stat-value { background: var(--gradient-cyan); -webkit-background-clip: text; background-clip: text; }
.stat-card:nth-child(4) .stat-value { background: var(--gradient-emerald); -webkit-background-clip: text; background-clip: text; }
.stat-card:nth-child(5) .stat-value { background: var(--gradient-amber); -webkit-background-clip: text; background-clip: text; }
.stat-card:nth-child(6) .stat-value { background: var(--gradient-violet); -webkit-background-clip: text; background-clip: text; }

.stat-label {
    font-size: 12px;
    color: var(--text-secondary);
    font-weight: 500;
}

/* =====================================================
   CHARTS GRID
   ===================================================== */
.charts-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
    gap: 16px;
    margin-bottom: 20px;
}

@media (max-width: 768px) { .charts-grid { grid-template-columns: 1fr; } }

.chart-card {
    background: var(--bg-card);
    backdrop-filter: blur(24px) saturate(1.4);
    -webkit-backdrop-filter: blur(24px) saturate(1.4);
    border: 1px solid var(--border);
    padding: 28px;
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    transition: all 0.3s;
    position: relative;
    overflow: hidden;
}

.chart-card::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 2px;
}

.charts-grid:nth-of-type(1) .chart-card:nth-of-type(1)::before { background: var(--gradient-1); }
.charts-grid:nth-of-type(1) .chart-card:nth-of-type(2)::before { background: var(--gradient-rose); }
.charts-grid:nth-of-type(2) .chart-card:nth-of-type(1)::before { background: var(--gradient-cyan); }
.charts-grid:nth-of-type(2) .chart-card:nth-of-type(2)::before { background: var(--gradient-emerald); }
.charts-grid:nth-of-type(3) .chart-card::before                 { background: var(--gradient-amber); }

.chart-card:hover {
    transform: translateY(-4px);
    border-color: var(--border-bright);
    box-shadow: var(--shadow-xl);
}

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

.chart-card h3 {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 17px;
    font-weight: 700;
    margin-bottom: 24px;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 10px;
}

.section-icon {
    width: 28px;
    height: 28px;
    object-fit: contain;
    filter: drop-shadow(0 0 8px rgba(99, 102, 241, 0.4));
}

/* =====================================================
   RECENT CAMPAIGNS SECTION
   ===================================================== */
.recent-campaigns {
    background: var(--bg-card);
    backdrop-filter: blur(24px) saturate(1.4);
    -webkit-backdrop-filter: blur(24px) saturate(1.4);
    border: 1px solid var(--border);
    padding: 28px;
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    margin-bottom: 20px;
    position: relative;
    overflow: hidden;
    transition: all 0.3s;
}

.recent-campaigns::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 2px;
    background: var(--gradient-amber);
}

.recent-campaigns:last-of-type::before {
    background: var(--gradient-rose);
}

.recent-campaigns:hover {
    border-color: var(--border-bright);
    box-shadow: var(--shadow-xl);
}

.recent-campaigns h3 {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 17px;
    font-weight: 700;
    margin-bottom: 20px;
    padding-bottom: 16px;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 10px;
    border-bottom: 1px solid var(--border);
    position: relative;
}

/* =====================================================
   SECTION HEADER
   ===================================================== */
.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    background: var(--bg-card);
    backdrop-filter: blur(24px) saturate(1.4);
    -webkit-backdrop-filter: blur(24px) saturate(1.4);
    border: 1px solid var(--border);
    padding: 20px 28px;
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    position: relative;
    overflow: hidden;
}

.section-header::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 2px;
    background: var(--gradient-1);
}

.section-header h2 {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 22px;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--gradient-1);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* =====================================================
   CAMPAIGNS LIST
   ===================================================== */
.campaigns-list,
.tests-list {
    display: grid;
    gap: 14px;
}

.campaign-item,
.test-item {
    background: var(--bg-card);
    backdrop-filter: blur(24px) saturate(1.4);
    -webkit-backdrop-filter: blur(24px) saturate(1.4);
    border: 1px solid var(--border);
    padding: 22px 24px;
    border-radius: var(--radius);
    box-shadow: var(--shadow-md);
    position: relative;
    overflow: hidden;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    animation: fadeIn 0.3s ease-out;
}

.campaign-item::before, .test-item::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 2px;
}

.campaign-item:nth-child(6n+1)::before, .test-item:nth-child(6n+1)::before { background: var(--gradient-1); }
.campaign-item:nth-child(6n+2)::before, .test-item:nth-child(6n+2)::before { background: var(--gradient-rose); }
.campaign-item:nth-child(6n+3)::before, .test-item:nth-child(6n+3)::before { background: var(--gradient-cyan); }
.campaign-item:nth-child(6n+4)::before, .test-item:nth-child(6n+4)::before { background: var(--gradient-emerald); }
.campaign-item:nth-child(6n+5)::before, .test-item:nth-child(6n+5)::before { background: var(--gradient-amber); }
.campaign-item:nth-child(6n+6)::before, .test-item:nth-child(6n+6)::before { background: var(--gradient-violet); }

.campaign-item:hover, .test-item:hover {
    transform: translateY(-4px);
    border-color: var(--border-bright);
    box-shadow: var(--shadow-xl);
    background: var(--bg-card-hover);
}

.campaign-header, .test-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 16px;
}

.campaign-title, .test-title {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 17px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 6px;
}

.campaign-channel {
    display: inline-block;
    padding: 3px 10px;
    background: rgba(99, 102, 241, 0.1);
    border: 1px solid rgba(99, 102, 241, 0.2);
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
    color: var(--primary-light);
    letter-spacing: 0.3px;
    text-transform: uppercase;
}

.campaign-actions, .test-actions {
    display: flex;
    gap: 8px;
    flex-shrink: 0;
}

.campaign-metrics, .test-metrics {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
    gap: 12px;
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid var(--border);
}

.metric {
    text-align: center;
    padding: 10px;
    background: rgba(255,255,255,0.02);
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
}

.metric-value {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 18px;
    font-weight: 700;
    color: var(--text-primary);
}

.metric-label {
    font-size: 11px;
    color: var(--text-secondary);
    margin-top: 4px;
    font-weight: 500;
}

/* =====================================================
   STATUS BADGES
   ===================================================== */
.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.3px;
}

.status-badge::before {
    content: '';
    width: 6px;
    height: 6px;
    border-radius: 50%;
    flex-shrink: 0;
}

.status-active {
    background: rgba(52, 211, 153, 0.12);
    color: #34D399;
    border: 1px solid rgba(52, 211, 153, 0.25);
}

.status-active::before {
    background: #34D399;
    box-shadow: 0 0 6px #34D399;
    animation: pulse 2s infinite;
}

.status-paused {
    background: rgba(251, 191, 36, 0.1);
    color: #FBBF24;
    border: 1px solid rgba(251, 191, 36, 0.2);
}

.status-paused::before { background: #FBBF24; }

.status-completed {
    background: rgba(99, 102, 241, 0.1);
    color: var(--primary-light);
    border: 1px solid rgba(99, 102, 241, 0.2);
}

.status-completed::before { background: var(--primary-light); }

.status-running {
    background: rgba(34, 211, 238, 0.1);
    color: var(--accent-cyan);
    border: 1px solid rgba(34, 211, 238, 0.2);
}

.status-running::before {
    background: var(--accent-cyan);
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { box-shadow: 0 0 4px currentColor; opacity: 1; }
    50%       { box-shadow: 0 0 10px currentColor; opacity: 0.7; }
}

/* =====================================================
   CALCULATOR GRID
   ===================================================== */
.calculator-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 20px;
}

@media (max-width: 768px) { .calculator-grid { grid-template-columns: 1fr; } }

.calculator-card {
    background: var(--bg-card);
    backdrop-filter: blur(24px) saturate(1.4);
    -webkit-backdrop-filter: blur(24px) saturate(1.4);
    border: 1px solid var(--border);
    padding: 26px;
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
}

.calculator-card::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 2px;
}

.calculator-card:nth-child(1)::before { background: var(--gradient-1); }
.calculator-card:nth-child(2)::before { background: var(--gradient-rose); }
.calculator-card:nth-child(3)::before { background: var(--gradient-cyan); }
.calculator-card:nth-child(4)::before { background: var(--gradient-emerald); }
.calculator-card:nth-child(5)::before { background: var(--gradient-amber); }
.calculator-card:nth-child(6)::before { background: var(--gradient-violet); }

.calculator-card:hover {
    transform: translateY(-5px);
    border-color: var(--border-bright);
    box-shadow: var(--shadow-xl);
    background: var(--bg-card-hover);
}

.calculator-card h3 {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 17px;
    font-weight: 700;
    margin-bottom: 22px;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 10px;
}

/* Card-specific primary button colors */
.calculator-card:nth-child(1) .btn-primary { background: var(--gradient-1); }
.calculator-card:nth-child(2) .btn-primary { background: var(--gradient-rose); }
.calculator-card:nth-child(3) .btn-primary { background: var(--gradient-cyan); }
.calculator-card:nth-child(4) .btn-primary { background: var(--gradient-emerald); }
.calculator-card:nth-child(5) .btn-primary { background: var(--gradient-amber); }
.calculator-card:nth-child(6) .btn-primary { background: var(--gradient-violet); }

/* =====================================================
   FORMS
   ===================================================== */
.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 7px;
    letter-spacing: 0.2px;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 11px 14px;
    background: rgba(6, 13, 31, 0.7);
    border: 1px solid var(--border);
    border-radius: var(--radius-xs);
    font-size: 14px;
    font-family: 'Inter', sans-serif;
    color: var(--text-primary);
    transition: all 0.2s;
    outline: none;
    -webkit-appearance: none;
}

.form-group input::placeholder,
.form-group textarea::placeholder {
    color: var(--text-muted);
}

.form-group select option {
    background: var(--bg-elevated);
    color: var(--text-primary);
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    border-color: var(--primary);
    background: rgba(99, 102, 241, 0.06);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.12);
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
}

/* =====================================================
   RESULT BOX
   ===================================================== */
.result {
    margin-top: 16px;
    padding: 14px 16px;
    border-radius: var(--radius-sm);
    font-weight: 600;
    font-size: 14px;
    display: none;
    border: 1px solid;
}

.result.success {
    background: rgba(52, 211, 153, 0.08);
    color: #34D399;
    border-color: rgba(52, 211, 153, 0.2);
    display: block;
}

.result.warning {
    background: rgba(251, 191, 36, 0.08);
    color: #FBBF24;
    border-color: rgba(251, 191, 36, 0.2);
    display: block;
}

.result.error {
    background: rgba(251, 113, 133, 0.08);
    color: #FB7185;
    border-color: rgba(251, 113, 133, 0.2);
    display: block;
}

/* =====================================================
   MODAL
   ===================================================== */
.modal {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(4, 8, 18, 0.75);
    backdrop-filter: blur(8px);
    z-index: 1000;
    overflow-y: auto;
    padding: 20px;
}

.modal.active {
    display: flex;
    align-items: center;
    justify-content: center;
    animation: modalIn 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes modalIn {
    from { opacity: 0; }
    to   { opacity: 1; }
}

.modal-content {
    background: var(--bg-elevated);
    border: 1px solid var(--border-bright);
    border-radius: var(--radius);
    max-width: 620px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 24px 80px rgba(0, 0, 0, 0.7), var(--glow-primary);
    animation: modalSlide 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
}

.modal-content::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 2px;
    background: var(--gradient-1);
    border-radius: var(--radius) var(--radius) 0 0;
}

@keyframes modalSlide {
    from { opacity: 0; transform: translateY(-20px) scale(0.97); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

.modal-header {
    padding: 22px 28px 20px;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h3 {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 20px;
    font-weight: 700;
    color: var(--text-primary);
}

.close {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    font-weight: 300;
    color: var(--text-secondary);
    cursor: pointer;
    border-radius: var(--radius-xs);
    transition: all 0.2s;
    background: transparent;
    border: none;
    line-height: 1;
}

.close:hover {
    color: var(--text-primary);
    background: rgba(255,255,255,0.05);
}

.modal-body {
    padding: 24px 28px;
}

.modal-body h4 {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 14px;
    font-weight: 700;
    margin: 22px 0 12px;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.6px;
}

.modal-footer {
    padding: 16px 28px 22px;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

/* =====================================================
   PROGRESS BAR
   ===================================================== */
.progress-bar {
    width: 100%;
    height: 6px;
    background: rgba(255,255,255,0.06);
    border-radius: 3px;
    overflow: hidden;
    margin-top: 10px;
}

.progress-fill {
    height: 100%;
    background: var(--gradient-1);
    border-radius: 3px;
    transition: width 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 0 8px var(--primary-glow);
}

/* =====================================================
   EMPTY STATE
   ===================================================== */
.empty-state {
    text-align: center;
    padding: 64px 20px;
    color: var(--text-secondary);
}

.empty-state-icon {
    font-size: 56px;
    margin-bottom: 16px;
    opacity: 0.4;
    display: block;
}

.empty-state h3 {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 18px;
    font-weight: 700;
    margin-bottom: 8px;
    color: var(--text-primary);
}

.empty-state p {
    font-size: 14px;
    color: var(--text-secondary);
}

/* =====================================================
   TEST VARIANTS
   ===================================================== */
.variant-comparison {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
    margin: 16px 0;
}

.variant-card {
    padding: 16px;
    background: rgba(255,255,255,0.03);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
}

.variant-card.winner {
    border-color: rgba(52, 211, 153, 0.4);
    background: rgba(52, 211, 153, 0.06);
    box-shadow: 0 0 20px rgba(52, 211, 153, 0.1);
}

.variant-name {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 15px;
    font-weight: 700;
    margin-bottom: 10px;
    color: var(--text-primary);
}

.conversion-rate {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 26px;
    font-weight: 800;
    background: var(--gradient-1);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* =====================================================
   HISTORY / CALCULATOR LOGS
   ===================================================== */
.history-section {
    margin-top: 36px;
}

.history-item {
    background: var(--bg-card);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    border: 1px solid var(--border);
    padding: 18px 22px;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    margin-bottom: 12px;
    animation: fadeIn 0.3s ease-out;
    transition: all 0.2s;
}

.history-item:hover {
    border-color: var(--border-bright);
}

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

.history-type {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 15px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.history-date {
    font-size: 12px;
    color: var(--text-secondary);
}

.history-details {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.history-section {
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.6;
}

.history-section strong {
    color: var(--text-primary);
    margin-right: 6px;
    font-weight: 600;
}

.history-section .highlight {
    color: var(--primary-light);
    font-weight: 600;
}

.history-evaluation {
    margin-top: 10px;
    padding: 8px 14px;
    background: rgba(99, 102, 241, 0.08);
    border: 1px solid rgba(99, 102, 241, 0.15);
    border-radius: var(--radius-xs);
    font-size: 13px;
    font-weight: 600;
    color: var(--primary-light);
}

/* =====================================================
   ANIMATIONS
   ===================================================== */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* =====================================================
   SCROLLBAR
   ===================================================== */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(99, 102, 241, 0.3); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: rgba(99, 102, 241, 0.5); }

/* =====================================================
   RESPONSIVE
   ===================================================== */
@media (max-width: 768px) {
    .container { padding: 16px 16px 32px; }

    .header { padding: 18px 20px; flex-direction: column; align-items: flex-start; }
    .header-actions { width: 100%; flex-wrap: wrap; }
    .header-actions .btn { flex: 1; min-width: 130px; justify-content: center; }

    .charts-grid { grid-template-columns: 1fr; }
    .chart-card.full-width { grid-column: 1; }
    .calculator-grid { grid-template-columns: 1fr; }
    .form-row { grid-template-columns: 1fr; }
    .campaign-metrics, .test-metrics { grid-template-columns: repeat(2, 1fr); }
    .variant-comparison { grid-template-columns: 1fr; }

    .section-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }

    .section-header > div {
        width: 100%;
        display: flex;
        flex-direction: column;
        gap: 8px;
    }

    .section-header .btn { width: 100%; justify-content: center; }

    .tab-btn { padding: 10px 16px; font-size: 13px; }
}

/* =====================================================
   TOP CAMPAIGN / ATTENTION LIST (generated by JS)
   ===================================================== */
#topCampaignsList .campaign-item,
#attentionCampaignsList .campaign-item {
    margin-bottom: 0;
}

/* =====================================================
   MISC — ensure select arrow visible on dark bg
   ===================================================== */
select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%238892B0' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 36px !important;
    cursor: pointer;
}
