:root {
    --primary: #00ff88;
    --primary-dark: #00cc6a;
    --primary-muted: rgba(0, 255, 136, 0.15);
    --bg-dark: #0a0e13;
    --bg-darker: #060a0f;
    --bg-card: #0f1419;
    --bg-elevated: #151b23;
    --text-primary: #e8eaed;
    --text-secondary: #9ca3af;
    --text-tertiary: #6b7280;
    --border: #1a1f28;
    --border-hover: #252d38;
    --red: #ff4757;
    --green: #00ff88;
}

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

html {
    /* Stops mobile Safari inflating type in landscape, which is one of the
       ways the layout appears to "shift" on a phone. */
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--bg-darker);
    color: var(--text-primary);
    width: 100%;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    font-size: 14px;
}

/* Nothing may push the page wider than the viewport - a single overflowing
   child is what makes the whole body slide sideways on touch devices. */
img,
canvas,
svg {
    max-width: 100%;
}

body.nav-open {
    overflow: hidden;
}

.app-body {
    background: var(--bg-dark);
    overflow: hidden;
}

/* ===== LANDING PAGE ===== */

.landing-page {
    min-height: 100vh;
    min-height: 100dvh;
}

/* Navigation */
.navbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    background: rgba(10, 14, 19, 0.85);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border);
    z-index: 1000;
}

.nav-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0.875rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
    letter-spacing: -0.02em;
}

.logo-icon {
    width: 28px;
    height: 28px;
    background: var(--primary);
    border-radius: 6px;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}

.logo-icon::before {
    content: '';
    position: absolute;
    width: 10px;
    height: 10px;
    background: var(--bg-dark);
    border-radius: 2px;
    transform: rotate(45deg);
}

.logo-icon.large {
    width: 56px;
    height: 56px;
}

.logo-icon.large::before {
    width: 20px;
    height: 20px;
}

.nav-links {
    display: flex;
    align-items: center;
    gap: 2rem;
}

/* Hamburger - desktop hides it, the 768px breakpoint reveals it */
.nav-toggle {
    display: none;
    flex-direction: column;
    justify-content: center;
    gap: 5px;
    width: 42px;
    height: 42px;
    padding: 0;
    background: transparent;
    border: 1px solid var(--border);
    border-radius: 6px;
    cursor: pointer;
}

.nav-toggle span {
    display: block;
    width: 18px;
    height: 2px;
    margin: 0 auto;
    background: var(--text-primary);
    border-radius: 2px;
    transition: transform 0.25s ease, opacity 0.2s ease;
}

.nav-toggle.active span:nth-child(1) {
    transform: translateY(7px) rotate(45deg);
}

.nav-toggle.active span:nth-child(2) {
    opacity: 0;
}

.nav-toggle.active span:nth-child(3) {
    transform: translateY(-7px) rotate(-45deg);
}

.nav-links a {
    color: var(--text-secondary);
    text-decoration: none;
    font-weight: 500;
    font-size: 0.875rem;
    transition: color 0.2s;
}

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

/* Launch Button with Animated Logo */
.btn-launch {
    background: var(--primary);
    color: var(--bg-dark) !important;
    padding: 0.5rem 1.25rem;
    border-radius: 6px;
    font-weight: 600;
    font-size: 0.875rem;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    align-items: center;
    gap: 0.5rem;
    position: relative;
    overflow: hidden;
}

.btn-launch::before {
    content: '';
    position: absolute;
    width: 20px;
    height: 20px;
    background: var(--bg-dark);
    border-radius: 3px;
    left: 0.75rem;
    transform: rotate(45deg);
    animation: logo-spin 3s linear infinite;
    opacity: 0.3;
}

@keyframes logo-spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

.btn-launch:hover {
    background: var(--primary-dark);
    transform: translateY(-1px);
}

.btn-launch:hover::before {
    animation-duration: 1s;
}

/* Hero Section */
.hero {
    padding: 8rem 2rem 5rem;
    position: relative;
    overflow: hidden;
}

.hero-bg-animation {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background:
        radial-gradient(circle at 20% 50%, rgba(0, 255, 136, 0.06) 0%, transparent 50%),
        radial-gradient(circle at 80% 80%, rgba(0, 255, 136, 0.04) 0%, transparent 50%);
    animation: float 20s infinite ease-in-out;
}

@keyframes float {
    0%, 100% { transform: translate(0, 0); }
    50% { transform: translate(30px, -30px); }
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    position: relative;
}

.hero-content {
    max-width: 900px;
    margin: 0 auto;
    text-align: center;
}

.hero-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    background: var(--primary-muted);
    border: 1px solid rgba(0, 255, 136, 0.25);
    padding: 0.375rem 0.875rem;
    border-radius: 50px;
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--primary);
    margin-bottom: 1.5rem;
}

.pulse-dot {
    width: 6px;
    height: 6px;
    background: var(--primary);
    border-radius: 50%;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.5; transform: scale(0.8); }
}

.hero-title {
    font-size: 3.5rem;
    font-weight: 700;
    line-height: 1.1;
    margin-bottom: 1.5rem;
    letter-spacing: -0.03em;
}

.gradient-text {
    background: linear-gradient(135deg, var(--primary) 0%, #00cc6a 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.hero-description {
    font-size: 1.05rem;
    line-height: 1.6;
    color: var(--text-secondary);
    margin-bottom: 2.5rem;
    max-width: 700px;
    margin-left: auto;
    margin-right: auto;
}

.hero-actions {
    display: flex;
    gap: 1rem;
    justify-content: center;
    align-items: center;
    margin-bottom: 4rem;
}

.btn-primary {
    background: var(--primary);
    color: var(--bg-dark);
    padding: 0.875rem 2rem;
    border-radius: 8px;
    font-weight: 600;
    font-size: 0.95rem;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    border: none;
    cursor: pointer;
    position: relative;
    overflow: hidden;
}

.btn-primary::before {
    content: '';
    position: absolute;
    width: 24px;
    height: 24px;
    background: rgba(0, 0, 0, 0.1);
    border-radius: 4px;
    left: 1rem;
    transform: rotate(45deg);
    animation: logo-spin-button 3s linear infinite;
}

@keyframes logo-spin-button {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

.btn-primary:hover {
    background: var(--primary-dark);
    transform: translateY(-2px);
}

.btn-primary:hover::before {
    animation-duration: 1s;
}

.btn-secondary {
    background: transparent;
    color: var(--text-primary);
    padding: 0.875rem 2rem;
    border-radius: 8px;
    font-weight: 600;
    font-size: 0.95rem;
    border: 1px solid var(--border);
    cursor: pointer;
    transition: all 0.2s;
}

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

.btn-large {
    padding: 1rem 2.5rem;
    font-size: 1rem;
}

.hero-stats {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 2rem;
    max-width: 800px;
    margin: 0 auto 4rem;
}

.stat-item {
    text-align: center;
}

.stat-value {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--primary);
    margin-bottom: 0.375rem;
    letter-spacing: -0.02em;
}

.stat-label {
    font-size: 0.8rem;
    color: var(--text-tertiary);
    font-weight: 500;
}

/* Terminal Preview */
.terminal-preview {
    margin-top: 3rem;
}

.terminal-window {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    overflow: hidden;
    max-width: 1000px;
    margin: 0 auto;
}

.terminal-header {
    background: var(--bg-elevated);
    padding: 0.75rem 1rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    border-bottom: 1px solid var(--border);
}

.terminal-dots {
    display: flex;
    gap: 0.375rem;
}

.terminal-dots span {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--border-hover);
}

.terminal-title {
    font-size: 0.75rem;
    color: var(--text-tertiary);
    font-weight: 500;
}

