:root {
    /* Deep Premium Palette (Ultra Dark Blue & Neon Cyan) */
    --bg-color: #050810;
    --sidebar-bg: rgba(5, 8, 16, 0.95);

    /* Glassmorphism v2 */
    --card-bg: rgba(13, 17, 28, 0.6);
    --card-hover-bg: rgba(20, 26, 41, 0.8);
    --glass-border: rgba(255, 255, 255, 0.08);
    --glass-blur: 20px;
    --glass-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);

    /* Accents */
    --accent-primary: #00e5ff;
    /* Neon Cyan */
    --accent-secondary: #7c3aed;
    /* Deep Violet */
    --accent-glow: rgba(0, 229, 255, 0.4);

    /* Typography */
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --font-head: 'Outfit', sans-serif;
    --font-body: 'Inter', sans-serif;

    /* Status Colors */
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;

    /* Layout */
    --sidebar-width: 280px;
    --radius-lg: 24px;
    --radius-md: 16px;
    --transition: cubic-bezier(0.25, 0.1, 0.25, 1);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: var(--font-body);
    background-color: var(--bg-color);
    color: var(--text-primary);
    line-height: 1.6;
    overflow-x: hidden;
    width: 100%;
}

img,
canvas,
video,
svg {
    max-width: 100%;
    height: auto;
}

/* Generalized Table Styles (Consolidated) */
.ads-table-container {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    /* Smooth scroll on iOS */
    margin-top: 1rem;
    border-radius: 8px;
    border: 1px solid var(--glass-border);
    /* Visual boundary */
}

table {
    width: 100%;
    border-collapse: collapse;
    color: #e2e8f0;
    font-size: 0.9rem;
    white-space: nowrap;
    /* Force scroll on small screens */
}

/* Scroll Hint for Tables */
.responsive-table-wrapper {
    overflow-x: auto;
    background:
        linear-gradient(to right, var(--card-bg) 30%, rgba(255, 255, 255, 0)),
        linear-gradient(to right, rgba(255, 255, 255, 0), var(--card-bg) 70%) 0 100%,
        radial-gradient(farthest-side at 0 50%, rgba(0, 229, 255, 0.2), rgba(0, 0, 0, 0)),
        radial-gradient(farthest-side at 100% 50%, rgba(0, 229, 255, 0.2), rgba(0, 0, 0, 0)) 0 100%;
    background-repeat: no-repeat;
    background-size: 40px 100%, 40px 100%, 14px 100%, 14px 100%;
    background-position: 0 0, 100% 0, 0 0, 100% 0;
    background-attachment: local, local, scroll, scroll;
}

th,
td {
    padding: 12px 15px;
    text-align: left;
    border-bottom: 1px solid var(--glass-border);
}

th {
    background: rgba(0, 0, 0, 0.2);
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    font-size: 0.75rem;
    letter-spacing: 0.05em;
}

tr:hover {
    background: rgba(255, 255, 255, 0.02);
}

body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background:
        radial-gradient(circle at 10% 20%, rgba(0, 229, 255, 0.05) 0%, transparent 40%),
        radial-gradient(circle at 90% 80%, rgba(188, 0, 255, 0.05) 0%, transparent 40%);
    pointer-events: none;
    z-index: -1;
}

/* Custom Scrollbar */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-color);
}

::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 10px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--accent-color);
}

h1,
h2,
h3 {
    font-family: 'Outfit', sans-serif;
}

.app-container {
    display: flex;
    min-height: 100vh;
}

/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    background-color: var(--sidebar-bg);
    border-right: 1px solid var(--border-color);
    padding: 2rem 0;
    display: flex;
    flex-direction: column;
    position: fixed;
    height: 100vh;
}

