:root {
  --bg: #0d1117;
  --bg-soft: #131a24;
  --card: #18212e;
  --card-hover: #1e2a3a;
  --border: #263244;
  --text: #e6edf3;
  --text-dim: #9aa8b8;
  --text-faint: #6b7a8c;
  --accent: #58a6ff;
  --accent-soft: rgba(88, 166, 255, 0.14);
  --vr: #6ee7b7;
  --psp: #f9a8d4;
  --danger: #f85149;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.35);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans CJK SC", sans-serif;
  font-size: 15px;
  line-height: 1.6;
}

.page {
  max-width: 1240px;
  margin: 0 auto;
  padding: 24px 20px 60px;
}

a {
  color: var(--accent);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

/* ---------- 顶部导航 ---------- */
.top-nav {
  display: flex;
  gap: 8px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.top-nav a {
  display: inline-block;
  padding: 6px 14px;
  border-radius: 8px;
  background: var(--card);
  color: var(--text-dim);
  border: 1px solid var(--border);
  font-size: 14px;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.top-nav a:hover {
  color: var(--text);
  text-decoration: none;
  background: var(--card-hover);
}

.top-nav a.active {
  color: var(--accent);
  background: var(--accent-soft);
  border-color: rgba(88, 166, 255, 0.45);
}

/* ---------- 头部 ---------- */
.site-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 20px;
}

.site-header h1 {
  margin: 0 0 6px;
  font-size: 28px;
  letter-spacing: 0.5px;
}

.site-header p {
  margin: 0;
  color: var(--text-dim);
  max-width: 720px;
}

.header-meta {
  font-size: 12px;
  color: var(--text-faint);
  text-align: right;
}

/* ---------- 控制栏 ---------- */
.controls {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
  margin-bottom: 18px;
  box-shadow: var(--shadow);
}

.control-group {
  display: flex;
  align-items: center;
  gap: 8px;
}

.control-group label {
  color: var(--text-dim);
  font-size: 13px;
  white-space: nowrap;
}

select,
button {
  font: inherit;
  color: var(--text);
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 7px 12px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}

select:hover,
button:hover {
  background: var(--card-hover);
  border-color: #3b4b63;
}

button.primary {
  background: var(--accent-soft);
  border-color: rgba(88, 166, 255, 0.45);
  color: var(--accent);
}

button.primary:hover {
  background: rgba(88, 166, 255, 0.22);
}

.spacer {
  flex: 1;
}

.updated {
  font-size: 12px;
  color: var(--text-faint);
}

/* ---------- 主播筛选弹出层 ---------- */
.popover-wrap {
  position: relative;
}

.popover {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  z-index: 50;
  width: 320px;
  max-height: 420px;
  display: flex;
  flex-direction: column;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
  overflow: hidden;
}

.popover.hidden {
  display: none;
}

.popover-head {
  display: flex;
  gap: 8px;
  padding: 10px;
  border-bottom: 1px solid var(--border);
}

.popover-head input[type="search"] {
  flex: 1;
  font: inherit;
  color: var(--text);
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 10px;
  outline: none;
}

.popover-head input[type="search"]:focus {
  border-color: var(--accent);
}

.popover-list {
  overflow-y: auto;
  padding: 6px;
  flex: 1;
}

.room-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border-radius: 6px;
  cursor: pointer;
}

.room-item:hover {
  background: var(--card-hover);
}

.room-item input {
  accent-color: var(--accent);
}

.room-item .room-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.popover-empty {
  color: var(--text-faint);
  text-align: center;
  padding: 18px 0;
}

.popover-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px;
  border-top: 1px solid var(--border);
}

.popover-foot span {
  font-size: 12px;
  color: var(--text-dim);
}

.union-tag {
  display: inline-block;
  font-size: 11px;
  line-height: 1;
  padding: 3px 6px;
  border-radius: 5px;
  flex-shrink: 0;
}

.union-tag.vr {
  color: var(--vr);
  background: rgba(110, 231, 183, 0.12);
}

.union-tag.psp {
  color: var(--psp);
  background: rgba(249, 168, 212, 0.12);
}

.live-dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  margin-left: 6px;
  border-radius: 50%;
  background: #f85149;
  box-shadow: 0 0 6px #f85149;
  vertical-align: middle;
}

/* ---------- 统计卡片 ---------- */
.stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 18px;
}

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

.stat-card .stat-num {
  display: block;
  font-size: 26px;
  font-weight: 700;
  color: var(--text);
  line-height: 1.3;
}

.stat-num.up {
  color: #7ee787;
}

.stat-num.down {
  color: #f85149;
}

.stat-card .stat-label {
  display: block;
  font-size: 12px;
  color: var(--text-dim);
  margin-top: 2px;
}

.stat-card .stat-range {
  font-size: 12px;
  color: var(--text-faint);
  margin-top: 6px;
}

