:root {
    /* Premium Color Palette */
    --brand-primary: #0ea5e9;
    --brand-secondary: #6366f1;
    --brand-accent: #f43f5e;

    --bg-main: #f1f5f9;
    --bg-surface: rgba(255, 255, 255, 0.75);
    --bg-card: rgba(255, 255, 255, 0.85);

    --text-primary: #0f172a;
    --text-muted: #475569;
    --text-on-brand: #ffffff;

    --border-soft: rgba(226, 232, 240, 0.4);
    --border-premium: rgba(255, 255, 255, 0.6);

    /* Effects & Shadows */
    --glass-blur: 24px;
    --shadow-soft: 0 10px 15px -3px rgba(15, 23, 42, 0.03), 0 4px 6px -2px rgba(15, 23, 42, 0.01);
    --shadow-premium: 0 25px 50px -12px rgba(15, 23, 42, 0.1), 0 0 1px 1px rgba(255, 255, 255, 0.7);
    --inner-glow: inset 0 0 0 1px rgba(255, 255, 255, 0.8);

    /* Spacing & Radii */
    --radius-lg: 24px;
    --radius-md: 16px;
    --radius-sm: 10px;

    --sidebar-bg: #ffffff;
    --border-color: #e2e8f0;
    --accent-primary: #3b82f6;
    --text-secondary: #64748b;

    /* AG Grid Overrides */
    --ag-background-color: transparent;
    --ag-header-background-color: transparent;
    --ag-header-foreground-color: var(--text-muted);
    --ag-header-cell-hover-background-color: rgba(14, 165, 233, 0.05);
    --ag-row-hover-color: rgba(14, 165, 233, 0.03);
    --ag-selected-row-background-color: rgba(14, 165, 233, 0.08);
    --ag-odd-row-background-color: rgba(255, 255, 255, 0.2);
    --ag-font-family: 'Inter', sans-serif;
    --ag-font-size: 13px;
    --ag-border-color: var(--border-soft);
    --ag-border-radius: 12px;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
}

body {
    background:
        radial-gradient(at 0% 0%, rgba(14, 165, 233, 0.05) 0px, transparent 50%),
        radial-gradient(at 50% 0%, rgba(99, 102, 241, 0.03) 0px, transparent 50%),
        radial-gradient(at 100% 0%, rgba(244, 63, 94, 0.03) 0px, transparent 50%),
        #f8fafc;
    color: var(--text-primary);
    -webkit-font-smoothing: antialiased;
    min-height: 100vh;
    animation: bg-pulse 10s ease-in-out infinite alternate;
}

@keyframes bg-pulse {
    0% {
        background-position: 0% 0%;
    }

    100% {
        background-position: 10% 10%;
    }
}

/* Custom Premium Scrollbar */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: rgba(14, 165, 233, 0.1);
    border-radius: 10px;
    transition: all 0.3s;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(14, 165, 233, 0.3);
}

/* Responsive Layout Enhancements */
@media (max-width: 1024px) {
    .dashboard-scrollable {
        padding: 15px;
    }



    .app-cell-horizontal {
        padding: 5px 0;
        gap: 10px;
    }

    .app-icon-wrapper {
        width: 32px;
        height: 32px;
    }
}

@media (max-width: 768px) {
    .dashboard-scrollable {
        padding: 10px;
    }

    .sidebar-overlay {
        display: none;
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background: rgba(15, 23, 42, 0.4);
        backdrop-filter: blur(4px);
        z-index: 1999;
    }

    .sidebar-overlay.active {
        display: block;
    }
}

.sidebar-slim {
    width: 250px;
    background: rgba(255, 255, 255, 0.8);
    backdrop-filter: blur(var(--glass-blur));
    border-right: 1px solid var(--border-soft);
    display: flex;
    flex-direction: column;
    padding: 24px 0;
    position: fixed;
    height: 100vh;
    z-index: 2000;
    transition: width 0.4s cubic-bezier(0.4, 0, 0.2, 1), transform 0.3s ease;
    box-shadow: 10px 0 30px rgba(0, 0, 0, 0.02);
}

.main-content-flow {
    flex: 1;
    min-width: 0;
    margin-left: 250px;
    /* Persistent sidebar space on desktop */
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Header Toggle Styles */
.mobile-menu-toggle {
    display: none !important;
    align-items: center;
    justify-content: center;
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: var(--bg-card);
    border: 1px solid var(--border-soft);
    color: var(--text-primary);
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: var(--shadow-soft);
}

.mobile-menu-toggle:active {
    transform: scale(0.92);
    background: var(--bg-surface);
}

@media (max-width: 1024px) {
    .sidebar-slim {
        width: 72px;
        /* Mini Sidebar */
        transform: translateX(0) !important;
        /* Always visible */
        padding: 20px 0;
        align-items: center;
    }

    .sidebar-slim .nav-item span,
    .sidebar-slim .sidebar-username,
    .sidebar-slim .sidebar-logout-btn span,
    .sidebar-slim .sidebar-logo span {
        display: none;
        /* Hide labels */
    }

    .nav-item {
        padding: 12px;
        justify-content: center;
        margin: 4px 8px;
    }

    .sidebar-user {
        padding: 15px 0;
        justify-content: center;
    }

    .main-content-flow {
        margin-left: 72px;
        /* Match mini sidebar */
    }

    .mobile-menu-toggle,
    .sidebar-close-btn {
        display: none !important;
        /* No longer needed */
    }

    .main-header {
        position: sticky;
        top: 0;
        z-index: 1000;
        background: rgba(255, 255, 255, 0.85);
        backdrop-filter: blur(12px);
    }
}

.sidebar-close-btn {
    display: none;
    position: absolute;
    top: 20px;
    right: 20px;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: rgba(244, 63, 94, 0.1);
    color: var(--brand-accent);
    border: none;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
    z-index: 2010;
}

.sidebar-close-btn:hover {
    background: rgba(244, 63, 94, 0.2);
    transform: rotate(90deg);
}

.sidebar-logo {
    display: flex;
    justify-content: center;
    margin-bottom: 30px;
}

.logo-circle {
    width: 40px;
    height: 40px;
    background: #1e293b;
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
}

.sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 12px 24px;
    text-decoration: none;
    color: var(--text-muted);
    font-size: 0.95rem;
    font-weight: 500;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    margin: 4px 12px;
    border-radius: var(--radius-sm);
}

.nav-item:hover {
    background: rgba(14, 165, 233, 0.05);
    color: var(--brand-primary);
    transform: translateX(4px);
}

.nav-item.active {
    color: var(--brand-primary);
    background: rgba(14, 165, 233, 0.1);
    font-weight: 600;
    box-shadow: inset 0 0 0 1px rgba(14, 165, 233, 0.1);
}

.nav-item.active::before {
    content: "";
    position: absolute;
    left: -12px;
    top: 50%;
    transform: translateY(-50%);
    width: 4px;
    height: 20px;
    background: var(--brand-primary);
    border-radius: 0 4px 4px 0;
    box-shadow: 2px 0 10px rgba(14, 165, 233, 0.5);
}

.sidebar-bottom {
    margin-top: auto;
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 10px 10px 14px;
    border-top: 1px solid rgba(226, 232, 240, 0.5);
}

.sidebar-user {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    border-radius: 10px;
}

.sidebar-username {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-primary);
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.avatar-circle {
    width: 32px;
    height: 32px;
    background: linear-gradient(135deg, #e0f2fe, #bae6fd);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    color: #0284c7;
}

/* ── Logout button ──────────────────────────────────────── */
.sidebar-logout-btn {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 10px 10px;
    border: none;
    background: transparent;
    border-radius: 10px;
    cursor: pointer;
    color: #94a3b8;
    font-size: 0.875rem;
    font-weight: 500;
    font-family: inherit;
    text-align: left;
    transition: background 0.2s ease, color 0.2s ease, transform 0.15s ease;
    outline: none;
    -webkit-appearance: none;
    appearance: none;
}

.sidebar-logout-btn:hover {
    background: rgba(244, 63, 94, 0.08);
    color: #f43f5e;
    transform: translateX(3px);
}

.sidebar-logout-btn:active {
    transform: translateX(0);
    background: rgba(244, 63, 94, 0.14);
}

.sidebar-logout-btn i,
.sidebar-logout-btn svg {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
    stroke-width: 2px;
    color: inherit;
}


/* .main-content-flow duplicate removed */

/* --- Header Re-Design (Single-Row Premium) --- */
.main-header {
    background: rgba(255, 255, 255, 0.7);
    backdrop-filter: blur(var(--glass-blur));
    border-bottom: 1px solid var(--border-soft);
    position: sticky;
    top: 0;
    z-index: 1001;
    box-shadow: 0 4px 30px rgba(0, 0, 0, 0.03);
}

.header-content-wrapper {
    display: flex !important;
    align-items: center !important;
    padding: 5px 5px !important;
    min-height: 60px !important;
    height: auto !important;
    gap: 12px 12px !important;
    flex-wrap: wrap !important;
    width: 100% !important;
}

.header-brand {
    display: none;
    /* User manually removed it from HTML too */
}

.brand-title {
    font-family: 'Outfit', sans-serif;
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1;
}

/* Divider removed from HTML */
.header-divider {
    display: none;
}

/* Wrapper classes removed from HTML */
.header-pill-section,
.pill-filter-bar,
.header-direct-actions,
.header-right-tools {
    display: contents !important;
}

.pill-action-toggle,
.filter-pill {
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(255, 255, 255, 0.4);
    padding: 5px 14px;
    border-radius: 50px;
    border: 1px solid var(--border-soft);
    position: relative;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    height: 38px;
    white-space: nowrap;
    cursor: pointer;
}

.filter-pill:hover {
    background: #ffffff;
    border-color: var(--brand-primary);
    box-shadow: 0 8px 20px rgba(14, 165, 233, 0.08);
    transform: translateY(-2px);
}

.filter-pill:active {
    transform: translateY(0) scale(0.98);
}

/* Loading State */
.filter-pill.loading {
    pointer-events: none;
}

.filter-pill.loading .pill-label,
.filter-pill.loading .pill-select,
.filter-pill.loading .pill-input,
.filter-pill.loading .select2-container {
    filter: blur(2px);
    opacity: 0.6;
}

.filter-pill.loading::after {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    width: 14px;
    height: 14px;
    margin: -7px 0 0 -7px;
    border: 2px solid rgba(0, 120, 215, 0.2);
    border-top-color: var(--accent-primary);
    border-radius: 50%;
    animation: pill-spinner 0.6s linear infinite;
    z-index: 2;
}

@keyframes pill-spinner {
    to {
        transform: rotate(360deg);
    }
}

.pill-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    background: #ffffff;
    padding: 0 16px;
    /* Increased horizontal padding for text-only pills */
    border-radius: 50px;
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    font-size: 11px;
    text-transform: uppercase;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    height: 34px;
}

