/* ============================================================
   自动交易助理 · 基础样式（颜色、字号、通用部件；从第 0 步样稿搬过来）
   ============================================================ */
*, *::before, *::after { box-sizing: border-box; }
:root {
  --font: "PingFang SC", "Microsoft YaHei UI", "Microsoft YaHei", "Noto Sans SC", "Source Han Sans SC", "Segoe UI", system-ui, sans-serif;
  --numfont: "Segoe UI", -apple-system, "SF Pro Text", Roboto, "Helvetica Neue", Arial, "Microsoft YaHei UI", sans-serif;
  --r-sm: 6px; --r: 10px; --r-lg: 14px;
  --gap: 12px;
  --fs: 14px;
  --stop: #E11D2E; --stop-hover: #F02537;
}
:root[data-fs="1"] { --fs: 13px; }
:root[data-fs="2"] { --fs: 14px; }
:root[data-fs="3"] { --fs: 16px; }
:root[data-fs="4"] { --fs: 18px; }
html { font-size: var(--fs); -webkit-text-size-adjust: 100%; }

/* ---------- 深色 ---------- */
:root[data-theme="dark"] {
  --bg: #0C1015; --bg-2: #10151C;
  --panel: #151B23; --panel-2: #1B222C; --panel-3: #232C38;
  --line: #262F3B; --line-2: #33404F;
  --text: #E9EDF2; --text-2: #A9B3C0; --text-3: #6F7B8B;
  --up: #FF5B61; --up-bg: rgba(255, 91, 97, .13);
  --down: #2FC27A; --down-bg: rgba(47, 194, 122, .13);
  --buy: #E5484D; --buy-hover: #F15257;
  --sell: #3D7EF5; --sell-hover: #5590F7;
  --accent: #8592FF; --accent-bg: rgba(133, 146, 255, .15);
  --ok: #3CC583; --ok-bg: rgba(60, 197, 131, .14);
  --warn: #F5A623; --warn-bg: rgba(245, 166, 35, .15);
  --bad: #FF5257; --bad-bg: rgba(255, 82, 87, .15);
  --info: #5AA2FF; --info-bg: rgba(90, 162, 255, .14);
  --shadow: 0 12px 40px rgba(0, 0, 0, .5);
  --overlay: rgba(4, 7, 11, .66);
  color-scheme: dark;
}
/* ---------- 浅色 ---------- */
:root[data-theme="light"] {
  --bg: #EEF1F5; --bg-2: #E8ECF1;
  --panel: #FFFFFF; --panel-2: #F5F7FA; --panel-3: #EBEFF4;
  --line: #E0E5EC; --line-2: #CDD5DF;
  --text: #111822; --text-2: #4A5565; --text-3: #8490A0;
  --up: #D92B33; --up-bg: rgba(217, 43, 51, .09);
  --down: #0A9455; --down-bg: rgba(10, 148, 85, .09);
  --buy: #D92B33; --buy-hover: #E5373F;
  --sell: #2462E8; --sell-hover: #3471F0;
  --accent: #4B57D1; --accent-bg: rgba(75, 87, 209, .10);
  --ok: #0F8F55; --ok-bg: rgba(15, 143, 85, .10);
  --warn: #B26A00; --warn-bg: rgba(229, 145, 0, .13);
  --bad: #D92B33; --bad-bg: rgba(217, 43, 51, .09);
  --info: #1E6BE0; --info-bg: rgba(30, 107, 224, .09);
  --shadow: 0 12px 36px rgba(20, 30, 45, .18);
  --overlay: rgba(20, 26, 36, .45);
  color-scheme: light;
}
/* 涨绿跌红（有人习惯反过来） */
:root[data-updown="green-up"][data-theme="dark"] { --up: #2FC27A; --up-bg: rgba(47,194,122,.13); --down: #FF5B61; --down-bg: rgba(255,91,97,.13); }
:root[data-updown="green-up"][data-theme="light"] { --up: #0A9455; --up-bg: rgba(10,148,85,.09); --down: #D92B33; --down-bg: rgba(217,43,51,.09); }

/* ---------- 演练 / 真账户：顶栏和外框颜色完全不同 ---------- */
:root[data-env="sim"]  { --env-1: #3F3AB0; --env-2: #2A2683; --env-ink: #FFFFFF; --env-soft: #CFCCFF; --env-frame: #6B66F0; }
:root[data-env="real"] { --env-1: #C25E07; --env-2: #8F3E02; --env-ink: #FFFFFF; --env-soft: #FFE0A6; --env-frame: #F59E0B; }

body {
  margin: 0; background: var(--bg); color: var(--text);
  font-family: var(--font); font-size: 1rem; line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}
/* 整个窗口一圈细边，演练是紫色、真账户是橙色 */
body::after {
  content: ""; position: fixed; inset: 0; pointer-events: none; z-index: 900;
  border: 3px solid var(--env-frame); opacity: .9;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
h1, h2, h3, h4 { margin: 0; font-weight: 600; }
p { margin: 0; }
a { color: var(--accent); }
[hidden] { display: none !important; }

.num { font-family: var(--numfont); font-variant-numeric: tabular-nums; letter-spacing: -.01em; }
.up { color: var(--up); }
.down { color: var(--down); }
.flat { color: var(--text-2); }
.muted { color: var(--text-3); }
.dim { color: var(--text-2); }
.t-xs { font-size: .75rem; }
.t-sm { font-size: .857rem; }
.t-lg { font-size: 1.15rem; }
.t-xl { font-size: 1.45rem; }
.t-2xl { font-size: 1.9rem; }
.t-3xl { font-size: 2.35rem; }
.b { font-weight: 600; }
.nowrap { white-space: nowrap; }
.grow { flex: 1 1 auto; min-width: 0; }
.row { display: flex; align-items: center; gap: 8px; min-width: 0; }
.row.wrap { flex-wrap: wrap; }
.col { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.sp { flex: 1 1 auto; }
.ic { width: 1.15em; height: 1.15em; flex: none; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; vertical-align: -.2em; }
.ic.fill { fill: currentColor; stroke: none; }
.ic-lg { width: 1.5em; height: 1.5em; }

/* ---------- 面板 ---------- */
.panel {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--r-lg);
  min-width: 0; position: relative;
}
.ph {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 11px 14px; border-bottom: 1px solid var(--line); min-height: 46px;
}
.ph h2 { font-size: 1.07rem; }
.ph .sub { color: var(--text-3); font-size: .857rem; }
.pb { padding: 12px 14px; }
.sec-title { font-size: .8rem; color: var(--text-3); font-weight: 600; letter-spacing: .02em; margin: 2px 0 8px; }

/* ---------- 按钮 ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 1px solid var(--line-2); background: var(--panel-2); color: var(--text);
  border-radius: var(--r-sm); padding: 6px 12px; min-height: 32px; font-size: .93rem;
  white-space: nowrap; transition: background .12s, border-color .12s, transform .05s;
}
.btn:hover { background: var(--panel-3); }
.btn:active { transform: translateY(1px); }
.btn:disabled, .btn.is-disabled { opacity: .45; cursor: not-allowed; transform: none; }
.btn:focus-visible, .chip-btn:focus-visible, .seg button:focus-visible, .tab:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.btn-sm { min-height: 26px; padding: 3px 9px; font-size: .82rem; }
.btn-lg { min-height: 42px; padding: 8px 18px; font-size: 1.05rem; font-weight: 600; border-radius: var(--r); }
.btn-xl { min-height: 54px; padding: 10px 22px; font-size: 1.2rem; font-weight: 700; border-radius: var(--r); width: 100%; }
.btn-buy { background: var(--buy); border-color: var(--buy); color: #fff; }
.btn-buy:hover { background: var(--buy-hover); }
.btn-sell { background: var(--sell); border-color: var(--sell); color: #fff; }
.btn-sell:hover { background: var(--sell-hover); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { filter: brightness(1.08); background: var(--accent); }
.btn-danger { background: var(--bad); border-color: var(--bad); color: #fff; }
.btn-danger:hover { filter: brightness(1.08); background: var(--bad); }
.btn-danger-o { background: transparent; border-color: var(--bad); color: var(--bad); }
.btn-danger-o:hover { background: var(--bad-bg); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--text-2); }
.btn-ghost:hover { background: var(--panel-2); color: var(--text); }
.btn-ok { background: var(--ok); border-color: var(--ok); color: #fff; }
.btn .kbd, .kbd {
  display: inline-flex; align-items: center; justify-content: center; min-width: 1.6em;
  padding: 0 .4em; height: 1.45em; border-radius: 4px; font-size: .78em; font-weight: 600;
  font-family: var(--numfont); border: 1px solid currentColor; opacity: .85; line-height: 1;
}
.kbd.solid { background: var(--panel-3); border-color: var(--line-2); color: var(--text-2); opacity: 1; }

/* ---------- 小标签 ---------- */
.chip {
  display: inline-flex; align-items: center; gap: 4px; white-space: nowrap;
  padding: 1px 8px; border-radius: 999px; font-size: .78rem; font-weight: 600; line-height: 1.6;
  background: var(--panel-3); color: var(--text-2);
}
.chip .ic { width: 1em; height: 1em; }
.chip.ok { background: var(--ok-bg); color: var(--ok); }
.chip.warn { background: var(--warn-bg); color: var(--warn); }
.chip.bad { background: var(--bad-bg); color: var(--bad); }
.chip.info { background: var(--info-bg); color: var(--info); }
.chip.acc { background: var(--accent-bg); color: var(--accent); }
.chip.up { background: var(--up-bg); color: var(--up); }
.chip.down { background: var(--down-bg); color: var(--down); }
.chip.solid-bad { background: var(--bad); color: #fff; }
.chip.solid-warn { background: var(--warn); color: #1a1205; }
.chip.outline { background: transparent; border: 1px solid var(--line-2); }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; flex: none; background: var(--text-3); }
.dot.ok { background: var(--ok); }
.dot.warn { background: var(--warn); }
.dot.bad { background: var(--bad); }
.dot.pulse { animation: pulse 1.6s infinite; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 currentColor; } 70% { box-shadow: 0 0 0 6px transparent; } 100% { box-shadow: 0 0 0 0 transparent; } }

/* 可点的小标签按钮 */
.chip-btn {
  border: 1px solid var(--line-2); background: var(--panel-2); color: var(--text-2);
  border-radius: 999px; padding: 3px 11px; font-size: .85rem; white-space: nowrap;
}
.chip-btn:hover { color: var(--text); border-color: var(--text-3); }
.chip-btn.on { background: var(--accent-bg); border-color: var(--accent); color: var(--accent); font-weight: 600; }

/* ---------- 分段选择 ---------- */
.seg { display: inline-flex; flex-wrap: wrap; gap: 4px; padding: 3px; background: var(--panel-2); border: 1px solid var(--line); border-radius: var(--r); max-width: 100%; }
.seg button {
  border: 0; background: transparent; color: var(--text-2); padding: 5px 11px; border-radius: 7px;
  font-size: .9rem; white-space: nowrap; min-height: 30px;
}
.seg button:hover { color: var(--text); }
.seg button.on { background: var(--panel); color: var(--text); font-weight: 600; box-shadow: 0 1px 3px rgba(0,0,0,.25); }
.seg.buy button.on { background: var(--buy); color: #fff; }
.seg.sell button.on { background: var(--sell); color: #fff; }
.seg button small { display: block; font-size: .72rem; opacity: .75; font-weight: 400; }
.seg button:disabled { opacity: .4; cursor: not-allowed; }

/* ---------- 开关 ---------- */
.sw { position: relative; display: inline-flex; align-items: center; gap: 8px; cursor: pointer; user-select: none; }
.sw input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.sw .track { width: 38px; height: 22px; border-radius: 999px; background: var(--line-2); position: relative; transition: background .15s; flex: none; }
.sw .track::after { content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: transform .15s; box-shadow: 0 1px 2px rgba(0,0,0,.3); }
.sw input:checked + .track { background: var(--ok); }
.sw input:checked + .track::after { transform: translateX(16px); }
.sw.danger input:checked + .track { background: var(--bad); }
.sw input:focus-visible + .track { outline: 2px solid var(--accent); outline-offset: 2px; }
.sw input:disabled + .track { opacity: .4; }
.sw.is-locked { cursor: not-allowed; }

/* ---------- 复选框 ---------- */
.ck { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; user-select: none; }
.ck input { width: 18px; height: 18px; accent-color: var(--accent); flex: none; margin: 0; }

/* ---------- 输入 ---------- */
.inp, .sel {
  background: var(--panel-2); border: 1px solid var(--line-2); border-radius: var(--r-sm);
  padding: 6px 10px; min-height: 34px; color: var(--text); min-width: 0; max-width: 100%;
}
.inp:focus, .sel:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: transparent; }
.inp:disabled { opacity: .55; cursor: not-allowed; }
.inp.num { text-align: right; }
.inp-unit { display: inline-flex; align-items: center; gap: 6px; }
.inp-unit .inp { width: 7.5em; }
.inp-unit.short .inp { width: 5em; }

/* ---------- 进度条 ---------- */
.meter { height: 6px; border-radius: 999px; background: var(--panel-3); overflow: hidden; position: relative; }
.meter > i { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 999px; background: var(--accent); display: block; }
.meter.ok > i { background: var(--ok); }
.meter.warn > i { background: var(--warn); }
.meter.bad > i { background: var(--bad); }
.meter.thin { height: 4px; }

/* ---------- 表格 ---------- */
.tbl-wrap { overflow-x: auto; }
.tbl { width: 100%; border-collapse: collapse; font-size: .93rem; }
.tbl th { text-align: left; font-weight: 500; color: var(--text-3); font-size: .8rem; padding: 7px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; background: var(--panel); position: sticky; top: 0; z-index: 1; }
.tbl td { padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.tbl th.r, .tbl td.r { text-align: right; }
.tbl tr.click { cursor: pointer; }
.tbl tr.click:hover td { background: var(--panel-2); }
.tbl tr.open td { background: var(--panel-2); }
.tbl tr.sub td { background: var(--bg-2); padding: 0; }
.tbl tr:last-child td { border-bottom: 0; }

/* ---------- 股票名 ---------- */
.stk { display: inline-flex; flex-direction: column; line-height: 1.25; min-width: 0; }
.stk b { font-weight: 600; white-space: nowrap; }
.stk small { color: var(--text-3); font-size: .78rem; font-family: var(--numfont); }
.stk-link { background: none; border: 0; padding: 0; text-align: left; color: inherit; cursor: pointer; }
.stk-link:hover b { color: var(--accent); text-decoration: underline; text-underline-offset: 3px; }

/* ---------- 弹窗 ---------- */
.modal-back {
  position: fixed; inset: 0; background: var(--overlay); z-index: 1000;
  display: flex; align-items: center; justify-content: center; padding: 20px;
  animation: fade .12s ease-out;
}
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.modal {
  width: min(560px, 100%); max-height: calc(100vh - 40px); overflow: auto;
  background: var(--panel); border: 1px solid var(--line-2); border-radius: 16px; box-shadow: var(--shadow);
  animation: pop .14s ease-out;
}
.modal.wide { width: min(760px, 100%); }
@keyframes pop { from { transform: translateY(8px) scale(.98); opacity: 0; } to { transform: none; opacity: 1; } }
.modal-h { display: flex; align-items: center; gap: 10px; padding: 16px 18px 12px; }
.modal-h h3 { font-size: 1.2rem; }
.modal-h .x { margin-left: auto; }
.modal.danger .modal-h { background: var(--bad-bg); border-bottom: 1px solid var(--bad); border-radius: 16px 16px 0 0; }
.modal.danger .modal-h h3 { color: var(--bad); }
.modal.warn .modal-h { background: var(--warn-bg); border-radius: 16px 16px 0 0; }
.modal.draft .modal-h { background: var(--accent-bg); border-radius: 16px 16px 0 0; }
.modal-b { padding: 14px 18px; display: flex; flex-direction: column; gap: 12px; }
.modal-f { display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap; padding: 12px 18px 18px; }
.modal-f .btn { min-width: 110px; }

/* ---------- 提示条 ---------- */
.toasts { position: fixed; right: 18px; top: calc(var(--top-h, 104px) + 12px); z-index: 1100; display: flex; flex-direction: column; gap: 8px; width: min(380px, calc(100vw - 32px)); pointer-events: none; }
.toast {
  pointer-events: auto; background: var(--panel); border: 1px solid var(--line-2); border-left: 4px solid var(--accent);
  border-radius: 10px; padding: 10px 12px; box-shadow: var(--shadow); font-size: .93rem;
  display: flex; gap: 8px; align-items: flex-start; animation: slidein .18s ease-out;
}
.toast.ok { border-left-color: var(--ok); }
.toast.warn { border-left-color: var(--warn); }
.toast.bad { border-left-color: var(--bad); }
.toast .ic { margin-top: 2px; }
.toast.ok .ic { color: var(--ok); } .toast.warn .ic { color: var(--warn); } .toast.bad .ic { color: var(--bad); }
@keyframes slidein { from { transform: translateX(16px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ---------- 弹出小框 ---------- */
.pop {
  position: fixed; z-index: 1050; background: var(--panel); border: 1px solid var(--line-2); border-radius: 12px;
  box-shadow: var(--shadow); padding: 12px 14px; width: min(360px, calc(100vw - 24px)); font-size: .93rem;
  animation: pop .12s ease-out;
}
.pop h4 { font-size: .95rem; margin-bottom: 8px; }

/* ---------- 迷你折线 ---------- */
.spark { width: 100%; height: 86px; display: block; }
.spark .area { fill: var(--accent); opacity: .12; }
.spark .line { fill: none; stroke: var(--accent); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.spark .thr { stroke: var(--warn); stroke-width: 1.5; stroke-dasharray: 5 4; }
.spark .thr-t { fill: var(--warn); font-size: 11px; font-family: var(--numfont); }
.spark .grid { stroke: var(--line); stroke-width: 1; }
.spark .hov { stroke: var(--text-3); stroke-width: 1; }
.spark .hov-dot { fill: var(--accent); stroke: var(--panel); stroke-width: 2; }
.spark-wrap { position: relative; }
.spark-hl { position: absolute; width: 1px; background: var(--text-3); pointer-events: none; }
.spark-tip {
  position: absolute; top: 0; transform: translateX(-50%); pointer-events: none;
  background: var(--panel-3); border: 1px solid var(--line-2); border-radius: 6px; padding: 2px 7px;
  font-size: .78rem; white-space: nowrap; color: var(--text);
}

/* ---------- 样稿标记 ---------- */
.sample-tag {
  position: fixed; left: 18px; bottom: 76px; z-index: 950; pointer-events: none;
  background: repeating-linear-gradient(135deg, #F5C542 0 10px, #E5B12E 10px 20px);
  color: #2A1D00; font-weight: 700; font-size: .8rem; padding: 4px 12px; border-radius: 999px;
  box-shadow: 0 4px 14px rgba(0,0,0,.35); letter-spacing: .02em;
}
.sample-inline {
  display: inline-flex; align-items: center; gap: 4px; white-space: nowrap;
  background: #F5C542; color: #2A1D00; font-weight: 700; font-size: .72rem; padding: 1px 7px; border-radius: 4px;
}

/* 倒计时圆环 */
.ring { --p: 1; --c: var(--warn); width: 52px; height: 52px; border-radius: 50%; flex: none; position: relative;
  background: conic-gradient(var(--c) calc(var(--p) * 360deg), var(--panel-3) 0); display: grid; place-items: center; }
.ring::before { content: ""; position: absolute; inset: 5px; border-radius: 50%; background: var(--panel); }
.ring b { position: relative; font-family: var(--numfont); font-size: 1.15rem; line-height: 1; }
.ring small { position: relative; display: block; font-size: .62rem; color: var(--text-3); text-align: center; margin-top: 1px; }
.ring .in { position: relative; text-align: center; }

/* 按住确认（危险操作） */
.hold-btn { position: relative; overflow: hidden; }
.hold-btn .fillbar { position: absolute; left: 0; top: 0; bottom: 0; width: 0; background: rgba(255,255,255,.25); pointer-events: none; }
.hold-btn.holding .fillbar { width: 100%; transition: width 1.2s linear; }
.hold-btn > span { position: relative; }

/* 拖动 */
.dragging { opacity: .45; }
.drag-over { outline: 2px dashed var(--accent); outline-offset: 2px; }

/* 闪一下：数值变了 */
@keyframes flashUp { 0% { background: var(--up-bg); } 100% { background: transparent; } }
@keyframes flashDown { 0% { background: var(--down-bg); } 100% { background: transparent; } }
.flash-up { animation: flashUp 1s ease-out; }
.flash-down { animation: flashDown 1s ease-out; }
@keyframes attention { 0%, 100% { box-shadow: 0 0 0 0 rgba(245, 166, 35, .0); } 50% { box-shadow: 0 0 0 4px rgba(245, 166, 35, .35); } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