/* ---------- 报告：周期标签与日期选择 ---------- */
.period-label {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
}

.controls input[type="date"],
.controls input[type="month"] {
  font: inherit;
  color: var(--text);
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 10px;
}

.controls input.hidden {
  display: none;
}

/* ---------- 报告：高亮卡片 ---------- */
.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(175px, 1fr));
  gap: 12px;
  margin-bottom: 26px;
}

.hl-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 13px 15px;
  box-shadow: var(--shadow);
  min-width: 0;
}

.hl-label {
  font-size: 12px;
  color: var(--text-dim);
  margin-bottom: 6px;
}

.hl-name {
  font-size: 13px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.hl-value {
  font-size: 22px;
  font-weight: 700;
  color: var(--accent);
  margin-top: 4px;
  line-height: 1.3;
}

.hl-title {
  font-size: 12px;
  color: var(--text-dim);
  margin-top: 3px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.hl-meta {
  font-size: 12px;
  color: var(--text-faint);
  margin-top: 2px;
}

.hl-empty {
  color: var(--text-faint);
  font-size: 13px;
  padding: 6px 0;
}

.hl-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 12px;
}

/* ---------- 报告：每日趋势 ---------- */
.daily-wrap {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 8px 16px;
}

.daily-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 7px 0;
  border-bottom: 1px dashed var(--border);
  font-size: 13px;
}

.daily-row:last-child {
  border-bottom: none;
}

.daily-date {
  min-width: 72px;
  color: var(--text-dim);
  display: flex;
  align-items: baseline;
  gap: 6px;
}

.daily-date small {
  font-size: 11px;
  color: var(--text-faint);
}

.daily-track {
  flex: 1;
  position: relative;
  height: 18px;
  background: var(--bg-soft);
  border-radius: 9px;
  overflow: hidden;
}

.daily-fill {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  border-radius: 9px;
  background: linear-gradient(90deg, var(--accent), #7ee787);
  opacity: 0.85;
}

.daily-meta {
  min-width: 150px;
  text-align: right;
  color: var(--text-dim);
  font-size: 12px;
  white-space: nowrap;
}

/* ---------- 报告：排行网格 ---------- */
.rank-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(330px, 1fr));
  gap: 14px;
}

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

.rank-card h3 {
  margin: 0 0 2px;
  font-size: 15px;
}

.rank-sub {
  font-size: 11px;
  color: var(--text-faint);
  margin-bottom: 8px;
}

.rank-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 5px 0;
  border-bottom: 1px dashed var(--border);
  font-size: 13px;
}

.rank-row:last-child {
  border-bottom: none;
}

.rank-no {
  width: 22px;
  color: var(--text-faint);
  font-weight: 700;
  text-align: center;
  flex-shrink: 0;
}

.rank-row.first .rank-no {
  color: #ffd76d;
}

.rank-name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.rank-val {
  font-weight: 600;
  white-space: nowrap;
}

/* ---------- 实时仪表板：趋势图 ---------- */
.chart-wrap {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px;
}

#chart {
  width: 100%;
  height: 240px;
  display: block;
}

.chart-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.legend-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  padding: 4px 11px;
  border-radius: 15px;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  color: var(--text-dim);
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s, opacity 0.15s;
}

.legend-chip.on {
  color: var(--text);
  border-color: #3b4b63;
}

.legend-chip.off {
  opacity: 0.45;
  text-decoration: line-through;
}

.legend-chip:hover {
  border-color: var(--accent);
}

.legend-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  flex-shrink: 0;
}

/* ---------- 实时仪表板：直播卡片网格 ---------- */
.live-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(285px, 1fr));
  gap: 14px;
}

.live-card {
  display: flex;
  flex-direction: column;
  gap: 7px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 13px 15px;
  box-shadow: var(--shadow);
  transition: border-color 0.15s, transform 0.15s;
}

.live-card:hover {
  border-color: #3b4b63;
  transform: translateY(-2px);
}

