/* ============================================
   Allora Worker Metrics Dashboard
   A modern, sleek dashboard with deep space aesthetics
   ============================================ */

:root {
    /* Color palette - Deep space with electric accents */
    --bg-primary: #0a0e14;
    --bg-secondary: #111822;
    --bg-tertiary: #1a2332;
    --bg-card: #151c28;
    --bg-hover: #1e2a3d;
    
    /* Accent colors */
    --accent-primary: #00d4aa;
    --accent-secondary: #5de4c7;
    --accent-blue: #7dcfff;
    --accent-purple: #bb9af7;
    --accent-orange: #ff9e64;
    --accent-red: #f7768e;
    --accent-yellow: #e0af68;
    
    /* Text colors */
    --text-primary: #e4e8eb;
    --text-secondary: #9aa5b1;
    --text-muted: #5c6b7a;
    
    /* Borders */
    --border-color: #2a3545;
    --border-subtle: #1e2a3d;
    
    /* Shadows */
    --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.5);
    --shadow-glow: 0 0 20px rgba(0, 212, 170, 0.15);
    
    /* Typography */
    --font-sans: 'Outfit', -apple-system, BlinkMacSystemFont, sans-serif;
    --font-mono: 'JetBrains Mono', 'Fira Code', monospace;
    
    /* Spacing */
    --sidebar-width: 260px;
    --header-height: 70px;
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    
    /* Transitions */
    --transition-fast: 150ms ease;
    --transition-normal: 250ms ease;
}

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

html {
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

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

/* App Layout */
.app {
    display: flex;
    min-height: 100vh;
}

/* ============================================
   Sidebar
   ============================================ */
.sidebar {
    width: var(--sidebar-width);
    background: var(--bg-secondary);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    position: fixed;
    height: 100vh;
    z-index: 100;
}

.sidebar-header {
    padding: 24px 20px;
    display: flex;
    align-items: center;
    gap: 12px;
    border-bottom: 1px solid var(--border-subtle);
}

.logo {
    color: var(--accent-primary);
    display: flex;
    align-items: center;
}

.sidebar-header h1 {
    font-size: 1.1rem;
    font-weight: 600;
    letter-spacing: -0.02em;
}

.nav-section {
    padding: 16px 12px;
}

.nav-label {
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
    padding: 0 8px 8px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 500;
    transition: all var(--transition-fast);
}

.nav-item:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.nav-item.active {
    background: linear-gradient(135deg, rgba(0, 212, 170, 0.15), rgba(0, 212, 170, 0.05));
    color: var(--accent-primary);
    border: 1px solid rgba(0, 212, 170, 0.2);
}

.nav-item svg {
    flex-shrink: 0;
}

/* Network Toggle - Sleek pill toggle in header */
.network-toggle {
    display: flex;
    position: relative;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 24px;
    padding: 3px;
    gap: 0;
}

.network-btn {
    position: relative;
    padding: 6px 14px;
    background: transparent;
    border: none;
    border-radius: 20px;
    color: var(--text-muted);
    font-family: var(--font-sans);
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    cursor: pointer;
    transition: all var(--transition-fast);
    z-index: 2;
    white-space: nowrap;
}

.network-btn:hover {
    color: var(--text-secondary);
}

.network-btn.active {
    color: var(--bg-primary);
}

.network-slider {
    position: absolute;
    top: 3px;
    bottom: 3px;
    width: calc(50% - 3px);
    background: var(--accent-primary);
    border-radius: 20px;
    transition: transform var(--transition-normal) cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 1;
}

.network-toggle[data-active="testnet"] .network-slider {
    transform: translateX(0);
}

.network-toggle[data-active="mainnet"] .network-slider {
    transform: translateX(100%);
}

.header-center {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
    flex-wrap: wrap;
    flex: 1;
    min-width: 0;
}

/* Global Date Picker */
.global-date-picker {
    display: flex;
    align-items: center;
    gap: 6px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    flex-wrap: wrap;
    padding: 6px 10px;
    font-size: 0.8rem;
    flex-shrink: 1;
    min-width: 0;
}

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

.global-date-picker input[type="date"] {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    color: var(--text-primary);
    padding: 4px 8px;
    font-family: var(--font-mono);
    font-size: 0.8rem;
}

.global-date-picker input[type="date"]:focus {
    outline: none;
    border-color: var(--accent-primary);
}

.global-date-picker .btn-sm {
    padding: 4px 10px;
    font-size: 0.8rem;
    border-radius: 4px;
}

.window-buttons {
    display: flex;
    gap: 4px;
}

.btn-window {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.15s ease;
}

.btn-window:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.btn-window.active {
    background: var(--accent-primary);
    border-color: var(--accent-primary);
    color: #fff;
}

.date-separator {
    color: var(--text-secondary);
    opacity: 0.4;
    margin: 0 2px;
}

.global-date-picker input[type="date"]:disabled,
.global-date-picker .btn-sm:disabled {
    opacity: 0.35;
    cursor: not-allowed;
    pointer-events: none;
}

.sidebar-footer {
    margin-top: auto;
    padding: 16px 12px;
    border-top: 1px solid var(--border-subtle);
}

/* ============================================
   Main Content
   ============================================ */
.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    display: flex;
    flex-direction: column;
    max-width: calc(100vw - var(--sidebar-width));
    overflow-x: hidden;
}

