/* 风格参考 参考设计/交易台原型-v3-单币.html：深蓝黑底、圆角卡片、渐变英雄区、绿涨红跌 */
:root {
  color-scheme: dark;
  --bg: #0b0e14;
  --bg2: #0f131c;
  --panel: #131826;
  --panel2: #161c2d;
  --border: #232b3f;
  --border2: #2d3750;
  --text: #e6ebf5;
  --text-2: #8b94ab;
  --muted: #5c657d;
  --grid: #1c2334;
  --axis: #2d3750;
  --green: #16c784;
  --green-dim: rgba(22, 199, 132, .12);
  --red: #ea3943;
  --red-dim: rgba(234, 57, 67, .12);
  --yellow: #f0b90b;
  --yellow-dim: rgba(240, 185, 11, .12);
  --blue: #4f8cff;
  --blue-dim: rgba(79, 140, 255, .10);
  --purple: #a06bff;
  --purple-dim: rgba(160, 107, 255, .12);
  --danger-bg: #3a1420;
  --danger-border: #8c2333;
  /* 图表分类色（已用 dataviz 校验器在 #131826 上通过 CVD/对比度检查） */
  --series-1: #3987e5;
  --series-2: #d95926;
  --series-3: #199e70;
  --series-4: #c98500;
  --series-5: #d55181;
  --series-6: #008300;
  --series-7: #9085e9;
  --series-8: #e66767;
  --font: "PingFang SC", "Helvetica Neue", Helvetica, system-ui, -apple-system, "Microsoft YaHei", sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
* { box-sizing: border-box; }
html { font-size: 15px; }
html, body { margin: 0; background: var(--bg); color: var(--text); font-family: var(--font); }
body { font-variant-numeric: tabular-nums; overflow-x: hidden; }
::selection { background: #2d3750; }
::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-thumb { background: #2a3248; border-radius: 5px; }
::-webkit-scrollbar-track { background: transparent; }
.hidden { display: none !important; }
a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }
code { font-family: var(--mono); font-size: .85em; background: var(--panel2); padding: 1px 6px; border-radius: 4px; }
h1 { font-size: 17px; margin: 0; font-weight: 700; }
h2 { font-size: 14px; margin: 26px 0 12px; font-weight: 700; letter-spacing: 1px; display: flex; align-items: center; gap: 10px; }
h2 .hint { font-size: 11px; font-weight: 400; color: var(--muted); letter-spacing: 0; }
h3 { font-size: 12.5px; margin: 0 0 12px; color: var(--text-2); font-weight: 600; display: flex; align-items: center; gap: 8px; }
.muted { color: var(--text-2); }
.dim { color: var(--muted); }
.err { color: var(--red); min-height: 1.2em; font-size: 12px; }
.num { font-variant-numeric: tabular-nums; text-align: right; }
.up { color: var(--green); }
.down { color: var(--red); }
:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }

/* ===== 布局骨架 ===== */
.app { display: flex; min-height: 100vh; }
.sidebar {
  width: 228px; min-width: 228px; background: var(--bg2); border-right: 1px solid var(--border);
  position: fixed; top: 0; bottom: 0; left: 0; z-index: 50; display: flex; flex-direction: column; overflow-y: auto;
}
.main-wrap { margin-left: 228px; flex: 1; min-width: 0; }
.main { padding: 24px 28px 60px; max-width: 1560px; }
.main:focus { outline: none; }

/* ===== 侧边栏 ===== */
.logo { padding: 20px 18px 16px; border-bottom: 1px solid var(--border); }
.logo .lg-name { font-size: 16px; font-weight: 700; letter-spacing: .5px; }
.logo .lg-name .dot { color: var(--green); }
.logo .lg-sub { font-size: 11px; color: var(--muted); margin-top: 4px; letter-spacing: 1px; }
.nav { padding: 10px 10px; flex: 1; }
.nav-sec { font-size: 11px; color: var(--muted); padding: 8px 10px 4px; letter-spacing: 2px; }
.nav a {
  display: flex; align-items: center; gap: 10px; padding: 8px 12px; border-radius: 8px;
  color: var(--text-2); font-size: 13.5px; margin-bottom: 2px; transition: all .15s; border: 1px solid transparent;
}
.nav a:hover { background: var(--panel); color: var(--text); text-decoration: none; }
.nav a.active { background: var(--panel2); color: var(--text); border-color: var(--border2); font-weight: 600; }
.nav a .ico { width: 18px; text-align: center; font-size: 15px; flex-shrink: 0; }
.nav a .bdg { margin-left: auto; font-size: 10.5px; padding: 1px 7px; border-radius: 9px; background: var(--red-dim); color: var(--red); font-weight: 600; }
.nav a .bdg.warn { background: var(--yellow-dim); color: var(--yellow); }
.side-actions { padding: 10px 12px; display: grid; gap: 8px; }
.side-foot { padding: 12px 16px; border-top: 1px solid var(--border); font-size: 11px; color: var(--muted); line-height: 1.8; }
.side-foot .ok { color: var(--green); }
.side-foot .bad { color: var(--red); }

/* ===== 顶栏 ===== */
.topbar {
  display: flex; align-items: center; gap: 14px; padding: 14px 28px; border-bottom: 1px solid var(--border);
  background: rgba(15, 19, 28, .85); backdrop-filter: blur(6px); position: sticky; top: 0; z-index: 40; min-height: 53px;
}
.crumb { font-size: 12px; color: var(--muted); }
.crumb b { color: var(--text-2); font-weight: 500; }
.spacer { flex: 1; }
.env-tag { font-size: 12px; padding: 3px 12px; border-radius: 6px; font-weight: 600; letter-spacing: 1px; border: 1px solid; }
.env-tag.demo { color: var(--yellow); background: var(--yellow-dim); border-color: rgba(240, 185, 11, .35); }
.env-tag.live { color: var(--red); background: var(--red-dim); border-color: rgba(234, 57, 67, .35); }
.env-tag.paper { color: var(--blue); background: var(--blue-dim); border-color: rgba(79, 140, 255, .35); }
.clock { font-size: 12px; color: var(--text-2); }
.clock b { color: var(--green); font-weight: 600; }

/* ===== 行情横幅 ===== */
.symbol-banner {
  display: flex; align-items: center; gap: 28px; padding: 12px 28px; overflow-x: auto;
  background: linear-gradient(135deg, #12202a 0%, #0f1a2b 55%, #131022 100%);
  border-bottom: 1px solid var(--border2); position: sticky; top: 53px; z-index: 35;
}
.symbol-banner:empty { display: none; }
.sym { display: flex; align-items: baseline; gap: 10px; white-space: nowrap; }
.sym-pair { font-size: 15px; font-weight: 800; letter-spacing: .5px; }
.sym-pair .quote { color: var(--muted); font-size: 12px; margin-left: 2px; }
.sym-price { font-size: 17px; font-weight: 800; }
.sym-stat { display: flex; flex-direction: column; align-items: flex-end; white-space: nowrap; }
.sym-stat .l { font-size: 10.5px; color: var(--muted); margin-bottom: 2px; }
.sym-stat .v { font-size: 14px; font-weight: 700; }
.sym-sep { width: 1px; align-self: stretch; background: var(--border2); }

/* ===== 页头 ===== */
.page-head { display: flex; justify-content: space-between; align-items: center; gap: 16px; flex-wrap: wrap; margin-bottom: 18px; }
#d-desc, #c-desc, #b-desc, #d-inst-info { font-size: 12px; line-height: 1.7; }
.page-head .desc { font-size: 12.5px; color: var(--text-2); }
.page { animation: fadein .25s ease; }
@keyframes fadein { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

/* ===== 登录 ===== */
.login { min-height: 100vh; display: grid; place-items: center; background: radial-gradient(ellipse at top, #12202a, var(--bg) 60%); }
.login-card { background: var(--panel); border: 1px solid var(--border2); padding: 36px; border-radius: 14px; width: min(380px, 92vw); display: grid; gap: 10px; box-shadow: 0 24px 80px rgba(0, 0, 0, .5); }
.login-card .logo { border: 0; padding: 0 0 10px; text-align: center; }
.login-card .logo .lg-name { font-size: 22px; }

/* ===== 按钮 ===== */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 7px 14px; border-radius: 8px; font-size: 12.5px;
  border: 1px solid var(--border2); background: var(--panel2); color: var(--text); cursor: pointer; user-select: none;
  transition: all .15s; font-family: inherit; text-decoration: none; white-space: nowrap;
}
.btn:hover { border-color: #3d4a6b; background: #1b2337; text-decoration: none; }
.btn.primary, .btn.green { background: linear-gradient(135deg, #0d6b4a, #10895f); border-color: #16a778; color: #d4ffee; font-weight: 700; }
.btn.primary:hover, .btn.green:hover { background: linear-gradient(135deg, #0e7d57, #129a6c); }
.btn.danger { background: linear-gradient(135deg, #7a1d2b, #a3263a); border-color: #c0364c; color: #ffd9dd; font-weight: 700; }
.btn.danger:hover { background: linear-gradient(135deg, #8f2233, #b52e45); }
.btn.ghost { background: transparent; }
.btn.small { padding: 4px 10px; font-size: 11.5px; }
.btn.wide { width: 100%; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* ===== 表单 ===== */
input, select, textarea {
  font: inherit; font-size: 13px; background: var(--bg2); color: var(--text); border: 1px solid var(--border2);
  border-radius: 8px; padding: 7px 12px; width: 100%; outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--blue); }
input[type=checkbox] { width: auto; accent-color: var(--blue); }
label { display: block; font-size: 12px; color: var(--text-2); margin-bottom: 5px; }
label.check { display: flex; align-items: center; gap: 8px; color: var(--text); font-size: 12.5px; margin: 4px 0; }
.field { margin-bottom: 12px; }
.field small { color: var(--muted); display: block; margin-top: 4px; font-size: 11px; line-height: 1.5; }
.grid { display: grid; gap: 14px; }
.grid.c2 { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
.grid.c3 { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.grid.c4 { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 0 16px; }
fieldset { border: 1px solid var(--border); border-radius: 12px; padding: 14px 18px 4px; margin: 0 0 14px; background: var(--panel); }
legend { padding: 0 8px; color: var(--text-2); font-size: 12.5px; font-weight: 600; }

/* ===== 卡片 / 指标 ===== */
.card { background: var(--panel); border: 1px solid var(--border); border-radius: 12px; padding: 16px 18px; }
.card.danger { background: linear-gradient(135deg, #1d0f16, #2a1119); border-color: var(--danger-border); }
.metric { background: var(--panel); border: 1px solid var(--border); border-radius: 12px; padding: 16px 18px; }
.metric .label { font-size: 12px; color: var(--text-2); margin-bottom: 8px; }
.metric .value { font-size: 26px; font-weight: 700; line-height: 1.15; letter-spacing: .3px; }
.metric .sub { font-size: 11.5px; color: var(--muted); margin-top: 6px; }

/* 英雄区（总盈亏） */
.hero {
  display: flex; align-items: center; gap: 28px; padding: 22px 26px; border-radius: 14px; margin-bottom: 14px;
  background: linear-gradient(135deg, #12202a 0%, #0f1a2b 55%, #131022 100%);
  border: 1px solid var(--border2); position: relative; overflow: hidden; flex-wrap: wrap;
}
.hero::after { content: ""; position: absolute; right: 0; top: 0; bottom: 0; width: 240px; background: radial-gradient(ellipse at right, rgba(22, 199, 132, .08), transparent 70%); pointer-events: none; }
.hero .big-label { font-size: 12.5px; color: var(--text-2); letter-spacing: 2px; margin-bottom: 8px; }
.hero .big-num { font-size: 46px; font-weight: 800; line-height: 1; letter-spacing: .5px; }
.hero .big-num small { font-size: 18px; font-weight: 600; color: var(--text-2); margin-left: 6px; }
.hero .big-sub { font-size: 12.5px; color: var(--muted); margin-top: 12px; display: flex; gap: 16px; flex-wrap: wrap; }
.hero .big-sub b { color: var(--text-2); font-weight: 600; }
.hero .note { font-size: 11px; color: var(--muted); margin-top: 8px; display: flex; align-items: center; gap: 6px; }
.hero .note .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--green); display: inline-block; }
.hero .split { display: flex; gap: 34px; margin-left: auto; position: relative; z-index: 1; flex-wrap: wrap; }
.hero .split .item { text-align: right; }
.hero .split .item .l { font-size: 11.5px; color: var(--muted); margin-bottom: 5px; }
.hero .split .item .v { font-size: 19px; font-weight: 700; }
.hero .action { position: relative; z-index: 1; }
.hero .action .btn { padding: 12px 26px; font-size: 14px; }

/* 横幅提示 */
.notice { display: flex; align-items: center; gap: 10px; padding: 10px 16px; border-radius: 10px; margin-bottom: 14px; font-size: 12.5px; font-weight: 600; border: 1px solid; }
.notice.warn { color: var(--yellow); background: var(--yellow-dim); border-color: rgba(240, 185, 11, .4); }
.notice.bad { color: #ffb3ba; background: var(--danger-bg); border-color: var(--danger-border); }

/* 分区标题（现货区 / 合约区） */
.section-title { font-size: 14px; font-weight: 700; padding: 10px 0 12px; letter-spacing: 1px; display: flex; align-items: center; gap: 10px; margin: 18px 0 12px; border-bottom: 1px solid var(--border); }
.section-title.spot { color: var(--blue); border-bottom-color: rgba(79, 140, 255, .2); }
.section-title.contract { color: var(--purple); border-bottom-color: rgba(160, 107, 255, .2); }
.section-title .hint { font-size: 11px; font-weight: 400; color: var(--muted); letter-spacing: 0; }
.section-title .right { margin-left: auto; }

/* ===== 机器人卡片 ===== */
.bot-card { background: var(--panel); border: 1px solid var(--border); border-radius: 12px; padding: 16px 18px; margin-bottom: 14px; transition: border-color .15s; }
.bot-card:hover { border-color: var(--border2); }
.bot-card.is-running { border-left: 3px solid var(--green); }
.bot-card.is-error { border-left: 3px solid var(--red); }
.bot-card header { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 10px; }
.bot-title { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.bot-title strong { font-size: 14.5px; }
.fee-warn { font-size: 12px; color: var(--yellow); margin: 6px 0; line-height: 1.6; }
.bot-msg { font-size: 12px; color: var(--text-2); margin: 0 0 12px; }
.bot-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 10px; margin-bottom: 12px; }
.bot-stats > div { background: var(--bg2); border: 1px solid var(--border); border-radius: 8px; padding: 8px 12px; }
.bot-stats > div > span { display: block; color: var(--muted); font-size: 11px; margin-bottom: 3px; }
.bot-stats b { font-weight: 700; font-size: 13.5px; font-variant-numeric: tabular-nums; }
details summary { cursor: pointer; font-size: 12.5px; color: var(--text-2); }
details summary:hover { color: var(--text); }

/* 状态标签：圆点 + 文字，不只依赖颜色 */
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 1px 8px; border-radius: 4px; font-size: 10.5px; font-weight: 600; letter-spacing: .5px; white-space: nowrap; }
.badge.good { color: var(--green); background: var(--green-dim); }
.badge.warn { color: var(--yellow); background: var(--yellow-dim); }
.badge.bad { color: var(--red); background: var(--red-dim); }
.badge.off { color: var(--text-2); background: #1d2333; }
.tag { display: inline-block; font-size: 10.5px; padding: 1px 8px; border-radius: 4px; font-weight: 600; letter-spacing: .5px; color: var(--text-2); background: #1d2333; white-space: nowrap; }
.tag.blue { color: var(--blue); background: var(--blue-dim); }
.tag.purple { color: var(--purple); background: var(--purple-dim); }
.tag.green { color: var(--green); background: var(--green-dim); }
.tag.yellow { color: var(--yellow); background: var(--yellow-dim); }
.tag.red { color: var(--red); background: var(--red-dim); }
.risk-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 7px; vertical-align: 1px; }
.risk-dot.g { background: var(--green); }
.risk-dot.y { background: var(--yellow); }
.risk-dot.r { background: var(--red); }
.acc-name { font-weight: 600; color: var(--text); }
.acc-sub { font-size: 10.5px; color: var(--muted); margin-top: 2px; }

/* 进度条 */
.bar { height: 6px; background: #1a2133; border-radius: 3px; overflow: hidden; min-width: 90px; }
.bar > i { display: block; height: 100%; border-radius: 3px; }

/* ===== 表格 ===== */
.table-wrap { overflow-x: auto; background: var(--panel); border: 1px solid var(--border); border-radius: 12px; padding: 4px 8px; }
.card .table-wrap, .bot-card .table-wrap { background: transparent; border: 0; padding: 0; border-radius: 0; }
table { width: 100%; border-collapse: collapse; font-size: 12.8px; }
th { text-align: left; font-size: 11px; color: var(--muted); font-weight: 600; padding: 9px 10px; border-bottom: 1px solid var(--border); white-space: nowrap; letter-spacing: .5px; }
th.num { text-align: right; }
td { padding: 9px 10px; border-bottom: 1px solid rgba(35, 43, 63, .5); white-space: nowrap; }
tbody tr { transition: background .12s; }
tbody tr:hover { background: rgba(79, 140, 255, .04); }
tbody tr:last-child td { border-bottom: 0; }
tr.row-danger { background: rgba(234, 57, 67, .06); }
tr.row-warn { background: rgba(240, 185, 11, .05); }
.empty { color: var(--muted); padding: 24px; text-align: center; }

/* ===== 图表 ===== */
.chart { position: relative; }
.chart svg { display: block; width: 100%; height: auto; }
.chart .grid-line { stroke: var(--grid); stroke-width: 1; }
.chart .axis-line { stroke: var(--axis); stroke-width: 1; }
.chart .tick { fill: var(--muted); font-size: 11px; font-family: var(--font); }
.chart .series { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart .crosshair { stroke: var(--text-2); stroke-width: 1; stroke-dasharray: 3 3; }
.legend { display: flex; flex-wrap: wrap; gap: 14px; font-size: 12px; color: var(--text-2); margin: 0 0 10px; }
.legend i { display: inline-block; width: 12px; height: 3px; border-radius: 2px; vertical-align: middle; margin-right: 6px; }
.tooltip { position: fixed; pointer-events: none; background: #1a2135; border: 1px solid var(--border2); border-radius: 8px; padding: 8px 12px; font-size: 12px; z-index: 250; display: none; box-shadow: 0 10px 40px rgba(0, 0, 0, .5); }
.tooltip .t-row { display: flex; gap: 14px; justify-content: space-between; }
.tooltip i { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; }

/* 时间范围切换 */
.time-range { display: flex; gap: 4px; }
.time-range button { padding: 5px 12px; border-radius: 6px; font-size: 11px; font-weight: 600; cursor: pointer; font-family: inherit; border: 1px solid var(--border2); background: var(--panel2); color: var(--text-2); }
.time-range button:hover { border-color: #3d4a6b; }
.time-range button.active { background: var(--green-dim); border-color: var(--green); color: var(--green); }

/* ===== 选项卡 ===== */
.tabs { display: flex; gap: 6px; margin-bottom: 16px; flex-wrap: wrap; }
.tabs button { font: inherit; font-size: 12.5px; font-weight: 600; background: var(--panel2); border: 1px solid var(--border2); color: var(--text-2); padding: 7px 16px; cursor: pointer; border-radius: 8px; transition: all .15s; }
.tabs button:hover { border-color: #3d4a6b; }
.tabs button.active { color: var(--blue); background: var(--blue-dim); border-color: var(--blue); }

/* ===== 日志条目 ===== */
.al-item { border: 1px solid var(--border); border-radius: 10px; padding: 11px 16px; margin-bottom: 8px; background: var(--panel); display: flex; gap: 14px; align-items: flex-start; }
.al-item.error { border-left: 3px solid var(--red); }
.al-item.warn { border-left: 3px solid var(--yellow); }
.al-item.info { border-left: 3px solid var(--blue); }
.al-item .al-body { flex: 1; min-width: 0; font-size: 12.8px; line-height: 1.6; word-break: break-all; }
.al-item .al-meta { font-size: 11px; color: var(--muted); white-space: nowrap; }

/* ===== 提示 / 弹窗 ===== */
.toast {
  position: fixed; bottom: 28px; left: 50%; transform: translateX(-50%) translateY(90px); background: #1a2135; border: 1px solid var(--border2);
  color: var(--text); padding: 11px 22px; border-radius: 10px; font-size: 13px; z-index: 300; transition: transform .3s;
  box-shadow: 0 10px 40px rgba(0, 0, 0, .5); max-width: 560px; pointer-events: none; opacity: 0; visibility: hidden;
}
.toast.show { transform: translateX(-50%) translateY(0); opacity: 1; visibility: visible; }
.toast.error { border-color: var(--danger-border); background: var(--danger-bg); color: #ffd9dd; }
dialog { background: var(--bg2); color: var(--text); border: 1px solid var(--border2); border-radius: 14px; padding: 26px 28px; width: min(640px, 94vw); box-shadow: 0 24px 80px rgba(0, 0, 0, .6); }
dialog.wide { width: min(1000px, 96vw); }
dialog.danger { border-color: var(--danger-border); }
dialog.danger h3 { color: #ff6b7a; }
dialog h3 { font-size: 16px; color: var(--text); }
dialog::backdrop { background: rgba(5, 8, 14, .78); backdrop-filter: blur(3px); }
.split { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 20px; align-items: start; }
.sticky { position: sticky; top: 130px; }

/* ===== 响应式 ===== */
@media (max-width: 1100px) {
  .split { grid-template-columns: 1fr; }
  .hero .split { margin-left: 0; }
  .sticky { position: static; }
}
@media (max-width: 860px) {
  .sidebar { width: 64px; min-width: 64px; }
  .sidebar .lg-sub, .sidebar .nav-sec, .nav a .t, .nav a .bdg, .side-foot, .side-actions .t { display: none; }
  .nav a { justify-content: center; padding: 11px 0; }
  .logo .lg-name { font-size: 12px; text-align: center; }
  .main-wrap { margin-left: 64px; }
  .main { padding: 18px 14px 60px; }
  .topbar, .symbol-banner { padding-left: 14px; padding-right: 14px; }
  .clock { display: none; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

/* 任务进度、条件编辑器、成本对比 */
.progress { display: flex; align-items: center; gap: 10px; margin: 6px 0 10px; font-size: 12px; color: var(--text-2); }
.progress .bar { flex: 0 0 220px; height: 8px; }
.field.wide { grid-column: 1 / -1; }
.rules-ed table input, .rules-ed table select { min-width: 80px; padding: 5px 7px; font-size: 12px; }
.rules-ed td { padding: 4px 6px; }
tr.row-hl > * { background: rgba(59, 130, 246, .08); }