.pill-btn:hover {
    border-color: var(--accent-primary);
    color: var(--accent-primary);
    background: #f0f9ff;
    transform: translateY(-1px);
}

.pill-btn i {
    width: 14px;
    height: 14px;
}

.header-right-tools {
    display: flex !important;
    align-items: center !important;
    gap: 12px !important;
    margin-left: auto !important;
    flex-shrink: 0 !important;
}

.header-search {
    width: 240px;
    /* Restored reasonable fixed width */
    flex-shrink: 0;
}

.search-input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.search-input-wrapper i {
    position: absolute;
    left: 12px;
    width: 14px;
    height: 14px;
    color: var(--text-secondary);
}

.search-input-wrapper input {
    width: 100%;
    padding: 0 12px 0 32px;
    background: #f1f5f9;
    border: 1px solid transparent;
    border-radius: 10px;
    font-size: 0.85rem;
    transition: all 0.2s;
    height: 34px;
    /* Consistent height */
}

.search-input-wrapper input:focus {
    background: #ffffff;
    border-color: var(--accent-primary);
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
    outline: none;
}

.header-user-actions {
    display: flex;
    gap: 8px;
}

.icon-btn-ghost {
    width: 34px;
    height: 34px;
    border-radius: 10px;
    border: none;
    background: transparent;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s;
}

.icon-btn-ghost:hover {
    background: #f1f5f9;
    color: var(--accent-primary);
}

.icon-btn {
    width: 34px;
    height: 34px;
    border-radius: 10px;
    border: 1px solid var(--border-color);
    background: transparent;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.icon-btn:hover {
    background: #f8fafc;
    color: var(--accent-primary);
    border-color: var(--accent-primary);
    transform: translateY(-1px);
}

/* Conflict definitions removed for single-row integrity */

/* Filter Pill - Standardize on line 1370 block */
.filter-pill.has-value .pill-label {
    display: none;
}

.more-btn {

    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 50%;
    width: 34px;
    height: 34px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: #94a3b8;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.03);
}

.more-btn:hover {
    background: #ffffff;
    color: var(--accent-primary);
    border-color: var(--accent-primary);
    box-shadow: 0 4px 12px rgba(14, 165, 233, 0.08);
    transform: translateY(-1px);
}

.more-options-dropdown {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    min-width: 160px;
    z-index: 9999;
    display: none;
    /* Hidden by default */
    padding: 6px;
}

.more-options-dropdown.show {
    display: block !important;
}

.dropdown-item {
    width: 100%;
    padding: 8px 12px;
    display: flex;
    align-items: center;
    gap: 10px;
    border: none;
    background: transparent;
    border-radius: 6px;
    cursor: pointer;
    color: #475569;
    font-size: 13px;
    font-weight: 500;
    transition: background 0.2s;
}

.dropdown-item:hover {
    background: #f1f5f9;
    color: #0ea5e9;
}

.dropdown-item i {
    width: 16px;
    height: 16px;
}

.search-input-wrapper {
    display: flex;
    align-items: center;
    gap: 12px;
    background: #f8fafc;
    padding: 0px 10px;
    border-radius: 12px;
    border: 1.5px solid transparent;
    transition: all 0.2s ease;
    width: 100%;
}

.search-input-wrapper:focus-within {
    background: #ffffff;
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 4px rgba(14, 165, 233, 0.08);
}

.search-input-wrapper i {
    color: #94a3b8;
    width: 18px;
    height: 18px;
    stroke-width: 2.5px;
}

.search-input-wrapper input {
    border: none;
    background: transparent;
    outline: none;
    width: 100%;
    font-size: 0.7rem;
    font-weight: 500;
    color: var(--text-primary);
}

.search-input-wrapper input::placeholder {
    color: #94a3b8;
}

/* --- Components --- */
/* .dashboard-scrollable duplicate removed */

.card {
    background: rgba(255, 255, 255, 0.6);
    backdrop-filter: blur(var(--glass-blur));
    border-radius: var(--radius-lg);
    padding: 24px;
    border: 1px solid var(--border-premium);
    box-shadow: var(--shadow-premium);
    display: flex;
    flex-direction: column;
    height: 100%;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.card:hover {
    transform: translateY(-4px);
    box-shadow: 0 30px 60px -12px rgba(15, 23, 42, 0.15);
}

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

.header-left-title {
    font-size: 1.5rem;
    font-weight: 800;
    color: #0f172a;
    letter-spacing: -0.02em;
}

.main-name {
    font-size: 1rem;
    font-weight: 500;
    color: #111827;
    display: flex;
    align-items: center;
    gap: 8px;
}

/* --- Tablet/Desktop Media Queries --- */
@media (min-width: 768px) {
    .sidebar-slim {
        width: 80px;
        transform: translateX(0);
        align-items: center;
    }

    .sidebar-slim.active {
        width: 250px;
    }

    .sidebar-slim.active .nav-item span {
        display: inline;
    }

    .sidebar-slim .nav-item span {
        display: none;
    }

    .main-content-flow {
        margin-left: 80px;
    }

    .main-header {
        flex-direction: row;
        justify-content: space-between;
        padding: 15px 30px;
    }

    .mobile-menu-toggle {
        display: none;
    }

}

/* --- Uifull Header Refinements --- */
.pill-icon {
    width: 14px;
    height: 14px;
    color: var(--brand-primary);
    opacity: 0.9;
    filter: drop-shadow(0 0 2px rgba(14, 165, 233, 0.3));
}

.filter-pill.has-value {
    background: linear-gradient(135deg, rgba(14, 165, 233, 0.1) 0%, rgba(99, 102, 241, 0.1) 100%);
    border-color: var(--brand-primary);
    box-shadow: 0 4px 15px rgba(14, 165, 233, 0.15);
}

.filter-pill.has-value .pill-label {
    color: var(--brand-primary);
    font-weight: 600;
}

.filter-pill {
    display: flex;
    align-items: center;
    gap: 10px;
    background: rgba(255, 255, 255, 0.6);
    backdrop-filter: blur(8px);
    padding: 6px 14px;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-soft);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.02);
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    height: 38px;
}

.filter-pill:hover {
    background: #ffffff;
    border-color: var(--brand-primary);
    box-shadow: 0 4px 12px rgba(14, 165, 233, 0.1);
    transform: translateY(-1px);
}

.pill-btn-action {
    display: flex;
    align-items: center;
    gap: 8px;
    background: #ffffff;
    padding: 0 16px;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-soft);
    color: var(--text-muted);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    height: 34px;
}

.pill-btn-action:hover {
    border-color: var(--brand-primary);
    color: var(--brand-primary);
    background: rgba(14, 165, 233, 0.05);
}

.pill-btn-action.premium {
    background: var(--brand-primary);
    color: white;
    border: none;
    box-shadow: 0 4px 10px rgba(14, 165, 233, 0.2);
}

.pill-btn-action.premium:hover {
    background: #0284c7;
    transform: translateY(-1px);
    box-shadow: 0 6px 15px rgba(14, 165, 233, 0.3);
}

.header-search-premium {
    flex: 1;
    min-width: 200px;
    max-width: 300px;
}

.search-input-wrapper-v2 {
    position: relative;
    display: flex;
    align-items: center;
}

.search-input-wrapper-v2 i {
    position: absolute;
    left: 14px;
    width: 16px;
    height: 16px;
    color: var(--text-muted);
    pointer-events: none;
}

.search-input-wrapper-v2 input {
    width: 100%;
    padding: 0 16px 0 15px;
    background: rgba(241, 245, 249, 0.5);
    border: 1px solid transparent;
    border-radius: var(--radius-lg);
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s;
    height: 38px;
}

.search-input-wrapper-v2 input:focus {
    background: #ffffff;
    border-color: var(--brand-primary);
    box-shadow: 0 0 0 4px rgba(14, 165, 233, 0.1);
    outline: none;
}

/* Premium Comparison Toggle */
.switch-premium {
    position: relative;
    display: inline-block;
    width: 36px;
    height: 20px;
}

