:root {
  /* Backgrounds */
  --bg-base: #0c0c14;
  --bg-surface: #12121e;
  --bg-elevated: rgba(255, 255, 255, 0.04);
  --bg-hover: rgba(255, 255, 255, 0.06);
  
  /* Brand */
  --color-primary: #00b8d4;
  --color-primary-muted: rgba(0, 184, 212, 0.15);
  --color-primary-border: rgba(0, 184, 212, 0.3);
  --color-secondary: #6d28d9;
  --color-gradient: linear-gradient(135deg, #00b8d4, #6d28d9);
  
  /* Semantic */
  --color-success: #22c55e;
  --color-warning: #f59e0b;
  --color-error: #ef4444;
  
  /* Text */
  --text-primary: #e4e4e7;
  --text-secondary: #71717a;
  --text-muted: #52525b;
  
  /* Borders */
  --border-subtle: rgba(255, 255, 255, 0.06);
  --border-default: rgba(255, 255, 255, 0.1);
  --border-hover: rgba(255, 255, 255, 0.15);
  
  /* Layout (shared across all pages) */
  --container-max-width: 1200px;
  --container-padding: 20px;
  
  /* Spacing */
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 12px;
  --radius-pill: 100px;
  
  /* Typography */
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', 'SF Mono', 'Fira Code', monospace;
  
  /* Transitions */
  --transition-fast: 150ms ease;
  --transition-normal: 200ms ease;
}

* {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
        }
        
        body {
            font-family: var(--font-sans);
            background: linear-gradient(180deg, var(--bg-base) 0%, var(--bg-surface) 100%);
            min-height: 100vh;
            color: var(--text-primary);
        }
        
        .container {
            max-width: var(--container-max-width);
            margin: 0 auto;
            padding: var(--container-padding);
        }
        
        /* Unified Header (same width as .container for alignment) */
        .site-header {
            background: rgba(12, 12, 20, 0.95);
            backdrop-filter: blur(10px);
            border-bottom: 1px solid var(--border-subtle);
            position: sticky;
            top: 0;
            z-index: 100;
        }
        
        .header-container {
            max-width: var(--container-max-width);
            margin: 0 auto;
            padding: 16px var(--container-padding);
            display: flex;
            justify-content: space-between;
            align-items: center;
        }
        
        .logo {
            display: flex;
            align-items: center;
            gap: 10px;
            text-decoration: none;
            transition: opacity var(--transition-normal);
        }
        
        .logo:hover {
            opacity: 0.8;
        }
        
        .logo-icon {
            flex-shrink: 0;
        }
        
        .logo-text {
            font-size: 20px;
            font-weight: 700;
            background: var(--color-gradient);
            -webkit-background-clip: text;
            -webkit-text-fill-color: transparent;
        }
        
        .nav-links {
            display: flex;
            align-items: center;
            gap: 8px;
        }
        
        .nav-link {
            color: var(--text-secondary);
            text-decoration: none;
            padding: 8px 16px;
            border-radius: var(--radius-sm);
            font-size: 14px;
            font-weight: 500;
            transition: all var(--transition-normal);
        }
        
        .nav-link:hover {
            color: #fff;
            background: var(--bg-elevated);
        }
        
        .nav-link.active {
            color: var(--color-primary);
            background: var(--color-primary-muted);
        }
        
        .header-actions {
            display: flex;
            align-items: center;
            gap: 16px;
            margin-left: 24px;
            padding-left: 24px;
            border-left: 1px solid var(--border-default);
        }
        
        .last-updated {
            color: var(--text-muted);
            font-size: 13px;
        }
        
        .refresh-btn {
            background: var(--color-primary);
            border: none;
            padding: 8px 16px;
            border-radius: 8px;
            color: white;
            font-weight: 600;
            font-size: 13px;
            cursor: pointer;
            transition: opacity var(--transition-normal), transform var(--transition-normal);
        }
        
        .refresh-btn:hover {
            opacity: 0.9;
            transform: translateY(-1px);
        }
        
        .refresh-btn:disabled {
            opacity: 0.5;
            cursor: not-allowed;
        }
        
        @media (max-width: 768px) {
            .header-container {
                padding: 12px 16px;
            }
            
            .logo-text {
                display: none;
            }
            
            .nav-link {
                padding: 8px 12px;
                font-size: 13px;
            }
            
            .header-actions {
                margin-left: 12px;
                padding-left: 12px;
            }
            
            .last-updated {
                display: none;
            }
        }
        
        /* Page Title */
        .page-header {
            display: flex;
            justify-content: space-between;
            align-items: center;
            margin-bottom: 30px;
        }
        
        .page-title {
            font-size: 28px;
            color: var(--text-primary);
        }
        
        .control-group {
            display: flex;
            align-items: center;
            gap: 10px;
        }
        
        .control-group label {
            font-size: 12px;
            color: var(--text-muted);
            white-space: nowrap;
            text-transform: uppercase;
            letter-spacing: 0.5px;
            font-weight: 500;
        }
        
        select, .search-input {
            background: var(--bg-elevated);
            border: 1px solid var(--border-default);
            padding: 10px 36px 10px 14px;
            border-radius: var(--radius-md);
            color: var(--text-primary);
            font-size: 14px;
            cursor: pointer;
            appearance: none;
            transition: all var(--transition-normal);
            -webkit-appearance: none;
            -moz-appearance: none;
            background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23888' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
            background-repeat: no-repeat;
            background-position: right 12px center;
            padding-right: 36px;
        }
        
        .search-input {
            cursor: text;
            background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%23888' stroke-width='2'%3E%3Ccircle cx='11' cy='11' r='8'/%3E%3Cline x1='21' y1='21' x2='16.65' y2='16.65'/%3E%3C/svg%3E");
            background-position: right 10px center;
            min-width: 160px;
        }
        
        .search-input::placeholder {
            color: var(--text-muted);
        }
        
        select:hover, .search-input:hover {
            border-color: var(--border-hover);
            background: var(--bg-hover);
        }
        
        select:focus, .search-input:focus {
            outline: none;
            border-color: var(--color-primary);
            box-shadow: 0 0 0 3px rgba(0, 184, 212, 0.15);
        }
        
        select option {
            background: var(--bg-base);
            color: var(--text-primary);
            padding: 10px;
        }
        
        select option:disabled {
            color: var(--text-muted);
        }
        
        .exchange-cards-container {
            margin-bottom: 30px;
        }
        
        .exchange-cards-section-header {
            font-size: 20px;
            font-weight: 600;
            margin-bottom: 20px;
            color: var(--text-primary);
            margin-top: 0;
        }
        
        .exchange-cards-grid {
            display: grid;
            grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
            gap: 12px;
        }
        
        .exchange-card {
            background: var(--bg-elevated);
            border-radius: var(--radius-lg);
            padding: 12px;
            border: 1px solid rgba(255,255,255,0.08);
            transition: all var(--transition-normal);
            cursor: pointer;
            position: relative;
            overflow: hidden;
        }
        
        .exchange-card::before {
            content: '';
            position: absolute;
            top: 0;
            left: 0;
            right: 0;
            height: 3px;
            background: var(--card-accent, var(--color-gradient));
            opacity: 0;
            transition: opacity var(--transition-normal);
        }
        
        .exchange-card:hover {
            background: var(--bg-hover);
            border-color: var(--color-primary-border);
            transform: translateY(-2px);
        }
        
        .exchange-card:hover::before {
            opacity: 1;
        }
        
        .exchange-card.best-rate {
            border-color: var(--color-primary-border);
            background: rgba(0, 184, 212, 0.04);
        }
        
        .exchange-card.best-rate::before {
            opacity: 1;
            background: var(--color-gradient);
        }
        
        .exchange-card-header {
            display: flex;
            align-items: center;
            justify-content: space-between;
            margin-bottom: 4px;
        }
        
        .exchange-card-name {
            font-size: 16px;
            font-weight: 600;
            color: var(--text-primary);
        }
        
        .exchange-card-median {
            text-align: right;
        }
        
        .exchange-card-median .median-label {
            font-size: 9px;
            color: var(--text-muted);
            text-transform: uppercase;
            letter-spacing: 0.5px;
        }
        
        .exchange-card-median .rate-display {
            display: flex;
            align-items: baseline;
            gap: 4px;
            justify-content: flex-end;
        }
        
        .exchange-card-median .median-value {
            font-size: 26px;
            font-weight: 700;
            color: var(--color-primary);
            line-height: 1.2;
            font-variant-numeric: tabular-nums;
        }
        
        .exchange-card-median .rate-unit {
            font-size: 12px;
            color: var(--text-muted);
        }
        
        .exchange-card-stats {
            display: grid;
            grid-template-columns: 1fr 1fr;
            gap: 8px;
            margin-bottom: 10px;
        }
        
        .exchange-card-stat {
            display: flex;
            flex-direction: column;
        }
        
        .exchange-card-stat .stat-label {
            font-size: 9px;
            color: var(--text-muted);
            text-transform: uppercase;
            letter-spacing: 0.5px;
        }
        
        .exchange-card-stat .stat-value {
            font-size: 14px;
            font-weight: 600;
            color: var(--text-primary);
            font-variant-numeric: tabular-nums;
        }
        
        .exchange-card-footer {
            display: flex;
            justify-content: space-between;
            align-items: center;
            font-size: 11px;
            color: var(--text-secondary);
            padding-top: 10px;
            border-top: 1px solid var(--border-subtle);
        }
        
        .exchange-cards-grid .empty-state {
            grid-column: 1 / -1;
            text-align: center;
            padding: 40px 20px;
            color: var(--text-secondary);
            font-size: 14px;
        }
        
        .table-container {
            background: var(--bg-elevated);
            border: 1px solid rgba(255,255,255,0.08);
            border-radius: var(--radius-lg);
            padding: 24px;
            margin-bottom: 30px;
        }
        
        .table-header {
            display: flex;
            flex-direction: column;
            margin-bottom: 20px;
            gap: 16px;
        }
        
        .table-title {
            font-size: 20px;
            font-weight: 600;
            color: var(--text-primary);
            margin: 0;
        }
        
        .table-toolbar {
            display: flex;
            flex-direction: column;
            gap: 12px;
            width: 100%;
        }
        
        .table-controls {
            display: flex;
            flex-direction: column;
            gap: 10px;
        }
        
        .control-group label {
            min-width: 70px;
        }
        
        .control-group select {
            flex: 1;
        }
        
        .search-wrapper {
            width: 100%;
        }
        
        .search-wrapper .search-input {
            width: 100%;
        }
        
        /* Exchange cards grid is defined above in exchange-cards-container section */
        
        .rates-table {
            overflow: hidden;
            border-radius: var(--radius-lg);
        }
        
        .rates-table table {
            width: 100%;
            border-collapse: collapse;
        }
        
        .rates-table th {
            background: rgba(0,0,0,0.4);
            padding: 16px 20px;
            text-align: left;
            font-size: 11px;
            text-transform: uppercase;
            letter-spacing: 0.8px;
            color: var(--text-secondary);
            font-weight: 600;
            border-bottom: 1px solid var(--border-default);
        }
        
        .rates-table td {
            padding: 16px 20px;
            border-bottom: 1px solid var(--border-subtle);
            font-size: 14px;
            font-variant-numeric: tabular-nums;
        }
        
        .rates-table tbody tr {
            transition: all var(--transition-fast);
        }
        
        .rates-table tbody tr:hover {
            background: rgba(0, 212, 255, 0.05);
        }
        
        .rates-table tbody tr:nth-child(even) {
            background: rgba(255,255,255,0.02);
        }
        
        .rates-table tbody tr:nth-child(even):hover {
            background: rgba(0, 212, 255, 0.05);
        }
        
        .rate-value {
            font-weight: 700;
            font-size: 16px;
            color: var(--color-primary);
            font-variant-numeric: tabular-nums;
        }
        
        .asset-cell {
            font-weight: 500;
        }
        
        .asset-desc {
            color: var(--text-secondary);
            font-size: 11px;
            font-weight: 400;
            cursor: help;
        }
        
        .collateral-info {
            color: var(--text-muted);
            font-size: 10px;
            font-weight: 400;
        }
        
        tr.highlight-asset {
            background: rgba(0, 184, 212, 0.08);
            border-left: 3px solid var(--color-primary);
        }
        
        tr.highlight-asset td:first-child {
            padding-left: 9px;
        }
        
        .volume-cell {
            position: relative;
            cursor: help;
        }
        
        .volume-cell .volume-tooltip {
            visibility: hidden;
            opacity: 0;
            position: absolute;
            bottom: 100%;
            left: 50%;
            transform: translateX(-50%);
            background: rgba(0, 0, 0, 0.9);
            color: var(--text-primary);
            padding: 8px 12px;
            border-radius: var(--radius-sm);
            font-size: 12px;
            white-space: nowrap;
            z-index: 100;
            transition: opacity var(--transition-normal), visibility var(--transition-normal);
            border: 1px solid var(--border-default);
            box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
        }
        
        .volume-cell .volume-tooltip::after {
            content: '';
            position: absolute;
            top: 100%;
            left: 50%;
            transform: translateX(-50%);
            border: 6px solid transparent;
            border-top-color: rgba(0, 0, 0, 0.9);
        }
        
        .volume-cell:hover .volume-tooltip {
            visibility: visible;
            opacity: 1;
        }
        
        .volume-source {
            color: var(--color-primary);
            font-weight: 500;
        }
        
        .volume-type {
            color: var(--text-secondary);
            font-style: italic;
        }
        
        .volume-note {
            color: #ffcc00;
            font-size: 11px;
            margin-top: 4px;
        }
        
        .info-icon {
            display: inline-block;
            width: 14px;
            height: 14px;
            margin-left: 4px;
            vertical-align: middle;
            opacity: 0.5;
        }
        
        .volume-cell:hover .info-icon {
            opacity: 1;
        }
        
        .exchange-badge {
            display: inline-flex;
            align-items: center;
            gap: 3px;
            padding: 5px 11px;
            border-radius: 100px;
            font-size: 11px;
            font-weight: 600;
            text-decoration: none;
            transition: all var(--transition-normal);
        }
        
        a.exchange-badge:hover {
            opacity: 0.9;
            transform: translateY(-1px);
            box-shadow: 0 4px 12px rgba(0,0,0,0.3);
        }
        
        .exchange-okx { background: rgba(0, 165, 230, 0.12); color: #0ea5d4; }
        .exchange-bitfinex { background: rgba(14, 210, 105, 0.12); color: #12c76a; }
        .exchange-kucoin { background: rgba(32, 160, 130, 0.12); color: #22a488; }
        .exchange-kraken { background: rgba(120, 85, 200, 0.12); color: #7a56c8; }
        .exchange-coinbase { background: rgba(0, 75, 230, 0.12); color: #004de6; }
        
        .sources-footer {
            margin-top: 30px;
            padding: 24px;
            background: var(--bg-elevated);
            border: 1px solid var(--border-subtle);
            border-radius: var(--radius-lg);
            display: flex;
            align-items: center;
            justify-content: space-between;
            gap: 20px;
            flex-wrap: wrap;
        }
        
        .sources-label {
            color: var(--text-muted);
            font-size: 13px;
        }
        
        .sources-links {
            display: flex;
            gap: 8px;
            flex-wrap: wrap;
        }
        
        .source-link {
            color: var(--text-secondary);
            text-decoration: none;
            font-size: 12px;
            padding: 6px 14px;
            background: var(--bg-elevated);
            border: 1px solid var(--border-subtle);
            border-radius: 100px;
            transition: all var(--transition-normal);
        }
        
        .source-link:hover {
            background: var(--border-default);
            border-color: var(--border-hover);
            color: #fff;
        }
        
        .loading {
            text-align: center;
            padding: 60px;
            color: var(--text-muted);
        }
        
        .error {
            background: rgba(255, 0, 0, 0.08);
            border: 1px solid rgba(255, 0, 0, 0.2);
            padding: 20px;
            border-radius: var(--radius-lg);
            color: #ff6b6b;
            margin-bottom: 20px;
        }
        
        .status-bar {
            display: flex;
            justify-content: center;
            align-items: center;
            gap: 24px;
            padding: 20px 24px;
            margin-top: 20px;
            font-size: 13px;
            color: var(--text-muted);
        }
        
        .status-indicator {
            display: flex;
            align-items: center;
            gap: 8px;
        }
        
        .status-dot {
            width: 6px;
            height: 6px;
            border-radius: 50%;
            background: var(--color-success);
            box-shadow: 0 0 8px rgba(34, 197, 94, 0.5);
        }
        
        .status-dot.error {
            background: var(--color-error);
            box-shadow: 0 0 8px rgba(239, 68, 68, 0.5);
        }
        
        .range-btn {
            background: var(--bg-elevated);
            border: 1px solid var(--border-default);
            color: var(--text-secondary);
            padding: 4px 10px;
            border-radius: 4px;
            cursor: pointer;
            font-size: 0.8rem;
            transition: all var(--transition-normal);
        }
        .range-btn:hover { background: var(--border-default); color: var(--text-primary); }
        .range-btn.active { background: var(--color-primary-muted); color: var(--color-primary); border-color: var(--color-primary-border); }
        
        .toast {
            position: fixed; bottom: 20px; right: 20px; z-index: 10000;
            background: var(--bg-surface); border: 1px solid var(--color-primary-border); border-radius: 8px;
            padding: 12px 18px; color: var(--text-primary); font-size: 0.85rem; max-width: 350px;
            box-shadow: 0 4px 20px rgba(0,0,0,0.4); animation: slideIn 0.3s ease;
        }
        @keyframes slideIn { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
        
        #auto-refresh-status {
            color: var(--text-muted);
        }
        
        @media (max-width: 768px) {
            header {
                flex-direction: column;
                gap: 15px;
            }
        }
        
        /* Exchange cards mobile responsiveness */
        @media (max-width: 768px) {
            .exchange-cards-grid {
                grid-template-columns: 1fr;
            }
        }