/* Header */
.header {
    min-height: var(--header-height);
    padding: 12px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 10px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    z-index: 50;
    max-width: 100%;
    overflow: hidden;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
}

.header-left h2 {
    font-size: 1.1rem;
    font-weight: 600;
    white-space: nowrap;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 16px;
    flex-shrink: 0;
}

.api-key-input {
    display: flex;
    gap: 8px;
}

.api-key-input input {
    padding: 8px 14px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-family: var(--font-mono);
    font-size: 0.85rem;
    width: 200px;
    outline: none;
    transition: border-color var(--transition-fast);
}

.api-key-input input:focus {
    border-color: var(--accent-primary);
}

/* Buttons */
.btn {
    padding: 8px 16px;
    border-radius: var(--radius-sm);
    font-family: var(--font-sans);
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-fast);
    border: none;
    outline: none;
}

.btn-primary {
    background: var(--accent-primary);
    color: var(--bg-primary);
}

.btn-primary:hover {
    background: var(--accent-secondary);
    box-shadow: var(--shadow-glow);
}

.btn-small {
    padding: 6px 12px;
    font-size: 0.8rem;
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
}

.btn-small:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.btn-secondary {
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
}

.btn-secondary:hover {
    background: var(--accent-red);
    color: var(--bg-primary);
    border-color: var(--accent-red);
}

/* Status Indicator */
.status-indicator {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.8rem;
    font-weight: 500;
}

.status-indicator::before {
    content: '';
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--accent-red);
}

.status-indicator.connected::before {
    background: var(--accent-primary);
    box-shadow: 0 0 8px var(--accent-primary);
}

.status-indicator.disconnected {
    color: var(--text-muted);
}

.status-indicator.connected {
    color: var(--accent-primary);
}

/* ============================================
   Views
   ============================================ */
.view {
    display: none;
    padding: 32px;
    flex: 1;
    overflow-x: auto;
    max-width: 100%;
}

.view.active {
    display: block;
}

.view-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
    position: relative;
    z-index: 1;
}

.view-header h3 {
    font-size: 1.1rem;
    font-weight: 600;
}

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 20px;
    margin-bottom: 32px;
}

.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 24px;
    display: flex;
    align-items: center;
    gap: 20px;
    transition: all var(--transition-normal);
}

.stat-card:hover {
    border-color: var(--border-subtle);
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.stat-icon {
    width: 56px;
    height: 56px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
}

.stat-icon.topics {
    background: linear-gradient(135deg, rgba(125, 207, 255, 0.2), rgba(125, 207, 255, 0.05));
    color: var(--accent-blue);
}

.stat-icon.workers {
    background: linear-gradient(135deg, rgba(187, 154, 247, 0.2), rgba(187, 154, 247, 0.05));
    color: var(--accent-purple);
}

.stat-icon.inferences {
    background: linear-gradient(135deg, rgba(0, 212, 170, 0.2), rgba(0, 212, 170, 0.05));
    color: var(--accent-primary);
}

.stat-icon.candles {
    background: linear-gradient(135deg, rgba(255, 158, 100, 0.2), rgba(255, 158, 100, 0.05));
    color: var(--accent-orange);
}

.stat-content {
    display: flex;
    flex-direction: column;
}

.stat-value {
    font-size: 1.75rem;
    font-weight: 700;
    font-family: var(--font-mono);
    letter-spacing: -0.02em;
}

.stat-label {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-top: 2px;
}

/* Dashboard Grid */
.dashboard-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
}