.slider-premium {
    position: absolute;
    cursor: pointer;
    inset: 0;
    background-color: #e2e8f0;
    transition: .4s;
    border-radius: 20px;
}

.slider-premium:before {
    position: absolute;
    content: "";
    height: 14px;
    width: 14px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: .4s;
    border-radius: 50%;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

input:checked+.slider-premium {
    background-color: var(--brand-primary);
}

input:checked+.slider-premium:before {
    transform: translateX(16px);
}

.icon-btn-glass {
    width: 38px;
    height: 38px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-soft);
    background: rgba(255, 255, 255, 0.5);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.2s;
}

.icon-btn-glass:hover {
    background: #ffffff;
    color: var(--brand-primary);
    border-color: var(--brand-primary);
    transform: scale(1.05);
}

.bottom-grid-section {
    display: flex;
    flex-direction: column;
    gap: 24px;
    min-height: 400px;
    min-width: 0;
    padding: 8px;
    height: calc(100vh - 140px);
    /* Taller for better view */
}

/* Table Search & Grid UI */
.table-search-inline {
    display: flex;
    align-items: center;
    gap: 8px;
    background: #f8fafc;
    padding: 6px 12px;
    border-radius: 6px;
    border: 1px solid #e2e8f0;
    transition: all 0.2s;
}

.table-search-inline:focus-within {
    border-color: var(--brand-primary);
    box-shadow: 0 0 0 4px rgba(14, 165, 233, 0.1);
}

