/* ═══════════════════════════════════════════════════════════════
   TRADERVIEW — Void Terminal Aesthetic
   Dark trading dashboard with neon P&L indicators
   ═══════════════════════════════════════════════════════════════ */

/* --- Fonts --- */
@import url('https://fonts.googleapis.com/css2?family=Syne:wght@700;800&family=Plus+Jakarta+Sans:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500;600;700&display=swap');

/* --- Custom Properties --- */
:root {
    --bg-void:       #08080d;
    --bg-surface-1:  #0e0e16;
    --bg-surface-2:  #14141f;
    --bg-surface-3:  #1a1a28;
    --bg-hover:      #20202f;
    --border:        #252538;
    --border-subtle: #1c1c2e;

    --text-primary:   #e4e4ed;
    --text-secondary: #7a7a94;
    --text-muted:     #4a4a60;

    --green:  #00dc82;
    --green-dim: rgba(0, 220, 130, 0.15);
    --green-glow: 0 0 20px rgba(0, 220, 130, 0.3);

    --red:    #ff4757;
    --red-dim: rgba(255, 71, 87, 0.15);
    --red-glow: 0 0 20px rgba(255, 71, 87, 0.3);

    --accent:     #6c5ce7;
    --accent-dim: rgba(108, 92, 231, 0.15);
    --yellow:     #ffd32a;
    --cyan:       #0abde3;

    --font-display: 'Syne', sans-serif;
    --font-body:    'Plus Jakarta Sans', sans-serif;
    --font-mono:    'JetBrains Mono', monospace;

    --radius:    12px;
    --radius-sm: 8px;
    --radius-xs: 6px;

    --shadow-card: 0 2px 8px rgba(0,0,0,0.3), 0 0 1px rgba(255,255,255,0.05) inset;
    --shadow-glow: 0 0 40px rgba(108, 92, 231, 0.08);

    --transition: 200ms cubic-bezier(0.4, 0, 0.2, 1);
}

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

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

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

/* Dot grid background */
body::before {
    content: '';
    position: fixed;
    inset: 0;
    background-image: radial-gradient(circle, var(--border-subtle) 1px, transparent 1px);
    background-size: 24px 24px;
    pointer-events: none;
    z-index: 0;
    opacity: 0.5;
}

a {
    color: var(--accent);
    text-decoration: none;
    transition: color var(--transition);
}

a:hover { color: var(--text-primary); }

