/* 中国省情一图览 · 样式
   深色科技风，与「我国主要河流分布图」同一调性 */

:root {
  --bg: #0b1220;
  --bg-soft: #111a2e;
  --panel: rgba(14, 22, 40, 0.92);
  --panel-solid: #101a30;
  --line: rgba(148, 163, 184, 0.22);
  --text: #e8eefc;
  --text-dim: #9fb0cc;
  --text-mute: #6f819e;
  --accent: #38bdf8;
  --accent-2: #fbbf24;
  --up: #f87171;      /* 涨/增 —— 红 */
  --down: #4ade80;    /* 跌/减 —— 绿 */
  --radius: 12px;
  --shadow: 0 10px 34px rgba(0, 0, 0, 0.45);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: "PingFang SC", "Microsoft YaHei", "Hiragino Sans GB", system-ui, -apple-system, sans-serif;
  -webkit-font-smoothing: antialiased;
}

#map { position: absolute; inset: 0; }

/* ---------- 顶部栏 ---------- */
.topbar {
  position: absolute;
  top: 0; left: 0; right: 0;
  z-index: 20;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 18px;
  background: linear-gradient(180deg, rgba(8, 14, 28, 0.92) 0%, rgba(8, 14, 28, 0.55) 70%, rgba(8, 14, 28, 0) 100%);
  pointer-events: none;
}
.topbar > * { pointer-events: auto; }

.brand h1 {
  margin: 0;
  font-size: 20px;
  letter-spacing: 0.5px;
  font-weight: 700;
}
.brand .sub {
  margin: 4px 0 0;
  font-size: 12.5px;
  color: var(--text-dim);
  line-height: 1.5;
}
.brand .sub b { color: var(--accent); font-weight: 600; }

.top-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.seg {
  display: inline-flex;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 3px;
  backdrop-filter: blur(8px);
}
.seg-btn {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--text-dim);
  font: inherit;
  font-size: 12.5px;
  padding: 6px 13px;
  border-radius: 999px;
  cursor: pointer;
  white-space: nowrap;
  transition: background .15s, color .15s;
}
.seg-btn:hover { color: var(--text); }
.seg-btn.active {
  background: var(--accent);
  color: #06121f;
  font-weight: 700;
}
.seg.small .seg-btn { padding: 5px 10px; font-size: 12px; }
.seg-btn.disabled { opacity: .38; cursor: not-allowed; }
.seg-btn.disabled:hover { color: var(--text-dim); }

.year-row {
  display: inline-flex;
  align-items: center;
  gap: 7px;
}
.year-row .lbl {
  font-size: 11.5px;
  color: var(--text-mute);
  letter-spacing: .04em;
}

.ghost-btn {
  appearance: none;
  background: var(--panel);
  border: 1px solid var(--line);
  color: var(--text);
  font: inherit;
  font-size: 12.5px;
  padding: 7px 12px;
  border-radius: 999px;
  cursor: pointer;
  backdrop-filter: blur(8px);
}
.ghost-btn:hover { border-color: var(--accent); color: var(--accent); }

