/* ITcoin Web 样式：深色交易终端风格，纯手写、无外部依赖（容器里不联网也能用） */

:root {
  --bg: #0b0f14;
  --bg-soft: #0f151d;
  --panel: #121a24;
  --panel-2: #16202c;
  --border: #1f2b3a;
  --border-soft: #182231;
  --text: #e6edf3;
  --muted: #8b98a9;
  --muted-2: #61707f;
  --accent: #4f8cff;
  --accent-soft: rgba(79, 140, 255, 0.14);
  --up: #2ecc71;
  --up-soft: rgba(46, 204, 113, 0.12);
  --down: #ff5d5d;
  --down-soft: rgba(255, 93, 93, 0.12);
  --warn: #f0b90b;
  --warn-soft: rgba(240, 185, 11, 0.14);
  --radius: 10px;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", "PingFang SC", sans-serif;
  font-size: 14px;
  line-height: 1.5;
}

a { color: var(--accent); text-decoration: none; }
h1, h2, h3, h4 { margin: 0; font-weight: 600; }
h1 { font-size: 20px; }
h2 { font-size: 15px; }
.muted { color: var(--muted); font-weight: 400; }
.mono { font-variant-numeric: tabular-nums; }
.up { color: var(--up); }
.down { color: var(--down); }
.warn { color: var(--warn); }