/* Cards */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    overflow: hidden;
}

.card-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-subtle);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.card-header h3 {
    font-size: 0.95rem;
    font-weight: 600;
}

.card-content {
    padding: 20px;
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-muted);
    font-size: 0.9rem;
}

/* Tables */
.table-container {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    overflow: hidden;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
}

.data-table th,
.data-table td {
    padding: 14px 20px;
    text-align: left;
}

.data-table th {
    background: var(--bg-tertiary);
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border-color);
}

.data-table td {
    font-size: 0.9rem;
    border-bottom: 1px solid var(--border-subtle);
}

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

.data-table tbody tr.clickable-row {
    cursor: pointer;
    position: relative;
}

.data-table tbody tr.clickable-row:hover {
    background: var(--bg-hover);
    outline: 1px solid var(--accent);
}

/* Make the link in the first cell cover the entire row for right-click support */
a.row-link {
    color: inherit;
    text-decoration: none;
}

a.row-link::after {
    content: '';
    position: absolute;
    inset: 0;
}

/* Dashboard worker rows and leaderboard rows */
a.worker-row {
    display: flex;
    text-decoration: none;
    color: inherit;
}

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

/* Address styling */
.address {
    font-family: var(--font-mono);
    font-size: 0.85rem;
    color: var(--accent-blue);
}

/* Status badges */
.badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
}

.badge-active {
    background: rgba(0, 212, 170, 0.1);
    color: var(--accent-primary);
    border: 1px solid rgba(0, 212, 170, 0.3);
}

.badge-inactive {
    background: rgba(92, 107, 122, 0.1);
    color: var(--text-muted);
    border: 1px solid rgba(92, 107, 122, 0.3);
}

.badge-target-log_return {
    background: rgba(102, 126, 234, 0.15);
    color: #8b9fea;
    border: 1px solid rgba(102, 126, 234, 0.4);
}

.badge-target-price {
    background: rgba(240, 147, 43, 0.15);
    color: #f5a956;
    border: 1px solid rgba(240, 147, 43, 0.4);
}

.badge-target-unknown {
    background: rgba(92, 107, 122, 0.1);
    color: var(--text-muted);
    border: 1px solid rgba(92, 107, 122, 0.3);
}

/* Metric value colors */
.metric-positive {
    color: #00d4aa !important;
}

.metric-negative {
    color: #ff6b6b !important;
}

/* Topic selector styling */
.topic-selector-section select {
    cursor: pointer;
    transition: border-color 0.2s;
}

.topic-selector-section select:hover {
    border-color: var(--accent-primary);
}

.topic-selector-section select:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 2px rgba(0, 212, 170, 0.2);
}

/* Topic metrics header */
.topic-metrics-header {
    border: 1px solid var(--border-color);
}

/* Search */
.search-box input {
    padding: 10px 16px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 0.9rem;
    width: 280px;
    outline: none;
    transition: border-color var(--transition-fast);
}

.search-box input:focus {
    border-color: var(--accent-primary);
}

/* Pagination */
.pagination {
    display: flex;
    justify-content: center;
    gap: 8px;
    padding: 20px;
}

.pagination button {
    padding: 8px 14px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.pagination button:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.pagination button.active {
    background: var(--accent-primary);
    color: var(--bg-primary);
    border-color: var(--accent-primary);
}

/* Leaderboard filters */
.leaderboard-filters {
    display: flex;
    gap: 12px;
    align-items: center;
}

.leaderboard-filters select,
.leaderboard-filters .search-input {
    padding: 8px 14px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 0.85rem;
    outline: none;
}

.leaderboard-filters select {
    cursor: pointer;
}

.leaderboard-filters .search-input {
    width: 280px;
}

.leaderboard-filters .search-input::placeholder {
    color: var(--text-muted);
}

.leaderboard-filters .search-input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 2px rgba(56, 189, 248, 0.1);
}