.terminal-body {
    display: grid;
    grid-template-columns: 190px 1fr 210px;
    height: 360px;
}

.terminal-panel-label {
    font-size: 0.6rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-tertiary);
    font-weight: 600;
    padding: 0 0.25rem 0.5rem;
}

.terminal-sidebar {
    background: var(--bg-darker);
    border-right: 1px solid var(--border);
    padding: 0.875rem 0.75rem;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.terminal-market-list {
    flex: 1;
    overflow-y: auto;
    min-height: 0;
}

.terminal-market-item {
    padding: 0.5rem;
    border-radius: 4px;
    margin-bottom: 0.25rem;
    border-left: 2px solid transparent;
    transition: background 0.15s, border-color 0.15s;
    cursor: pointer;
}

.terminal-market-item:hover {
    background: var(--bg-elevated);
}

.terminal-market-item.active {
    background: var(--primary-muted);
    border-left-color: var(--primary);
}

.tm-row {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 0.5rem;
}

.tm-row + .tm-row {
    margin-top: 0.1875rem;
}

.t-symbol {
    font-size: 0.7rem;
    font-weight: 600;
    letter-spacing: -0.01em;
}

.t-price {
    font-size: 0.7rem;
    color: var(--text-primary);
    font-family: 'JetBrains Mono', monospace;
}

.t-volume {
    font-size: 0.6rem;
    color: var(--text-tertiary);
    font-family: 'JetBrains Mono', monospace;
}

.t-change {
    font-size: 0.6rem;
    font-weight: 600;
    font-family: 'JetBrains Mono', monospace;
}

.t-change.positive { color: var(--green); }
.t-change.negative { color: var(--red); }

/* Preview chart panel */
.terminal-chart-panel {
    display: flex;
    flex-direction: column;
    min-width: 0;
    min-height: 0;
}

.terminal-chart-header {
    display: flex;
    align-items: baseline;
    gap: 0.625rem;
    padding: 0.625rem 0.875rem;
    border-bottom: 1px solid var(--border);
}

.tc-symbol {
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: -0.01em;
}

.tc-price {
    font-size: 0.75rem;
    font-family: 'JetBrains Mono', monospace;
    color: var(--text-primary);
}

.tc-change {
    font-size: 0.65rem;
    font-weight: 600;
    font-family: 'JetBrains Mono', monospace;
}

.tc-change.positive { color: var(--green); }
.tc-change.negative { color: var(--red); }

.tc-interval {
    margin-left: auto;
    font-size: 0.6rem;
    color: var(--text-tertiary);
    border: 1px solid var(--border);
    border-radius: 3px;
    padding: 0.125rem 0.375rem;
}

.terminal-chart {
    flex: 1;
    position: relative;
    min-height: 0;
    padding: 0.5rem 0;
}

.terminal-chart canvas {
    display: block;
    width: 100%;
    height: 100%;
}

/* Preview activity feed */
.terminal-trades {
    border-left: 1px solid var(--border);
    background: var(--bg-darker);
    padding: 0.875rem 0.75rem;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.terminal-trade-feed {
    flex: 1;
    overflow: hidden;
    min-height: 0;
}

.tf-row {
    display: grid;
    grid-template-columns: 2.25rem 2.5rem 1fr auto;
    align-items: baseline;
    gap: 0.375rem;
    padding: 0.3125rem 0.25rem;
    border-bottom: 1px solid var(--border);
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.6rem;
    animation: tf-in 0.3s ease;
}

@keyframes tf-in {
    from { opacity: 0; transform: translateY(-4px); }
    to { opacity: 1; transform: translateY(0); }
}

.tf-side {
    font-weight: 600;
}

.tf-row.buy .tf-side { color: var(--green); }
.tf-row.sell .tf-side { color: var(--red); }

.tf-pair {
    color: var(--text-secondary);
    font-weight: 600;
}

.tf-size {
    color: var(--text-tertiary);
    text-align: right;
}

.tf-px {
    color: var(--text-primary);
}

.terminal-feed-empty {
    font-size: 0.65rem;
    color: var(--text-tertiary);
    padding: 0.5rem 0.25rem;
}

/* Profit notification */
.terminal-trade-item {
    margin-top: 0.75rem;
    background: var(--primary-muted);
    border: 1px solid rgba(0, 255, 136, 0.25);
    border-radius: 6px;
    padding: 0.625rem 0.75rem;
}

.trade-profit {
    display: flex;
    flex-direction: column;
    gap: 0.1875rem;
}

.profit-label {
    font-size: 0.55rem;
    font-weight: 700;
    letter-spacing: 0.1em;
    color: var(--primary);
}

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

.profit-percent {
    font-size: 0.65rem;
    font-weight: 600;
    font-family: 'JetBrains Mono', monospace;
    color: var(--green);
}

@media (max-width: 900px) {
    .terminal-body {
        grid-template-columns: 1fr;
        height: auto;
    }

    .terminal-sidebar {
        border-right: none;
        border-bottom: 1px solid var(--border);
    }

    .terminal-chart {
        height: 220px;
    }

    .terminal-trades {
        border-left: none;
        border-top: 1px solid var(--border);
    }
}

/* Features Section */
.features {
    padding: 6rem 2rem;
    background: var(--bg-dark);
}

.section-title {
    text-align: center;
    font-size: 2.25rem;
    font-weight: 700;
    margin-bottom: 3rem;
    letter-spacing: -0.02em;
}

.features-grid {
    max-width: 1200px;
    margin: 0 auto;
    display: grid;
    /* min() keeps the track from demanding 320px on a narrower phone, which
       would overflow the viewport rather than wrapping. */
    grid-template-columns: repeat(auto-fit, minmax(min(320px, 100%), 1fr));
    gap: 1.5rem;
}

.feature-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 1.75rem;
    transition: all 0.3s;
}

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

.feature-icon {
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--primary-muted);
    border-radius: 8px;
    margin-bottom: 1.25rem;
}

.feature-card h3 {
    font-size: 1.05rem;
    font-weight: 600;
    margin-bottom: 0.75rem;
    letter-spacing: -0.01em;
}

.feature-card p {
    font-size: 0.875rem;
    line-height: 1.6;
    color: var(--text-secondary);
}

/* Performance Section */
.performance {
    padding: 6rem 2rem;
    background: var(--bg-darker);
}

.performance-content {
    max-width: 1200px;
    margin: 0 auto;
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 2rem;
}

.performance-chart {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 2rem;
}

.chart-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
}

.chart-header h3 {
    font-size: 1.05rem;
    font-weight: 600;
}

.chart-legend {
    display: flex;
    gap: 1.5rem;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.legend-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
}

.legend-ai { background: var(--primary); }
.legend-market { background: var(--text-tertiary); }

