* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
body {
  margin: 0; padding: 0;
  font-family: -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif;
  background: #f5f5f7; color: #333; font-size: 15px;
}
.topbar {
  background: linear-gradient(135deg, #1e3c72, #2a5298);
  color: #fff; padding: 12px 16px;
  display: flex; justify-content: space-between; align-items: center;
  position: sticky; top: 0; z-index: 10;
}
.brand { font-size: 18px; font-weight: 600; }
.meta { font-size: 12px; opacity: 0.9; }
.tabs {
  display: flex; background: #fff; border-bottom: 1px solid #ddd;
  position: sticky; top: 48px; z-index: 9;
}
.tab {
  flex: 1; padding: 12px 0; background: none; border: none;
  font-size: 14px; color: #666; cursor: pointer; border-bottom: 3px solid transparent;
}
.tab.active { color: #1e3c72; border-bottom-color: #1e3c72; font-weight: 600; }
.page { display: none; padding: 12px; }
.page.active { display: block; }
.card {
  background: #fff; border-radius: 8px; padding: 14px;
  margin-bottom: 12px; box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}
.row {
  display: flex; justify-content: space-between; padding: 6px 0;
  border-bottom: 1px solid #f0f0f0;
}
.row:last-child { border-bottom: none; }
.k { color: #888; }
.v { font-weight: 600; }
.section-title { font-size: 14px; color: #888; margin: 14px 0 8px; }
.conds { display: flex; flex-direction: column; gap: 8px; }
.cond {
  background: #fff; border-radius: 6px; padding: 12px;
  display: flex; justify-content: space-between; align-items: center;
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}
.cond.passed { border-left: 4px solid #4caf50; }
.cond.failed { border-left: 4px solid #f44336; background: #fff0f0; }
.cond .name { font-size: 14px; }
.cond .val { font-weight: 600; }
.cond .val.pass { color: #4caf50; }
.cond .val.fail { color: #f44336; }
.cond .formula { font-size: 11px; color: #888; display: block; margin-top: 4px; }
.reason {
  margin-top: 8px; padding: 8px; background: #fff3cd; color: #856404;
  border-radius: 4px; font-size: 13px;
}
.reason.open { background: #d4edda; color: #155724; }
.phases { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; }
.phase {
  background: #fff; padding: 8px 12px; border-radius: 6px;
  display: flex; justify-content: space-between; align-items: center;
  font-size: 14px; box-shadow: 0 1px 2px rgba(0,0,0,0.04);
}
.phase .arrow { color: #aaa; margin: 0 4px; }
.phase .count { font-weight: 600; color: #1e3c72; }
.candidate {
  background: #fff; border-radius: 8px; padding: 14px; box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}
.candidate h4 { margin: 0 0 10px; color: #1e3c72; }
.detail-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 8px;
}
.detail-grid .item { padding: 4px 0; border-bottom: 1px solid #f0f0f0; }
.detail-grid .item .k { font-size: 12px; }
.detail-grid .item .v { font-size: 14px; }
.rules { margin-top: 12px; }
.rule-item {
  display: flex; justify-content: space-between; padding: 6px 0;
  border-bottom: 1px solid #f0f0f0; font-size: 13px;
}
.rule-item .check { font-weight: 600; }
.rule-item .check.yes { color: #4caf50; }
.rule-item .check.no { color: #f44336; }
.no-candidate {
  text-align: center; padding: 30px; color: #888; background: #fff;
  border-radius: 8px; margin-top: 12px;
}
.btn-primary {
  background: #1e3c72; color: #fff; border: none; padding: 12px 16px;
  border-radius: 6px; font-size: 14px; cursor: pointer; width: 100%;
  margin-bottom: 12px;
}
.btn-link {
  background: none; color: #666; border: 1px solid #ddd;
  padding: 10px 16px; border-radius: 6px; width: 100%; margin-top: 8px;
}
.form {
  background: #fff; padding: 12px; border-radius: 8px; margin-bottom: 12px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}
.form label {
  display: block; margin-bottom: 8px; font-size: 12px; color: #666;
}
.form input {
  display: block; width: 100%; padding: 8px; border: 1px solid #ddd;
  border-radius: 4px; font-size: 14px; margin-top: 4px;
}
.pos-item {
  background: #fff; border-radius: 8px; padding: 12px; margin-bottom: 10px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}
.pos-item .pos-head { display: flex; justify-content: space-between; margin-bottom: 8px; }
.pos-item .pos-code { font-weight: 600; color: #1e3c72; }
.pos-item .pnl { font-weight: 700; }
.pos-item .pnl.up { color: #f44336; }
.pos-item .pnl.down { color: #4caf50; }
.pos-item .rule-badge {
  display: inline-block; background: #ffebee; color: #c62828;
  padding: 2px 8px; border-radius: 4px; font-size: 11px; margin-right: 4px;
}
.hist-list { display: flex; flex-direction: column; gap: 8px; }
.hist-item {
  background: #fff; padding: 12px; border-radius: 6px;
  box-shadow: 0 1px 2px rgba(0,0,0,0.04);
  font-size: 13px;
}
.hist-item .hist-date { font-weight: 600; color: #1e3c72; }
.hist-item .hist-row { display: flex; justify-content: space-between; margin-top: 4px; }
.hist-item .badge-open { background: #d4edda; color: #155724; padding: 1px 6px; border-radius: 4px; }
.hist-item .badge-close { background: #f8d7da; color: #721c24; padding: 1px 6px; border-radius: 4px; }
.loading {
  position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%);
  background: rgba(0,0,0,0.7); color: #fff; padding: 8px 16px;
  border-radius: 20px; display: none; z-index: 100;
}
.loading.show { display: block; }
/* 14:50 正式结果显著卡片 */
.final-card {
  padding: 16px; border-radius: 8px; text-align: center;
  border-left: 6px solid #888; background: #f5f5f7;
}
.final-card.open { border-left-color: #4caf50; background: #d4edda; }
.final-card.close { border-left-color: #f44336; background: #ffebee; }
.final-card.scanning { border-left-color: #2196f3; background: #e3f2fd; }
.final-card.pending { border-left-color: #9e9e9e; background: #f5f5f7; }
.final-card .final-badge {
  display: inline-block; background: #1e3c72; color: #fff;
  padding: 2px 10px; border-radius: 4px; font-size: 11px; margin-bottom: 6px;
}
.final-card .final-badge.draft { background: #757575; }
.final-card .final-signal { font-size: 18px; font-weight: 700; margin: 6px 0; }
.final-card.open .final-signal { color: #2e7d32; }
.final-card.close .final-signal { color: #c62828; }
.final-card .final-meta { font-size: 12px; color: #666; }
.final-card .final-reason { font-size: 12px; color: #666; margin-top: 4px; }

/* 调试状态区（真机可见，不显示 Token 明文） */
.debug-status {
  background: #fff; border-bottom: 1px solid #eee;
  padding: 8px 14px; font-size: 12px;
}
.ds-row { display: flex; justify-content: space-between; padding: 2px 0; }
.ds-k { color: #888; }
.ds-v { color: #333; font-weight: 500; }
.ds-v.ok { color: #2e7d32; }
.ds-v.fail { color: #c62828; }

/* Token 未配置错误提示 */
.token-error {
  background: #fff3e0; border-bottom: 1px solid #ffe0b2;
  padding: 14px 16px; color: #c62828; font-size: 15px;
}
