:root {
    --bg-base: #07090e;
    --bg-surface: #0d111a;
    --bg-card: rgba(18, 24, 38, 0.7);
    --border-subtle: rgba(255, 255, 255, 0.08);
    --border-focus: rgba(16, 185, 129, 0.4);

    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;

    --accent-emerald: #10b981;
    --accent-emerald-glow: rgba(16, 185, 129, 0.25);
    --accent-cyan: #06b6d4;
    --accent-gold: #f59e0b;
    --accent-crimson: #ef4444;

    --font-ui: 'Changa', system-ui, -apple-system, sans-serif;
    --font-mono: 'JetBrains Mono', monospace;
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --shadow-card: 0 10px 25px -5px rgba(0, 0, 0, 0.5), 0 8px 10px -6px rgba(0, 0, 0, 0.5);
}

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

body.dark-terminal {
    background-color: var(--bg-base);
    background-image: 
        radial-gradient(circle at 15% 15%, rgba(16, 185, 129, 0.04) 0%, transparent 40%),
        radial-gradient(circle at 85% 85%, rgba(6, 182, 212, 0.03) 0%, transparent 40%);
    color: var(--text-primary);
    font-family: var(--font-ui);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
}

.font-mono {
    font-family: var(--font-mono);
}

.text-emerald { color: var(--accent-emerald); }
.text-cyan { color: var(--accent-cyan); }
.text-gold { color: var(--accent-gold); }
.text-crimson { color: var(--accent-crimson); }
.text-center { text-align: center; }

/* ── Top Navigation Bar ── */
.top-nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 28px;
    background: rgba(13, 17, 26, 0.85);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border-subtle);
    position: sticky;
    top: 0;
    z-index: 100;
}

.brand-group {
    display: flex;
    align-items: center;
    gap: 14px;
}

.brand-logo {
    display: flex;
    align-items: center;
    gap: 10px;
}

.neon-cube {
    width: 14px;
    height: 14px;
    background: var(--accent-emerald);
    border-radius: 3px;
    box-shadow: 0 0 12px var(--accent-emerald);
    display: inline-block;
    animation: pulseGlow 2s infinite ease-in-out;
}

@keyframes pulseGlow {
    0%, 100% { opacity: 0.8; transform: scale(0.95); }
    50% { opacity: 1; transform: scale(1.1); box-shadow: 0 0 18px var(--accent-emerald); }
}

.brand-title {
    font-size: 1.35rem;
    font-weight: 800;
    letter-spacing: 0.5px;
}

.brand-title .highlight {
    color: var(--accent-emerald);
}

.vps-tag {
    font-size: 0.78rem;
    font-family: var(--font-mono);
    background: rgba(255, 255, 255, 0.05);
    padding: 4px 10px;
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    border: 1px solid var(--border-subtle);
}

.endpoint-tag {
    font-size: 0.8rem;
    font-family: var(--font-mono);
    color: var(--accent-cyan);
    background: rgba(6, 182, 212, 0.1);
    padding: 4px 10px;
    border-radius: var(--radius-sm);
    border: 1px solid rgba(6, 182, 212, 0.2);
}

.system-status-group {
    display: flex;
    align-items: center;
    gap: 16px;
}

.status-indicator {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.pulse-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--accent-emerald);
    box-shadow: 0 0 8px var(--accent-emerald);
}

.metric-pill {
    display: flex;
    align-items: center;
    gap: 6px;
    background: rgba(255, 255, 255, 0.04);
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 0.82rem;
    border: 1px solid var(--border-subtle);
}

.pill-label { color: var(--text-muted); }
.pill-value { color: var(--text-primary); font-weight: 600; }

.mode-badge {
    font-size: 0.78rem;
    font-weight: 700;
    padding: 6px 14px;
    border-radius: 20px;
    letter-spacing: 0.5px;
}

.mode-badge.paper {
    background: rgba(245, 158, 11, 0.15);
    color: var(--accent-gold);
    border: 1px solid rgba(245, 158, 11, 0.3);
}

.mode-badge.live {
    background: rgba(16, 185, 129, 0.2);
    color: var(--accent-emerald);
    border: 1px solid rgba(16, 185, 129, 0.4);
    animation: livePulse 2s infinite;
}