.performance-stats {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.perf-stat {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 1.5rem;
}

.perf-label {
    font-size: 0.75rem;
    color: var(--text-tertiary);
    margin-bottom: 0.5rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 500;
}

.perf-value {
    font-size: 1.75rem;
    font-weight: 700;
    margin-bottom: 0.25rem;
    letter-spacing: -0.02em;
}

.perf-value.positive { color: var(--green); }
.perf-value.negative { color: var(--red); }

.perf-period {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

/* CTA Section */
.cta {
    padding: 6rem 2rem;
    text-align: center;
    background: var(--bg-dark);
}

.cta-content h2 {
    font-size: 2.25rem;
    font-weight: 700;
    margin-bottom: 1rem;
    letter-spacing: -0.02em;
}

.cta-content p {
    font-size: 1.05rem;
    color: var(--text-secondary);
    margin-bottom: 2rem;
}

/* Footer */
.footer {
    background: var(--bg-darker);
    border-top: 1px solid var(--border);
    padding: 3rem 2rem 2rem;
}

.footer-content {
    max-width: 1200px;
    margin: 0 auto;
    display: grid;
    grid-template-columns: 2fr 1fr 1fr 1fr;
    gap: 3rem;
    margin-bottom: 2rem;
}

.footer-section h4 {
    font-size: 0.875rem;
    font-weight: 600;
    margin-bottom: 1rem;
}

.footer-section a {
    display: block;
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.85rem;
    margin-bottom: 0.625rem;
    transition: color 0.2s;
}

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

.footer-section p {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-top: 0.5rem;
}

.footer-bottom {
    max-width: 1200px;
    margin: 0 auto;
    padding-top: 2rem;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.footer-bottom p {
    font-size: 0.8rem;
    color: var(--text-tertiary);
}

.footer-links {
    display: flex;
    gap: 1.5rem;
}

.footer-links a {
    font-size: 0.8rem;
    color: var(--text-secondary);
    text-decoration: none;
}

/* ===== TRADING APP ===== */

.trading-app {
    /* 100vh on mobile is the URL-bar-hidden height, so the app grows taller
       than the visible area and the page jumps as the bar slides. dvh tracks
       the real viewport; the vh line stays as the fallback. */
    height: 100vh;
    height: 100dvh;
    display: flex;
    flex-direction: column;
    background: var(--bg-dark);
}

/* Mobile panel switcher - revealed at the 860px breakpoint */
.mobile-tabs {
    display: none;
    flex-shrink: 0;
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
}

.mtab {
    flex: 1;
    min-height: 44px;
    background: transparent;
    border: none;
    border-bottom: 2px solid transparent;
    color: var(--text-secondary);
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    cursor: pointer;
    transition: color 0.2s, border-color 0.2s;
}

.mtab.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
}

/* App Header */
.app-header {
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    padding: 0.75rem 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

.network-status {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.status-dot {
    width: 6px;
    height: 6px;
    background: var(--primary);
    border-radius: 50%;
    animation: pulse 2s infinite;
}

.header-center {
    flex: 1;
    max-width: 500px;
    margin: 0 2rem;
}

.search-bar {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    background: var(--bg-dark);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 0.5rem 0.875rem;
    transition: border-color 0.2s;
}

.search-bar:focus-within {
    border-color: var(--primary);
}

.search-bar svg {
    color: var(--text-tertiary);
    flex-shrink: 0;
}

.search-bar input {
    flex: 1;
    background: none;
    border: none;
    outline: none;
    color: var(--text-primary);
    font-size: 0.85rem;
}

.search-bar input::placeholder {
    color: var(--text-tertiary);
}

.header-right {
    display: flex;
    align-items: center;
    gap: 1.25rem;
}

.open-connect-modal {
    background: var(--primary);
    color: var(--bg-dark);
    padding: 0.5rem 1.25rem;
    border-radius: 6px;
    border: none;
    font-weight: 600;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.2s;
}

.open-connect-modal:hover {
    background: var(--primary-dark);
}

/* App Content */
.app-content {
    display: flex;
    flex: 1;
    overflow: hidden;
    min-height: 0;
}

/* Sidebar */
.sidebar {
    width: 260px;
    background: var(--bg-card);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
}

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

.sidebar-header h3 {
    font-size: 0.85rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.view-toggle {
    display: flex;
    gap: 0.25rem;
}

.toggle-btn {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.8rem;
    transition: all 0.2s;
}

.toggle-btn.active {
    background: var(--primary);
    color: var(--bg-dark);
}

.market-list {
    flex: 1;
    overflow-y: auto;
}

.market-item {
    padding: 0.75rem 1.25rem;
    border-bottom: 1px solid var(--border);
    cursor: pointer;
    transition: background 0.2s;
}

.market-item:hover {
    background: var(--bg-elevated);
}

.market-item.active {
    background: var(--primary-muted);
    border-left: 2px solid var(--primary);
}

.market-item-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.25rem;
}

.market-symbol-text {
    font-weight: 600;
    font-size: 0.8rem;
}

.market-price {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.75rem;
}

.market-item-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.market-volume {
    font-size: 0.7rem;
    color: var(--text-tertiary);
}

.market-change {
    font-size: 0.7rem;
    font-weight: 600;
    padding: 0.125rem 0.375rem;
    border-radius: 3px;
}

.market-change.positive {
    color: var(--green);
    background: rgba(0, 255, 136, 0.1);
}

.market-change.negative {
    color: var(--red);
    background: rgba(255, 71, 87, 0.1);
}

/* Main Content */
/* The chart plus the insights panel are taller than a short viewport, so this
   column scrolls instead of clipping whatever does not fit. */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    overflow-x: hidden;
    background: var(--bg-dark);
    min-height: 0;
}

.market-header {
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    padding: 0.875rem 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1.5rem;
    flex-wrap: wrap;
    flex-shrink: 0;
}

.market-info {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.market-symbol {
    font-size: 0.9rem;
    font-weight: 600;
    letter-spacing: -0.01em;
}

.market-chain {
    font-size: 0.65rem;
    color: var(--text-secondary);
    background: var(--bg-dark);
    padding: 0.2rem 0.5rem;
    border-radius: 3px;
}

.market-price-info {
    display: flex;
    align-items: baseline;
    gap: 0.625rem;
}

.current-price {
    font-size: 1.1rem;
    font-weight: 600;
    font-family: 'JetBrains Mono', monospace;
    letter-spacing: -0.02em;
}

.price-change {
    font-size: 0.8rem;
    font-weight: 500;
}

.price-change.positive {
    color: var(--green);
}

.price-change.negative {
    color: var(--red);
}

.market-stats {
    display: flex;
    gap: 1.25rem;
    flex-wrap: wrap;
}

.stat-item {
    display: flex;
    flex-direction: column;
    min-width: 85px;
}

.stat-label {
    font-size: 0.625rem;
    color: var(--text-tertiary);
    margin-bottom: 0.2rem;
    white-space: nowrap;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 500;
}

.stat-value {
    font-size: 0.775rem;
    font-weight: 500;
    font-family: 'JetBrains Mono', monospace;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    letter-spacing: -0.01em;
}

/* Chart Container */
/* flex-shrink:0 keeps the chart from being squeezed to nothing once the column
   scrolls; the min-height is a floor, not a fixed 500px demand. */
.chart-container {
    flex: 1 0 auto;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-height: 360px;
}

.chart-controls {
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    padding: 0.875rem 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
}

.timeframe-selector {
    display: flex;
    gap: 0.375rem;
}

.tf-btn {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-secondary);
    padding: 0.375rem 0.75rem;
    border-radius: 5px;
    font-size: 0.8rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

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

.tf-btn.active {
    background: var(--primary);
    color: var(--bg-dark);
    border-color: var(--primary);
}

.chart-indicators {
    display: flex;
    gap: 0.375rem;
}

.indicator-btn {
    background: var(--bg-dark);
    border: 1px solid var(--border);
    color: var(--text-secondary);
    padding: 0.375rem 0.75rem;
    border-radius: 5px;
    font-size: 0.8rem;
    cursor: pointer;
    transition: all 0.2s;
}

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

.chart-wrapper {
    flex: 1;
    padding: 1rem 1.25rem;
    position: relative;
    min-height: 300px;
}

#mainChart {
    width: 100%;
    height: 100%;
}

/* AI Insights */
/* flex-shrink:0 keeps this from being squeezed to nothing when the chart
   above it claims the free space in a short viewport. */
.ai-insights {
    background: var(--bg-card);
    border-top: 1px solid var(--border);
    padding: 1.25rem 1.5rem;
    flex-shrink: 0;
}

.insights-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.insights-header h3 {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.85rem;
    font-weight: 600;
}

.ai-status {
    display: flex;
    align-items: center;
    gap: 0.375rem;
    font-size: 0.7rem;
    color: var(--text-secondary);
}

.insights-content {
    display: flex;
    gap: 1rem;
}

.insight-item {
    flex: 1;
    background: var(--bg-dark);
    border: 1px solid var(--border);
    border-left: 3px solid;
    border-radius: 6px;
    padding: 1rem;
}

.insight-item.bullish {
    border-left-color: var(--green);
}

.insight-item.neutral {
    border-left-color: var(--text-tertiary);
}

.insight-indicator {
    font-size: 0.7rem;
    font-weight: 700;
    margin-bottom: 0.625rem;
    letter-spacing: 0.05em;
}

.insight-item p {
    font-size: 0.8rem;
    line-height: 1.5;
    color: var(--text-secondary);
    margin-bottom: 0.625rem;
}

.insight-confidence {
    font-size: 0.7rem;
    color: var(--text-tertiary);
}

/* Right Panel */
.right-panel {
    width: 340px;
    background: var(--bg-card);
    border-left: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    flex-shrink: 0;
}

/* Trading Panel */
.trading-panel {
    border-bottom: 1px solid var(--border);
    padding: 1.25rem;
}

.trade-tabs {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1.25rem;
}

.trade-tab {
    flex: 1;
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-secondary);
    padding: 0.5rem;
    border-radius: 6px;
    font-size: 0.8rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.trade-tab.active {
    background: var(--primary);
    color: var(--bg-dark);
    border-color: var(--primary);
}

.order-type-selector {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem;
    margin-bottom: 1.25rem;
}

.order-type-btn {
    padding: 0.625rem;
    border-radius: 6px;
    border: 1px solid var(--border);
    background: transparent;
    color: var(--text-secondary);
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.order-type-btn.active {
    background: rgba(0, 255, 136, 0.1);
    border-color: var(--primary);
    color: var(--primary);
}

.form-group {
    margin-bottom: 1rem;
}

.form-group label {
    display: block;
    font-size: 0.75rem;
    color: var(--text-tertiary);
    margin-bottom: 0.5rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    font-weight: 500;
}

.input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.input-wrapper input {
    width: 100%;
    background: var(--bg-dark);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 0.625rem 0.875rem;
    color: var(--text-primary);
    font-size: 0.85rem;
    font-family: 'JetBrains Mono', monospace;
    transition: border-color 0.2s;
}

.input-wrapper input:focus {
    outline: none;
    border-color: var(--primary);
}

.input-suffix {
    position: absolute;
    right: 0.875rem;
    font-size: 0.75rem;
    color: var(--text-tertiary);
    pointer-events: none;
}

.amount-slider {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0.375rem;
    margin-bottom: 1rem;
}

.amount-quick {
    background: var(--bg-dark);
    border: 1px solid var(--border);
    color: var(--text-secondary);
    padding: 0.375rem;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.amount-quick:hover {
    border-color: var(--primary);
    color: var(--primary);
}

.trade-submit-btn {
    width: 100%;
    padding: 0.75rem;
    border-radius: 6px;
    border: none;
    font-weight: 600;
    font-size: 0.875rem;
    cursor: pointer;
    transition: all 0.2s;
}

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

.buy-btn:hover {
    background: var(--primary-dark);
}

.sell-btn {
    background: var(--red);
    color: white;
}

.sell-btn:hover {
    background: var(--red-dark);
}

.available-balance {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border);
}

.balance-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.8rem;
}

.balance-row span:first-child {
    color: var(--text-secondary);
}

.balance-amount {
    font-weight: 600;
    font-family: 'JetBrains Mono', monospace;
}

/* Activity Panel */
.activity-panel {
    padding: 1.25rem;
    border-bottom: 1px solid var(--border);
}

.activity-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.activity-header h3 {
    font-size: 0.85rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.activity-filter {
    background: var(--bg-dark);
    border: 1px solid var(--border);
    color: var(--text-secondary);
    padding: 0.375rem 0.625rem;
    border-radius: 4px;
    font-size: 0.75rem;
    cursor: pointer;
}

.activity-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.activity-item {
    background: var(--bg-dark);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 0.75rem;
}

.activity-item-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.375rem;
}

.activity-type {
    font-size: 0.7rem;
    font-weight: 700;
    padding: 0.2rem 0.5rem;
    border-radius: 3px;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.activity-type.buy {
    background: rgba(0, 255, 136, 0.1);
    color: var(--green);
}

.activity-type.sell {
    background: rgba(255, 71, 87, 0.1);
    color: var(--red);
}

.activity-time {
    font-size: 0.7rem;
    color: var(--text-tertiary);
}

.activity-details {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.activity-details strong {
    color: var(--text-primary);
}

/* Positions Panel */
.positions-panel {
    padding: 1.25rem;
}

.positions-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.positions-header h3 {
    font-size: 0.85rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.positions-count {
    background: var(--bg-dark);
    color: var(--text-secondary);
    padding: 0.25rem 0.625rem;
    border-radius: 12px;
    font-size: 0.7rem;
    font-weight: 600;
}

.empty-state {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--text-tertiary);
}

.empty-state svg {
    margin-bottom: 1rem;
}

.empty-state p {
    font-size: 0.85rem;
    margin-bottom: 0.5rem;
}

.empty-state span {
    font-size: 0.75rem;
    color: var(--text-tertiary);
}

/* Loading Screen */
.loading-screen {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--bg-dark);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    transition: opacity 0.5s;
}

.loading-content {
    text-align: center;
}

.loading-logo .logo-icon {
    margin: 0 auto 1.5rem;
    animation: logo-spin 2s linear infinite;
}

.loading-text {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-bottom: 1.5rem;
}

.loading-bar {
    width: 200px;
    height: 3px;
    background: var(--bg-elevated);
    border-radius: 2px;
    overflow: hidden;
}

.loading-progress {
    height: 100%;
    background: var(--primary);
    animation: loading 1.5s ease-in-out infinite;
}

@keyframes loading {
    0% { width: 0%; margin-left: 0%; }
    50% { width: 75%; margin-left: 25%; }
    100% { width: 0%; margin-left: 100%; }
}

/* ===== AUTHENTICATION PAGE ===== */

.auth-page {
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-darker);
    padding: 2rem;
}

.auth-container {
    max-width: 420px;
    width: 100%;
}

.auth-logo {
    text-align: center;
    margin-bottom: 2.5rem;
}

.auth-logo h1 {
    font-size: 1.75rem;
    margin-top: 1rem;
    color: var(--primary);
    letter-spacing: -0.02em;
}

.auth-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 2.25rem;
}

.auth-card h2 {
    font-size: 1.35rem;
    margin-bottom: 0.5rem;
    text-align: center;
    letter-spacing: -0.01em;
}

.auth-subtitle {
    color: var(--text-secondary);
    text-align: center;
    margin-bottom: 1.75rem;
    font-size: 0.875rem;
}

.auth-form .form-group {
    margin-bottom: 1.25rem;
}

.auth-form label {
    display: block;
    margin-bottom: 0.5rem;
    color: var(--text-secondary);
    font-size: 0.8rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.auth-form input[type="text"] {
    width: 100%;
    padding: 0.75rem 0.875rem;
    background: var(--bg-dark);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text-primary);
    font-size: 0.95rem;
    font-family: 'JetBrains Mono', monospace;
    letter-spacing: 0.5px;
    transition: all 0.2s;
}

.auth-form input[type="text"]:focus {
    outline: none;
    border-color: var(--primary);
}

.error-message {
    background: rgba(255, 58, 110, 0.1);
    border: 1px solid rgba(255, 58, 110, 0.3);
    color: #ff3a6e;
    padding: 0.625rem 0.875rem;
    border-radius: 6px;
    font-size: 0.8rem;
    margin-bottom: 1rem;
    text-align: center;
}

.btn-full {
    width: 100%;
    justify-content: center;
}

.auth-footer {
    margin-top: 1.75rem;
    text-align: center;
}

.auth-footer p {
    color: var(--text-secondary);
    font-size: 0.8rem;
    margin-bottom: 0.5rem;
}

.back-link {
    color: var(--primary);
    text-decoration: none;
    font-size: 0.8rem;
    transition: opacity 0.2s;
}

.back-link:hover {
    opacity: 0.8;
}

/* ===== ADMIN PANEL ===== */

.admin-page {
    min-height: 100vh;
    min-height: 100dvh;
    background: var(--bg-dark);
}

.admin-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.25rem 2rem;
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
}

.admin-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem;
}

