:root {
    --bg: #0a0e17;
    --bg-soft: #0f1524;
    --bg-card: #121a2c;
    --bg-input: #0d1322;
    --border: #1e2a44;
    --border-soft: #16203a;
    --text: #e7edf7;
    --text-dim: #8ea0bd;
    --text-faint: #5c6c8a;
    --accent: #00d68f;
    --accent-soft: rgba(0, 214, 143, 0.12);
    --up: #00d68f;
    --down: #ff5d6c;
    --radius: 12px;
    --radius-sm: 8px;
    --shadow: 0 8px 30px rgba(0, 0, 0, 0.35);
}

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

html { scroll-behavior: smooth; }

body {
    font-family: "Inter", "Segoe UI", system-ui, -apple-system, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    background-image:
        radial-gradient(1200px 500px at 80% -10%, rgba(0, 214, 143, 0.06), transparent),
        radial-gradient(900px 400px at 0% 0%, rgba(56, 130, 246, 0.05), transparent);
}

a { color: inherit; text-decoration: none; }
b { font-weight: 600; }

/* ---------- Top bar ---------- */
.topbar {
    position: sticky;
    top: 0;
    z-index: 50;
    background: rgba(10, 14, 23, 0.85);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--border-soft);
}
.topbar-inner {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 24px;
    height: 64px;
    display: flex;
    align-items: center;
    gap: 28px;
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 18px; letter-spacing: 0.4px; }
.brand-mark { color: var(--accent); font-size: 22px; }
.brand-dim { color: var(--text-faint); font-weight: 400; margin-left: 4px; }
.main-nav { display: flex; gap: 20px; flex: 1; }
.main-nav a { color: var(--text-dim); font-size: 14px; font-weight: 500; padding: 6px 2px; }
.main-nav a:hover, .main-nav a.active { color: var(--text); }
.main-nav a.active { color: var(--accent); box-shadow: inset 0 -2px 0 var(--accent); }
.topbar-actions { display: flex; align-items: center; gap: 12px; margin-left: auto; }

.demo-badge {
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 1.2px;
    color: var(--accent);
    background: var(--accent-soft);
    border: 1px solid rgba(0, 214, 143, 0.35);
    padding: 4px 10px;
    border-radius: 999px;
}

.account-chip { display: flex; align-items: center; gap: 10px; padding: 4px 10px; border: 1px solid var(--border); border-radius: 999px; background: var(--bg-card); }
.account-avatar { width: 28px; height: 28px; border-radius: 50%; background: var(--accent-soft); color: var(--accent); display: grid; place-items: center; font-weight: 700; font-size: 14px; }
.account-meta { display: flex; flex-direction: column; line-height: 1.15; }
.account-name { font-size: 13px; font-weight: 600; }
.account-email { font-size: 11px; color: var(--text-faint); }

/* ---------- Buttons ---------- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 18px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--bg-card);
    color: var(--text);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.08s ease, box-shadow 0.15s ease, background 0.15s ease, border-color 0.15s ease;
}
.btn:hover { border-color: var(--text-faint); }
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #05261b; }
.btn-primary:hover { background: #00f2a0; border-color: #00f2a0; }
.btn-ghost { background: transparent; }
.btn-lg { padding: 14px 26px; font-size: 15px; border-radius: 10px; }
.btn-block { width: 100%; }
.btn-up { background: var(--up); border-color: var(--up); color: #05261b; }
.btn-down { background: var(--down); border-color: var(--down); color: #2b0508; }

/* ---------- Hero ---------- */
.hero { padding: 88px 24px 60px; text-align: center; }
.hero-inner { max-width: 760px; margin: 0 auto; }
.hero-tag {
    display: inline-block;
    font-size: 13px;
    color: var(--accent);
    background: var(--accent-soft);
    border: 1px solid rgba(0, 214, 143, 0.3);
    padding: 6px 14px;
    border-radius: 999px;
    margin-bottom: 24px;
}
.hero h1 { font-size: 46px; line-height: 1.12; letter-spacing: -0.5px; font-weight: 800; }
.accent { color: var(--accent); }
.hero-sub { margin: 20px auto 0; max-width: 560px; color: var(--text-dim); font-size: 17px; }
.hero-actions { display: flex; justify-content: center; gap: 14px; margin-top: 32px; flex-wrap: wrap; }
.hero-stats { display: flex; justify-content: center; gap: 48px; margin-top: 56px; flex-wrap: wrap; }
.stat { display: flex; flex-direction: column; gap: 4px; }
.stat-num { font-size: 26px; color: var(--text); }
.stat span { font-size: 13px; color: var(--text-faint); }

