:root {
  --bg: #f4f6fa;
  --panel: #ffffff;
  --line: #e3e8f0;
  --ink: #1f2937;
  --ink2: #6b7280;
  --brand: #2f5597;
  --brand-soft: #eaf1fb;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(16, 24, 40, .06), 0 1px 2px rgba(16, 24, 40, .04);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
               "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}

/* ---------- 顶栏 ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  box-shadow: var(--shadow);
}
.topbar-inner {
  max-width: 1780px;
  margin: 0 auto;
  padding: 12px 20px 8px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  flex-wrap: wrap;
}
.brand h1 {
  margin: 0;
  font-size: 18px;
  font-weight: 650;
  letter-spacing: .3px;
  color: var(--brand);
}
.brand .sub {
  margin: 4px 0 0;
  font-size: 12px;
  color: var(--ink2);
}

.toolbar {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}
.year-box { display: flex; gap: 6px; flex-wrap: wrap; }

.ctl {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  color: var(--ink2);
  cursor: pointer;
  user-select: none;
}
.ctl input { cursor: pointer; }

.btn {
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--ink2);
  font-size: 12px;
  padding: 5px 12px;
  border-radius: 6px;
  cursor: pointer;
  transition: all .15s;
}
.btn:hover { border-color: var(--brand); color: var(--brand); background: var(--brand-soft); }

/* 年份开关 */
.ytoggle {
  border: 1px solid var(--line);
  background: var(--panel);
  border-radius: 999px;
  padding: 3px 11px;
  font-size: 12px;
  color: var(--ink2);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  transition: all .15s;
}
.ytoggle .dot {
  width: 9px; height: 9px; border-radius: 50%;
  background: currentColor; opacity: .25;
}
.ytoggle.on { color: var(--ink); border-color: #cbd5e1; background: #f8fafc; }
.ytoggle.on .dot { opacity: 1; }

/* ---------- Tab ---------- */
.tabs {
  max-width: 1780px;
  margin: 0 auto;
  padding: 0 20px;
  display: flex;
  gap: 4px;
}
.tab {
  border: none;
  background: transparent;
  padding: 9px 16px;
  font-size: 13px;
  color: var(--ink2);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: all .15s;
  font-family: inherit;
}
.tab:hover { color: var(--brand); }
.tab.active {
  color: var(--brand);
  border-bottom-color: var(--brand);
  font-weight: 600;
}
.tab .cnt {
  font-size: 11px;
  color: #94a3b8;
  margin-left: 5px;
}

/* ---------- 主体 ---------- */
main {
  max-width: 1780px;
  margin: 0 auto;
  padding: 18px 20px 40px;
}
.loading { padding: 60px; text-align: center; color: var(--ink2); }

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(430px, 1fr));
  gap: 14px;
}