.logo-container {
    padding: 0 1.5rem;
    margin-bottom: 2.5rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.logo-icon {
    width: 32px;
    height: 32px;
    background: linear-gradient(135deg, var(--accent-color), #bc00ff);
    border-radius: 8px;
    box-shadow: 0 0 15px var(--accent-glow);
}

.logo-container h1 {
    font-size: 1.25rem;
    font-weight: 700;
    background: linear-gradient(to right, #fff, #94a3b8);
    background-clip: text;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.sidebar nav ul {
    list-style: none;
}

.sidebar nav li {
    padding: 0.25rem 1rem;
}

.sidebar nav a {
    color: var(--text-secondary);
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.85rem 1rem;
    border-radius: var(--radius-md);
    transition: all 0.3s var(--transition);
    font-weight: 500;
}

.sidebar nav li.active a,
.sidebar nav a:hover {
    background-color: rgba(0, 229, 255, 0.08);
    color: var(--accent-primary);
    box-shadow: inset 0 0 0 1px rgba(0, 229, 255, 0.1);
}

.sidebar nav li.active a::after {
    content: '';
    position: absolute;
    right: 0;
    width: 4px;
    height: 20px;
    background: var(--accent-primary);
    border-radius: 4px 0 0 4px;
    box-shadow: -4px 0 12px var(--accent-glow);
}

.sidebar-footer {
    margin-top: auto;
    padding: 1.5rem;
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.status-online::before {
    content: '';
    display: inline-block;
    width: 8px;
    height: 8px;
    background-color: var(--success);
    border-radius: 50%;
    margin-right: 6px;
    box-shadow: 0 0 8px var(--success);
}

/* Main Content */
.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    padding: 2rem 3rem;
    max-width: 1600px;

}

@keyframes revealFadeIn {
    from {
        opacity: 0;
        transform: translateY(15px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes accentPulse {
    0% {
        box-shadow: 0 0 0 0 rgba(0, 229, 255, 0.4);
    }

    70% {
        box-shadow: 0 0 0 10px rgba(0, 229, 255, 0);
    }

    100% {
        box-shadow: 0 0 0 0 rgba(0, 229, 255, 0);
    }
}

.reveal-1 {
    animation: revealFadeIn 0.5s ease-out;
}

.reveal-2 {
    animation: revealFadeIn 0.5s ease-out 0.1s both;
}

.reveal-3 {
    animation: revealFadeIn 0.5s ease-out 0.2s both;
}

.reveal-4 {
    animation: revealFadeIn 0.5s ease-out 0.3s both;
}




.top-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2.5rem;
    gap: 2rem;
}

.search-container {
    flex: 1;
    max-width: 500px;
    position: relative;
    display: flex;
    align-items: center;
}

.search-input {
    width: 100%;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-md);
    padding: 0.75rem 1rem 0.75rem 2.75rem;
    color: var(--text-primary);
    font-size: 0.9rem;
    transition: all 0.3s var(--transition);
}

.search-input:focus {
    background: rgba(255, 255, 255, 0.06);
    border-color: var(--accent-primary);
    box-shadow: 0 0 20px rgba(0, 229, 255, 0.1);
    outline: none;
}

.search-icon {
    position: absolute;
    left: 1rem;
    color: var(--text-muted);
    pointer-events: none;
}

.shortcut-chip {
    position: absolute;
    right: 0.75rem;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid var(--glass-border);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.7rem;
    color: var(--text-muted);
    pointer-events: none;
}

.header-left h2 {
    font-size: 1.875rem;
    margin-bottom: 0.25rem;
}

.header-left p {
    color: var(--text-secondary);
}

.selectors {
    display: flex;
    gap: 1.5rem;
    align-items: flex-end;
}

.selector-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.selector-group label {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-secondary);
    font-weight: 600;
}

select,
input[type="date"] {
    background-color: var(--sidebar-bg);
    border: 1px solid var(--border-color);
    color: #fff;
    padding: 0.6rem 1rem;
    border-radius: 8px;
    outline: none;
    transition: border-color 0.3s;
}

select:focus,
input[type="date"]:focus {
    border-color: var(--accent-color);
}

.date-range {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.btn-refresh {
    background: linear-gradient(135deg, var(--accent-color), #00a3ff);
    color: #000;
    border: none;
    padding: 0.6rem 1.5rem;
    border-radius: 8px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s;
    height: 42px;
}

.btn-refresh:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px var(--accent-glow);
}

/* Glassmorphism V2 */
.glass {
    background: var(--card-bg);
    backdrop-filter: blur(var(--glass-blur));
    -webkit-backdrop-filter: blur(var(--glass-blur));
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--glass-shadow);
    transition: all 0.4s var(--transition);
    position: relative;
    overflow: hidden;
}

.glass::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.03) 0%, transparent 40%);
    pointer-events: none;
    z-index: 1;
}

.glass:hover {
    transform: translateY(-4px);
    border-color: rgba(255, 255, 255, 0.15);
    background: var(--card-hover-bg);
    box-shadow: 0 20px 40px -5px rgba(0, 0, 0, 0.6), 0 0 15px -3px var(--accent-glow);
}

/* KPI Cards - Original Premium Look */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1.5rem;
    margin-bottom: 3rem;
}

