/* ===== 全局 ===== */
* { margin:0; padding:0; box-sizing:border-box; }
:root {
  --placing-1-bg: #fef3c7;
  --placing-2-bg: #dbeafe;
  --placing-3-bg: #d1fae5;
}
body {
  font-family: "PingFang SC","Microsoft YaHei",-apple-system,BlinkMacSystemFont,"Segoe UI",sans-serif;
  background:#f0f2f5; color:#1f2937; font-size:14px; line-height:1.5;
}
a { color:inherit; text-decoration:none; }

/* ===== 浮动广告 ===== */
.ad-float { position: fixed; z-index: 1500; overflow: visible; box-shadow: 0 2px 10px rgba(0,0,0,.15); border-radius: 6px; }
.ad-float .ad-inner { display: block; }
.ad-float .ad-inner img { display: block; border-radius: 6px 6px 0 0; object-fit: cover; background: #fff; }
.ad-float .ad-text { font-size: 12px; line-height: 1.3; color: #1f2937; background: #fff; padding: 3px 4px; border-radius: 0 0 6px 6px; text-align: center; word-break: break-all; }
.ad-float .ad-close { position: absolute; top: -8px; right: -8px; width: 18px; height: 18px; border-radius: 50%; background: #374151; color: #fff; font-size: 13px; line-height: 18px; text-align: center; cursor: pointer; display: none; }
.ad-float:hover .ad-close { display: block; }

/* ===== 顶栏 ===== */
.topbar {
  background:linear-gradient(135deg,#006341 0%,#008553 100%);
  color:#fff; padding:0 24px; height:56px;
  display:flex; align-items:center; justify-content:space-between;
  box-shadow:0 2px 8px rgba(0,0,0,.15); position:sticky; top:0; z-index:100;
}
.brand { display:flex; align-items:center; gap:10px; font-size:18px; font-weight:600; }
.logo { font-size:22px; }
.nav { display:flex; align-items:center; gap:14px; }
.nav-link { padding:6px 16px; border-radius:6px; font-size:15px; transition:all .2s; opacity:.85; }
.nav-link:hover { background:rgba(255,255,255,.15); opacity:1; }
.nav-link.active { background:rgba(255,255,255,.22); opacity:1; font-weight:600; }
.nav-sep { opacity:.5; }

/* ===== 容器 ===== */
.container { max-width:1600px; margin:0 auto; padding:16px 20px; }

/* ===== 工具栏 ===== */
.toolbar {
  background:#fff; border-radius:10px; padding:14px 18px; margin-bottom:16px;
  display:flex; flex-wrap:wrap; gap:12px; align-items:center;
  box-shadow:0 1px 4px rgba(0,0,0,.06);
}
.toolbar label { font-size:13px; color:#6b7280; font-weight:500; }
.toolbar select, .toolbar input[type=text], .toolbar input[type=date] {
  padding:7px 10px; border:1px solid #d1d5db; border-radius:6px; font-size:14px;
  background:#fff; color:#1f2937; min-width:120px; transition:border-color .2s;
}
.toolbar select:focus, .toolbar input:focus { outline:none; border-color:#008553; }

/* ===== 按钮 ===== */
.btn {
  padding:8px 18px; border:none; border-radius:6px; font-size:14px; font-weight:500;
  cursor:pointer; transition:all .2s; display:inline-flex; align-items:center; gap:6px;
}
.btn-primary { background:#006341; color:#fff; }
.btn-primary:hover { background:#008553; }
.btn-collect { background:linear-gradient(135deg,#d97706,#f59e0b); color:#fff; font-weight:600; }
.btn-collect:hover { filter:brightness(1.08); box-shadow:0 2px 8px rgba(217,119,6,.4); }
.btn-collect-all { background:linear-gradient(135deg,#b91c1c,#ef4444); color:#fff; font-weight:600; }
.btn-collect-all:hover { filter:brightness(1.08); box-shadow:0 2px 8px rgba(185,28,28,.4); }
.btn-verify { background:linear-gradient(135deg,#1d4ed8,#3b82f6); color:#fff; font-weight:600; }
.btn-verify:hover { filter:brightness(1.08); box-shadow:0 2px 8px rgba(29,78,216,.4); }
.btn-outline { background:#fff; color:#006341; border:1px solid #006341; }
.btn-outline:hover { background:#f0fdf4; }
.btn:disabled { opacity:.5; cursor:not-allowed; }
.btn-sm { padding:5px 12px; font-size:13px; }

/* ===== 卡片 ===== */
.card {
  background:#fff; border-radius:10px; padding:18px; margin-bottom:16px;
  box-shadow:0 1px 4px rgba(0,0,0,.06);
}
.card-title { font-size:16px; font-weight:600; margin-bottom:14px; color:#111827;
  display:flex; align-items:center; gap:8px; }
.card-title::before { content:""; width:4px; height:16px; background:#006341; border-radius:2px; }

/* ===== 赛事信息 ===== */
.race-info { display:flex; flex-wrap:wrap; gap:10px 24px; }
.race-info-item { display:flex; flex-direction:column; gap:2px; }
.race-info-item .label { font-size:12px; color:#9ca3af; }
.race-info-item .value { font-size:15px; font-weight:600; color:#111827; }

/* ===== 表格 ===== */
.table-wrap { overflow-x:auto; border-radius:8px; border:1px solid #e5e7eb; }
table.data { width:100%; border-collapse:collapse; font-size:13px; background:#fff; }
table.data th, table.data td { padding:9px 12px; text-align:left; border-bottom:1px solid #f0f0f0; white-space:nowrap; }
table.data th { background:#f9fafb; font-weight:600; color:#374151; position:sticky; top:0; }
table.data tbody tr:hover { background:#f0fdf4; }
table.data tbody tr.placing-row-1 { background: var(--placing-1-bg); }
table.data tbody tr.placing-row-2 { background: var(--placing-2-bg); }
table.data tbody tr.placing-row-3 { background: var(--placing-3-bg); }
table.data tbody tr.placing-row-1:hover { background:#fde68a; }
table.data tbody tr.placing-row-2:hover { background:#bfdbfe; }
table.data tbody tr.placing-row-3:hover { background:#a7f3d0; }
/* 兼容旧 winner 类名 */
table.data tbody tr.winner { background: var(--placing-1-bg); }
table.data tbody tr.winner:hover { background:#fde68a; }
table.data .num { text-align:center; font-weight:600; }
table.data .center { text-align:center; }
table.data .silks { width:34px; }
table.data .silks img { width:26px; height:26px; vertical-align:middle; }
.placing-1 { color:#d97706; font-weight:700; }
.placing-2 { color:#6b7280; font-weight:600; }
.placing-3 { color:#92400e; font-weight:600; }
.tag { display:inline-block; padding:2px 8px; border-radius:10px; font-size:12px; font-weight:500; }
.tag-class { background:#dbeafe; color:#1e40af; }
.tag-surface { background:#dcfce7; color:#166534; }

/* ===== 统计卡片 ===== */
.stats-grid { display:grid; grid-template-columns:repeat(auto-fill,minmax(180px,1fr)); gap:14px; margin-bottom:16px; }
.stat-card { background:#fff; border-radius:10px; padding:16px; box-shadow:0 1px 4px rgba(0,0,0,.06); }
.stat-card .stat-label { font-size:13px; color:#6b7280; margin-bottom:6px; }
.stat-card .stat-value { font-size:26px; font-weight:700; color:#006341; }
.stat-card .stat-sub { font-size:12px; color:#9ca3af; margin-top:4px; }

.rank-grid { display:grid; grid-template-columns:1fr 1fr; gap:16px; }
@media(max-width:900px){ .rank-grid { grid-template-columns:1fr; } }

/* ===== 空状态/加载 ===== */
.empty { text-align:center; padding:60px 20px; color:#9ca3af; }
.empty .icon { font-size:48px; margin-bottom:12px; }
.loading { text-align:center; padding:40px; color:#6b7280; }
.spinner { display:inline-block; width:24px; height:24px; border:3px solid #e5e7eb; border-top-color:#006341; border-radius:50%; animation:spin .8s linear infinite; vertical-align:middle; margin-right:8px; }
@keyframes spin { to { transform:rotate(360deg); } }

/* ===== Toast ===== */
.toast {
  position:fixed; bottom:24px; left:50%; transform:translateX(-50%) translateY(100px);
  background:#1f2937; color:#fff; padding:12px 24px; border-radius:8px; font-size:14px;
  box-shadow:0 4px 12px rgba(0,0,0,.2); z-index:9999; opacity:0; transition:all .3s;
}
.toast.show { transform:translateX(-50%) translateY(0); opacity:1; }
.toast.success { background:#006341; }
.toast.error { background:#dc2626; }

/* ===== Modal ===== */
.modal-overlay { position:fixed; inset:0; background:rgba(0,0,0,.5); display:flex; align-items:center; justify-content:center; z-index:9998; }
.modal-overlay[hidden] { display:none; }
.modal { background:#fff; border-radius:10px; width:90%; max-width:460px; overflow:hidden; }
.modal-header { display:flex; justify-content:space-between; align-items:center; padding:16px 20px; border-bottom:1px solid #e5e7eb; }
.modal-header h3 { font-size:16px; }
.modal-close { font-size:24px; cursor:pointer; color:#9ca3af; line-height:1; }
.modal-body { padding:20px; max-height:60vh; overflow-y:auto; }
.modal-body .date-opt { display:block; width:100%; text-align:left; padding:12px 16px; margin-bottom:8px; border:1px solid #e5e7eb; border-radius:8px; background:#fff; cursor:pointer; transition:all .15s; font-size:14px; }
.modal-body .date-opt:hover { border-color:#006341; background:#f0fdf4; }
.modal-body .date-opt .date { font-weight:600; }
.modal-body .date-opt .meta { color:#9ca3af; font-size:12px; margin-top:2px; }

/* ===== 派彩 ===== */
.dividend-list { display:flex; flex-wrap:wrap; gap:8px; margin-top:10px; }
.dividend-item { background:#f9fafb; border:1px solid #e5e7eb; border-radius:6px; padding:6px 12px; font-size:13px; }
.dividend-item .pool { color:#6b7280; margin-right:6px; }
.dividend-item .combo { font-weight:600; color:#111827; margin-right:6px; }
.dividend-item .amt { color:#d97706; font-weight:600; }

.progress-log { background:#1f2937; color:#e5e7eb; border-radius:8px; padding:14px; font-family:monospace; font-size:13px; max-height:240px; overflow-y:auto; }
.progress-log .line { margin-bottom:3px; }
.progress-log .ok { color:#34d399; }
.progress-log .err { color:#f87171; }

/* 任务进度条 */
/* 马匹查询 17 列紧凑表 */
.horse-table { font-size:12px; table-layout:fixed; min-width:0; width:100%; }
.horse-table th, .horse-table td { padding:4px 5px !important; white-space:nowrap; overflow:visible; line-height:1.3; }
.horse-table th { font-size:12px; }
.horse-table-wrap { overflow-x:auto; }
.horse-table td:first-child { padding-left:6px !important; }
.horse-table td:last-child { padding-right:6px !important; }
.horse-table tbody tr.current-race-row td { background:#f0f9ff; border-bottom:4px solid #6b7280; padding-bottom:10px !important; }

/* 整场马匹数据比对汇总表 */
.race-summary-table th, .race-summary-table td { padding:8px 10px !important; text-align:left; border-bottom:1px solid #e2e8f0; }
.race-summary-table tbody tr.summary-row:hover { background:#fef9c3; }
.race-summary-wrap .race-summary-table th { background:transparent !important; }
.race-summary-wrap .race-summary-table td { background:transparent !important; }

/* 骑师/练马师汇总表 */
.person-table { font-size:12px; table-layout:fixed; min-width:0; width:100%; }
.person-table th, .person-table td { padding:5px 6px !important; white-space:nowrap; overflow:visible; }
.person-table-wrap { overflow-x:auto; }

/* 自动补全 */
.autocomplete-wrap { position:relative; display:inline-block; }
.autocomplete-input { width:45px; min-width:45px; }
.autocomplete-input.horse { width:65px; min-width:65px; }
.autocomplete-list { position:absolute; top:100%; left:0; right:0; z-index:999; background:#fff;
  border:1px solid #d1d5db; border-top:none; border-radius:0 0 6px 6px; max-height:200px;
  overflow-y:auto; box-shadow:0 4px 12px rgba(0,0,0,.1); display:none; }
.autocomplete-item { padding:6px 10px; font-size:13px; cursor:pointer; border-bottom:1px solid #f0f0f0; }
.autocomplete-item:hover, .autocomplete-item.active { background:#f0fdf4; color:#006341; font-weight:600; }
.autocomplete-item .meta { font-size:11px; color:#9ca3af; display:block; }

/* 清除按钮 */
.clear-btn { position:absolute; right:4px; top:50%; transform:translateY(-50%);
  cursor:pointer; color:#9ca3af; font-size:16px; line-height:1; padding:0 4px;
  display:none; user-select:none; z-index:10; }
.clear-btn:hover { color:#dc2626; }
.autocomplete-wrap:hover .clear-btn.has-value { display:block; }
.progress-fill { background:linear-gradient(90deg,#006341,#008553); height:100%; width:0%;
  transition:width .3s; text-align:center; color:#fff; font-size:12px; line-height:22px; font-weight:600; }
.job-status { font-size:13px; color:#6b7280; margin:6px 0; }
.job-current { font-size:14px; color:#111827; font-weight:500; margin:4px 0; }
.job-actions { display:flex; gap:8px; margin-top:14px; justify-content:flex-end; }
.missing-list { background:#fef3c7; border:1px solid #fbbf24; border-radius:6px; padding:10px; margin-top:10px; max-height:160px; overflow-y:auto; font-size:13px; }
.missing-list .item { padding:3px 0; }
.missing-list .item a { color:#92400e; text-decoration:underline; cursor:pointer; }

/* ===== 返回顶部悬浮按钮 ===== */
.back-to-top {
  position: fixed; right: 24px; bottom: 24px; width: 46px; height: 46px;
  border-radius: 50%; border: none; background: #006341; color: #fff;
  font-size: 22px; line-height: 1; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 4px 12px rgba(0,0,0,.25); z-index: 200;
  opacity: 0; visibility: hidden; transition: opacity .25s, visibility .25s, transform .15s;
}
.back-to-top:hover { background: #008553; transform: translateY(-2px); }
.back-to-top.show { opacity: 1; visibility: visible; }

/* 访问统计浮动图标 */
.visit-wrap {
  position: fixed; left: 16px; bottom: 16px; z-index: 200;
  display: flex; align-items: center; gap: 8px;
}
.visit-fab {
  width: 36px; height: 36px; border-radius: 50%; border: none;
  background: #006341; color: #fff; font-size: 16px; line-height: 1;
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  box-shadow: 0 3px 8px rgba(0,0,0,.22);
  flex-shrink: 0;
}
.visit-fab:hover { background: #008553; transform: translateY(-2px); }
.visit-popover {
  position: relative;
  background: #fff; border: 1px solid #e5e7eb; border-radius: 8px;
  box-shadow: 0 3px 10px rgba(0,0,0,.12); padding: 6px 10px;
  width: auto; min-width: 150px; white-space: nowrap;
}
.visit-popover[hidden] { display: none; }
.visit-pop-body { display: flex; align-items: center; gap: 8px; }
.visit-pop-body .visit-row {
  display: inline-flex; flex-direction: column; align-items: center;
  font-size: 11px; color: #374151; line-height: 1.2;
}
.visit-pop-body .visit-row b { color: #006341; font-size: 13px; margin-top: 1px; }
