:root {
    --primary-bg: #0a0e27;
    --secondary-bg: #141b3d;
    --card-bg: #1a2238;
    --accent-blue: #00d4ff;
    --accent-cyan: #00ffcc;
    --accent-purple: #7b2cbf;
    --text-primary: #ffffff;
    --text-secondary: #a0aec0;
    --text-muted: #718096;
    --border-color: #2d3748;
    --success: #48bb78;
    --danger: #f56565;
    --warning: #ed8936;

    --font-primary: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', sans-serif;
    --font-mono: 'SF Mono', 'Monaco', 'Inconsolata', 'Fira Mono', monospace;

    --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 10px 30px rgba(0, 0, 0, 0.5);
    --shadow-glow: 0 0 20px rgba(0, 212, 255, 0.3);

    --transition-fast: 0.15s ease;
    --transition-normal: 0.3s ease;
    --transition-slow: 0.5s ease;
}

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

html {
    scroll-behavior: smooth;
    height: 100%;
}

body {
    font-family: var(--font-primary);
    background: linear-gradient(135deg, var(--primary-bg) 0%, #0d1628 100%);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    height: 100%;
    background-attachment: fixed;
    overflow-x: hidden;
    margin: 0;
    padding: 0;
}

/* Navbar - Professional Financial/Technical Design */
.navbar {
    background: linear-gradient(180deg, rgba(26, 34, 56, 0.98) 0%, rgba(20, 27, 45, 0.98) 100%);
    border-bottom: 1px solid rgba(0, 212, 255, 0.2);
    padding: 0;
    position: sticky;
    top: 0;
    z-index: 1000;
    backdrop-filter: blur(20px) saturate(180%);
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.4), 0 1px 0 rgba(0, 212, 255, 0.1) inset;
}

.navbar::after {
    content: '';
    position: absolute;
    bottom: -1px;
    left: 0;
    right: 0;
    height: 1px;
    background: linear-gradient(90deg,
        transparent 0%,
        rgba(0, 212, 255, 0.5) 20%,
        rgba(0, 255, 204, 0.5) 50%,
        rgba(0, 212, 255, 0.5) 80%,
        transparent 100%);
}

.nav-container {
    max-width: 1600px;
    margin: 0 auto;
    padding: 0 3rem;
    display: grid;
    grid-template-columns: auto auto 1fr auto;
    align-items: center;
    gap: 2.5rem;
    height: 72px;
}

.nav-brand {
    display: flex;
    align-items: center;
    gap: 0.875rem;
    padding: 0.5rem 0;
    grid-column: 1;
}

.brand-icon {
    font-size: 2rem;
    filter: drop-shadow(0 0 8px rgba(0, 212, 255, 0.4));
    animation: pulse 3s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% {
        transform: scale(1);
        filter: drop-shadow(0 0 8px rgba(0, 212, 255, 0.4));
    }
    50% {
        transform: scale(1.05);
        filter: drop-shadow(0 0 12px rgba(0, 212, 255, 0.6));
    }
}

.nav-brand h1 {
    font-size: 1.5rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--accent-blue) 0%, var(--accent-cyan) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    letter-spacing: -0.5px;
    text-shadow: 0 0 20px rgba(0, 212, 255, 0.3);
}

.nav-menu {
    display: flex;
    list-style: none;
    gap: 0.5rem;
    justify-self: start;
    align-items: center;
    height: 100%;
    grid-column: 2;
}

.nav-menu li {
    height: 100%;
    display: flex;
    align-items: center;
}

.nav-link {
    color: var(--text-secondary);
    text-decoration: none;
    font-weight: 500;
    font-size: 0.9375rem;
    padding: 0.625rem 1.25rem;
    border-radius: 6px;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    letter-spacing: 0.2px;
    height: 100%;
    display: flex;
    align-items: center;
}

.nav-link::before {
    content: '';
    position: absolute;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 0;
    height: 2px;
    background: linear-gradient(90deg, var(--accent-blue), var(--accent-cyan));
    transition: width 0.3s ease;
}

.nav-link:hover {
    color: var(--accent-cyan);
    background: rgba(0, 212, 255, 0.08);
}

.nav-link:hover::before {
    width: 80%;
}

.nav-link.active {
    color: var(--accent-blue);
    background: rgba(0, 212, 255, 0.12);
    font-weight: 600;
}

.nav-link.active::before {
    width: 80%;
}

/* Market Selector - Premium Design */
.market-selector {
    display: flex;
    gap: 0;
    align-items: center;
    justify-self: end;
    margin-right: 1.5rem;
    background: rgba(10, 14, 27, 0.6);
    border: 1px solid rgba(0, 212, 255, 0.2);
    border-radius: 8px;
    padding: 4px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.05);
    grid-column: 3;
}

.market-btn {
    padding: 0.5rem 1.125rem;
    border: none;
    border-radius: 6px;
    background: transparent;
    color: var(--text-secondary);
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    white-space: nowrap;
    letter-spacing: 0.3px;
    position: relative;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.market-btn::after {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: 6px;
    background: linear-gradient(135deg, rgba(0, 212, 255, 0.15), rgba(0, 255, 204, 0.15));
    opacity: 0;
    transition: opacity 0.2s ease;
}

.market-btn:hover:not(.active) {
    color: var(--text-primary);
    background: rgba(0, 212, 255, 0.08);
}

.market-btn.active {
    background: linear-gradient(135deg, rgba(0, 212, 255, 0.25), rgba(0, 255, 204, 0.2));
    color: var(--text-primary);
    box-shadow: 0 0 12px rgba(0, 212, 255, 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.1);
    position: relative;
}

.market-btn.active::after {
    opacity: 1;
}

/* Granularity Control */
.granularity-wrapper {
    display: flex;
    align-items: center;
    gap: 2px;
    transition: opacity 0.3s ease, width 0.3s ease;
}

.granularity-wrapper.hidden {
    display: none;
}

.granularity-divider {
    width: 1px;
    height: 16px;
    background: rgba(255, 255, 255, 0.1);
    margin: 0 6px;
}

.granularity-btn {
    padding: 4px 8px;
    border: 1px solid transparent;
    border-radius: 6px;
    background: transparent;
    color: var(--text-muted);
    font-size: 0.7rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: var(--font-mono);
    letter-spacing: 0.5px;
}

.granularity-btn:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.05);
}

