* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
:root {
  --bg: #0b0e11; --card: #161a1e; --line: #2b3139; --text: #eaecef; --sub: #848e9c;
  --long: #0ecb81; --short: #f6465d; --warn: #f0b90b;
}
html, body { background: var(--bg); color: var(--text); }
body {
  font: 15px/1.5 -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}
.app { max-width: 480px; margin: 0 auto; padding: 12px 14px 32px; }

.top { display: flex; justify-content: space-between; align-items: center; padding: 6px 2px 14px; }
.sym { font-size: 20px; font-weight: 700; }
.tag { font-size: 11px; font-weight: 400; color: var(--warn); border: 1px solid var(--warn); border-radius: 4px; padding: 0 5px; margin-left: 4px; vertical-align: middle; }
.mode { font-size: 12px; color: var(--sub); margin-top: 2px; }
.price { font-size: 26px; font-weight: 700; font-variant-numeric: tabular-nums; transition: color .3s; }
.price.up { color: var(--long); }
.price.down { color: var(--short); }

.card { background: var(--card); border-radius: 12px; padding: 14px; margin-bottom: 12px; }
.card-title { font-size: 13px; color: var(--sub); margin-bottom: 10px; }

.quota { display: flex; align-items: center; justify-content: space-between; }
.quota-label { color: var(--sub); font-size: 13px; }
.quota-num { font-size: 30px; font-weight: 700; font-variant-numeric: tabular-nums; }
.quota-num small { font-size: 16px; color: var(--sub); font-weight: 400; }
.quota-dots { display: flex; gap: 6px; }
.quota-dots i { width: 12px; height: 12px; border-radius: 50%; background: var(--warn); }
.quota-dots i.used { background: var(--line); }

.order { display: grid; grid-template-columns: 72px 1fr; gap: 10px; margin-bottom: 6px; }
.order label { grid-column: 1; align-self: center; color: var(--sub); font-size: 14px; }
.order input {
  grid-column: 2; height: 52px; border: 1px solid var(--line); border-radius: 12px;
  background: var(--card); color: var(--text); font-size: 20px; padding: 0 14px;
  font-variant-numeric: tabular-nums;
}
.order input:focus { outline: 1px solid var(--warn); }
.order input:disabled { color: var(--sub); background: var(--bg); }
#chart.locked { cursor: default; }
.order .preview, .order .btn { grid-column: 1 / -1; }
.preview {
  min-height: 42px; padding: 8px 12px; border-radius: 10px; background: var(--bg);
  color: var(--sub); font-size: 13px; font-variant-numeric: tabular-nums;
}
.preview.bad { color: var(--short); }
.preview.ok { color: var(--text); }
.chart-card { padding-bottom: 8px; touch-action: none; }
.chart-card .card-title { display: flex; justify-content: space-between; }
#chart { width: 100%; height: 280px; display: block; touch-action: none; cursor: crosshair; }
.cross { min-height: 20px; margin-top: 6px; font-size: 13px; color: var(--warn); font-variant-numeric: tabular-nums; }
.btn {
  height: 56px; border: 0; border-radius: 12px; font-size: 18px; font-weight: 700; color: #fff;
  background: var(--warn); cursor: pointer; touch-action: manipulation;
}
.btn:active { transform: scale(.97); }
.btn:disabled { background: var(--line); color: var(--sub); cursor: not-allowed; transform: none; }
.lock-reason { min-height: 22px; text-align: center; font-size: 13px; color: var(--warn); margin-bottom: 8px; }

.pos { border: 1px solid var(--line); border-radius: 10px; padding: 12px; margin-bottom: 10px; }
.pos:last-child { margin-bottom: 0; }
.pos-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.side { font-weight: 700; font-size: 14px; padding: 2px 8px; border-radius: 4px; }
.side.long { color: var(--long); background: rgba(14,203,129,.12); }
.side.short { color: var(--short); background: rgba(246,70,93,.12); }
.pnl { font-size: 18px; font-weight: 700; font-variant-numeric: tabular-nums; }
.pos-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 4px 12px; font-size: 13px; }
.pos-grid span { color: var(--sub); }
.pos-grid b { font-weight: 500; float: right; font-variant-numeric: tabular-nums; }
.wait {
  margin-top: 10px; padding: 10px; border-radius: 8px; text-align: center;
  background: rgba(132, 142, 156, .12); color: var(--sub); font-size: 13px;
}

.grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px 8px; }
.grid div { display: flex; flex-direction: column; }
.grid span { font-size: 12px; color: var(--sub); }
.grid b { font-size: 15px; font-weight: 600; font-variant-numeric: tabular-nums; }

.pos-v { color: var(--long); }
.neg-v { color: var(--short); }

.rules { margin: 4px 2px 0; }
.rules summary { color: #5e6673; font-size: 12px; cursor: pointer; text-align: center; padding: 8px; }
.rules summary::-webkit-details-marker { display: none; }
.rules ul { list-style: none; font-size: 12px; margin-top: 4px; background: var(--card); border-radius: 12px; padding: 8px 14px; }
.rules li { padding: 6px 0; border-bottom: 1px dashed var(--line); display: flex; justify-content: space-between; gap: 12px; }
.rules li:last-child { border-bottom: 0; }
.rules li span { color: var(--sub); flex: none; }

.hist { display: flex; justify-content: space-between; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--line); font-size: 13px; }
.hist:last-child { border-bottom: 0; }
.hist .meta { color: var(--sub); font-size: 12px; }
.hist .r { text-align: right; }

.empty { text-align: center; color: var(--sub); font-size: 13px; padding: 12px 0; }

.foot { text-align: center; margin-top: 18px; }
.link { background: none; border: 0; color: var(--sub); font-size: 13px; text-decoration: underline; padding: 8px; cursor: pointer; }
.note { font-size: 11px; color: #5e6673; margin-top: 4px; }

.toast {
  position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); transform: translateX(-50%) translateY(20px);
  max-width: 90vw; background: #2b3139; color: var(--text); padding: 12px 18px; border-radius: 10px;
  font-size: 14px; opacity: 0; pointer-events: none; transition: all .25s; z-index: 10; text-align: center;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.err { background: #4a1f26; color: #ffb3bd; }
.toast.ok { background: #123b2b; color: #9ff0cc; }

.mask {
  position: fixed; inset: 0; z-index: 20; background: rgba(0, 0, 0, .62);
  display: flex; align-items: flex-end; justify-content: center;
}
.mask[hidden] { display: none; }
.sheet {
  width: min(480px, 100%); background: var(--card); color: var(--text);
  border-radius: 18px 18px 0 0; padding: 18px 16px calc(16px + env(safe-area-inset-bottom));
}
.sheet h2 { font-size: 16px; font-weight: 600; text-align: center; }
.sheet-side { margin: 12px 0; text-align: center; font-size: 22px; font-weight: 700; }
.reasons { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.reasons button {
  min-height: 44px; border: 1px solid var(--line); border-radius: 10px; background: var(--bg);
  color: var(--text); font-size: 14px;
}
.reasons button.on { border-color: var(--warn); color: var(--warn); }
.sheet-rows { margin: 14px 0 8px; }
.sheet-rows div { display: flex; justify-content: space-between; padding: 7px 0; border-bottom: 1px solid var(--line); }
.sheet-rows dt { color: var(--sub); }
.sheet-rows dd { font-variant-numeric: tabular-nums; }
.sheet-note { min-height: 20px; color: var(--warn); font-size: 13px; text-align: center; }
.sheet-actions { display: grid; grid-template-columns: 1fr 1.4fr; gap: 10px; margin-top: 12px; }
.sheet-cancel, .sheet-go {
  height: 50px; border: 0; border-radius: 12px; font-size: 16px; font-weight: 700;
}
.sheet-cancel { background: var(--line); color: var(--text); }
.sheet-go { background: var(--warn); color: #1e2329; }
.sheet-go:disabled { background: var(--line); color: var(--sub); }
