:root {
  --bg: #0b0e11;
  --bg2: #12161c;
  --panel: #171c23;
  --border: #232a33;
  --text: #eaecef;
  --muted: #848e9c;
  --up: #0ecb81;
  --down: #f6465d;
  --primary: #1673ff;
  --gold: #f0b90b;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  font-size: 14px;
}
main { min-height: calc(100vh - 52px); padding-bottom: 40px; }
main.with-nav { padding-top: 12px; }
a { color: var(--primary); text-decoration: none; }

/* ---- 顶部导航 ---- */
.top-nav {
  display: flex; align-items: center; gap: 24px;
  height: 52px; padding: 0 20px;
  background: var(--bg2); border-bottom: 1px solid var(--border);
}
.brand { color: var(--text); font-weight: 700; font-size: 15px; white-space: nowrap; }
.brand-badge {
  display: inline-block; background: var(--gold); color: #000;
  border-radius: 4px; padding: 1px 7px; margin-right: 8px; font-size: 13px;
}
.nav-links { display: flex; gap: 18px; flex: 1; }
.nav-links a { color: var(--muted); padding: 6px 10px; border-radius: 6px; }
.nav-links a.active, .nav-links a:hover { color: var(--text); background: rgba(255,255,255,.05); }
.nav-right { display: flex; align-items: center; gap: 12px; }
.user-chip { color: var(--muted); font-size: 13px; }
.inline { display: inline; }

/* ---- 登录/注册 ---- */
.auth-wrap { display: flex; justify-content: center; padding-top: 8vh; }
.auth-card {
  width: 400px; max-width: calc(100vw - 32px);
  background: var(--panel); border: 1px solid var(--border);
  border-radius: 12px; padding: 28px;
}
.auth-title { margin: 0 0 4px; font-size: 22px; }
.auth-sub { margin: 0 0 18px; color: var(--muted); font-size: 13px; }
.auth-foot { text-align: center; color: var(--muted); margin-top: 16px; }

.form label { display: block; margin-bottom: 14px; color: var(--muted); font-size: 13px; }
.form input, .form select {
  width: 100%; margin-top: 6px; padding: 9px 12px;
  background: var(--bg2); border: 1px solid var(--border); border-radius: 8px;
  color: var(--text); font-size: 14px; outline: none;
}
.form input:focus { border-color: var(--primary); }
.captcha-row { display: flex; gap: 10px; align-items: center; margin-top: 6px; }
.captcha-row input { flex: 1; margin-top: 0; }
.captcha-img { height: 40px; border-radius: 6px; cursor: pointer; border: 1px solid var(--border); }
.grid-form { max-width: 100%; }
.pair { display: flex; gap: 8px; }
.pair input { width: calc(50% - 4px); }
.form-msg { color: var(--up); font-size: 13px; }