@media (max-width: 1200px) {
    .kpi-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 768px) {
    .kpi-grid {
        grid-template-columns: 1fr;
    }
}

.kpi-card {
    padding: 2rem 1.5rem;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 1rem;
    cursor: pointer;
    background: var(--card-bg);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-lg);
    transition: all 0.3s var(--transition);
}

.kpi-card:hover {
    background: var(--card-hover-bg);
    border-color: var(--accent-primary);
    transform: translateY(-5px);
    box-shadow: 0 10px 30px -5px rgba(0, 229, 255, 0.15);
}

.kpi-card .kpi-header {
    display: flex;
    justify-content: space-between;
    width: 100%;
    align-items: flex-start;
}

.kpi-icon {
    width: 48px;
    height: 48px;
    border-radius: 14px;
    background: linear-gradient(135deg, rgba(0, 229, 255, 0.15), rgba(124, 58, 237, 0.1));
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--accent-primary);
    border: 1px solid rgba(0, 229, 255, 0.2);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    transition: all 0.3s ease;
}

.kpi-card:hover .kpi-icon {
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
    color: #000;
    box-shadow: 0 0 20px var(--accent-glow);
}

.kpi-data {
    margin-top: 0.5rem;
}

.kpi-label {
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    font-weight: 600;
}

.kpi-data h3 {
    font-size: 1.75rem;
    font-weight: 700;
    margin: 0.25rem 0;
    background: linear-gradient(to right, #fff, #cbd5e1);
    background-clip: text;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.kpi-trend {
    font-size: 0.75rem;
    font-weight: 600;
}

.kpi-trend.positive {
    color: var(--success);
}

.kpi-trend.negative {
    color: var(--danger);
}

/* Charts */
.charts-row {
    display: grid;
    grid-template-columns: repeat(12, 1fr);
    gap: 1.5rem;
    margin-bottom: 1.5rem;
}

.chart-container {
    padding: 1.5rem;
}

.chart-container.lg {
    grid-column: span 8;
}

.chart-container.sm {
    grid-column: span 4;
}

.chart-container.md {
    grid-column: span 6;
}

.chart-container.full {
    grid-column: span 12;
}

@media (max-width: 1200px) {

    .chart-container.lg,
    .chart-container.sm {
        grid-column: span 12;
    }
}

.chart-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.chart-header h3 {
    font-size: 1.1rem;
    color: var(--text-primary);
}

.chart-actions {
    display: flex;
    background: var(--bg-color);
    padding: 0.25rem;
    border-radius: 8px;
}

.chart-actions button {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    padding: 0.4rem 1rem;
    border-radius: 6px;
    font-size: 0.75rem;
    cursor: pointer;
    transition: all 0.2s;
}

.chart-actions button.active {
    background: var(--sidebar-bg);
    color: var(--accent-color);
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
}

.chart-body {
    height: 300px;
    position: relative;
}

.funnel-body {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 300px;
}

/* Funnel Visualization */
.funnel-container {
    display: flex;
    flex-direction: column;
    gap: 12px;
    height: 100%;
    justify-content: center;
    padding: 10px 0;
}

.funnel-step {
    position: relative;
    height: 45px;
    background: rgba(0, 229, 255, 0.15);
    border-right: 4px solid var(--accent-color);
    display: flex;
    align-items: center;
    padding: 0 15px;
    border-radius: 4px;
    transition: width 1s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    overflow: hidden;
}

.funnel-step::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    height: 100%;
    width: 4px;
    background: var(--accent-color);
}

.funnel-label {
    flex: 1;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-secondary);
}