.live-card-head {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.live-rank {
  min-width: 20px;
  color: var(--text-faint);
  font-weight: 700;
  text-align: center;
}

.live-rank.first {
  color: #ffd76d;
}

.live-name {
  flex: 1;
  font-weight: 700;
  font-size: 14px;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.live-name:hover {
  color: var(--accent);
  text-decoration: none;
}

.live-title {
  font-size: 12px;
  color: var(--text-dim);
  line-height: 1.5;
  min-height: 36px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.live-viewers {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-top: 2px;
}

.live-num {
  font-size: 26px;
  font-weight: 800;
  line-height: 1.1;
  color: var(--text);
}

.live-label {
  font-size: 12px;
  color: var(--text-faint);
}

.live-bar-track {
  height: 5px;
  background: var(--bg-soft);
  border-radius: 3px;
  overflow: hidden;
}

.live-bar {
  height: 100%;
  border-radius: 3px;
  background: linear-gradient(90deg, var(--accent), #7ee787);
}

.live-foot {
  font-size: 11px;
  color: var(--text-faint);
  margin-top: auto;
}

/* ---------- 区块标题 ---------- */
.section {
  margin-bottom: 26px;
}

.section-title {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin: 0 0 12px;
  font-size: 19px;
}

.section-title small {
  font-size: 12px;
  color: var(--text-faint);
  font-weight: 400;
}

/* ---------- 热力图 ---------- */
.heatmap-wrap {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  box-shadow: var(--shadow);
  overflow-x: auto;
}

#heatmap {
  border-collapse: separate;
  border-spacing: 3px;
  width: 100%;
  min-width: 780px;
}

#heatmap th,
#heatmap td {
  text-align: center;
  vertical-align: middle;
}

#heatmap .corner,
#heatmap .day-head {
  font-size: 12px;
  color: var(--text-dim);
  padding: 2px 8px;
  white-space: nowrap;
  font-weight: 500;
}

#heatmap .day-head {
  text-align: left;
}

#heatmap .hour-head {
  font-size: 11px;
  color: var(--text-faint);
  font-weight: 400;
  padding: 2px 0;
}

#heatmap .heat-cell {
  width: 3.8%;
  height: 38px;
  border-radius: 5px;
  font-size: 12px;
  color: #fff;
  font-weight: 600;
  cursor: default;
  transition: transform 0.1s;
}

#heatmap .heat-cell:hover {
  outline: 2px solid rgba(255, 255, 255, 0.65);
  outline-offset: -1px;
  transform: scale(1.05);
  position: relative;
  z-index: 2;
}

.legend {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 10px;
  font-size: 12px;
  color: var(--text-faint);
}

.legend-bar {
  display: flex;
  width: 200px;
  height: 10px;
  border-radius: 5px;
  overflow: hidden;
}

.legend-bar div {
  flex: 1;
}

/* ---------- TOP5 ---------- */
.top-slots {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 12px;
}

.slot-card {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
  box-shadow: var(--shadow);
  position: relative;
  overflow: hidden;
}

.slot-rank {
  font-size: 22px;
  font-weight: 800;
  color: var(--accent);
  opacity: 0.85;
  min-width: 34px;
}

.slot-info {
  flex: 1;
  min-width: 0;
}

.slot-name {
  font-weight: 700;
}

.slot-meta {
  font-size: 12px;
  color: var(--text-dim);
}

.slot-bar-wrap {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 3px;
  background: var(--border);
}

.slot-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), #7ee787);
}

/* ---------- 主播明细表 ---------- */
.table-wrap {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow-x: auto;
}

table.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  min-width: 720px;
}

table.data-table th,
table.data-table td {
  padding: 9px 12px;
  text-align: right;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

table.data-table th {
  color: var(--text-dim);
  font-weight: 500;
  font-size: 12px;
  position: sticky;
  top: 0;
  background: var(--card);
}

table.data-table th.sortable {
  cursor: pointer;
  user-select: none;
}

table.data-table th.sortable:hover {
  color: var(--accent);
}

table.data-table th.sorted {
  color: var(--accent);
}

.sort-ind {
  display: inline-block;
  margin-left: 4px;
  font-size: 10px;
}

table.data-table tr:last-child td {
  border-bottom: none;
}

table.data-table tbody tr:hover {
  background: var(--card-hover);
}

table.data-table td:first-child,
table.data-table th:first-child {
  text-align: left;
}

.empty-hint {
  color: var(--text-faint);
  text-align: center;
  padding: 22px 0;
}

/* ---------- 状态 ---------- */
.error-box {
  background: rgba(248, 81, 73, 0.1);
  border: 1px solid rgba(248, 81, 73, 0.4);
  color: #ffb3b0;
  border-radius: var(--radius);
  padding: 12px 16px;
  margin-bottom: 16px;
}

.error-box.hidden,
.loading.hidden {
  display: none;
}

.error-box.warning {
  background: rgba(219, 171, 9, 0.12);
  border-color: rgba(219, 171, 9, 0.45);
  color: #ffd76d;
}

.loading {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text-dim);
  padding: 10px 0;
}

.spinner {
  width: 16px;
  height: 16px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* ---------- 页脚 ---------- */
.site-footer {
  margin-top: 40px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
  color: var(--text-faint);
  font-size: 12px;
  line-height: 1.8;
}

/* ---------- 响应式 ---------- */
@media (max-width: 760px) {
  .page {
    padding: 16px 12px 40px;
  }

  .site-header h1 {
    font-size: 22px;
  }

  .stats {
    grid-template-columns: repeat(2, 1fr);
  }

  .controls {
    align-items: stretch;
  }

  .control-group {
    flex: 1 1 45%;
  }

  .spacer {
    display: none;
  }

  .updated {
    flex-basis: 100%;
  }
}