/* Animations */
@keyframes fadeInLift {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.stagger-entry {
    animation: fadeInLift 0.6s cubic-bezier(0.2, 0.8, 0.2, 1) forwards;
    opacity: 0;
}

.stagger-1 {
    animation-delay: 0.1s;
}

.stagger-2 {
    animation-delay: 0.2s;
}

.stagger-3 {
    animation-delay: 0.3s;
}

.stagger-4 {
    animation-delay: 0.4s;
}

/* Skeleton Loader */
.skeleton {
    background: linear-gradient(90deg, #f1f5f9 25%, #e2e8f0 50%, #f1f5f9 75%);
    background-size: 200% 100%;
    animation: skeleton-loading 1.5s infinite;
    border-radius: 4px;
}

@keyframes skeleton-loading {
    0% {
        background-position: 200% 0;
    }

    100% {
        background-position: -200% 0;
    }
}

.table-search-inline input {
    border: none;
    background: transparent;
    outline: none;
    font-size: 0.9rem;
    color: #475569;
    width: 200px;
}



/* Removed defunct Pagination UI */

.card-body-grid {
    padding: 0;
    overflow: auto;
    /* Changed from hidden to allow scrollbars if needed */
    border-radius: 16px;
    flex: 1;
    display: flex;
    position: relative;
    min-width: 0;
}

/* AG Grid Premium Styling */
.ag-theme-alpine {
    --ag-border-color: transparent;
    --ag-row-border-color: var(--border-soft);
    border: none !important;
}

.ag-header {
    border-bottom: 2px solid var(--border-soft) !important;
}

.ag-header-cell::after {
    display: none !important;
}

.ag-row {
    transition: background-color 0.2s ease;
}

.ag-row-hover {
    background-color: var(--ag-row-hover-color) !important;
}

.ag-cell {
    display: flex;
    align-items: center;
    border: none !important;
}

/* Sorting Transition Effect */
.sorting-transition {
    opacity: 0.6;
    filter: blur(2px);
    transition: all 0.4s ease;
}

#countryGrid {
    flex: 1;
    width: 100%;
    height: 100%;
    min-height: 300px;
    background: transparent !important;
}

/* Custom App Cell Styles (Horizontal Professional) */
.app-cell-horizontal {
    display: flex;
    align-items: center;
    gap: 14px;
    height: 100%;
    padding: 6px 0;
}

.app-icon-wrapper {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    overflow: hidden;
    flex-shrink: 0;
    background: #ffffff;
    border: 1px solid #e2e8f0;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.06);
}

.app-icon-img-small {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.app-details {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 0;
    width: 100%;
}

.app-name-text {
    font-size: 14px;
    font-weight: 600;
    color: #0f172a;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* REDIRECT LINK FIX */
.app-redirect-link {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 12px;
    font-weight: 500;
    color: #64748b;
    text-decoration: none;
    transition: all 0.2s ease;
    width: fit-content;
}

.app-redirect-link:hover {
    color: #0ea5e9;
    transform: translateX(2px);
}

/* Custom Grid Scaling & ID Handling */
.small-text {
    font-size: 11px !important;
    color: var(--text-secondary) !important;
    opacity: 0.8;
}


.badge-format {
    background: #f1f5f9;
    color: #475569;
    padding: 2px 8px;
    border-radius: 6px;
    font-size: 10px;
    font-weight: 700;
    border: 1px solid #e2e8f0;
}

.badge-net {
    background: #eff6ff;
    color: #2563eb;
    padding: 2px 8px;
    border-radius: 6px;
    font-size: 10px;
    font-weight: 700;
    border: 1px solid #dbeafe;
}

.app-redirect-link i {
    opacity: 0.6;
    transition: opacity 0.2s;
}

.app-redirect-link:hover i {
    opacity: 1;
}

.country-performance-card {
    border-radius: 20px;
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.4);
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.04), 0 4px 6px -4px rgba(0, 0, 0, 0.02);
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(12px);
}

.app-redirect-link {
    display: flex;
    align-items: center;
    gap: 4px;
    color: #64748b;
    font-size: 0.75rem;
    font-weight: 600;
    text-decoration: none;
    transition: all 0.2s;
}

.app-redirect-link span {
    border-bottom: 1px solid transparent;
}

.app-redirect-link:hover {
    color: #0ea5e9;
}

.app-redirect-link:hover span {
    border-bottom-color: #0ea5e9;
}





.text-right {
    text-align: right !important;
    display: flex;
    justify-content: flex-end;
    align-items: center;
}

/* PREMIUM LOADER */
.global-loader {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.35);
    backdrop-filter: blur(6px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

.global-loader.hidden {
    display: none;
}

.loader-content {
    text-align: center;
    color: #fff;
    font-weight: 500;
    letter-spacing: 0.3px;
}

.loader-dots {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin-bottom: 12px;
}

.loader-dots span {
    width: 10px;
    height: 10px;
    background: #ffffff;
    border-radius: 50%;
    animation: bounce 0.6s infinite alternate;
}

.loader-dots span:nth-child(2) {
    animation-delay: 0.2s;
}

.loader-dots span:nth-child(3) {
    animation-delay: 0.4s;
}

/* Table-Specific Loader Styles */
.grid-loader-overlay {
    position: absolute;
    inset: 0;
    background: rgba(255, 255, 255, 0.7);
    backdrop-filter: blur(2px);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 100;
    border-radius: 16px;
    transition: opacity 0.3s ease;
}

.grid-loader-overlay.hidden {
    display: none;
    opacity: 0;
}

.grid-loader-spinner {
    width: 32px;
    height: 32px;
    border: 3px solid #f1f5f9;
    border-top-color: #0ea5e9;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin-bottom: 10px;
}

.grid-loader-text {
    font-size: 0.85rem;
    font-weight: 500;
    color: #475569;
}

/* Legacy App Cell removed (Duplicate) */


@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

@keyframes bounce {
    from {
        transform: translateY(0);
        opacity: 0.6;
    }

    to {
        transform: translateY(-8px);
        opacity: 1;
    }
}



.ag-theme-alpine .ag-cell {
    display: flex;
    align-items: center;
    padding-top: 0 !important;
    padding-bottom: 0 !important;
}

.ag-theme-alpine .ag-cell-wrapper {
    width: 100%;
}


.ag-theme-alpine .header-emerald .ag-header-cell-label,
.ag-theme-alpine .header-blue .ag-header-cell-label {
    color: #334155 !important;
    font-weight: 700 !important;
    font-size: 12px !important;
    white-space: normal !important;
    line-height: 1.2 !important;
    width: 100%;
}

.ag-theme-alpine .ag-header-cell-text {
    overflow: visible !important;
    white-space: normal !important;
}

/* Pinned Top Summary Row styling */
.ag-theme-alpine .ag-floating-top {
    background-color: #ffffff !important;
    border-top: none !important;
    border-bottom: 2px solid #e2e8f0 !important;
    /* Subtle separator from data */
}

.ag-theme-alpine .ag-floating-top .ag-row {
    background-color: #ffffff !important;
    font-weight: 700 !important;
    color: #1e293b !important;
    font-size: 14px !important;
    border-bottom: none !important;
}

/* Allow cellStyle borders (the colored bars) to show on pinned cells */
.ag-theme-alpine .ag-floating-top .ag-cell {
    border-top: none !important;
    border-left: none !important;
    border-right: none !important;
    /* NO vertical lines in summary row */
    /* Do NOT set border-bottom: none !important here, let JS cellStyle handle it */
    background-color: #ffffff !important;
}

.ag-theme-alpine .ag-floating-top .ag-cell-label-container {
    padding-bottom: 4px;
    /* Space for the bar */
}

/* Header Bars - REMOVED from headers (moved to pinned row bottom) */
.ag-theme-alpine .header-with-emerald-bar,
.ag-theme-alpine .header-with-blue-bar {
    border-bottom: none !important;
    padding-bottom: 0 !important;
}

/* COLUMN SEPARATION - Create small gaps between columns using white borders */
.ag-theme-alpine .ag-header-cell,
.ag-theme-alpine .ag-header-group-cell,
.ag-theme-alpine .ag-floating-top .ag-cell,
.ag-theme-alpine .ag-cell {
    border-right: 5px solid #ffffff !important;
}

/* Show horizontal borders for each row as requested */
.ag-theme-alpine .ag-row {
    border-bottom: 2px solid #e2e8f0 !important;
}

/* Re-enabled horizontal scrollbar from the grid */
/* .ag-theme-alpine .ag-body-horizontal-scroll,
.ag-theme-alpine .ag-horizontal-left-spacer,
.ag-theme-alpine .ag-horizontal-right-spacer {
    display: none !important;
    height: 0 !important;
    overflow: hidden !important;
} */

.ag-horizontal-left-spacer,
.ag-horizontal-right-spacer {
    height: 100%;
    min-width: 0;
    overflow-x: hidden;
}

/* Hide AG Grid header icons (Menu, Filter) to match clean look */
.ag-theme-alpine .ag-header-cell-menu-button,
.ag-theme-alpine .ag-header-cell-filter-button,
.ag-theme-alpine .ag-header-group-cell .ag-header-expand-icon {
    display: none !important;
}

/* Ensure colored bar headers also have the white separation gap */
.header-with-emerald-bar,
.header-with-blue-bar {
    border-right: 2px solid #ffffff !important;
}




/* Hover effects for column headers */
.ag-theme-alpine .ag-header-cell:hover {
    background: #f8fafc !important;
}

/* Ensure the group header text is visible */
.ag-theme-alpine .ag-header-group-cell .ag-header-group-cell-label {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
}

/* Add subtle shadow for depth */
.ag-theme-alpine .ag-header-group-cell {
    box-shadow: inset 0 -2px 0 rgba(0, 0, 0, 0.05);
}

/* Column Content Alignment */
.left-align {
    text-align: left !important;
    justify-content: flex-start !important;
    display: flex !important;
    align-items: center !important;
}

.center-align {
    text-align: center !important;
    justify-content: center !important;
    display: flex !important;
    align-items: center !important;
}

.right-align {
    text-align: right !important;
    justify-content: flex-end !important;
    display: flex !important;
    align-items: center !important;
}

/* Ensure header labels inherit alignment */
.left-align .ag-header-cell-label {
    justify-content: flex-start !important;
}

.center-align .ag-header-cell-label {
    justify-content: center !important;
}

.right-align .ag-header-cell-label {
    justify-content: flex-end !important;
}

.left-align .ag-cell-value,
.center-align .ag-cell-value,
.right-align .ag-cell-value {
    width: 100%;
}

/* ============================================================
   COLUMN GROUP HEADERS (Dimensions / Metrics banners)
   ============================================================ */

/* Base group header */
.ag-theme-alpine .ag-header-group-cell {
    font-weight: 700 !important;
    font-size: 11px !important;
    letter-spacing: 0.8px !important;
    text-transform: uppercase !important;
}

/* Hide expand/collapse icon so groups stay fixed */
.ag-theme-alpine .ag-header-group-cell .ag-header-expand-icon {
    display: none !important;
}

/* DIMENSIONS group header — emerald theme */
.ag-theme-alpine .ag-header-group-cell.dim-group-header {
    background: linear-gradient(90deg, #f0fdf4 0%, #dcfce7 100%) !important;
    color: #15803d !important;
    border-left: 3px solid #22c55e !important;
    border-bottom: 2px solid #86efac !important;
}

.ag-theme-alpine .ag-header-group-cell.dim-group-header .ag-header-group-cell-label {
    justify-content: flex-start !important;
    padding-left: 8px !important;
    gap: 6px !important;
}

/* METRICS group header — blue theme */
.ag-theme-alpine .ag-header-group-cell.metric-group-header {
    background: linear-gradient(90deg, #eff6ff 0%, #dbeafe 100%) !important;
    color: #1d4ed8 !important;
    border-left: 3px solid #3b82f6 !important;
    border-bottom: 2px solid #93c5fd !important;
}

.ag-theme-alpine .ag-header-group-cell.metric-group-header .ag-header-group-cell-label {
    justify-content: flex-start !important;
    padding-left: 8px !important;
    gap: 6px !important;
}

/* ============================================================
   COLUMN SEPARATOR (small colored space between columns)
   ============================================================ */

/* Dimension column separator — right border in emerald */
.ag-theme-alpine .ag-cell.col-sep-right {
    border-right: 2px solid #e2e8f0 !important;
}

/* Header separator — right border in matching color */
.ag-theme-alpine .ag-header-cell.col-sep-right {
    border-right: 2px solid #e2e8f0 !important;
}

/* Hover separator accent */
.ag-theme-alpine .ag-row:hover .ag-cell.col-sep-right {
    border-right-color: #cbd5e1 !important;
}


.green-text {
    color: #059669;
    font-weight: 600;
}

/* Badge styles for different eCPM ranges */
.badge-low {
    background: #fee2e2;
    color: #991b1b;
    padding: 4px 10px;
    border-radius: 20px;
    font-weight: 600;
    font-size: 12px;
    display: inline-block;
}

.badge-mid {
    background: #fef3c7;
    color: #92400e;
    padding: 4px 10px;
    border-radius: 20px;
    font-weight: 600;
    font-size: 12px;
    display: inline-block;
}

.badge-high {
    background: #d1fae5;
    color: #065f46;
    padding: 4px 10px;
    border-radius: 20px;
    font-weight: 600;
    font-size: 12px;
    display: inline-block;
}

/* Badge for ad format */
.badge-format {
    background: #f1f5f9;
    color: #475569;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.3px;
    display: inline-block;
}

/* App cell styling */
.app-cell-pro {
    display: flex;
    align-items: center;
    gap: 8px;
    height: 100%;
    width: 100%;
    overflow: visible;
}

.app-icon-box {
    width: 22px !important;
    height: 22px !important;
    border-radius: 4px !important;
    overflow: hidden;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.app-icon-img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.app-text-area {
    display: flex;
    flex-direction: column;
    justify-content: center;
    overflow: visible;
    min-width: 0;
}

.app-title {
    font-weight: 500;
    color: #2563eb;
    font-size: 13px !important;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    text-decoration: none;
}

.app-link {
    display: flex;
    align-items: center;
    gap: 4px;
    color: #64748b;
    font-size: 12px;
    text-decoration: none;
    transition: color 0.2s;
}

.app-link:hover {
    color: #0ea5e9;
}

.arrow {
    font-size: 14px;
    line-height: 1;
}

/* Consolidated duplicated filter sections */
.filter-pill {
    display: flex;
    align-items: center;
    justify-content: center;
    background: #ffffff;
    border-radius: 20px;
    padding: 4px 14px;
    gap: 8px;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    border: 1px solid #e2e8f0;
    height: 34px;
    min-height: 34px;
    min-width: 120px;
    cursor: pointer;
    position: relative;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.03);
}

.pill-label {
    font-size: 11px;
    font-weight: 600;
    color: #475569;
    white-space: nowrap;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.pill-select,
.pill-input {
    background: transparent;
    border: none;
    font-size: 11px;
    color: #1e293b;
    outline: none;
    cursor: pointer;
    font-weight: 600;
    padding: 0;
    max-width: 200px;
    font-family: 'Inter', sans-serif;
}

.filter-pill:hover {
    background: #f8fafc;
    border-color: #cbd5e1;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

/* Active state — when a filter value is selected */
.filter-pill.has-value {
    background: #e0f2fe;
    border-color: #7dd3fc;
    box-shadow: 0 2px 6px rgba(14, 165, 233, 0.12);
    padding-right: 28px;
    /* Space for the clear button */
}

.filter-pill.has-value .pill-label {
    display: none;
    /* Hide label when value is selected */
}

.filter-pill.has-value .pill-select,
.filter-pill.has-value .pill-input {
    color: #0c4a6e;
    font-weight: 700;
}

.pill-label {
    font-size: 11px;
    font-weight: 600;
    color: #475569;
    white-space: nowrap;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.pill-select,
.pill-input {
    background: transparent;
    border: none;
    font-size: 11px;
    color: #1e293b;
    outline: none;
    cursor: pointer;
    font-weight: 600;
    padding: 0;
    max-width: 200px;
    font-family: 'Inter', sans-serif;
}

.pill-input {
    width: 150px;
}

/* More Options Restoration */
.filter-more-options {
    position: relative;
    margin-left: 4px;
}

.more-btn {
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 50%;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: #94a3b8;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.more-btn:hover {
    background: #f8fafc;
    color: var(--accent-primary);
    border-color: #cbd5e1;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

.more-btn i {
    width: 18px;
    height: 18px;
}

/* Dropdown Restyling to match clean capsule aesthetic */

.more-options-dropdown.show {
    display: block;
    animation: fadeIn 0.15s ease-out;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(-5px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.dropdown-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    color: #475569;
    font-size: 13px;
    font-weight: 500;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    width: 100%;
    background: transparent;
    border: none;
}

.dropdown-item:hover {
    background: #f1f5f9;
    color: #0f172a;
}

.dropdown-item i {
    width: 16px;
    height: 16px;
    color: #94a3b8;
}

.dropdown-divider {
    height: 1px;
    background: #f1f5f9;
    margin: 4px 0;
}

.switch-sm {
    position: relative;
    display: inline-block;
    width: 30px;
    height: 16px;
    margin-left: auto;
}

.switch-sm input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider-sm {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #e2e8f0;
    transition: .3s;
    border-radius: 20px;
}

.slider-sm:before {
    position: absolute;
    content: "";
    height: 12px;
    width: 12px;
    left: 2px;
    bottom: 2px;
    background-color: white;
    transition: .3s;
    border-radius: 50%;
}

input:checked+.slider-sm {
    background-color: #3b82f6;
}

input:checked+.slider-sm:before {
    transform: translateX(14px);
}

.dropdown-item:hover i {
    color: #3b82f6;
}

.dropdown-divider {
    height: 1px;
    background: #f1f5f9;
    margin: 6px 0;
}

/* Custom switch for Compare toggle */
.switch-sm {
    position: relative;
    display: inline-block;
    width: 32px;
    height: 18px;
}

.switch-sm input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider-sm {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #e2e8f0;
    transition: .4s;
    border-radius: 34px;
}

.slider-sm:before {
    position: absolute;
    content: "";
    height: 14px;
    width: 14px;
    left: 2px;
    bottom: 2px;
    background-color: white;
    transition: .4s;
    border-radius: 50%;
}

input:checked+.slider-sm {
    background-color: #3b82f6;
}

input:checked+.slider-sm:before {
    transform: translateX(14px);
}

/* --- Select2 High-Fidelity Override for Pills --- */
.filter-pill .select2-container--default .select2-selection--multiple {
    background-color: transparent !important;
    border: none !important;
    padding: 0 !important;
    min-height: auto !important;
    display: flex;
    align-items: center;
}

.toolbar-segment .select2-container--default .select2-selection--multiple .select2-selection__rendered {
    padding: 0 !important;
    display: flex;
    flex-wrap: nowrap !important;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    width: 100%;
    margin: 0 !important;
}

.toolbar-segment .select2-container--default .select2-selection--multiple .select2-selection__choice {
    background-color: transparent !important;
    border: none !important;
    margin: 0 !important;
    padding: 0 !important;
    color: #1e293b !important;
    font-weight: 600 !important;
    font-size: 13px !important;
}

.toolbar-segment .select2-container--default .select2-selection--multiple .select2-selection__choice__remove {
    display: none !important;
}

.toolbar-segment .select2-container--default .select2-search--inline {
    display: none !important;
}

.more-options-segment:hover {
    background: #e2e8f0;
}

/* Unified More Button Style */
.more-btn {
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 50%;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: #94a3b8;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.03);
}

.more-btn:hover {
    background: #f8fafc;
    color: var(--accent-primary);
    border-color: #cbd5e1;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
    transform: translateY(-1px);
}

.filter-actions-compact {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
}

.primary-btn-sm {
    background: #3b82f6;
    color: white;
    border: none;
    padding: 5px 15px;
    border-radius: 15px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
}

.outline-btn-sm {
    background: transparent;
    color: #64748b;
    border: 1px solid #e2e8f0;
    padding: 5px 15px;
    border-radius: 15px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
}


/* Dashboard Main Container (Grid + Sidebar) */
.dashboard-main-container {
    display: flex;
    gap: 20px;
    /* Increased gap */
    flex: 1;
    /* min-height: 0; */
    min-width: 0;
    margin-top: 16px;
    /* Space between header and content */
}

@media (max-width: 1024px) {
    .dashboard-main-container {
        flex-direction: column;
        gap: 24px;
        /* Maintain space between stacked elements */
    }

    .sidebar-filters {
        width: 100% !important;
        order: -1;
    }
}

.grid-card {
    flex: 1;
    padding: 0 !important;
    overflow: hidden;
    min-width: 0;
    /* Add this to prevent expansion */
    background: #ffffff;
    border: none;
    border-radius: 12px;
}

/* Sidebar Filters (Right) */
.sidebar-filters {
    width: 300px;
    /* Increased size as requested */
    background: var(--bg-surface);
    border: 1px solid var(--border-soft);
    border-radius: 16px;
    padding: 24px 20px;
    display: flex;
    flex-direction: column;
    gap: 24px;
    height: 100%;
    box-shadow: var(--premium-shadow);
}

.sidebar-section {
    display: flex;
    flex-direction: column;
    gap: 12px;
    flex: 1;
    /* Equal 50/50 split */
    /* min-height: 0; */
    /* Critical for inner scrolling */
}

.section-title {
    font-size: 11px;
    font-weight: 700;
    color: #94a3b8;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    margin-bottom: 4px;
}

.dimension-list,
.metric-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    overflow-y: auto;
    /* Independent scrolling */
    padding-right: 4px;
}

/* Custom internal scrollbar */
.dimension-list::-webkit-scrollbar,
.metric-list::-webkit-scrollbar {
    width: 4px;
}

.dimension-list::-webkit-scrollbar-thumb,
.metric-list::-webkit-scrollbar-thumb {
    background: #e2e8f0;
    border-radius: 10px;
}

.dim-pill,
.metric-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 16px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-soft);
    background: rgba(255, 255, 255, 0.4);
    color: var(--text-primary);
    font-size: 13px;
    font-weight: 500;
    cursor: grab;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.02);
}

.dim-pill:hover,
.metric-item:hover {
    background: #ffffff;
    border-color: var(--brand-primary);
    transform: translateX(4px);
    box-shadow: 0 4px 12px rgba(15, 23, 42, 0.05);
}

.dim-pill.active {
    background: rgba(16, 185, 129, 0.1);
    border-color: rgba(16, 185, 129, 0.3);
    color: #065f46;
}

.metric-item.active {
    background: rgba(14, 165, 233, 0.1);
    border-color: rgba(14, 165, 233, 0.3);
    color: #0369a1;
}

.dim-pill.active::before,
.metric-item.active::before {
    content: "";
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 3px;
    height: 60%;
    border-radius: 0 4px 4px 0;
}

.dim-pill.active::before {
    background: #10b981;
}

.metric-item.active::before {
    background: #0ea5e9;
}

.dim-pill:hover,
.metric-item:hover {
    background: #f8fafc;
    border-color: var(--accent-primary);
    transform: translateX(4px);
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
}

.drag-handle {
    width: 16px;
    height: 16px;
    color: #94a3b8;
    cursor: grab;
    flex-shrink: 0;
}

.drag-handle:active {
    cursor: grabbing;
}

.pin-icon {
    margin-left: auto;
    width: 14px;
    height: 14px;
    color: #cbd5e1;
}

.pin-icon.active {
    color: #1e293b;
}

/* SortableJS Ghost Class */
.sortable-ghost {
    opacity: 0.4;
    background: #f1f5f9 !important;
    border: 1px dashed #3b82f6 !important;
}

/* AG Grid Custom Header Enhancement */
.custom-header-comp {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    gap: 2px;
}

.header-summary-val {
    font-size: 13px;
    font-weight: 600;
    color: #1e293b;
}

.header-label-text {
    font-size: 11px;
    font-weight: 600;
    /* Slightly bolder */
    color: #475569;
    text-transform: none;
}

/* emerald for Dimensions */
.header-emerald {
    background: #ffffff !important;
}

/* Blue for Metrics */
.header-blue {
    background: #ffffff !important;
}

/* No color bars on header cells — bars only on pinned summary row (handled by col-id rules) */
.header-with-blue-bar::after,
.header-with-emerald-bar::after {
    content: none;
}

/* Pinned Top Row — font sizing only (border handled by col-id rules above) */
.ag-theme-alpine .ag-floating-top .ag-row {
    background-color: #ffffff !important;
    font-weight: 700 !important;
    color: #334155 !important;
    font-size: 14px !important;
}

.ag-theme-alpine .ag-floating-top .ag-cell {
    font-size: 13px !important;
}

/* Hide default AG Grid sidebars since we have our own */
.ag-side-bar {
    display: none !important;
}

/* ==========================================================================
   Premium Select2 Redesign ("Ui Full")
   ========================================================================== */

/* Main selection container - Forced to behave like a clean pill */
.select2-container--default .select2-selection--multiple {
    background-color: transparent !important;
    border: none !important;
    height: 24px !important;
    min-height: 24px !important;
    display: flex !important;
    align-items: center !important;
    padding: 0 !important;
    cursor: pointer !important;
    font-size: 11px !important;
    font-family: 'Inter', sans-serif !important;
    color: #334155 !important;
    overflow: visible !important;
    position: relative !important;
}

/* Clear Button (The "x") Refinement */
.select2-container--default .select2-selection--multiple .select2-selection__clear {
    position: absolute !important;
    right: -22px !important;
    /* Position relative to the selection text, but fits in the pill's right padding */
    top: 50% !important;
    transform: translateY(-50%) !important;
    margin: 0 !important;
    padding: 0 !important;
    color: #3b82f6 !important;
    font-weight: bold !important;
    font-size: 14px !important;
    width: 20px !important;
    height: 20px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    background: rgba(59, 130, 246, 0.1) !important;
    border-radius: 50% !important;
    transition: all 0.2s !important;
    line-height: 1 !important;
    cursor: pointer !important;
}

.select2-container--default .select2-selection--multiple .select2-selection__clear:hover {
    background: rgba(14, 165, 233, 0.2) !important;
    color: #0284c7 !important;
}

/* Selection Text Styling (The Summary Inside the Pill) */
.select2-container--default .select2-selection--multiple .select2-selection__rendered {
    display: flex !important;
    align-items: center !important;
    padding: 0 !important;
    margin: 0 !important;
    white-space: nowrap !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    width: 100% !important;
    color: #475569 !important;
    font-weight: 500 !important;
    height: 100% !important;
    line-height: normal !important;
}

/* Individual Tags (We use TemplateSelection to hide all except the first one) */
.select2-container--default .select2-selection--multiple .select2-selection__choice {
    background: transparent !important;
    border: none !important;
    margin: 0 !important;
    padding: 0 !important;
    font-size: 11px !important;
    font-weight: 600 !important;
    color: #0c4a6e !important;
    /* Darker blue for visibility */
    display: flex !important;
    align-items: center !important;
}

/* Hide the 'x' remove button on tags inside the pill to keep it clean */
.select2-container--default .select2-selection--multiple .select2-selection__choice__remove {
    display: none !important;
}

/* Clear button (the 'x' that clears everything) */
.select2-container--default .select2-selection--clear {
    position: absolute !important;
    right: 6px !important;
    top: 50% !important;
    transform: translateY(-50%) !important;
    width: 14px !important;
    height: 14px !important;
    background: #f1f5f9 !important;
    border-radius: 50% !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    color: #94a3b8 !important;
    font-size: 9px !important;
    font-weight: 800 !important;
    z-index: 10 !important;
    cursor: pointer !important;
    transition: all 0.2s ease !important;
    border: 1px solid #e2e8f0 !important;
    line-height: 1 !important;
    margin: 0 !important;
}

.select2-container--default .select2-selection--clear:hover {
    background: #fee2e2 !important;
    color: #ef4444 !important;
    border-color: #fecaca !important;
}

/* Dropdown Container */
.select2-dropdown {
    border: 1px solid #e2e8f0 !important;
    border-radius: 12px !important;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05) !important;
    overflow: hidden !important;
    z-index: 9999 !important;
    background: #ffffff !important;
    margin-top: 5px !important;
    padding: 4px !important;
}

/* Dropdown Search Box */
.select2-container--default .select2-search--dropdown {
    padding: 8px !important;
}

.select2-container--default .select2-search--dropdown .select2-search__field {
    border: 1px solid #f1f5f9 !important;
    background-color: #f8fafc !important;
    border-radius: 8px !important;
    padding: 8px 12px !important;
    outline: none !important;
    font-size: 12px !important;
    font-family: 'Inter', sans-serif !important;
}

/* Results Container */
.select2-results__options {
    max-height: 250px !important;
    padding: 4px !important;
}

/* Individual Result Item */
.select2-results__option {
    padding: 8px 12px !important;
    font-size: 12px !important;
    color: #475569 !important;
    border-radius: 6px !important;
    margin-bottom: 1px !important;
    transition: all 0.2s ease !important;
}

.select2-container--default .select2-results__option--selected {
    background-color: transparent !important;
}

.select2-container--default .select2-results__option--selected,
.select2-container--default .select2-results__option--selected:hover {
    background-color: transparent !important;
}


/* Checkbox Style UI */
.select2-result-checkbox {
    display: flex !important;
    align-items: center !important;
    gap: 10px !important;
}

.checkmark-box {
    width: 16px !important;
    height: 16px !important;
    border: 1px solid #cbd5e1 !important;
    border-radius: 4px !important;
    background: #ffffff !important;
    position: relative !important;
    flex-shrink: 0 !important;
    transition: all 0.2s ease !important;
}

/* Neutralize hover background change and prevent text selection */
.select2-results__option {
    user-select: none !important;
    -webkit-user-select: none !important;
    -moz-user-select: none !important;
    -ms-user-select: none !important;
    cursor: pointer !important;
}

/* Force transparency on highlighted (hover) state with higher specificity */
.select2-container--default .select2-results__option--highlighted,
.select2-container--default .select2-results__option--highlighted:hover,
.select2-results__option--highlighted {
    background-color: transparent !important;
    color: inherit !important;
}

.select2-results__option--highlighted .checkmark-box,
.select2-container--default .select2-results__option--highlighted .checkmark-box {
    border-color: #cbd5e1 !important;
}

/* Selected State — FORCE persistence even on hover */
.select2-results__option--selected,
.select2-results__option--selected.select2-results__option--highlighted {
    background-color: #f0f9ff !important;
    color: #0369a1 !important;
}

.select2-results__option--selected .checkmark-box,
.select2-results__option--selected.select2-results__option--highlighted .checkmark-box {
    background-color: #0ea5e9 !important;
    border-color: #0ea5e9 !important;
}

/* Keep checkmark visible */
.select2-results__option--selected .checkmark-box::after,
.select2-results__option--selected.select2-results__option--highlighted .checkmark-box::after {
    display: block !important;
}

/* Add checkmark icon */
.select2-results__option--selected .checkmark-box::after {
    content: '' !important;
    position: absolute !important;
    left: 5px !important;
    top: 2px !important;
    width: 4px !important;
    height: 8px !important;
    border: solid white !important;
    border-width: 0 2px 2px 0 !important;
    transform: rotate(45deg) !important;
    display: block !important;
}

/* Prevent custom UI elements from blocking click */
.select2-result-checkbox,
.checkmark-box,
.result-text {
    pointer-events: none !important;
}

/* Result Text */
.result-text {
    font-weight: 500 !important;
}

/* Consistent width for filter pills in the bar */
.pill-filter-bar .select2-container {
    min-width: 140px !important;
    margin-right: 2px !important;
}

/* Fix for Select2 in filter pills */
.filter-pill .select2-container {
    flex: 1 !important;
    min-width: 0 !important;
    position: absolute !important;
    opacity: 0 !important;
    pointer-events: none !important;
}

.filter-pill.has-value .select2-container,
.filter-pill.dropdown-open .select2-container {
    position: static !important;
    opacity: 1 !important;
    pointer-events: auto !important;
    display: block !important;
}



/* Custom Search in Dropdown (Matching Reference Image) */
.custom-search-wrapper {
    padding: 10px 12px 10px !important;
    background: #ffffff !important;
    border-bottom: 1px solid #f1f5f9 !important;
    position: sticky !important;
    top: 0 !important;
    z-index: 10 !important;
}

/* Loader in Dropdown Results Area */
.select2-dropdown.loading .select2-results {
    position: relative;
    min-height: 120px;
    display: flex;
    flex-direction: column;
}

.select2-dropdown.loading .select2-results::after {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    width: 24px;
    height: 24px;
    margin: -12px 0 0 -12px;
    border: 3px solid rgba(14, 165, 233, 0.1);
    border-top-color: var(--accent-primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    z-index: 20;
}

/* Blur results while loading */
.select2-dropdown.loading .select2-results__options {
    opacity: 0.3;
    pointer-events: none;
    filter: blur(1px);
}

.custom-dropdown-search {
    width: 100% !important;
    height: 38px !important;
    padding: 10px 14px !important;
    border: 1px solid #cbd5e1 !important;
    border-radius: 6px !important;
    font-size: 13px !important;
    font-family: 'Outfit', sans-serif !important;
    background-color: #ffffff !important;
    outline: none !important;
    transition: all 0.2s ease !important;
    color: #334155 !important;
    box-sizing: border-box !important;
}

.custom-dropdown-search::placeholder {
    color: #94a3b8 !important;
    font-weight: 400 !important;
}

.custom-dropdown-search:focus {
    border-color: #3b82f6 !important;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1) !important;
}

/* Hide standard Select2 search in multi-select since we use custom */
.select2-container--default .select2-search--inline {
    display: none !important;
}

/* Scrollbar for dropdown */
.select2-results__options::-webkit-scrollbar {
    width: 6px !important;
}



.select2-results__options::-webkit-scrollbar-track {
    background: transparent !important;
}

.select2-results__options::-webkit-scrollbar-thumb {
    background: #e2e8f0 !important;
    border-radius: 10px !important;
}

.select2-results__options::-webkit-scrollbar-thumb:hover {
    background: #cbd5e1 !important;
}

.select2-container .select2-selection--multiple .select2-selection__clear {
    background-color: transparent;
    border: none;
    font-size: 1em;
    margin: 7px;
}


/* Ensure AG Grid fits the container */
#countryGrid {
    height: 100%;
    width: 100%;
}

/* Remove AG Grid Borders */
.ag-theme-alpine {
    --ag-border-color: transparent !important;
    --ag-secondary-border-color: transparent !important;
    --ag-row-border-color: #f1f5f9 !important;
    /* Keep subtle row lines */
}

.ag-theme-alpine .ag-root-wrapper {
    border: none !important;
}

.ag-theme-alpine .ag-cell {
    border-right: none !important;
}

.ag-theme-alpine .ag-header {
    background-color: #f8fafc !important;
    border-bottom: 1px solid var(--border-soft) !important;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 700;
}

.ag-theme-alpine .ag-header-cell-label {
    color: #64748b !important;
}

.ag-theme-alpine .ag-row {
    transition: background-color 0.2s ease;
}

.ag-theme-alpine .ag-row:hover {
    background-color: rgba(14, 165, 233, 0.02) !important;
}

.ag-theme-alpine .ag-cell {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-primary);
    display: flex;
    align-items: center;
}

.center-align {
    text-align: center !important;
    justify-content: center !important;
    display: flex !important;
    align-items: center !important;
}

.center-align .ag-header-cell-label {
    justify-content: center !important;
    text-align: center !important;
    width: 100%;
}

.center-align .ag-cell-value,
.center-align .ag-group-value {
    text-align: center;
    width: 100%;
}



/* === COMPLETE RESPONSIVE REFINEMENTS === */

/* Large Screens */
@media (min-width: 1440px) {
    .sidebar-filters {
        width: 240px;
    }
}

/* Tablets and Below (1024px) */
@media (max-width: 1024px) {
    .header-content-wrapper {
        padding: 12px !important;
    }

    .header-search {
        width: 180px !important;
    }

    .dashboard-main-container {
        flex-direction: column;
        gap: 12px;
    }

    /* Sidebar Filters become a horizontal row of pills on tablet */
    .sidebar-filters {
        width: 100% !important;
        height: auto !important;
        position: static !important;
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 12px;
        padding: 12px;
        overflow-y: visible;
    }

    .sidebar-section {
        gap: 8px;
    }

    /* Dimension/Metric pills become smaller on tablet */
    .dim-pill,
    .metric-item {
        padding: 6px 10px;
        font-size: 12px;
    }



    #countryGrid {
        height: 420px;
        min-height: 420px;
    }
}

/* Mobile Screens (768px) */
@media (max-width: 768px) {
    .header-search {
        width: 140px !important;
    }

    /* Stack Dimension + Metric panels vertically on mobile */
    .sidebar-filters {
        grid-template-columns: 1fr;
    }

    /* On mobile, show dimensions as horizontal scrollable chip row */
    .dimension-list,
    .metric-list {
        flex-direction: row;
        flex-wrap: wrap;
        gap: 6px;
    }

    .dim-pill,
    .metric-item {
        width: auto;
        flex: 0 0 auto;
        padding: 5px 10px;
        font-size: 12px;
    }

    .compact-filters {
        flex-wrap: wrap;
        width: 100%;
        gap: 8px;
    }

    .ghost-select {
        flex: 1;
        min-width: 100px;
    }

    .filter-more-options {
        margin-left: 0;
        width: 100%;
        display: flex;
        justify-content: flex-end;
    }

    .ag-theme-alpine {
        --ag-font-size: 12px;
    }

    /* Fix Pagination for Mobile */
    .ag-theme-alpine .ag-paging-panel {
        flex-wrap: wrap;
        justify-content: center;
        gap: 8px;
        padding: 10px 5px !important;
    }

    .ag-theme-alpine .ag-paging-row-summary-panel {
        display: none;
    }

    .ag-paging-button.processing-pagination {
        cursor: wait !important;
        background-color: rgba(14, 165, 233, 0.05) !important;
    }




    #countryGrid {
        height: 360px;
        min-height: 360px;
    }

    .advanced-filter-section {
        padding: 10px 12px;
    }

    .filter-actions-compact {
        justify-content: stretch;
    }

    .primary-btn-sm,
    .outline-btn-sm {
        flex: 1;
        text-align: center;
    }
}

/* Extra Small Screens (480px) */
@media (max-width: 480px) {
    .header-content-wrapper {
        padding: 12px 10px !important;
    }

    .header-search {
        width: 110px !important;
    }

    .header-search {
        width: 100% !important;
    }

    .header-user-actions {
        justify-content: center;
        width: 100%;
    }



    #countryGrid {
        height: 320px;
        min-height: 320px;
    }

    .header-breadcrumb h1 {
        font-size: 15px;
    }

    .section-title {
        font-size: 11px;
    }
}