/* --- Layout --- */
.app {
    position: relative;
    z-index: 1;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.container {
    max-width: 1280px;
    margin: 0 auto;
    padding: 0 1.5rem;
    width: 100%;
}

/* --- Navigation --- */
.nav {
    position: sticky;
    top: 0;
    z-index: 100;
    background: rgba(8, 8, 13, 0.85);
    backdrop-filter: blur(20px) saturate(1.2);
    border-bottom: 1px solid var(--border-subtle);
    padding: 0 1.5rem;
}

.nav-inner {
    max-width: 1280px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 60px;
}

.nav-logo {
    font-family: var(--font-mono);
    font-weight: 700;
    font-size: 1.1rem;
    color: var(--text-primary);
    letter-spacing: -0.5px;
}

.nav-logo .bracket {
    color: var(--accent);
    font-weight: 400;
}

.nav-links {
    display: flex;
    gap: 0.25rem;
}

.nav-link {
    font-family: var(--font-body);
    font-size: 0.87rem;
    font-weight: 500;
    color: var(--text-secondary);
    padding: 0.5rem 1rem;
    border-radius: var(--radius-xs);
    transition: all var(--transition);
}

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

.nav-link.active {
    color: var(--text-primary);
    background: var(--bg-surface-3);
}

.nav-right {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.mode-toggle {
    font-size: 0.75rem;
    font-weight: 600;
    padding: 4px 12px;
    border-radius: 4px;
    border: 1px solid var(--toggle-color, #6c5ce7);
    color: var(--toggle-color, #6c5ce7);
    text-decoration: none;
    transition: all 0.2s ease;
    letter-spacing: 0.05em;
}
.mode-toggle:hover {
    background: var(--toggle-color, #6c5ce7);
    color: #fff;
}

.mode-badge {
    font-size: 0.65rem;
    font-weight: 700;
    padding: 3px 8px;
    border-radius: 4px;
    color: #fff;
    letter-spacing: 0.1em;
}

.nav-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: 2px solid var(--border);
    transition: border-color var(--transition);
}

.nav-avatar:hover { border-color: var(--accent); }

.nav-logout {
    font-size: 0.8rem;
    color: var(--text-muted);
    padding: 0.4rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-xs);
    transition: all var(--transition);
}

.nav-logout:hover {
    color: var(--red);
    border-color: var(--red);
}

/* Hamburger toggle — hidden on desktop, shown via media query on mobile */
.nav-toggle {
    display: none;
    width: 40px;
    height: 40px;
    padding: 0;
    background: transparent;
    border: 1px solid var(--border);
    border-radius: var(--radius-xs);
    cursor: pointer;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 5px;
    transition: border-color var(--transition);
}
.nav-toggle:hover { border-color: var(--accent); }
.nav-toggle span {
    display: block;
    width: 20px;
    height: 2px;
    background: var(--text-primary);
    border-radius: 2px;
    transition: transform 200ms ease, opacity 200ms ease;
}
.nav[data-menu-open] .nav-toggle span:nth-child(1) {
    transform: translateY(7px) rotate(45deg);
}
.nav[data-menu-open] .nav-toggle span:nth-child(2) {
    opacity: 0;
}
.nav[data-menu-open] .nav-toggle span:nth-child(3) {
    transform: translateY(-7px) rotate(-45deg);
}

/* --- Date Range Picker --- */
.date-bar {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 1rem 0;
    flex-wrap: wrap;
}

.date-btn {
    font-family: var(--font-mono);
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--text-secondary);
    background: var(--bg-surface-2);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-xs);
    padding: 0.4rem 0.85rem;
    cursor: pointer;
    transition: all var(--transition);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.date-btn:hover {
    color: var(--text-primary);
    border-color: var(--border);
    background: var(--bg-surface-3);
}

.date-btn.active {
    color: var(--accent);
    border-color: var(--accent);
    background: var(--accent-dim);
}

.date-custom {
    display: none;
    align-items: center;
    gap: 0.5rem;
    margin-left: 0.5rem;
}

.date-custom.visible { display: flex; }

.date-input {
    font-family: var(--font-mono);
    font-size: 0.75rem;
    background: var(--bg-surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-xs);
    color: var(--text-primary);
    padding: 0.4rem 0.6rem;
}

.date-input:focus {
    outline: none;
    border-color: var(--accent);
}

/* --- Hero Section --- */
.hero {
    padding: 2rem 0 1.5rem;
}

.hero-grid {
    display: grid;
    grid-template-columns: 1fr auto auto auto auto auto auto auto;
    gap: 1rem;
    align-items: start;
}

.hero-pnl {
    position: relative;
}


.hero-label {
    font-family: var(--font-mono);
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
}

.hero-value {
    font-family: var(--font-mono);
    font-size: 3.2rem;
    font-weight: 700;
    line-height: 1.1;
    letter-spacing: -2px;
}

.hero-value.profit {
    color: var(--green);
    text-shadow: var(--green-glow);
}

.hero-value.loss {
    color: var(--red);
    text-shadow: var(--red-glow);
}

.hero-pct {
    font-family: var(--font-mono);
    font-size: 1rem;
    margin-top: 0.35rem;
}

.hero-stat {
    text-align: right;
    padding: 0.6rem 0.9rem;
    background: var(--bg-surface-2);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius);
    white-space: nowrap;
}

.hero-stat-value {
    font-family: var(--font-mono);
    font-size: 1.15rem;
    font-weight: 600;
    color: var(--text-primary);
}

.hero-stat-label {
    font-size: 0.65rem;
    color: var(--text-muted);
    margin-top: 0.15rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* --- Market Regime Widget --- */
.regime-widget {
    background: var(--bg-surface-1);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius);
    padding: 1rem 1.25rem;
    margin-top: 15px;
    margin-bottom: 1rem;
    box-shadow: var(--shadow-card);
}
.regime-head {
    display: flex;
    align-items: center;
    gap: 1rem;
}
.regime-badge {
    flex-shrink: 0;
    padding: 0.35rem 0.75rem;
    border-radius: var(--radius-xs);
    font-family: var(--font-mono);
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    color: #08080d;
    text-transform: uppercase;
}
.regime-title { flex: 1; min-width: 0; }
.regime-label {
    font-family: var(--font-display);
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: 0.02em;
}
.regime-summary {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-top: 0.1rem;
    line-height: 1.4;
}
.regime-date {
    font-family: var(--font-mono);
    font-size: 0.7rem;
    color: var(--text-muted);
    flex-shrink: 0;
}
.regime-metrics {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
    margin-top: 0.85rem;
    padding-top: 0.85rem;
    border-top: 1px solid var(--border-subtle);
}
.regime-metric-label {
    font-family: var(--font-mono);
    font-size: 0.65rem;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text-muted);
    margin-bottom: 0.15rem;
}
.regime-metric-value {
    font-family: var(--font-mono);
    font-size: 1.15rem;
    font-weight: 700;
}
.regime-metric-sub {
    font-family: var(--font-mono);
    font-size: 0.7rem;
    color: var(--text-muted);
    margin-top: 0.1rem;
}

