:root {
  --bg: #f4f6fa;
  --card: #ffffff;
  --border: #e3e8ef;
  --text: #1f2933;
  --muted: #7b8794;
  --primary: #d4380d;
  --primary-hover: #b5391a;
  --green: #cf1322; /* A 股红涨 */
  --shadow: 0 1px 3px rgba(0,0,0,.06), 0 1px 2px rgba(0,0,0,.04);
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
}

.topbar {
  background: linear-gradient(135deg, #b5391a, #d4380d);
  color: #fff;
  padding: 14px 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-shadow: var(--shadow);
}
.brand { display: flex; align-items: center; gap: 12px; }
.logo { font-size: 28px; }
.topbar h1 { margin: 0; font-size: 20px; font-weight: 600; }
.sub { margin: 2px 0 0; font-size: 12px; opacity: .85; }
.actions { display: flex; gap: 8px; }

.container { max-width: 1400px; margin: 16px auto; padding: 0 16px; }

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px;
  margin-bottom: 14px;
  box-shadow: var(--shadow);
}

.filters .row { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; }
.filters .row + .row { margin-top: 12px; }
.field { display: flex; flex-direction: column; gap: 4px; }
.field label { font-size: 12px; color: var(--muted); }
.field input, .field select {
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 13px;
  outline: none;
  min-width: 120px;
}
.field input:focus, .field select:focus { border-color: var(--primary); }
.field.btns { flex-direction: row; gap: 8px; }