.admin-section {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 1.75rem;
    margin-bottom: 1.75rem;
}

.section-header {
    margin-bottom: 1.25rem;
}

.section-header h2 {
    font-size: 1.25rem;
    margin-bottom: 0.375rem;
    letter-spacing: -0.01em;
}

.section-header p {
    color: var(--text-secondary);
    font-size: 0.85rem;
}

.code-generator {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

.generator-form .form-row {
    display: flex;
    gap: 0.875rem;
    align-items: flex-end;
}

.generator-form .form-group {
    flex: 1;
}

.generator-form label {
    display: block;
    margin-bottom: 0.5rem;
    color: var(--text-secondary);
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    font-weight: 500;
}

.generator-form input[type="text"] {
    width: 100%;
    padding: 0.625rem 0.875rem;
    background: var(--bg-dark);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text-primary);
    font-size: 0.85rem;
}

.generated-code {
    background: var(--bg-dark);
    border: 2px solid var(--primary);
    border-radius: 10px;
    padding: 1.25rem;
}

.code-display {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.code-display code {
    flex: 1;
    font-family: 'JetBrains Mono', monospace;
    font-size: 1.15rem;
    color: var(--primary);
    letter-spacing: 1px;
}

.copy-btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    background: var(--primary);
    color: var(--bg-dark);
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-weight: 600;
    font-size: 0.8rem;
    transition: all 0.2s;
}

