:root {
  --bg: #f4f5f7;
  --panel: #ffffff;
  --line: #e3e6ea;
  --text: #1d2129;
  --muted: #86909c;
  --up: #e03131;
  --down: #2b8a3e;
  --red-line: #d9230f;
  --black-line: #111111;
  --mine: #1c6fd6;
  --accent: #1c6fd6;
  --warn-bg: #fff4e5;
  --warn: #b25e00;
  --bad: #c92a2a;
  --ok: #2b8a3e;
  --radius: 8px;
  font-family: -apple-system, "PingFang SC", "Microsoft YaHei", "Hiragino Sans GB", "Noto Sans CJK SC", sans-serif;
  color-scheme: light;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); font-size: 14px; }
button, input, select, textarea { font: inherit; color: inherit; }
button {
  border: 1px solid var(--line); background: var(--panel); border-radius: 6px; padding: 5px 10px;
  cursor: pointer; white-space: nowrap;
}
button:hover { border-color: #c4c9d0; }
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
button.danger { color: var(--bad); border-color: #f1c0c0; }
button.ghost { border-color: transparent; background: transparent; color: var(--muted); }
button.warn { background: var(--warn-bg); border-color: #ffd8a8; color: var(--warn); }
button.on-state { background: #e7f5ff; border-color: #a5d8ff; color: var(--accent); }
input, select, textarea {
  border: 1px solid var(--line); border-radius: 6px; padding: 5px 8px; background: #fff; min-width: 0;
}
textarea { width: 100%; resize: vertical; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.err { color: var(--bad); font-size: 12px; min-height: 0; }
.red { color: var(--red-line); font-weight: 600; }
.blue { color: var(--mine); font-weight: 600; }
.up { color: var(--up); }
.down { color: var(--down); }

/* 登录 */
.login { display: flex; align-items: center; justify-content: center; min-height: 100%; padding: 16px; }
.login-card {
  width: 100%; max-width: 340px; background: var(--panel); border: 1px solid var(--line);
  border-radius: 12px; padding: 28px 24px; display: flex; flex-direction: column; gap: 10px;
}
.login-title { font-size: 22px; font-weight: 700; }
.login-sub { color: var(--muted); margin-bottom: 8px; }
.login-card input { padding: 9px 10px; }
.login-card button { padding: 9px; }

/* 顶栏 */
.top {
  display: flex; align-items: center; gap: 14px; padding: 8px 14px; background: var(--panel);
  border-bottom: 1px solid var(--line); flex-wrap: wrap;
}
.brand { font-weight: 700; font-size: 16px; }
.brand-sub { color: var(--muted); font-weight: 400; font-size: 12px; margin-left: 6px; }
.agent { display: flex; align-items: center; gap: 6px; color: #4e5969; }
.avatar {
  width: 24px; height: 24px; border-radius: 50%; background: #1d2129; color: #fff; display: inline-flex;
  align-items: center; justify-content: center; font-size: 12px; flex: none;
}
.agent.live .avatar { box-shadow: 0 0 0 3px rgba(43, 138, 62, .25); background: var(--ok); }
.data-status { font-size: 12px; color: var(--muted); }
.data-status.bad { color: #fff; background: var(--bad); padding: 2px 8px; border-radius: 4px; }
.actions { margin-left: auto; display: flex; gap: 6px; flex-wrap: wrap; }

/* 盯盘状态条：只在行情断了或后台卡住时出现 */
.radar {
  display: flex; align-items: center; gap: 8px; padding: 5px 14px; font-size: 12px; color: #4e5969;
  background: #f7f8fa; border-bottom: 1px solid var(--line); white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.radar.live { background: #ebfbee; color: #1b5e20; }
.radar.bad { background: #fff5f5; color: var(--bad); }
.radar #radar-text { overflow: hidden; text-overflow: ellipsis; }
.beat { width: 8px; height: 8px; border-radius: 50%; background: #adb5bd; flex: none; }
.radar.live .beat { background: var(--ok); animation: beat 1.2s ease-out infinite; }
.radar.bad .beat { background: var(--bad); }
@keyframes beat { 0% { box-shadow: 0 0 0 0 rgba(43, 138, 62, .55); } 100% { box-shadow: 0 0 0 9px rgba(43, 138, 62, 0); } }
.radar .hit { color: var(--warn); font-weight: 600; }
.flash-up { animation: fu 1s ease-out; }
.flash-down { animation: fd 1s ease-out; }
@keyframes fu { 0% { background: rgba(224, 49, 49, .28); } 100% { background: transparent; } }
@keyframes fd { 0% { background: rgba(43, 138, 62, .28); } 100% { background: transparent; } }

/* 三栏 */
#app { height: 100%; display: flex; flex-direction: column; }
.pool-scroll { overflow: auto; flex: 1; min-height: 0; }
.sub-head { border-top: 1px solid var(--line); background: #fafbfc; }
.grid { display: grid; grid-template-columns: 280px minmax(0, 1fr) 320px; gap: 10px; padding: 10px; flex: 1; min-height: 0; }
.left, .right, .center { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); min-height: 0; }
.left, .right { display: flex; flex-direction: column; overflow: hidden; }
.center { overflow: auto; padding: 12px 14px; }
.panel-head { display: flex; align-items: center; gap: 8px; padding: 10px 12px; border-bottom: 1px solid var(--line); }
.panel-head .small-btn { margin-left: auto; }
.small-btn { padding: 3px 8px; font-size: 12px; }
.add-box { padding: 10px 12px; border-bottom: 1px solid var(--line); display: flex; flex-direction: column; gap: 6px; }

.pool { list-style: none; margin: 0; padding: 0; }
.pool li {
  display: grid; grid-template-columns: 1fr auto; gap: 2px 8px; padding: 8px 12px; border-bottom: 1px solid #f0f2f5;
  cursor: pointer; position: relative;
}
.pool li:hover { background: #f7f8fa; }
.pool li.sel { background: #e8f3ff; }
.pool .nm { font-weight: 600; }
.pool .cd { color: var(--muted); font-size: 12px; margin-left: 4px; font-weight: 400; }
.pool .px { text-align: right; font-variant-numeric: tabular-nums; }
.pool .st { font-size: 12px; color: #4e5969; }
.pool .nr { font-size: 12px; text-align: right; color: var(--muted); font-variant-numeric: tabular-nums; }
.pool .nr.hot { color: var(--warn); font-weight: 600; }
.pool .dot {
  position: absolute; left: 3px; top: 13px; width: 6px; height: 6px; border-radius: 50%; background: var(--up);
}
.pool-empty { padding: 16px 12px; color: var(--muted); font-size: 13px; }

.tag { display: inline-block; font-size: 12px; padding: 0 6px; border-radius: 4px; line-height: 18px; border: 1px solid; }
.tag.c-up { color: #1d2129; border-color: #1d2129; }
.tag.c-down { color: var(--red-line); border-color: var(--red-line); }
.tag.c-mid { color: var(--muted); border-color: #c9cdd4; }

/* 中间 */
.empty { padding: 80px 20px; text-align: center; }
.empty-title { font-size: 18px; margin-bottom: 6px; }
.stock-head { display: flex; align-items: baseline; gap: 14px; flex-wrap: wrap; margin-bottom: 8px; }
.s-title { font-size: 18px; font-weight: 700; display: flex; gap: 8px; align-items: baseline; }
.s-title .muted { font-size: 13px; font-weight: 400; }
.s-price { font-size: 18px; font-variant-numeric: tabular-nums; }
.s-price small { font-size: 12px; margin-left: 6px; color: var(--muted); }
.s-state { font-size: 13px; }
.range { margin-left: auto; display: flex; gap: 4px; align-items: center; flex-wrap: wrap; }
.range button { padding: 2px 8px; font-size: 12px; }
.range button.on { background: #1d2129; color: #fff; border-color: #1d2129; }
.chk { display: inline-flex; gap: 4px; align-items: center; font-size: 12px; color: #4e5969; }

.chart-wrap { position: relative; border: 1px solid var(--line); border-radius: 6px; background: #fff; }
#chart { display: block; width: 100%; height: 440px; cursor: crosshair; touch-action: pan-y; }
.tip {
  position: absolute; left: 8px; top: 6px; background: rgba(255, 255, 255, .92); border: 1px solid var(--line);
  border-radius: 4px; padding: 3px 8px; font-size: 12px; pointer-events: none; font-variant-numeric: tabular-nums;
}
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12px; color: #4e5969; margin: 8px 0 0; }
.lg { display: inline-block; width: 18px; height: 5px; vertical-align: middle; margin-right: 4px; }
.lg-red { border-top: 1.5px solid var(--red-line); border-bottom: 1.5px solid var(--red-line); }
.lg-black { border-top: 1.5px solid var(--black-line); border-bottom: 1.5px solid var(--black-line); }
.lg-mine { height: 2px; background: var(--mine); }
.lg-round { height: 0; border-top: 2px dashed #e8590c; }
.summary { background: #f7f8fa; border-radius: 6px; padding: 8px 10px; margin: 10px 0; line-height: 1.7; }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-top: 6px; }
.tabs button { border: none; border-bottom: 2px solid transparent; border-radius: 0; background: none; padding: 6px 12px; }
.tabs button.on { border-bottom-color: var(--accent); color: var(--accent); font-weight: 600; }
.tab { padding: 10px 0; }

.line-form { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 4px; }
.line-form input#line-price { width: 100px; }
.line-form input#line-note { width: 160px; }
.tbl { width: 100%; border-collapse: collapse; margin-top: 6px; font-size: 13px; }
.tbl th, .tbl td { text-align: left; padding: 6px 8px; border-bottom: 1px solid #f0f2f5; white-space: nowrap; }
.tbl th { color: var(--muted); font-weight: 400; font-size: 12px; }
.tbl td.num { font-variant-numeric: tabular-nums; }
.sw { display: inline-block; width: 16px; height: 6px; vertical-align: middle; margin-right: 6px; }
.sw.red { border-top: 1.5px solid var(--red-line); border-bottom: 1.5px solid var(--red-line); }
.sw.black { border-top: 1.5px solid var(--black-line); border-bottom: 1.5px solid var(--black-line); }
.sw.mine { height: 2px; background: var(--mine); }
.sw.round { height: 0; border-top: 2px dashed #e8590c; }
.zone { font-size: 12px; padding: 0 6px; border-radius: 4px; }
.zone.far { color: var(--muted); }
.zone.near { background: var(--warn-bg); color: var(--warn); }
.zone.over { background: #fff0f6; color: #a61e4d; }
.zone.conf { background: #e6fcf5; color: #087f5b; }

.book-wrap { overflow-x: auto; }
.book { border-collapse: collapse; font-size: 12px; font-variant-numeric: tabular-nums; min-width: 620px; }
.book th, .book td { border: 1px solid var(--line); padding: 3px 8px; text-align: right; }
.book th { background: #f7f8fa; font-weight: 600; text-align: center; }
.book td.d { text-align: left; color: var(--muted); }
.book td.ink-black { color: #000; font-weight: 600; }
.book td.ink-red { color: var(--red-line); font-weight: 600; }
.book td.ink-pencil { color: #7a828c; }
.book td.u-red { border-bottom: 4px double var(--red-line); }
.book td.u-black { border-bottom: 4px double var(--black-line); }
.events { margin-top: 10px; font-size: 12px; color: #4e5969; line-height: 1.8; }

.params { display: flex; flex-direction: column; gap: 10px; max-width: 560px; }
.params label { display: block; }
.params input[inputmode] { width: 70px; margin: 0 4px; }
.params .hint { display: block; color: var(--muted); font-size: 12px; margin-top: 2px; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

/* 提醒 */
.alerts { list-style: none; margin: 0; padding: 0; overflow: auto; flex: 1; }
.alerts li { padding: 8px 12px; border-bottom: 1px solid #f0f2f5; cursor: pointer; }
.alerts li.unread { background: #fffbf2; }
.alerts li.important { border-left: 3px solid var(--up); }
.alerts .meta { display: flex; gap: 6px; font-size: 12px; color: var(--muted); align-items: center; }
.alerts .meta b { color: var(--text); }
.alerts .who { margin-left: auto; }
.alerts .txt { margin: 3px 0; line-height: 1.5; }
.alerts .fb { display: flex; gap: 6px; }
.alerts .fb button { padding: 1px 8px; font-size: 12px; }
.alerts .fb .chosen { background: #1d2129; color: #fff; border-color: #1d2129; }
.badge { background: var(--up); color: #fff; border-radius: 10px; padding: 0 7px; font-size: 12px; }
.feedback { border-top: 1px solid var(--line); padding: 10px 12px; display: flex; flex-direction: column; gap: 6px; }
.feedback button { align-self: flex-start; }

.toasts { position: fixed; right: 16px; bottom: 16px; display: flex; flex-direction: column; gap: 8px; z-index: 50; max-width: 360px; }
.toast {
  background: #1d2129; color: #fff; border-radius: 8px; padding: 10px 12px; box-shadow: 0 6px 20px rgba(0, 0, 0, .2);
  line-height: 1.5; cursor: pointer;
}
.toast.important { background: var(--up); }
.toast .t1 { font-size: 12px; opacity: .85; }

.dlg { border: 1px solid var(--line); border-radius: 12px; max-width: 640px; width: calc(100% - 32px); padding: 18px 22px; }
.dlg::backdrop { background: rgba(0, 0, 0, .3); }
.dlg h3 { margin-top: 0; }
.dlg li { margin-bottom: 6px; line-height: 1.6; }
.dlg hr { border: none; border-top: 1px solid var(--line); margin: 14px 0; }

@media (max-width: 1100px) {
  #app { height: auto; }
  .grid { grid-template-columns: 240px minmax(0, 1fr); flex: none; }
  .right { grid-column: 1 / -1; max-height: 420px; }
}
@media (max-width: 720px) {
  .grid { grid-template-columns: minmax(0, 1fr); padding: 8px; }
  .left { max-height: 320px; }
  #chart { height: 340px; }
  .actions { margin-left: 0; }
  .range { margin-left: 0; }
}

.pool .rm {
  position: absolute; right: 4px; top: 50%; transform: translateY(-50%); width: 20px; height: 20px; padding: 0;
  border-radius: 50%; line-height: 18px; font-size: 13px; color: var(--muted); background: #fff; display: none;
}
.pool li:hover .rm { display: block; }
.pool li:hover .px, .pool li:hover .nr { padding-right: 18px; }
.pool .rm:hover { color: var(--bad); border-color: var(--bad); }
@media (hover: none) { .pool .rm { display: block; } .pool .px, .pool .nr { padding-right: 18px; } }
.tag.c-grp { color: var(--accent); border-color: #a5d8ff; }
.s-leaders { width: 100%; font-size: 12px; color: #4e5969; display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.s-leaders .warn-txt { color: var(--warn); font-weight: 600; }
.ratio-wrap { border: 1px solid var(--line); border-radius: 6px; margin: 6px 0; }
#ratio-chart { display: block; width: 100%; height: 130px; }
.weak-y { color: var(--bad); font-weight: 600; }
.weak-n { color: var(--ok); }
.dlg-wide { max-width: 820px; }
.rules li { margin-bottom: 8px; }
.rules ul { margin: 4px 0 0; padding-left: 18px; }
.rules ul li { margin-bottom: 3px; }


/* 工具之间的切换（关键点盯盘 / AI 选股） */
.tool-nav { display: flex; gap: 4px; }
.tool-nav a { padding: 4px 10px; border-radius: 6px; color: #4e5969; text-decoration: none; border: 1px solid transparent; }
.tool-nav a:hover { background: #f2f3f5; }
.tool-nav a.on { background: #e8f3ff; color: var(--accent); border-color: #bedaff; font-weight: 600; }
.s-ask { margin-left: 6px; font-size: 12px; font-weight: 500; color: var(--accent); text-decoration: none; white-space: nowrap; }
.s-ask:hover { text-decoration: underline; }