/* Custom Metric Header Styles */
.custom-header-wrapper {
    display: flex;
    flex-direction: column;
    height: 100%;
    width: 100%;
    justify-content: center;
    padding: 4px 0;
}

/* Metric columns (Revenue, Impressions) should be right-aligned */
.ag-header-cell.metric-col-header .custom-header-wrapper {
    align-items: flex-end;
    text-align: right;
}

.custom-metric-header {
    height: 100%;
    width: 100%;
    line-height: 1.2;
}

.custom-metric-header .header-label {
    font-size: 11px;
    font-weight: 500;
    color: #64748b;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 4px;
}

.custom-metric-header .header-total {
    font-size: 12px !important;
    font-weight: 600;
    color: #1e293b;
}

/* Header Alignment and Borders */
.ag-header-cell-label {
    align-items: center !important;
    height: 100% !important;
}

.dim-col-header {
    border-bottom: 3px solid #22c55e !important;
}

.metric-col-header {
    border-bottom: 3px solid #3b82f6 !important;
}

/* Ensure AG Grid header cells don't cut off our custom content */
.ag-header-cell-label {
    width: 100%;
    height: 100%;
}

/* --- Toggle Switch Styling --- */
.switch-sm {
    position: relative;
    display: inline-block;
    width: 32px;
    height: 18px;
    margin-left: auto;
}

