:root {
  --bg: #f5f6f8;
  --panel: #ffffff;
  --line: #e4e7eb;
  --line-2: #d3d8de;
  --text: #1f2328;
  --text-2: #59616b;
  --text-3: #8c949f;
  --pos: #c0392b;
  --neg: #1d8348;
  --accent: #2f6fed;
  --accent-weak: #eaf0fd;
  --accent-ring: #cfe0ff;
  --head-deep: #14315f;
  --head-mid: #1f4b99;
  --hover: #f0f2f5;
  --hover-row: #fafcff;
  --seg-bg: #f4f6f9;
  --chip-bg: #f1f3f6;
  --th-bg: #f8f9fb;
  --row-sum: #fcfcfd;
  --row-diff: #fbfbfc;
  --warn-bg: #fff8e6;
  --warn-line: #f2dfae;
  --warn-text: #7a5b12;
  --radius: 10px;
  /* 吸顶高度：JS 在载入与尺寸变化时覆写，务必保持与 .board-stick 实测一致 */
  --stick-h: 160px;
}

* { box-sizing: border-box; }
html, body { margin: 0; }

body {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", sans-serif;
  -webkit-font-smoothing: antialiased;
}

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

/* ---------- 吸顶区（页头 + 工具条） ---------- */
.board-stick {
  position: sticky;
  top: 0;
  z-index: 40;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
}

.board-head {
  background: linear-gradient(120deg, var(--head-deep) 0%, var(--head-mid) 62%, var(--accent) 130%);
  color: #fff;
}
.head-inner {
  max-width: 1680px;
  margin: 0 auto;
  padding: 26px 20px 22px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  transition: padding .18s ease, gap .18s ease;
}
.board-head h1 {
  margin: 0;
  font-size: 32px;
  font-weight: 500;
  letter-spacing: .5px;
  line-height: 1.2;
  text-align: center;
  color: #fff;
  transition: font-size .18s ease, letter-spacing .18s ease;
}
.head-chips { display: flex; flex: 0 0 auto; gap: 8px; }
.chip {
  display: inline-flex;
  align-items: center;
  height: 26px;
  padding: 0 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, .16);
  color: #fff;
  font-size: 12px;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
  transition: height .18s ease;
}
.chip-city { background: #fff; color: var(--head-deep); font-weight: 500; }

/* 滚动态：大标题收成细条，标题与城市/月份并排居中 */
.board-stick.compact .head-inner {
  flex-direction: row;
  justify-content: center;
  gap: 14px;
  padding: 10px 20px;
}
.board-stick.compact h1 { font-size: 18px; letter-spacing: 0; }
.board-stick.compact .chip { height: 22px; }

/* ---------- 工具条：页签 + 筛选 ---------- */
.board-bar { border-top: 1px solid var(--line); background: var(--panel); }
.bar-inner {
  max-width: 1680px;
  margin: 0 auto;
  padding: 8px 20px;
  display: flex;
  align-items: center;
  gap: 14px;
  min-height: 52px;
}
.seg {
  display: flex;
  flex: 0 0 auto;
  gap: 2px;
  padding: 3px;
  background: var(--seg-bg);
  border-radius: 9px;
}
.seg a {
  padding: 5px 14px;
  border-radius: 7px;
  font-size: 13px;
  color: var(--text-2);
  white-space: nowrap;
}
.seg a:hover { background: #fff; color: var(--text); text-decoration: none; }
.seg a.on {
  background: var(--panel);
  color: var(--text);
  font-weight: 500;
  box-shadow: 0 1px 2px rgba(16, 24, 40, .08);
}
.bar-sep { flex: 0 0 auto; width: 1px; height: 24px; background: var(--line); }

.filters {
  display: flex;
  flex: 1 1 auto;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}
.filters label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-3);
}
.filters .actions { display: flex; gap: 8px; margin-left: auto; }