/* Worker detail styles */
.worker-detail-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 24px;
}

.detail-card {
    background: var(--bg-tertiary);
    border-radius: var(--radius-sm);
    padding: 16px;
}

.detail-card h4 {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    margin-bottom: 8px;
}

.detail-card .value {
    font-size: 1.2rem;
    font-weight: 600;
    font-family: var(--font-mono);
}

/* Responsive */
@media (max-width: 1200px) {
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .dashboard-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
    }
    
    .main-content {
        margin-left: 0;
        max-width: 100vw;
    }
    
    .stats-grid {
        grid-template-columns: 1fr;
    }
    
    .header {
        padding: 10px 12px;
    }
    
    .header-center {
        order: 3;
        width: 100%;
        justify-content: flex-start;
    }
    
    .global-date-picker {
        width: 100%;
    }
}

@media (max-width: 1024px) {
    .header-center {
        gap: 10px;
    }
    
    .global-date-picker label {
        font-size: 0.75rem;
    }
    
    .global-date-picker input[type="date"] {
        font-size: 0.75rem;
        padding: 3px 6px;
    }
    
    .global-date-picker .btn-sm {
        padding: 3px 8px;
        font-size: 0.75rem;
    }
}

/* Loading spinner */
.loading {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 2px solid var(--border-color);
    border-top-color: var(--accent-primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

/* Rank badge for leaderboard */
.rank {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    font-weight: 600;
    font-size: 0.85rem;
}

.rank-1 {
    background: linear-gradient(135deg, #ffd700, #ffb700);
    color: #1a1a1a;
}

.rank-2 {
    background: linear-gradient(135deg, #c0c0c0, #a0a0a0);
    color: #1a1a1a;
}

.rank-3 {
    background: linear-gradient(135deg, #cd7f32, #b57030);
    color: #1a1a1a;
}

/* Action buttons */
.action-btn {
    padding: 6px 12px;
    background: transparent;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: 0.8rem;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.action-btn:hover {
    background: var(--accent-primary);
    border-color: var(--accent-primary);
    color: var(--bg-primary);
}

/* ============================================
   Worker Metrics View (Embedded - Compact Single Pane)
   ============================================ */

/* Worker metrics view - only shows when active */
.wm-view {
    flex-direction: column;
    height: calc(100vh - var(--header-height) - 64px);
    padding: 12px !important;
    overflow-x: auto;
    overflow-y: auto;
}

/* Override the default block display for this view */
.wm-view.active {
    display: flex;
}

/* Compact Info Bar */
.wm-info-bar {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 8px 12px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    margin-bottom: 10px;
    flex-shrink: 0;
    flex-wrap: wrap;
}

.wm-worker-info {
    display: flex;
    align-items: center;
    gap: 6px;
}

.wm-label {
    font-size: 0.6rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-muted);
}

.wm-address {
    font-family: var(--font-mono);
    font-size: 0.75rem;
    color: var(--accent-primary);
}

.wm-stats {
    display: flex;
    gap: 1rem;
}

.wm-stat {
    display: flex;
    align-items: center;
    gap: 4px;
}

.wm-value {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-primary);
}

.wm-topic-selector {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-left: auto;
}

#wm-topic-select {
    background: var(--bg-tertiary);
    border: 2px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    padding: 6px 10px;
    font-size: 0.8rem;
    min-width: 200px;
    cursor: pointer;
    outline: none;
    transition: all var(--transition-fast);
}

#wm-topic-select:hover,
#wm-topic-select:focus {
    border-color: var(--accent-primary);
}

/* Pulsating glow effect when topic needs to be selected */
#wm-topic-select.needs-selection {
    border-color: var(--accent-primary);
    animation: pulse-glow 2s ease-in-out infinite;
}

@keyframes pulse-glow {
    0%, 100% {
        box-shadow: 0 0 5px rgba(0, 212, 170, 0.3), 0 0 10px rgba(0, 212, 170, 0.2);
        border-color: var(--accent-primary);
    }
    50% {
        box-shadow: 0 0 15px rgba(0, 212, 170, 0.6), 0 0 30px rgba(0, 212, 170, 0.4), 0 0 45px rgba(0, 212, 170, 0.2);
        border-color: var(--accent-secondary);
    }
}

/* Arrow indicator pointing to selector */
.wm-select-prompt {
    display: none;
    align-items: center;
    gap: 8px;
    color: var(--accent-primary);
    font-size: 0.8rem;
    font-weight: 600;
    animation: bounce-arrow 1s ease-in-out infinite;
}

.wm-select-prompt.show {
    display: flex;
}

@keyframes bounce-arrow {
    0%, 100% { transform: translateX(0); }
    50% { transform: translateX(5px); }
}

.wm-topic-badges {
    display: flex;
    gap: 4px;
}

.wm-badge {
    padding: 3px 8px;
    border-radius: 12px;
    font-size: 0.65rem;
    font-weight: 600;
    text-transform: uppercase;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
}

.wm-badge.asset {
    color: var(--accent-primary);
    border-color: rgba(0, 212, 170, 0.3);
}

.wm-badge.horizon {
    color: var(--accent-blue);
    border-color: rgba(125, 207, 255, 0.3);
}

.wm-badge.target {
    color: var(--accent-orange);
    border-color: rgba(255, 158, 100, 0.3);
}

/* Main Content Grid - Fill remaining space */
.wm-main-content {
    display: grid;
    grid-template-columns: 1fr 300px;
    gap: 10px;
    flex: 1;
    min-height: 0;
    overflow: hidden;
}

/* Chart Section */
.wm-chart-section {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 12px;
    display: flex;
    flex-direction: column;
    min-height: 0;
    overflow: hidden;
}

.wm-chart-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
    flex-shrink: 0;
}