.granularity-btn.active {
    color: var(--accent-cyan);
    background: rgba(0, 255, 204, 0.1);
    border-color: rgba(0, 255, 204, 0.2);
    box-shadow: 0 0 10px rgba(0, 255, 204, 0.1);
}

/* GitHub Link - Premium Design */
.github-link {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    padding: 0.625rem 1.375rem;
    background: linear-gradient(135deg, rgba(0, 212, 255, 0.15), rgba(0, 255, 204, 0.12));
    border: 1px solid rgba(0, 212, 255, 0.3);
    border-radius: 8px;
    color: var(--text-primary);
    text-decoration: none;
    font-weight: 600;
    font-size: 0.9rem;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
    white-space: nowrap;
    letter-spacing: 0.3px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2), inset 0 1px 0 rgba(255, 255, 255, 0.1);
    grid-column: 4;
    justify-self: end;
}

.github-link::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
    transition: left 0.5s ease;
}

.github-link:hover::before {
    left: 100%;
}

.github-link:hover {
    background: linear-gradient(135deg, var(--accent-blue), var(--accent-cyan));
    border-color: var(--accent-cyan);
    color: var(--primary-bg);
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(0, 212, 255, 0.4), 0 0 30px rgba(0, 212, 255, 0.2);
}

.github-link:active {
    transform: translateY(0);
}

.github-icon {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
    transition: transform 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

.github-link:hover .github-icon {
    transform: rotate(360deg) scale(1.1);
}

.github-text {
    font-weight: 600;
    letter-spacing: 0.3px;
}

/* Container */
.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0;
    display: flex;
    flex-direction: column;
    min-height: calc(100vh - 76px);
}

.container-padded {
    padding: 2rem;
}

/* Page Header */
.page-header {
    text-align: center;
    margin-bottom: 0.4rem;
    padding: 0.4rem 2rem 0.2rem;
    flex-shrink: 0;
}

.page-header h2 {
    font-size: 1.3rem;
    font-weight: 700;
    margin-bottom: 0.1rem;
    background: linear-gradient(135deg, var(--text-primary), var(--accent-blue));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.subtitle {
    color: var(--text-secondary);
    font-size: 0.75rem;
}

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
    gap: 0.4rem;
    margin-bottom: 0.4rem;
    padding: 0 2rem;
    flex-shrink: 0;
}

.stat-card {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 0.6rem 0.9rem;
    transition: all var(--transition-normal);
    position: relative;
    overflow: hidden;
    box-shadow: var(--shadow-sm);
}

.stat-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 3px;
    background: linear-gradient(90deg, var(--accent-blue), var(--accent-cyan));
    opacity: 0;
    transition: opacity var(--transition-normal);
}

.stat-card:hover::before {
    opacity: 1;
}

.stat-card:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow-lg);
    border-color: rgba(0, 212, 255, 0.3);
}

.stat-label {
    color: var(--text-secondary);
    font-size: 0.7rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 0.15rem;
}

.stat-value {
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--accent-cyan);
    font-family: var(--font-mono);
}

/* Chart Section */
.chart-section {
    margin-bottom: 0;
    padding: 0;
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-height: calc(100vh - 300px); /* Ensure chart takes most of viewport */
    position: relative;
}

.chart-section::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 60px;
    background: linear-gradient(to bottom, transparent, var(--primary-bg));
    pointer-events: none;
    z-index: 1;
}

.chart-card {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 0;
    padding: 0.6rem 1.5rem 0.8rem;
    box-shadow: none;
    border-left: none;
    border-right: none;
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-height: 0; /* Important for flex children */
}

.chart-card.hero {
    flex: 1;
    min-height: 0;
}

.chart-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.4rem;
    flex-wrap: wrap;
    gap: 0.6rem;
    flex-shrink: 0;
}

.chart-header h3 {
    font-size: 1.05rem;
    color: var(--text-primary);
}

.chart-controls {
    display: flex;
    gap: 1rem;
}

.btn-secondary {
    background: var(--secondary-bg);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    padding: 0.6rem 1.2rem;
    border-radius: 10px;
    cursor: pointer;
    font-weight: 500;
    font-size: 0.9rem;
    transition: all var(--transition-normal);
    position: relative;
    overflow: hidden;
}

.btn-secondary::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(0, 212, 255, 0.3);
    transform: translate(-50%, -50%);
    transition: width 0.6s, height 0.6s;
}

.btn-secondary:hover::before {
    width: 300px;
    height: 300px;
}

.btn-secondary:hover {
    background: var(--accent-blue);
    border-color: var(--accent-blue);
    color: var(--primary-bg);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 212, 255, 0.4);
}

.btn-secondary:active {
    transform: translateY(0);
}

.chart-container {
    position: relative;
    width: 100%;
    flex: 1;
    min-height: 0;
}

.chart-card.hero .chart-container {
    flex: 1;
    min-height: 0;
}

.chart-container-small {
    position: relative;
    height: 300px;
}

/* Legend Section */
.legend-section {
    display: none;
}

.legend-section h3 {
    font-size: 1.3rem;
    margin-bottom: 1.5rem;
    color: var(--text-primary);
}

.agent-legend {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1rem;
}

.legend-item {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 1.25rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    transition: all var(--transition-fast);
}

.legend-item:hover {
    transform: translateY(-3px);
    border-color: var(--accent-blue);
    box-shadow: var(--shadow-md);
}

.legend-icon {
    width: 42px;
    height: 42px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    flex-shrink: 0;
    background: rgba(0, 212, 255, 0.1);
}

.legend-icon-img {
    width: 28px;
    height: 28px;
    object-fit: contain;
}

.legend-color {
    width: 4px;
    height: 42px;
    border-radius: 2px;
    flex-shrink: 0;
}

.legend-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.legend-name {
    color: var(--text-primary);
    font-size: 0.95rem;
    font-weight: 600;
}

.legend-return {
    font-weight: 700;
    font-family: var(--font-mono);
    font-size: 1rem;
}

.legend-return.positive {
    color: var(--success);
}

.legend-return.negative {
    color: var(--danger);
}

/* Portfolio Specific Styles */
.agent-selector-section {
    margin-bottom: 2rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0 2rem;
}

.agent-selector-section label {
    font-weight: 600;
    color: var(--text-primary);
    font-size: 0.95rem;
}