.funnel-value {
    font-weight: 700;
    font-size: 0.95rem;
    color: var(--text-primary);
}

.funnel-conversion {
    position: absolute;
    bottom: -10px;
    right: 0;
    font-size: 0.7rem;
    color: var(--accent-color);
    font-weight: 600;
}

/* Toast */
.toast {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    background: var(--sidebar-bg);
    color: #fff;
    padding: 1rem 2rem;
    border-radius: 8px;
    border-left: 4px solid var(--accent-color);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    transform: translateY(150%);
    transition: transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    z-index: 1000;
}

.toast.show {
    transform: translateY(0);
}

/* Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    backdrop-filter: blur(5px);
}

.modal.show {
    display: flex;
}

.modal-content {
    width: 100%;
    max-width: 500px;
    padding: 30px;
    border-radius: 16px;
    position: relative;
    animation: modalSlide 0.3s ease-out;
}

@keyframes modalSlide {
    from {
        transform: translateY(-50px);
        opacity: 0;
    }

    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 25px;
}

.close-modal {
    font-size: 28px;
    cursor: pointer;
    color: var(--text-secondary);
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.file-drop-area {
    border: 2px dashed rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    padding: 20px;
    text-align: center;
    cursor: pointer;
    transition: background 0.3s;
    position: relative;
    margin-bottom: 20px;
}

.file-drop-area:hover {
    background: rgba(255, 255, 255, 0.02);
}

#import-file {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: pointer;
}

.btn-primary {
    width: 100%;
    padding: 14px;
    background: var(--accent-color);
    border: none;
    border-radius: 8px;
    color: #0c0e12;
    font-weight: 700;
    cursor: pointer;
    transition: transform 0.2s, opacity 0.2s;
}

.import-progress {
    margin-top: 20px;
}

.progress-bar {
    height: 6px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 3px;
    overflow: hidden;
    margin-bottom: 10px;
}

.progress-fill {
    height: 100%;
    background: var(--accent-color);
    width: 0%;
    transition: width 0.3s;
}

#import-status {
    font-size: 0.85rem;
    color: var(--text-secondary);
    text-align: center;
}

/* Analytics Navigation (New) */
.nav-analytics {
    display: flex;
    gap: 30px;
    padding: 15px 20px;
    background: rgba(17, 24, 39, 0.85);
    /* Slightly transparent for glass feel */
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 25px;
    overflow-x: auto;
    position: sticky;
    top: 0;
    z-index: 99;
    border-radius: 0 0 12px 12px;
}

.nav-group {
    display: flex;
    align-items: center;
    gap: 8px;
    padding-right: 20px;
    border-right: 1px solid rgba(255, 255, 255, 0.05);
}

.nav-group:last-child {
    border-right: none;
}

.nav-label {
    font-size: 0.7rem;
    text-transform: uppercase;
    color: var(--text-secondary);
    font-weight: 700;
    letter-spacing: 0.05em;
    margin-right: 8px;
    white-space: nowrap;
}

.nav-analytics .tab-btn {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.05);
    color: var(--text-secondary);
    padding: 6px 14px;
    border-radius: 20px;
    /* Pill shape */
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}

.nav-analytics .tab-btn:hover {
    background: rgba(255, 255, 255, 0.08);
    color: #fff;
    transform: translateY(-1px);
}

.nav-analytics .tab-btn.active {
    background: linear-gradient(135deg, rgba(0, 229, 255, 0.15), rgba(188, 0, 255, 0.15));
    border-color: rgba(0, 229, 255, 0.3);
    color: var(--accent-color);
    box-shadow: 0 2px 8px rgba(0, 229, 255, 0.15);
}

/* Hide valid scrollbars for cleaner look */
.nav-analytics::-webkit-scrollbar {
    height: 4px;
}

.nav-analytics::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
}

/* Level Selector Buttons (Ads Granular) */
.level-btn,
.corr-level-btn {
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    padding: 0.4rem 1rem;
    border-radius: 6px;
    font-size: 0.75rem;
    cursor: pointer;
    transition: all 0.2s;
    margin-left: 5px;
}

.level-btn:hover,
.corr-level-btn:hover {
    background: var(--glass-border);
    color: #fff;
}

