:root { --bg: #0f1419; --panel: #161b22; --line: #2b2b43; --text: #d1d4dc; --dim: #8b949e; --up: #e5484d; --down: #30a46c; --accent: #4c9aff; }
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); font: 14px/1.4 -apple-system, "PingFang SC", "Helvetica Neue", Arial, sans-serif; }
.hidden { display: none !important; }
.view { min-height: 100vh; }
#view-start, #view-summary { padding: 24px; max-width: 1100px; margin: 0 auto; }
h1 { font-size: 22px; margin: 0 0 16px; }
h2 { font-size: 16px; margin: 20px 0 8px; }
h3 { font-size: 14px; margin: 0 0 8px; color: var(--dim); }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 12px; margin-bottom: 12px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 16px; }
label { display: flex; flex-direction: column; gap: 4px; }
label.check { flex-direction: row; align-items: center; gap: 6px; }
label small { color: var(--dim); }
input, select, textarea, button { font: inherit; color: var(--text); background: #0d1117; border: 1px solid var(--line); border-radius: 6px; padding: 6px 8px; }
input[type="checkbox"], input[type="radio"] { width: auto; padding: 0; }
textarea { width: 100%; resize: vertical; }
button { cursor: pointer; background: #21262d; }
button:hover { border-color: var(--accent); }
button.primary { background: var(--accent); color: #fff; border-color: var(--accent); }
button.danger { color: var(--up); }
button:disabled { opacity: 0.5; cursor: default; }
kbd { font-size: 11px; color: var(--dim); border: 1px solid var(--line); border-radius: 4px; padding: 0 4px; margin-left: 4px; }
.row { display: flex; align-items: center; gap: 6px; margin: 6px 0; flex-wrap: wrap; }
.row input[type="number"] { width: 90px; }
#o-price { width: 100%; }
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { text-align: left; padding: 4px 6px; border-bottom: 1px solid var(--line); vertical-align: top; }
.table th { color: var(--dim); font-weight: normal; }
.table td.num { text-align: right; font-variant-numeric: tabular-nums; }
.plain { list-style: none; margin: 0; padding: 0; }
.plain li { padding: 3px 0; border-bottom: 1px solid var(--line); }
.small { font-size: 12px; }
.dim { color: var(--dim); }
.strong { font-weight: 600; }
.error { color: var(--up); min-height: 1.2em; margin-top: 6px; }
.pos-long { color: var(--up); } .pos-short { color: var(--down); }
.pnl-pos { color: var(--up); } .pnl-neg { color: var(--down); }
fieldset { border: 1px solid var(--line); border-radius: 6px; margin: 12px 0; padding: 8px 12px; display: flex; flex-wrap: wrap; gap: 8px 16px; }
fieldset label { flex-direction: row; align-items: center; gap: 4px; }
fieldset input[type="number"], fieldset input[type="text"] { width: 64px; padding: 2px 4px; }

#topbar { height: 48px; display: flex; align-items: center; gap: 12px; padding: 0 12px; border-bottom: 1px solid var(--line); background: var(--panel); }
#topbar .spacer { flex: 1; }
#main { display: grid; grid-template-columns: 1fr 360px; height: calc(100vh - 48px); }
#charts { display: flex; flex-direction: column; min-width: 0; }
#chart-main { flex: 1 1 auto; min-height: 300px; }
#ind-toggles { margin: 0; padding: 6px 10px; border-bottom: 1px solid var(--line); font-size: 12px; }
#ind-toggles label { padding: 1px 10px; }
#chart-ref-wrap { height: 28%; border-top: 1px solid var(--line); position: relative; }
#chart-ref-title { position: absolute; top: 4px; left: 8px; z-index: 2; font-size: 12px; }
#chart-ref { height: 100%; }
#side { overflow-y: auto; border-left: 1px solid var(--line); padding: 10px; }
#side .card { margin-bottom: 10px; }

.numbers { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; margin-bottom: 12px; }
.numbers div { background: var(--panel); border: 1px solid var(--line); border-radius: 6px; padding: 8px; }
.numbers b { display: block; font-size: 18px; }
#chart-equity { height: 220px; }

#modal { position: fixed; inset: 0; background: rgba(0,0,0,0.6); display: flex; align-items: center; justify-content: center; z-index: 10; }
#modal-box { width: 520px; max-width: 95vw; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0; }
.chips label { flex-direction: row; align-items: center; gap: 4px; border: 1px solid var(--line); border-radius: 14px; padding: 2px 10px; cursor: pointer; }
.chips label.on { border-color: var(--accent); background: rgba(76,154,255,0.15); }
#toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: #21262d; border: 1px solid var(--line); border-radius: 8px; padding: 8px 14px; z-index: 20; max-width: 80vw; }
#toast.err { border-color: var(--up); }

/* 回测报告页 */
.bt-page { padding: 24px; max-width: 1200px; margin: 0 auto; }
.bt-head { display: flex; align-items: baseline; gap: 16px; }
.bt-head a, .start-links a { color: var(--accent); text-decoration: none; }
.bt-chart { height: 360px; }
.bt-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(460px, 1fr)); gap: 0 12px; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 14px; margin-bottom: 6px; font-size: 12px; }
.legend label { flex-direction: row; align-items: center; gap: 4px; cursor: pointer; opacity: 0.45; }
.legend label.on { opacity: 1; }
.swatch { display: inline-block; width: 12px; height: 3px; border-radius: 2px; }
.start-links { float: right; font-size: 14px; font-weight: normal; }
@media (max-width: 640px) { .bt-page { padding: 12px 16px; } .bt-grid { grid-template-columns: 1fr; } }

/* K 线主图左上角的指标值（代替贴在线上的标签，避免挡住 K 线） */
.chart-legend { position: absolute; top: 4px; left: 8px; z-index: 3; pointer-events: none; display: flex; flex-wrap: wrap;
  gap: 2px 12px; max-width: calc(100% - 90px); font-size: 12px; font-variant-numeric: tabular-nums;
  background: rgba(19, 23, 34, 0.6); padding: 2px 6px; border-radius: 4px; }

/* 登录页与用户标记 */
.login-card { max-width: 360px; margin: 12vh auto 0; }
.login-card form { display: flex; flex-direction: column; gap: 10px; }
#user-badge { font-size: 12px; color: var(--dim); }
#user-badge a { color: var(--accent); text-decoration: none; }
#btn-export { font-size: 12px; margin-left: 8px; }
@media (max-width: 640px) { .login-card { margin: 8vh 16px 0; } }
