/* ========================================
   CSS Variables & Design Tokens
======================================== */
:root {
    /* Colors - Dark Theme */
    --bg-primary: #0a0a0f;
    --bg-secondary: #12121a;
    --bg-tertiary: #1a1a25;
    --bg-card: rgba(26, 26, 37, 0.7);
    --bg-hover: rgba(139, 92, 246, 0.1);

    /* Accent Colors */
    --accent-primary: #8B5CF6;
    --accent-secondary: #EC4899;
    --accent-tertiary: #06B6D4;
    --accent-success: #10B981;
    --accent-warning: #F59E0B;
    --accent-error: #EF4444;

    /* Text Colors */
    --text-primary: #FAFAFA;
    --text-secondary: #A1A1AA;
    --text-tertiary: #71717A;
    --text-muted: #52525B;

    /* Border Colors */
    --border-primary: rgba(255, 255, 255, 0.06);
    --border-secondary: rgba(255, 255, 255, 0.1);
    --border-accent: rgba(139, 92, 246, 0.3);

    /* Gradients */
    --gradient-primary: linear-gradient(135deg, #8B5CF6 0%, #EC4899 100%);
    --gradient-secondary: linear-gradient(135deg, #06B6D4 0%, #8B5CF6 100%);
    --gradient-glass: linear-gradient(135deg, rgba(255, 255, 255, 0.05) 0%, rgba(255, 255, 255, 0.02) 100%);
    --gradient-bg: radial-gradient(ellipse at top, rgba(139, 92, 246, 0.15) 0%, transparent 50%),
        radial-gradient(ellipse at bottom right, rgba(236, 72, 153, 0.1) 0%, transparent 50%);

    /* Shadows */
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 20px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 8px 40px rgba(0, 0, 0, 0.5);
    --shadow-glow: 0 0 40px rgba(139, 92, 246, 0.2);

    /* Typography */
    --font-display: 'Outfit', sans-serif;
    --font-body: 'Inter', sans-serif;

    /* Spacing */
    --space-xs: 0.25rem;
    --space-sm: 0.5rem;
    --space-md: 1rem;
    --space-lg: 1.5rem;
    --space-xl: 2rem;
    --space-2xl: 3rem;
    --space-3xl: 4rem;

    /* Border Radius */
    --radius-sm: 6px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 24px;
    --radius-full: 9999px;

    /* Transitions */
    --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-base: 200ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-slow: 300ms cubic-bezier(0.4, 0, 0.2, 1);
}

/* ========================================
   Reset & Base Styles
======================================== */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    scroll-behavior: smooth;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: var(--font-body);
    font-size: 14px;
    line-height: 1.6;
    color: var(--text-primary);
    background-color: var(--bg-primary);
    min-height: 100vh;
    overflow-x: hidden;
}

/* Background Gradient */
.background-gradient {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--gradient-bg);
    pointer-events: none;
    z-index: -1;
}