.btn-emergency {
    background: rgba(239, 68, 68, 0.15);
    color: #fca5a5;
    border: 1px solid rgba(239, 68, 68, 0.4);
    padding: 8px 16px;
    border-radius: var(--radius-sm);
    font-family: var(--font-ui);
    font-weight: 700;
    font-size: 0.88rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.2s ease;
}

.btn-emergency:hover {
    background: var(--accent-crimson);
    color: white;
    box-shadow: 0 0 16px rgba(239, 68, 68, 0.6);
}

/* ── Dashboard Layout ── */
.dashboard-container {
    flex: 1;
    padding: 24px 28px;
    max-width: 1600px;
    margin: 0 auto;
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 22px;
}

/* ── KPI Cards ── */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 16px;
}

.kpi-card {
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: 18px 20px;
    box-shadow: var(--shadow-card);
    backdrop-filter: blur(8px);
    display: flex;
    flex-direction: column;
    gap: 8px;
    transition: transform 0.2s ease, border-color 0.2s ease;
}

.kpi-card:hover {
    transform: translateY(-2px);
    border-color: var(--border-focus);
}

.kpi-card.glow-profit {
    border-color: rgba(16, 185, 129, 0.35);
    background: linear-gradient(135deg, rgba(16, 185, 129, 0.08) 0%, rgba(18, 24, 38, 0.7) 100%);
}

.kpi-card.glow-balance {
    border-color: rgba(6, 182, 212, 0.35);
    background: linear-gradient(135deg, rgba(6, 182, 212, 0.08) 0%, rgba(18, 24, 38, 0.7) 100%);
}

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

.kpi-title {
    font-size: 0.88rem;
    color: var(--text-secondary);
    font-weight: 600;
}

.kpi-value {
    font-size: 1.85rem;
    font-weight: 700;
    color: var(--accent-emerald);
}

.kpi-subtext {
    font-size: 0.78rem;
    color: var(--text-muted);
}

/* ── Controls Bar ── */
.controls-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: 14px 20px;
    flex-wrap: wrap;
    gap: 16px;
}

.controls-left, .controls-right {
    display: flex;
    align-items: center;
    gap: 18px;
}

/* Toggle Switch */
.switch-container {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 600;
}

.switch-container input { display: none; }

.slider {
    width: 44px;
    height: 24px;
    background: #334155;
    border-radius: 30px;
    position: relative;
    transition: background 0.3s ease;
}

.slider:before {
    content: '';
    position: absolute;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: white;
    top: 3px;
    right: 3px;
    transition: transform 0.3s ease;
}

.switch-container input:checked + .slider {
    background: var(--accent-emerald);
    box-shadow: 0 0 10px var(--accent-emerald-glow);
}

.switch-container input:checked + .slider:before {
    transform: translateX(-20px);
}

.mode-select-wrap select {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-primary);
    border: 1px solid var(--border-subtle);
    padding: 8px 14px;
    border-radius: var(--radius-sm);
    font-family: var(--font-ui);
    outline: none;
    font-size: 0.88rem;
}

.btn-refresh {
    background: rgba(255, 255, 255, 0.06);
    color: var(--text-primary);
    border: 1px solid var(--border-subtle);
    padding: 8px 16px;
    border-radius: var(--radius-sm);
    font-family: var(--font-ui);
    cursor: pointer;
    font-weight: 600;
    transition: all 0.2s;
}

.btn-refresh:hover {
    background: rgba(255, 255, 255, 0.12);
}

/* ── Content Grid ── */
.content-grid {
    display: grid;
    grid-template-columns: 1.6fr 1fr;
    gap: 20px;
}

@media (max-width: 1024px) {
    .content-grid {
        grid-template-columns: 1fr;
    }
}

.panel {
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-card);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

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

.panel-header h3 {
    font-size: 1rem;
    font-weight: 700;
}

.panel-title-wrap {
    display: flex;
    align-items: center;
    gap: 10px;
}

.live-pill {
    background: rgba(239, 68, 68, 0.15);
    color: #f87171;
    font-size: 0.68rem;
    font-weight: 800;
    padding: 2px 8px;
    border-radius: 4px;
    letter-spacing: 0.5px;
    animation: blink 1.5s infinite;
}

