* { box-sizing: border-box; margin: 0; padding: 0; min-width: 0; }
:root {
  --bg: #0d1117; --panel: #161b22; --border: #30363d;
  --text: #e6edf3; --dim: #8b949e; --accent: #2f81f7;
  --green: #3fb950; --red: #f85149;
}
html, body {
  overflow-x: hidden; max-width: 100%;
  font-family: -apple-system, "Segoe UI", "Microsoft YaHei", sans-serif;
  background: var(--bg); color: var(--text); font-size: 15px;
  -webkit-tap-highlight-color: transparent;
}
.hidden { display: none !important; }
button {
  background: var(--accent); color: #fff; border: 0; border-radius: 8px;
  padding: 10px 16px; font-size: 15px; cursor: pointer;
}
button.ghost { background: transparent; border: 1px solid var(--border); color: var(--dim); }
input, select {
  background: var(--panel); border: 1px solid var(--border); color: var(--text);
  border-radius: 8px; padding: 10px; font-size: 15px; width: 100%;
}
.err { color: var(--red); margin-top: 8px; min-height: 20px; font-size: 14px; }
.hint { color: var(--dim); margin-top: 12px; font-size: 13px; }

/* 登录 */
.login { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; }
.login-card {
  background: var(--panel); border: 1px solid var(--border); border-radius: 14px;
  padding: 28px 24px; width: 100%; max-width: 360px;
}
.login-card h1 { font-size: 20px; margin-bottom: 20px; text-align: center; }
.login-card input { margin-bottom: 12px; }
.login-card button { width: 100%; }
.pwd-row { display: flex; gap: 8px; margin-bottom: 12px; }
.pwd-row input { margin-bottom: 0; flex: 1; }
.login-card .pwd-eye {
  flex: 0 0 auto; width: auto; padding: 10px 14px; font-size: 17px; line-height: 1;
}

.captcha-row { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 12px; align-items: center; }
.captcha-row input { margin-bottom: 0; flex: 1; min-width: 100px; }
.captcha-img {
  height: 66px; width: 182px; border-radius: 8px; border: 1px solid var(--border);
  cursor: pointer; flex: 0 0 auto; background: #f5f5f8; image-rendering: -webkit-optimize-contrast;
}

/* 主界面 */
header {
  display: flex; align-items: center; gap: 12px; padding: 14px 16px;
  border-bottom: 1px solid var(--border); position: sticky; top: 0; background: var(--bg); z-index: 5;
}
.brand { font-weight: 700; }
.who { color: var(--dim); font-size: 13px; margin-left: auto; }
header button.ghost { padding: 6px 12px; font-size: 13px; }

nav { display: flex; border-bottom: 1px solid var(--border); position: sticky; top: 57px; background: var(--bg); z-index: 4; }
nav button {
  flex: 1; background: transparent; color: var(--dim); border-radius: 0;
  border-bottom: 2px solid transparent; padding: 12px 0; font-size: 14px;
}
nav button.active { color: var(--text); border-bottom-color: var(--accent); }

main { padding: 16px; max-width: 900px; margin: 0 auto; }
.tab { display: none; }
.tab.active { display: block; }
h3 { margin: 18px 0 10px; font-size: 15px; color: var(--dim); }

.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px; }
.card {
  background: var(--panel); border: 1px solid var(--border); border-radius: 12px; padding: 16px;
}
.card .k { color: var(--dim); font-size: 13px; }
.card .v { font-size: 22px; font-weight: 700; margin-top: 6px; }

.row { display: flex; gap: 10px; margin-bottom: 8px; }
.row select { flex: 1; }
.row button { flex: 0 0 auto; }

.form { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 14px; }
.form label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--dim); }
.form label.ckbox { flex-direction: row; align-items: center; flex-wrap: wrap; gap: 8px; }
.form label.ckbox input { width: auto; }
.form label.ckbox .fh { flex-basis: 100%; }
.fh { color: #6e7681; font-size: 11px; font-weight: 400; line-height: 1.4; }
.form button, #pmSave, #btRun { grid-column: 1 / -1; }

.status { color: var(--dim); font-size: 13px; margin: 8px 0; }
.status.warn {
  color: #f0b429; background: rgba(240,180,41,0.1); border: 1px solid rgba(240,180,41,0.35);
  border-radius: 8px; padding: 10px 12px; margin-bottom: 12px;
}
.metrics { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 14px; }
.metrics .m { background: var(--panel); border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; }
.metrics .m .k { color: var(--dim); font-size: 12px; }
.metrics .m .v { font-size: 17px; font-weight: 600; margin-top: 4px; }

canvas { width: 100%; height: auto; background: var(--panel); border: 1px solid var(--border); border-radius: 10px; margin-top: 8px; }

.tablewrap { overflow-x: auto; border: 1px solid var(--border); border-radius: 10px; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { padding: 8px 10px; text-align: right; white-space: nowrap; }
th:first-child, td:first-child { text-align: left; }
thead th { color: var(--dim); border-bottom: 1px solid var(--border); font-weight: 500; }
tbody tr:nth-child(even) { background: rgba(255,255,255,0.02); }
.buy { color: var(--green); }
.sell { color: var(--red); }
.pos { color: var(--green); }
.neg { color: var(--red); }

/* 通用确认弹窗 */
.modal-mask {
  position: fixed; inset: 0; background: rgba(0,0,0,0.55);
  display: flex; align-items: center; justify-content: center;
  padding: 20px; z-index: 50;
}
.modal-box {
  background: var(--panel); border: 1px solid var(--border); border-radius: 14px;
  padding: 20px; width: 100%; max-width: 420px; max-height: 80vh; overflow-y: auto;
}
.modal-title { font-size: 16px; font-weight: 700; margin-bottom: 10px; }
.modal-body { font-size: 13px; color: var(--text); line-height: 1.7; }
.modal-body table { width: 100%; margin-top: 8px; font-size: 12px; }
.modal-body th, .modal-body td { padding: 4px 6px; }
.modal-actions { display: flex; gap: 10px; margin-top: 18px; }
.modal-actions button { flex: 1; }
.status-badge { padding: 2px 8px; border-radius: 6px; font-size: 12px; }
.status-badge.running { background: rgba(240,180,41,0.15); color: #f0b429; }
.status-badge.done { background: rgba(63,185,80,0.15); color: var(--green); }
.status-badge.error { background: rgba(248,81,73,0.15); color: var(--red); }
tr.clickable { cursor: pointer; }
tr.clickable:hover { background: rgba(255,255,255,0.05); }
