:root {
    --bg-dark: #0a0a0c;
    --bg-card: #13131f;
    --bg-card-hover: #1c1c2e;
    --primary: #6366f1;
    --accent: #8b5cf6;
    --text-main: #ffffff;
    --text-muted: #94a3b8;
    --success: #10b981;
    --danger: #ef4444;
    --border: rgba(255, 255, 255, 0.08);
    --font-heading: 'Outfit', sans-serif;
    --font-mono: 'Space Mono', monospace;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    background-color: var(--bg-dark);
    color: var(--text-main);
    font-family: var(--font-heading);
    min-height: 100vh;
    overflow-x: hidden;
}

.app-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 2rem;
}

/* Header */
.main-header {
    margin-bottom: 3rem;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid var(--border);
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.logo-icon {
    font-size: 2rem;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    background-clip: text;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

h1 {
    font-size: 1.75rem;
    font-weight: 700;
    letter-spacing: -0.02em;
}

.market-status {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    background: rgba(16, 185, 129, 0.1);
    padding: 0.5rem 1rem;
    border-radius: 999px;
    border: 1px solid rgba(16, 185, 129, 0.2);
}

.status-dot {
    width: 8px;
    height: 8px;
    background-color: var(--text-muted);
    /* Default to closed */
    border-radius: 50%;
}

.status-dot.live {
    background-color: var(--success);
    box-shadow: 0 0 10px var(--success);
    animation: pulse 2s infinite;
}

.status-text {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-muted);
    /* Default to closed */
}

/* Market Status States */
.market-status.open .status-text {
    color: var(--success);
}

.market-status.open .status-dot {
    background-color: var(--success);
    box-shadow: 0 0 10px var(--success);
}

.market-status.closed .status-text {
    color: var(--text-muted);
}

.market-status.closed .status-dot {
    background-color: var(--text-muted);
    box-shadow: none;
}


.live-clock {
    font-family: var(--font-mono);
    font-size: 0.875rem;
    color: var(--text-muted);
    margin-left: 0.5rem;
    border-left: 1px solid rgba(16, 185, 129, 0.2);
    padding-left: 0.75rem;
}

/* Main Content Gap */
main {
    display: flex;
    flex-direction: column;
    gap: 3rem;
}

/* Leaderboard Cards */
.cards-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 1rem;
    margin-top: 1.5rem;
}

/* Responsive: 4 columns on medium screens */
@media (max-width: 1400px) {
    .cards-grid {
        grid-template-columns: repeat(4, 1fr);
    }
}

/* Responsive: 3 columns on smaller screens */
@media (max-width: 1100px) {
    .cards-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

/* Responsive: 2 columns on tablets */
@media (max-width: 768px) {
    .cards-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* Responsive: 1 column on mobile */
@media (max-width: 480px) {
    .cards-grid {
        grid-template-columns: 1fr;
    }
}

.model-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 1.5rem;
    transition: transform 0.2s, box-shadow 0.2s, background-color 0.2s;
    position: relative;
    overflow: hidden;
}

.model-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 10px 40px -10px rgba(0, 0, 0, 0.5);
    background-color: var(--bg-card-hover);
    border-color: rgba(255, 255, 255, 0.15);
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 1.5rem;
}

.model-info {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.model-icon {
    width: 40px;
    height: 40px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.model-icon svg {
    width: 100%;
    height: 100%;
}

.model-text h3 {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 0.25rem;
}

.model-provider {
    font-size: 0.875rem;
    color: var(--text-muted);
}

.rank-badge {
    background: rgba(255, 255, 255, 0.05);
    padding: 0.25rem 0.75rem;
    border-radius: 8px;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-muted);
}

.card-stats {
    display: grid;
    gap: 1rem;
}

.stat-row {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
}

.stat-label {
    font-size: 0.875rem;
    color: var(--text-muted);
}

.stat-value {
    font-family: var(--font-mono);
    font-weight: 700;
    font-size: 1.1rem;
}

.stat-value.large {
    font-size: 1.5rem;
}

.text-success {
    color: var(--success);
}

.text-danger {
    color: var(--danger);
}

/* Chart Section */
.chart-section {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 1.5rem;
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.chart-controls {
    display: flex;
    gap: 0.5rem;
    background: rgba(0, 0, 0, 0.2);
    padding: 0.25rem;
    border-radius: 8px;
}

.time-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    padding: 0.5rem 1rem;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 600;
    font-size: 0.875rem;
    transition: all 0.2s;
}

.time-btn:hover {
    color: var(--text-main);
}

.time-btn.active {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-main);
}