.level-btn.active,
.corr-level-btn.active {
    background: var(--sidebar-bg);
    border-color: var(--accent-color);
    color: var(--accent-color);
    box-shadow: 0 0 10px rgba(0, 229, 255, 0.1);
}

/* Correlation Matrix */
.matrix-table th,
.matrix-table td {
    text-align: center;
    padding: 0.8rem;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.matrix-table th {
    background: var(--glass-border);
}

/* Mobile & Tablet Responsiveness */
@media (max-width: 800px) {
    .sidebar {
        transform: translateX(-100%);
        transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
        z-index: 1000;
        box-shadow: 5px 0 15px rgba(0, 0, 0, 0.5);
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .app-container {
        overflow-x: hidden;
        width: 100%;
        max-width: 100vw;
    }

    .main-content {
        margin-left: 0;
        padding: 1.5rem;
        width: 100% !important;
        max-width: 100vw !important;
        overflow-x: hidden;
        box-sizing: border-box;
    }

    /* Hamburger Menu Button */
    .mobile-menu-btn {
        display: flex !important;
        align-items: center;
        justify-content: center;
        position: fixed;
        top: 1.5rem;
        left: 1.5rem;
        z-index: 1001;
        background: var(--card-bg);
        border: 1px solid var(--glass-border);
        color: var(--text-primary);
        width: 42px;
        height: 42px;
        border-radius: 12px;
        cursor: pointer;
        backdrop-filter: blur(12px);
        box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
        transition: all 0.3s var(--transition);
    }

    .mobile-menu-btn:hover {
        background: var(--card-hover-bg);
        border-color: var(--accent-primary);
    }

    /* Mobile Overlay */
    .sidebar-overlay {
        display: none;
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background: rgba(0, 0, 0, 0.6);
        z-index: 999;
        backdrop-filter: blur(4px);
        opacity: 0;
        transition: opacity 0.4s ease;
    }

    .sidebar-overlay.show {
        display: block;
        opacity: 1;
    }
}

.mobile-menu-btn {
    display: none;
    /* Hidden on desktop */
}

@media (max-width: 768px) {
    .kpi-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 1rem;
    }

    .charts-row {
        grid-template-columns: 1fr;
    }

    .chart-container.lg,
    .chart-container.md,
    .chart-container.sm {
        grid-column: span 1 !important;
    }

    .top-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 1.5rem;
        margin-top: 3.5rem;
        /* Space for hamburger */
        text-align: left;
    }

    .header-left h2 {
        font-size: 1.5rem;
    }

    .header-left p {
        font-size: 0.85rem;
    }

    .search-container {
        width: 100%;
        max-width: 100%;
    }

    .selectors {
        flex-direction: column;
        align-items: flex-start;
        width: 100%;
        gap: 1rem;
    }

    .selector-group {
        width: 100%;
    }

    select,
    input[type="date"] {
        width: 100%;
    }

    .btn-refresh {
        width: 100%;
    }

    .ceo-charts-grid {
        gap: 1.5rem;
    }

    .ceo-chart-card {
        padding: 1.5rem;
    }
}

@media (max-width: 480px) {
    .kpi-grid {
        grid-template-columns: 1fr;
    }

    .main-content {
        padding: 1rem;
    }

    .header-left h2 {
        font-size: 1.3rem;
    }
}

.analytics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 20px;
    margin-bottom: 24px;
}

@media (max-width: 768px) {
    .analytics-grid {
        grid-template-columns: 1fr;
    }
}

/* 🚩 War Room Alerts */
.war-banner-container {
    height: 0;
    overflow: hidden;
    transition: height 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    position: sticky;
    top: 0;
    z-index: 2000;
}

.war-banner-container.active {
    height: 50px;
}