/* ---------------- 顶栏 ---------------- */
.topbar {
  display: flex;
  align-items: center;
  gap: 18px;
  height: 56px;
  padding: 0 18px;
  background: linear-gradient(180deg, #101822, #0c1219);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 30;
}

.brand { display: flex; align-items: center; gap: 9px; font-weight: 700; letter-spacing: 0.3px; }
.brand .logo {
  display: grid;
  place-items: center;
  width: 28px; height: 28px;
  border-radius: 8px;
  background: linear-gradient(135deg, #4f8cff, #2f6ae0);
  color: #fff;
  font-size: 12px;
  font-weight: 800;
}
.brand .ver {
  font-size: 10px;
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 1px 7px;
  font-weight: 500;
}

.nav { display: flex; gap: 4px; }
.nav a {
  color: var(--muted);
  padding: 7px 12px;
  border-radius: 8px;
  font-size: 13px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.nav a:hover { background: var(--panel-2); color: var(--text); }
.nav a.active { background: var(--accent-soft); color: #cfe0ff; }
.nav .badge {
  min-width: 18px;
  padding: 0 5px;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  font-size: 11px;
  text-align: center;
  line-height: 17px;
}

.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 12px; }
.dot-live { width: 8px; height: 8px; border-radius: 50%; background: var(--muted-2); }
.dot-live.on { background: var(--up); box-shadow: 0 0 8px rgba(46, 204, 113, 0.7); }
.dot-live.err { background: var(--down); }

/* ---------------- 页面容器 ---------------- */
.page { padding: 14px 18px 26px; max-width: 1680px; margin: 0 auto; }
.page-head { display: flex; align-items: baseline; gap: 12px; margin: 2px 0 12px; }

.layout {
  display: grid;
  grid-template-columns: 336px minmax(0, 1fr);
  gap: 14px;
  align-items: start;
}
.sidebar, .main { display: flex; flex-direction: column; gap: 12px; min-width: 0; }

/* 设置页是「表单宽、状态窄」，方向反过来 */
.layout.wide-left { grid-template-columns: minmax(0, 1fr) 360px; }

@media (max-width: 1080px) {
  .layout, .layout.wide-left { grid-template-columns: 1fr; }
}

/* ---------------- 工具栏 ---------------- */
.toolbar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  padding: 10px 12px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 12px;
}
.toolbar .spacer { flex: 1 1 auto; }
.toolbar .label { color: var(--muted); font-size: 12px; }

.seg { display: inline-flex; background: var(--bg-soft); border: 1px solid var(--border); border-radius: 8px; padding: 2px; }
.seg button {
  border: 0;
  background: transparent;
  color: var(--muted);
  padding: 5px 11px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
  font-family: inherit;
}
.seg button:hover { color: var(--text); }
.seg button.active { background: #24344a; color: #dbe9ff; }

.symbol-box { display: inline-flex; align-items: center; gap: 4px; }
.symbol-box input {
  width: 148px;
  padding: 7px 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg-soft);
  color: var(--text);
  font-family: inherit;
  font-size: 13px;
  text-transform: uppercase;
}
.symbol-box input:focus { outline: none; border-color: var(--accent); }

button.btn, .btn {
  border: 1px solid var(--border);
  background: var(--panel-2);
  color: var(--text);
  padding: 7px 12px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 13px;
  font-family: inherit;
  transition: background 0.15s, border-color 0.15s;
  white-space: nowrap;
}
button.btn:hover, .btn:hover { background: #1d2a3a; border-color: #2b3b4f; }
button.btn.primary, .btn.primary { background: #2f6ae0; border-color: #3f7bf0; color: #fff; }
button.btn.primary:hover, .btn.primary:hover { background: #3f7bf0; }
button.btn.ghost { background: transparent; }
button.btn.danger { color: #ffb4b4; border-color: #4a2626; background: #2a1616; }
button.btn.danger:hover { background: #3a1c1c; }
button.btn:disabled { opacity: 0.55; cursor: not-allowed; }

/* ---------------- 卡片 ---------------- */
.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
}
.card-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}
.card-head .muted { font-size: 12px; }
.card-head .spacer { flex: 1; }

/* ---------------- 信号卡 ---------------- */
.signal-card { padding-bottom: 14px; }
.price-row { display: flex; align-items: baseline; gap: 10px; }
.price { font-size: 30px; font-weight: 700; letter-spacing: -0.5px; font-variant-numeric: tabular-nums; }
.change { font-size: 13px; color: var(--muted); }

.action-row { display: flex; align-items: center; gap: 10px; margin-top: 10px; }
.action {
  font-size: 22px;
  font-weight: 700;
  padding: 2px 12px;
  border-radius: 8px;
  background: var(--panel-2);
  color: var(--muted);
}
.action.buy { background: var(--up-soft); color: #4ade80; }
.action.sell { background: var(--down-soft); color: #ff8080; }
.action.short { background: var(--down-soft); color: #ff8080; }
.action.long { background: var(--up-soft); color: #4ade80; }
.action.hold, .action.wait { background: rgba(240, 185, 11, 0.1); color: var(--warn); }
.conf { font-size: 12px; color: var(--muted); }

.sub { margin-top: 8px; font-size: 12px; color: var(--muted); }

.scorebar {
  margin-top: 12px;
  height: 8px;
  border-radius: 999px;
  background: #1a2431;
  overflow: hidden;
  position: relative;
}
.scorebar i {
  display: block;
  height: 100%;
  width: 0;
  border-radius: 999px;
  background: linear-gradient(90deg, #2f6ae0, #4f8cff);
  transition: width 0.35s ease;
}
.score-meta { display: flex; justify-content: space-between; margin-top: 6px; font-size: 12px; color: var(--muted); }

/* ---------------- 交易计划 ---------------- */
.plan-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 14px; }
.plan-item { display: flex; flex-direction: column; gap: 2px; }
.plan-item span { font-size: 11px; color: var(--muted); }
.plan-item b { font-size: 14px; font-variant-numeric: tabular-nums; font-weight: 600; }
.plan-note { margin-top: 10px; font-size: 12px; color: var(--muted); border-top: 1px dashed var(--border); padding-top: 8px; }

/* ---------------- 依据 ---------------- */
.reasons { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; font-size: 13px; }
.reasons li { position: relative; padding-left: 14px; color: #c3cedb; }
.reasons li::before { content: "·"; position: absolute; left: 2px; color: var(--accent); }
.reasons li.warn-item::before { content: "!"; color: var(--warn); }
.reasons li.warn-item { color: #e8d08a; }

/* ---------------- 自选 ---------------- */
.watchlist { display: flex; flex-direction: column; gap: 2px; max-height: 260px; overflow: auto; }
.watch-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 6px 8px;
  border-radius: 8px;
  cursor: pointer;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text);
  font-family: inherit;
  font-size: 13px;
  width: 100%;
  text-align: left;
}
.watch-item:hover { background: var(--panel-2); }
.watch-item.active { background: var(--accent-soft); border-color: #2b4c86; }
.watch-item .mk { font-size: 11px; color: var(--muted); }

/* ---------------- 图表 ---------------- */
.chart-card { padding-bottom: 6px; }
.chart-body { position: relative; height: 460px; }
.chart-body canvas { width: 100%; height: 100%; display: block; }
.legend { display: flex; gap: 12px; font-size: 12px; color: var(--muted); }
.legend i { display: inline-block; width: 10px; height: 3px; border-radius: 2px; vertical-align: middle; margin-right: 5px; }
.legend .e20 { background: #4f8cff; }
.legend .e50 { background: #f0b90b; }
.legend .e200 { background: #b46bff; }
.legend .boll { background: #39465a; }
.hover-info { margin-left: auto; font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.chart-empty {
  position: absolute; inset: 0;
  display: grid; place-items: center;
  color: var(--muted);
  font-size: 13px;
  background: rgba(11, 15, 20, 0.55);
}

/* ---------------- 指标 ---------------- */
.metrics { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 10px; }
@media (max-width: 1280px) { .metrics { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
@media (max-width: 720px) { .metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.metric { background: var(--bg-soft); border: 1px solid var(--border-soft); border-radius: 8px; padding: 8px 10px; }
.metric span { display: block; font-size: 11px; color: var(--muted); }
.metric b { font-size: 14px; font-variant-numeric: tabular-nums; }

/* ---------------- 状态栏 ---------------- */
.statusbar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 12px;
  padding: 7px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-soft);
  color: var(--muted);
  font-size: 12px;
  min-height: 34px;
}
.statusbar .right { margin-left: auto; font-variant-numeric: tabular-nums; }

/* ---------------- 表格 ---------------- */
.table-wrap { overflow: auto; max-height: 62vh; border: 1px solid var(--border-soft); border-radius: 8px; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
thead th {
  position: sticky; top: 0; z-index: 2;
  background: #16202c;
  color: var(--muted);
  font-weight: 500;
  text-align: left;
  padding: 8px 10px;
  white-space: nowrap;
  border-bottom: 1px solid var(--border);
}
tbody td { padding: 7px 10px; border-bottom: 1px solid var(--border-soft); white-space: nowrap; font-variant-numeric: tabular-nums; }
tbody tr:hover { background: rgba(79, 140, 255, 0.06); }
tbody tr:last-child td { border-bottom: 0; }
td.num, th.num { text-align: right; }
.row-actions { display: flex; gap: 6px; }
.row-actions button { padding: 3px 8px; font-size: 12px; }
.empty { padding: 18px; text-align: center; color: var(--muted); font-size: 13px; }

.tag { display: inline-block; padding: 1px 7px; border-radius: 999px; font-size: 11px; background: var(--panel-2); color: var(--muted); }
.tag.up { background: var(--up-soft); color: #4ade80; }
.tag.down { background: var(--down-soft); color: #ff8080; }
.tag.warn { background: var(--warn-soft); color: var(--warn); }

/* ---------------- 钱包 ---------------- */
.wallet { display: flex; flex-wrap: wrap; gap: 18px; align-items: center; }
.wallet-principal { display: flex; align-items: center; gap: 8px; }
.wallet-principal input {
  width: 120px; padding: 7px 9px; border-radius: 8px;
  border: 1px solid var(--border); background: var(--bg-soft); color: var(--text);
  font-family: inherit; font-size: 13px;
}
.wallet-stats { display: flex; flex-wrap: wrap; gap: 22px; }
.wallet-stats div { display: flex; flex-direction: column; }
.wallet-stats span { font-size: 11px; color: var(--muted); }
.wallet-stats b { font-size: 16px; font-variant-numeric: tabular-nums; }

/* ---------------- 表单 ---------------- */
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 16px; }
@media (max-width: 760px) { .form-grid { grid-template-columns: 1fr; } }
.field { display: flex; flex-direction: column; gap: 5px; }
.field label { font-size: 12px; color: var(--muted); }
.field input, .field select, .field textarea {
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg-soft);
  color: var(--text);
  font-family: inherit;
  font-size: 13px;
  width: 100%;
}
.field input:focus, .field select:focus { outline: none; border-color: var(--accent); }
.field .hint { font-size: 11px; color: var(--muted-2); }
.field.checkbox { flex-direction: row; align-items: center; gap: 8px; }
.field.checkbox input { width: 16px; height: 16px; }

fieldset { border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px 16px; margin: 0 0 14px; }
legend { padding: 0 6px; font-size: 13px; color: #cfe0ff; }
fieldset .desc { font-size: 12px; color: var(--muted); margin-bottom: 12px; }

.flash { padding: 9px 12px; border-radius: 8px; margin-bottom: 12px; font-size: 13px; }
.flash.ok { background: var(--up-soft); color: #8ef0b6; border: 1px solid #24543c; }
.flash.error { background: var(--down-soft); color: #ffb4b4; border: 1px solid #4a2626; }

/* ---------------- 弹窗 ---------------- */
.modal {
  position: fixed; inset: 0;
  background: rgba(4, 7, 11, 0.72);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 60;
  padding: 20px;
}
.modal.open { display: flex; }
.modal-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow);
  width: min(560px, 100%);
  max-height: 88vh;
  overflow: auto;
  padding: 16px 18px;
}
.modal-card h3 { margin-bottom: 12px; font-size: 16px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }

/* ---------------- 提示 ---------------- */
.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 80;
  pointer-events: none;
}
.toast .item {
  background: #1a2431;
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  color: var(--text);
  padding: 9px 13px;
  border-radius: 8px;
  font-size: 13px;
  box-shadow: var(--shadow);
  animation: toast-in 0.18s ease-out;
  max-width: 380px;
}
.toast .item.err { border-left-color: var(--down); }
.toast .item.ok { border-left-color: var(--up); }
@keyframes toast-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* ---------------- 统计块 ---------------- */
.stat-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 10px; }
.stat { background: var(--bg-soft); border: 1px solid var(--border-soft); border-radius: 8px; padding: 9px 11px; }
.stat span { display: block; font-size: 11px; color: var(--muted); }
.stat b { font-size: 16px; font-variant-numeric: tabular-nums; }

.section-gap { margin-top: 12px; }
.loading { color: var(--muted); font-size: 13px; padding: 10px 0; }

/* ---------------- 登录页（2026-11-04） ---------------- */
.login-body {
  min-height: 100vh;
  margin: 0;
  padding: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(1100px 520px at 50% -12%, #16243a 0%, var(--bg) 62%);
}
.login-card {
  width: 100%;
  max-width: 372px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 26px 24px 20px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--shadow);
}
.login-brand { font-size: 17px; }
.login-sub { margin: -4px 0 4px; font-size: 12px; color: var(--muted); }
.login-card .field input { padding: 9px 11px; }
.remember { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--muted); }
.remember input { width: 15px; height: 15px; }
.login-submit { width: 100%; padding: 9px 12px; }
.login-hint { margin: 2px 0 0; font-size: 11px; line-height: 1.6; color: var(--muted-2); }

/* ---------------- 顶栏用户 ---------------- */
.user-chip {
  padding: 2px 9px;
  font-size: 12px;
  color: #cfe0ff;
  background: var(--accent-soft);
  border: 1px solid #2b4c86;
  border-radius: 999px;
}
.logout-form { margin: 0; }
.topbar-right .btn { padding: 3px 9px; font-size: 12px; }

/* ---------------- 用户管理 ---------------- */
.user-form {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr)) auto;
  gap: 10px;
  align-items: end;
}
.user-form .btn { height: 34px; }
.user-table td { vertical-align: middle; }
.user-table select,
.user-table input[type="password"],
.user-table input[type="text"] {
  width: 100%;
  min-width: 88px;
  padding: 5px 8px;
  font-size: 12px;
  color: var(--text);
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: 7px;
}
.user-table select:focus,
.user-table input:focus { outline: none; border-color: var(--accent); }
.mini { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; color: var(--muted); }
.mini input { width: 14px; height: 14px; }
.row-actions form { margin: 0; }

@media (max-width: 900px) {
  .user-form { grid-template-columns: 1fr 1fr; }
}

/* ---------------- 自动交易状态条（2026-11-04） ---------------- */
.auto-strip { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.auto-strip .auto-main { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; min-width: 0; }
.auto-strip .auto-main b { font-size: 14px; }
.auto-strip .auto-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
}
.auto-strip .auto-actions .seg button { padding: 4px 10px; font-size: 12px; }
.auto-events {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding-top: 8px;
  border-top: 1px dashed var(--border);
  font-size: 12px;
  color: var(--muted);
}
.auto-events:empty { display: none; }

/* ---------------- 图例（回测三条曲线） ---------------- */
.legend { display: flex; flex-wrap: wrap; gap: 14px; margin-bottom: 6px; font-size: 12px; color: var(--muted); }
.legend i { display: inline-block; width: 9px; height: 9px; border-radius: 2px; margin-right: 5px; }

/* ---------------- 错误页 ---------------- */
.error-card { max-width: 460px; text-align: center; padding: 28px 24px; }
.error-card h1 { font-size: 44px; margin: 0 0 6px; letter-spacing: 1px; }
.error-card p { margin: 0 0 14px; }
.error-card .btn { display: inline-block; padding: 6px 14px; text-decoration: none; }
