:root {
  --bg: #080b10;
  --bg-2: #0c1118;
  --panel: #11161d;
  --panel-2: #161d26;
  --line: #1e2632;
  --line-2: #2a3442;
  --text: #d8dde5;
  --muted: #6d7887;
  --dim: #4a5563;
  --up: #0ecb81;
  --down: #f6465d;
  --accent: #4f8cff;
  --warn: #f0b90b;
  --hl: #50d2c1;
  --radius: 12px;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }
html, body {
  margin: 0; padding: 0;
  background: var(--bg); color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
  font-size: 13px; line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
button, input, select, textarea { font: inherit; }
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #232c39; border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: #31404f; }

/* ================= 登录页 ================= */
.auth-wrap { min-height: 100vh; display: grid; grid-template-columns: 1.1fr 0.9fr; }
@media (max-width: 900px) { .auth-wrap { grid-template-columns: 1fr; } .auth-hero { display: none; } }

.auth-hero {
  position: relative; padding: 64px 56px;
  background:
    radial-gradient(900px 500px at 15% 10%, rgba(80, 210, 193, .13), transparent 60%),
    radial-gradient(700px 500px at 85% 80%, rgba(79, 140, 255, .13), transparent 60%),
    #070a0e;
  border-right: 1px solid var(--line);
  display: flex; flex-direction: column; justify-content: center; overflow: hidden;
}
.auth-hero h1 { font-size: 34px; line-height: 1.25; margin: 0 0 16px; letter-spacing: -.5px; }
.auth-hero h1 span { color: var(--hl); }
.auth-hero p.lead { color: var(--muted); font-size: 14px; max-width: 460px; margin: 0 0 32px; }
.hero-list { display: grid; gap: 14px; max-width: 460px; }
.hero-item { display: flex; gap: 12px; align-items: flex-start; }
.hero-item .ico {
  width: 26px; height: 26px; flex: 0 0 26px; border-radius: 8px;
  background: rgba(80, 210, 193, .12); color: var(--hl);
  display: grid; place-items: center; font-size: 13px; font-weight: 700;
}
.hero-item b { display: block; font-size: 13px; font-weight: 600; }
.hero-item small { color: var(--muted); font-size: 12px; }

.auth-panel { display: flex; align-items: center; justify-content: center; padding: 40px 24px; }
.auth-card { width: 100%; max-width: 380px; }
.auth-card h2 { font-size: 20px; margin: 0 0 6px; }
.auth-card .sub { color: var(--muted); font-size: 12.5px; margin: 0 0 24px; }
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 11.5px; color: var(--muted); margin-bottom: 6px; }
.field input, .field select {
  width: 100%; padding: 10px 12px; border-radius: 9px;
  background: var(--panel-2); border: 1px solid var(--line-2); color: var(--text);
  outline: none; transition: border-color .15s, box-shadow .15s;
}
.field input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(79, 140, 255, .12); }
.btn-block { width: 100%; padding: 11px; border-radius: 9px; font-weight: 600; }
.auth-switch { text-align: center; margin-top: 16px; font-size: 12.5px; color: var(--muted); }
.err { color: var(--down); font-size: 12px; min-height: 18px; margin: 8px 0 0; }
.auth-logo { display: flex; align-items: center; gap: 10px; margin-bottom: 28px; font-weight: 700; letter-spacing: .3px; }
.auth-logo .mark {
  width: 30px; height: 30px; border-radius: 9px;
  background: linear-gradient(135deg, var(--hl), var(--accent));
  display: grid; place-items: center; color: #05100e; font-size: 15px;
}

/* ================= 应用外壳 ================= */
.shell { display: grid; grid-template-columns: 220px 1fr; min-height: 100vh; }
@media (max-width: 1000px) { .shell { grid-template-columns: 64px 1fr; } .nav-label, .nav-group { display: none; } }

.sidebar {
  background: var(--bg-2); border-right: 1px solid var(--line);
  padding: 18px 12px; display: flex; flex-direction: column; gap: 6px;
  position: sticky; top: 0; height: 100vh;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 18px; }
.brand .mark {
  width: 28px; height: 28px; border-radius: 8px; flex: 0 0 28px;
  background: linear-gradient(135deg, var(--hl), var(--accent));
  display: grid; place-items: center; color: #05100e; font-weight: 800; font-size: 14px;
}
.brand b { font-size: 13.5px; }
.brand small { display: block; font-size: 9.5px; color: var(--dim); letter-spacing: 1.2px; }