.alert { padding: 10px 12px; border-radius: 8px; margin-bottom: 14px; font-size: 13px; }
.alert.error { background: rgba(246,70,93,.12); color: var(--down); border: 1px solid rgba(246,70,93,.35); }
.alert.info { background: rgba(22,115,255,.12); color: #6ea8ff; border: 1px solid rgba(22,115,255,.35); }

/* ---- 按钮 ---- */
.btn {
  border: none; cursor: pointer; border-radius: 8px;
  padding: 10px 18px; font-size: 14px; color: var(--text);
  background: #262c35; transition: filter .15s ease;
}
.btn:hover { filter: brightness(1.15); }
.btn.primary { background: var(--primary); color: #fff; }
.btn.block { width: 100%; margin-top: 6px; }
.btn.sm { padding: 5px 12px; font-size: 12px; }
.btn.ghost { background: transparent; border: 1px solid var(--border); color: var(--muted); }
.btn.big { width: 100%; font-size: 15px; font-weight: 600; margin-top: 12px; }
.btn.up { background: var(--up); color: #04120b; }
.btn.down { background: var(--down); color: #fff; }
.btn:disabled { opacity: .45; cursor: not-allowed; }

/* ---- 工作台 ---- */
.dash-wrap, .te-wrap { max-width: 1280px; margin: 0 auto; padding: 0 20px; }
.dash-head h1 { font-size: 20px; margin: 8px 0 4px; }
.muted { color: var(--muted); }

.cards-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; margin: 16px 0; }
.cards-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-bottom: 14px; }
.card {
  background: var(--panel); border: 1px solid var(--border);
  border-radius: 12px; padding: 18px;
}
.card.stat .stat-label { color: var(--muted); font-size: 13px; }
.card.stat .stat-value { font-size: 26px; font-weight: 700; margin-top: 6px; }

.panel-grid { display: grid; grid-template-columns: 380px 1fr; gap: 14px; align-items: start; }
.card.wide { min-height: 300px; }
.card h2, .card h3 { font-size: 15px; margin: 0 0 14px; }
.running-strategy-info p { margin: 0 0 8px; line-height: 1.5; }
.running-strategy-info + .btn { margin-top: 6px; }
.run-state-warning { color: var(--down); font-size: 12px; }
.gate-balance-state { margin: 10px 0; font-size: 12px; line-height: 1.5; }
.gate-balance-state.alert { padding: 9px 10px; }
.gate-balance-ok { color: var(--up); }
.order-error { margin-top: 6px; max-width: 300px; color: var(--down); font-size: 12px; line-height: 1.45; white-space: normal; }

.switch-row { display: flex; align-items: center; gap: 8px; color: var(--text) !important; }
.switch-row input { width: auto !important; margin-top: 0 !important; }

/* ---- 表格 ---- */
.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th, .table td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--border); }
.table th { color: var(--muted); font-weight: 500; white-space: nowrap; }
.table.small td, .table.small th { padding: 7px 8px; }
.tag { padding: 2px 8px; border-radius: 4px; font-size: 12px; }
.tag.open { background: rgba(240,185,11,.15); color: var(--gold); }
.tag.won { background: rgba(14,203,129,.15); color: var(--up); }
.tag.lost { background: rgba(246,70,93,.15); color: var(--down); }
.pnl-pos { color: var(--up); } .pnl-neg { color: var(--down); }