@keyframes blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

.panel-counter {
    font-size: 0.8rem;
    font-family: var(--font-mono);
    color: var(--accent-emerald);
}

.sub-tag {
    font-size: 0.78rem;
    color: var(--text-muted);
}

/* ── Opportunities Cards ── */
.opportunities-list {
    padding: 18px 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    max-height: 640px;
    overflow-y: auto;
}

.opp-card {
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: 16px 18px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: all 0.2s ease;
}

.opp-card:hover {
    border-color: var(--accent-emerald);
    transform: translateX(-4px);
    background: rgba(24, 32, 50, 0.8);
}

.opp-info {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.opp-badge-row {
    display: flex;
    align-items: center;
    gap: 8px;
}

.type-badge {
    font-size: 0.72rem;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 4px;
    background: rgba(6, 182, 212, 0.15);
    color: var(--accent-cyan);
    border: 1px solid rgba(6, 182, 212, 0.3);
}

.opp-symbol {
    font-size: 1.1rem;
    font-weight: 800;
    letter-spacing: 0.5px;
}

.opp-details {
    font-size: 0.82rem;
    color: var(--text-secondary);
    display: flex;
    gap: 14px;
}

.opp-metrics {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 4px;
}

.opp-spread {
    font-size: 1.25rem;
    font-weight: 800;
    color: var(--accent-emerald);
}

.opp-est-profit {
    font-size: 0.78rem;
    color: var(--text-muted);
}

.opp-action-btn {
    margin-top: 4px;
    background: var(--accent-emerald);
    color: #07090e;
    border: none;
    padding: 4px 12px;
    border-radius: 4px;
    font-weight: 700;
    font-size: 0.78rem;
    cursor: pointer;
    transition: opacity 0.2s;
}

.opp-action-btn:hover {
    opacity: 0.9;
}

/* ── Side Column: Tables & History ── */
.side-column {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.84rem;
}

.data-table th {
    text-align: right;
    padding: 10px 14px;
    color: var(--text-muted);
    font-size: 0.78rem;
    border-bottom: 1px solid var(--border-subtle);
}

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

.audit-list {
    padding: 14px 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: 300px;
    overflow-y: auto;
}

.audit-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(255, 255, 255, 0.02);
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    font-size: 0.8rem;
    border-left: 3px solid var(--accent-emerald);
}

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

.spinner {
    width: 24px;
    height: 24px;
    border: 2px solid rgba(16, 185, 129, 0.2);
    border-top-color: var(--accent-emerald);
    border-radius: 50%;
    display: inline-block;
    animation: spin 0.8s linear infinite;
    margin-bottom: 10px;
}

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

/* ── Footer ── */
.terminal-footer {
    padding: 16px 28px;
    border-top: 1px solid var(--border-subtle);
    background: rgba(13, 17, 26, 0.7);
    font-size: 0.78rem;
    color: var(--text-muted);
}

.footer-meta {
    display: flex;
    justify-content: space-between;
}

/* ── Enterprise Pro & Triangular Styles ── */
.badge-enterprise {
    background: linear-gradient(135deg, #10b981 0%, #06b6d4 100%);
    color: #07090e;
    font-size: 0.65rem;
    font-weight: 800;
    padding: 2px 6px;
    border-radius: 4px;
    letter-spacing: 0.5px;
    vertical-align: middle;
}

.triangular-box {
    margin-top: 14px;
    border-top: 1px solid var(--border-subtle);
    padding: 16px 20px;
    background: rgba(6, 182, 212, 0.03);
}

.tri-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.tri-header h4 {
    font-size: 0.88rem;
    font-weight: 700;
    color: var(--accent-cyan);
}

.badge-mini {
    font-size: 0.72rem;
    background: rgba(6, 182, 212, 0.12);
    border: 1px solid rgba(6, 182, 212, 0.3);
    padding: 2px 8px;
    border-radius: 4px;
}

.tri-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.tri-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(18, 24, 38, 0.8);
    border: 1px solid rgba(6, 182, 212, 0.2);
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    font-size: 0.82rem;
    transition: all 0.2s ease;
}

.tri-item:hover {
    border-color: var(--accent-cyan);
    transform: translateX(-3px);
}

