:root {
    --bg: #0b0e11;
    --bg-2: #12161c;
    --bg-3: #1a1f27;
    --line: #232a33;
    --text: #eaecef;
    --text-dim: #848e9c;
    --brand: #00e0c6;
    --brand-2: #00b8ff;
    --up: #2ebd85;
    --down: #f6465d;
    --radius: 12px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
    background: var(--bg);
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    font-size: 14px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
.up { color: var(--up); }
.down { color: var(--down); }
.mono { font-variant-numeric: tabular-nums; font-feature-settings: "tnum"; }
.container { max-width: 1240px; margin: 0 auto; padding: 0 20px; }

/* Header */
.nav {
    position: sticky; top: 0; z-index: 50;
    background: rgba(11,14,17,.9);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--line);
}
.nav-inner { display: flex; align-items: center; gap: 28px; height: 60px; }
.logo { font-size: 22px; font-weight: 800; letter-spacing: -.5px; display: inline-flex; align-items: center; }
.logo-word { font-size: 21px; font-weight: 800; letter-spacing: -.5px; color: var(--text); }
.logo-word span { background: linear-gradient(90deg, var(--brand), var(--brand-2)); -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; }
.nav-links { display: flex; gap: 24px; margin-left: 8px; }
.nav-links a { color: var(--text-dim); font-weight: 500; transition: color .15s; }
.nav-links a:hover, .nav-links a.active { color: var(--text); }
.nav-right { margin-left: auto; display: flex; align-items: center; gap: 14px; }

