/* ========== 基础 ========== */
* { margin: 0; padding: 0; box-sizing: border-box; }
:root {
  --bg: #f4f6f9;
  --card: #ffffff;
  --border: #e8ecf2;
  --text: #1f2733;
  --text-sub: #7a8699;
  --primary: #c9483a;
  --primary-dark: #a8382c;
  --green: #e0433a;   /* 涨-红 */
  --fall: #17a866;    /* 跌-绿 */
  --accent: #e8f0fe;
  --shadow: 0 2px 12px rgba(30,45,80,.06);
}
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
               "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
}
.hidden { display: none !important; }
.app { max-width: 1600px; margin: 0 auto; padding: 0 22px 30px; }

/* ========== 顶部栏 ========== */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 4px 16px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 18px;
}
.brand { display: flex; align-items: center; gap: 13px; }
.brand-icon {
  width: 46px; height: 46px; border-radius: 12px;
  background: linear-gradient(135deg, #d9534f, #a8382c);
  display: flex; align-items: center; justify-content: center;
  font-size: 24px; box-shadow: 0 4px 14px rgba(201,72,58,.3);
}
.brand h1 { font-size: 21px; letter-spacing: .5px; }
.brand-sub { font-size: 13px; color: var(--text-sub); font-weight: 400; margin-left: 8px; }
.brand-desc { font-size: 12px; color: var(--text-sub); margin-top: 2px; }
.topbar-right { display: flex; align-items: center; gap: 18px; }
.update-info { font-size: 12px; color: var(--text-sub); display: flex; align-items: center; gap: 7px; }
.dot { width: 7px; height: 7px; border-radius: 50%; background: #2eb872; box-shadow: 0 0 0 3px rgba(46,184,114,.15); }

/* ========== 按钮 ========== */
.btn {
  border: none; border-radius: 8px; padding: 9px 16px;
  font-size: 13px; cursor: pointer; font-weight: 500;
  transition: all .15s; display: inline-flex; align-items: center; gap: 6px;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn:disabled { opacity: .6; cursor: not-allowed; }
.btn-icon { font-size: 15px; }
.btn-block { width: 100%; justify-content: center; background: var(--primary); color: #fff; padding: 11px; margin-top: 8px; font-size: 14px; }
.btn-block:hover { background: var(--primary-dark); }
.btn-sm { padding: 6px 11px; font-size: 12px; }
.btn-outline { background: #fff; border: 1px solid var(--border); color: var(--text); }
.btn-outline:hover { border-color: var(--primary); color: var(--primary); }

/* ========== 进度条 ========== */
.progress-bar { background: var(--card); border: 1px solid var(--border); border-radius: 10px; padding: 12px 16px; margin-bottom: 16px; box-shadow: var(--shadow); }
.progress-info { display: flex; justify-content: space-between; font-size: 12px; color: var(--text-sub); margin-bottom: 8px; }
.progress-track { height: 6px; background: #eef1f5; border-radius: 4px; overflow: hidden; }
.progress-fill { height: 100%; background: linear-gradient(90deg, #e0a23c, var(--primary)); width: 0%; transition: width .3s; border-radius: 4px; }

/* ========== 主布局 ========== */
.main { display: grid; grid-template-columns: 268px 1fr; gap: 18px; align-items: start; }

/* ========== 参数面板 ========== */
.panel { background: var(--card); border-radius: 12px; border: 1px solid var(--border); box-shadow: var(--shadow); }
.params-panel { padding: 18px; position: sticky; top: 18px; }
.panel-title { display: flex; justify-content: space-between; align-items: center; font-size: 15px; font-weight: 600; padding-bottom: 14px; border-bottom: 1px solid var(--border); margin-bottom: 14px; }
.reset-link { background: none; border: none; color: var(--primary); font-size: 12px; cursor: pointer; }
.preset-row { display: flex; gap: 6px; margin-bottom: 18px; }
.preset-btn { flex: 1; padding: 7px 0; border: 1px solid var(--border); background: #fafbfc; border-radius: 7px; font-size: 13px; cursor: pointer; color: var(--text-sub); transition: all .15s; }
.preset-btn:hover { border-color: var(--primary); }
.preset-btn.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.param-group { margin-bottom: 17px; }
.param-group > label { display: flex; justify-content: space-between; font-size: 13px; font-weight: 500; margin-bottom: 7px; }
.param-group .val { color: var(--primary); font-weight: 600; }
.param-group .hint { color: var(--text-sub); font-weight: 400; }
.param-desc { font-size: 11px; color: var(--text-sub); margin-top: 4px; line-height: 1.4; }
.range-row { display: flex; align-items: center; gap: 8px; }
.range-row input { width: 100%; min-width: 0; }
.range-sep { color: var(--text-sub); }
input[type=number] { border: 1px solid var(--border); border-radius: 7px; padding: 7px 9px; font-size: 13px; width: 100%; outline: none; }
input[type=number]:focus { border-color: var(--primary); }
input[type=range] { width: 100%; accent-color: var(--primary); cursor: pointer; height: 4px; }
.checkbox-group { display: flex; flex-direction: column; gap: 9px; margin-top: 20px; }
.chk { display: flex !important; align-items: center; gap: 7px; font-size: 12px; font-weight: 400 !important; cursor: pointer; color: var(--text-sub); }
.chk input { accent-color: var(--primary); cursor: pointer; }

/* ========== 统计卡片 ========== */
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 16px; }
.stat-card { background: var(--card); border: 1px solid var(--border); border-radius: 11px; padding: 15px 18px; box-shadow: var(--shadow); position: relative; overflow: hidden; }
.stat-card.accent { background: linear-gradient(135deg, #fff8f7, #fff); border-color: #f3d5d0; }
.stat-label { font-size: 12px; color: var(--text-sub); margin-bottom: 6px; }
.stat-value { font-size: 27px; font-weight: 700; color: var(--text); line-height: 1; }
.stat-card.accent .stat-value { color: var(--primary); }
.stat-foot { font-size: 11px; color: var(--text-sub); margin-top: 5px; }

/* ========== 策略提示 ========== */
.strategy-tip { background: #fffdf5; border: 1px solid #f2e6c0; border-radius: 10px; padding: 12px 16px; margin-bottom: 16px; font-size: 12px; line-height: 1.7; color: #6b6438; display: flex; gap: 10px; }
.strategy-tip strong { color: #8a6d1f; }
.tip-icon { font-size: 17px; flex-shrink: 0; }

/* ========== 表格卡片 ========== */
.table-card { background: var(--card); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow); overflow: hidden; }
.table-toolbar { display: flex; justify-content: space-between; align-items: center; padding: 14px 18px; border-bottom: 1px solid var(--border); }
.table-title { font-size: 15px; font-weight: 600; display: flex; align-items: center; gap: 8px; }
.badge { background: var(--primary); color: #fff; font-size: 11px; padding: 2px 8px; border-radius: 10px; font-weight: 600; }
.toolbar-right { display: flex; align-items: center; gap: 12px; }
.sort-label { font-size: 12px; color: var(--text-sub); }
.sort-label select { border: 1px solid var(--border); border-radius: 6px; padding: 5px 8px; font-size: 12px; outline: none; cursor: pointer; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
thead th { background: #fafbfc; padding: 11px 10px; text-align: left; font-weight: 600; color: var(--text-sub); font-size: 12px; white-space: nowrap; border-bottom: 1px solid var(--border); }
tbody td { padding: 10px; border-bottom: 1px solid #f2f4f7; white-space: nowrap; }
tbody tr:hover { background: #fafbfd; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.up { color: var(--green); font-weight: 600; }
.down { color: var(--fall); font-weight: 600; }
.col-star { width: 32px; text-align: center; }
.col-rank { width: 36px; color: var(--text-sub); }
.col-chart { width: 56px; text-align: center; }
.star { cursor: pointer; font-size: 15px; color: #d5dbe3; transition: color .15s; }
.star.on { color: #f0a828; }
.code-text { font-family: "SF Mono", Consolas, monospace; color: var(--text-sub); font-size: 12px; }
.name-text { font-weight: 600; }
.score-pill { display: inline-block; min-width: 38px; padding: 2px 7px; border-radius: 5px; font-weight: 700; font-size: 12px; }
.score-high { background: #fdecea; color: #c9483a; }
.score-mid { background: #fff4e0; color: #c8841f; }
.score-low { background: #eef1f5; color: #7a8699; }
.chart-btn { background: #eef3fb; color: #3b6fc4; border: none; border-radius: 5px; padding: 3px 9px; font-size: 11px; cursor: pointer; }
.chart-btn:hover { background: #dce8fa; }
.empty-row { text-align: center; color: var(--text-sub); padding: 45px 10px !important; }
.table-foot { display: flex; justify-content: space-between; align-items: center; padding: 12px 18px; font-size: 12px; color: var(--text-sub); }
.load-more { background: #fafbfc; border: 1px solid var(--border); border-radius: 6px; padding: 6px 16px; font-size: 12px; cursor: pointer; color: var(--text); }
.load-more:hover { border-color: var(--primary); color: var(--primary); }

/* ========== 页脚 ========== */
.footer { display: flex; justify-content: space-between; margin-top: 24px; padding-top: 16px; border-top: 1px solid var(--border); font-size: 11px; color: var(--text-sub); }

/* ========== 弹窗 ========== */
.modal { position: fixed; inset: 0; background: rgba(20,28,40,.55); display: flex; align-items: center; justify-content: center; z-index: 100; backdrop-filter: blur(2px); }
.modal-box { background: var(--card); border-radius: 14px; width: min(860px, 92vw); max-height: 90vh; overflow: auto; box-shadow: 0 20px 60px rgba(0,0,0,.25); }
.modal-head { display: flex; justify-content: space-between; align-items: flex-start; padding: 18px 22px; border-bottom: 1px solid var(--border); }
.modal-head h3 { font-size: 18px; }
.modal-head p { font-size: 12px; color: var(--text-sub); margin-top: 3px; }
.modal-close { background: #f2f4f7; border: none; width: 30px; height: 30px; border-radius: 7px; cursor: pointer; font-size: 14px; color: var(--text-sub); }
.modal-close:hover { background: #e8ecf2; }
.kline-chart { height: 420px; padding: 10px; }
.modal-metrics { display: flex; flex-wrap: wrap; gap: 10px; padding: 0 22px 20px; }
.metric-chip { background: #f7f9fc; border: 1px solid var(--border); border-radius: 8px; padding: 8px 12px; font-size: 12px; }
.metric-chip b { display: block; font-size: 15px; margin-top: 2px; color: var(--primary); }
.verify-content { padding: 18px 22px 24px; }
.verify-item { border: 1px solid var(--border); border-radius: 10px; padding: 14px 16px; margin-bottom: 12px; }
.verify-item h4 { font-size: 15px; margin-bottom: 10px; }
.verify-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; font-size: 12px; }
.verify-grid div { background: #f7f9fc; border-radius: 7px; padding: 8px 10px; }
.verify-grid span { color: var(--text-sub); display: block; font-size: 11px; }
.verify-grid b { font-size: 14px; }
.verify-score { display: inline-block; background: var(--primary); color: #fff; padding: 2px 10px; border-radius: 6px; font-size: 13px; margin-left: 8px; }

/* ========== 悬浮按钮 ========== */
.verify-float { position: fixed; right: 24px; bottom: 24px; width: 46px; height: 46px; border-radius: 50%; border: none; background: var(--primary); color: #fff; font-size: 19px; cursor: pointer; box-shadow: 0 6px 20px rgba(201,72,58,.4); z-index: 50; }
.verify-float:hover { background: var(--primary-dark); transform: scale(1.05); }

/* ========== 响应式 ========== */
@media (max-width: 1100px) {
  .main { grid-template-columns: 1fr; }
  .params-panel { position: static; }
  .stats { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 640px) {
  .app { padding: 0 12px 20px; }
  .topbar { flex-direction: column; gap: 14px; align-items: flex-start; }
  .stats { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .footer { flex-direction: column; gap: 6px; }
}

/* ========== 移动端专项适配 ========== */
@media (max-width: 640px) {
  .app { padding: 0 10px 20px; }
  .topbar { padding: 12px 2px; margin-bottom: 12px; flex-direction: column; align-items: stretch; gap: 12px; }
  .brand-icon { width: 40px; height: 40px; font-size: 21px; }
  .brand h1 { font-size: 18px; }
  .brand-sub { display: block; margin-left: 0; font-size: 11px; }
  .brand-desc { font-size: 11px; }
  .topbar-right { justify-content: space-between; }
  .btn-primary { flex: 0 0 auto; }
  .stats { gap: 8px; margin-bottom: 12px; }
  .stat-card { padding: 11px 12px; }
  .stat-value { font-size: 22px; }
  .stat-label { font-size: 11px; }
  .strategy-tip { font-size: 11px; padding: 10px 12px; }
  .params-panel { padding: 14px; }
  .param-group { margin-bottom: 14px; }
  .table-toolbar { flex-direction: column; align-items: flex-start; gap: 10px; padding: 12px 14px; }
  .toolbar-right { width: 100%; justify-content: space-between; }
  table { font-size: 12px; }
  thead th { padding: 9px 7px; font-size: 11px; }
  tbody td { padding: 9px 7px; }
  /* 手机上隐藏次要列，保留核心信息 */
  th:nth-child(6), td:nth-child(6),   /* 涨跌% */
  th:nth-child(9), td:nth-child(9),   /* 位置 */
  th:nth-child(11), td:nth-child(11), /* 振幅 */
  th:nth-child(12), td:nth-child(12)  /* 20日% */ { display: none; }
  .score-pill { min-width: 32px; padding: 2px 5px; }
  .chart-btn { padding: 3px 7px; }
  .modal-box { width: 96vw; max-height: 92vh; }
  .kline-chart { height: 340px; }
  .modal-metrics { padding: 0 14px 16px; gap: 8px; }
  .metric-chip { flex: 1 1 30%; }
  .verify-grid { grid-template-columns: repeat(2, 1fr); }
  .footer { font-size: 10px; }
  .verify-float { right: 16px; bottom: 16px; width: 42px; height: 42px; font-size: 17px; }
}

/* K线加载遮罩 */
.chart-container { position: relative; }
.chart-mask {
  position: absolute; inset: 0; display: none;
  align-items: center; justify-content: center;
  background: rgba(255,255,255,.85); color: #999; font-size: 14px;
  z-index: 5;
}
.chart-mask.show { display: flex; }

/* 提示气泡 */
.toast {
  position: fixed; left: 50%; bottom: 90px; transform: translateX(-50%) translateY(20px);
  background: rgba(31,39,51,.92); color: #fff; padding: 11px 22px; border-radius: 10px;
  font-size: 14px; z-index: 200; opacity: 0; pointer-events: none;
  transition: opacity .25s, transform .25s; box-shadow: 0 6px 24px rgba(0,0,0,.2);
  white-space: nowrap;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
#screenBtn.loading { opacity: .7; pointer-events: none; }