/* ---------- Ticker ---------- */
.ticker {
    display: flex;
    align-items: center;
    gap: 16px;
    justify-content: center;
    padding: 14px 24px;
    background: var(--bg-soft);
    border-top: 1px solid var(--border-soft);
    border-bottom: 1px solid var(--border-soft);
    font-size: 15px;
}
.ticker-label { font-weight: 700; color: var(--text-dim); }
.ticker-price { font-weight: 700; font-size: 18px; font-variant-numeric: tabular-nums; }
.ticker-change { font-weight: 600; }
.ticker-change.up { color: var(--up); }
.ticker-change.down { color: var(--down); }

.feed-badge {
    font-size: 10px;
    font-weight: 800;
    letter-spacing: 1.5px;
    padding: 3px 8px;
    border-radius: 999px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    color: var(--text-faint);
}
.feed-badge.live {
    color: var(--accent);
    border-color: var(--accent);
    background: var(--accent-soft);
    display: inline-flex;
    align-items: center;
    gap: 6px;
}
.feed-badge.live::before {
    content: '';
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--accent);
    animation: pulse 1.6s ease infinite;
}
@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.25; }
}

/* ---------- Sections ---------- */
.section { max-width: 1200px; margin: 0 auto; padding: 72px 24px; }
.section-title { font-size: 28px; font-weight: 800; letter-spacing: -0.3px; margin-bottom: 32px; }
.features { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 20px; }
.feature {
    background: var(--bg-card);
    border: 1px solid var(--border-soft);
    border-radius: var(--radius);
    padding: 26px;
}
.feature:hover { border-color: var(--border); }
.feature-icon { font-size: 30px; }
.feature h3 { margin: 14px 0 8px; font-size: 17px; }
.feature p { color: var(--text-dim); font-size: 14px; }

/* ---------- Learn ---------- */
.learn-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 20px; }
.learn-card { background: var(--bg-card); border: 1px solid var(--border-soft); border-radius: var(--radius); padding: 24px; }
.learn-card h3 { font-size: 17px; margin-bottom: 8px; }
.learn-card p { color: var(--text-dim); font-size: 14px; }

/* ---------- Trade layout ---------- */
.trade-layout {
    display: grid;
    grid-template-columns: 1fr 320px;
    gap: 20px;
    max-width: 1280px;
    margin: 0 auto;
    padding: 24px;
}
.trade-main { display: flex; flex-direction: column; gap: 20px; min-width: 0; }

.card, .chart-card, .positions-card, .history-card, .order-card, .mini-card {
    background: var(--bg-card);
    border: 1px solid var(--border-soft);
    border-radius: var(--radius);
    padding: 20px;
}
.chart-card { padding: 20px; }
.chart-head { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 14px; gap: 16px; flex-wrap: wrap; }
.pair { font-size: 12px; letter-spacing: 1px; color: var(--text-faint); font-weight: 700; display: block; }
.price { font-size: 30px; font-weight: 800; font-variant-numeric: tabular-nums; }
.change { font-size: 14px; font-weight: 600; margin-left: 10px; }
.change.up { color: var(--up); }
.change.down { color: var(--down); }
.chart-ranges { display: flex; gap: 6px; }
.range-btn {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-dim);
    font-size: 12px;
    font-weight: 600;
    padding: 6px 12px;
    border-radius: 6px;
    cursor: pointer;
}
.range-btn.active { background: var(--accent-soft); color: var(--accent); border-color: var(--accent); }
#priceChart { width: 100%; height: 360px; display: block; }

.positions-card h3, .history-card h3 { font-size: 15px; font-weight: 700; margin-bottom: 14px; color: var(--text-dim); letter-spacing: 0.4px; }
.balances { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 16px; }
.balance { display: flex; flex-direction: column; gap: 4px; }
.balance-label { font-size: 12px; color: var(--text-faint); font-weight: 600; letter-spacing: 0.6px; }
.balance-value { font-size: 20px; font-weight: 700; font-variant-numeric: tabular-nums; }