.nav-group { font-size: 10px; color: var(--dim); letter-spacing: 1px; padding: 14px 10px 6px; text-transform: uppercase; }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 10px; border-radius: 9px; color: var(--muted);
  cursor: pointer; transition: .15s; border: 1px solid transparent; font-size: 12.5px;
}
.nav-item:hover { background: var(--panel); color: var(--text); }
.nav-item.active { background: rgba(79, 140, 255, .1); color: var(--text); border-color: rgba(79, 140, 255, .25); }
.nav-item .n-ico { width: 16px; text-align: center; font-size: 13px; }
.nav-item .badge {
  margin-left: auto; font-family: var(--mono); font-size: 10px;
  background: var(--panel-2); border: 1px solid var(--line-2);
  padding: 0 5px; border-radius: 999px; color: var(--muted);
}
.sidebar-foot { margin-top: auto; padding: 12px 10px 0; border-top: 1px solid var(--line); }
.sidebar-foot .plan-chip {
  display: inline-block; font-size: 10.5px; padding: 2px 8px; border-radius: 999px;
  background: rgba(80, 210, 193, .12); color: var(--hl); border: 1px solid rgba(80, 210, 193, .3);
}
.sidebar-foot .mail { font-size: 10.5px; color: var(--dim); margin-top: 6px; word-break: break-all; }

.main { padding: 20px 24px 60px; max-width: 1500px; }
.topline { display: flex; align-items: center; gap: 14px; margin-bottom: 18px; flex-wrap: wrap; }
.topline h1 { font-size: 17px; margin: 0; font-weight: 650; }
.topline .sub { font-size: 11.5px; color: var(--muted); }
.topline .right { margin-left: auto; display: flex; align-items: center; gap: 8px; }

.dot { width: 7px; height: 7px; border-radius: 50%; background: var(--dim); display: inline-block; }
.dot.on { background: var(--up); box-shadow: 0 0 8px rgba(14, 203, 129, .7); animation: pulse 2s infinite; }
@keyframes pulse { 50% { box-shadow: 0 0 2px rgba(14, 203, 129, .2); } }

.chip {
  font-family: var(--mono); font-size: 10.5px; padding: 3px 9px; border-radius: 999px;
  background: var(--panel-2); border: 1px solid var(--line); color: var(--muted); white-space: nowrap;
}
.chip.ok { color: var(--up); border-color: rgba(14, 203, 129, .3); }
.chip.warn { color: var(--warn); border-color: rgba(240, 185, 11, .3); }
.chip.bad { color: var(--down); border-color: rgba(246, 70, 93, .3); }