.btn {
  padding: 7px 16px;
  border: 1px solid var(--border);
  background: #fff;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
  color: var(--text);
  transition: all .15s;
}
.btn:hover { background: #f0f2f5; }
.btn-primary { background: var(--primary); color: #fff; border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-hover); }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.summary { font-size: 13px; color: var(--muted); }
.summary b { color: var(--text); }

.dates-strip { display: flex; flex-wrap: wrap; gap: 6px; }
.date-chip {
  font-size: 12px;
  padding: 4px 10px;
  border-radius: 12px;
  background: #fff5f3;
  border: 1px solid #ffd6cc;
  color: var(--primary);
  cursor: pointer;
  white-space: nowrap;
}
.date-chip:hover { background: #ffe6e0; }
.date-chip.active { background: var(--primary); color: #fff; border-color: var(--primary); }

.card-title { font-weight: 600; font-size: 14px; margin-bottom: 10px; display: flex; align-items: center; }
.card-sub { font-weight: normal; color: var(--muted); font-size: 12px; margin-left: 6px; }
.btn-sm { padding: 3px 10px; font-size: 12px; }
.industry-bars { display: flex; flex-direction: column; gap: 5px; max-height: 380px; overflow: auto; padding-right: 4px; }
.ind-row { display: flex; align-items: center; gap: 8px; font-size: 12px; }
.ind-head { color: var(--muted); font-size: 11px; padding-bottom: 4px; border-bottom: 1px solid var(--border); margin-bottom: 4px; }
.ind-name {
  width: 92px; text-align: right; color: var(--text); flex-shrink: 0;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; cursor: pointer;
}
.ind-name:hover { color: var(--primary); text-decoration: underline; }
.ind-bar-wrap { flex: 1; background: #f0f2f5; border-radius: 4px; height: 16px; min-width: 80px; }
.ind-bar { height: 100%; background: linear-gradient(90deg, #d4380d, #ff7a45); border-radius: 4px; transition: width .3s; }
.ind-bar-label { display: block; font-size: 11px; color: var(--muted); padding-left: 2px; }
.ind-count { width: 32px; text-align: left; font-weight: 600; color: var(--primary); flex-shrink: 0; }
.ind-spark { flex: 2; min-width: 140px; height: 28px; display: flex; align-items: center; }
.ind-spark .spark { width: 100%; height: 28px; display: block; }
.ind-amt { width: 82px; text-align: right; color: var(--text); flex-shrink: 0; font-variant-numeric: tabular-nums; }
.ind-head .ind-bar-wrap { background: transparent; height: auto; }
.ind-head .ind-spark { height: auto; }

.table-wrap { overflow-x: auto; padding: 0; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 9px 10px; text-align: right; white-space: nowrap; }
th { background: #fafbfc; font-weight: 600; color: var(--muted); font-size: 12px;
     border-bottom: 1px solid var(--border); position: sticky; top: 0; }
td { border-bottom: 1px solid #f0f2f5; }
tbody tr:hover { background: #fafbfc; }
td:nth-child(2), td:nth-child(3), td:nth-child(4) { text-align: left; }
td:nth-child(1) { text-align: left; }
th.left, td.left { text-align: left; }
th.sortable { cursor: pointer; user-select: none; }
th.sortable:hover { color: var(--primary); }
th.sortable .sort-arr { display: inline-block; width: 12px; margin-left: 3px; font-size: 10px; color: var(--muted); }
th.sort-active { color: var(--primary); }
th.sort-active .sort-arr { color: var(--primary); }
.up { color: var(--green); font-weight: 600; }
.empty { text-align: center; color: var(--muted); padding: 32px; }

/* Tabs */
.tabs { display: flex; gap: 0; border-bottom: 2px solid var(--border); margin-bottom: 14px; }
.tab {
  padding: 10px 24px; background: none; border: none; cursor: pointer; font-size: 14px;
  color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -2px;
}
.tab.active { color: var(--primary); font-weight: 600; border-bottom-color: var(--primary); }
.tab:hover { color: var(--text); }
.tab-content { display: none; }
.tab-content.active { display: block; }

/* 明细栏 */
.detail-bar .row { flex-wrap: wrap; }
.detail-info { margin-left: auto; color: var(--muted); font-size: 13px; align-self: center; }

/* 每日统计表 */
#stats-tbl td { cursor: pointer; }
#stats-tbl tbody tr:hover { background: #fff5f3; }
.cnt-cell { position: relative; min-width: 140px; height: 20px; display: flex; align-items: center; }
.cnt-bar { position: absolute; left: 0; top: 2px; bottom: 2px; background: #ffe0d6; border-radius: 3px; z-index: 0; }
.cnt-num { position: relative; z-index: 1; padding-left: 8px; font-weight: 600; color: var(--primary); }

/* 成交额趋势图 */
.chart-legend { display: flex; flex-wrap: wrap; gap: 14px; margin-bottom: 8px; font-size: 12px; }
.legend-item { display: flex; align-items: center; gap: 5px; color: var(--text); }
.legend-dot { width: 12px; height: 3px; border-radius: 2px; }
.chart-wrap { position: relative; width: 100%; overflow-x: auto; }
.chart-wrap svg { display: block; width: 100%; min-width: 560px; height: auto; }
.chart-wrap .hov { cursor: crosshair; }
.chart-tip {
  position: absolute; pointer-events: none; background: rgba(31,41,51,.92); color: #fff;
  padding: 7px 10px; border-radius: 6px; font-size: 12px; white-space: nowrap; z-index: 10;
  transform: translate(-50%, 0); line-height: 1.5; display: none;
}
.chart-tip .tip-date { font-weight: 600; margin-bottom: 2px; }
.chart-tip .tip-row { display: flex; justify-content: space-between; gap: 10px; }
.chart-tip .tip-row b { color: #ffd; }

.pagination { display: flex; gap: 6px; justify-content: center; align-items: center; margin-top: 4px; }
.pagination button { min-width: 34px; }
.pagination .info { color: var(--muted); font-size: 12px; margin: 0 8px; }

.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: #1f2933;
  color: #fff;
  padding: 10px 20px;
  border-radius: 8px;
  font-size: 13px;
  opacity: 0;
  transition: all .25s;
  pointer-events: none;
  z-index: 100;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.error { background: #b5391a; }