.history-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.history-table th { text-align: left; color: var(--text-faint); font-weight: 600; font-size: 11px; text-transform: uppercase; letter-spacing: 0.6px; padding: 8px 10px; border-bottom: 1px solid var(--border-soft); }
.history-table td { padding: 9px 10px; border-bottom: 1px solid var(--border-soft); font-variant-numeric: tabular-nums; }
.history-table tr:last-child td { border-bottom: none; }
.tag-buy { color: var(--up); font-weight: 700; }
.tag-sell { color: var(--down); font-weight: 700; }
.history-empty { color: var(--text-faint); text-align: center; padding: 24px; font-size: 13px; }

/* ---------- Order ticket ---------- */
.trade-side { display: flex; flex-direction: column; gap: 20px; }
.order-tabs { display: flex; gap: 8px; margin-bottom: 18px; }
.order-tab {
    flex: 1;
    padding: 10px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: transparent;
    color: var(--text-dim);
    font-weight: 700;
    font-size: 14px;
    cursor: pointer;
}
.order-tab.active { background: var(--up); border-color: var(--up); color: #05261b; }
.order-tab.sell.active { background: var(--down); border-color: var(--down); color: #2b0508; }

.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field span { font-size: 12px; color: var(--text-faint); font-weight: 600; letter-spacing: 0.4px; }
.field input {
    background: var(--bg-input);
    border: 1px solid var(--border);
    color: var(--text);
    border-radius: var(--radius-sm);
    padding: 12px 14px;
    font-size: 15px;
    outline: none;
    transition: border-color 0.15s ease;
}
.field input:focus { border-color: var(--accent); }

.order-preview { display: flex; justify-content: space-between; font-size: 13px; color: var(--text-dim); margin-bottom: 14px; }
.order-preview b { color: var(--text); font-variant-numeric: tabular-nums; }
.order-note { margin-top: 10px; text-align: center; font-size: 12px; color: var(--text-faint); }

.mini-card h4 { font-size: 13px; color: var(--text-dim); margin-bottom: 10px; letter-spacing: 0.5px; }
.mini-row { display: flex; justify-content: space-between; font-size: 13px; padding: 6px 0; color: var(--text-dim); }
.mini-row b { color: var(--text); font-variant-numeric: tabular-nums; }

/* ---------- Auth ---------- */
.auth-wrap { min-height: 60vh; display: flex; align-items: center; justify-content: center; padding: 48px 24px; }
.auth-card {
    width: 100%;
    max-width: 420px;
    background: var(--bg-card);
    border: 1px solid var(--border-soft);
    border-radius: var(--radius);
    padding: 34px;
    box-shadow: var(--shadow);
}
.auth-card h2 { font-size: 22px; font-weight: 800; margin: 12px 0 6px; }
.auth-sub { color: var(--text-dim); font-size: 14px; margin-bottom: 22px; }
.auth-error { color: var(--down); font-size: 13px; margin-bottom: 12px; }
.auth-switch { margin-top: 16px; font-size: 13px; text-align: center; }
.auth-switch a { color: var(--accent); }
.auth-switch a:hover { text-decoration: underline; }
.auth-terms { margin-top: 16px; font-size: 11px; color: var(--text-faint); text-align: center; }

/* ---------- Footer ---------- */
.footer { margin-top: auto; border-top: 1px solid var(--border-soft); padding: 28px 24px; }
.footer-inner { max-width: 1200px; margin: 0 auto; display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; font-size: 13px; color: var(--text-dim); }
.footer-note { color: var(--text-faint); font-size: 12px; }

/* ---------- Toast ---------- */
.toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--bg-card);
    border: 1px solid var(--border);
    color: var(--text);
    padding: 12px 22px;
    border-radius: 999px;
    box-shadow: var(--shadow);
    font-size: 14px;
    z-index: 100;
    animation: toast-in 0.2s ease;
}
.toast.error { border-color: var(--down); color: var(--down); }
.toast.success { border-color: var(--accent); color: var(--accent); }
@keyframes toast-in { from { opacity: 0; transform: translateX(-50%) translateY(8px); } to { opacity: 1; transform: translateX(-50%) translateY(0); } }

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
    .trade-layout { grid-template-columns: 1fr; }
    .hero h1 { font-size: 34px; }
    .main-nav { display: none; }
}
@media (max-width: 600px) {
    .hero-stats { gap: 24px; }
    .account-email { display: none; }
}