.switch-sm input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider-sm {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #e2e8f0;
    transition: .3s;
    border-radius: 20px;
}

.slider-sm:before {
    position: absolute;
    content: "";
    height: 12px;
    width: 12px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: .3s;
    border-radius: 50%;
}

input:checked+.slider-sm {
    background-color: #0ea5e9;
}

input:focus+.slider-sm {
    box-shadow: 0 0 1px #0ea5e9;
}

input:checked+.slider-sm:before {
    transform: translateX(14px);
}

.toggle-item {
    cursor: pointer;
    display: flex !important;
    align-items: center;
    gap: 10px;
    padding-right: 12px !important;
}

.dropdown-divider {
    height: 1px;
    background: #f1f5f9;
    margin: 4px 6px;
}

/* --- Inline Trend UI & Colors --- */
.inline-trend-cell {
    display: flex !important;
    flex-direction: column !important;
    justify-content: center !important;
    line-height: 1.2 !important;
    height: 100% !important;
    text-align: right !important;
    padding-right: 8px !important;
}

.inline-trend-cell .main-val {
    font-weight: 600 !important;
    font-size: 13px !important;
    margin-bottom: 1px !important;
}

.inline-trend-cell .sub-val {
    display: inline-flex !important;
    align-items: center !important;
    gap: 4px !important;
    font-size: 10px !important;
    font-weight: 700 !important;
    padding: 1px 3px !important;
    border-radius: 4px !important;
    width: fit-content !important;
    margin-left: auto !important;
    border: none;
    /* Default Hidden logic will be handled via class toggled by JS or simply opacity */
    opacity: 1;
    transition: opacity 0.2s ease, transform 0.2s ease;
}