.copy-btn:hover {
    background: var(--primary-dark);
}

.codes-list {
    display: flex;
    flex-direction: column;
    gap: 0.875rem;
}

.code-item {
    background: var(--bg-dark);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 1.125rem;
    transition: border-color 0.2s;
}

.code-item:hover {
    border-color: var(--border-hover);
}

.code-item.revoked {
    opacity: 0.6;
}

.code-item-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.625rem;
}

.code-text {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.9rem;
    color: var(--primary);
    background: var(--primary-muted);
    padding: 0.35rem 0.75rem;
    border-radius: 5px;
}

.code-status {
    padding: 0.25rem 0.75rem;
    border-radius: 20px;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.status-active {
    background: rgba(0, 255, 136, 0.15);
    color: var(--primary);
}

.status-revoked {
    background: rgba(255, 58, 110, 0.15);
    color: #ff3a6e;
}

.code-item-details {
    display: flex;
    gap: 1.25rem;
    margin-bottom: 0.875rem;
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.code-item-actions {
    display: flex;
    gap: 0.5rem;
}

.code-item-actions button {
    padding: 0.5rem 1rem;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 0.8rem;
    font-weight: 500;
    transition: all 0.2s;
}

.btn-copy {
    background: var(--bg-elevated);
    color: var(--text-primary);
    border: 1px solid var(--border);
}

.btn-copy:hover {
    background: var(--border-hover);
}

.btn-revoke {
    background: rgba(255, 58, 110, 0.1);
    color: #ff3a6e;
}

.btn-revoke:hover {
    background: rgba(255, 58, 110, 0.2);
}

.btn-activate {
    background: rgba(0, 255, 136, 0.1);
    color: var(--primary);
}

.btn-activate:hover {
    background: rgba(0, 255, 136, 0.2);
}

.btn-delete {
    background: rgba(255, 58, 110, 0.05);
    color: #ff3a6e;
}

.btn-delete:hover {
    background: rgba(255, 58, 110, 0.15);
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(200px, 100%), 1fr));
    gap: 1rem;
}

.stat-card {
    background: var(--bg-dark);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 1.25rem;
}

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

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

.empty-state {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--text-secondary);
}

.empty-state p {
    margin-top: 1rem;
}

/* Admin Badge */
.admin-badge {
    display: inline-block;
    padding: 0.25rem 0.5rem;
    background: var(--primary);
    color: var(--bg-dark);
    font-size: 0.625rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border-radius: 3px;
}

/* Checkbox styling */
input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
    accent-color: var(--primary);
}

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

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

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

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

/* ===== DOCUMENTATION PAGE ===== */

.docs-section {
    padding: 8rem 2rem 4rem;
    min-height: 100vh;
}

.docs-layout {
    display: grid;
    grid-template-columns: 260px 1fr;
    gap: 3rem;
    max-width: 1200px;
    margin: 0 auto;
}

.docs-sidebar {
    position: sticky;
    top: 6rem;
    height: fit-content;
}

.docs-sidebar h3 {
    font-size: 0.85rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 1rem;
    color: var(--text-tertiary);
}

.docs-nav {
    list-style: none;
}

.docs-nav li {
    margin-bottom: 0.5rem;
}

.docs-nav a {
    display: block;
    padding: 0.5rem 0.75rem;
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.875rem;
    border-radius: 6px;
    transition: all 0.2s;
}

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

.docs-nav a.active {
    background: var(--primary-muted);
    color: var(--primary);
}

.docs-content {
    max-width: 800px;
}

.docs-content h1 {
    font-size: 2.5rem;
    font-weight: 700;
    margin-bottom: 1rem;
    letter-spacing: -0.02em;
}

.docs-intro {
    font-size: 1.125rem;
    color: var(--text-secondary);
    margin-bottom: 3rem;
    line-height: 1.6;
}

.doc-block {
    margin-bottom: 4rem;
    scroll-margin-top: 6rem;
}

.doc-block h2 {
    font-size: 1.75rem;
    font-weight: 700;
    margin-bottom: 1rem;
    letter-spacing: -0.01em;
    padding-top: 1rem;
    border-top: 1px solid var(--border);
}

.doc-block h3 {
    font-size: 1.25rem;
    font-weight: 600;
    margin: 2rem 0 1rem;
    letter-spacing: -0.01em;
}

.doc-block h4 {
    font-size: 1.05rem;
    font-weight: 600;
    margin: 1.5rem 0 0.75rem;
}

.doc-block p {
    font-size: 0.95rem;
    line-height: 1.7;
    color: var(--text-secondary);
    margin-bottom: 1rem;
}

.doc-block ul,
.doc-block ol {
    margin: 1rem 0 1rem 1.5rem;
    color: var(--text-secondary);
}

.doc-block li {
    margin-bottom: 0.5rem;
    font-size: 0.95rem;
    line-height: 1.6;
}

.doc-block a {
    color: var(--primary);
    text-decoration: none;
    border-bottom: 1px solid transparent;
    transition: border-color 0.2s;
}

.doc-block a:hover {
    border-bottom-color: var(--primary);
}