.agent-select {
    position: relative;
    background: linear-gradient(135deg, var(--card-bg), var(--secondary-bg));
    color: var(--text-primary);
    border: 2px solid var(--border-color);
    padding: 0.875rem 3rem 0.875rem 1.25rem;
    border-radius: 12px;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    min-width: 320px;
    transition: all var(--transition-normal);
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='%2300d4ff' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 1rem center;
    background-size: 20px;
}

.agent-select:hover {
    border-color: var(--accent-blue);
    background: linear-gradient(135deg, var(--secondary-bg), var(--card-bg));
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 212, 255, 0.2);
}

.agent-select:focus {
    outline: none;
    border-color: var(--accent-blue);
    box-shadow: 0 0 0 3px rgba(0, 212, 255, 0.1);
}

.agent-select option {
    background: var(--card-bg);
    color: var(--text-primary);
    padding: 0.75rem;
}

.portfolio-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
    gap: 2rem;
    margin-bottom: 3rem;
    padding: 0 2rem;
}

.portfolio-card {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 2rem;
    box-shadow: var(--shadow-md);
    transition: all var(--transition-normal);
}

.portfolio-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-lg);
    border-color: rgba(0, 212, 255, 0.3);
}

.portfolio-card h3 {
    font-size: 1.3rem;
    margin-bottom: 1.5rem;
    color: var(--accent-cyan);
    position: relative;
    padding-bottom: 0.75rem;
}

.portfolio-card h3::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 50px;
    height: 3px;
    background: linear-gradient(90deg, var(--accent-blue), transparent);
    border-radius: 2px;
}

.metrics-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.metric-item {
    display: flex;
    justify-content: space-between;
    padding: 1rem 1.25rem;
    background: var(--secondary-bg);
    border-radius: 8px;
    border-left: 3px solid var(--accent-blue);
    transition: all var(--transition-fast);
}

.metric-item:hover {
    background: var(--card-bg);
    border-left-width: 4px;
    transform: translateX(5px);
}

.metric-label {
    color: var(--text-secondary);
    font-weight: 500;
}

.metric-value {
    color: var(--text-primary);
    font-weight: 700;
    font-family: var(--font-mono);
}

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

.holdings-section h3 {
    font-size: 1.5rem;
    margin-bottom: 1.5rem;
    color: var(--text-primary);
}

.holdings-scroll-wrapper {
    height: 400px;
    overflow-y: scroll;
    overflow-x: hidden;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    background: var(--card-bg);
    position: relative;
    isolation: isolate;
    contain: layout style;
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
}

.holdings-table-container {
    background: var(--card-bg);
    position: relative;
}

/* Force scrollbar to always be visible */
.holdings-scroll-wrapper::-webkit-scrollbar {
    width: 12px;
    background: var(--secondary-bg);
}

.holdings-scroll-wrapper::-webkit-scrollbar-track {
    background: var(--secondary-bg);
    border-radius: 6px;
}

.holdings-scroll-wrapper::-webkit-scrollbar-thumb {
    background: var(--accent-cyan);
    border-radius: 6px;
    border: 2px solid var(--secondary-bg);
}

.holdings-scroll-wrapper::-webkit-scrollbar-thumb:hover {
    background: var(--accent-blue);
}

.holdings-table {
    width: 100%;
    border-collapse: collapse;
    min-width: 600px;
}

.holdings-table thead {
    background: var(--secondary-bg);
    position: sticky;
    top: 0;
    z-index: 10;
    display: table-header-group;
}

.holdings-table th {
    padding: 1rem;
    text-align: left;
    font-weight: 600;
    color: var(--accent-cyan);
    text-transform: uppercase;
    font-size: 0.85rem;
    letter-spacing: 1px;
    border-bottom: 2px solid var(--border-color);
}

.holdings-table td {
    padding: 1rem;
    border-top: 1px solid var(--border-color);
    color: var(--text-secondary);
}

.holdings-table tbody tr {
    transition: all var(--transition-fast);
    cursor: pointer;
}

.holdings-table tbody tr:hover {
    background: rgba(0, 212, 255, 0.05);
    transform: scale(1.01);
}

.holdings-table .symbol {
    color: var(--accent-blue);
    font-weight: 700;
    font-family: var(--font-mono);
}

/* Trade Timeline */
.trade-history-section {
    padding: 0 2rem;
}

.trade-history-section h3 {
    font-size: 1.5rem;
    margin-bottom: 1.5rem;
    color: var(--text-primary);
}

.trade-timeline {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.trade-item {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 1.5rem;
    display: flex;
    align-items: center;
    gap: 1.5rem;
    transition: all var(--transition-fast);
}

.trade-item:hover {
    border-color: var(--accent-blue);
    transform: translateX(5px);
}

.trade-icon {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    flex-shrink: 0;
}

.trade-icon.buy {
    background: rgba(72, 187, 120, 0.2);
    color: var(--success);
}

.trade-icon.sell {
    background: rgba(245, 101, 101, 0.2);
    color: var(--danger);
}

.trade-details {
    flex: 1;
}

.trade-action {
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 0.25rem;
}

.trade-meta {
    color: var(--text-muted);
    font-size: 0.9rem;
}

/* Loading Overlay */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(10, 14, 39, 0.95);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    backdrop-filter: blur(5px);
}

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

/* Utility Classes */
.hidden {
    display: none !important;
}

.positive {
    color: var(--success) !important;
}

.negative {
    color: var(--danger) !important;
}

/* Scroll to Top Button */
.scroll-to-top {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    width: 50px;
    height: 50px;
    background: linear-gradient(135deg, var(--accent-blue), var(--accent-cyan));
    color: var(--primary-bg);
    border: none;
    border-radius: 50%;
    font-size: 1.5rem;
    font-weight: bold;
    cursor: pointer;
    opacity: 0;
    visibility: hidden;
    transition: all var(--transition-normal);
    z-index: 1000;
    box-shadow: 0 4px 12px rgba(0, 212, 255, 0.4);
}

.scroll-to-top.visible {
    opacity: 1;
    visibility: visible;
}

.scroll-to-top:hover {
    transform: translateY(-5px);
    box-shadow: 0 6px 20px rgba(0, 212, 255, 0.6);
}

.scroll-to-top:active {
    transform: translateY(-2px);
}

@media (max-width: 768px) {
    .scroll-to-top {
        width: 45px;
        height: 45px;
        bottom: 1.5rem;
        right: 1.5rem;
        font-size: 1.3rem;
    }
}