.comparison-hidden .sub-val {
    opacity: 0 !important;
    pointer-events: none;
    transform: translateY(2px);
}

.comparison-hidden .header-trend {
    display: none !important;
}

/* Premium Trend Colors */
.trend-up {
    color: #059669 !important;
    /* background: rgba(16, 185, 129, 0.08) !important; */
    /* border: 1px solid rgba(16, 185, 129, 0.1); */
}

.trend-down {
    color: #dc2626 !important;
    /* background: rgba(239, 68, 68, 0.08) !important; */
    /* border: 1px solid rgba(239, 68, 68, 0.1); */
}

/* Header Trend Styling */
.header-total-group {
    display: flex !important;
    align-items: center !important;
    gap: 8px !important;
}

.header-trend {
    font-size: 11px !important;
    font-weight: 600 !important;
    border: none;
}

/* Comparison Visibility Sync - display: none when hidden */
.comparison-hidden .sub-val,
.comparison-hidden .header-trend {
    display: none !important;
}

/* Custom Header Sorting Styles */
.custom-header-wrapper_root {
    width: 100%;
    cursor: pointer;
}

.custom-header-wrapper {
    display: flex;
    flex-direction: column;
    justify-content: center;
    height: 100%;
    width: 100%;
    padding: 6px 10px;
}

.header-label {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    margin-bottom: 6px;
}

.label-left {
    display: flex;
    align-items: center;
    gap: 6px;
}

.header-title-text {
    font-size: 10px;
    font-weight: 800;
    color: #64748b;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    line-height: 1;
}

.header-icon-group {
    display: none;
    /* Removed in favor of label-left + filter-btn placement */
}


/* Sorting Effect - Feature Requested */
.sorting-transition .ag-row {
    animation: rowAppearEffect 0.5s cubic-bezier(0.4, 0, 0.2, 1) forwards !important;
    opacity: 0;
}

@keyframes rowAppearEffect {
    0% {
        opacity: 0;
        transform: translateY(12px);
    }

    100% {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Staggered Row Animation - Premium feel */
.sorting-transition .ag-row:nth-child(1) {
    animation-delay: 0.04s;
}

.sorting-transition .ag-row:nth-child(2) {
    animation-delay: 0.08s;
}

.sorting-transition .ag-row:nth-child(3) {
    animation-delay: 0.12s;
}

.sorting-transition .ag-row:nth-child(4) {
    animation-delay: 0.16s;
}

.sorting-transition .ag-row:nth-child(5) {
    animation-delay: 0.20s;
}

.sorting-transition .ag-row:nth-child(n+6) {
    animation-delay: 0.24s;
}

.header-sort-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    color: #000000;
}

.header-sort-icon.active .sort-arrow {
    color: #000000;
}

.header-filter-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    border-radius: 4px;
    background: #f8fafc;
    color: #94a3b8;
    border: 1px solid #e2e8f0;
    transition: all 0.2s ease;
    cursor: pointer;
}

.header-filter-btn:hover {
    color: #1e293b;
    background: #f1f5f9;
    border-color: #cbd5e1;
}


.header-total-group {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 2px;
}

.header-total {
    font-size: 12px;
    font-weight: 600;
    color: #0f172a;
}

.header-trend {
    font-size: 11px;
    font-weight: 700;
    padding: 1px 4px;
    border-radius: 4px;
}

.custom-metric-header:hover .header-label,
.custom-metric-header:hover .header-total {
    color: var(--primary-color);
}

