/* ===================================================
   样式表 (style.css) - UI美化版
   优化：字体放大、颜色区分、按钮统一、手机适配
   =================================================== */

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: 'Segoe UI', 'Microsoft YaHei', sans-serif;
  background: #f0f2f5;
  color: #1e2a3a;
  padding: 6px;
  max-width: 800px;
  margin: 0 auto;
  font-size: 14px;
}

/* 头部 */
.header {
  background: #fff;
  border-radius: 16px;
  padding: 10px 12px;
  margin-bottom: 8px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.04);
}
.target-switch {
  display: flex;
  gap: 6px;
  margin-bottom: 8px;
}
.target-btn {
  flex: 1;
  padding: 10px 0;
  border: 2px solid #e2e8f0;
  background: #fff;
  border-radius: 24px;
  font-weight: 700;
  cursor: pointer;
  font-size: 0.85rem;
  text-align: center;
  transition: 0.2s;
}
.target-btn.active {
  background: #2563eb;
  color: #fff;
  border-color: #2563eb;
}
.issue-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 4px 0;
  font-size: 0.82rem;
  flex-wrap: wrap;
}
.issue-row select, .issue-row input {
  padding: 5px 8px;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  font-size: 0.82rem;
}
.action-row {
  display: flex;
  gap: 8px;
  margin-top: 6px;
}