/* --- Charts --- */
.charts-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.25rem;
    margin-bottom: 1.5rem;
}

.chart-card {
    background: var(--bg-surface-1);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius);
    padding: 1.25rem;
    box-shadow: var(--shadow-card);
    transition: border-color var(--transition);
    position: relative;
}

.chart-card:hover {
    border-color: var(--border);
}

.chart-card.full-width {
    grid-column: 1 / -1;
}

.chart-title {
    font-family: var(--font-mono);
    font-size: 0.73rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-muted);
    margin-bottom: 1rem;
}

.chart-wrap {
    position: relative;
    height: 240px;
    width: 100%;
}

.chart-canvas {
    position: absolute;
    inset: 0;
    width: 100% !important;
    height: 100% !important;
}

/* --- Bot Cards --- */
.bots-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1rem;
    margin-bottom: 2rem;
}

.bot-card {
    background: var(--bg-surface-1);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius);
    padding: 1.25rem;
    cursor: pointer;
    transition: all var(--transition);
    position: relative;
    overflow: hidden;
    box-shadow: var(--shadow-card);
}

.bot-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: var(--bot-color, var(--accent));
    opacity: 0.6;
    transition: opacity var(--transition);
}

.bot-card:hover {
    border-color: var(--border);
    transform: translateY(-2px);
    box-shadow: var(--shadow-card), var(--shadow-glow);
}

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

.bot-name {
    font-family: var(--font-display);
    font-size: 1rem;
    font-weight: 700;
    margin-bottom: 0.75rem;
}

.bot-pnl {
    font-family: var(--font-mono);
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
}

.bot-meta {
    font-family: var(--font-mono);
    font-size: 0.73rem;
    color: var(--text-secondary);
    line-height: 1.7;
}

.bot-meta span {
    display: block;
}

/* --- Tables --- */
.table-wrap {
    background: var(--bg-surface-1);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow-card);
    margin-bottom: 1.5rem;
}

.table-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border-subtle);
    flex-wrap: wrap;
    gap: 0.75rem;
}

.table-title {
    font-family: var(--font-display);
    font-size: 1rem;
    font-weight: 700;
}