select, button, .btn { font: inherit; }
select {
  height: 32px;
  min-width: 118px;
  padding: 0 26px 0 8px;
  color: var(--text);
  background: #fff;
  border: 1px solid var(--line-2);
  border-radius: 7px;
}
select:focus-visible { outline: 2px solid var(--accent-ring); outline-offset: -1px; border-color: var(--accent); }
button {
  height: 32px;
  padding: 0 14px;
  color: #fff;
  background: var(--accent);
  border: 1px solid transparent;
  border-radius: 7px;
  cursor: pointer;
  white-space: nowrap;
}
button:hover { filter: brightness(.95); }
button.ghost { color: var(--text-2); background: #fff; border-color: var(--line-2); }
button.ghost:hover { background: #f3f5f8; filter: none; }

/* 「清除状态」用链接实现：回退到无参地址即恢复默认筛选，无需后端配合 */
.btn {
  display: inline-flex;
  align-items: center;
  height: 32px;
  padding: 0 14px;
  border: 1px solid transparent;
  border-radius: 7px;
  color: #fff;
  background: var(--accent);
  font-size: 14px;
  white-space: nowrap;
  cursor: pointer;
}
.btn:hover { filter: brightness(.95); text-decoration: none; }
.btn.ghost { color: var(--text-2); background: #fff; border-color: var(--line-2); }
.btn.ghost:hover { background: #f3f5f8; filter: none; }

main { flex: 1 1 auto; width: 100%; max-width: 1680px; margin: 0 auto; padding: 12px 20px 40px; }

/* ---------- 公共页脚（备案信息） ---------- */
.site-footer {
  border-top: 1px solid var(--line);
  background: var(--panel);
}
.site-footer .footer-inner {
  max-width: 1680px;
  margin: 0 auto;
  padding: 14px 20px;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
  color: var(--text-3);
  font-size: 12px;
}
.site-footer .icp { color: var(--text-2); }
.site-footer .icp:hover { color: var(--accent); text-decoration: underline; }

/* ---------- 提示与说明 ---------- */
.notice {
  margin: 0 0 12px;
  padding: 10px 12px;
  font-size: 13px;
  color: var(--warn-text);
  background: var(--warn-bg);
  border: 1px solid var(--warn-line);
  border-radius: 8px;
}
.legend { margin: 2px 0 10px; font-size: 12px; color: var(--text-3); }

/* ---------- 板块卡片（折叠） ---------- */
.card {
  margin-bottom: 10px;
  overflow: hidden;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.card > summary {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 9px 14px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  list-style: none;
}
.card > summary::-webkit-details-marker { display: none; }
.card > summary::before {
  content: "";
  flex: 0 0 auto;
  width: 0;
  height: 0;
  border-top: 4px solid transparent;
  border-bottom: 4px solid transparent;
  border-left: 5px solid var(--text-3);
  transition: transform .15s ease;
}
.card[open] > summary::before { transform: rotate(90deg); }
.card[open] > summary { border-bottom: 1px solid var(--line); }
.card > summary:hover { background: var(--row-sum); }

.gname { font-weight: 500; color: var(--text); }
.gvals { display: flex; align-items: center; gap: 10px; margin-left: auto; font-size: 12px; color: var(--text-2); }
.gvals em { font-style: normal; color: var(--text-3); }
.gvals b { font-weight: 500; color: var(--text); }

/* ---------- 表格 ---------- */
table.data {
  width: 100%;
  font-size: 13px;
  border-collapse: separate;
  border-spacing: 0;
  table-layout: fixed;
}
table.data th,
table.data td {
  padding: 6px 10px;
  text-align: left;
  vertical-align: middle;
  border-bottom: 1px solid var(--line);
}
/* 表头 sticky 的参照物是最近的滚动容器：利润表在原位卡片内、分队利润在 .table-wrap 内。
   两处容器都不吸顶，因此这里必须是 top: 0；写成 var(--stick-h) 会在容器顶部留出空洞。 */
table.data thead th {
  position: sticky;
  top: 0;
  z-index: 5;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-2);
  white-space: nowrap;
  background: var(--th-bg);
  border-bottom: 1px solid var(--line-2);
}
table.data tbody tr:hover td { background: var(--hover-row); }
table.data tbody tr:last-child td { border-bottom: 0; }

.num { text-align: right; font-variant-numeric: tabular-nums; }
.zero { color: var(--text-3); }
.pos { color: var(--pos); }
.neg { color: var(--neg); }
.mon { text-align: center; color: var(--text-3); white-space: nowrap; }

tr.lv1 td { font-weight: 500; background: var(--row-sum); }
tr.lv2 td { color: var(--text-2); }

col.c-mon { width: 84px; }
col.c-num { width: 136px; }

/* ---------- 宽表：横向滚动 + 双向吸附 ---------- */
.table-wrap {
  max-height: calc(100vh - var(--stick-h) - 40px);
  overflow: auto;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
table.wide { width: auto; min-width: 100%; table-layout: auto; }
table.wide thead th { z-index: 7; }
table.wide th.sticky-1,
table.wide td.sticky-1 {
  position: sticky;
  left: 0;
  z-index: 4;
  min-width: 172px;
  background: var(--panel);
  box-shadow: 1px 0 0 var(--line);
}
table.wide th.sticky-2,
table.wide td.sticky-2 {
  position: sticky;
  left: 172px;
  z-index: 4;
  background: var(--panel);
  box-shadow: 1px 0 0 var(--line);
}
table.wide thead th.sticky-1,
table.wide thead th.sticky-2 { background: var(--th-bg); }
table.wide tbody tr:hover td.sticky-1,
table.wide tbody tr:hover td.sticky-2 { background: var(--hover-row); }

tr.t-diff td { background: var(--row-diff); color: var(--text-2); }
tr.t-first td { border-top: 1px solid var(--line-2); }
tr.t-first:first-child td { border-top: 0; }

/* ---------- 响应式 ---------- */
@media (max-width: 1100px) {
  .bar-inner { flex-wrap: wrap; }
  .filters { justify-content: flex-start; }
  .bar-sep { display: none; }
}

@media (max-width: 720px) {
  .head-inner { padding: 20px 12px 16px; gap: 10px; }
  .board-head h1 { font-size: 22px; letter-spacing: .2px; }
  .bar-inner { padding: 8px 12px; gap: 10px; }
  main { padding: 10px 12px 32px; }
  col.c-num { width: 112px; }
  .filters label { flex-direction: column; align-items: flex-start; gap: 3px; }
  select { min-width: 104px; }
  /* 收起时不再整块隐藏汇总值，改为紧凑显示 */
  .gvals { gap: 6px; font-size: 11px; }
}