.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    padding: 9px 18px; border-radius: 10px; font-weight: 600; cursor: pointer;
    border: none; font-size: 14px; transition: filter .15s, background .15s; white-space: nowrap;
}
.btn-ghost { background: transparent; color: var(--text); }
.btn-ghost:hover { color: var(--brand); }
.btn-primary { background: linear-gradient(90deg, var(--brand), var(--brand-2)); color: #04211f; }
.btn-primary:hover { filter: brightness(1.08); }
.btn-up { background: var(--up); color: #fff; width: 100%; padding: 12px; }
.btn-down { background: var(--down); color: #fff; width: 100%; padding: 12px; }
.btn-block { width: 100%; }

/* Hero */
.hero { padding: 72px 0 40px; }
.hero h1 { font-size: 52px; line-height: 1.1; margin: 0 0 18px; font-weight: 800; letter-spacing: -1.5px; }
.hero h1 .grad { background: linear-gradient(90deg, var(--brand), var(--brand-2)); -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; }
.hero p { font-size: 18px; color: var(--text-dim); max-width: 520px; margin: 0 0 28px; }
.hero-cta { display: flex; gap: 14px; }
.hero-grid { display: grid; grid-template-columns: 1.1fr .9fr; gap: 40px; align-items: center; }

/* Cards / tables */
.card { background: var(--bg-2); border: 1px solid var(--line); border-radius: var(--radius); }
.section-title { font-size: 24px; font-weight: 700; margin: 48px 0 20px; }

.ticker-cards { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }
.tcard { padding: 16px; }
.tcard .pair { display: flex; align-items: center; gap: 8px; color: var(--text-dim); font-weight: 600; }
.tcard .price { font-size: 22px; font-weight: 700; margin: 8px 0 2px; }

table.mkt { width: 100%; border-collapse: collapse; }
table.mkt th { text-align: left; color: var(--text-dim); font-weight: 500; font-size: 13px; padding: 14px 16px; border-bottom: 1px solid var(--line); }
table.mkt td { padding: 14px 16px; border-bottom: 1px solid var(--line); }
table.mkt tbody tr { transition: background .12s; }
table.mkt tbody tr:hover { background: var(--bg-3); cursor: pointer; }
table.mkt th.r, table.mkt td.r { text-align: right; }
.coin { display: flex; align-items: center; gap: 10px; }
.coin .sym { position: relative; width: 30px; height: 30px; border-radius: 50%; background: var(--bg-3); display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 700; color: var(--brand); overflow: hidden; flex-shrink: 0; }
.coin b { font-weight: 600; }
.coin small { color: var(--text-dim); }
.pill { padding: 4px 10px; border-radius: 8px; font-weight: 600; font-size: 13px; }
.pill.up { background: rgba(46,189,133,.12); }
.pill.down { background: rgba(246,70,93,.12); }

/* Trade layout */
.trade-wrap { display: grid; grid-template-columns: 1fr 250px 300px; gap: 14px; margin: 16px 0; }
.trade-wrap.no-book { grid-template-columns: 1fr 320px; }

/* Order book */
.book-panel { padding: 0; display: flex; flex-direction: column; overflow: hidden; }
.book-tabs { display: flex; border-bottom: 1px solid var(--line); }
.book-tabs button { flex: 1; padding: 10px; background: none; border: none; color: var(--text-dim); font-weight: 600; cursor: pointer; font-size: 13px; }
.book-tabs button.active { color: var(--text); box-shadow: inset 0 -2px 0 var(--brand); }
.book-head { display: flex; justify-content: space-between; padding: 8px 12px; color: var(--text-dim); font-size: 11px; }
.book-side { display: flex; flex-direction: column; }
.book-row { position: relative; display: flex; justify-content: space-between; padding: 2px 12px; font-size: 12px; font-variant-numeric: tabular-nums; cursor: pointer; }
.book-row:hover { background: var(--bg-3); }
.book-row .bar { position: absolute; top: 0; bottom: 0; right: 0; opacity: .14; }
.book-row .px { position: relative; z-index: 1; }
.book-row .sz { position: relative; z-index: 1; color: var(--text-dim); }
.book-row.ask .px { color: var(--down); }
.book-row.ask .bar { background: var(--down); }
.book-row.bid .px { color: var(--up); }
.book-row.bid .bar { background: var(--up); }
.book-mid { padding: 8px 12px; border-block: 1px solid var(--line); font-size: 16px; font-weight: 700; display: flex; align-items: center; gap: 8px; }
.book-mid small { color: var(--text-dim); font-size: 11px; font-weight: 400; }
.trades-list { overflow-y: auto; }
.trade-row { display: flex; justify-content: space-between; padding: 3px 12px; font-size: 12px; font-variant-numeric: tabular-nums; }
.trade-row .t { color: var(--text-dim); }
.trade-head { display: flex; align-items: center; gap: 24px; padding: 16px 20px; }
.trade-head .big { font-size: 24px; font-weight: 700; }
.chart-box { height: 460px; padding: 8px; }
.stat { display: flex; flex-direction: column; }
.stat small { color: var(--text-dim); font-size: 12px; }
.order-panel { padding: 18px; }
.tabs { display: flex; gap: 4px; background: var(--bg-3); border-radius: 10px; padding: 4px; margin-bottom: 16px; }
.tabs button { flex: 1; padding: 8px; border: none; background: transparent; color: var(--text-dim); border-radius: 7px; cursor: pointer; font-weight: 600; }
.tabs button.active { background: var(--bg); color: var(--text); }
.field { margin-bottom: 12px; }
.field label { display: block; color: var(--text-dim); font-size: 12px; margin-bottom: 6px; }
.field input { width: 100%; background: var(--bg-3); border: 1px solid var(--line); border-radius: 8px; color: var(--text); padding: 11px 12px; font-size: 14px; }
.field input:focus { outline: none; border-color: var(--brand); }
.seg { display: flex; gap: 8px; margin-bottom: 14px; }
.seg button { flex: 1; padding: 9px; border-radius: 8px; border: 1px solid var(--line); background: transparent; color: var(--text-dim); cursor: pointer; font-weight: 600; }
.seg button.buy.active { background: rgba(46,189,133,.15); color: var(--up); border-color: var(--up); }
.seg button.sell.active { background: rgba(246,70,93,.15); color: var(--down); border-color: var(--down); }
.bal-line { display: flex; justify-content: space-between; color: var(--text-dim); font-size: 13px; margin-bottom: 14px; }

/* Auth */
.auth-wrap { min-height: calc(100vh - 60px); display: flex; align-items: center; justify-content: center; padding: 40px 20px; }
.auth-card { width: 100%; max-width: 420px; padding: 36px; }
.auth-card h2 { margin: 0 0 6px; font-size: 26px; }
.auth-card .sub { color: var(--text-dim); margin-bottom: 26px; }
.auth-card .field input { padding: 13px; }
.alert { background: rgba(246,70,93,.12); color: var(--down); padding: 11px 14px; border-radius: 8px; margin-bottom: 16px; font-size: 13px; }
.auth-foot { text-align: center; color: var(--text-dim); margin-top: 20px; }
.auth-foot a { color: var(--brand); font-weight: 600; }
.bonus-note { background: rgba(0,224,198,.08); border: 1px solid rgba(0,224,198,.2); color: var(--brand); padding: 12px 14px; border-radius: 8px; font-size: 13px; margin-bottom: 20px; }

/* Assets */
.asset-hero { padding: 28px; margin: 20px 0; display: flex; align-items: flex-end; gap: 40px; }
.asset-hero .total { font-size: 34px; font-weight: 800; }
.asset-hero small { color: var(--text-dim); }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }

/* Footer */
.footer { border-top: 1px solid var(--line); margin-top: 64px; padding: 32px 0; color: var(--text-dim); font-size: 13px; }
.footer .disc { margin-top: 8px; opacity: .8; }

/* Mobile bottom navigation (Bitget-style) */
.mnav { display: none; }
.mnav {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 60;
    background: rgba(11,14,17,.96); backdrop-filter: blur(12px);
    border-top: 1px solid var(--line);
    padding: 6px 0 calc(6px + env(safe-area-inset-bottom));
}
.mnav-inner { display: flex; }
.mnav a { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 6px 0; color: var(--text-dim); font-size: 10px; font-weight: 600; }
.mnav a.active { color: var(--brand); }
.mnav a svg { width: 22px; height: 22px; }

@media (max-width: 1024px) {
    .trader-grid { grid-template-columns: repeat(2, 1fr) !important; }
}

@media (max-width: 900px) {
    .container { padding: 0 14px; }
    .hero { padding: 40px 0 24px; }
    .hero-grid { grid-template-columns: 1fr; gap: 24px; }
    .hero h1 { font-size: 34px; letter-spacing: -1px; }
    .hero p { font-size: 16px; }
    .hero-cta { flex-direction: column; }
    .hero-cta .btn { width: 100%; }
    .ticker-cards { grid-template-columns: repeat(2, 1fr); }
    .trade-wrap, .trade-wrap.no-book { grid-template-columns: 1fr; }
    .nav-links { display: none; }
    .grid-2 { grid-template-columns: 1fr; }
    .section-title { font-size: 20px; margin: 32px 0 16px; }

    /* show mobile bottom nav, pad body so content clears it */
    body { padding-bottom: 68px; }
    .mnav { display: block; }
    .footer { margin-bottom: 60px; }

    /* horizontal-scroll any table-bearing card so columns never break layout */
    .card:has(table.mkt) { overflow-x: auto; -webkit-overflow-scrolling: touch; }
    table.mkt { min-width: 560px; }
    table.mkt th, table.mkt td { padding: 12px 12px; }

    /* trade header: let stats scroll instead of overflowing */
    .trade-head { gap: 16px; overflow-x: auto; -webkit-overflow-scrolling: touch; padding: 14px; white-space: nowrap; }
    .trade-head .stat { flex-shrink: 0; }
    .trade-head .big { font-size: 20px; }
    .chart-box { height: 320px; }
    .order-panel { padding: 16px; }

    /* assets summary stacks */
    .asset-hero { flex-direction: column; align-items: flex-start; gap: 18px; padding: 20px; }
    .asset-hero .total { font-size: 28px; }

    .trader-grid { grid-template-columns: 1fr !important; }

    .auth-card { padding: 26px 20px; }
    .nav-inner { gap: 12px; }
    .nav-right { gap: 8px; }
    .nav-right .btn { padding: 8px 13px; font-size: 13px; }
    .logo { font-size: 20px; }
}

@media (max-width: 380px) {
    .ticker-cards { grid-template-columns: 1fr; }
    .hero h1 { font-size: 29px; }
}