.spinner {
    width: 60px;
    height: 60px;
    border: 4px solid var(--border-color);
    border-top-color: var(--accent-blue);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

.loading-overlay p {
    margin-top: 1.5rem;
    color: var(--text-secondary);
    font-size: 1.1rem;
}

/* Leaderboard and Action Flow Section */
.insights-section {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
    padding: 2rem;
    margin-top: 2rem; /* Add space above to separate from chart */
}

/* Leaderboard */
.leaderboard-section {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 0;
    box-shadow: var(--shadow-md);
    overflow: hidden;
}

.section-header {
    background: linear-gradient(135deg, var(--secondary-bg), var(--card-bg));
    padding: 1.5rem 2rem;
    border-bottom: 2px solid var(--border-color);
    position: relative;
}

.section-header::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 2px;
    background: linear-gradient(90deg, var(--accent-blue), var(--accent-cyan));
}

.section-header h3 {
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin: 0;
}

.section-icon {
    font-size: 1.6rem;
}

.leaderboard-list {
    padding: 1rem;
    max-height: 600px;
    overflow-y: auto;
}

.leaderboard-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem 1.25rem;
    background: var(--secondary-bg);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    margin-bottom: 0.75rem;
    transition: all var(--transition-normal);
    position: relative;
    overflow: hidden;
}

.leaderboard-item::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    width: 4px;
    height: 100%;
    background: var(--accent-blue);
    opacity: 0;
    transition: opacity var(--transition-normal);
}

.leaderboard-item:hover::before {
    opacity: 1;
}

.leaderboard-item:hover {
    transform: translateX(5px);
    border-color: rgba(0, 212, 255, 0.4);
    box-shadow: var(--shadow-md);
}

.leaderboard-rank {
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--accent-cyan);
    font-family: var(--font-mono);
    min-width: 40px;
    text-align: center;
}

.leaderboard-rank.first {
    color: #ffd700;
    text-shadow: 0 0 10px rgba(255, 215, 0, 0.5);
}

.leaderboard-rank.second {
    color: #c0c0c0;
    text-shadow: 0 0 10px rgba(192, 192, 192, 0.3);
}

.leaderboard-rank.third {
    color: #cd7f32;
    text-shadow: 0 0 10px rgba(205, 127, 50, 0.3);
}

.leaderboard-icon {
    width: 48px;
    height: 48px;
    border-radius: 10px;
    padding: 8px;
    background: rgba(0, 212, 255, 0.1);
    flex-shrink: 0;
}

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

.leaderboard-info {
    flex: 1;
    min-width: 0;
}

.leaderboard-name {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.25rem;
}

.leaderboard-value {
    font-size: 0.9rem;
    color: var(--text-secondary);
    font-family: var(--font-mono);
}

.leaderboard-gain {
    text-align: right;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 0.25rem;
}

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

.gain-percent {
    font-size: 0.85rem;
    font-weight: 600;
    padding: 0.25rem 0.5rem;
    border-radius: 6px;
    font-family: var(--font-mono);
}

.gain-amount.positive,
.gain-percent.positive {
    color: var(--success);
}

.gain-amount.negative,
.gain-percent.negative {
    color: var(--danger);
}

.gain-percent.positive {
    background: rgba(72, 187, 120, 0.15);
}

.gain-percent.negative {
    background: rgba(245, 101, 101, 0.15);
}

/* Action Flow */
.action-flow-section {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 0;
    box-shadow: var(--shadow-md);
    overflow: hidden;
}

.action-list {
    padding: 1rem;
    max-height: 600px;
    overflow-y: auto;
}

.action-card {
    background: var(--secondary-bg);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    margin-bottom: 1rem;
    overflow: hidden;
    transition: all var(--transition-normal);
}

.action-card:hover {
    border-color: rgba(0, 212, 255, 0.3);
    box-shadow: var(--shadow-md);
}

.action-header {
    padding: 1rem 1.25rem;
    background: linear-gradient(135deg,
                rgba(26, 34, 56, 0.6) 0%,
                rgba(20, 27, 45, 0.6) 100%);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    gap: 1rem;
}

.action-agent-icon {
    width: 40px;
    height: 40px;
    border-radius: 8px;
    padding: 6px;
    background: rgba(0, 212, 255, 0.1);
    flex-shrink: 0;
}

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

.action-meta {
    flex: 1;
    min-width: 0;
}

.action-agent-name {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.2rem;
}

.action-details {
    font-size: 0.85rem;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.action-type {
    font-weight: 600;
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
    font-size: 0.75rem;
    text-transform: uppercase;
}

.action-type.buy {
    background: rgba(72, 187, 120, 0.2);
    color: var(--success);
}

.action-type.sell {
    background: rgba(245, 101, 101, 0.2);
    color: var(--danger);
}

.action-symbol {
    font-weight: 700;
    color: var(--accent-blue);
    font-family: var(--font-mono);
}

.action-timestamp {
    margin-left: auto;
    font-size: 0.8rem;
    color: var(--text-muted);
    font-family: var(--font-mono);
}

.action-body {
    padding: 1rem 1.25rem;
}

.action-thinking-label {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--accent-cyan);
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 0.5rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.thinking-icon {
    font-size: 1rem;
}

.action-thinking {
    font-size: 0.9rem;
    line-height: 1.6;
    color: var(--text-secondary);
    background: rgba(0, 0, 0, 0.2);
    padding: 1rem;
    border-radius: 8px;
    border-left: 3px solid var(--accent-blue);
    max-height: 200px;
    overflow-y: auto;
}

.action-thinking p {
    margin: 0 0 0.75rem 0;
}

.action-thinking p:last-child {
    margin-bottom: 0;
}

/* Scrollbar styling */
.leaderboard-list::-webkit-scrollbar,
.action-list::-webkit-scrollbar,
.action-thinking::-webkit-scrollbar {
    width: 8px;
}

.leaderboard-list::-webkit-scrollbar-track,
.action-list::-webkit-scrollbar-track,
.action-thinking::-webkit-scrollbar-track {
    background: var(--secondary-bg);
    border-radius: 4px;
}

.leaderboard-list::-webkit-scrollbar-thumb,
.action-list::-webkit-scrollbar-thumb,
.action-thinking::-webkit-scrollbar-thumb {
    background: var(--accent-cyan);
    border-radius: 4px;
    border: 2px solid var(--secondary-bg);
}

.leaderboard-list::-webkit-scrollbar-thumb:hover,
.action-list::-webkit-scrollbar-thumb:hover,
.action-thinking::-webkit-scrollbar-thumb:hover {
    background: var(--accent-blue);
}

/* Footer */
.footer {
    background: var(--card-bg);
    border-top: 1px solid var(--border-color);
    padding: 2rem;
    text-align: center;
    margin-top: 4rem;
    position: relative;
    overflow: hidden;
}

.footer::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 2px;
    background: linear-gradient(90deg,
        transparent,
        var(--accent-blue),
        var(--accent-cyan),
        transparent
    );
}