/* 按钮通用 */
.btn {
  background: #2563eb;
  color: #fff;
  border: none;
  padding: 7px 16px;
  border-radius: 20px;
  font-weight: 600;
  cursor: pointer;
  font-size: 0.82rem;
  min-height: 36px;
  white-space: nowrap;
  transition: 0.15s;
}
.btn:hover { filter: brightness(0.92); }
.btn.small {
  padding: 6px 14px;
  font-size: 0.78rem;
  min-height: 32px;
}
.btn.mini {
  padding: 4px 10px;
  font-size: 0.73rem;
  min-height: 26px;
  border-radius: 14px;
}
.btn.danger { background: #dc2626; }
.btn.secondary { background: #64748b; }
.btn.success { background: #10b981; }
.btn.warning { background: #f59e0b; color: #1e293b; }
.btn.outline {
  background: #fff;
  color: #2563eb;
  border: 1px solid #2563eb;
}

/* 全选/全关特殊按钮 */
.btn.select-all {
  background: #dcfce7;
  color: #16a34a;
  border: 1px solid #bbf7d0;
}
.btn.deselect-all {
  background: #fee2e2;
  color: #dc2626;
  border: 1px solid #fecaca;
}

/* 卡片 */
.card {
  background: #fff;
  border-radius: 14px;
  padding: 10px 12px;
  margin-bottom: 8px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}
.card h3 {
  font-size: 0.88rem;
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  color: #1e293b;
}

/* 智能分析卡片 */
.smart-header {
  background: #f8fafc;
  padding: 10px 12px;
  border-radius: 10px;
  font-weight: 700;
  font-size: 0.88rem;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}
.collapsible {
  overflow: hidden;
  transition: max-height 0.3s ease;
}
.collapsible:not(.open) { max-height: 0; }

/* 定位胆码行 */
.danma-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 0;
  border-bottom: 1px solid #f1f5f9;
  font-size: 0.82rem;
  flex-wrap: wrap;
}
.danma-label {
  min-width: 34px;
  font-weight: 700;
  color: #2563eb;
  font-size: 0.82rem;
}
.danma-digits {
  display: flex;
  gap: 12px;
  flex: 1;
  font-family: 'Courier New', monospace;
  font-size: 0.82rem;
  color: #5b21b6;
  font-weight: 600;
}
.danma-digits span { white-space: nowrap; }

/* 信息行 */
.info-line {
  font-size: 0.82rem;
  margin: 4px 0;
}
.summary-line {
  font-weight: 700;
  font-size: 0.88rem;
  color: #1e40af;
}
.trans-line {
  color: #059669;
  font-weight: 500;
  font-size: 0.82rem;
}
.raw-follow {
  color: #475569;
  font-size: 0.8rem;
  background: #f1f5f9;
  padding: 4px 8px;
  border-radius: 6px;
  margin-top: 2px;
}
.follow-line {
  background: #fffbeb;
  color: #92400e;
  padding: 5px 10px;
  border-radius: 6px;
  font-size: 0.8rem;
  font-weight: 500;
}
.shuangfei-line {
  background: #eff6ff;
  color: #1e40af;
  padding: 5px 10px;
  border-radius: 6px;
  font-size: 0.78rem;
}

/* 预警网格 */
.warn-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}
.warn-item {
  background: #fffbeb;
  border-left: 3px solid #f59e0b;
  padding: 8px 10px;
  border-radius: 8px;
  font-size: 0.76rem;
  line-height: 1.4;
}
.warn-item .warn-title {
  font-weight: 700;
  color: #92400e;
  margin-bottom: 2px;
}
.warn-item .warn-detail { color: #78350f; font-size: 0.72rem; margin-top: 2px; }
.warn-item .warn-acc { font-size: 0.66rem; color: #dc2626; margin-top: 1px; }

/* 公式列表 */
.formula-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 0;
  border-bottom: 1px solid #f1f5f9;
  font-size: 0.8rem;
}
.formula-row input[type="checkbox"] { width: 18px; height: 18px; flex-shrink: 0; }
.formula-row label {
  flex: 1;
  cursor: pointer;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 150px;
  color: #1e293b;
}
.formula-val {
  font-size: 0.8rem;
  font-weight: 700;
  color: #2563eb;
  flex-shrink: 0;
}
.acc-badge {
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 0.72rem;
  font-weight: 700;
  background: #dcfce7;
  color: #16a34a;
  margin-left: auto;
  white-space: nowrap;
}

/* 标签页 */
.tab-nav {
  display: flex;
  background: #fff;
  border-radius: 10px;
  margin-bottom: 8px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.03);
}
.tab-btn {
  flex: 1;
  text-align: center;
  padding: 10px;
  font-weight: 700;
  font-size: 0.85rem;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  color: #64748b;
  background: none;
  min-height: 40px;
}
.tab-btn.active { color: #2563eb; border-bottom-color: #2563eb; }
.tab-content { display: none; }
.tab-content.active { display: block; }

/* 分类标签页 */
.cat-tabs { display: flex; gap: 4px; flex-wrap: wrap; margin-bottom: 8px; }
.cat-tab {
  padding: 5px 12px;
  border-radius: 16px;
  font-size: 0.74rem;
  font-weight: 600;
  cursor: pointer;
  border: 2px solid #e2e8f0;
  background: #fff;
  color: #64748b;
  transition: 0.2s;
}
.cat-tab.active { color: #fff; border-color: transparent; }
.cat-tab.cat-direct.active { background: #2563eb; }
.cat-tab.cat-group.active { background: #7c3aed; }
.cat-tab.cat-g3.active { background: #dc2626; }
.cat-tab.cat-g6.active { background: #059669; }
.cat-tab.cat-qs.active { background: #d97706; }
.cat-tab.cat-bs.active { background: #0891b2; }
.cat-tab.cat-zl.active { background: #4b5563; }
.cat-tab.cat-bz.active { background: #9d174d; }

.result-container {
  border: 2px solid #e2e8f0;
  border-radius: 10px;
  padding: 8px;
  margin-bottom: 6px;
  display: none;
}
.result-container.active { display: block; }
.result-container-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 4px;
  font-size: 0.8rem;
  font-weight: 700;
  color: #1e293b;
}
.result-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(48px, 1fr));
  gap: 3px;
  max-height: 180px;
  overflow-y: auto;
  font-family: 'Courier New', monospace;
  font-size: 0.78rem;
}
.result-cell {
  background: #f8fafc;
  padding: 4px;
  text-align: center;
  border-radius: 4px;
  border: 1px solid #e2e8f0;
  color: #1e293b;
}
.summary-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  background: #f1f5f9;
  padding: 8px;
  border-radius: 10px;
  margin: 6px 0;
  font-size: 0.76rem;
  color: #475569;
}

/* 手动条件标签 */
.filter-tag {
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  padding: 3px 8px;
  border-radius: 10px;
  font-size: 0.72rem;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin: 2px;
  color: #1e293b;
}
.delete-filter { color: #dc2626; cursor: pointer; font-weight: bold; }

/* 弹窗 */
.modal {
  display: none;
  position: fixed;
  top: 0; left: 0;
  width: 100%; height: 100%;
  background: rgba(0,0,0,0.5);
  z-index: 1000;
  overflow-y: auto;
}
.modal.active {
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding: 20px;
}
.modal-content {
  background: #fff;
  border-radius: 16px;
  width: 100%;
  max-width: 680px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.2);
  padding: 16px;
}
.modal-close { font-size: 1.4rem; cursor: pointer; color: #64748b; float: right; }

/* 高级过滤 */
.filter-tab-btn {
  padding: 7px 14px;
  border: 1px solid #cbd5e1;
  background: #fff;
  border-radius: 16px;
  cursor: pointer;
  font-size: 0.76rem;
  color: #1e293b;
  transition: 0.2s;
  margin: 2px;
}
.filter-tab-btn.active { background: #2563eb; color: #fff; border-color: #2563eb; }
.filter-panel { display: none; margin-bottom: 8px; }
.filter-panel.active { display: block; }

.shape-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(56px, 1fr));
  gap: 4px;
  margin: 6px 0;
}
.shape-grid label {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 6px;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.74rem;
  background: #f8fafc;
  transition: 0.2s;
  position: relative;
  color: #1e293b;
}
.shape-grid label.checked { background: #dbeafe; border-color: #2563eb; color: #2563eb; }
.shape-grid input[type="checkbox"] { display: none; }
.shape-grid .count-badge {
  position: absolute;
  top: -7px; right: -7px;
  background: #dc2626;
  color: #fff;
  border-radius: 8px;
  font-size: 0.52rem;
  padding: 0 3px;
  line-height: 12px;
  min-width: 12px;
  text-align: center;
}

.two-ma-tabs { display: flex; gap: 3px; margin-bottom: 6px; }
.two-ma-tabs button {
  padding: 5px 10px;
  border: 1px solid #cbd5e1;
  background: #fff;
  border-radius: 10px;
  cursor: pointer;
  font-size: 0.7rem;
  color: #1e293b;
}
.two-ma-tabs button.active { background: #2563eb; color: #fff; border-color: #2563eb; }
.two-ma-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(34px, 1fr));
  gap: 3px;
  margin: 6px 0;
}
.two-ma-grid label {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 4px;
  border: 1px solid #cbd5e1;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.74rem;
  background: #fff;
  color: #1e293b;
}
.two-ma-grid label.checked { background: #dbeafe; border-color: #2563eb; }
.two-ma-grid input[type="checkbox"] { display: none; }

.action-bar { display: flex; gap: 6px; margin: 6px 0; flex-wrap: wrap; align-items: center; }
.action-btn {
  padding: 5px 12px;
  border: 1px solid #cbd5e1;
  background: #fff;
  border-radius: 14px;
  font-size: 0.72rem;
  cursor: pointer;
  transition: 0.2s;
  color: #1e293b;
}
.action-btn.active-action { background: #2563eb; color: #fff; border-color: #2563eb; }

.laji-inputs { display: flex; flex-direction: column; gap: 6px; }
.laji-inputs label { font-size: 0.8rem; display: flex; align-items: center; gap: 6px; color: #1e293b; }
.laji-inputs input { flex: 1; padding: 5px; border: 1px solid #cbd5e1; border-radius: 6px; font-size: 0.8rem; }

.toast {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: #1e293b;
  color: #fff;
  padding: 8px 20px;
  border-radius: 24px;
  font-size: 0.8rem;
  opacity: 0;
  transition: opacity 0.3s;
  pointer-events: none;
  z-index: 9999;
}
.toast.show { opacity: 1; }

.formula-subgroup h4 {
  font-size: 0.8rem;
  color: #475569;
  margin-bottom: 3px;
  display: flex;
  align-items: center;
  gap: 4px;
  background: #eef2ff;
  padding: 4px 8px;
  border-radius: 6px;
  border-left: 3px solid #2563eb;
  cursor: pointer;
}
.formula-subgroup h4 .arrow { transition: transform 0.3s; margin-left: auto; }
.formula-subgroup h4.collapsed .arrow { transform: rotate(-90deg); }

.card[data-section="kill"] { background: #f8faff; }
.card[data-section="danma"] { background: #f0fdf4; }
.card[data-section="duanzu"] { background: #fdf2f8; }

.tolerance-group { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 4px; }
.tolerance-item { display: flex; align-items: center; gap: 3px; }
.tolerance-item span { font-size: 0.72rem; font-weight: 500; white-space: nowrap; color: #475569; }
.tolerance-input {
  display: flex; align-items: center;
  background: #fff;
  border: 1px solid #cbd5e1;
  border-radius: 10px;
  overflow: hidden;
  height: 24px;
}
.tolerance-input button {
  width: 22px; height: 24px;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.8rem; color: #475569;
  background: #f1f5f9; border: none;
  cursor: pointer; line-height: 1;
}
.tolerance-input button:hover { background: #e2e8f0; }
.tolerance-input .tol-value {
  width: 22px; text-align: center;
  font-weight: 700; font-size: 0.72rem;
  color: #1e293b; background: #fff;
}

.set-area { margin-bottom: 3px; }
.set-info { font-size: 0.76rem; color: #475569; margin-bottom: 3px; }

.range-btn {
  background: #4caf50; color: #fff;
  border: none; padding: 5px 12px;
  border-radius: 14px; font-size: 0.72rem;
  cursor: pointer; transition: 0.2s;
}
.range-btn:hover { filter: brightness(0.9); }

.smart-card { background: #f0f9ff; border: 1px solid #bae6fd; }
.hidden { display: none; }

.backtest-table {
  width: 100%; font-size: 0.76rem;
  border-collapse: collapse;
  max-height: 180px; overflow-y: auto;
  display: block;
}
.backtest-table td, .backtest-table th {
  padding: 4px; border-bottom: 1px solid #e2e8f0;
  text-align: center;
}
.backtest-table th { background: #f1f5f9; position: sticky; top: 0; }
.hit-yes { color: #10b981; font-weight: 700; }
.hit-no { color: #dc2626; }
.hit-rate {
  font-size: 0.65rem;
  color: #059669;
  margin-left: 4px;
  white-space: nowrap;
  background: #dcfce7;
  padding: 1px 5px;
  border-radius: 8px;
}