/* ========================================
   Container
======================================== */
.container {
    max-width: 1600px;
    margin: 0 auto;
    padding: var(--space-lg) var(--space-xl);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* ========================================
   Header
======================================== */
.header {
    margin-bottom: var(--space-2xl);
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: var(--space-lg);
}

.logo-section {
    display: flex;
    align-items: center;
    gap: var(--space-md);
}

.logo-icon svg {
    width: 48px;
    height: 48px;
    filter: drop-shadow(0 4px 12px rgba(139, 92, 246, 0.3));
}

.logo-text h1 {
    font-family: var(--font-display);
    font-size: 1.75rem;
    font-weight: 700;
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    letter-spacing: -0.02em;
}

.tagline {
    color: var(--text-secondary);
    font-size: 0.875rem;
    margin-top: var(--space-xs);
}

.built-by {
    color: var(--text-secondary);
    font-size: 0.95rem;
    font-weight: 500;
    margin-top: var(--space-sm);
}

.built-by a {
    color: #c084fc;
    text-decoration: none;
    margin-left: 4px;
    font-weight: 600;
    transition: color var(--transition-base);
}

.built-by a:hover {
    color: #e879f9;
    text-shadow: 0 0 8px rgba(232, 121, 249, 0.5);
}

.built-by .x-icon {
    color: #a855f7;
    font-weight: 700;
}

.built-by .tg-icon {
    color: #38bdf8;
}

.built-by .separator {
    color: var(--text-muted);
    margin: 0 8px;
}

.header-stats {
    display: flex;
    align-items: center;
    gap: var(--space-md);
}

.stat-pill {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    padding: var(--space-sm) var(--space-md);
    background: var(--bg-card);
    border: 1px solid var(--border-primary);
    border-radius: var(--radius-md);
    backdrop-filter: blur(12px);
}

.stat-label {
    font-size: 0.75rem;
    color: var(--text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.stat-value {
    font-family: var(--font-display);
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-primary);
}

.refresh-btn {
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-card);
    border: 1px solid var(--border-primary);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--transition-base);
    color: var(--text-secondary);
}

.refresh-btn:hover {
    background: var(--bg-hover);
    border-color: var(--border-accent);
    color: var(--accent-primary);
    transform: rotate(180deg);
}

.refresh-btn svg {
    width: 20px;
    height: 20px;
}

/* ========================================
   Main Content
======================================== */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    position: relative;
}

/* Metrics Legend */
.metrics-legend {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-md) var(--space-xl);
    padding: var(--space-md) var(--space-lg);
    background: var(--bg-card);
    border: 1px solid var(--border-primary);
    border-radius: var(--radius-lg);
    margin-bottom: var(--space-lg);
    backdrop-filter: blur(12px);
}

.legend-item {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    font-size: 0.8125rem;
    color: var(--text-secondary);
}

.legend-dot {
    width: 8px;
    height: 8px;
    border-radius: var(--radius-full);
}

.legend-dot.oi {
    background: var(--accent-primary);
}

.legend-dot.volume {
    background: var(--accent-secondary);
}

.legend-dot.revenue {
    background: var(--accent-success);
}

.legend-dot.tvl {
    background: var(--accent-tertiary);
}

.legend-dot.users {
    background: var(--accent-warning);
}

/* ========================================
   Table Container
======================================== */
.table-container {
    background: var(--bg-card);
    border: 1px solid var(--border-primary);
    border-radius: var(--radius-lg);
    overflow: hidden;
    backdrop-filter: blur(12px);
    box-shadow: var(--shadow-lg);
}

.table-wrapper {
    overflow-x: auto;
    scrollbar-width: thin;
    scrollbar-color: var(--bg-tertiary) transparent;
}

.table-wrapper::-webkit-scrollbar {
    height: 8px;
}

.table-wrapper::-webkit-scrollbar-track {
    background: transparent;
}

.table-wrapper::-webkit-scrollbar-thumb {
    background: var(--bg-tertiary);
    border-radius: var(--radius-full);
}

/* ========================================
   Comparison Table
======================================== */
.comparison-table {
    width: 100%;
    border-collapse: collapse;
    min-width: 1200px;
}

.comparison-table thead {
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.03) 0%, transparent 100%);
}

.comparison-table th {
    padding: var(--space-md) var(--space-lg);
    text-align: left;
    font-family: var(--font-display);
    font-weight: 600;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-tertiary);
    border-bottom: 1px solid var(--border-primary);
    white-space: nowrap;
}

.comparison-table th.sticky-col {
    position: sticky;
    left: 0;
    z-index: 10;
    background: var(--bg-secondary);
}

.comparison-table th.divider {
    width: 2px;
    padding: 0;
    background: linear-gradient(180deg, transparent, var(--accent-primary), transparent);
}

.comparison-table td {
    padding: var(--space-md) var(--space-lg);
    border-bottom: 1px solid var(--border-primary);
    font-size: 0.9375rem;
    vertical-align: middle;
}