.footer p {
    color: var(--text-muted);
    font-size: 0.9rem;
}

/* Responsive Design */
@media (max-width: 1024px) and (min-width: 769px) {
    .nav-container {
        padding: 0 2rem;
        gap: 1.5rem;
        grid-template-columns: auto auto 1fr auto;
    }

    .market-selector {
        grid-column: 3;
        justify-self: end;
        margin-right: 1rem;
    }

    .github-link {
        grid-column: 4;
        padding: 0.625rem 1.125rem;
        font-size: 0.875rem;
    }

    .github-text {
        font-size: 0.85rem;
    }

    .nav-menu {
        gap: 0.25rem;
    }
}

@media (max-width: 768px) {
    .navbar {
        padding: 0;
    }

    .nav-container {
        padding: 0 1rem;
        grid-template-columns: 1fr;
        grid-template-rows: auto auto auto auto;
        gap: 0.875rem;
        height: auto;
        padding-top: 0.875rem;
        padding-bottom: 0.875rem;
    }

    .nav-brand {
        grid-column: 1;
        grid-row: 1;
        justify-self: center;
    }

    .nav-brand h1 {
        font-size: 1.25rem;
    }

    .brand-icon {
        font-size: 1.5rem;
    }

    /* Row 2: Market selector centered */
    .market-selector {
        grid-column: 1;
        grid-row: 2;
        justify-self: center;
        padding: 4px;
        margin: 0;
    }

    .market-btn {
        padding: 0.5rem 1rem;
        font-size: 0.8125rem;
        gap: 0.5rem;
    }

    /* Row 3: GitHub button centered */
    .github-link {
        grid-column: 1;
        grid-row: 3;
        justify-self: center;
        padding: 0.625rem 1.5rem;
        font-size: 0.875rem;
        gap: 0.625rem;
        width: auto;
    }

    .github-text {
        display: inline;
    }

    .github-icon {
        width: 18px;
        height: 18px;
    }

    /* Row 4: Navigation links */
    .nav-menu {
        grid-column: 1;
        grid-row: 4;
        gap: 0.375rem;
        width: 100%;
        justify-self: stretch;
    }

    .nav-menu li {
        flex: 1;
        height: auto;
    }

    .nav-link {
        padding: 0.5rem 0.5rem;
        font-size: 0.8125rem;
        width: 100%;
        justify-content: center;
        text-align: center;
        height: auto;
    }
    .container {
        padding: 0;
    }

    .container-padded {
        padding: 1rem;
    }

    .container {
        min-height: 100vh; /* Let it grow naturally, don't constrain height */
        height: auto;
    }

    .page-header {
        padding: 0.3rem 1rem 0.15rem;
        margin-bottom: 0.3rem;
    }

    .page-header h2 {
        font-size: 1.15rem;
    }

    .subtitle {
        font-size: 0.7rem;
    }

    .stats-grid {
        grid-template-columns: 1fr 1fr;
        gap: 0.35rem;
        padding: 0 1rem;
        margin-bottom: 0.35rem;
    }

    .stat-card {
        padding: 0.55rem 0.75rem;
    }

    .stat-label {
        font-size: 0.6rem;
    }

    .stat-value {
        font-size: 1.05rem;
    }

    .chart-section {
        min-height: 450px; /* Give chart good visibility on mobile */
        flex: 1;
    }

    .chart-section::after {
        height: 30px; /* Smaller gradient on mobile */
    }

    .chart-card {
        padding: 0.6rem 1rem;
    }

    .chart-card.hero {
        flex: 1;
        min-height: 0;
    }

    .chart-container {
        flex: 1;
        min-height: 0;
    }

    .chart-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }

    .chart-header h3 {
        font-size: 1.1rem;
    }

    .chart-controls {
        width: 100%;
        justify-content: space-between;
    }

    .btn-secondary {
        font-size: 0.85rem;
        padding: 0.4rem 0.8rem;
    }

    .legend-section {
        padding: 0 1rem;
    }

    .agent-legend {
        grid-template-columns: 1fr;
    }

    .legend-item {
        animation: fadeIn 0.4s ease-out backwards;
    }

    .portfolio-grid {
        grid-template-columns: 1fr;
        padding: 0 1rem;
    }

    .agent-selector-section {
        flex-direction: column;
        align-items: flex-start;
        padding: 0 1rem;
    }

    .agent-select {
        width: 100%;
        min-width: unset;
    }

    .holdings-table {
        font-size: 0.8rem;
    }

    .holdings-table th,
    .holdings-table td {
        padding: 0.6rem 0.4rem;
    }

    .trade-item {
        padding: 1rem;
        gap: 1rem;
    }

    .trade-icon {
        width: 40px;
        height: 40px;
        font-size: 1.2rem;
    }

    /* Leaderboard and Action Flow - Mobile */
    .insights-section {
        grid-template-columns: 1fr;
        gap: 1rem;
        padding: 1rem;
    }

    .section-header {
        padding: 1rem 1.25rem;
    }

    .section-header h3 {
        font-size: 1.1rem;
    }

    .leaderboard-list,
    .action-list {
        max-height: 400px;
    }

    .leaderboard-item {
        padding: 0.75rem 1rem;
        gap: 0.75rem;
    }

    .leaderboard-rank {
        font-size: 1.2rem;
        min-width: 32px;
    }

    .leaderboard-icon {
        width: 36px;
        height: 36px;
    }

    .leaderboard-name {
        font-size: 0.9rem;
    }

    .leaderboard-value {
        font-size: 0.8rem;
    }

    .gain-amount {
        font-size: 0.95rem;
    }

    .gain-percent {
        font-size: 0.75rem;
    }

    .action-card {
        margin-bottom: 0.75rem;
    }

    .action-header {
        padding: 0.75rem 1rem;
        flex-wrap: wrap;
    }

    .action-agent-icon {
        width: 32px;
        height: 32px;
    }

    .action-agent-name {
        font-size: 0.85rem;
    }

    .action-details {
        font-size: 0.8rem;
        flex-wrap: wrap;
    }

    .action-timestamp {
        font-size: 0.7rem;
        width: 100%;
        margin-top: 0.25rem;
        margin-left: 0;
    }

    .action-body {
        padding: 0.75rem 1rem;
    }

    .action-thinking {
        font-size: 0.85rem;
        max-height: 150px;
    }
}