/* 分矿山（reuters_mine）：强制 2 张/行，方便对比四大矿山 */
.grid.grid-2 { grid-template-columns: repeat(2, 1fr); }

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.card-head {
  padding: 9px 14px;
  border-bottom: 1px solid var(--line);
  font-size: 13px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  background: linear-gradient(180deg, #fcfdff, #f7f9fc);
}
.card-head .tag {
  font-size: 11px;
  font-weight: 400;
  color: #94a3b8;
}
.chart {
  width: 100%;
  height: 330px;
}
.card.wide { grid-column: 1 / -1; }
.card.wide .chart { height: 420px; }

/* ---------- 页脚 ---------- */
.foot {
  max-width: 1780px;
  margin: 0 auto;
  padding: 16px 20px 30px;
  display: flex;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  font-size: 12px;
  color: #94a3b8;
  border-top: 1px solid var(--line);
}
.foot .disc { color: #b0b8c4; }

/* ---------- 截图模式 ---------- */
body.shot .topbar { position: static; box-shadow: none; }
body.shot .foot { display: none; }

/* 路透专题长图：截图时顶部居中的总标题（仅 body.shot 显示，不打扰线上浏览）。
   作为 <main> 首元素，裁掉顶部 chrome 后自然落在长图最顶端。 */
.shot-title { display: none; }
body.shot .shot-title {
  display: block;
  text-align: center;
  font-family: "KaiTi", "STKaiti", "楷体", serif;
  font-size: 28px;
  font-weight: 700;
  color: #1f2937;
  letter-spacing: 1px;
  padding: 4px 0 16px;
}
body.shot main { padding-top: 6px; }

@media (max-width: 900px) {
  .grid { grid-template-columns: 1fr; }
  .topbar-inner { flex-direction: column; }
}

/* ---------- 汇总表（在图表网格之前） ---------- */
.summary {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin: 16px auto 0;
  max-width: 1780px;
  overflow: hidden;
}
.summary-head {
  padding: 10px 16px;
  background: linear-gradient(180deg, #eaf1fb 0%, #f5f8fd 100%);
  border-bottom: 1px solid var(--line);
  font-size: 13px;
  color: var(--ink);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.summary-head strong { color: var(--brand); font-weight: 600; }
.summary-dates { color: var(--ink2); font-size: 12px; font-weight: normal; }
.summary-scroll {
  overflow-x: auto;
  overflow-y: hidden;
}
.summary-table {
  width: 100%;
  table-layout: fixed;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}
/* 全球发运专用：按截图（1998px 长图）量出的每列像素宽度，整体刚好等于截图宽度。
   容器宽度不够时由 .summary-scroll 横向滚动，列宽比例与长图完全一致。 */
.summary-table.global-fit {
  width: auto;
  min-width: 100%;
  table-layout: fixed;
  font-size: 12px;
}
.summary-table th,
.summary-table td {
  padding: 6px 7px;
  border-right: 1px solid #eef1f6;
  border-bottom: 1px solid #eef1f6;
  text-align: right;
  vertical-align: middle;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.summary-table thead th {
  white-space: normal;
  word-break: break-all;
  line-height: 1.25;
  text-overflow: clip;
}
.summary-table .row-label,
.summary-table td.row-label {
  background: #f8fafc;
  color: #475569;
  font-weight: 600;
  text-align: left;
  position: sticky;
  left: 0;
  z-index: 1;
  border-right: 2px solid var(--line);
  padding: 7px 10px;
  white-space: normal;
  overflow: visible;
  text-overflow: clip;
  min-width: 120px;
}
.summary-table .grp-row th {
  background: var(--brand);
  color: #fff;
  font-weight: 600;
  font-size: 12px;
  padding: 8px 10px;
  text-align: center;
  border-right: 1px solid #3d6ab2;
}
.summary-table .grp-row th.row-label {
  background: var(--brand);
  color: #fff;
  border-right: 1px solid #3d6ab2;
}

/* 差值行（环比/较年初/累计同比/累计增幅%）— 浅灰背景 + 标签字色淡，
   与"值行"（本期/上期）一眼能区分 */
.summary-table tr.r-delta {
  background: #f6f8fb;
}
.summary-table tr.r-delta .row-label,
.summary-table tr.r-delta td.row-label {
  background: #f6f8fb;
  color: #94a3b8;
  font-weight: 500;
}
.summary-table .lab-row th {
  background: var(--brand-soft);
  color: #1e3a5f;
  font-weight: 600;
  padding: 7px 12px;
  text-align: center;
}
.summary-table tbody tr:nth-child(even) td:not(.row-label) {
  background: #fafbfc;
}
.summary-table tbody tr:hover td:not(.row-label) {
  background: #f0f4ff;
}
.summary-table td.up {
  color: #b91c1c;
  background: #fee2e2 !important;
  font-weight: 600;
}
.summary-table td.down {
  color: #15803d;
  background: #dcfce7 !important;
  font-weight: 600;
}
.summary-table td.na { color: #cbd5e1; }
.summary-table tbody tr.r-累计同比 td.row-label,
.summary-table tbody tr.r-累计增幅% td.row-label {
  color: var(--brand);
}