.doc-block code {
    background: var(--bg-card);
    padding: 0.2rem 0.4rem;
    border-radius: 3px;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.875rem;
    color: var(--primary);
}

.info-box,
.warning-box {
    padding: 1rem 1.25rem;
    border-radius: 8px;
    margin: 1.5rem 0;
    font-size: 0.9rem;
    line-height: 1.6;
}

.info-box {
    background: var(--primary-muted);
    border-left: 3px solid var(--primary);
    color: var(--text-secondary);
}

.warning-box {
    background: rgba(255, 71, 87, 0.1);
    border-left: 3px solid var(--red);
    color: var(--text-secondary);
}

.info-box strong,
.warning-box strong {
    color: var(--text-primary);
}

/* Logo Image */
.logo-image {
    width: 28px;
    height: 28px;
    border-radius: 6px;
}

.logo-image.large {
    width: 56px;
    height: 56px;
}

/* Responsive */
@media (max-width: 768px) {
    .docs-layout {
        grid-template-columns: 1fr;
        gap: 2rem;
    }

    .docs-sidebar {
        position: relative;
        top: 0;
    }

    .docs-content h1 {
        font-size: 2rem;
    }
}

/* ===== AI AUTO BOT PANEL =====
   The Spot/Margin form and the bot panel occupy the same slot; data-mode on
   .trading-panel decides which one is mounted. */

.ai-bot-panel {
    display: none;
}

.trading-panel[data-mode="ai"] .trade-form,
.trading-panel[data-mode="ai"] .order-type-selector {
    display: none;
}

.trading-panel[data-mode="ai"] .ai-bot-panel {
    display: block;
}

.bot-status-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.bot-state {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.8rem;
    font-weight: 500;
}

.bot-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--text-tertiary);
    flex-shrink: 0;
}

.bot-dot.scanning {
    background: var(--primary);
    animation: pulse 1.6s infinite;
}

.bot-dot.active {
    background: var(--primary);
    box-shadow: 0 0 0 3px rgba(0, 255, 136, 0.15);
}

.bot-dot.waiting {
    background: #f0a020;
    animation: pulse 1.6s infinite;
}

.bot-mode {
    font-size: 0.6rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-tertiary);
    border: 1px solid var(--border);
    border-radius: 3px;
    padding: 0.15rem 0.4rem;
}

.bot-pnl {
    background: var(--bg-dark);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 1rem;
    margin-bottom: 0.75rem;
    text-align: center;
}

.bot-pnl-label {
    display: block;
    font-size: 0.625rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-tertiary);
    font-weight: 600;
    margin-bottom: 0.375rem;
}

.bot-pnl-value {
    display: block;
    font-size: 1.4rem;
    font-weight: 700;
    font-family: 'JetBrains Mono', monospace;
    letter-spacing: -0.02em;
    /* Counter shifts by a digit constantly; a tabular font stops the jitter */
    font-variant-numeric: tabular-nums;
    transition: color 0.3s;
}

.bot-pnl-value.positive { color: var(--green); }
.bot-pnl-value.negative { color: var(--red); }

.bot-stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.5rem;
    margin-bottom: 0.75rem;
}

.bot-stat {
    background: var(--bg-dark);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 0.5rem 0.375rem;
    text-align: center;
    min-width: 0;
}

.bot-stat-label {
    display: block;
    font-size: 0.55rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-tertiary);
    font-weight: 600;
    margin-bottom: 0.25rem;
}

.bot-stat-value {
    display: block;
    font-size: 0.7rem;
    font-weight: 600;
    font-family: 'JetBrains Mono', monospace;
    font-variant-numeric: tabular-nums;
    /* "Best" can reach +$50,000.00 in a 1/3-width cell */
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.bot-position {
    background: var(--bg-dark);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 0.75rem;
    margin-bottom: 0.875rem;
    min-height: 44px;
}

.bot-position-empty {
    font-size: 0.7rem;
    color: var(--text-tertiary);
}

.bot-position-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.5rem;
}

.bot-position-row + .bot-position-row {
    margin-top: 0.375rem;
}

.bot-pos-side {
    font-size: 0.625rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    padding: 0.125rem 0.375rem;
    border-radius: 3px;
}

.bot-pos-side.buy {
    color: var(--green);
    background: rgba(0, 255, 136, 0.12);
}

.bot-pos-side.sell {
    color: var(--red);
    background: rgba(255, 71, 87, 0.12);
}

.bot-pos-symbol {
    font-size: 0.7rem;
    font-weight: 600;
}

.bot-pos-label {
    font-size: 0.65rem;
    color: var(--text-tertiary);
}

.bot-pos-value {
    font-size: 0.7rem;
    font-family: 'JetBrains Mono', monospace;
    font-variant-numeric: tabular-nums;
}

.bot-toggle-btn {
    width: 100%;
    padding: 0.75rem;
    border-radius: 6px;
    border: 1px solid var(--primary);
    background: var(--primary);
    color: var(--bg-dark);
    font-weight: 600;
    font-size: 0.875rem;
    cursor: pointer;
    transition: all 0.2s;
}

.bot-toggle-btn:hover {
    background: var(--primary-dark);
}

.bot-toggle-btn.running {
    background: transparent;
    border-color: var(--red);
    color: var(--red);
}

.bot-toggle-btn.running:hover {
    background: rgba(255, 71, 87, 0.1);
}

/* Secondary to the Start/Stop action above it: outlined, not filled, so the
   primary control still reads as primary. */
.bot-withdraw-btn {
    width: 100%;
    margin-top: 0.5rem;
    padding: 0.7rem;
    border-radius: 6px;
    border: 1px solid var(--border);
    background: transparent;
    color: var(--text-primary);
    font-weight: 600;
    font-size: 0.8rem;
    font-variant-numeric: tabular-nums;
    cursor: pointer;
    transition: all 0.2s;
}

.bot-withdraw-btn:hover:not(:disabled) {
    border-color: var(--primary);
    color: var(--primary);
    background: rgba(0, 255, 136, 0.06);
}

.bot-withdraw-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

/* Reserves no space until it has something to say, so the panel does not
   jump the first time a withdrawal lands. */
.bot-withdraw-note {
    max-height: 0;
    margin: 0;
    overflow: hidden;
    opacity: 0;
    font-size: 0.7rem;
    line-height: 1.5;
    text-align: center;
    color: var(--primary);
    transition: opacity 0.25s ease, max-height 0.25s ease, margin-top 0.25s ease;
}

.bot-withdraw-note.visible {
    max-height: 3rem;
    margin-top: 0.55rem;
    opacity: 1;
}

.bot-disclaimer {
    margin-top: 0.75rem;
    font-size: 0.6rem;
    line-height: 1.5;
    color: var(--text-tertiary);
    text-align: center;
}

/* ===== CHART EXECUTION ANIMATIONS =====
   Overlaid on .chart-wrapper (already position:relative). pointer-events:none
   throughout so the chart stays fully interactive underneath. */

.bot-fx-layer {
    position: absolute;
    inset: 0;
    overflow: hidden;
    pointer-events: none;
    z-index: 5;
}

.bot-fx-chip {
    position: absolute;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.95rem;
    font-weight: 700;
    letter-spacing: -0.01em;
    padding: 0.3rem 0.625rem;
    border-radius: 6px;
    white-space: nowrap;
    pointer-events: none;
    animation: bot-fx-rise 2.1s cubic-bezier(0.2, 0.7, 0.3, 1) forwards;
}

.bot-fx-chip.win {
    color: var(--green);
    background: rgba(0, 255, 136, 0.1);
    border: 1px solid rgba(0, 255, 136, 0.3);
}