/* Animations */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes slideInLeft {
    from {
        opacity: 0;
        transform: translateX(-30px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes slideInRight {
    from {
        opacity: 0;
        transform: translateX(30px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.stat-card,
.chart-card,
.portfolio-card,
.legend-item {
    animation: fadeIn 0.6s ease-out backwards;
}

.stat-card:nth-child(1) { animation-delay: 0.1s; }
.stat-card:nth-child(2) { animation-delay: 0.2s; }
.stat-card:nth-child(3) { animation-delay: 0.3s; }
.stat-card:nth-child(4) { animation-delay: 0.4s; }

.legend-item:nth-child(odd) {
    animation: slideInLeft 0.5s ease-out backwards;
}

.legend-item:nth-child(even) {
    animation: slideInRight 0.5s ease-out backwards;
}

.legend-item:nth-child(1) { animation-delay: 0.1s; }
.legend-item:nth-child(2) { animation-delay: 0.15s; }
.legend-item:nth-child(3) { animation-delay: 0.2s; }
.legend-item:nth-child(4) { animation-delay: 0.25s; }
.legend-item:nth-child(5) { animation-delay: 0.3s; }
.legend-item:nth-child(6) { animation-delay: 0.35s; }

/* ====================================================
   Custom Chart Tooltip Styles - Fully Responsive
   ==================================================== */

/* Base tooltip container */
#chartjs-tooltip {
    /* Solid background with fallback for better readability */
    background: rgba(20, 27, 45, 0.99);
    background: linear-gradient(135deg,
                rgba(26, 34, 56, 0.99) 0%,
                rgba(20, 27, 61, 0.99) 100%);
    border: 1.5px solid rgba(0, 212, 255, 0.6);
    border-radius: clamp(8px, 2vw, 12px);
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.8),
                0 0 25px rgba(0, 212, 255, 0.2),
                inset 0 1px 0 rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(12px) saturate(180%);
    -webkit-backdrop-filter: blur(12px) saturate(180%);
    font-family: var(--font-primary);
    padding: 0;
    pointer-events: none;
    z-index: 10000;
    width: auto;
    min-width: min(280px, calc(100vw - 40px));
    max-width: min(420px, calc(100vw - 40px));
    transition: opacity 0.2s ease, transform 0.2s ease;
    will-change: transform, opacity;
    overflow: hidden;
}

#chartjs-tooltip .tooltip-container {
    padding: 0;
    display: flex;
    flex-direction: column;
}

/* Tooltip title */
#chartjs-tooltip .tooltip-title {
    background: linear-gradient(90deg,
                rgba(0, 212, 255, 0.35) 0%,
                rgba(0, 255, 204, 0.3) 100%);
    color: var(--accent-blue);
    font-size: clamp(0.7rem, 2vw, 0.85rem);
    font-weight: 600;
    padding: clamp(8px, 2vw, 12px) clamp(12px, 3vw, 16px);
    border-bottom: 1px solid rgba(0, 212, 255, 0.5);
    border-radius: clamp(8px, 2vw, 12px) clamp(8px, 2vw, 12px) 0 0;
    letter-spacing: 0.3px;
    text-transform: uppercase;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
}

/* Tooltip body */
#chartjs-tooltip .tooltip-body {
    padding: clamp(6px, 1.5vw, 8px) clamp(8px, 2vw, 12px) clamp(8px, 2vw, 12px) clamp(8px, 2vw, 12px);
    max-height: calc(100vh - 100px);
    overflow-y: auto;
    overflow-x: hidden;
    background: rgba(16, 22, 40, 0.7);
}

/* Scrollbar styling for tooltip body */
#chartjs-tooltip .tooltip-body::-webkit-scrollbar {
    width: 6px;
}

#chartjs-tooltip .tooltip-body::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 3px;
}

#chartjs-tooltip .tooltip-body::-webkit-scrollbar-thumb {
    background: rgba(0, 212, 255, 0.3);
    border-radius: 3px;
}

#chartjs-tooltip .tooltip-body::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 212, 255, 0.5);
}

/* Tooltip row */
#chartjs-tooltip .tooltip-row {
    display: flex;
    align-items: center;
    gap: clamp(6px, 1.5vw, 10px);
    padding: clamp(6px, 1.5vw, 8px) clamp(4px, 1vw, 6px);
    border-radius: 6px;
    transition: background-color 0.15s ease;
    margin-bottom: 3px;
    min-height: 32px;
}

#chartjs-tooltip .tooltip-row:last-child {
    margin-bottom: 0;
}

/* Rank badge */
#chartjs-tooltip .rank-badge {
    background: linear-gradient(135deg, rgba(0, 212, 255, 0.4) 0%, rgba(0, 255, 204, 0.35) 100%);
    color: var(--accent-blue);
    font-size: clamp(0.65rem, 1.5vw, 0.7rem);
    font-weight: 700;
    padding: clamp(2px, 0.5vw, 3px) clamp(5px, 1.5vw, 7px);
    border-radius: 6px;
    min-width: clamp(26px, 6vw, 30px);
    text-align: center;
    font-family: var(--font-mono);
    border: 1px solid rgba(0, 212, 255, 0.6);
    letter-spacing: 0.5px;
    flex-shrink: 0;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.6);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.1);
}

/* Tooltip icon */
#chartjs-tooltip .tooltip-icon {
    width: clamp(20px, 5vw, 24px);
    height: clamp(20px, 5vw, 24px);
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.05);
    padding: 3px;
    flex-shrink: 0;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    object-fit: contain;
}

/* Tooltip label */
#chartjs-tooltip .tooltip-label {
    flex: 1;
    font-size: clamp(0.75rem, 2vw, 0.9rem);
    font-weight: 500;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    letter-spacing: 0.2px;
    min-width: 0;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.6);
}

