/* VARIABLES */
    :root {
        --color-primary: #1e3a5f;
        --color-accent: #d4af37;
        --color-success: #22c55e;
        --color-danger: #ef4444;
        --bg-body: #f5f7fa;
        --bg-card: #ffffff;
        --bg-dark: #0f1419;
        --text-primary: #1a1a2e;
        --text-secondary: #64748b;
        --text-light: #ffffff;
        --border-color: #e2e8f0;
        --radius-lg: 12px;
        --shadow-card: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
        /* Navbar height approximation for sticky positioning */
        --navbar-height: 76px;
        /* GLOBAL ACCENT */
        accent-color: var(--color-accent);
    }

    /* COMPACT FILTER BAR */
    .filter-bar {
        background: rgba(255, 255, 255, 0.75);
        backdrop-filter: blur(20px);
        -webkit-backdrop-filter: blur(20px);
        border-radius: var(--radius-lg);
        padding: 0.75rem 1rem;
        /* Compact padding */
        box-shadow: 0 8px 32px rgba(31, 38, 135, 0.07);
        border: 1px solid rgba(255, 255, 255, 0.4);
        margin-bottom: 1.5rem;
        display: flex;
        flex-wrap: wrap;
        gap: 1rem;
        /* Compact gap */
        align-items: center;
        /* Center align items */
    }

    .filter-section {
        display: flex;
        flex-direction: column;
        gap: 0.5rem;
        min-width: 150px;
    }

    .filter-section.wide {
        flex: 1;
        min-width: 250px;
    }

    .filter-label {
        font-size: 0.7rem;
        /* Smaller font */
        font-weight: 700;
        color: var(--text-secondary);
        text-transform: uppercase;
        letter-spacing: 0.5px;
        margin-bottom: 0;
        white-space: nowrap;
    }

    /* Filter Input Row in Table */
    .filter-input-row th {
        background: #f8fafc;
        padding: 0.5rem;
        border-bottom: 2px solid #cbd5e1;
        position: sticky;
        top: 45px;
        /* Below main header */
        z-index: 101;
    }

    .header-main-th {
        z-index: 102;
        height: 45px;
    }

    .filter-input-sm {
        width: 100%;
        font-size: 0.8rem;
        padding: 0.25rem 0.5rem;
        border: 1px solid #ced4da;
        border-radius: 4px;
    }

    .form-select-custom,
    .form-control-custom {
        width: 100%;
        padding: 0.5rem 0.75rem;
        border: 1px solid var(--border-color);
        border-radius: 8px;
        font-size: 0.9rem;
        background-color: #f1f5f9;
        border: 1px solid transparent;
        transition: all 0.2s ease;
        box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.02);
    }

    .form-select-custom:hover,
    .form-control-custom:hover {
        background-color: #e2e8f0;
    }

    .btn-update-table:hover {
        background: #b8972e !important;
        box-shadow: 0 6px 18px rgba(212, 175, 55, 0.5) !important;
        transform: translateY(-1px);
    }
    .btn-update-table:active {
        transform: translateY(0);
        box-shadow: 0 2px 8px rgba(212, 175, 55, 0.3) !important;
    }

    .form-select-custom:focus,
    .form-control-custom:focus {
        outline: 2px solid var(--color-primary);
        border-color: transparent;
    }

    /* Compact Slider Group */
    .slider-group {
        display: flex;
        align-items: center;
        gap: 10px;
    }

    .slider-group input[type=range] {
        flex-grow: 1;
    }

    .slider-val {
        font-size: 0.85rem;
        font-weight: 700;
        color: #d4af37;
        min-width: 50px;
        text-align: right;
    }

    /* View Tabs (Integrated into filter bar or close to it) */
    .view-tabs {
        display: flex;
        gap: 0.5rem;
        margin-bottom: 0;
        /* aligned inside bar or just below */
    }

    .view-tab-btn {
        padding: 0.5rem 1rem;
        border: 1px solid var(--border-color);
        background: transparent;
        color: var(--text-secondary);
        font-weight: 600;
        font-size: 0.85rem;
        border-radius: 50px;
        cursor: pointer;
        transition: all 0.2s;
        white-space: nowrap;
    }

    .view-tab-btn:hover {
        background: #e2e8f0;
        color: var(--color-primary);
    }

    .view-tab-btn.active {
        background: #d4af37;
        color: #ffffff;
        border-color: #d4af37;
        box-shadow: 0 4px 12px rgba(212, 175, 55, 0.4);
        transform: translateY(-1px);
    }

    /* TABLE LAYOUT — full-page, natural scroll */
    .rankings-table-container {
        width: 100%;
        position: relative;
        min-height: 500px;
        overflow-x: auto; /* horizontal scroll only; page scrolls vertically */
    }
    .rankings-table-container::-webkit-scrollbar { height: 8px; }
    .rankings-table-container::-webkit-scrollbar-track { background: rgba(0,0,0,0.08); border-radius: 4px; }
    .rankings-table-container::-webkit-scrollbar-thumb { background: rgba(100,116,139,0.6); border-radius: 4px; }
    .rankings-table-container::-webkit-scrollbar-thumb:hover { background: rgba(100,116,139,0.9); }
    /* Sparkline column */
    .sparkline-cell {
        min-width: 205px;
        padding: 0.35rem 0.75rem !important;
        vertical-align: middle;
    }

    /* Horizontal overflow hint */
    .table-scroll-fade {
        position: absolute;
        top: 0;
        right: 0;
        width: 88px;
        height: 100%;
        background: linear-gradient(to right, rgba(248, 250, 252, 0), rgba(248, 250, 252, 0.95));
        pointer-events: none;
        z-index: 5;
        transition: opacity 0.2s ease;
    }

    .table-scroll-arrow {
        position: absolute;
        right: 14px;
        top: 50%;
        transform: translateY(-50%);
        width: 22px;
        height: 22px;
        border-radius: 50%;
        display: flex;
        align-items: center;
        justify-content: center;
        background: rgba(15, 23, 42, 0.15);
        border: 1px solid rgba(15, 23, 42, 0.12);
        color: rgba(15, 23, 42, 0.75);
        font-size: 0.75rem;
        backdrop-filter: blur(4px);
        box-shadow: 0 4px 10px rgba(15, 23, 42, 0.12);
        pointer-events: none;
        z-index: 6;
        animation: scrollHintPulse 1.6s ease-in-out infinite;
        transition: opacity 0.2s ease, transform 0.2s ease;
    }

    .table-scroll-fade.hidden,
    .table-scroll-arrow.hidden {
        opacity: 0;
        transform: translateY(-2px);
    }

    @keyframes scrollHintPulse {
        0% { opacity: 0.35; transform: translateY(-50%) translateX(0); }
        50% { opacity: 1; transform: translateY(-50%) translateX(4px); }
        100% { opacity: 0.35; transform: translateY(-50%) translateX(0); }
    }

    [data-theme="dark"] .table-scroll-fade {
        background: linear-gradient(to right, rgba(15, 23, 42, 0), rgba(15, 23, 42, 0.95));
    }

    [data-theme="dark"] .table-scroll-arrow {
        background: rgba(15, 23, 42, 0.35);
        border-color: rgba(255, 255, 255, 0.08);
        color: #e2e8f0;
    }
    .table-custom {
        min-width: 900px;
    }

    .table-custom {
        width: 100%;
        border-collapse: separate;
        border-spacing: 0;
    }

    /* STICKY HEADER — JS translateY handles sticking (CSS sticky breaks with overflow-x) */
    .table-custom thead {
        position: relative;
        z-index: 500;
        will-change: transform; /* GPU compositing for smooth animation */
    }
    .table-custom thead th {
        background: #f1f5f9;
        padding: 1rem;
        font-size: 0.75rem;
        font-weight: 800;
        text-transform: uppercase;
        color: var(--text-primary);
        border-bottom: 2px solid #cbd5e1;
        box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
        cursor: pointer;
        white-space: nowrap;
    }

    .table-custom tbody td {
        background: #ffffff;
        padding: 1rem;
        font-size: 0.9rem;
        border-bottom: 1px solid var(--border-color);
        vertical-align: middle;
        color: var(--text-primary);
    }

    .table-custom tbody tr:hover td {
        background-color: #f8fafc;
    }

    /* Benchmark row — moves with thead via JS transform, no CSS sticky needed */
    .bench-row-sticky td {
        background-color: #fffbeb !important;
        border-bottom: 2px solid #fcd34d !important;
        font-weight: 700;
        color: #b45309;
        box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
        padding: 1rem;
        font-size: 0.9rem;
        vertical-align: middle;
    }

    /* UTILS */
    .rank-cell {
        width: 40px;
        text-align: center;
        font-weight: bold;
        color: var(--text-secondary);
    }

    .val-cell {
        text-align: right;
        font-family: 'Space Grotesk', monospace;
    }

    .bg-win {
        background-color: #dcfce7 !important;
        color: #166534;
        font-weight: 600;
    }

    .bg-loss {
        background-color: #fee2e2 !important;
        color: #991b1b;
        font-weight: 600;
    }

    /* Custom Scrollbar for heavy data */
    input[type=range] {
        -webkit-appearance: none;
        -moz-appearance: none;
        appearance: none;
        width: 100%;
        background: transparent;
    }

    input[type=range]::-webkit-slider-thumb {
        -webkit-appearance: none;
        height: 18px;
        width: 18px;
        background: #d4af37 !important;
        border: 2px solid #fff;
        border-radius: 50%;
        margin-top: -6px;
        cursor: pointer;
        box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
        transition: transform 0.1s ease;
    }

    input[type=range]::-webkit-slider-thumb:hover {
        transform: scale(1.2);
    }

    input[type=range]::-moz-range-thumb {
        height: 18px;
        width: 18px;
        background: #d4af37 !important;
        border: 2px solid #fff;
        border-radius: 50%;
        cursor: pointer;
        box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
    }

    input[type=range]::-webkit-slider-runnable-track {
        height: 6px;
        background: #e2e8f0;
        border-radius: 3px;
    }

    input[type=range]::-moz-range-track {
        height: 6px;
        background: #e2e8f0;
        border-radius: 3px;
    }

    .loading-overlay {
        position: absolute;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(255, 255, 255, 0.8);
        z-index: 200;
        display: flex;
        align-items: center;
        justify-content: center;
        backdrop-filter: blur(2px);
    }

    /* Custom Switch Color (Gold) */
    .form-check-input:checked {
        background-color: #d4af37 !important;
        border-color: #d4af37 !important;
    }

    /* Gold Buttons for radio groups */
    .btn-check:checked+.btn-outline-primary {
        background-color: #d4af37 !important;
        border-color: #d4af37 !important;
        color: #fff !important;
    }

    .btn-check:checked+.btn-outline-secondary {
        background-color: #d4af37 !important;
        border-color: #d4af37 !important;
        color: #fff !important;
    }

    .btn-outline-primary,
    .btn-outline-secondary {
        border-color: #e2e8f0;
        color: #64748b;
    }

    .btn-outline-primary:hover,
    .btn-outline-secondary:hover {
        background-color: #f1f5f9;
        border-color: #d4af37;
        color: #d4af37;
    }

    /* Background Pattern for Glassmorphism Context */
    body {
        background-image: radial-gradient(#cbd5e1 1px, transparent 1px);
        background-size: 24px 24px;
        background-color: #f8fafc;
    }

    /* Range Wrapper for dual sliders */
    .range-wrapper {
        position: relative;
        width: 100%;
        height: 20px;
        /* Increased height to accommodate thumbs without clipping */
        margin: 10px 0 25px 0;
        display: flex;
        align-items: center;
    }

    .range-wrapper .q-range-track-bg {
        position: absolute;
        width: 100%;
        height: 6px;
        background: #e2e8f0;
        border-radius: 3px;
        z-index: -2;
        /* Force to the bottom */
        top: 7px;
        /* Center in 20px wrapper */
        pointer-events: none;
    }

    .range-wrapper input[type="range"] {
        position: absolute;
        width: 100%;
        pointer-events: none;
        -webkit-appearance: none;
        appearance: none;
        background: none;
        top: 0;
        left: 0;
        margin: 0;
        height: 100%;
        z-index: 2;
    }

    /* Hide the default track for these specific inputs */
    .range-wrapper input[type="range"]::-webkit-slider-runnable-track {
        background: transparent !important;
        border: none !important;
        outline: none !important;
        box-shadow: none !important;
    }

    .range-wrapper input[type="range"]::-moz-range-track {
        background: transparent !important;
        border: none !important;
        outline: none !important;
        box-shadow: none !important;
    }

    .range-wrapper input[type="range"]::-ms-track {
        background: transparent !important;
        color: transparent !important;
        border: none !important;
        outline: none !important;
        box-shadow: none !important;
    }

    /* Thumb styling */
    .range-wrapper input[type="range"]::-webkit-slider-thumb {
        pointer-events: auto;
        -webkit-appearance: none;
        width: 20px;
        height: 20px;
        background: #d4af37;
        border-radius: 50%;
        cursor: pointer;
        border: 2px solid white;
        box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
        transition: transform 0.1s ease;
    }

    .range-wrapper input[type="range"]::-webkit-slider-thumb:hover {
        transform: scale(1.2);
    }

    /* Highlighted track between thumbs */
    .q-range-track-highlight {
        position: absolute;
        height: 6px;
        /* Match track height, not wrapper height */
        background: #d4af37;
        border-radius: 3px;
        z-index: -1;
        /* Behind handles, but above bg-track */
        pointer-events: none;
        /* Crucial: let clicks pass through to handles */
        top: 7px;
        /* (20px wrapper - 6px track) / 2 = 7px */
    }

    /* Hero feature badges */
    .hero-badges-grid {
        display: grid;
        grid-template-columns: repeat(4, 1fr);
        gap: 0.75rem;
    }
    @media (max-width: 1100px) {
        .hero-badges-grid { grid-template-columns: repeat(2, 1fr); }
    }
    @media (max-width: 600px) {
        .hero-badges-grid { grid-template-columns: 1fr; }
    }
    .hero-badge {
        display: flex;
        align-items: flex-start;
        gap: 0.85rem;
        background: rgba(255, 255, 255, 0.06);
        border: 1px solid rgba(255, 255, 255, 0.1);
        border-radius: 12px;
        padding: 0.9rem 1rem;
        color: #fff;
        transition: background 0.2s, border-color 0.2s;
    }
    .hero-badge:hover {
        background: rgba(255, 255, 255, 0.1);
        border-color: rgba(212, 175, 55, 0.35);
    }
    .hero-badge .hb-icon {
        font-size: 1.25rem;
        flex-shrink: 0;
        width: 22px;
        text-align: center;
        margin-top: 1px;
    }
    .hb-title {
        font-size: 0.85rem;
        font-weight: 700;
        line-height: 1.3;
        margin-bottom: 0.25rem;
    }
    .hb-sub {
        font-size: 0.75rem;
        opacity: 0.55;
        line-height: 1.45;
    }
/* Market Snapshot Bar */
                .market-snapshot {
                    display: flex;
                    align-items: center;
                    gap: 0;
                    background: linear-gradient(135deg, #f8fafc 0%, #eef2ff 100%);
                    border: 1px solid #e2e8f0;
                    border-radius: 12px;
                    padding: 0.75rem 1.25rem;
                    flex-wrap: wrap;
                }
                .snapshot-stat {
                    display: flex;
                    flex-direction: column;
                    align-items: center;
                    padding: 0 1rem;
                    min-width: 100px;
                }
                .snapshot-label {
                    font-size: 0.7rem;
                    text-transform: uppercase;
                    letter-spacing: 0.5px;
                    color: #64748b;
                    font-weight: 600;
                    white-space: nowrap;
                }
                .snapshot-value {
                    font-size: 1.1rem;
                    font-weight: 700;
                    color: #1e293b;
                }
                .snapshot-divider {
                    width: 1px;
                    height: 32px;
                    background: #cbd5e1;
                    flex-shrink: 0;
                }
                .snapshot-premium-teaser {
                    position: relative;
                    cursor: pointer;
                }
                .snapshot-premium-teaser:hover::after {
                    content: 'PRO Feature';
                    position: absolute;
                    bottom: -20px;
                    left: 50%;
                    transform: translateX(-50%);
                    font-size: 0.65rem;
                    color: #d4af37;
                    font-weight: 700;
                    white-space: nowrap;
                }
                [data-theme="dark"] .market-snapshot {
                    background: linear-gradient(135deg, #1e293b 0%, #1a1f3a 100%);
                    border-color: #334155;
                }
                [data-theme="dark"] .snapshot-value { color: #f1f5f9; }
                [data-theme="dark"] .snapshot-label { color: #94a3b8; }
                [data-theme="dark"] .snapshot-divider { background: #475569; }

                /* Premium CTA Banner */
                .premium-cta-banner {
                    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #0f3460 100%);
                    border: 1px solid rgba(212, 175, 55, 0.3);
                    border-radius: 16px;
                    padding: 2rem 2.5rem;
                    margin-top: 2rem;
                    position: relative;
                    overflow: hidden;
                }
                .premium-cta-banner::before {
                    content: '';
                    position: absolute;
                    top: -50%;
                    right: -20%;
                    width: 400px;
                    height: 400px;
                    background: radial-gradient(circle, rgba(212,175,55,0.08) 0%, transparent 70%);
                    pointer-events: none;
                }
                .premium-cta-banner h3 {
                    color: #d4af37;
                    font-weight: 700;
                    margin-bottom: 0.5rem;
                }
                .premium-cta-banner p {
                    color: #94a3b8;
                    margin-bottom: 1.25rem;
                }
                .premium-features-grid {
                    display: grid;
                    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
                    gap: 0.75rem;
                    margin-bottom: 1.5rem;
                }
                .premium-features-grid .feature-item {
                    display: flex;
                    align-items: center;
                    gap: 0.5rem;
                    color: #cbd5e1;
                    font-size: 0.85rem;
                }
                .premium-features-grid .feature-item i {
                    color: #d4af37;
                    font-size: 0.75rem;
                }
                .btn-premium-cta {
                    background: linear-gradient(135deg, #d4af37, #f5d060);
                    color: #1a1a2e;
                    font-weight: 700;
                    border: none;
                    padding: 0.75rem 2rem;
                    border-radius: 8px;
                    font-size: 1rem;
                    transition: all 0.3s;
                    text-decoration: none;
                }
                .btn-premium-cta:hover {
                    transform: translateY(-2px);
                    box-shadow: 0 8px 25px rgba(212, 175, 55, 0.4);
                    color: #1a1a2e;
                }

                .ticker-tag {
                    background-color: #fee2e2;
                    color: #991b1b;
                    border: 1px solid #fecaca;
                    border-radius: 4px;
                    padding: 2px 6px;
                    font-size: 0.75rem;
                    font-weight: 600;
                    display: inline-flex;
                    align-items: center;
                    gap: 4px;
                }

                .ticker-tag i {
                    cursor: pointer;
                    opacity: 0.6;
                    transition: opacity 0.2s;
                }

                .ticker-tag i:hover {
                    opacity: 1;
                }

                .premium-blur {
                    filter: blur(5px);
                    user-select: none;
                    pointer-events: none;
                    opacity: 0.7;
                }

                .premium-lock-icon {
                    position: absolute;
                    top: 50%;
                    left: 50%;
                    transform: translate(-50%, -50%);
                    z-index: 10;
                    color: #d4af37;
                    font-size: 0.9rem;
                    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
                }

                .premium-cell {
                    position: relative;
                    overflow: hidden;
                }

/* ── SEO / UX FIXES ──────────────────────────────────────────── */
/* Smooth momentum scrolling on iOS */
.rankings-table-container {
    -webkit-overflow-scrolling: touch;
}

/* Increase filter label size on small screens */
@media (max-width: 600px) {
    .filter-label {
        font-size: 0.85rem;
    }
    .view-tab-btn {
        padding: 0.5rem 0.75rem;
        font-size: 0.8rem;
    }
}

/* Minimum tap target sizes */
.view-tab-btn,
.btn-update-table,
.btn-outline-primary,
.btn-outline-secondary {
    min-height: 44px;
}