.war-banner {
    background: linear-gradient(90deg, #ef4444 0%, #b91c1c 100%);
    color: white;
    padding: 0 2rem;
    height: 50px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 0.9rem;
    box-shadow: 0 4px 15px rgba(239, 68, 68, 0.3);
}

.war-content {
    display: flex;
    align-items: center;
    gap: 12px;
}

.war-btn {
    background: white;
    color: #ef4444;
    border: none;
    padding: 6px 16px;
    border-radius: 6px;
    font-weight: 700;
    font-size: 0.8rem;
    cursor: pointer;
    transition: all 0.2s;
}

.war-btn:hover {
    transform: scale(1.05);
    background: #f8fafc;
}

/* 🛠️ UI Helpers */
.text-red {
    color: #ef4444 !important;
}

.text-green {
    color: #10b981 !important;
}

.text-yellow {
    color: #f59e0b !important;
}


/* Cleaned UI Hooks */

.error-text {
    color: #ef4444;
    font-weight: bold;
    cursor: help;
}

.kpi-value-container {
    display: flex;
    flex-direction: column;
}




/* Global stability patches */



@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(15px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.main-content {
    animation: fadeIn 0.8s ease-out;
}

@keyframes loading-pulse {
    0% {
        opacity: 1;
    }

    50% {
        opacity: 0.4;
    }

    100% {
        opacity: 1;
    }
}

.loading-pulse {
    animation: loading-pulse 1.5s infinite ease-in-out;
}

/* Sparkline Charts */
.kpi-sparkline {
    margin-top: 0.75rem;
    opacity: 0.8;
    transition: opacity 0.3s ease;
}

.kpi-card:hover .kpi-sparkline {
    opacity: 1;
}

/* Skeleton Loading Animations */
@keyframes skeleton-shimmer {
    0% {
        background-position: -200% 0;
    }

    100% {
        background-position: 200% 0;
    }
}

.skeleton-text {
    background: linear-gradient(90deg,
            rgba(255, 255, 255, 0.05) 25%,
            rgba(255, 255, 255, 0.1) 50%,
            rgba(255, 255, 255, 0.05) 75%);
    background-size: 200% 100%;
    animation: skeleton-shimmer 1.5s infinite;
    border-radius: 4px;
}

.skeleton-row {
    height: 48px;
    background: linear-gradient(90deg,
            rgba(255, 255, 255, 0.02) 25%,
            rgba(255, 255, 255, 0.05) 50%,
            rgba(255, 255, 255, 0.02) 75%);
    background-size: 200% 100%;
    animation: skeleton-shimmer 1.5s infinite;
}

/* Trend Badges */
.kpi-trend-badge {
    position: absolute;
    top: 1rem;
    right: 1rem;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 0.7rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 4px;
}

.kpi-trend-badge.positive {
    background: rgba(34, 197, 94, 0.15);
    color: #22c55e;
    border: 1px solid rgba(34, 197, 94, 0.3);
}

.kpi-trend-badge.negative {
    background: rgba(239, 68, 68, 0.15);
    color: #ef4444;
    border: 1px solid rgba(239, 68, 68, 0.3);
}

.kpi-trend-badge.neutral {
    background: rgba(156, 163, 175, 0.15);
    color: #9ca3af;
    border: 1px solid rgba(156, 163, 175, 0.3);
}

/* Filter Select Styles */
.filter-select {
    background-color: var(--sidebar-bg);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 0.5rem 1rem;
    border-radius: 8px;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.2s ease;
    min-width: 150px;
}

.filter-select:hover {
    border-color: var(--accent-primary);
}

.filter-select:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px rgba(0, 229, 255, 0.1);
}

.filter-group {
    display: flex;
    align-items: center;
}

/* Status Badges Enhanced */
.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 0.7rem;
    font-weight: 600;
}

.status-badge.recovered {
    background: rgba(34, 197, 94, 0.15);
    color: #22c55e;
}

.status-badge.pending {
    background: rgba(245, 158, 11, 0.15);
    color: #f59e0b;
}

.status-badge.lost {
    background: rgba(239, 68, 68, 0.15);
    color: #ef4444;
}

/* Time Badge */
.time-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.7rem;
    background: rgba(59, 130, 246, 0.1);
    color: #3b82f6;
}

/* Avatar Initials */
.avatar-initials {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: 600;
    color: #fff;
    flex-shrink: 0;
}

/* Table Improvements */
.data-table td {
    vertical-align: middle;
}

.customer-cell {
    display: flex;
    align-items: center;
    gap: 10px;
}

.customer-info {
    display: flex;
    flex-direction: column;
}

.customer-name {
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 6px;
}