.comparison-table td.sticky-col {
    position: sticky;
    left: 0;
    z-index: 5;
    background: var(--bg-secondary);
}

.comparison-table td.divider {
    padding: 0;
    width: 2px;
    background: linear-gradient(180deg, transparent, rgba(139, 92, 246, 0.3), transparent);
}

.comparison-table tbody tr {
    transition: background var(--transition-fast);
}

.comparison-table tbody tr:hover {
    background: var(--bg-hover);
}

.comparison-table tbody tr:last-child td {
    border-bottom: none;
}

/* Protocol Cell */
.protocol-cell {
    display: flex;
    align-items: center;
    gap: var(--space-md);
}

.protocol-icon {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    overflow: hidden;
}

.protocol-icon img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: var(--radius-md);
}

.protocol-icon-fallback {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 0.875rem;
    color: white;
    text-transform: uppercase;
}

.protocol-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.protocol-name {
    font-family: var(--font-display);
    font-weight: 600;
    font-size: 0.9375rem;
    color: var(--text-primary);
}

.protocol-token {
    font-size: 0.75rem;
    color: var(--text-tertiary);
}

.protocol-token.has-token {
    color: var(--accent-success);
}

.protocol-token.projected {
    color: var(--accent-warning);
    font-style: italic;
}

/* Metric Values */
.metric-value {
    font-family: var(--font-display);
    font-weight: 600;
    color: var(--text-primary);
}

.metric-value.positive {
    color: var(--accent-success);
}

.metric-value.na {
    color: var(--text-muted);
    font-weight: 400;
    font-style: italic;
}

.metric-subtitle {
    font-size: 0.6875rem;
    color: var(--text-tertiary);
    margin-top: 2px;
}

/* Metric with Date (for TVL) */
.metric-with-date {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.metric-date {
    font-size: 0.6875rem;
    color: var(--text-muted);
    font-weight: 400;
}

/* Metric with Change Indicator */
.metric-with-change {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.change-indicator {
    font-size: 0.6875rem;
    font-weight: 500;
}

.change-positive {
    color: var(--accent-success);
}

.change-negative {
    color: var(--accent-error);
}

.change-neutral {
    color: var(--text-muted);
}

/* Price Section */
.price-value {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.price-main {
    font-family: var(--font-display);
    font-weight: 600;
    color: var(--text-primary);
}

.price-label {
    font-size: 0.6875rem;
    color: var(--text-tertiary);
}

.price-projected {
    color: var(--accent-warning);
}

.ratio-value {
    font-family: var(--font-display);
    font-weight: 600;
    color: var(--accent-tertiary);
}

/* ========================================
   Loading State
======================================== */
.loading-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(10, 10, 15, 0.85);
    backdrop-filter: blur(4px);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: var(--space-lg);
    z-index: 100;
    border-radius: var(--radius-lg);
}

.loading-overlay.hidden {
    display: none;
}

.loader {
    position: relative;
    width: 60px;
    height: 60px;
}

.loader-ring {
    position: absolute;
    width: 100%;
    height: 100%;
    border: 3px solid transparent;
    border-radius: 50%;
    animation: loader-spin 1.5s linear infinite;
}

.loader-ring:nth-child(1) {
    border-top-color: var(--accent-primary);
    animation-delay: 0s;
}

.loader-ring:nth-child(2) {
    border-right-color: var(--accent-secondary);
    animation-delay: 0.15s;
}

.loader-ring:nth-child(3) {
    border-bottom-color: var(--accent-tertiary);
    animation-delay: 0.3s;
}

@keyframes loader-spin {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

.loading-text {
    font-family: var(--font-display);
    font-size: 0.875rem;
    color: var(--text-secondary);
    animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {

    0%,
    100% {
        opacity: 0.5;
    }

    50% {
        opacity: 1;
    }
}

/* ========================================
   Error State
======================================== */
.error-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: var(--space-3xl);
    text-align: center;
    background: var(--bg-card);
    border: 1px solid var(--border-primary);
    border-radius: var(--radius-lg);
}

.error-icon {
    font-size: 3rem;
    margin-bottom: var(--space-lg);
}

.error-state h3 {
    font-family: var(--font-display);
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: var(--space-sm);
}

.error-state p {
    color: var(--text-secondary);
    margin-bottom: var(--space-xl);
}

.retry-btn {
    padding: var(--space-sm) var(--space-xl);
    font-family: var(--font-display);
    font-size: 0.875rem;
    font-weight: 600;
    color: white;
    background: var(--gradient-primary);
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--transition-base);
}

.retry-btn:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-glow);
}