.table-stats {
    display: flex;
    gap: 1.5rem;
    font-family: var(--font-mono);
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.table-stats strong {
    color: var(--text-primary);
}

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

thead th {
    font-family: var(--font-mono);
    font-size: 0.68rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: var(--text-muted);
    text-align: left;
    padding: 0.7rem 1rem;
    border-bottom: 1px solid var(--border-subtle);
    white-space: nowrap;
    cursor: pointer;
    user-select: none;
    transition: color var(--transition);
}

thead th:hover { color: var(--text-secondary); }

thead th.sorted { color: var(--accent); }

tbody tr {
    border-bottom: 1px solid var(--border-subtle);
    transition: background var(--transition);
}

tbody tr:last-child { border-bottom: none; }

tbody tr:hover { background: var(--bg-surface-2); }

tbody td {
    padding: 0.65rem 1rem;
    font-size: 0.85rem;
    white-space: nowrap;
}

td.mono {
    font-family: var(--font-mono);
    font-size: 0.8rem;
}

td.ticker-cell {
    font-family: var(--font-mono);
    font-weight: 600;
    color: var(--text-primary);
}

/* --- Filters --- */
.filters {
    display: flex;
    gap: 0.75rem;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border-subtle);
    flex-wrap: wrap;
    align-items: center;
}

.filter-group {
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.capital-stats {
    display: flex;
    gap: 1.25rem;
    margin-left: auto;
    padding-left: 1rem;
    border-left: 1px solid var(--border-subtle);
}

.capital-stat {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.15rem;
}

.capital-label {
    font-size: 0.65rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    font-family: 'Plus Jakarta Sans', sans-serif;
    font-weight: 600;
}

.capital-value {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-primary);
}

.filter-label {
    font-size: 0.73rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-family: var(--font-mono);
}

.filter-select {
    font-family: var(--font-mono);
    font-size: 0.78rem;
    background: var(--bg-surface-3);
    border: 1px solid var(--border);
    border-radius: var(--radius-xs);
    color: var(--text-primary);
    padding: 0.35rem 0.6rem;
    cursor: pointer;
    transition: border-color var(--transition);
}

.filter-select:focus {
    outline: none;
    border-color: var(--accent);
}

/* --- Pagination --- */
.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
    padding: 1rem;
}

.page-btn {
    font-family: var(--font-mono);
    font-size: 0.78rem;
    color: var(--text-secondary);
    background: var(--bg-surface-2);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-xs);
    padding: 0.35rem 0.7rem;
    cursor: pointer;
    transition: all var(--transition);
}

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

.page-btn.active {
    color: var(--accent);
    border-color: var(--accent);
    background: var(--accent-dim);
}

/* --- P&L Formatting --- */
.profit {
    color: var(--green);
}

.loss {
    color: var(--red);
}

.profit-bg {
    background: var(--green-dim);
    color: var(--green);
    padding: 0.15rem 0.5rem;
    border-radius: var(--radius-xs);
    font-family: var(--font-mono);
    font-size: 0.78rem;
    font-weight: 500;
}

.loss-bg {
    background: var(--red-dim);
    color: var(--red);
    padding: 0.15rem 0.5rem;
    border-radius: var(--radius-xs);
    font-family: var(--font-mono);
    font-size: 0.78rem;
    font-weight: 500;
}

/* --- Bot Detail Page --- */
.bot-header {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 2rem 0 1rem;
}

.bot-header-name {
    font-family: var(--font-display);
    font-size: 1.8rem;
    font-weight: 800;
}

.bot-header-badge {
    font-family: var(--font-mono);
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
    padding: 0.3rem 0.75rem;
    border-radius: 20px;
    background: var(--green-dim);
    color: var(--green);
    border: 1px solid rgba(0, 220, 130, 0.2);
}

.bot-header-desc {
    font-size: 0.87rem;
    color: var(--text-secondary);
    margin-top: 0.25rem;
}

.section-title {
    font-family: var(--font-mono);
    font-size: 0.73rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    color: var(--text-muted);
    margin: 1.5rem 0 0.75rem;
}