.chart-container {
    height: 400px;
    width: 100%;
}

/* Holdings Table */
.holdings-section {
    margin-bottom: 3rem;
}

.tabs {
    display: flex;
    gap: 1rem;
    margin-top: 1rem;
    margin-bottom: 1.5rem;
    border-bottom: 1px solid var(--border);
    padding-bottom: 1px;
}

.tab-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    padding: 0.75rem 0;
    margin-right: 1rem;
    font-size: 1rem;
    cursor: pointer;
    position: relative;
    transition: color 0.2s;
}

.tab-btn:hover {
    color: var(--text-main);
}

.tab-btn.active {
    color: var(--primary);
    font-weight: 600;
}

.tab-btn.active::after {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 0;
    width: 100%;
    height: 2px;
    background: var(--primary);
    box-shadow: 0 -2px 10px var(--primary);
}

.table-container {
    overflow-x: auto;
    border-radius: 16px;
    border: 1px solid var(--border);
}

.holdings-table {
    width: 100%;
    border-collapse: collapse;
    background: var(--bg-card);
    font-size: 0.925rem;
}

.holdings-table th {
    text-align: left;
    padding: 1rem 1.5rem;
    color: var(--text-muted);
    font-weight: 600;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

.holdings-table td {
    padding: 1rem 1.5rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.03);
    font-family: var(--font-mono);
}

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

.holdings-table tr:hover td {
    background: rgba(255, 255, 255, 0.02);
}

.ticker-cell {
    font-family: var(--font-heading);
    font-weight: 600;
    color: var(--text-main);
    display: block;
}

.company-name {
    font-size: 0.8rem;
    color: var(--text-muted);
    font-weight: normal;
}

/* Table Utilities */
.table-message {
    text-align: center;
    padding: 2rem;
    color: var(--text-muted);
}

.cell-date {
    color: var(--text-muted);
    font-family: var(--font-mono);
    font-size: 0.9em;
}

.cell-action {
    font-weight: 700;
}

.cell-pnl {
    font-weight: 600;
}

@keyframes pulse {
    0% {
        opacity: 1;
        transform: scale(1);
    }

    50% {
        opacity: 0.5;
        transform: scale(0.9);
    }

    100% {
        opacity: 1;
        transform: scale(1);
    }
}

@media (max-width: 768px) {
    .app-container {
        padding: 1rem;
    }

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

    .chart-container {
        height: 300px;
    }
}

/* Loading Overlay */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: var(--bg-dark);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 9999;
    transition: opacity 0.5s ease-out, visibility 0.5s;
}

.loading-overlay.hidden {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

.spinner {
    width: 50px;
    height: 50px;
    border: 3px solid rgba(99, 102, 241, 0.3);
    border-radius: 50%;
    border-top-color: var(--primary);
    animation: spin 1s ease-in-out infinite;
    margin-bottom: 1.5rem;
}

.loading-text {
    font-family: var(--font-mono);
    color: var(--text-muted);
    font-size: 0.9rem;
    letter-spacing: 1px;
    animation: pulse 2s infinite;
}

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

.activity-section h2 {
    margin-bottom: 1.5rem;
}

.pagination-controls {
    display: flex;
    justify-content: center;
    gap: 0.5rem;
    margin-top: 1.5rem;
}

.page-btn {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-muted);
    padding: 0.5rem 1rem;
    border-radius: 6px;
    cursor: pointer;
    font-family: var(--font-mono);
    transition: all 0.2s;
}

.page-btn:hover:not(:disabled) {
    border-color: var(--primary);
    color: var(--text-main);
}

.page-btn.active {
    background: var(--primary);
    border-color: var(--primary);
    color: white;
}

.page-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

@keyframes flash-highlight {
    0% {
        background-color: rgba(16, 185, 129, 0.2);
    }

    100% {
        background-color: transparent;
    }
}

