:root {
  --bg: #0e1116; --card: #171c24; --line: #2a323d; --fg: #e6edf3;
  --muted: #8b98a8; --green: #2ea043; --red: #e5534b; --amber: #d29922; --accent: #2f81f7;
}
* { box-sizing: border-box; }
body {
  margin: 0; background: var(--bg); color: var(--fg);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  -webkit-font-smoothing: antialiased;
}
header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 18px; border-bottom: 1px solid var(--line); position: sticky; top: 0;
  background: var(--bg); z-index: 5;
}
h1 { font-size: 18px; margin: 0; }
h2 { font-size: 16px; margin: 0 0 12px; }
h3 { font-size: 13px; color: var(--muted); margin: 18px 0 8px; text-transform: uppercase; letter-spacing: .04em; }
main { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; padding: 16px; max-width: 1200px; margin: 0 auto; }
@media (max-width: 820px) { main { grid-template-columns: 1fr; } }

.card { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 16px; }
.grid-form { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
@media (max-width: 480px) { .grid-form { grid-template-columns: 1fr; } }
label { display: flex; flex-direction: column; font-size: 12px; color: var(--muted); gap: 4px; }
input {
  background: #0e1116; border: 1px solid var(--line); border-radius: 8px; color: var(--fg);
  padding: 9px 10px; font-size: 14px; width: 100%;
}
input:focus { outline: none; border-color: var(--accent); }

.btn-row { display: flex; gap: 10px; margin-top: 14px; flex-wrap: wrap; }
button {
  border: none; border-radius: 8px; padding: 10px 16px; font-size: 14px; cursor: pointer;
  color: #fff; font-weight: 600; flex: 1; min-width: 110px;
  background: var(--accent);
}
button:hover { filter: brightness(1.08); }
button.primary { background: var(--green); }
button.danger { background: var(--red); }
button.secondary { background: #30363d; }
button:active { transform: translateY(1px); }

.preview { margin-top: 12px; padding: 10px; background: #0e1116; border-radius: 8px; font-size: 13px; color: var(--muted); white-space: pre-line; }

.stat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 16px; }
.stat { display: flex; justify-content: space-between; padding: 7px 0; border-bottom: 1px solid var(--line); font-size: 13px; }
.stat .k { color: var(--muted); }
.stat .v { font-variant-numeric: tabular-nums; font-weight: 600; }
.pos { color: var(--green); } .neg { color: var(--red); } .warn { color: var(--amber); }

table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { text-align: right; padding: 6px 8px; border-bottom: 1px solid var(--line); font-variant-numeric: tabular-nums; }
th:first-child, td:first-child { text-align: left; }
.mono { font-family: ui-monospace, Menlo, monospace; font-size: 12px; color: var(--muted); white-space: pre-wrap; word-break: break-all; }

.badge { font-size: 12px; padding: 4px 10px; border-radius: 20px; background: #30363d; }
.badge.ok { background: rgba(46,160,67,.2); color: var(--green); }
.badge.bad { background: rgba(229,83,75,.2); color: var(--red); }
.stale { color: var(--amber); font-size: 12px; }
.err { color: var(--red); font-size: 13px; min-height: 18px; }

.overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.7); display: flex; align-items: center;
  justify-content: center; z-index: 20; padding: 20px;
}
.overlay .card { width: 100%; max-width: 360px; }
.login input, .confirm { margin-bottom: 12px; }
.hidden { display: none !important; }

/* ---- 多账户 UI ---- */
.view { max-width: 900px; margin: 0 auto; padding: 16px; }
.hint { color: #8b98a8; font-size: 0.9em; }
#accounts-table { width: 100%; border-collapse: collapse; }
#accounts-table th, #accounts-table td { border-bottom: 1px solid var(--line); padding: 8px; text-align: left; }
.modal { position: fixed; inset: 0; margin: auto; width: 320px; height: max-content;
  background: var(--card); border: 1px solid var(--line); border-radius: 8px; padding: 16px; box-shadow: 0 8px 30px rgba(0,0,0,.4); z-index: 30; }
#equity-canvas { width: 100%; max-width: 600px; border: 1px solid var(--line); border-radius: 6px; display: block; }
#control-area { display: flex; gap: 10px; margin: 16px 0; flex-wrap: wrap; }
#config-form { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0; }
#config-form input { flex: 1 1 140px; }
@media (max-width: 600px) { #accounts-table { font-size: 0.85em; } .view { padding: 8px; } }