.bot-fx-chip.loss {
    color: var(--red);
    background: rgba(255, 71, 87, 0.1);
    border: 1px solid rgba(255, 71, 87, 0.3);
}

/* Big wins get a longer, larger flight so they read as an event */
.bot-fx-chip.big {
    font-size: 1.3rem;
    padding: 0.4rem 0.875rem;
    border-color: rgba(0, 255, 136, 0.5);
    animation: bot-fx-rise-big 2.9s cubic-bezier(0.2, 0.7, 0.3, 1) forwards;
}

.bot-fx-chip.entry {
    font-size: 0.65rem;
    font-weight: 600;
    letter-spacing: 0.06em;
    color: var(--text-secondary);
    background: var(--bg-elevated);
    border: 1px solid var(--border-hover);
    animation: bot-fx-fade 1.5s ease-out forwards;
}

@keyframes bot-fx-rise {
    0%   { opacity: 0; transform: translateY(10px) scale(0.9); }
    15%  { opacity: 1; transform: translateY(0) scale(1); }
    70%  { opacity: 1; transform: translateY(-26px) scale(1); }
    100% { opacity: 0; transform: translateY(-46px) scale(0.96); }
}

@keyframes bot-fx-rise-big {
    0%   { opacity: 0; transform: translateY(14px) scale(0.8); }
    12%  { opacity: 1; transform: translateY(0) scale(1.12); }
    22%  { transform: translateY(-4px) scale(1); }
    70%  { opacity: 1; transform: translateY(-40px) scale(1); }
    100% { opacity: 0; transform: translateY(-68px) scale(0.94); }
}

@keyframes bot-fx-fade {
    0%   { opacity: 0; transform: translateY(6px); }
    20%  { opacity: 1; transform: translateY(0); }
    75%  { opacity: 1; }
    100% { opacity: 0; transform: translateY(-10px); }
}

/* ===== ACTIVITY FEED - BOT ROWS ===== */

.activity-bot-tag {
    display: inline-block;
    margin-right: 0.3rem;
    padding: 0.05rem 0.25rem;
    border-radius: 2px;
    background: var(--primary);
    color: var(--bg-dark);
    font-size: 0.5rem;
    font-weight: 800;
    letter-spacing: 0.05em;
    vertical-align: 1px;
}

.activity-item.bot-activity {
    border-left: 2px solid var(--primary);
    padding-left: 0.625rem;
}

/* The details line carries the size/price text plus an optional P&L figure;
   flex with margin-left:auto pins the figure right without a float, which
   would escape the rounded card on a narrow panel. */
.activity-details {
    display: flex;
    align-items: baseline;
    flex-wrap: wrap;
    gap: 0.25rem;
}

.activity-pnl {
    margin-left: auto;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.7rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

.activity-pnl.positive { color: var(--green); }
.activity-pnl.negative { color: var(--red); }

/* ===== RESPONSIVE LAYERS =====
   Breakpoints, widest first: 1200 trims the desktop chrome, 1024 unstacks the
   tablet grids, 900 narrows the middle column, 860 turns the three-column
   terminal into one panel at a time, 768 swaps the landing nav for a drawer,
   480 tightens a phone. */

/* --- 1200px: small laptops - give the chart back some width --- */
@media (max-width: 1200px) {
    .sidebar {
        width: 220px;
    }

    .right-panel {
        width: 300px;
    }

    .nav-container {
        padding: 0.875rem 1.5rem;
    }

    .hero {
        padding: 7rem 1.5rem 4rem;
    }

    .features,
    .performance,
    .cta {
        padding: 5rem 1.5rem;
    }

    .footer {
        padding: 3rem 1.5rem 2rem;
    }
}

/* --- 1024px: tablet - two-up grids collapse, header search shrinks --- */
@media (max-width: 1024px) {
    .hero-title {
        font-size: 2.75rem;
    }

    .performance-content {
        grid-template-columns: 1fr;
    }

    /* Side-by-side on a wide tablet reads better than a tall single column */
    .performance-stats {
        flex-direction: row;
        flex-wrap: wrap;
    }

    .perf-stat {
        flex: 1 1 200px;
    }

    .footer-content {
        grid-template-columns: 1fr 1fr;
        gap: 2rem;
    }

    .header-center {
        max-width: 320px;
        margin: 0 1rem;
    }

    .docs-layout {
        gap: 2rem;
    }
}

/* --- 900px: the middle column is too narrow for side-by-side insights --- */
@media (max-width: 900px) {
    .insights-content {
        flex-direction: column;
    }

    .market-stats {
        gap: 1rem;
    }

    /* The landing terminal is stacked here (rule above), so the market list
       needs its own ceiling or it prints all rows at full height. */
    .terminal-market-list {
        max-height: 200px;
    }
}

/* --- 860px: the trading terminal goes single-panel ---
   260px + 340px of fixed side columns cannot share a phone with a chart, so
   the tab bar in app.html picks one panel and the rest are hidden. */
@media (max-width: 860px) {
    .mobile-tabs {
        display: flex;
    }

    /* Logo/status and balance/connect keep row one; search drops to row two */
    .app-header {
        flex-wrap: wrap;
        gap: 0.625rem;
        padding: 0.75rem 1rem;
    }

    .header-left {
        gap: 0.875rem;
    }

    .header-center {
        order: 3;
        flex: 1 0 100%;
        max-width: none;
        margin: 0;
    }

    .header-right {
        gap: 0.875rem;
    }

    .app-content {
        flex-direction: column;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }

    .sidebar,
    .right-panel {
        width: 100%;
        flex: 1 1 auto;
        min-height: 0;
        border-left: none;
        border-right: none;
    }

    /* The single scroll container is .app-content now */
    .main-content {
        flex: 1 1 auto;
        overflow: visible;
    }

    .right-panel {
        overflow-y: visible;
    }
}

/* Panel visibility, driven by data-panel on .app-content. "trade" and
   "activity" both live in .right-panel, so they split it between them. */
@media (max-width: 860px) {
    .app-content[data-panel="markets"] .main-content,
    .app-content[data-panel="markets"] .right-panel {
        display: none;
    }

    .app-content[data-panel="chart"] .sidebar,
    .app-content[data-panel="chart"] .right-panel {
        display: none;
    }

    .app-content[data-panel="trade"] .sidebar,
    .app-content[data-panel="trade"] .main-content,
    .app-content[data-panel="trade"] .activity-panel,
    .app-content[data-panel="trade"] .positions-panel {
        display: none;
    }

    .app-content[data-panel="activity"] .sidebar,
    .app-content[data-panel="activity"] .main-content,
    .app-content[data-panel="activity"] .trading-panel {
        display: none;
    }

    .chart-container {
        min-height: 320px;
    }

    .chart-wrapper {
        padding: 0.75rem 0.875rem;
        min-height: 260px;
    }

    .market-header {
        padding: 0.75rem 1rem;
        gap: 0.875rem;
    }

    .chart-controls {
        padding: 0.75rem 1rem;
    }

    .ai-insights {
        padding: 1rem;
    }
}

/* --- 768px: phones - landing nav becomes a drawer --- */
@media (max-width: 768px) {
    .nav-toggle {
        display: flex;
    }

    /* top:100% anchors the drawer to the real navbar height, so changing the
       nav padding never leaves a gap or an overlap here. */
    .nav-container {
        position: relative;
        padding: 0.75rem 1.25rem;
    }

    .nav-links {
        position: absolute;
        top: 100%;
        left: 0;
        right: 0;
        flex-direction: column;
        align-items: stretch;
        gap: 0;
        padding: 0.25rem 1.25rem 1.25rem;
        background: var(--bg-dark);
        border-bottom: 1px solid var(--border);
        /* Subtract the navbar rather than using a percentage, which browsers
           may drop entirely against an auto-height parent. */
        max-height: calc(100dvh - 56px);
        overflow-y: auto;
        opacity: 0;
        visibility: hidden;
        transform: translateY(-10px);
        pointer-events: none;
        transition: opacity 0.22s ease, transform 0.22s ease, visibility 0.22s;
    }

    .nav-links.open {
        opacity: 1;
        visibility: visible;
        transform: translateY(0);
        pointer-events: auto;
    }

    .nav-links a {
        padding: 0.875rem 0.25rem;
        font-size: 0.95rem;
        border-bottom: 1px solid var(--border);
    }

    .nav-links .btn-launch {
        margin-top: 1rem;
        padding: 0.875rem 1.25rem;
        justify-content: center;
        border-bottom: none;
    }

    /* The spinning square sits behind centred text at full width */
    .nav-links .btn-launch::before {
        display: none;
    }
}

/* 768px: landing content stacks */
@media (max-width: 768px) {
    .hero {
        padding: 6rem 1.25rem 3rem;
    }

    .hero-title {
        font-size: 2.1rem;
    }

    .hero-description {
        font-size: 0.95rem;
        margin-bottom: 2rem;
    }

    .hero-actions {
        flex-direction: column;
        align-items: stretch;
        margin-bottom: 3rem;
    }

    .btn-primary,
    .btn-secondary {
        width: 100%;
        justify-content: center;
        padding: 0.875rem 1.25rem;
    }

    .btn-primary::before {
        display: none;
    }

    .hero-stats {
        grid-template-columns: repeat(2, 1fr);
        gap: 1.25rem 1rem;
        margin-bottom: 3rem;
    }

    /* Scoped: .stat-value is also the app's 24h High/Low and an admin stat card,
       and neither of those wants a 1.4rem number. */
    .hero-stats .stat-value {
        font-size: 1.4rem;
    }

    .section-title {
        font-size: 1.6rem;
        margin-bottom: 2rem;
    }
}

/* 768px: sections, footer and docs */
@media (max-width: 768px) {
    .features,
    .performance,
    .cta {
        padding: 3.5rem 1.25rem;
    }

    .feature-card {
        padding: 1.375rem;
    }

    .performance-chart {
        padding: 1.25rem;
    }

    .chart-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.75rem;
        margin-bottom: 1.25rem;
    }

    .cta-content h2 {
        font-size: 1.6rem;
    }

    .cta-content p {
        font-size: 0.95rem;
    }

    .footer {
        padding: 2.5rem 1.25rem 1.5rem;
    }

    .footer-content {
        grid-template-columns: 1fr;
        gap: 1.75rem;
    }

    .footer-bottom {
        flex-direction: column;
        gap: 1rem;
        text-align: center;
    }

    .docs-section {
        padding: 6rem 1.25rem 3rem;
    }
}