/* --- Leaderboard --- */
.leaderboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 0.75rem;
    margin-bottom: 1.5rem;
}

.leader-card {
    background: var(--bg-surface-1);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    padding: 1rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    transition: border-color var(--transition);
}

.leader-card:hover { border-color: var(--border); }

.leader-rank {
    font-family: var(--font-mono);
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--text-muted);
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: var(--bg-surface-3);
    flex-shrink: 0;
}

.leader-rank.gold { background: rgba(255, 211, 42, 0.15); color: var(--yellow); }
.leader-rank.silver { background: rgba(192, 192, 192, 0.15); color: #c0c0c0; }
.leader-rank.bronze { background: rgba(205, 127, 50, 0.15); color: #cd7f32; }

.leader-info { flex: 1; }

.leader-ticker {
    font-family: var(--font-mono);
    font-weight: 600;
    font-size: 0.9rem;
}

.leader-meta {
    font-size: 0.73rem;
    color: var(--text-secondary);
}

.leader-pnl {
    font-family: var(--font-mono);
    font-weight: 600;
    font-size: 0.9rem;
    text-align: right;
}

/* --- Wheel Specific --- */
.options-table td {
    font-family: var(--font-mono);
    font-size: 0.8rem;
}

.dte-badge {
    display: inline-block;
    font-family: var(--font-mono);
    font-size: 0.7rem;
    font-weight: 600;
    padding: 0.2rem 0.5rem;
    border-radius: var(--radius-xs);
    background: var(--bg-surface-3);
    color: var(--text-secondary);
}

.dte-badge.urgent {
    background: var(--red-dim);
    color: var(--red);
}

.dte-badge.soon {
    background: rgba(255, 211, 42, 0.15);
    color: var(--yellow);
}

/* --- Login Page --- */
.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
}

.login-container {
    text-align: center;
}

.login-card {
    background: var(--bg-surface-1);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 3rem 3.5rem;
    box-shadow: var(--shadow-card), var(--shadow-glow);
}

.login-logo {
    font-family: var(--font-mono);
    font-size: 1.6rem;
    font-weight: 700;
    margin-bottom: 1.5rem;
}

.logo-bracket { color: var(--accent); }
.logo-text { color: var(--text-primary); }

.login-subtitle {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 2rem;
}

.google-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.75rem;
    font-family: var(--font-body);
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-primary);
    background: var(--bg-surface-3);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 0.75rem 1.75rem;
    transition: all var(--transition);
}

.google-btn:hover {
    color: var(--text-primary);
    background: var(--bg-hover);
    border-color: var(--accent);
    box-shadow: 0 0 20px rgba(108, 92, 231, 0.15);
}

.login-footer {
    margin-top: 1.5rem;
    font-size: 0.73rem;
    color: var(--text-muted);
}

.login-dot {
    display: inline-block;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--green);
    margin-right: 0.3rem;
    vertical-align: middle;
    box-shadow: 0 0 8px rgba(0, 220, 130, 0.5);
}

/* --- Export Button --- */
.btn {
    font-family: var(--font-mono);
    font-size: 0.75rem;
    font-weight: 500;
    padding: 0.45rem 1rem;
    border-radius: var(--radius-xs);
    border: 1px solid var(--border);
    background: var(--bg-surface-2);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--transition);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.btn:hover {
    color: var(--text-primary);
    border-color: var(--accent);
}

.btn-accent {
    background: var(--accent-dim);
    border-color: var(--accent);
    color: var(--accent);
}

.btn-accent:hover {
    background: var(--accent);
    color: #fff;
}

/* --- Empty State --- */
.empty-state {
    text-align: center;
    padding: 4rem 2rem;
    color: var(--text-muted);
}

.empty-state-icon {
    font-size: 2.5rem;
    margin-bottom: 1rem;
    opacity: 0.3;
}

.empty-state p {
    font-size: 0.9rem;
}