.wm-chart-header h2 {
    font-size: 0.9rem;
    font-weight: 600;
}

.wm-chart-stats {
    display: flex;
    gap: 12px;
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.wm-chart-stats strong {
    color: var(--accent-primary);
}

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

.wm-chart-container canvas {
    width: 100% !important;
    height: 100% !important;
}

.wm-chart-legend {
    display: flex;
    justify-content: center;
    gap: 16px;
    padding-top: 8px;
    flex-shrink: 0;
}

.wm-legend-item {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 0.7rem;
    color: var(--text-muted);
}

.wm-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
}

.wm-line {
    width: 16px;
    height: 2px;
    border-radius: 1px;
}

.wm-dot.data-point { background: var(--accent-blue); }
.wm-line.regression-line { background: var(--accent-primary); }
.wm-line.perfect-line { background: var(--text-muted); }

/* Loading State */
.wm-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex: 1;
    gap: 10px;
    color: var(--text-muted);
}

.wm-loading span {
    font-size: 0.8rem;
}

/* Metrics Panel - Compact */
.wm-metrics-panel {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 10px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    overflow: hidden;
}

.wm-metrics-panel h2 {
    font-size: 0.85rem;
    font-weight: 600;
    padding-bottom: 6px;
    border-bottom: 1px solid var(--border-subtle);
    flex-shrink: 0;
}

.wm-metrics-scroll {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.wm-metrics-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.wm-metrics-group h3 {
    font-size: 0.55rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-muted);
    margin-bottom: 2px;
}

.wm-metric-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px;
}

.wm-metric-card {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-subtle);
    border-radius: 4px;
    padding: 6px 8px;
}

.wm-metric-label {
    font-size: 0.6rem;
    color: var(--text-secondary);
    margin-bottom: 2px;
}

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

.wm-metric-value.positive { color: var(--accent-primary); }
.wm-metric-value.negative { color: var(--accent-red); }

.wm-metric-value.small {
    font-size: 0.75rem;
}

/* Confidence Interval Display */
.wm-ci {
    font-size: 0.65rem;
    color: var(--text-muted);
    font-family: var(--font-mono);
    margin-top: 2px;
}

.wm-ci.small {
    font-size: 0.6rem;
}

/* RMS Score Group Styling */
.rms-score-group {
    background: linear-gradient(135deg, rgba(0, 212, 170, 0.1) 0%, rgba(59, 130, 246, 0.05) 100%);
    border-radius: 8px;
    padding: 8px;
    margin: -4px;
}

.rms-score-group h3 {
    color: var(--accent-primary);
}

.score-card .wm-metric-value {
    font-size: 1.2rem;
    font-weight: 800;
}