/* Tooltip value */
#chartjs-tooltip .tooltip-value {
    font-family: var(--font-mono);
    font-size: clamp(0.8rem, 2vw, 0.95rem);
    font-weight: 600;
    color: var(--text-primary);
    letter-spacing: -0.5px;
    text-align: right;
    min-width: clamp(80px, 20vw, 100px);
    background: rgba(0, 212, 255, 0.2);
    padding: clamp(3px, 1vw, 4px) clamp(6px, 2vw, 10px);
    border-radius: 6px;
    border: 1px solid rgba(0, 212, 255, 0.4);
    flex-shrink: 0;
    white-space: nowrap;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.6);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

/* First place highlight */
#chartjs-tooltip .tooltip-row:first-child .rank-badge {
    background: linear-gradient(135deg, rgba(255, 215, 0, 0.5) 0%, rgba(255, 193, 7, 0.45) 100%);
    color: #ffd700;
    border-color: rgba(255, 215, 0, 0.7);
    font-weight: 800;
    box-shadow: 0 0 12px rgba(255, 215, 0, 0.4),
                inset 0 1px 0 rgba(255, 255, 255, 0.2);
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.8);
}

#chartjs-tooltip .tooltip-row:first-child .tooltip-value {
    background: rgba(255, 215, 0, 0.25);
    border-color: rgba(255, 215, 0, 0.5);
    color: #ffd700;
    font-weight: 700;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.1),
                0 0 8px rgba(255, 215, 0, 0.2);
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.8);
}

/* Second place highlight */
#chartjs-tooltip .tooltip-row:nth-child(2) .rank-badge {
    background: linear-gradient(135deg, rgba(192, 192, 192, 0.4) 0%, rgba(169, 169, 169, 0.35) 100%);
    color: #c0c0c0;
    border-color: rgba(192, 192, 192, 0.6);
}

/* Third place highlight */
#chartjs-tooltip .tooltip-row:nth-child(3) .rank-badge {
    background: linear-gradient(135deg, rgba(205, 127, 50, 0.4) 0%, rgba(184, 115, 51, 0.35) 100%);
    color: #cd7f32;
    border-color: rgba(205, 127, 50, 0.6);
}

/* ====================================================
   Responsive Breakpoints
   ==================================================== */

/* Large desktop (1920px+) */
@media (min-width: 1920px) {
    #chartjs-tooltip {
        max-width: 450px;
        min-width: 320px;
    }
}

/* Standard desktop (1200px - 1919px) */
@media (min-width: 1200px) and (max-width: 1919px) {
    #chartjs-tooltip {
        max-width: 400px;
        min-width: 300px;
    }
}

/* Tablet landscape (900px - 1199px) */
@media (min-width: 900px) and (max-width: 1199px) {
    #chartjs-tooltip {
        max-width: 360px;
        min-width: 280px;
    }
    
    #chartjs-tooltip .tooltip-row {
        gap: 8px;
    }
}

/* Tablet portrait (600px - 899px) */
@media (min-width: 600px) and (max-width: 899px) {
    #chartjs-tooltip {
        max-width: 320px;
        min-width: 260px;
    }
    
    #chartjs-tooltip .tooltip-title {
        font-size: 0.75rem;
        padding: 8px 12px;
    }
    
    #chartjs-tooltip .tooltip-body {
        padding: 6px 10px 10px 10px;
    }
    
    #chartjs-tooltip .tooltip-row {
        gap: 7px;
        padding: 6px 4px;
    }
    
    #chartjs-tooltip .rank-badge {
        font-size: 0.65rem;
        min-width: 28px;
        padding: 2px 6px;
    }
    
    #chartjs-tooltip .tooltip-icon {
        width: 20px;
        height: 20px;
    }
    
    #chartjs-tooltip .tooltip-label {
        font-size: 0.8rem;
    }
    
    #chartjs-tooltip .tooltip-value {
        font-size: 0.85rem;
        min-width: 90px;
        padding: 3px 8px;
    }
}

/* Mobile (360px - 599px) */
@media (max-width: 599px) {
    #chartjs-tooltip {
        max-width: calc(100vw - 30px);
        min-width: min(240px, calc(100vw - 30px));
        border-radius: 10px;
    }
    
    #chartjs-tooltip .tooltip-title {
        font-size: 0.7rem;
        padding: 7px 10px;
        letter-spacing: 0.2px;
    }
    
    #chartjs-tooltip .tooltip-body {
        padding: 5px 8px 8px 8px;
        max-height: calc(100vh - 120px);
    }
    
    #chartjs-tooltip .tooltip-row {
        gap: 6px;
        padding: 5px 3px;
        min-height: 28px;
    }
    
    #chartjs-tooltip .rank-badge {
        font-size: 0.6rem;
        min-width: 24px;
        padding: 2px 4px;
        letter-spacing: 0.3px;
    }
    
    #chartjs-tooltip .tooltip-icon {
        width: 18px;
        height: 18px;
        padding: 2px;
    }
    
    #chartjs-tooltip .tooltip-label {
        font-size: 0.75rem;
        letter-spacing: 0.1px;
    }
    
    #chartjs-tooltip .tooltip-value {
        font-size: 0.8rem;
        min-width: 75px;
        padding: 2px 6px;
        letter-spacing: -0.3px;
    }
}

/* Small mobile (< 360px) */
@media (max-width: 359px) {
    #chartjs-tooltip {
        max-width: calc(100vw - 20px);
        min-width: calc(100vw - 20px);
    }
    
    #chartjs-tooltip .tooltip-title {
        font-size: 0.65rem;
        padding: 6px 8px;
    }
    
    #chartjs-tooltip .tooltip-row {
        gap: 4px;
        padding: 4px 2px;
    }
    
    #chartjs-tooltip .rank-badge {
        font-size: 0.55rem;
        min-width: 22px;
        padding: 1px 3px;
    }
    
    #chartjs-tooltip .tooltip-icon {
        width: 16px;
        height: 16px;
    }
    
    #chartjs-tooltip .tooltip-label {
        font-size: 0.7rem;
    }
    
    #chartjs-tooltip .tooltip-value {
        font-size: 0.75rem;
        min-width: 70px;
        padding: 2px 5px;
    }
}

/* High DPI displays */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    #chartjs-tooltip .tooltip-icon {
        image-rendering: -webkit-optimize-contrast;
        image-rendering: crisp-edges;
    }
}

/* Landscape orientation adjustments */
@media (max-height: 600px) and (orientation: landscape) {
    #chartjs-tooltip {
        max-height: calc(100vh - 60px);
    }
    
    #chartjs-tooltip .tooltip-body {
        max-height: calc(100vh - 120px);
    }
    
    #chartjs-tooltip .tooltip-row {
        padding: 4px 4px;
        min-height: 26px;
    }
}