/* --- Animations --- */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(12px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.fade-in {
    animation: fadeInUp 0.5s ease-out forwards;
    opacity: 0;
}

.fade-in:nth-child(1) { animation-delay: 0.05s; }
.fade-in:nth-child(2) { animation-delay: 0.1s; }
.fade-in:nth-child(3) { animation-delay: 0.15s; }
.fade-in:nth-child(4) { animation-delay: 0.2s; }
.fade-in:nth-child(5) { animation-delay: 0.25s; }

@keyframes pulseGlow {
    0%, 100% { opacity: 0.6; }
    50% { opacity: 1; }
}

.glow-pulse {
    animation: pulseGlow 3s ease-in-out infinite;
}

/* --- Scrollbar --- */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: var(--bg-void);
}

::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* --- Responsive --- */
@media (max-width: 900px) {
    .hero-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 1rem;
    }

    .hero-pnl {
        grid-column: 1 / -1;
        grid-row: auto;
    }

    .charts-grid {
        grid-template-columns: 1fr;
    }

    .bots-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 600px) {
    html { font-size: 14px; }

    /* iOS safe areas (notch + home indicator) */
    .nav,
    .container {
        padding-left: max(1rem, env(safe-area-inset-left));
        padding-right: max(1rem, env(safe-area-inset-right));
    }
    body {
        padding-bottom: env(safe-area-inset-bottom);
    }

    /* Nav: hamburger drops the links into a collapsible panel below the header. */
    .nav {
        padding: 0;
    }
    .nav-inner {
        flex-wrap: wrap;
        height: auto;
        padding: 0.6rem 0.9rem;
        gap: 0.5rem;
        position: relative;
    }
    .nav-right {
        flex-shrink: 0;
        gap: 0.5rem;
        order: 2;
        margin-left: auto; /* push right group + hamburger to the right */
    }
    .nav-toggle {
        display: inline-flex;
        order: 3;
    }
    .nav-avatar { display: none; }
    .nav-logout { padding: 0.35rem 0.6rem; font-size: 0.75rem; }

    .nav-links {
        flex-basis: 100%;
        order: 99;
        flex-direction: column;
        gap: 0;
        margin-top: 0.25rem;
        border-top: 1px solid var(--border-subtle);
        max-height: 0;
        opacity: 0;
        overflow: hidden;
        pointer-events: none;
        transition: max-height 220ms ease, opacity 180ms ease, margin-top 220ms ease;
    }
    .nav[data-menu-open] .nav-links {
        max-height: 80vh;
        opacity: 1;
        pointer-events: auto;
        margin-top: 0.4rem;
        padding-bottom: 0.4rem;
        overflow-y: auto;
    }
    .nav-link {
        padding: 0.9rem 0.5rem;
        font-size: 0.95rem;
        border-bottom: 1px solid var(--border-subtle);
        border-radius: 0;
        min-height: 44px;
        display: flex;
        align-items: center;
    }
    .nav-link:last-child { border-bottom: none; }
    .nav-link.active {
        background: var(--accent-dim);
        color: var(--text-primary);
        padding-left: 0.75rem;
        border-left: 3px solid var(--accent);
    }

    /* Hero */
    .hero {
        padding: 1.25rem 0 1rem;
    }
    .hero-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 0.75rem;
    }
    .hero-value {
        font-size: 2.4rem;
        letter-spacing: -1px;
    }
    .hero-stat {
        text-align: left;
        padding: 0.5rem 0.7rem;
    }

    /* Charts: shrink a bit on mobile so two stack without huge scroll */
    .chart-wrap { height: 200px; }

    /* Regime widget: stack head vertically, keep the metric triple flush */
    .regime-head { flex-wrap: wrap; }
    .regime-date { order: 4; flex-basis: 100%; }
    .regime-metrics { gap: 0.5rem; }
    .regime-metric-value { font-size: 1rem; }

    /* Bots / date bar */
    .bots-grid {
        grid-template-columns: 1fr;
    }
    .date-bar {
        padding: 0.75rem 0;
        gap: 0.35rem;
    }
    .date-btn {
        padding: 0.5rem 0.75rem;
        font-size: 0.72rem;
    }

    /* Tables */
    .table-header {
        flex-direction: column;
        align-items: flex-start;
    }
    .filters {
        flex-direction: column;
        align-items: flex-start;
    }
    .capital-stats {
        margin-left: 0;
        padding-left: 0;
        border-left: none;
        padding-top: 0.5rem;
        border-top: 1px solid var(--border-subtle);
        width: 100%;
        justify-content: flex-start;
    }
    .table-wrap { overflow-x: auto; }
    tbody td { padding: 0.55rem 0.8rem; font-size: 0.8rem; }
    thead th { padding: 0.55rem 0.8rem; }

    /* Touch targets */
    .btn, .date-btn, .nav-link {
        min-height: 36px;
    }
}