/* 768px: form controls.
   iOS Safari zooms the whole page when a focused field is under 16px and never
   zooms back out - that is what makes the body look like it has shifted
   sideways after tapping a field. 16px is the threshold, so every input that
   a phone can focus is pinned to it. */
@media (max-width: 768px) {
    .search-bar input,
    .auth-form input[type="text"],
    .input-wrapper input,
    .generator-form input[type="text"],
    .activity-filter,
    input[type="text"],
    input[type="number"],
    input[type="email"],
    input[type="password"],
    select,
    textarea {
        font-size: 16px;
    }

    /* Keep tap targets at the 44px minimum */
    .tf-btn,
    .indicator-btn,
    .toggle-btn,
    .trade-tab,
    .order-type-btn,
    .amount-quick,
    .code-item-actions button {
        min-height: 40px;
    }

    .trade-submit-btn,
    .open-connect-modal,
    .btn-launch {
        min-height: 44px;
    }
}

/* 768px: auth and admin */
@media (max-width: 768px) {
    .auth-page {
        padding: 1.25rem;
    }

    .auth-card {
        padding: 1.5rem;
    }

    .auth-logo {
        margin-bottom: 1.75rem;
    }

    .admin-header {
        flex-wrap: wrap;
        gap: 0.75rem;
        padding: 1rem 1.25rem;
    }

    .admin-container {
        padding: 1.25rem;
    }

    .admin-section {
        padding: 1.25rem;
    }

    .generator-form .form-row {
        flex-direction: column;
        align-items: stretch;
    }

    .code-display {
        flex-direction: column;
        align-items: stretch;
        gap: 0.75rem;
    }

    /* Generated codes are long enough to overflow a phone unbroken */
    .code-display code {
        font-size: 0.95rem;
        word-break: break-all;
    }

    .code-item-header {
        flex-wrap: wrap;
        gap: 0.5rem;
    }

    .code-item-details {
        flex-direction: column;
        gap: 0.35rem;
    }

    .code-item-actions {
        flex-wrap: wrap;
    }

    .code-item-actions button {
        flex: 1 1 auto;
    }
}

/* --- 480px: small phones --- */
@media (max-width: 480px) {
    .nav-container {
        padding: 0.75rem 1rem;
    }

    .hero {
        padding: 5.5rem 1rem 2.5rem;
    }

    .hero-title {
        font-size: 1.8rem;
    }

    .hero-badge {
        font-size: 0.7rem;
    }

    .hero-stats {
        gap: 1rem 0.75rem;
    }

    .features,
    .performance,
    .cta {
        padding: 3rem 1rem;
    }

    .footer {
        padding: 2rem 1rem 1.25rem;
    }

    .footer-links {
        flex-direction: column;
        gap: 0.5rem;
    }

    .terminal-chart {
        height: 180px;
    }

    .terminal-header {
        padding: 0.625rem 0.75rem;
        gap: 0.75rem;
    }

    .docs-section {
        padding: 5.5rem 1rem 2.5rem;
    }

    .docs-content h1 {
        font-size: 1.6rem;
    }
}

/* 480px: the terminal on a small phone */
@media (max-width: 480px) {
    .app-header {
        padding: 0.625rem 0.875rem;
    }

    /* Reclaim the width - the status dot duplicates what the app already shows */
    .network-status {
        display: none;
    }

    .market-header {
        padding: 0.75rem 0.875rem;
        gap: 0.75rem;
    }

    .current-price {
        font-size: 1rem;
    }

    .market-stats {
        width: 100%;
        gap: 0.875rem;
    }

    /* Let the three stats share the row instead of forcing an 85px floor.
       Scoped so the hero's .stat-item grid cells are left alone. */
    .market-stats .stat-item {
        flex: 1 1 0;
        min-width: 0;
    }

    /* Eleven buttons will not fit - two rows that scroll sideways will */
    .chart-controls {
        flex-direction: column;
        align-items: stretch;
        gap: 0.5rem;
        padding: 0.625rem 0.875rem;
    }

    .timeframe-selector,
    .chart-indicators {
        overflow-x: auto;
        scrollbar-width: none;
        -webkit-overflow-scrolling: touch;
    }

    .timeframe-selector::-webkit-scrollbar,
    .chart-indicators::-webkit-scrollbar {
        display: none;
    }

    .tf-btn,
    .indicator-btn {
        flex: 0 0 auto;
    }

    .trading-panel,
    .activity-panel,
    .positions-panel {
        padding: 1rem;
    }
}

/* --- Touch devices: a tapped :hover sticks, so drop the lift effects --- */
@media (hover: none) {
    .feature-card:hover,
    .btn-primary:hover,
    .btn-launch:hover {
        transform: none;
    }
}

/* --- Respect a reduced-motion preference --- */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }

    .hero-bg-animation {
        animation: none;
    }
}