/* ========================================
   Footer
======================================== */
.footer {
    margin-top: var(--space-2xl);
    padding-top: var(--space-lg);
    border-top: 1px solid var(--border-primary);
}

.footer-content {
    display: flex;
    flex-direction: column;
    gap: var(--space-md);
    align-items: center;
    text-align: center;
}

.data-sources {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    flex-wrap: wrap;
    justify-content: center;
}

.source-label {
    font-size: 0.8125rem;
    color: var(--text-tertiary);
}

.source-link {
    display: flex;
    align-items: center;
    gap: var(--space-xs);
    font-size: 0.8125rem;
    color: var(--text-secondary);
    text-decoration: none;
    padding: var(--space-xs) var(--space-sm);
    background: var(--bg-tertiary);
    border-radius: var(--radius-sm);
    transition: all var(--transition-base);
}

.source-link:hover {
    color: var(--accent-primary);
    background: var(--bg-hover);
}

.source-logo {
    width: 16px;
    height: 16px;
    object-fit: contain;
}

.disclaimer {
    font-size: 0.75rem;
    color: var(--text-muted);
    max-width: 600px;
}

/* ========================================
   Skeleton Loading
======================================== */
.skeleton {
    background: linear-gradient(90deg,
            var(--bg-tertiary) 25%,
            var(--bg-secondary) 50%,
            var(--bg-tertiary) 75%);
    background-size: 200% 100%;
    animation: skeleton-loading 1.5s ease-in-out infinite;
    border-radius: var(--radius-sm);
}

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

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

.skeleton-text {
    height: 1em;
    width: 80px;
}

.skeleton-icon {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-md);
}

/* ========================================
   Responsive Design
======================================== */
@media (max-width: 1024px) {
    .container {
        padding: var(--space-md);
    }

    .header-content {
        flex-direction: column;
        align-items: flex-start;
    }

    .header-stats {
        width: 100%;
        justify-content: space-between;
    }

    .metrics-legend {
        gap: var(--space-sm) var(--space-lg);
    }
}

@media (max-width: 640px) {
    .logo-text h1 {
        font-size: 1.5rem;
    }

    .comparison-table th,
    .comparison-table td {
        padding: var(--space-sm) var(--space-md);
    }

    .protocol-icon {
        width: 28px;
        height: 28px;
        font-size: 0.75rem;
    }

    .legend-item span:last-child {
        font-size: 0.75rem;
    }
}

/* ========================================
   Animations
======================================== */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

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

.comparison-table tbody tr {
    animation: fadeIn 0.3s ease-out forwards;
}

.comparison-table tbody tr:nth-child(1) {
    animation-delay: 0.05s;
}

.comparison-table tbody tr:nth-child(2) {
    animation-delay: 0.1s;
}

.comparison-table tbody tr:nth-child(3) {
    animation-delay: 0.15s;
}

.comparison-table tbody tr:nth-child(4) {
    animation-delay: 0.2s;
}

.comparison-table tbody tr:nth-child(5) {
    animation-delay: 0.25s;
}

.comparison-table tbody tr:nth-child(6) {
    animation-delay: 0.3s;
}

.comparison-table tbody tr:nth-child(7) {
    animation-delay: 0.35s;
}

.comparison-table tbody tr:nth-child(8) {
    animation-delay: 0.4s;
}