/* Standalone PWA mode — hide the logout button and mode badge niceties a bit */
@media (display-mode: standalone) {
    body {
        overscroll-behavior-y: contain;
    }
}

/* ---------------------------------------------------------------------------
   Hover tooltips — plain-English explainers (the "?" markers + dotted labels)
   Usage:  <span class="tip" data-tip="Explanation in plain English">?</span>
           <span class="help" data-tip="...">Label</span>   (dotted underline)
   Add  tip-left / tip-right  to steer the bubble away from screen edges.
--------------------------------------------------------------------------- */
.tip {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 15px;
    height: 15px;
    margin-left: 5px;
    border-radius: 50%;
    background: var(--bg-surface-3);
    border: 1px solid var(--border);
    color: var(--text-secondary);
    font-size: 10px;
    font-weight: 700;
    font-style: normal;
    line-height: 1;
    cursor: help;
    position: relative;
    vertical-align: middle;
    user-select: none;
    -webkit-user-select: none;
}
.tip:hover {
    color: var(--text-primary);
    border-color: var(--accent);
}
/* dotted-underline variant that wraps a real label */
.help {
    border-bottom: 1px dotted var(--text-secondary);
    cursor: help;
    position: relative;
}
.tip::after,
.help::after {
    content: attr(data-tip);
    position: absolute;
    bottom: calc(100% + 9px);
    left: 50%;
    transform: translateX(-50%) translateY(4px);
    width: max-content;
    max-width: 280px;
    background: var(--bg-surface-2);
    color: var(--text-primary);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 11px 13px;
    font-size: 12.5px;
    font-weight: 400;
    font-style: normal;
    line-height: 1.55;
    letter-spacing: 0;
    text-align: left;
    white-space: normal;
    text-transform: none;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 0.16s ease, transform 0.16s ease;
    z-index: 200;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.55);
}
/* little arrow under the bubble */
.tip::before,
.help::before {
    content: "";
    position: absolute;
    bottom: calc(100% + 3px);
    left: 50%;
    transform: translateX(-50%) translateY(4px);
    border: 6px solid transparent;
    border-top-color: var(--border);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.16s ease, transform 0.16s ease;
    z-index: 201;
}
.tip:hover::after,
.tip:hover::before,
.help:hover::after,
.help:hover::before {
    opacity: 1;
    visibility: visible;
    transform: translateX(-50%) translateY(0);
}
/* edge-steering: align bubble to the marker instead of centering */
.tip.tip-left::after,
.help.tip-left::after  { left: 0;   transform: translateX(0) translateY(4px); }
.tip.tip-left:hover::after,
.help.tip-left:hover::after  { transform: translateX(0) translateY(0); }
.tip.tip-right::after,
.help.tip-right::after { left: auto; right: 0; transform: translateX(0) translateY(4px); }
.tip.tip-right:hover::after,
.help.tip-right:hover::after { transform: translateX(0) translateY(0); }

@media (max-width: 600px) {
    .tip::after,
    .help::after { max-width: 220px; font-size: 12px; }
}