@keyframes text-flash {
    0% {
        transform: scale(1);
    }

    15% {
        transform: scale(1.15);
        background-color: var(--success);
        color: #fff;
        box-shadow: 0 0 15px var(--success);
    }

    100% {
        transform: scale(1);
        background-color: transparent;
    }
}

.flash-text {
    display: inline-block;
    border-radius: 4px;
    padding: 0 4px;
    animation: text-flash 1s ease-out;
}

.animate-update {
    animation: flash-highlight 2s ease-out;
}

/* Trade Ticker */
.trade-ticker-container {
    background: transparent;
    border: none;
    height: 32px;
    display: flex;
    align-items: center;
    overflow: hidden;
    position: relative;
    box-shadow: none;
}

.ticker-item {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-wrap: nowrap;
    gap: 0.5rem;
    opacity: 0;
    transform: translateY(20px);
    transition: transform 0.8s cubic-bezier(0.2, 0, 0.2, 1), opacity 0.8s ease-out;
    padding: 0;
    font-size: 0.95rem;
}

.ticker-item.active {
    opacity: 1;
    transform: translateY(0);
    z-index: 2;
}

.ticker-item.exit {
    opacity: 0;
    transform: translateY(-20px);
    z-index: 1;
}

/* ── Weekly Digest Carousel ── */
.weekly-digest-section {
    margin: 0;
}

.digest-carousel {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    position: relative;
}

.digest-track-wrapper {
    flex: 1;
    overflow: hidden;
    min-height: 72px;
    position: relative;
}

.digest-track {
    display: flex;
    transition: transform 0.45s cubic-bezier(0.4, 0, 0.2, 1);
    will-change: transform;
}

.digest-slide {
    min-width: 100%;
    padding: 0 1.5rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    min-height: 72px;
    box-sizing: border-box;
}

.digest-model-badge {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-shrink: 0;
    padding: 0.3rem 0.75rem 0.3rem 0.5rem;
    border-radius: 999px;
    border: 1px solid;
    font-weight: 700;
    font-size: 0.8rem;
    letter-spacing: 0.03em;
    text-transform: uppercase;
}

.digest-model-icon {
    width: 18px;
    height: 18px;
    display: flex;
    align-items: center;
    flex-shrink: 0;
}

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

.digest-week-label {
    font-family: var(--font-mono);
    font-size: 0.72rem;
    color: var(--text-muted);
    flex-shrink: 0;
    white-space: nowrap;
}

.digest-divider {
    width: 1px;
    height: 28px;
    background: var(--border);
    flex-shrink: 0;
}

.digest-text {
    font-size: 0.875rem;
    color: var(--text-muted);
    line-height: 1.5;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    flex: 1;
}

.digest-text strong {
    color: var(--text-main);
    font-weight: 600;
}

.digest-arrow {
    flex-shrink: 0;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--bg-card);
    border: 1px solid var(--border);
    color: var(--text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    font-size: 0;
    position: relative;
}

.digest-arrow::after {
    content: '';
    display: block;
    width: 8px;
    height: 8px;
    border-right: 2px solid var(--text-muted);
    border-top: 2px solid var(--text-muted);
    transition: border-color 0.2s;
}

.digest-arrow-left::after {
    transform: rotate(-135deg) translate(1px, -1px);
}

.digest-arrow-right::after {
    transform: rotate(45deg) translate(-1px, 1px);
}

.digest-arrow:hover {
    background: var(--bg-card-hover);
    border-color: var(--primary);
}

.digest-arrow:hover::after {
    border-color: var(--primary);
}

.digest-dots {
    display: flex;
    justify-content: center;
    gap: 6px;
    margin-top: 0.6rem;
}

.digest-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--border);
    border: none;
    padding: 0;
    cursor: pointer;
    transition: all 0.3s;
}

.digest-dot.active {
    width: 18px;
    border-radius: 3px;
    background: var(--primary);
}

@media (max-width: 768px) {
    .digest-slide {
        padding: 0 1rem;
        gap: 0.75rem;
        flex-wrap: wrap;
    }
    .digest-week-label, .digest-divider {
        display: none;
    }
}