/* ---------- 图例 ---------- */
.legend {
  position: absolute;
  left: 18px;
  bottom: 46px;
  z-index: 15;
  width: 208px;
  padding: 12px 14px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  backdrop-filter: blur(8px);
  box-shadow: var(--shadow);
}
.legend-title { font-size: 13px; font-weight: 700; margin-bottom: 8px; }
.legend-bar {
  height: 9px;
  border-radius: 5px;
  background: linear-gradient(90deg, #0c2b4a, #1d5c8f, #2b8fbe, #58c3d6, #a8e063, #fbbf24, #f97316, #dc2626);
}
.legend-scale {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: var(--text-mute);
  margin-top: 5px;
}
.legend-note { font-size: 11px; color: var(--text-mute); margin-top: 8px; line-height: 1.45; }
.legend-hint { font-size: 11px; color: #67e8f9; margin-top: 4px; line-height: 1.45; opacity: .85; }

/* ---------- 省份卡片 ---------- */
.card-panel {
  position: absolute;
  top: 74px; right: 18px; bottom: 46px;
  z-index: 25;
  width: 372px;
  max-width: calc(100vw - 36px);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
  transform: translateX(calc(100% + 26px));
  transition: transform .28s cubic-bezier(.22, .61, .36, 1);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.card-panel.open { transform: translateX(0); }
.card-close {
  position: absolute;
  top: 8px; right: 10px;
  z-index: 3;
  appearance: none;
  border: 0;
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
  width: 26px; height: 26px;
  border-radius: 50%;
  font-size: 17px;
  line-height: 1;
  cursor: pointer;
}
.card-close:hover { background: rgba(255, 255, 255, 0.18); }
.card-inner {
  overflow-y: auto;
  padding: 16px 18px 20px;
  scrollbar-width: thin;
  scrollbar-color: rgba(148, 163, 184, .4) transparent;
}
.card-inner::-webkit-scrollbar { width: 6px; }
.card-inner::-webkit-scrollbar-thumb { background: rgba(148, 163, 184, .35); border-radius: 3px; }

.c-head { border-bottom: 1px solid var(--line); padding-bottom: 12px; margin-bottom: 12px; }
.c-name { font-size: 21px; font-weight: 800; letter-spacing: .5px; }
.c-meta { font-size: 12px; color: var(--text-mute); margin-top: 3px; }
.c-tag {
  display: inline-block;
  margin-top: 9px;
  font-size: 12px;
  color: var(--accent-2);
  background: rgba(251, 191, 36, .12);
  border: 1px solid rgba(251, 191, 36, .32);
  border-radius: 999px;
  padding: 4px 10px;
  line-height: 1.35;
}

.c-kpis {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 6px;
}
.kpi {
  background: rgba(56, 189, 248, .07);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 9px 11px;
}
.kpi .k { font-size: 11px; color: var(--text-mute); }
.kpi .v { font-size: 17px; font-weight: 800; margin-top: 2px; letter-spacing: .3px; }
.kpi .v small { font-size: 11px; font-weight: 600; color: var(--text-dim); margin-left: 2px; }
.kpi .d { font-size: 11px; margin-top: 2px; color: var(--text-mute); }
.up { color: var(--up) !important; }
.down { color: var(--down) !important; }

.c-sec { margin-top: 16px; }
.c-sec h3 {
  margin: 0 0 7px;
  font-size: 13px;
  color: var(--accent);
  display: flex;
  align-items: center;
  gap: 6px;
  letter-spacing: .5px;
}
.c-sec h3::before {
  content: "";
  width: 3px; height: 13px;
  background: var(--accent);
  border-radius: 2px;
}
.c-sec p { margin: 0; font-size: 13px; line-height: 1.75; color: #d6e0f4; }
.c-sec .dim { color: var(--text-dim); font-size: 12.5px; }

/* 历年数据小表 */
.c-sec h3 .hint {
  font-size: 10.5px;
  font-weight: 500;
  color: var(--text-mute);
  letter-spacing: 0;
}
table.trend {
  width: 100%;
  border-collapse: collapse;
  margin-top: 8px;
  font-size: 11.5px;
  font-variant-numeric: tabular-nums;
}
table.trend th, table.trend td {
  padding: 5px 6px;
  text-align: right;
  border-bottom: 1px solid var(--line);
  color: #cfdcf2;
}
table.trend thead th {
  color: var(--text-mute);
  font-weight: 600;
  font-size: 11px;
  text-align: right;
}
table.trend thead th.on { color: var(--accent); }
table.trend tbody th {
  text-align: left;
  font-weight: 600;
  color: var(--text-dim);
  white-space: nowrap;
}
table.trend tbody th small { display: block; font-size: 10px; color: var(--text-mute); font-weight: 400; }
table.trend td.on {
  color: #eaf2ff;
  font-weight: 700;
  background: rgba(56, 189, 248, .09);
}

.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.chip {
  font-size: 12px;
  padding: 3px 9px;
  border-radius: 999px;
  background: rgba(255, 255, 255, .06);
  border: 1px solid var(--line);
  color: #cddef6;
}
.chip.water { background: rgba(56, 189, 248, .12); border-color: rgba(56, 189, 248, .3); }
.chip.lake { background: rgba(45, 212, 191, .12); border-color: rgba(45, 212, 191, .3); }

.best-list { margin: 0; padding: 0; list-style: none; }
.best-list li {
  display: flex;
  gap: 9px;
  padding: 8px 0;
  border-bottom: 1px dashed rgba(148, 163, 184, .16);
  font-size: 13px;
  line-height: 1.65;
}
.best-list li:last-child { border-bottom: 0; }
.best-list .idx {
  flex: 0 0 auto;
  width: 20px; height: 20px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #06121f;
  font-size: 11px;
  font-weight: 800;
  display: flex; align-items: center; justify-content: center;
  margin-top: 2px;
}
.best-list .bt { font-weight: 700; color: #fff; }
.best-list .bd { color: var(--text-dim); font-size: 12.5px; }

.c-actions { margin-top: 18px; display: flex; gap: 8px; }
.c-actions a {
  flex: 1;
  text-align: center;
  text-decoration: none;
  font-size: 13px;
  font-weight: 700;
  padding: 10px 12px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--accent), #0ea5e9);
  color: #04121d;
}
.c-actions a.secondary {
  background: rgba(255, 255, 255, .07);
  border: 1px solid var(--line);
  color: var(--text);
  font-weight: 600;
}

/* ---------- 34 省目录抽屉 ---------- */
.catalog {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  z-index: 30;
  max-height: 74vh;
  display: flex;
  flex-direction: column;
  background: var(--panel-solid);
  border-top: 1px solid var(--line);
  box-shadow: 0 -14px 40px rgba(0, 0, 0, .5);
  transform: translateY(100%);
  transition: transform .3s cubic-bezier(.22, .61, .36, 1);
}
.catalog.open { transform: translateY(0); }
.catalog-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 20px 10px;
  border-bottom: 1px solid var(--line);
}
.catalog-head h2 { margin: 0; font-size: 16px; }
.catalog-head p { margin: 3px 0 0; font-size: 12px; color: var(--text-mute); }
.catalog-body {
  overflow-y: auto;
  padding: 12px 20px 22px;
  scrollbar-width: thin;
}
.catalog-body::-webkit-scrollbar { width: 7px; }
.catalog-body::-webkit-scrollbar-thumb { background: rgba(148, 163, 184, .35); border-radius: 4px; }

.region-block { margin-bottom: 16px; }
.region-title {
  font-size: 12.5px;
  color: var(--accent);
  font-weight: 700;
  letter-spacing: 1px;
  margin: 0 0 8px;
  display: flex; align-items: center; gap: 8px;
}
.region-title::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.pgrid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 8px;
}
.pcell {
  display: block;
  text-decoration: none;
  color: var(--text);
  background: rgba(255, 255, 255, .04);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 9px 11px;
  transition: border-color .15s, background .15s, transform .15s;
}
.pcell:hover {
  border-color: var(--accent);
  background: rgba(56, 189, 248, .12);
  transform: translateY(-2px);
}
.pcell .pn { font-size: 14px; font-weight: 700; display: flex; align-items: baseline; gap: 6px; }
.pcell .pn em {
  font-style: normal;
  font-size: 11px;
  color: var(--accent-2);
  border: 1px solid rgba(251, 191, 36, .35);
  border-radius: 4px;
  padding: 0 4px;
}
.pcell .pv { font-size: 11.5px; color: var(--text-mute); margin-top: 3px; }

/* 省份简称 DOM 标注 */
.map-labels {
  position: absolute;
  inset: 0;
  z-index: 10;
  pointer-events: none;
  overflow: hidden;
}
.map-label {
  position: absolute;
  transform: translate(-50%, -50%);
  font-size: 12.5px;
  font-weight: 700;
  color: #0b1220;
  background: rgba(255, 255, 255, .84);
  border: 1px solid rgba(11, 18, 32, .25);
  border-radius: 5px;
  padding: 1px 6px;
  white-space: nowrap;
  pointer-events: auto;
  cursor: pointer;
  box-shadow: 0 1px 4px rgba(0, 0, 0, .3);
  transition: background .15s, color .15s;
}
.map-label:hover { background: #fff; color: #0369a1; }
.map-label.dim { font-size: 11px; padding: 0 4px; opacity: .9; }
.map-label.active { background: var(--accent); color: #04121d; border-color: var(--accent); }

.src-note {
  position: absolute;
  left: 18px; bottom: 12px;
  z-index: 12;
  font-size: 11px;
  color: var(--text-mute);
  max-width: 62vw;
  line-height: 1.5;
  text-shadow: 0 1px 4px rgba(0, 0, 0, .8);
}

/* ---------- 地图提示气泡 ---------- */
.maplibregl-popup .maplibregl-popup-content {
  background: rgba(12, 20, 38, .95);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 7px 11px;
  font-size: 12.5px;
  box-shadow: var(--shadow);
}
.maplibregl-popup .maplibregl-popup-tip { border-top-color: rgba(12, 20, 38, .95); }
.maplibregl-popup-content b { color: var(--accent); }
.maplibregl-ctrl-attrib { background: rgba(0, 0, 0, .45) !important; }
.maplibregl-ctrl-attrib a { color: #9fb0cc !important; }

/* ================= 省份详情页 ================= */
.p-wrap { max-width: 1080px; margin: 0 auto; padding: 0 20px 60px; }

.p-topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 20px;
  background: rgba(11, 18, 32, .92);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.p-topbar .back {
  color: var(--text-dim);
  text-decoration: none;
  font-size: 13px;
}
.p-topbar .back:hover { color: var(--accent); }
.p-topbar .crumb { font-size: 12px; color: var(--text-mute); }

.p-hero { padding: 26px 0 6px; }
.p-hero h1 { margin: 0; font-size: 32px; letter-spacing: 1px; }
.p-hero .p-sub { margin: 8px 0 0; font-size: 13.5px; color: var(--text-mute); }
.p-hero .p-tag {
  display: inline-block;
  margin-top: 12px;
  font-size: 13px;
  color: var(--accent-2);
  background: rgba(251, 191, 36, .12);
  border: 1px solid rgba(251, 191, 36, .32);
  border-radius: 999px;
  padding: 5px 12px;
}

.p-kpis {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 10px;
  margin: 20px 0 6px;
}
.p-kpi {
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 16px;
}
.p-kpi .k { font-size: 12px; color: var(--text-mute); }
.p-kpi .v { font-size: 24px; font-weight: 800; margin-top: 4px; letter-spacing: .5px; }
.p-kpi .v small { font-size: 12px; font-weight: 600; color: var(--text-dim); margin-left: 3px; }
.p-kpi .d { font-size: 11.5px; margin-top: 4px; color: var(--text-mute); }

.p-map {
  position: relative;
  height: 320px;
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--line);
  margin: 16px 0 4px;
}
.p-sec { margin-top: 30px; }
.p-sec > h2 {
  font-size: 18px;
  margin: 0 0 12px;
  display: flex; align-items: center; gap: 9px;
}
.p-sec > h2::before {
  content: "";
  width: 4px; height: 17px;
  background: linear-gradient(180deg, var(--accent), var(--accent-2));
  border-radius: 2px;
}
.p-sec p { font-size: 14.5px; line-height: 1.85; color: #d6e0f4; margin: 0 0 10px; }
.p-sec .bar {
  font-size: 12px;
  color: var(--text-mute);
  margin-top: 10px;
  padding-top: 8px;
  border-top: 1px dashed rgba(148, 163, 184, .18);
}

.p-table { width: 100%; border-collapse: collapse; font-size: 13.5px; margin-top: 6px; }
.p-table th, .p-table td {
  text-align: left;
  padding: 9px 10px;
  border-bottom: 1px solid rgba(148, 163, 184, .16);
}
.p-table th { color: var(--text-mute); font-weight: 600; font-size: 12px; }
.p-table td b { color: var(--accent); }

.p-table.p-trend { font-size: 12.5px; font-variant-numeric: tabular-nums; }
.p-table.p-trend th, .p-table.p-trend td { text-align: right; padding: 8px 8px; }
.p-table.p-trend tbody th { text-align: left; white-space: nowrap; color: var(--text-dim); }
.p-table.p-trend tbody th small { display: block; font-size: 10.5px; color: var(--text-mute); font-weight: 400; }
.p-table.p-trend tbody td:last-child { font-weight: 700; }

/* ---------- 图表（省详情页） ---------- */
.chart-box {
  margin: 16px 0 18px;
  padding: 14px 16px 12px;
  background: rgba(17, 26, 46, .55);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.chart-head {
  display: flex; flex-wrap: wrap; gap: 8px 16px;
  align-items: center; justify-content: space-between;
  margin-bottom: 10px;
}
.chart-head .ct { font-size: 12.5px; color: var(--text-dim); font-weight: 600; }
.lg-row { display: flex; flex-wrap: wrap; gap: 12px; }
.lg { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text-dim); }
.lg i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.lg b { color: var(--text); font-variant-numeric: tabular-nums; }
svg.chart { width: 100%; height: auto; display: block; overflow: visible; }

.donut-row {
  display: flex; flex-wrap: wrap; gap: 14px;
  justify-content: space-around;
  margin: 14px 0 16px;
}
.dcell { text-align: center; width: 148px; }
svg.donut { width: 120px; height: 120px; display: block; margin: 0 auto 6px; }
.dcell .dname { font-size: 13px; color: var(--text-dim); font-weight: 600; }
.dcell .dval { font-size: 12.5px; color: var(--text); margin-top: 2px; font-variant-numeric: tabular-nums; }
.dcell .drank { font-size: 11.5px; color: var(--accent); margin-top: 2px; }

.bars { margin: 12px 0 14px; }
.brow {
  display: grid; grid-template-columns: 42px 1fr 86px;
  align-items: center; gap: 10px;
  padding: 4px 0;
  font-size: 12.5px; color: var(--text-dim);
}
.brow .btrack { height: 12px; background: rgba(148, 163, 184, .12); border-radius: 6px; overflow: hidden; }
.brow .btrack i { display: block; height: 100%; background: #33507a; border-radius: 6px; }
.brow .bv { text-align: right; font-variant-numeric: tabular-nums; color: var(--text-mute); }
.brow.on { color: var(--accent); font-weight: 700; }
.brow.on .btrack i { background: linear-gradient(90deg, #38bdf8, #22d3ee); }
.brow.on .bv { color: var(--accent); }

.p-best { list-style: none; margin: 0; padding: 0; }
.p-best li {
  display: flex; gap: 12px;
  padding: 12px 14px;
  margin-bottom: 9px;
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-left: 3px solid var(--accent-2);
  border-radius: 10px;
}
.p-best .idx {
  flex: 0 0 24px; height: 24px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #06121f;
  font-size: 12px; font-weight: 800;
  display: flex; align-items: center; justify-content: center;
}
.p-best .bt { font-weight: 700; font-size: 14.5px; }
.p-best .bd { font-size: 13px; color: var(--text-dim); margin-top: 3px; line-height: 1.7; }

.p-nav {
  display: flex; justify-content: space-between; gap: 10px;
  margin-top: 34px; padding-top: 18px;
  border-top: 1px solid var(--line);
}
.p-nav a {
  text-decoration: none;
  color: var(--text);
  font-size: 13.5px;
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 14px;
  max-width: 46%;
}
.p-nav a:hover { border-color: var(--accent); color: var(--accent); }
.p-nav span.n { display: block; font-size: 11px; color: var(--text-mute); margin-bottom: 2px; }

.p-related { margin-top: 26px; }
.p-related .chips a { text-decoration: none; color: inherit; }
.p-related .chips a:hover { border-color: var(--accent); color: var(--accent); }

.p-footer {
  margin-top: 40px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
  font-size: 12px;
  color: var(--text-mute);
  line-height: 1.8;
}

/* ---------- 站内导航（地图跑在主站 iframe 内，target="_top" 跳出 iframe） ---------- */
.map-nav {
  position: absolute;
  right: 18px;
  bottom: 152px;
  z-index: 15;
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: flex-end;
}
.map-nav a {
  display: inline-block;
  padding: 6px 12px;
  font-size: 12px;
  color: var(--text-dim);
  text-decoration: none;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 999px;
  backdrop-filter: blur(8px);
  box-shadow: var(--shadow);
}
.map-nav a:hover { color: var(--accent); border-color: var(--accent); }

/* ---------- 移动端 ---------- */
@media (max-width: 900px) {
  .topbar { flex-direction: column; align-items: stretch; }
  .top-actions { justify-content: flex-start; }
  .map-nav { top: 104px; right: 12px; bottom: auto; }
  .card-panel {
    top: auto; left: 0; right: 0; bottom: 0;
    width: auto;
    max-height: 62vh;
    border-radius: 14px 14px 0 0;
    transform: translateY(calc(100% + 20px));
  }
  .card-panel.open { transform: translateY(0); }
  .legend { display: none; }
  .src-note { display: none; }
  .p-hero h1 { font-size: 25px; }
  .catalog { max-height: 82vh; }
}