.empty-mini {
    color: var(--text-muted);
    font-size: 0.82rem;
    text-align: center;
    padding: 10px 0;
}

/* ── Full Width Executed Trades Ledger ── */
.full-width-ledger-panel {
    margin-top: 10px;
    width: 100%;
}

.badge-success {
    background: rgba(16, 185, 129, 0.15);
    color: var(--accent-emerald);
    border: 1px solid rgba(16, 185, 129, 0.4);
    font-size: 0.72rem;
    font-weight: 800;
    padding: 3px 10px;
    border-radius: 4px;
    letter-spacing: 0.5px;
}

.ledger-stats-bar {
    display: flex;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
}

.stat-badge {
    font-size: 0.84rem;
    color: var(--text-secondary);
    background: rgba(255, 255, 255, 0.03);
    padding: 4px 12px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-subtle);
}

.table-responsive {
    width: 100%;
    overflow-x: auto;
    max-height: 480px;
}

.ledger-table {
    width: 100%;
}

.ledger-table th {
    background: rgba(13, 17, 26, 0.95);
    position: sticky;
    top: 0;
    z-index: 10;
}

.badge-status-profit {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    background: rgba(16, 185, 129, 0.12);
    color: var(--accent-emerald);
    border: 1px solid rgba(16, 185, 129, 0.3);
    padding: 3px 8px;
    border-radius: 4px;
    font-size: 0.78rem;
    font-weight: 700;
}

/* ── v57.0 Specific Badges & Micro-Interactions ── */
.badge-buy {
    background: rgba(0, 255, 136, 0.12);
    color: #00ff88;
    border: 1px solid rgba(0, 255, 136, 0.3);
    padding: 2px 8px;
    border-radius: 4px;
    font-weight: bold;
}

.badge-sell {
    background: rgba(255, 90, 90, 0.12);
    color: #ff6060;
    border: 1px solid rgba(255, 90, 90, 0.3);
    padding: 2px 8px;
    border-radius: 4px;
    font-weight: bold;
}

.badge-verified {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: rgba(0, 255, 200, 0.1);
    color: var(--accent-cyan);
    border: 1px solid rgba(0, 255, 200, 0.25);
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: bold;
}

.kpi-mini-card {
    transition: transform 0.2s ease, border-color 0.2s ease;
}

.kpi-mini-card:hover {
    transform: translateY(-2px);
    border-color: rgba(0, 255, 200, 0.35);
}

/* ── v61.0 Arbitrage Profit Engine Badges & Styling ── */
.badge-aqs {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    border-radius: 6px;
    font-family: var(--font-mono);
    font-size: 0.8rem;
    font-weight: 800;
    letter-spacing: 0.5px;
}

.badge-aqs-a-plus {
    background: rgba(80, 250, 123, 0.2);
    color: #50fa7b;
    border: 1px solid #50fa7b;
    box-shadow: 0 0 12px rgba(80, 250, 123, 0.3);
}

.badge-aqs-a {
    background: rgba(16, 185, 129, 0.15);
    color: #10b981;
    border: 1px solid rgba(16, 185, 129, 0.4);
}

.badge-aqs-b {
    background: rgba(6, 182, 212, 0.15);
    color: #06b6d4;
    border: 1px solid rgba(6, 182, 212, 0.4);
}

.badge-aqs-c {
    background: rgba(245, 158, 11, 0.15);
    color: #f59e0b;
    border: 1px solid rgba(245, 158, 11, 0.4);
}

.badge-aqs-reject {
    background: rgba(239, 68, 68, 0.15);
    color: #ef4444;
    border: 1px solid rgba(239, 68, 68, 0.4);
}

.decay-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
    gap: 8px;
    margin-top: 10px;
}

.decay-box {
    background: rgba(0, 0, 0, 0.35);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 6px;
    padding: 8px 10px;
    text-align: center;
    font-family: var(--font-mono);
}

.decay-box.active {
    border-color: rgba(0, 255, 200, 0.4);
    background: rgba(0, 255, 200, 0.05);
}

.decay-box .time-label {
    font-size: 0.7rem;
    color: var(--text-muted);
    margin-bottom: 2px;
}

.decay-box .pnl-value {
    font-size: 0.85rem;
    font-weight: 700;
}



