* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 14px;
  background: #f5f5f5;
  color: #333;
}

.navbar {
  background: #1a73e8;
  color: #fff;
  padding: 0 20px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.nav-brand { font-size: 16px; font-weight: 600; }
.nav-links a { color: #fff; text-decoration: none; margin-left: 20px; }
.nav-links a:hover { text-decoration: underline; }

.container { max-width: 1200px; margin: 20px auto; padding: 0 16px; }

.toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  background: #fff;
  border-radius: 8px;
  padding: 12px 16px;
  margin-bottom: 16px;
  box-shadow: 0 1px 3px rgba(0,0,0,.1);
  flex-wrap: wrap;
}
.toolbar select, .toolbar button {
  padding: 6px 12px;
  border: 1px solid #ddd;
  border-radius: 4px;
  font-size: 13px;
  cursor: pointer;
}
.toolbar button.primary {
  background: #1a73e8;
  color: #fff;
  border-color: #1a73e8;
}
.week-nav { display: flex; align-items: center; gap: 8px; }
.week-nav button { padding: 4px 10px; }
.week-label { font-weight: 500; min-width: 160px; text-align: center; }

.table-wrap {
  background: #fff;
  border-radius: 8px;
  box-shadow: 0 1px 3px rgba(0,0,0,.1);
  overflow: hidden;
}
table { width: 100%; border-collapse: collapse; }
th {
  background: #f8f9fa;
  padding: 10px 12px;
  text-align: left;
  font-weight: 600;
  border-bottom: 2px solid #e0e0e0;
  white-space: nowrap;
}
td { padding: 9px 12px; border-bottom: 1px solid #f0f0f0; }
tr:last-child td { border-bottom: none; }
tr.row-hit { background: #e6f4ea; }
tr.row-miss { background: #fce8e6; }
tr.row-live { background: #e8f0fe; }
tr.row-draw { background: #f0f0f0; }
tr.row-highlight { outline: 2px solid #1a73e8; }

tr.expandable { cursor: pointer; }
tr.expandable:hover { filter: brightness(0.97); }
tr.detail-row td { background: #fafafa; padding: 12px 20px; font-size: 13px; color: #555; }

.hit-yes { color: #137333; font-weight: 700; }
.hit-no  { color: #c5221f; font-weight: 700; }
.hit-refund { color: #999; }

.summary-bar {
  background: #fff;
  border-radius: 8px;
  padding: 10px 16px;
  margin-top: 12px;
  box-shadow: 0 1px 3px rgba(0,0,0,.1);
  font-size: 13px;
  color: #555;
  display: flex;
  gap: 20px;
  flex-wrap: wrap;
}
.summary-bar span b { color: #333; }

.section-title { font-size: 15px; font-weight: 600; margin: 16px 0 8px; }
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}
.match-card {
  background: #fff;
  border-radius: 8px;
  padding: 12px;
  box-shadow: 0 1px 3px rgba(0,0,0,.1);
  cursor: pointer;
  transition: box-shadow .15s;
  border: 2px solid transparent;
}
.match-card:hover { box-shadow: 0 3px 8px rgba(0,0,0,.15); border-color: #1a73e8; }
.match-card .league-tag {
  font-size: 11px;
  background: #e8f0fe;
  color: #1a73e8;
  border-radius: 3px;
  padding: 1px 5px;
  display: inline-block;
  margin-bottom: 4px;
}
.match-card .teams { font-weight: 600; margin: 4px 0; }
.match-card .meta { font-size: 12px; color: #888; }
.match-card .score { font-size: 18px; font-weight: 700; text-align: center; margin: 4px 0; }

.modal-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,.4);
  z-index: 100;
  align-items: center;
  justify-content: center;
}
.modal-overlay.open { display: flex; }
.modal {
  background: #fff;
  border-radius: 10px;
  padding: 24px;
  width: 420px;
  max-width: 95vw;
}
.modal h2 { font-size: 16px; margin-bottom: 16px; }
.form-row { margin-bottom: 14px; }
.form-row label { display: block; font-weight: 500; margin-bottom: 4px; font-size: 13px; }
.form-row input, .form-row select, .form-row textarea {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid #ddd;
  border-radius: 4px;
  font-size: 13px;
}
.form-row .radio-group { display: flex; gap: 12px; }
.form-row .radio-group label { font-weight: normal; display: flex; align-items: center; gap: 4px; }
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 16px; }
.modal-actions button { padding: 8px 18px; border-radius: 4px; border: 1px solid #ddd; cursor: pointer; }
.modal-actions .btn-primary { background: #1a73e8; color: #fff; border-color: #1a73e8; }
.odds-loading { color: #888; font-size: 12px; }

.stats-table tr.clickable { cursor: pointer; }
.stats-table tr.clickable:hover { background: #f0f4ff; }
.roi-positive { color: #137333; font-weight: 600; }
.roi-negative { color: #c5221f; font-weight: 600; }

/* LLM 对比页 */
.llm-stats-bar {
  background: #fff;
  border-radius: 8px;
  padding: 12px 16px;
  box-shadow: 0 1px 3px rgba(0,0,0,.1);
  display: flex;
  gap: 24px;
  flex-wrap: wrap;
  font-size: 13px;
}
.stat-item { display: flex; align-items: center; gap: 6px; }
.stat-item b { font-size: 13px; color: #333; }
.stat-good { color: #137333; font-weight: 600; }
.stat-bad  { color: #c5221f; font-weight: 600; }

.date-stat-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 4px;
}
.date-stat-row {
  position: relative;
  border-radius: 6px;
  padding: 5px 10px;
  cursor: default;
  text-align: center;
  min-width: 52px;
}
.date-stat-date {
  font-size: 11px;
  color: #888;
  margin-bottom: 2px;
}
.date-stat-gpt {
  font-size: 13px;
  font-weight: 600;
}
.date-stat-tooltip {
  display: none;
  position: absolute;
  top: calc(100% + 4px);
  left: 50%;
  transform: translateX(-50%);
  background: #fff;
  border: 1px solid #e0e0e0;
  border-radius: 6px;
  padding: 8px 12px;
  white-space: nowrap;
  font-size: 12px;
  box-shadow: 0 2px 8px rgba(0,0,0,.15);
  z-index: 20;
  display: none;
  flex-direction: column;
  gap: 4px;
}
.date-stat-row:hover .date-stat-tooltip { display: flex; }

.llm-table td { text-align: center; }
.llm-table td:nth-child(3) { text-align: left; }
.llm-table td:nth-child(2) { text-align: left; font-size: 12px; color: #888; }
.llm-table td:first-child  { text-align: left; white-space: nowrap; font-size: 12px; color: #888; }
.llm-hit     { color: #137333; font-weight: 700; }
.llm-miss    { color: #c5221f; font-weight: 700; }
.llm-abstain { color: #bbb; }
.llm-pending { color: #888; }

.detail-model {
  border-bottom: 1px solid #f0f0f0;
  padding: 10px 0;
}
.detail-model:last-child { border-bottom: none; }
.detail-model-name { font-weight: 600; margin-bottom: 4px; }
.detail-dir { font-weight: normal; color: #555; font-size: 13px; }
.detail-reason { font-size: 13px; color: #555; line-height: 1.6; white-space: pre-wrap; }

.prompt-block { margin-top: 16px; border-top: 1px solid #eee; padding-top: 10px; }
.prompt-toggle {
  font-size: 13px;
  color: #1a73e8;
  cursor: pointer;
  user-select: none;
}
.prompt-toggle:hover { text-decoration: underline; }
.prompt-content {
  margin-top: 8px;
  padding: 10px 12px;
  background: #f8f9fa;
  border-radius: 4px;
  font-size: 12px;
  color: #444;
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 400px;
  overflow-y: auto;
}

/* ── 回测页 ─────────────────────────────────────────── */
.section-card {
  background: #fff;
  border-radius: 8px;
  padding: 16px;
  box-shadow: 0 1px 3px rgba(0,0,0,.1);
}
.section-title { font-size: 15px; font-weight: 600; margin-bottom: 10px; }
.form-label { display: block; font-size: 12px; color: #666; margin-bottom: 4px; }
.form-input {
  padding: 6px 10px;
  border: 1px solid #ddd;
  border-radius: 4px;
  font-size: 13px;
}
.btn { padding: 7px 16px; border-radius: 4px; border: 1px solid #ddd; cursor: pointer; font-size: 13px; }
.btn-primary { background: #1a73e8; color: #fff; border-color: #1a73e8; }
.btn-secondary { background: #fff; color: #333; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.checkbox-list { display: flex; flex-direction: column; gap: 4px; font-size: 13px; max-height: 140px; overflow-y: auto; }
.checkbox-list label { display: flex; align-items: center; gap: 6px; cursor: pointer; }
.meta-panel { font-size: 13px; color: #555; }
.data-table { width: 100%; border-collapse: collapse; }
.data-table th { background: #f8f9fa; padding: 8px 12px; text-align: left; font-weight: 600; border-bottom: 2px solid #e0e0e0; font-size: 13px; }
.data-table td { padding: 8px 12px; border-bottom: 1px solid #f0f0f0; font-size: 13px; }
.data-table tr:last-child td { border-bottom: none; }
.progress-bar-wrap { background: #f0f0f0; border-radius: 4px; height: 10px; overflow: hidden; }
.progress-bar { background: #1a73e8; height: 100%; border-radius: 4px; transition: width .3s; }
.modal-box {
  background: #fff;
  border-radius: 10px;
  padding: 20px;
  width: 95vw;
  max-height: 90vh;
  overflow-y: auto;
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
  font-size: 15px;
  font-weight: 600;
}
.modal-close {
  background: none;
  border: none;
  font-size: 18px;
  cursor: pointer;
  color: #999;
}
.modal-close:hover { color: #333; }

/* ── 移动端适配 ───────────────────────────────────────── */
.mobile-cards { display: none; }

@media (max-width: 600px) {
  .container { margin: 10px auto; padding: 0 10px; }

  .navbar {
    height: auto;
    padding: 8px 12px;
    flex-wrap: wrap;
    gap: 6px;
  }
  .nav-links { display: flex; flex-wrap: wrap; gap: 4px 10px; }
  .nav-links a { margin-left: 0; font-size: 13px; }

  .toolbar { gap: 8px; padding: 10px 12px; }
  .week-label { min-width: 0; font-size: 13px; }

  /* 表格横向滚动（统计/LLM等页面） */
  .table-wrap { overflow-x: auto; }

  /* 首页：隐藏表格，显示卡片 */
  .pred-table-wrap { display: none !important; }
  .mobile-cards { display: block; }

  /* 移动端卡片 */
  .mob-card {
    background: #fff;
    border-radius: 8px;
    padding: 10px 12px;
    margin-bottom: 8px;
    box-shadow: 0 1px 3px rgba(0,0,0,.1);
    cursor: pointer;
  }
  .mob-card.row-hit  { background: #e6f4ea; }
  .mob-card.row-miss { background: #fce8e6; }
  .mob-card.row-live { background: #e8f0fe; }
  .mob-card.row-draw { background: #f0f0f0; }

  .mob-card-head {
    display: flex;
    justify-content: space-between;
    font-size: 12px;
    color: #888;
    margin-bottom: 4px;
  }
  .mob-league { font-weight: 500; color: #1a73e8; }
  .mob-teams {
    font-size: 15px;
    font-weight: 600;
    margin: 4px 0;
    display: flex;
    align-items: center;
    gap: 6px;
  }
  .mob-score {
    font-size: 16px;
    color: #333;
    min-width: 36px;
    text-align: center;
  }
  .mob-card-foot {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    color: #555;
    margin-top: 4px;
    flex-wrap: wrap;
  }
  .mob-bet { flex: 1; min-width: 0; }
  .mob-progress { color: #888; }
  .mob-hit { font-size: 14px; }
  .mob-detail {
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid #eee;
    font-size: 12px;
    color: #555;
    line-height: 1.6;
  }
  .mob-tag {
    display: inline-block;
    font-size: 11px;
    padding: 1px 5px;
    border-radius: 3px;
  }
  .tag-live  { background: #e8f0fe; color: #1a73e8; }
  .tag-heavy { background: #fff3e0; color: #e65100; }

  /* 统计/LLM 等页面表格最小宽度，确保可滚动 */
  .llm-table { min-width: 540px; }
  .stats-table { min-width: 480px; }

  /* 回测页面 */
  /* 历史回测表格可横向滚动 */
  .backtest-runs-wrap { overflow-x: auto; }
  .backtest-runs-wrap table { min-width: 520px; }

  /* 详情弹窗全屏 */
  #detailModal .modal-box,
  #matchLogModal .modal-box {
    width: 100vw;
    max-width: 100vw;
    height: 100vh;
    max-height: 100vh;
    border-radius: 0;
    padding: 12px;
  }

  /* 详情表格可横向滚动 */
  #detailModal .table-wrap { overflow-x: auto; }
  #detailModal .data-table { min-width: 480px; }
  #detailModal .data-table th,
  #detailModal .data-table td { padding: 6px 8px; font-size: 12px; }
}