.customer-email {
    font-size: 0.75rem;
    color: #9ca3af;
}

.customer-cpf {
    font-size: 0.7rem;
    color: #6b7280;
}

/* D3 Tooltip */
.d3-tooltip {
    pointer-events: none;
    transition: opacity 0.2s ease;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
}

.funnel-slice {
    transition: all 0.3s ease;
    cursor: pointer;
}

.funnel-slice:hover {
    filter: brightness(1.2);
}

/* Heatmap Adjustments */
#abandoned-heatmap-wrapper rect {
    cursor: crosshair;
}

/* Phase 4 - Abandoned Carts Polish */
.kpi-card.glass {
    position: relative;
    overflow: hidden;
    transition: all 0.4s var(--transition);
}

.kpi-card.glass:hover {
    transform: translateY(-5px) scale(1.02);
    background: var(--card-hover-bg);
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.4),
        0 0 20px var(--accent-glow);
}

.kpi-card.glass::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle, rgba(255, 255, 255, 0.03) 0%, transparent 70%);
    pointer-events: none;
    transition: transform 0.6s ease;
}

.kpi-card.glass:hover::before {
    transform: translate(10%, 10%);
}

.kpi-sparkline {
    opacity: 0.6;
    transition: opacity 0.3s ease;
}

.kpi-card:hover .kpi-sparkline {
    opacity: 1;
}

/* Enhanced Skeleton Loader */
.skeleton-text {
    position: relative;
    overflow: hidden;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 4px;
    color: transparent !important;
}

.skeleton-text::after {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg,
            transparent,
            rgba(255, 255, 255, 0.08),
            transparent);
    animation: shimmer 1.5s infinite;
}

@keyframes shimmer {
    0% {
        transform: translateX(-100%);
    }

    100% {
        transform: translateX(100%);
    }
}

.skeleton-row td {
    height: 60px;
    background: linear-gradient(90deg,
            rgba(255, 255, 255, 0.02) 25%,
            rgba(255, 255, 255, 0.05) 50%,
            rgba(255, 255, 255, 0.02) 75%);
    background-size: 200% 100%;
    animation: shimmer 2s infinite;
}

/* Premium Table Rows */
.data-table tbody tr {
    transition: background 0.2s ease;
}

.data-table tbody tr:hover {
    background: rgba(139, 92, 246, 0.05) !important;
}

.customer-cell {
    display: flex;
    align-items: center;
    gap: 12px;
}

.avatar-initials {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: 700;
    color: #fff;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);
}

.time-badge {
    font-size: 0.7rem;
    padding: 2px 6px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    color: var(--text-secondary);
}

/* D3 Tooltip Refinement */
.d3-tooltip {
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.8) !important;
    border: 1px solid rgba(255, 255, 255, 0.2) !important;
    font-family: 'Outfit', sans-serif !important;
}

.d3-tooltip strong {
    color: var(--accent-primary);
    display: block;
    margin-bottom: 4px;
    font-size: 0.85rem;
}

/* Glass Tabs/Filters */
.filter-select {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: #fff;
    padding: 6px 12px;
    border-radius: 8px;
    outline: none;
    transition: all 0.3s ease;
}

.filter-label {
    font-size: 0.75rem;
    text-transform: uppercase;
    color: var(--text-secondary);
    margin-right: 0.5rem;
    font-weight: 600;
    letter-spacing: 0.02em;
}

.filter-select:focus {
    border-color: var(--accent-primary);
    background: rgba(255, 255, 255, 0.08);
    box-shadow: 0 0 10px var(--accent-glow);
}

/* Layout Intelligence Grid */
.ceo-charts-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 30px;
    margin-bottom: 32px;
    align-items: stretch;
}

.section-divider {
    grid-column: 1 / -1;
    padding: 20px 0 10px 0;
    border-bottom: 1px solid var(--glass-border);
    margin-bottom: 10px;
}