/* Live Update Animations */

/* Glowing point pulse animation for chart endpoints */
@keyframes chart-point-pulse {
    0%, 100% {
        box-shadow: 0 0 10px currentColor,
        0 0 20px currentColor,
        0 0 30px currentColor;
        transform: scale(1);
    }
    50% {
        box-shadow: 0 0 15px currentColor,
        0 0 30px currentColor,
        0 0 45px currentColor,
        0 0 60px currentColor;
        transform: scale(1.15);
    }
}

@keyframes chart-point-ripple {
    0% {
        transform: scale(1);
        opacity: 0.8;
    }
    100% {
        transform: scale(2.5);
        opacity: 0;
    }
}

/* Leaderboard live update animation */
@keyframes leaderboard-pulse {
    0%, 100% {
        box-shadow: 0 0 0 0 rgba(0, 212, 255, 0);
    }
    50% {
        box-shadow: 0 0 0 4px rgba(0, 212, 255, 0.2),
        0 0 12px 2px rgba(0, 212, 255, 0.1);
    }
}

@keyframes leaderboard-glow {
    0%, 100% {
        background: var(--secondary-bg);
    }
    50% {
        background: linear-gradient(90deg,
        var(--secondary-bg) 0%,
        rgba(0, 212, 255, 0.05) 50%,
        var(--secondary-bg) 100%);
    }
}

.leaderboard-item {
    animation: leaderboard-glow 3s ease-in-out infinite;
}

.leaderboard-item:nth-child(1) {
    animation-delay: 0s;
}

.leaderboard-item:nth-child(2) {
    animation-delay: 0.3s;
}

.leaderboard-item:nth-child(3) {
    animation-delay: 0.6s;
}

.leaderboard-item:nth-child(4) {
    animation-delay: 0.9s;
}

.leaderboard-item:nth-child(5) {
    animation-delay: 1.2s;
}

.leaderboard-item:nth-child(n+6) {
    animation-delay: 1.5s;
}

/* Leaderboard icon pulse */
.leaderboard-icon {
    position: relative;
}

.leaderboard-icon::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 100%;
    height: 100%;
    border-radius: 10px;
    background: radial-gradient(circle, var(--accent-blue) 0%, transparent 70%);
    transform: translate(-50%, -50%);
    opacity: 0;
    animation: icon-ping 3s cubic-bezier(0, 0, 0.2, 1) infinite;
    pointer-events: none;
}

.leaderboard-icon:nth-child(1)::after {
    animation-delay: 0s;
}

.leaderboard-icon:nth-child(2)::after {
    animation-delay: 0.3s;
}

@keyframes icon-ping {
    0% {
        transform: translate(-50%, -50%) scale(1);
        opacity: 0.8;
    }
    50%, 100% {
        transform: translate(-50%, -50%) scale(1.5);
        opacity: 0;
    }
}

/* Action card live update animation */
.action-card {
    position: relative;
    animation: action-card-slide-in 0.4s ease-out;
}

@keyframes action-card-slide-in {
    from {
        opacity: 0;
        transform: translateX(-20px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.action-card::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    width: 3px;
    height: 100%;
    background: linear-gradient(180deg,
    transparent 0%,
    var(--accent-blue) 20%,
    var(--accent-cyan) 50%,
    var(--accent-blue) 80%,
    transparent 100%);
    opacity: 0;
    animation: action-card-edge-glow 2.5s ease-in-out infinite;
}

@keyframes action-card-edge-glow {
    0%, 100% {
        opacity: 0;
        transform: translateY(-100%);
    }
    50% {
        opacity: 0.6;
        transform: translateY(100%);
    }
}

.action-card:nth-child(1)::before {
    animation-delay: 0s;
}

.action-card:nth-child(2)::before {
    animation-delay: 0.4s;
}

.action-card:nth-child(3)::before {
    animation-delay: 0.8s;
}

.action-card:nth-child(4)::before {
    animation-delay: 1.2s;
}

.action-card:nth-child(n+5)::before {
    animation-delay: 1.6s;
}

/* Action agent icon ripple effect */
.action-agent-icon {
    position: relative;
    overflow: visible;
}

.action-agent-icon::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 100%;
    height: 100%;
    border: 2px solid var(--accent-cyan);
    border-radius: 8px;
    transform: translate(-50%, -50%);
    opacity: 0;
    animation: action-icon-ripple 2.5s ease-out infinite;
}

@keyframes action-icon-ripple {
    0% {
        transform: translate(-50%, -50%) scale(1);
        opacity: 0.6;
    }
    100% {
        transform: translate(-50%, -50%) scale(1.8);
        opacity: 0;
    }
}

/* Live indicator dot */
.live-indicator {
    display: inline-block;
    width: 8px;
    height: 8px;
    background: var(--success);
    border-radius: 50%;
    margin-left: 0.5rem;
    position: relative;
    animation: live-blink 2s ease-in-out infinite;
}

.live-indicator::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 100%;
    height: 100%;
    background: var(--success);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    animation: live-ping 2s cubic-bezier(0, 0, 0.2, 1) infinite;
}

@keyframes live-blink {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.5;
    }
}

@keyframes live-ping {
    0% {
        transform: translate(-50%, -50%) scale(1);
        opacity: 1;
    }
    100% {
        transform: translate(-50%, -50%) scale(3);
        opacity: 0;
    }
}

/* Transaction type badge pulse */
.action-type {
    position: relative;
    animation: badge-subtle-glow 3s ease-in-out infinite;
}

.action-type.buy {
    animation-name: badge-buy-glow;
}

.action-type.sell {
    animation-name: badge-sell-glow;
}

@keyframes badge-buy-glow {
    0%, 100% {
        box-shadow: 0 0 0 0 rgba(72, 187, 120, 0);
    }
    50% {
        box-shadow: 0 0 8px 2px rgba(72, 187, 120, 0.3);
    }
}

@keyframes badge-sell-glow {
    0%, 100% {
        box-shadow: 0 0 0 0 rgba(245, 101, 101, 0);
    }
    50% {
        box-shadow: 0 0 8px 2px rgba(245, 101, 101, 0.3);
    }
}

/* Print styles */
@media print {
    #chartjs-tooltip {
        display: none !important;
    }
}