/* ---- 事件合约交易页 ---- */
.te-toolbar { display: flex; justify-content: space-between; align-items: center; gap: 14px; margin: 12px 0; flex-wrap: wrap; }
.crypto-tabs { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; }
.crypto-tabs button {
  display: flex; align-items: center; gap: 6px;
  background: var(--panel); border: 1px solid var(--border); color: var(--text);
  border-radius: 999px; padding: 6px 14px; cursor: pointer; white-space: nowrap; font-size: 13px;
}
.crypto-tabs button img { width: 18px; height: 18px; border-radius: 50%; }
.crypto-tabs button.on { border-color: var(--gold); background: rgba(240,185,11,.08); }
.period-tabs { display: flex; gap: 6px; }
.period-tabs button {
  background: transparent; border: 1px solid var(--border); color: var(--muted);
  border-radius: 8px; padding: 6px 14px; cursor: pointer;
}
.period-tabs button.on { color: #000; background: var(--gold); border-color: var(--gold); font-weight: 600; }

.te-layout { display: grid; grid-template-columns: 320px 1fr; gap: 14px; align-items: start; }
.te-list ul { list-style: none; margin: 0; padding: 0; max-height: 72vh; overflow-y: auto; }
.te-list li {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 8px; border-radius: 8px; cursor: pointer;
}
.te-list li:hover { background: rgba(255,255,255,.04); }
.te-list li.on { background: rgba(240,185,11,.09); }
.te-list li img { width: 26px; height: 26px; border-radius: 50%; }
.ev-meta { flex: 1; min-width: 0; }
.ev-name { font-size: 13px; }
.ev-time { color: var(--muted); font-size: 12px; }
.ev-probs { text-align: right; font-size: 13px; white-space: nowrap; }
.p-up { color: var(--up); } .p-down { color: var(--down); }

.outcome { text-align: center; padding: 20px; }
.outcome-head { color: var(--muted); font-size: 13px; }
.outcome-price { font-size: 30px; font-weight: 800; margin: 6px 0 2px; }
.outcome.up .outcome-price { color: var(--up); }
.outcome.down .outcome-price { color: var(--down); }

.kline-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.kline-svg { width: 100%; height: 320px; display: block; margin-top: 10px; }
.kline-svg rect.body-up { fill: var(--up); }
.kline-svg rect.body-down { fill: var(--down); }
.kline-svg line.wick-up { stroke: var(--up); }
.kline-svg line.wick-down { stroke: var(--down); }
.kline-svg line.guide { stroke: #2a323c; stroke-dasharray: 4 4; }
.kline-svg line.level { stroke: var(--gold); stroke-dasharray: 2 3; }
.kline-svg text { fill: var(--muted); font-size: 11px; }

@media (max-width: 960px) {
  .cards-3, .cards-2 { grid-template-columns: 1fr; }
  .panel-grid, .te-layout { grid-template-columns: 1fr; }
}

/* ---- 下单弹层与提示 ---- */
.order-mask {
  display: none; position: fixed; inset: 0; z-index: 100;
  background: rgba(0,0,0,.6); align-items: center; justify-content: center;
}
.order-dialog {
  width: 360px; max-width: calc(100vw - 40px);
  background: var(--panel); border: 1px solid var(--border);
  border-radius: 12px; padding: 22px;
}
.order-dialog h3 { margin: 0 0 8px; font-size: 16px; }
.order-dialog label { display: block; color: var(--muted); font-size: 13px; margin: 14px 0; }
.order-dialog input {
  width: 100%; margin-top: 6px; padding: 9px 12px;
  background: var(--bg2); border: 1px solid var(--border); border-radius: 8px;
  color: var(--text); font-size: 14px; outline: none;
}
.order-actions { display: flex; gap: 10px; justify-content: flex-end; }

.toast {
  position: fixed; top: 68px; left: 50%; transform: translateX(-50%) translateY(-12px);
  background: #262c35; color: var(--text); border: 1px solid var(--border);
  padding: 9px 18px; border-radius: 8px; font-size: 13px;
  opacity: 0; pointer-events: none; transition: all .25s ease; z-index: 120;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---- Gate 绑定卡 ---- */
.qr-wrap { display: flex; justify-content: center; margin: 10px 0; }
.qr-wrap img { width: 220px; height: 220px; background: #fff; border-radius: 8px; padding: 6px; }
.tag.active { background: rgba(14,203,129,.15); color: var(--up); }
.manual-order { margin-top: 14px; }
.manual-order-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
.manual-amount-label { display: grid; gap: 5px; color: var(--muted); font-size: 12px; min-width: 130px; }
.manual-amount-label input { width: 130px; }
.manual-order-actions { display: flex; gap: 10px; margin-top: 12px; }
.manual-order-actions .btn { flex: 1; }
.manual-order-actions .btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.danger { background: rgba(246,70,93,.14); color: #f6465d; border: 1px solid rgba(246,70,93,.35); }
.manual-order-note { margin-top: 10px; font-size: 12px; }
.cookie-input {
  width: 100%; margin-top: 6px; padding: 8px 10px;
  background: var(--bg2); border: 1px solid var(--border); border-radius: 8px;
  color: var(--text); font-size: 12px; font-family: Consolas, monospace;
  resize: vertical; outline: none;
}
.cookie-input:focus { border-color: var(--primary); }

/* ---- 策略广场 ---- */
.strat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: 14px; }
.strat-card { cursor: pointer; position: relative; border-width: 1px; transition: border-color .15s; }
.strat-card:hover { border-color: var(--gold); }
.strat-card.on { border-color: var(--gold); background: rgba(240,185,11,.05); }
.strat-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }
.strat-head h3 { margin: 0; font-size: 16px; }
.strat-meta { display: flex; gap: 10px; align-items: center; margin-bottom: 8px; font-size: 13px; }
.ghost-tag { background: rgba(255,255,255,.06); color: var(--muted); }
.strat-desc { font-size: 13px; line-height: 1.6; margin: 0; }
.strat-picked {
  position: absolute; top: 12px; right: 40px; color: var(--gold);
  font-size: 12px; font-weight: 700;
}
.tag.open { background: rgba(240,185,11,.15); color: var(--gold); }

/* ---- TradingView 信号卡 ---- */
.tv-row { display: block; color: var(--muted); font-size: 13px; margin-bottom: 10px; }
.copy-row { display: flex; gap: 8px; margin-top: 6px; }
.copy-row input {
  flex: 1; min-width: 0; padding: 8px 10px;
  background: var(--bg2); border: 1px solid var(--border); border-radius: 8px;
  color: var(--text); font-size: 12px;
}
.tv-actions { display: flex; gap: 8px; align-items: center; margin-bottom: 10px; }
.tv-help summary { cursor: pointer; }
.tv-pre {
  margin: 10px 0 0; padding: 12px; background: var(--bg2);
  border: 1px solid var(--border); border-radius: 8px;
  font-size: 12px; line-height: 1.7; overflow-x: auto; white-space: pre-wrap;
  color: #c8d0da;
}