.header-sort-icon {
    font-size: 11px;
    opacity: 0.7;
    margin-left: 2px;
    color: var(--primary-color);
    font-weight: 800;
    cursor: pointer;
}

/* Cell Trend Labels */
.trend-cell-container {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    line-height: 1.2;
}

.cell-trend {
    font-size: 13px;
    font-weight: 500;
}

/* Header Filter Button */
.header-filter-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s ease;
    background: #f1f5f9;
    color: #64748b;
    border: 1px solid #e2e8f0;
}


.header-filter-btn:hover {
    background: #e2e8f0;
    color: #1e293b;
}

.header-filter-icon {
    width: 14px;
    height: 14px;
    stroke-width: 2.5px;
}

.comparison-col .header-sort-icon {
    margin-left: 2px;
}

/* New Standalone Comparison Badge Styling (Simplified + Vertical) */
.comparison-badge {
    display: flex !important;
    flex-direction: column !important;
    align-items: flex-end !important;
    gap: 4px !important;
    /* Added gap for "line space" as requested */
    padding: 0;
    font-weight: 600;
    font-size: 12px;
    background: transparent !important;
    border: none !important;
    transition: all 0.2s ease;
    width: 100%;
    line-height: 1.1 !important;
}

.change-pct-small {
    font-size: 11px;
    opacity: 0.95;
    /* Slightly more visible */
    font-weight: 700;
    /* Bolder for contrast */
    min-width: 70px;
    text-align: right;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 4px;
    /* Space between arrow and number */
}

/* Simplified Trend Colors */
.comparison-badge.trend-up {
    color: #10b981;
    /* Standard Success Green */
}

.comparison-badge.trend-down {
    color: #ef4444;
    /* Standard Danger Red */
}

.comparison-col {
    background-color: rgba(14, 165, 233, 0.02) !important;
    /* Extremely subtle blue tint for grouping */
    border-left: 1px solid rgba(226, 232, 240, 0.4) !important;
    /* Subtle separate line */
}

/* Metric Parent groups (Earnings, Impressions, CPM) - Right border to separate groups */
.metric-col-header {
    border-bottom: 3px solid #3b82f6 !important;
}

.comparison-hidden .comparison-col {
    display: none !important;
}

/* --- Feature 14 v2: Premium View Switcher --- */
.view-switcher {
    display: flex;
    background: #f1f5f9;
    padding: 4px;
    border-radius: 12px;
    gap: 4px;
    /* margin-right: -100px; */
    /* Offset to center relative to main space */
}

.switcher-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 10px;
    border: none;
    background: transparent;
    color: #64748b;
    font-size: 13px;
    font-weight: 600;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.switcher-btn:hover {
    color: #1e293b;
    background: rgba(255, 255, 255, 0.5);
}

.switcher-btn.active {
    background: #ffffff;
    color: #0ea5e9;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
}

.switcher-btn i {
    width: 14px;
    height: 14px;
}

/* Metric Switcher Tabs (v3) */
.chart-metric-switcher {
    display: flex;
    background: #f8fafc;
    padding: 3px;
    border-radius: 10px;
    border: 1px solid #e2e8f0;
}

.metric-tab {
    padding: 6px 14px;
    font-size: 12px;
    font-weight: 600;
    color: #64748b;
    background: transparent;
    border: none;
    border-radius: 7px;
    cursor: pointer;
    transition: all 0.2s;
}

.metric-tab:hover {
    color: #1e293b;
}

.metric-tab.active {
    background: #ffffff;
    color: #0ea5e9;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

/* Chart Type Selector (v4) */
.chart-type-selector {
    display: flex;
    background: #f8fafc;
    padding: 3px;
    border-radius: 10px;
    border: 1px solid #e2e8f0;
    margin-right: 4px;
}

.type-btn {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    border-radius: 7px;
    color: #94a3b8;
    cursor: pointer;
    transition: all 0.2s;
}

.type-btn:hover {
    color: #64748b;
}

.type-btn.active {
    background: #ffffff;
    color: #0ea5e9;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.type-btn i {
    width: 16px;
    height: 16px;
}

.hidden {
    display: none !important;
}

.chart-card {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 550px;
    max-height: 700px;
    /* Keep sizing constraint to prevent flickering */
    background: #ffffff !important;
    border-radius: 16px;
    border: 1px solid #f1f5f9;
    overflow: hidden;
}

.card-body-chart {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

#mainDashboardChart {
    width: 100% !important;
    max-height: 100% !important;
    object-fit: contain;
}

/* --- Custom Light Filter Theme (Matches User Reference Image) --- */
.ag-theme-alpine .ag-popup-child,
.ag-menu,
.ag-filter-wrapper {
    background-color: #ffffff !important;
    border: 1px solid #e2e8f0 !important;
    border-radius: 8px !important;
    color: #1e293b !important;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.08), 0 4px 6px -2px rgba(0, 0, 0, 0.04) !important;
}

/*
.ag-filter-wrapper {
    padding: 10px !important;
    min-width: 240px !important;
} */

/* Dropdown/Picker Styling */
.ag-theme-alpine .ag-picker-field-wrapper {
    background-color: #ffffff !important;
    border: 1px solid #e2e8f0 !important;
    border-radius: 6px !important;
    color: #1e293b !important;
    padding: 0 8px !important;
    height: 38px !important;
    display: flex !important;
    align-items: center !important;
    /* margin-bottom: 8px !important; */
    transition: all 0.2s ease;
}

/*
.ag-theme-alpine .ag-picker-field-wrapper:hover {
     border-color: #cbd5e1 !important; 
}*/

/* Input Styling with Magnifying Glass */
/* .ag-theme-alpine .ag-filter-body .ag-input-field-icon,
.ag-theme-alpine .ag-filter-body .ag-icon-search,
.ag-theme-alpine .ag-filter-body .ag-icon-filter,
.ag-theme-alpine .ag-floating-filter-button,
.ag-theme-alpine .ag-icon-filter {
    display: none !important;
    /* Hide ALL native icons to prevent overlap with custom background icon 
}*/

.ag-theme-alpine .ag-filter-body .ag-input-field-input {
    background-color: #ffffff !important;
    border: 1.5px solid #93c5fd !important;
    /* Clean blue border from image 2 */
    border-radius: 6px !important;
    color: #1e293b !important;
    height: 40px !important;
    padding: 0 12px 0 34px !important;
    /* Space for icon */
    font-size: 14px !important;
    /* background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="%2394a3b8" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"><circle cx="11" cy="11" r="8"/><line x1="21" y1="21" x2="16.65" y2="16.65"/></svg>') !important; */
    background-repeat: no-repeat !important;
    background-position: 10px center !important;
    transition: all 0.2s ease !important;
}

.ag-theme-alpine .ag-filter-body .ag-input-field-input:focus {
    border-color: #3b82f6 !important;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1) !important;
    outline: none !important;
}

.ag-theme-alpine .ag-filter-body .ag-input-field-input::placeholder {
    color: #94a3b8 !important;
    opacity: 0.7 !important;
    /* Matches 'image 2' subtlety */
}

/* Apply Panel Styling */
.ag-filter-apply-panel {
    border-top: 1px solid #f1f5f9 !important;
    padding: 12px 0 0 0 !important;
    margin-top: 12px !important;
    display: flex !important;
    gap: 8px !important;
    justify-content: flex-end !important;
}

.ag-theme-alpine .ag-button {
    border-radius: 6px !important;
    padding: 8px 16px !important;
    font-size: 13px !important;
    font-weight: 600 !important;
    transition: all 0.2s ease;
    border: none !important;
}

/* Secondary/Reset Button */
.ag-standard-button {
    background-color: #f1f5f9 !important;
    color: #64748b !important;
}

.ag-standard-button:hover {
    background-color: #e2e8f0 !important;
    color: #1e293b !important;
}

/* Primary/Apply Button */
.ag-filter-apply-panel .ag-button:last-child {
    background-color: #3b82f6 !important;
    color: #ffffff !important;
}

.ag-filter-apply-panel .ag-button:last-child:hover {
    background-color: #2563eb !important;
    box-shadow: 0 4px 6px -1px rgba(37, 99, 235, 0.2) !important;
}

/* Hide help/labels that clutter the screenshot look */
.ag-filter-condition {
    padding: 8px 0 !important;
}

.ag-filter-to {
    color: #64748b !important;
    font-size: 11px !important;
    text-transform: uppercase !important;
    font-weight: 700 !important;
    letter-spacing: 0.5px;
}

/* Ensure the grid cell for metrics is tall enough and centered */
.ag-cell.right-align {
    display: flex;
    align-items: center;
    justify-content: flex-end;
}

/* Toast Notification Styles */
#toast-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.toast {
    min-width: 250px;
    padding: 12px 20px;
    border-radius: 12px;
    background: #1e293b;
    color: #ffffff;
    font-size: 13px;
    font-weight: 500;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    display: flex;
    align-items: center;
    gap: 12px;
    animation: toast-in 0.3s ease-out forwards;
}

.toast.error {
    border-left: 4px solid #ef4444;
}

.toast.warning {
    border-left: 4px solid #f59e0b;
}

.toast.success {
    border-left: 4px solid #10b981;
}

@keyframes toast-in {
    from {
        transform: translateX(100%);
        opacity: 0;
    }

    to {
        transform: translateX(0);
        opacity: 1;
    }
}

.toast.fade-out {
    animation: toast-out 0.3s ease-in forwards;
}

@keyframes toast-out {
    to {
        transform: translateX(100%);
        opacity: 0;
    }
}