.btn {
  padding: 7px 14px; border-radius: 8px; border: 1px solid var(--line-2);
  background: var(--panel-2); color: var(--text); cursor: pointer; transition: .15s; white-space: nowrap;
  font-size: 12px;
}
.btn:hover { background: #1d2632; border-color: #3a4757; }
.btn:active { transform: translateY(1px); }
.btn.primary { background: linear-gradient(180deg, #2f6bdd, #2456b8); border-color: #3a78ee; color: #fff; }
.btn.primary:hover { filter: brightness(1.1); }
.btn.danger { background: linear-gradient(180deg, #b8374c, #93293b); border-color: #d94a62; color: #fff; }
.btn.ghost { background: transparent; }
.btn.sm { padding: 4px 10px; font-size: 11px; border-radius: 6px; }
.btn:disabled { opacity: .45; cursor: not-allowed; }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(148px, 1fr)); gap: 10px; margin-bottom: 16px; }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; }
.stat .k { font-size: 11px; color: var(--muted); margin-bottom: 3px; }
.stat .v { font-family: var(--mono); font-size: 19px; font-weight: 600; letter-spacing: -.4px; }
.stat .v small { font-size: 10.5px; font-weight: 400; color: var(--muted); margin-left: 3px; }
.up { color: var(--up); } .down { color: var(--down); }

.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; margin-bottom: 16px; }
.panel-head {
  display: flex; align-items: center; gap: 12px; padding: 11px 14px;
  border-bottom: 1px solid var(--line); background: linear-gradient(180deg, #131a23, #11161d);
  flex-wrap: wrap;
}
.panel-head h2 { margin: 0; font-size: 12.5px; font-weight: 600; letter-spacing: .3px; display: flex; align-items: baseline; gap: 7px; }
.panel-head small { color: var(--muted); font-weight: 400; font-size: 11px; font-family: var(--mono); }
.panel-head .tools { margin-left: auto; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.hint { font-size: 11px; color: var(--muted); }

.filters { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; font-size: 11px; color: var(--muted); }
.filters label { display: flex; align-items: center; gap: 5px; }
.filters b { font-family: var(--mono); color: var(--text); font-weight: 500; min-width: 32px; }
.filters input[type=range] { width: 70px; accent-color: var(--accent); }
.filters select, .filters input.num, .filters input.text {
  background: var(--panel-2); color: var(--text); border: 1px solid var(--line-2);
  border-radius: 6px; padding: 3px 7px; outline: none; font-size: 11px;
}
.filters input.num { width: 58px; font-family: var(--mono); }
.filters input.text { width: 110px; }

.table-wrap { overflow: auto; max-height: 620px; }
.tbl { width: 100%; border-collapse: collapse; font-size: 12px; }
.tbl th {
  position: sticky; top: 0; z-index: 2; background: #131a23; color: var(--muted);
  font-weight: 500; font-size: 10.5px; text-align: left; padding: 8px 10px;
  border-bottom: 1px solid var(--line); white-space: nowrap;
}
.tbl td { padding: 8px 10px; border-bottom: 1px solid rgba(30, 38, 50, .6); white-space: nowrap; vertical-align: middle; }
.tbl tbody tr:hover { background: rgba(79, 140, 255, .05); }
.tbl tbody tr.watched { background: rgba(79, 140, 255, .07); }
.r { text-align: right; font-family: var(--mono); }
.c { text-align: center; }

.ex-badge {
  display: inline-block; font-size: 9.5px; font-family: var(--mono); padding: 2px 6px;
  border-radius: 4px; border: 1px solid var(--line-2); color: var(--muted); letter-spacing: .3px;
}
.ex-hyperliquid { color: var(--hl); border-color: rgba(80, 210, 193, .35); background: rgba(80, 210, 193, .08); }
.ex-okx { color: #9db8ff; border-color: #2b3f66; background: #16203a; }
.ex-binance { color: #f0c60b; border-color: #4a3f12; background: #241f08; }
.ex-gate { color: #6ee7d5; border-color: #1b4a44; background: #0c2523; }

.nick { font-weight: 500; }
.nick small { display: block; color: var(--dim); font-size: 9.5px; font-family: var(--mono); font-weight: 400; }

.tag { display: inline-block; font-size: 9.5px; padding: 1px 6px; border-radius: 4px; margin-right: 3px;
  background: #1a212b; color: #8b97a8; border: 1px solid #232c39; }
.tag.good { color: var(--up); border-color: rgba(14, 203, 129, .28); background: rgba(14, 203, 129, .08); }
.tag.bad { color: var(--down); border-color: rgba(246, 70, 93, .28); background: rgba(246, 70, 93, .08); }
.tag.warn { color: var(--warn); border-color: rgba(240, 185, 11, .3); background: rgba(240, 185, 11, .08); }

.score-bar { display: inline-flex; align-items: center; gap: 6px; font-family: var(--mono); }
.score-bar .bar { width: 32px; height: 4px; border-radius: 2px; background: #1e2632; overflow: hidden; }
.score-bar .bar i { display: block; height: 100%; background: var(--accent); }

.switch { position: relative; display: inline-block; width: 36px; height: 19px; vertical-align: middle; }
.switch input { display: none; }
.switch .slider { position: absolute; inset: 0; background: #222b38; border-radius: 999px; cursor: pointer;
  transition: .2s; border: 1px solid var(--line-2); }
.switch .slider::before { content: ""; position: absolute; width: 13px; height: 13px; left: 2px; top: 2px;
  background: #74808f; border-radius: 50%; transition: .2s; }
.switch input:checked + .slider { background: rgba(14, 203, 129, .22); border-color: var(--up); }
.switch input:checked + .slider::before { transform: translateX(17px); background: var(--up); }

.pos-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 10px; padding: 14px; }
.pos-card { background: var(--panel-2); border: 1px solid var(--line-2); border-radius: 10px; padding: 12px; }
.pos-card .top { display: flex; align-items: center; gap: 7px; margin-bottom: 6px; }
.pos-card .sym { font-family: var(--mono); font-weight: 600; font-size: 13px; }
.side-badge { font-size: 9.5px; padding: 1px 5px; border-radius: 3px; font-weight: 700; letter-spacing: .3px; }
.side-long { background: rgba(14, 203, 129, .15); color: var(--up); }
.side-short { background: rgba(246, 70, 93, .15); color: var(--down); }
.pos-card .row { display: flex; justify-content: space-between; font-size: 10.5px; color: var(--muted);
  font-family: var(--mono); margin-top: 3px; }
.pos-card .pnl { font-family: var(--mono); font-size: 15px; font-weight: 600; margin-top: 8px; }
.pos-card .foot { display: flex; justify-content: space-between; align-items: center; margin-top: 8px; }

.signal-list { max-height: 420px; overflow-y: auto; }
.signal-item { padding: 8px 14px; border-bottom: 1px solid rgba(30, 38, 50, .5);
  display: flex; gap: 8px; align-items: flex-start; font-size: 11.5px; animation: slideIn .3s; }
@keyframes slideIn { from { opacity: 0; transform: translateY(-5px); } }
.sig-icon { font-family: var(--mono); font-size: 9.5px; font-weight: 700; padding: 1px 5px;
  border-radius: 3px; margin-top: 1px; flex-shrink: 0; }
.sig-open .sig-icon { background: rgba(14, 203, 129, .16); color: var(--up); }
.sig-close .sig-icon { background: rgba(246, 70, 93, .16); color: var(--down); }
.sig-increase .sig-icon { background: rgba(79, 140, 255, .16); color: var(--accent); }
.sig-body { flex: 1; min-width: 0; }
.sig-title { display: flex; gap: 6px; align-items: baseline; }
.sig-sym { font-family: var(--mono); font-weight: 600; }
.sig-trader { color: var(--dim); font-size: 10px; }
.sig-note { color: var(--muted); font-size: 10px; font-family: var(--mono); }
.sig-status { font-size: 9.5px; padding: 1px 5px; border-radius: 3px; flex-shrink: 0; margin-top: 2px; }
.st-executed { background: rgba(14, 203, 129, .14); color: var(--up); }
.st-new { background: rgba(79, 140, 255, .14); color: var(--accent); }
.st-skipped { background: #1b222c; color: var(--muted); }
.st-rejected { background: rgba(240, 185, 11, .14); color: var(--warn); }
.st-error { background: rgba(246, 70, 93, .14); color: var(--down); }

.empty { padding: 26px 14px; text-align: center; color: var(--muted); font-size: 12px; }

.settings-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px; padding: 16px; }
.sfield { display: flex; flex-direction: column; gap: 5px; }
.sfield label { font-size: 11px; color: var(--muted); }
.sfield input, .sfield select {
  background: var(--panel-2); color: var(--text); border: 1px solid var(--line-2);
  border-radius: 7px; padding: 7px 10px; outline: none; font-family: var(--mono); font-size: 12px;
}
.sfield input:focus, .sfield select:focus { border-color: var(--accent); }
.sfield input[type=text] { font-family: inherit; }
.row2 { display: grid; grid-template-columns: 1fr 70px; gap: 6px; }
.main-switch { grid-column: span 2; flex-direction: row; align-items: center; gap: 12px;
  background: var(--panel-2); border: 1px solid var(--line-2); border-radius: 9px; padding: 10px 14px; }
.main-switch > span { font-weight: 600; }
.main-switch em { font-style: normal; font-size: 10.5px; color: var(--muted); margin-left: auto; }
.switch-line { display: flex; align-items: center; gap: 7px; font-size: 11.5px; cursor: pointer; }
.switch-line input { accent-color: var(--accent); }

.key-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 12px; padding: 14px; }
.key-card { background: var(--panel-2); border: 1px solid var(--line-2); border-radius: 10px; padding: 14px; }
.key-card .head { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; }
.key-card .head b { font-size: 12.5px; }
.key-card .note { font-size: 10.5px; color: var(--dim); margin-bottom: 12px; min-height: 28px; }
.key-card .state { font-size: 10.5px; font-family: var(--mono); margin-bottom: 10px; }
.key-card input {
  width: 100%; background: #0d1219; color: var(--text); border: 1px solid var(--line-2);
  border-radius: 6px; padding: 6px 9px; margin-bottom: 6px; font-family: var(--mono); font-size: 11px; outline: none;
}
.key-card input:focus { border-color: var(--accent); }
.key-card .actions { display: flex; gap: 6px; margin-top: 8px; }

.plan-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; padding: 14px; }
.plan-card { border: 1px solid var(--line-2); border-radius: 10px; padding: 16px; background: var(--panel-2); }
.plan-card.current { border-color: var(--hl); box-shadow: 0 0 0 1px rgba(80, 210, 193, .25); }
.plan-card .price { font-family: var(--mono); font-size: 24px; font-weight: 600; margin: 6px 0 2px; }
.plan-card .price small { font-size: 11px; color: var(--muted); font-weight: 400; }
.plan-card ul { margin: 12px 0 0; padding-left: 16px; font-size: 11px; color: var(--muted); }
.plan-card li { margin-bottom: 4px; }

.modal-mask {
  position: fixed; inset: 0; background: rgba(4, 7, 11, .75); backdrop-filter: blur(4px);
  display: none; align-items: center; justify-content: center; z-index: 100; padding: 20px;
}
.modal-mask.show { display: flex; }
.modal { background: var(--panel); border: 1px solid var(--line-2); border-radius: 14px;
  width: 100%; max-width: 440px; padding: 20px; }
.modal.wide { max-width: 820px; }
.modal h3 { margin: 0 0 4px; font-size: 15px; }
.modal p.sub { color: var(--muted); font-size: 11.5px; margin: 0 0 16px; }
.modal .actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 18px; }

.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%) translateY(20px);
  background: var(--panel-2); border: 1px solid var(--line-2); border-radius: 10px;
  padding: 10px 18px; font-size: 12px; opacity: 0; transition: .25s; z-index: 200;
  pointer-events: none; max-width: 90vw;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.ok { border-color: rgba(14, 203, 129, .4); }
.toast.err { border-color: rgba(246, 70, 93, .4); }

.tabs { display: flex; gap: 4px; padding: 0 14px; border-bottom: 1px solid var(--line); }
.tab { padding: 9px 12px; font-size: 12px; color: var(--muted); cursor: pointer;
  border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tab:hover { color: var(--text); }
.tab.active { color: var(--text); border-bottom-color: var(--accent); }

.hidden { display: none !important; }

/* 告警横幅：跟单链路出问题时必须在任何页面都能看到 */
.alert-bar {
  position: fixed; top: 0; left: 0; right: 0; z-index: 9999;
  display: flex; align-items: center; gap: 12px;
  padding: 10px 18px; font-size: 12.5px;
  background: #4a1010; color: #ffb4b4;
  border-bottom: 1px solid #7a1c1c;
}
.alert-bar.warn { background: #4a3a10; color: #ffd98a; border-bottom-color: #7a5c1c; }
.alert-bar.hidden { display: none; }
.alert-bar button {
  margin-left: auto; background: transparent; border: 1px solid currentColor;
  color: inherit; border-radius: 6px; padding: 4px 10px; cursor: pointer; font-size: 11.5px;
}
.alert-bar .dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; animation: pulse 1.4s infinite; }
@keyframes pulse { 0%,100% { opacity: 1 } 50% { opacity: .3 } }

/* 成交记录：操作标签 + 开平价对比 */
.act { display:inline-block; padding:1px 7px; border-radius:4px; font-size:11px; line-height:1.6; white-space:nowrap; }
.act-open  { background:rgba(80,210,193,.14); color:#50d2c1; }
.act-add   { background:rgba(122,162,255,.14); color:#7aa2ff; }
.act-close { background:rgba(160,160,170,.16); color:#a8a8b2; }
.act-tp    { background:rgba(46,204,113,.16); color:#2ecc71; }
.act-sl    { background:rgba(231,76,60,.16);  color:#e74c3c; }

.px-pair {
  display:flex; justify-content:flex-end; align-items:center; gap:6px;
  font-family:var(--mono); font-size:11.5px; width:100%;
  font-variant-numeric: tabular-nums;
}
.px-pair .px-in  { color:var(--muted); }
.px-pair .arrow  { color:var(--dim); font-size:10px; }
.px-pair .px-out { color:var(--text); font-weight:600; }

/* 成交记录：所有数值列严格右对齐 + 等宽数字，保证上下行完全对齐 */
#tbody-orders td { vertical-align: middle; }
#tbody-orders td.r {
  text-align: right;
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
}
#tbody-orders th.r { text-align: right; }
#tbody-orders td:nth-child(1) { white-space: nowrap; }   /* 时间 */
#tbody-orders td:nth-child(3) { white-space: nowrap; }   /* 交易对 */
#tbody-orders td:nth-child(4) { white-space: nowrap; }   /* 操作标签 */

/* 固定列宽，避免内容长短把后面的列推歪 */
#orders-table { table-layout: fixed; width: 100%; }
#orders-table col.c-time { width: 130px; }
#orders-table col.c-ex   { width: 82px; }
#orders-table col.c-sym  { width: 118px; }
#orders-table col.c-act  { width: 108px; }
#orders-table col.c-qty  { width: 128px; }
#orders-table col.c-px   { width: 200px; }
#orders-table col.c-pnl  { width: 108px; }
#orders-table col.c-mode { width: 68px; }

/* 杠杆徽标：跟单倍数是关键信息，必须一眼看到 */
.lev-badge {
  display:inline-block; padding:1px 6px; border-radius:4px;
  font-family:var(--mono); font-size:11px; font-weight:600;
  background:rgba(122,162,255,.16); color:#7aa2ff;
}
#orders-table col.c-lev { width: 64px; }
.side-badge { font-weight:600; }