/* Data Info Footer */
.wm-data-info {
    background: var(--bg-tertiary);
    border-radius: 4px;
    padding: 6px 8px;
    font-size: 0.65rem;
    color: var(--text-secondary);
    display: flex;
    flex-direction: column;
    gap: 2px;
    flex-shrink: 0;
}

.wm-data-info strong {
    color: var(--accent-primary);
}

/* Responsive */
@media (max-width: 1100px) {
    .wm-main-content {
        grid-template-columns: 1fr;
        overflow-y: auto;
    }
    
    .wm-view {
        height: auto;
        overflow-y: auto;
    }
    
    .wm-chart-section {
        min-height: 400px;
    }
}

@media (max-height: 800px) {
    .wm-view {
        padding: 8px !important;
    }
    
    .wm-info-bar {
        padding: 6px 10px;
        margin-bottom: 8px;
    }
    
    .wm-main-content {
        gap: 8px;
    }
    
    .wm-chart-section,
    .wm-metrics-panel {
        padding: 8px;
    }
    
    .wm-metrics-group h3 {
        font-size: 0.5rem;
    }
    
    .wm-metric-card {
        padding: 4px 6px;
    }
    
    .wm-metric-value {
        font-size: 0.85rem;
    }
    
    .wm-metric-value.small {
        font-size: 0.7rem;
    }
}

/* ============================================
   Date Range Picker (Reusable)
   ============================================ */
.wm-date-range {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 6px 12px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    margin-bottom: 10px;
    flex-shrink: 0;
    flex-wrap: wrap;
}

.wm-date-input {
    display: flex;
    align-items: center;
    gap: 6px;
}

.wm-date-input input[type="datetime-local"] {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    color: var(--text-primary);
    padding: 4px 8px;
    font-size: 0.75rem;
    font-family: var(--font-mono);
    outline: none;
    transition: border-color var(--transition-fast);
}

.wm-date-input input[type="datetime-local"]:hover,
.wm-date-input input[type="datetime-local"]:focus {
    border-color: var(--accent-primary);
}

/* Style the calendar icon */
.wm-date-input input[type="datetime-local"]::-webkit-calendar-picker-indicator {
    filter: invert(0.7);
    cursor: pointer;
}

.wm-apply-btn,
.wm-reset-btn {
    padding: 5px 12px;
    border-radius: 4px;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    cursor: pointer;
    transition: all var(--transition-fast);
    border: 1px solid var(--border-color);
}

.wm-apply-btn {
    background: var(--accent-primary);
    color: var(--bg-primary);
    border-color: var(--accent-primary);
}

.wm-apply-btn:hover {
    background: var(--accent-secondary);
    box-shadow: 0 0 8px rgba(0, 212, 170, 0.3);
}

.wm-reset-btn {
    background: transparent;
    color: var(--text-muted);
}

.wm-reset-btn:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

/* ============================================
   Topic Metrics View
   ============================================ */
/* Network Performance Summary Bar */
.tm-network-summary {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 12px 16px;
    margin-bottom: 12px;
}

.tm-network-metrics {
    display: flex;
    gap: 24px;
    flex-wrap: wrap;
    justify-content: center;
}

.tm-network-metric {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    min-width: 80px;
}

.tm-network-metric .label {
    font-size: 0.7rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.tm-network-metric .value {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--accent);
    font-family: var(--font-mono);
}

/* Chart Section - Full Width */
.tm-chart-section {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 16px;
    margin-bottom: 16px;
}

.tm-chart-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.tm-chart-header h2 {
    font-size: 0.9rem;
    font-weight: 600;
    margin: 0;
}

.tm-chart-wrapper {
    height: 400px;
    position: relative;
    width: 100%;
}

/* Worker Leaderboard Panel */
.tm-workers-panel {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 10px;
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
    overflow: hidden;
}

.tm-workers-panel h2 {
    font-size: 0.8rem;
    font-weight: 600;
    padding-bottom: 6px;
    border-bottom: 1px solid var(--border-subtle);
    flex-shrink: 0;
    margin-bottom: 6px;
}

.tm-workers-list {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.tm-worker-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 8px;
    background: var(--bg-tertiary);
    border-radius: 4px;
    cursor: pointer;
    transition: background var(--transition-fast);
}