.ceo-chart-card {
    background: var(--card-bg);
    border-radius: var(--radius-md);
    padding: 24px;
    border: 1px solid var(--glass-border);
    backdrop-filter: blur(var(--glass-blur));
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.ceo-chart-card:hover {
    transform: translateY(-5px);
    border-color: var(--accent-primary);
    box-shadow: 0 10px 30px -10px var(--accent-glow);
}

@media (max-width: 1024px) {
    .ceo-charts-grid {
        grid-template-columns: 1fr;
    }

    .section-divider {
        grid-column: span 1;
    }
}

.section-title {
    font-size: 1.2rem;
    color: var(--accent-primary);
    display: flex;
    align-items: center;
    gap: 10px;
    font-family: var(--font-head);
    margin: 0;
}

.full-width {
    grid-column: 1 / -1;
}

/* Enhanced Unit Economics */
.unit-economics-card {
    display: flex;
    flex-direction: column;
}

.unit-economics-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex: 1;
    text-align: center;
}

.unit-economics-card .ratio {
    font-size: 1.8rem;
    font-weight: 800;
    color: var(--accent-primary);
    line-height: 1.1;
}

.unit-economics-card .label {
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-top: 4px;
    font-weight: 500;
}

.ltv-cac-visual {
    position: relative;
    width: 160px;
    height: 100px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-end;
}


.ltv-cac-arch {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

#ltv-cac-arch-fill {
    transition: stroke-dashoffset 1.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.ratio-container {
    padding-bottom: 10px;
    z-index: 10;
    text-align: center;
}

.ltv-cac-badge {
    display: inline-flex;
    padding: 4px 12px;
    border-radius: 100px;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin: 12px 0 8px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.ltv-cac-meta {
    font-size: 0.75rem;
    color: var(--text-muted);
}


/* Scroll Containers for Insights */
.insights-scroll-container,
.health-scroll-container {
    display: flex;
    flex-direction: column;
    gap: 12px;
    max-height: 400px;
    overflow-y: auto;
    padding-right: 5px;
}

.insights-scroll-container::-webkit-scrollbar,
.health-scroll-container::-webkit-scrollbar {
    width: 4px;
}

/* Responsive Table Wrapper */
.responsive-table-wrapper {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin-top: 1rem;
    border-radius: var(--radius-md);
    background: rgba(0, 0, 0, 0.1);
}

.responsive-table-wrapper .data-table {
    width: 100%;
    border-collapse: collapse;
    min-width: 600px;
    /* Force scroll on mobile */
}

/* Mobile Specific Adjustments for Units and Grid */
@media (max-width: 768px) {
    .unit-economics-card {
        padding: 1.5rem !important;
    }

    .unit-economics-card .ratio {
        font-size: 2.5rem;
    }

    .unit-economics-card .label {
        font-size: 0.85rem;
    }
}

/* --- North Star Metrics (Phase 2.1) --- */
.north-star-grid {
    display: grid !important;
    grid-template-columns: repeat(4, 1fr) !important;
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.north-star-card {
    background: var(--card-bg);
    border-radius: var(--radius-lg);
    padding: 2rem;
    position: relative;
    overflow: hidden;
    min-height: 180px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    border: 1px solid rgba(255, 255, 255, 0.05);
    transition: transform 0.2s, box-shadow 0.2s;
}

.north-star-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    border-color: rgba(255, 255, 255, 0.1);
}

.north-star-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.north-star-title {
    font-size: 1rem;
    color: var(--text-secondary);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.north-star-value {
    font-size: 2.2rem;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1;
    margin-bottom: 0.5rem;
    font-family: 'Inter', sans-serif;
}

.north-star-footer {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.north-star-delta {
    display: inline-flex;
    align-items: center;
    padding: 0.25rem 0.75rem;
    border-radius: 20px;
    font-size: 0.9rem;
    font-weight: 600;
}

.delta-positive {
    background: rgba(16, 185, 129, 0.15);
    color: #34d399;
}

.delta-negative {
    background: rgba(239, 68, 68, 0.15);
    color: #f87171;
}

.delta-neutral {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-secondary);
}

.secondary-kpi-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1.5rem;
    margin-bottom: 2rem;
}

@media (max-width: 800px) {
    .north-star-grid {
        grid-template-columns: repeat(1, 1fr) !important;
        gap: 1rem;
    }

    .north-star-value {
        font-size: 2.8rem;
    }

    .secondary-kpi-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 600px) {
    .secondary-kpi-grid {
        grid-template-columns: 1fr;
    }
}