.tm-worker-row:hover {
    background: var(--bg-hover);
}

.tm-worker-rank {
    width: 20px;
    height: 20px;
    background: var(--accent-primary);
    color: var(--bg-primary);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.65rem;
    font-weight: 700;
    flex-shrink: 0;
}

.tm-worker-rank.rank-1 { background: linear-gradient(135deg, #ffd700, #ffb700); color: #1a1a1a; }
.tm-worker-rank.rank-2 { background: linear-gradient(135deg, #c0c0c0, #a0a0a0); color: #1a1a1a; }
.tm-worker-rank.rank-3 { background: linear-gradient(135deg, #cd7f32, #b57030); color: #1a1a1a; }

.tm-worker-address {
    font-family: var(--font-mono);
    font-size: 0.7rem;
    color: var(--accent-blue);
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
}

.tm-worker-metric {
    font-size: 0.65rem;
    color: var(--text-muted);
    white-space: nowrap;
}

.tm-worker-metric.positive { color: var(--accent-primary); }
.tm-worker-metric.negative { color: var(--accent-red); }

@media (max-width: 1100px) {
    .tm-main-content {
        grid-template-columns: 1fr;
        overflow-y: auto;
    }
    
    .tm-right-panel {
        flex-direction: row;
        gap: 10px;
    }
    
    .tm-metrics-compact,
    .tm-workers-panel {
        flex: 1;
        min-height: 200px;
    }
}

/* Worker Comparison Table */
.tm-comparison-section {
    margin-top: 16px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 16px;
}

.tm-comparison-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border-subtle);
}

.tm-comparison-header h2 {
    font-size: 1rem;
    font-weight: 600;
    margin: 0;
}

.tm-worker-count {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.tm-comparison-table-wrapper {
    overflow-x: auto;
    max-height: 600px;
    overflow-y: auto;
}

.tm-comparison-table {
    width: 100%;
    min-width: 1200px;
}

.tm-comparison-table th {
    position: sticky;
    top: 0;
    background: var(--bg-tertiary);
    z-index: 10;
    white-space: nowrap;
    padding: 10px 8px;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.tm-comparison-table th.sortable {
    cursor: pointer;
    user-select: none;
}

.tm-comparison-table th.sortable:hover {
    background: var(--bg-hover);
}

.tm-comparison-table th.sortable::after {
    content: '↕';
    margin-left: 4px;
    opacity: 0.3;
    font-size: 0.65rem;
}

.tm-comparison-table th.sortable.sort-asc::after {
    content: '↑';
    opacity: 1;
    color: var(--accent);
}

.tm-comparison-table th.sortable.sort-desc::after {
    content: '↓';
    opacity: 1;
    color: var(--accent);
}

.tm-comparison-table td {
    padding: 8px;
    font-size: 0.8rem;
    white-space: nowrap;
}

.tm-comparison-table .address-cell {
    font-family: var(--font-mono);
    color: var(--accent-blue);
    cursor: pointer;
}

.tm-comparison-table .address-cell:hover {
    text-decoration: underline;
}

.tm-comparison-table .metric-positive {
    color: var(--accent-primary);
}

.tm-comparison-table .metric-negative {
    color: var(--accent-red);
}

.tm-comparison-table .network-row {
    background: linear-gradient(90deg, rgba(56, 189, 248, 0.15) 0%, rgba(56, 189, 248, 0.05) 100%);
    border-left: 3px solid var(--accent);
    font-weight: 600;
}

.tm-comparison-table .network-row td {
    color: var(--accent);
}

.tm-comparison-table .metric-cell {
    text-align: right;
    font-family: var(--font-mono);
    font-size: 0.75rem;
}

/* ============================================
   Leaderboard - Top Earners
   ============================================ */

.leaderboard-container {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

/* Top 3 Row Highlights */
.leaderboard-row.rank-gold {
    background: linear-gradient(90deg, rgba(255, 215, 0, 0.12) 0%, rgba(255, 215, 0, 0.03) 100%);
    border-left: 3px solid #ffd700;
    box-shadow: inset 0 0 20px rgba(255, 215, 0, 0.08);
}
.leaderboard-row.rank-gold:hover {
    background: linear-gradient(90deg, rgba(255, 215, 0, 0.18) 0%, rgba(255, 215, 0, 0.06) 100%);
}
.leaderboard-row.rank-gold .rank {
    background: linear-gradient(135deg, #ffd700, #ffec8b);
    color: #1a1a1a;
    font-weight: 700;
}

.leaderboard-row.rank-silver {
    background: linear-gradient(90deg, rgba(192, 192, 192, 0.12) 0%, rgba(192, 192, 192, 0.03) 100%);
    border-left: 3px solid #c0c0c0;
    box-shadow: inset 0 0 20px rgba(192, 192, 192, 0.08);
}
.leaderboard-row.rank-silver:hover {
    background: linear-gradient(90deg, rgba(192, 192, 192, 0.18) 0%, rgba(192, 192, 192, 0.06) 100%);
}
.leaderboard-row.rank-silver .rank {
    background: linear-gradient(135deg, #c0c0c0, #e8e8e8);
    color: #1a1a1a;
    font-weight: 700;
}

.leaderboard-row.rank-bronze {
    background: linear-gradient(90deg, rgba(205, 127, 50, 0.12) 0%, rgba(205, 127, 50, 0.03) 100%);
    border-left: 3px solid #cd7f32;
    box-shadow: inset 0 0 20px rgba(205, 127, 50, 0.08);
}
.leaderboard-row.rank-bronze:hover {
    background: linear-gradient(90deg, rgba(205, 127, 50, 0.18) 0%, rgba(205, 127, 50, 0.06) 100%);
}
.leaderboard-row.rank-bronze .rank {
    background: linear-gradient(135deg, #cd7f32, #daa06d);
    color: #1a1a1a;
    font-weight: 700;
}

/* Leaderboard Table */
.leaderboard-table {
    width: 100%;
}

.leaderboard-table thead th {
    font-size: 0.75rem;
    padding: 12px 16px;
}

.leaderboard-table .rank-col { width: 60px; text-align: center; }
.leaderboard-table .address-col { width: 180px; }
.leaderboard-table .emissions-col { width: 140px; text-align: right; }
.leaderboard-table .inferences-col { width: 100px; text-align: right; }
.leaderboard-table .topics-col { width: 80px; text-align: right; }

.leaderboard-row {
    cursor: pointer;
    position: relative;
    isolation: isolate;
    transition: all var(--transition-fast);
}

.leaderboard-row:hover {
    background: var(--bg-hover);
}

.leaderboard-row td {
    padding: 14px 16px;
}

.leaderboard-row .emissions-cell {
    color: var(--accent-primary);
    font-weight: 600;
    font-family: var(--font-mono);
    font-size: 0.85rem;
    text-align: right;
}

.leaderboard-row .rank {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    background: var(--bg-tertiary);
    border-radius: 50%;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-secondary);
}

@media (max-width: 768px) {
    .podium {
        flex-direction: column;
        align-items: center;
    }
    
    .podium-card {
        width: 100%;
        max-width: 280px;
    }
}

/* ============================================
   API Endpoint Display
   ============================================ */
.api-endpoint-container {
    margin: 8px 0 16px 0;
    display: none;
}

.api-endpoint-box {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-family: var(--font-mono);
    font-size: 0.8rem;
}

.api-label {
    color: var(--text-muted);
    font-weight: 500;
    white-space: nowrap;
}

.api-url {
    color: var(--accent-blue);
    background: var(--bg-primary);
    padding: 4px 8px;
    border-radius: 4px;
    flex: 1;
    overflow-x: auto;
    white-space: nowrap;
}

.copy-btn {
    background: var(--bg-hover);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    padding: 4px 8px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: all var(--transition-fast);
}

.copy-btn:hover {
    background: var(--accent-primary);
    color: var(--bg-primary);
}

/* Toast Notifications */
.toast-notification {
    position: fixed;
    bottom: 20px;
    right: 20px;
    background: var(--accent-primary);
    color: var(--bg-primary);
    padding: 12px 20px;
    border-radius: var(--radius-sm);
    font-weight: 600;
    font-size: 0.9rem;
    z-index: 1000;
    opacity: 0;
    transform: translateY(20px);
    transition: all 0.3s ease;
    box-shadow: var(--shadow-lg);
}

.toast-notification.show {
    opacity: 1;
    transform: translateY(0);
}
