/* ==========================================================================
   数据大屏层
   --------------------------------------------------------------------------
   构成逻辑：中间是地图（空间的"面"），左栏是总量与结构（数字的"面"），
   右栏是当前选中的对象（具体的人/库）。三块都不占满，留出地图的呼吸。
   四角准星与发丝线是这套界面的记忆点 —— 像取景器，而不是常见的圆角卡片堆叠。
   ========================================================================== */

.app {
  background: var(--bg);
}

/* ---------- 顶栏 ---------- */

.hud-top {
  position: relative;
  z-index: 900;
  height: 62px;
  display: flex;
  align-items: center;
  gap: 26px;
  padding: 0 22px;
  background: linear-gradient(180deg, rgba(6, 13, 11, 0.97), rgba(3, 8, 6, 0.93));
  border-bottom: 1px solid var(--line);
}
.hud-top::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: -1px;
  height: 1px;
  background: linear-gradient(90deg, transparent, color-mix(in srgb, var(--accent) 50%, transparent), transparent);
}

.hud-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: none;
}
/* 品牌角标：4 个汉字按 2×2 落在方块里；上传图片后整块换成图片 */
.brand-mark {
  width: 42px;
  height: 42px;
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  grid-template-rows: repeat(2, 1fr);
  place-items: center;
  padding: 3px;
  border-radius: 2px;
  overflow: hidden;
  background: linear-gradient(150deg, var(--accent), #8a6220);
  color: #0c0906;
  font-family: "PingFang SC", "Microsoft YaHei", "Noto Sans CJK SC", system-ui, sans-serif;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0;
  line-height: 1;
}
.brand-mark i {
  font-style: normal;
}
.brand-mark.has-image {
  display: block;
  padding: 2px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid color-mix(in srgb, var(--accent) 34%, transparent);
}
.brand-mark img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  border-radius: 2px;
}
.brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.2;
}
.brand-text h1 {
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.06em;
}
.brand-text small {
  font-family: var(--font-mono);
  font-size: 9.5px;
  color: var(--muted-2);
  letter-spacing: 0.22em;
  margin-top: 3px;
}

/* 面包屑：省 / 市 */
.hud-crumb {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12.5px;
  color: var(--muted);
  padding-left: 22px;
  border-left: 1px solid var(--line);
  min-width: 200px;
}
.hud-crumb strong {
  color: var(--accent-bright);
  font-weight: 500;
  letter-spacing: 0.04em;
}
.crumb-link {
  font: inherit;
  background: none;
  border: 0;
  padding: 2px 0;
  color: var(--muted);
  cursor: pointer;
  border-bottom: 1px dotted var(--line-strong);
}
.crumb-link:hover {
  color: var(--accent);
  border-color: var(--accent);
}
.crumb-sep {
  color: var(--muted-2);
}

.hud-nav {
  display: flex;
  gap: 2px;
  margin-left: auto;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.02);
}
.tab {
  border: 0;
  background: transparent;
  cursor: pointer;
  font: inherit;
  font-size: 12.5px;
  color: var(--muted);
  padding: 6px 16px;
  border-radius: 2px;
  letter-spacing: 0.04em;
  transition: color var(--dur-fast), background var(--dur-fast);
}
.tab:hover {
  color: var(--ink);
}
.tab.is-active {
  background: var(--accent-dim);
  color: var(--accent-bright);
  box-shadow: inset 0 0 0 1px rgba(224, 168, 63, 0.28);
}

.hud-meta {
  display: flex;
  align-items: center;
  gap: 14px;
  flex: none;
}

/* 版本角标：宽屏一眼可核对线上版本；窄屏顶栏空间紧，收起后改到「系统设置」底部看 */
.ver-badge {
  flex: none;
  font: 10px/1 var(--mono, ui-monospace, monospace);
  letter-spacing: .08em;
  color: var(--muted);
  padding: 4px 6px;
  border: 1px solid var(--line);
  border-radius: 4px;
  white-space: nowrap;
  cursor: help;
}
@media (max-width: 900px) {
  .ver-badge { display: none; }
}

/* ---------- 大屏容器 ---------- */

.view-screen {
  position: absolute;
  inset: 0;
  overflow: hidden;
}

/* 取景框四角 */
.map-frame {
  position: absolute;
  inset: 14px;
  pointer-events: none;
  z-index: 400;
}
.fc {
  position: absolute;
  width: 16px;
  height: 16px;
  border: 1px solid rgba(224, 168, 63, 0.4);
}
.fc.tl {
  left: 0;
  top: 0;
  border-right: 0;
  border-bottom: 0;
}
.fc.tr {
  right: 0;
  top: 0;
  border-left: 0;
  border-bottom: 0;
}
.fc.bl {
  left: 0;
  bottom: 0;
  border-right: 0;
  border-top: 0;
}
.fc.br {
  right: 0;
  bottom: 0;
  border-left: 0;
  border-top: 0;
}

/* 区域悬停时的浮动读数 */
.map-hover-banner {
  position: absolute;
  left: 50%;
  top: 18px;
  transform: translate(-50%, -10px);
  z-index: 600;
  font-family: var(--font-mono);
  font-size: 11.5px;
  letter-spacing: 0.06em;
  color: var(--accent-bright);
  background: rgba(10, 18, 15, 0.9);
  border: 1px solid rgba(224, 168, 63, 0.32);
  padding: 5px 14px;
  border-radius: 2px;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--dur-fast), transform var(--dur-fast) var(--ease-out);
  backdrop-filter: blur(8px);
}
.map-hover-banner.is-on {
  opacity: 1;
  transform: translate(-50%, 0);
}

/* 返回上一级地图：常驻按钮，不跟着面包屑一起在窄屏收掉。
   放在顶部中间是因为两侧都把着面板，中间这块只有悬停读数，市视图里读数是空的 */
.map-back {
  position: absolute;
  left: 50%;
  top: 16px;
  transform: translateX(-50%);
  z-index: 700;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font: inherit;
  font-size: 12.5px;
  letter-spacing: 0.05em;
  color: var(--ink);
  background: rgba(9, 17, 14, 0.92);
  border: 1px solid var(--line-strong);
  border-left: 2px solid var(--accent);
  padding: 7px 15px 7px 12px;
  border-radius: 2px;
  cursor: pointer;
  backdrop-filter: blur(12px) saturate(1.1);
  box-shadow: 0 10px 26px rgba(0, 0, 0, 0.45);
  animation: back-in 300ms var(--ease-out) both;
  transition: color var(--dur-fast), border-color var(--dur-fast), background var(--dur-fast);
}
.map-back[hidden] {
  display: none;
}
.map-back-arrow {
  font-family: var(--font-mono);
  font-size: 14px;
  line-height: 1;
  color: var(--accent);
  transition: transform var(--dur-fast) var(--ease-out);
}
.map-back:hover {
  color: var(--accent-bright);
  border-color: color-mix(in srgb, var(--accent) 60%, transparent);
  border-left-color: var(--accent);
  background: rgba(14, 25, 21, 0.95);
}
.map-back:hover .map-back-arrow {
  transform: translateX(-2px);
}
.map-back:active {
  background: rgba(20, 33, 28, 0.96);
}
@keyframes back-in {
  from {
    opacity: 0;
    transform: translate(-50%, -8px);
  }
}
/* 返回键在场时，悬停读数让一行，两者都留在顶部中间 */
.view-screen.is-back .map-hover-banner {
  top: 58px;
}

/* ---------- 侧栏 ---------- */

.rail {
  position: absolute;
  top: 18px;
  bottom: 62px;
  z-index: 500;
  display: flex;
  flex-direction: column;
  gap: 14px;
  pointer-events: none;
}
.rail > * {
  pointer-events: auto;
}

.rail-left {
  left: 20px;
  width: 356px;
}
.rail-right {
  right: 20px;
  width: 380px;
}

.rail-block,
.rail-right .ctx-body {
  position: relative;
  background: linear-gradient(168deg, rgba(8, 16, 13, 0.94), rgba(4, 9, 7, 0.9));
  border: 1px solid var(--line);
  backdrop-filter: blur(14px) saturate(1.1);
  padding: 12px 15px 11px;
  animation: rail-in var(--dur-slow) var(--ease-out) both;
}
@keyframes rail-in {
  from {
    opacity: 0;
    transform: translateY(16px);
  }
}

/* 左上角与右下角的一小段金色描边，替代整圈粗边框 */
.rail-block::before,
.rail-right .ctx-body::before {
  content: "";
  position: absolute;
  left: -1px;
  top: -1px;
  width: 22px;
  height: 1px;
  background: var(--accent);
}
.rail-block::after,
.rail-right .ctx-body::after {
  content: "";
  position: absolute;
  right: -1px;
  bottom: -1px;
  width: 22px;
  height: 1px;
  background: color-mix(in srgb, var(--accent) 45%, transparent);
}

.rail-block:nth-child(1) {
  animation-delay: 60ms;
}
.rail-block:nth-child(2) {
  animation-delay: 150ms;
}
.rail-block:nth-child(3) {
  animation-delay: 240ms;
}
.rail-right .ctx-body {
  animation-delay: 190ms;
}

.rail-grow {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.rail-kicker {
  display: flex;
  align-items: baseline;
  gap: 9px;
  margin-bottom: 9px;
  padding-bottom: 7px;
  border-bottom: 1px solid var(--line);
}
.rail-kicker span {
  font-family: var(--font-mono);
  font-size: 9.5px;
  letter-spacing: 0.24em;
  color: var(--accent);
  opacity: 0.9;
}
.rail-kicker em {
  font-style: normal;
  font-size: 11.5px;
  color: var(--muted);
  letter-spacing: 0.06em;
  margin-left: auto;
}
/* 排行块的表头右侧让位给「N 市 · 按库容」，顺带暗示下方列表可滚 */
.rail-rank .rail-kicker em {
  margin-left: 0;
}
.rail-rank .kicker-tag {
  margin-left: auto;
  font-family: var(--font-mono);
  font-size: 9.5px;
  font-weight: 400;
  letter-spacing: 0;
  color: rgba(198, 220, 206, 0.48);
  white-space: nowrap;
  flex: none;
}

/* ---------- 总量读数 ---------- */

.big-metric {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin: 2px 0 4px;
}
.metric-num {
  font-family: var(--font-display);
  font-size: 48px;
  line-height: 0.96;
  letter-spacing: 0.005em;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
  text-shadow: 0 0 34px rgba(224, 168, 63, 0.22);
}
.metric-unit {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--accent);
  letter-spacing: 0.06em;
}
.metric-sub {
  display: flex;
  gap: 0;
  margin-top: 8px;
  border-top: 1px solid var(--line);
  padding-top: 10px;
}
.metric-sub span {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 1px;
  padding-right: 8px;
}
.metric-sub span + span {
  border-left: 1px solid var(--line);
  padding-left: 10px;
}
.metric-sub b {
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 400;
  line-height: 1;
  color: var(--ink);
  letter-spacing: 0.01em;
}
.metric-sub em {
  font-style: normal;
  font-size: 10.5px;
  color: var(--muted-2);
  letter-spacing: 0.04em;
  white-space: nowrap; /* 四格并排时宁可缩字号，也不要"万㎡占/地"这种断行 */
}

/* ---------- 类型构成 ---------- */

.type-bars {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 9px;
}
.type-row {
  display: grid;
  grid-template-columns: 9px 54px 44px 1fr 66px;
  align-items: center;
  gap: 9px;
  animation: row-in var(--dur-base) var(--ease-out) both;
  animation-delay: calc(220ms + var(--d, 0ms));
}
@keyframes row-in {
  from {
    opacity: 0;
    transform: translateX(-8px);
  }
}
.type-swatch {
  width: 9px;
  height: 9px;
  background: var(--tc);
  box-shadow: 0 0 10px color-mix(in srgb, var(--tc) 60%, transparent);
}
.type-name {
  font-size: 12px;
  color: var(--ink-2);
}
.type-count {
  font-size: 10.5px;
  color: var(--muted-2);
  text-align: right;
  font-family: var(--font-mono);
}
.type-count b {
  font-size: 12.5px;
  color: var(--ink);
  font-weight: 500;
}
.type-bar {
  position: relative;
  min-width: 0;
  height: 4px;
  background: rgba(255, 255, 255, 0.05);
  overflow: hidden;
}
.type-bar i {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  background: linear-gradient(90deg, color-mix(in srgb, var(--tc) 55%, transparent), var(--tc));
  transition: width var(--dur-slow) var(--ease-out);
}
.type-vol {
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--ink);
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.type-vol em {
  font-style: normal;
  font-size: 9.5px;
  color: var(--muted-2);
  margin-left: 3px;
}

/* ---------- 地市排行 ---------- */

.city-rank {
  list-style: none;
  margin: 0;
  padding: 0;
  overflow-y: auto;
  -webkit-mask-image: linear-gradient(to bottom, #000 92%, transparent 100%);
  mask-image: linear-gradient(to bottom, #000 92%, transparent 100%);
  flex: 1;
  min-height: 0;
  margin-right: -6px;
  padding-right: 6px;
}
.city-rank::-webkit-scrollbar,
.ctx-body::-webkit-scrollbar,
.wh-list::-webkit-scrollbar {
  width: 4px;
}
.city-rank::-webkit-scrollbar-thumb,
.ctx-body::-webkit-scrollbar-thumb,
.wh-list::-webkit-scrollbar-thumb {
  background: rgba(198, 220, 206, 0.2);
}
.city-rank::-webkit-scrollbar-track,
.ctx-body::-webkit-scrollbar-track,
.wh-list::-webkit-scrollbar-track {
  background: transparent;
}

.rank-row {
  display: grid;
  grid-template-columns: 22px 42px 1fr 46px;
  align-items: center;
  gap: 8px;
  padding: 1px 6px 1px 0;
  cursor: pointer;
  min-height: 24px;
  border-bottom: 1px solid rgba(198, 220, 206, 0.05);
  transition: background var(--dur-fast), padding-left var(--dur-fast);
  animation: row-in var(--dur-base) var(--ease-out) both;
  animation-delay: calc(280ms + var(--d, 0ms));
}
.rank-row:hover,
.rank-row.is-on {
  background: rgba(224, 168, 63, 0.08);
  padding-left: 4px;
}
.rank-no {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--muted-2);
  letter-spacing: 0.02em;
}
.rank-row.is-on .rank-no {
  color: var(--accent);
}
.rank-name {
  font-size: 12px;
  color: var(--ink-2);
}
.rank-row.is-on .rank-name {
  color: var(--accent-bright);
}
.rank-track {
  position: relative;
  height: 3px;
  background: rgba(255, 255, 255, 0.045);
}
.rank-track i {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  background: linear-gradient(90deg, rgba(224, 168, 63, 0.35), var(--accent));
  transition: width var(--dur-slow) var(--ease-out);
}
.rank-val {
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--muted);
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.rank-empty {
  font-size: 12px;
  color: var(--muted-2);
  padding: 14px 0;
  list-style: none;
}

/* ---------- 右栏上下文面板 ---------- */

.rail-right .ctx-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 16px 18px 18px;
}
.ctx-head {
  margin-bottom: 16px;
}
.ctx-kicker {
  font-family: var(--font-mono);
  font-size: 9.5px;
  letter-spacing: 0.2em;
  color: var(--accent);
  opacity: 0.85;
  margin-bottom: 6px;
}
.ctx-title {
  font-size: 25px;
  font-weight: 600;
  letter-spacing: 0.04em;
  line-height: 1.15;
  color: var(--ink);
}
.ctx-desc {
  font-size: 11.5px;
  color: var(--muted);
  line-height: 1.7;
  margin: 8px 0 0;
}

.ctx-metrics {
  border-top: 1px solid var(--line);
}
.ctx-metrics-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0;
}
.ctx-metrics-3 .m-row {
  padding: 10px 10px 10px 0;
}
.ctx-metrics-3 .m-row + .m-row {
  border-left: 1px solid var(--line);
  padding-left: 12px;
}
.m-row {
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding: 11px 0;
  border-bottom: 1px solid var(--line);
}
.m-label {
  font-size: 11.5px;
  color: var(--muted);
  flex: none;
}
.m-value {
  margin-left: auto;
  font-family: var(--font-display);
  font-size: 22px;
  line-height: 1;
  color: var(--ink);
  letter-spacing: 0.02em;
  font-variant-numeric: tabular-nums;
}
.m-value em {
  font-style: normal;
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--muted-2);
  margin-left: 3px;
  letter-spacing: 0;
}
.m-sub {
  font-size: 10.5px;
  color: var(--muted-2);
  margin-left: 6px;
}
.ctx-metrics-3 .m-row {
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
}
.ctx-metrics-3 .m-value {
  margin-left: 0;
}

.ctx-block {
  margin-top: 18px;
}
.ctx-block-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  font-size: 11px;
  color: var(--ink-2);
  letter-spacing: 0.06em;
  margin-bottom: 10px;
}
.ctx-block-head em {
  font-style: normal;
  font-size: 10px;
  color: var(--muted-2);
  font-family: var(--font-mono);
}
/* 四个类型要能并排一行：用等分栅格而不是自由换行，
   窄栏里宁可标签内边距收一点，也别把"立筒仓"挤到第二行去 */
.tchip-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(62px, 1fr));
  gap: 5px;
}
.tchip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  min-width: 0;
  font-size: 10.5px;
  color: var(--ink-2);
  border: 1px solid var(--line);
  padding: 4px 3px;
  border-radius: 2px;
  background: rgba(255, 255, 255, 0.02);
  white-space: nowrap;
}
.tchip i {
  width: 6px;
  height: 6px;
  background: var(--tc);
  flex: none;
}
.tchip b {
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--ink);
  font-weight: 500;
}
.tchip-empty {
  font-size: 11px;
  color: var(--muted-2);
}

/* 主导产业：不是计量数据，别再套表格样式；用一排"标签"表达城市画像 */
.ind-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.ind-chip {
  font-size: 11px;
  color: var(--ink-2);
  border: 1px solid color-mix(in srgb, var(--accent) 26%, var(--line));
  background: color-mix(in srgb, var(--accent) 7%, transparent);
  padding: 4px 9px;
  border-radius: 2px;
  letter-spacing: 0.02em;
  animation: chip-in 320ms var(--ease-out) both;
  animation-delay: var(--d, 0ms);
}
@keyframes chip-in {
  from {
    opacity: 0;
    transform: translateY(4px);
  }
}

/* 库容结构：一条按体积切分的实心条 + 四行占比明细 */
.vol-stack {
  display: flex;
  gap: 2px;
  height: 8px;
  margin: 12px 0 13px;
  background: rgba(198, 220, 206, 0.05);
}
.vol-stack i {
  display: block;
  height: 100%;
  min-width: 3px;
  background: var(--tc);
  opacity: 0.8;
  transition: opacity var(--dur-fast);
}
.vol-stack:hover i {
  opacity: 0.95;
}
.vol-legend {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 8px;
}
.vol-legend li {
  display: grid;
  grid-template-columns: 6px 1fr 46px 52px;
  align-items: center;
  gap: 9px;
  font-size: 11.5px;
  color: var(--muted);
  letter-spacing: 0.02em;
}
.vol-legend li > i {
  width: 6px;
  height: 6px;
  background: var(--tc);
  opacity: 0.9;
}
.vol-legend b {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 500;
  color: var(--ink);
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.vol-legend em {
  font-style: normal;
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--muted-2);
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.ctx-enter {
  width: 100%;
  margin-top: 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font: inherit;
  font-size: 12.5px;
  letter-spacing: 0.06em;
  color: #14100a;
  background: var(--accent);
  border: 1px solid var(--accent);
  padding: 10px 14px;
  cursor: pointer;
  touch-action: manipulation;
  transition: background var(--dur-fast), letter-spacing var(--dur-fast);
}
.ctx-enter:hover:not(:disabled) {
  background: var(--accent-bright);
  letter-spacing: 0.12em;
}
.ctx-enter:disabled {
  background: transparent;
  color: var(--muted-2);
  border-color: var(--line);
  cursor: not-allowed;
}
.ctx-enter span {
  font-family: var(--font-mono);
}

.ctx-hint {
  margin-top: 18px;
  font-size: 11px;
  color: var(--muted-2);
  display: flex;
  align-items: center;
  gap: 8px;
  line-height: 1.6;
}
.pulse-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--accent);
  flex: none;
  animation: pulse 2.4s ease-in-out infinite;
}
@keyframes pulse {
  0%,
  100% {
    opacity: 0.35;
    transform: scale(0.85);
  }
  50% {
    opacity: 1;
    transform: scale(1.15);
  }
}

/* 城市列表 */
.ctx-block-list {
  margin-top: 14px;
}
.wh-list {
  list-style: none;
  margin: 0;
  padding: 0;
  max-height: calc(100vh - 470px);
  overflow-y: auto;
}

/* 市级视图的「区县列表 + 库区列表」同栏分区。
   旧版两块各自 max-height，又在 DOM 里互相嵌套，两个滚动条叠加、
   库区列表被推到面板可视区外（实测只剩 35% 能看见）。
   这里改成：区县改紧凑网格只占四行，库区列表拿剩下的全部高度，
   一屏内两块都完整可见，不必再纠结谁让位给谁。 */
#ctx-body.is-split {
  display: flex;
  flex-direction: column;
  /* 正常情况下两块靠 flex 分配、不会溢出；窗口极矮时留一条兜底滚动，
     宁可多一个滚动条，也不要出现够不到的内容 */
  overflow-x: hidden;
  overflow-y: auto;
}
#ctx-body.is-split > .ctx-head,
#ctx-body.is-split > .ctx-metrics {
  flex: none;
}
.ctx-split {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
  gap: 14px;
}
.ctx-split .ctx-block-list {
  display: flex;
  flex-direction: column;
  min-height: 0;
  margin-top: 0;
}
.ctx-split .ctx-block-counties {
  /* 区县网格按内容高度，不参与伸缩 */
  flex: 0 0 auto;
}
.ctx-split .ctx-block-campus {
  /* 库区列表按内容高度，装不下时自己滚（表头保持可见），
     不硬撑满剩余空间——3 个库区拉出 500px 空白比留白更难看 */
  flex: 0 1 auto;
  min-height: 0;
}
.ctx-split .wh-list {
  flex: 0 1 auto;
  min-height: 0;
  max-height: none;
  overflow-y: auto;
}

/* 区县索引：12 个区县按行铺会整栏吃掉，改三列 chip，名称 + 仓数一行说完；
   空白县压暗但仍可点，保留"这个市有哪些县"的完整视野。 */
.county-chips {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
}
.county-chip {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-areas: "name num" "sub sub";
  align-items: baseline;
  gap: 0 5px;
  min-width: 0;
  padding: 5px 8px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.02);
  cursor: pointer;
  transition: background var(--dur-fast), border-color var(--dur-fast);
}
.county-chip:hover {
  background: rgba(224, 168, 63, 0.1);
  border-color: color-mix(in srgb, var(--accent) 45%, transparent);
}
/* 地图悬停联动：鼠标在地图上扫过区县，右栏对应的格子一起亮
   （与左侧地市榜的 .is-on 同义，只是市级视图的"榜"是这排格子） */
.county-chip.is-hover {
  background: rgba(224, 168, 63, 0.16);
  border-color: color-mix(in srgb, var(--accent) 65%, transparent);
}
.county-chip.is-hover .cc-name {
  color: #ffe0a8;
}
.cc-name {
  grid-area: name;
  font-size: 11.5px;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.cc-num {
  grid-area: num;
  flex: none;
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
}
.cc-sub {
  grid-area: sub;
  font-size: 9px;
  color: var(--muted-2);
  letter-spacing: 0.04em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.county-chip.is-empty {
  opacity: 0.42;
}
.county-chip.is-empty .cc-num {
  color: var(--muted-2);
}

/* 库区按区县分组的吸顶小标题：补齐数据后库区会从 2–3 行涨到十几个，
   有组头才扫得动；只有一个库区的县不插组头（区县名并进那一行的副信息）。 */
.wh-group {
  position: sticky;
  top: 0;
  z-index: 1;
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding: 5px 8px 4px 12px;
  list-style: none;
  background: rgba(9, 16, 13, 0.97);
  border-bottom: 1px solid var(--line);
}
.wh-group span {
  font-size: 10.5px;
  color: var(--accent);
  letter-spacing: 0.06em;
}
.wh-group em {
  margin-left: auto;
  font-style: normal;
  font-family: var(--font-mono);
  font-size: 9px;
  color: var(--muted-2);
  font-variant-numeric: tabular-nums;
}
.wh-item {
  position: relative;
  display: grid;
  grid-template-columns: 1fr auto;
  grid-template-areas: "name no" "meta meta";
  gap: 1px 8px;
  padding: 9px 8px 9px 12px;
  cursor: pointer;
  border-bottom: 1px solid rgba(198, 220, 206, 0.06);
  transition: background var(--dur-fast);
}
.wh-item::before {
  content: "";
  position: absolute;
  left: 0;
  top: 9px;
  bottom: 9px;
  width: 2px;
  background: var(--tc);
  opacity: 0.55;
}
.wh-item:hover {
  background: rgba(255, 255, 255, 0.035);
}
.wh-item:hover::before {
  opacity: 1;
}
.wh-item-no {
  grid-area: no;
  font-family: var(--font-mono);
  font-size: 9.5px;
  color: var(--muted);
  letter-spacing: 0.04em;
}
.wh-item-name {
  grid-area: name;
  font-size: 12.5px;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.wh-item-meta {
  grid-area: meta;
  font-size: 10.5px;
  color: var(--muted-2);
  font-variant-numeric: tabular-nums;
}

/* 库区行比仓库行高一级：名字更实、右侧带箭头，视觉上能看出"点进去还有一层" */
.wh-item.wh-campus {
  grid-template-columns: 1fr auto;
  padding: 11px 20px 11px 12px;
}
.wh-item.wh-campus .wh-item-name {
  font-size: 13.5px;
  font-weight: 500;
  letter-spacing: 0.01em;
}
.wh-item.wh-campus::after {
  content: "›";
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 15px;
  color: var(--muted-2);
  transition: transform var(--dur-fast), color var(--dur-fast);
}
.wh-item.wh-campus:hover::after {
  color: var(--accent);
  transform: translate(2px, -50%);
}
.wh-item.wh-campus.is-on {
  background: rgba(224, 168, 63, 0.09);
}
.wh-item.wh-campus.is-on::before {
  opacity: 1;
}

.data-table .campus-cell {
  color: var(--ink-2);
  font-size: 12.5px;
}

/* 详情 */
.ctx-head-detail {
  display: flex;
  gap: 10px;
  align-items: flex-start;
}
.ctx-back {
  flex: none;
  width: 28px;
  height: 28px;
  margin-top: 2px;
  border: 1px solid var(--line-strong);
  background: transparent;
  color: var(--ink-2);
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
  transition: border-color var(--dur-fast), color var(--dur-fast);
}
.ctx-back:hover {
  border-color: var(--accent);
  color: var(--accent);
}
.detail-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 4px;
}
.tag {
  font-size: 10.5px;
  padding: 3px 9px;
  border-radius: 2px;
  background: rgba(255, 255, 255, 0.04);
  color: var(--ink-2);
  border: 1px solid var(--line);
}
.tag[style*="--tc"] {
  color: var(--tc);
  border-color: color-mix(in srgb, var(--tc) 38%, transparent);
  background: color-mix(in srgb, var(--tc) 12%, transparent);
}
.tag-ok {
  color: var(--ok);
  border-color: rgba(79, 191, 149, 0.35);
}

.spec {
  display: grid;
  grid-template-columns: 68px 1fr;
  gap: 7px 12px;
  margin: 16px 0 0;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}
.spec dt {
  font-size: 11px;
  color: var(--muted-2);
}
.spec dd {
  font-size: 11.5px;
  margin: 0;
  color: var(--ink-2);
  word-break: break-all;
}
.spec dd.mono {
  font-size: 11px;
}

.ctx-actions {
  display: flex;
  gap: 8px;
  margin-top: 18px;
}
.ctx-actions .btn {
  flex: 1;
  text-align: center;
}

/* ---------- 工具条 ---------- */

.map-tools {
  position: absolute;
  left: 50%;
  bottom: 56px;
  transform: translateX(-50%);
  display: flex;
  gap: 1px;
  z-index: 500;
  border: 1px solid var(--line);
  background: rgba(9, 17, 14, 0.9);
  backdrop-filter: blur(12px);
}
.tool {
  font: inherit;
  font-size: 12px;
  cursor: pointer;
  background: transparent;
  border: 0;
  border-right: 1px solid var(--line);
  padding: 8px 16px;
  color: var(--ink-2);
  letter-spacing: 0.04em;
  transition: background var(--dur-fast), color var(--dur-fast);
}
.tool:last-child {
  border-right: 0;
}
.tool:hover {
  background: rgba(224, 168, 63, 0.1);
  color: var(--accent-bright);
}
.tool.is-active {
  background: var(--accent);
  color: #14100a;
}

/* ---------- 底栏 ---------- */

.hud-foot {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 44px;
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 0 24px;
  background: linear-gradient(0deg, rgba(6, 12, 10, 0.96), rgba(6, 12, 10, 0.4));
  border-top: 1px solid var(--line);
  z-index: 500;
  font-size: 10.5px;
  color: var(--muted-2);
}
.foot-legend {
  display: flex;
  gap: 18px;
}
.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 10.5px;
  color: var(--muted);
  letter-spacing: 0.06em;
}
.legend-item i {
  width: 8px;
  height: 8px;
  background: var(--tc);
  box-shadow: 0 0 8px color-mix(in srgb, var(--tc) 55%, transparent);
}
.foot-note {
  margin-left: auto;
  font-family: var(--font-mono);
  letter-spacing: 0.04em;
  /* 注释比备案号长得多，窄屏下先让它截断，备案号必须完整可见 */
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.foot-icp {
  flex: none;
  color: var(--muted-2);
  font-family: var(--font-mono);
  letter-spacing: 0.04em;
  text-decoration: none;
  transition: color 160ms ease;
}
.foot-icp:hover {
  color: var(--accent);
}
/* 访客台账「操作」列的只读占位 */
.ops-ro {
  color: var(--muted-2);
  font-size: 12px;
}

/* ---------- 下钻过渡：一层短暂的暗场，让"换页"这件事被看见 ---------- */

.view-screen::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 700;
  pointer-events: none;
  background: radial-gradient(circle at 50% 46%, rgba(224, 168, 63, 0.14), rgba(3, 8, 7, 0.92) 62%);
  opacity: 0;
  transition: opacity 220ms ease-out;
}
.view-screen.is-drilling::after {
  opacity: 1;
}

/* 进入市级后，左栏的排行会让位给"本市清单"，视觉上收窄一档 */
.view-screen.is-city .rail-left .city-rank {
  opacity: 0.55;
}
.view-screen.is-city .city-rank .rank-row {
  pointer-events: none;
}

/* ---------- 响应式 ---------- */

/* 矮窗口（笔记本 768/864 高，或 125% 缩放后的等效高度）：
   市级视图右栏要同时装下区县网格和库区列表，头部与指标的留白最该先让出来。
   实测 614 高时库区列表只剩 60px（一行放不下），收完这些约省 45px。 */
@media (max-height: 780px) {
  #ctx-body.is-split > .ctx-head {
    margin-bottom: 10px;
  }
  #ctx-body.is-split .ctx-title {
    font-size: 20px;
  }
  #ctx-body.is-split > .ctx-head .ctx-desc {
    margin-top: 5px;
    line-height: 1.5;
  }
  #ctx-body.is-split > .ctx-metrics .m-row {
    padding: 7px 10px 7px 0;
  }
  #ctx-body.is-split .ctx-split {
    gap: 10px;
  }
  #ctx-body.is-split .county-chip {
    padding: 4px 7px;
  }
}

@media (max-width: 1480px) {
  .rail-left {
    width: 320px;
  }
  .rail-right {
    width: 344px;
  }
  .metric-num {
    font-size: 54px;
  }
  .ctx-title {
    font-size: 22px;
  }
}

@media (max-width: 1240px) {
  .hud-crumb {
    min-width: 0;
    padding-left: 14px;
  }
  /* 排行是首页数据结构的第三块，不能因为窄就消失：压缩行高让它继续在场。
     真挤到 1040 以下还有一档更紧的规则接手。 */
  .rail-left {
    width: 300px;
  }
  .rail-rank .kicker-tag {
    font-size: 9px;
    padding: 1px 5px;
  }
  .rank-row {
    grid-template-columns: 19px 38px 1fr 42px;
    gap: 6px;
    min-height: 21px;
  }
  .rank-no {
    font-size: 9.5px;
  }
  .rank-name {
    font-size: 11.5px;
  }
  .rank-val {
    font-size: 11px;
  }
  .rail-right {
    width: 316px;
  }
  .type-row {
    grid-template-columns: 9px 50px 40px 1fr 58px;
    gap: 7px;
  }
  .metric-num {
    font-size: 46px;
  }
  /* 四格指标在 300px 出头的栏里会顶到边界，字号和间距一起收 */
  .metric-sub b {
    font-size: 17px;
  }
  .metric-sub em {
    font-size: 9.5px;
    letter-spacing: 0.02em;
  }
  .metric-sub span {
    padding-right: 5px;
  }
  .metric-sub span + span {
    padding-left: 7px;
  }
}

/* 1024 级窄栏：库容单位会顶到第二行，宁可只留数字（单位在左栏大读数和右栏都有） */
@media (max-width: 1120px) {
  .type-row {
    grid-template-columns: 9px 46px 38px 1fr 54px;
    gap: 6px;
  }
  .type-vol {
    font-size: 10.5px;
    white-space: nowrap;
  }
  .type-vol em {
    display: none;
  }
}

@media (max-width: 1040px) {
  .hud-crumb {
    display: none;
  }
  /* 数据是虚构演示：窄屏也必须能看到免责声明（允许截断，但保留前缀） */
  .foot-note {
    font-size: 10px;
    line-height: 1.2;
  }
  /* 注释隐藏后没有元素再撑开左间距，备案号得自己靠右站住 */
  .foot-icp {
    margin-left: auto;
  }
  .rail-right {
    width: 300px;
  }
  .rail-left {
    width: 260px;
  }
}

@media (max-width: 860px) {
  .hud-top {
    gap: 14px;
    padding: 0 14px;
  }
  .brand-text small {
    display: none;
  }
  .rail-right {
    display: none;
  }
  .rail-left {
    width: calc(100% - 28px);
    left: 14px;
    right: 14px;
    bottom: auto;
    top: 12px;
  }
  .rail-left .rail-block:not(.rail-kpi) {
    display: none;
  }
  .rail-left .rail-kpi {
    padding: 10px 14px;
  }
  .metric-num {
    font-size: 40px;
  }
  .metric-sub {
    margin-top: 7px;
    padding-top: 8px;
  }
  .metric-sub b {
    font-size: 17px;
  }
  .map-tools {
    bottom: 54px;
    width: calc(100% - 28px);
    justify-content: space-between;
  }
  .tool {
    flex: 1;
    text-align: center;
    padding: 8px 6px;
    font-size: 11px;
  }
  .foot-legend {
    gap: 10px;
    flex-wrap: wrap;
  }
}

/* 手机竖屏：只保留"看总量 + 看版图"这条主线，其余控件让位，否则顶栏会把按钮压成竖排 */
@media (max-width: 640px) {
  .hud-top {
    height: 50px;
    gap: 8px;
    padding: 0 12px;
  }
  .brand-mark {
    width: 32px;
    height: 32px;
    font-size: 9.5px;
    padding: 2px;
  }
  .brand-text h1 {
    font-size: 12.5px;
    letter-spacing: 0.04em;
  }
  .brand-text small,
  .hud-crumb {
    display: none;
  }
  #btn-settings {
    padding: 5px 8px;
    font-size: 11px;
  }
  .hud-nav {
    margin-left: auto;
    padding: 2px;
  }
  .tab {
    padding: 5px 9px;
    font-size: 11px;
    white-space: nowrap;
  }
  .conn #conn-text {
    display: none;
  }
  .rail-left {
    left: 10px;
    right: 10px;
    top: 8px;
    bottom: auto;
    width: auto;
  }
  .rail-left .rail-kpi {
    padding: 8px 12px;
  }
  .metric-num {
    font-size: 34px;
  }
  .map-tools {
    bottom: 12px;
    width: calc(100% - 20px);
  }
  .banner {
    left: 10px;
    right: 10px;
    bottom: 62px;
    transform: none;
    max-width: none;
    flex-wrap: wrap;
    row-gap: 6px;
    font-size: 11px;
    line-height: 1.5;
  }
  .hud-foot {
    display: none;
  }
}

/* ==========================================================================
   手机端：详情面板改为底部抽屉 + 安装到桌面的适配
   --------------------------------------------------------------------------
   桌面端是"左总量 / 中地图 / 右详情"三栏并排；手机上并排塞不下，
   所以详情改成从底部升起的抽屉：点地市→抽屉带数据上来，点仓库→抽屉换成详情，
   「收起」等价于返回上一级。地图始终占满整屏，抽屉只盖住下面一段。
   ========================================================================== */

.sheet-head {
  display: none;
}

@media (max-width: 860px) {
  .rail-right {
    display: flex;
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    top: auto;
    width: auto;
    max-height: min(58vh, 520px);
    z-index: 620;
    flex-direction: column;
    gap: 0;
    pointer-events: auto;
    border-top: 1px solid var(--line-strong);
    border-radius: 18px 18px 0 0;
    background: linear-gradient(180deg, rgba(6, 13, 11, 0.98), rgba(3, 8, 6, 0.995));
    box-shadow: 0 -18px 60px rgba(0, 0, 0, 0.66);
    padding-bottom: env(safe-area-inset-bottom);
    transform: translateY(calc(100% + 30px));
    transition: transform 340ms cubic-bezier(0.22, 1, 0.36, 1);
    will-change: transform;
  }
  .rail-right.is-open {
    transform: none;
  }

  .rail-right .sheet-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 7px 14px 3px;
    flex: none;
  }
  .sheet-handle {
    position: absolute;
    left: 50%;
    top: 7px;
    width: 38px;
    height: 4px;
    margin-left: -19px;
    border-radius: 99px;
    background: rgba(198, 220, 206, 0.28);
  }
  .sheet-close {
    margin-left: auto;
    font: inherit;
    font-size: 11.5px;
    letter-spacing: 0.04em;
    color: var(--muted);
    background: transparent;
    border: 1px solid var(--line);
    border-radius: 99px;
    padding: 5px 12px;
    min-height: 30px;
    cursor: pointer;
  }
  .sheet-close:active {
    color: var(--ink);
    border-color: var(--accent);
  }

  .rail-right .ctx-body {
    border: none;
    border-radius: 0;
    background: transparent;
    backdrop-filter: none;
    box-shadow: none;
    padding: 8px 16px 16px;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
  }

  /* 抽屉升起时，底部工具条与提示条让位，避免叠成两层 */
  .rail-right.is-open ~ .map-tools,
  .rail-right.is-open ~ .banner {
    opacity: 0;
    pointer-events: none;
    transition: opacity 160ms ease;
  }

  /* 手指比鼠标粗：所有可点的东西抬到 34px 起 */
  .tool {
    min-height: 36px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }
  .tab {
    min-height: 32px;
  }
  .rank-row,
  .type-row {
    min-height: 26px;
  }
}

/* 手机上顶栏要避开刘海；装成 App 打开时还要避开状态栏 */
@media (max-width: 640px) {
  .hud-top {
    padding-left: max(12px, env(safe-area-inset-left));
    padding-right: max(12px, env(safe-area-inset-right));
  }
  .map-tools {
    bottom: max(12px, env(safe-area-inset-bottom));
  }
}

@media (display-mode: standalone) {
  .hud-top {
    height: calc(64px + env(safe-area-inset-top));
    padding-top: env(safe-area-inset-top);
  }
}

@media (max-width: 640px) and (display-mode: standalone) {
  .hud-top {
    height: calc(50px + env(safe-area-inset-top));
  }
}

/* 抽屉升起时顶部指标收走，把屏幕让给地图（城市数据在抽屉里已经有一份） */
@media (max-width: 860px) {
  body.is-sheet .rail-left {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 180ms ease;
  }
  .rail-right {
    max-height: min(54vh, 480px);
  }
  /* 提示条挪到顶栏下方，别压住抽屉里的内容 */
  .toast {
    top: calc(60px + env(safe-area-inset-top));
    bottom: auto;
    max-width: 86vw;
  }
}

/* 小屏顶栏：把「系统设置」收成齿轮，腾出宽度给标题和视图切换 */
@media (max-width: 430px) {
  .brand-text h1 {
    font-size: 12px;
    letter-spacing: 0.02em;
  }
  .tab {
    padding: 5px 8px;
    font-size: 10.5px;
  }
  #btn-settings {
    width: 32px;
    height: 30px;
    padding: 0;
    font-size: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: none;
  }
  #btn-settings::before {
    content: "⚙";
    font-size: 15px;
    line-height: 1;
  }
}

/* ==========================================================================
   首页数据展示：补齐参考图的结构
   --------------------------------------------------------------------------
   参考稿的首页有三块左栏数据（总量 / 类型 / 排行）+ 一块右栏概览。
   这里处理的是它在不同屏幕上的"缺块"问题：
   - 桌面窄屏：排行压缩保留，不再整块消失
   - 手机：类型与排行收进「全省总览」抽屉，点工具条那颗按钮展开
   - 右栏概览补一块「单仓规模」，填掉下半屏的空白
   ========================================================================== */

/* 单仓规模：四档库容的座数分布，视觉语言和类型构成一致 */
.spread {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.spread li {
  display: grid;
  grid-template-columns: 52px 1fr 22px;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  color: var(--muted);
}
.spread-k {
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--ink-2);
  letter-spacing: 0.02em;
  white-space: nowrap;
}
.spread-track {
  position: relative;
  height: 4px;
  background: rgba(255, 255, 255, 0.05);
  overflow: hidden;
}
.spread-track i {
  display: block;
  height: 100%;
  background: color-mix(in srgb, var(--accent) 78%, transparent);
  transition: width var(--dur-slow) var(--ease-out);
}
.spread b {
  font-family: var(--font-mono);
  font-size: 11.5px;
  font-weight: 500;
  color: var(--ink);
  text-align: right;
  font-variant-numeric: tabular-nums;
}

/* 抽屉里的排行：不滚动、不裁切，16 行一次看完 */
.city-rank-sheet {
  flex: none;
  overflow: visible;
  margin-right: 0;
  padding-right: 0;
  -webkit-mask-image: none;
  mask-image: none;
}

/* 这一块只在手机出现：桌面端左栏已经有排行，不重复 */
.ctx-province-extra {
  display: none;
}

/* 「全省总览」按钮：桌面不需要，手机上才有意义 */
.tool-overview {
  display: none;
}

/* 「库区边界」只在市级视图出现：省域看面，市域才看点与范围 */
.map-tools .tool-bounds {
  display: none;
}
.view-screen.is-city .map-tools .tool-bounds {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

@media (max-width: 860px) {
  .tool-overview {
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }
  .ctx-province-extra {
    display: block;
    margin-top: 4px;
  }
  .ctx-province-extra .city-rank-sheet .rank-row {
    min-height: 26px;
  }
  .ctx-province-extra .city-rank-sheet .rank-name {
    font-size: 12px;
  }
  .spread li {
    grid-template-columns: 56px 1fr 26px;
    font-size: 11.5px;
  }
}

@media (max-width: 1040px) {
  /* 右栏收到 300 时四个标签会掉一行：字号和间距一起收，仍然并排 */
  .tchip-row {
    grid-template-columns: repeat(auto-fit, minmax(56px, 1fr));
    gap: 4px;
  }
  .tchip {
    font-size: 10px;
    gap: 3px;
    padding: 3px 2px;
  }
  .tchip b {
    font-size: 10px;
  }
  /* 左栏到 260 时排行要再紧一档，否则数值列会被压掉 */
  .rank-row {
    grid-template-columns: 17px 34px 1fr 38px;
    gap: 5px;
    min-height: 20px;
  }
  .rank-name {
    font-size: 11px;
  }
}

/* 工具条现在有 5 颗按钮（多了「全省总览」），手机宽里不能再让文字折行 */
@media (max-width: 860px) {
  .map-tools .tool {
    white-space: nowrap;
    min-height: 34px;
  }
}

@media (max-width: 430px) {
  .map-tools .tool {
    font-size: 10px;
    padding: 8px 3px;
    letter-spacing: 0;
  }
}
/* 平板宽度（641–900）顶栏挤在中间档：微调间距，别让管理模式徽标把标题挤出去 */
@media (min-width: 641px) and (max-width: 900px) {
  .hud-top {
    gap: 16px;
  }
  .hud-meta {
    gap: 10px;
  }
}
/* 390 / 375 / 360 这些常见窄屏：顶栏原本会横向溢出十几像素，
   收紧间距并让位给标题；只有大屏一个视图时连导航一起收掉 */
@media (max-width: 400px) {
  .hud-top {
    gap: 8px;
    padding: 0 14px;
  }
  .hud-brand {
    gap: 9px;
  }
  .brand-mark {
    width: 30px;
    height: 30px;
    font-size: 9px;
    padding: 2px;
  }
  .brand-text h1 {
    font-size: 11px;
  }
  .brand-text small {
    display: none;
  }
  .tab {
    padding: 5px 7px;
    font-size: 10px;
  }
  .hud-nav.is-single {
    display: none;
  }
}

/* 手机上顶部指标在抽屉升起时会收走，返回键独占这一行，不必让位。
   挪到左侧：中间顶部让给 toast（"已进入济南 · 3 个库区"就在那儿），
   两个都居中会互相压住 */
@media (max-width: 860px) {
  .map-back {
    left: 10px;
    top: 10px;
    transform: none;
    animation-name: back-in-left;
    font-size: 12px;
    padding: 6px 13px 6px 10px;
    gap: 7px;
  }
  .view-screen.is-back .map-hover-banner {
    top: 52px;
  }
}

@keyframes back-in-left {
  from {
    opacity: 0;
    transform: translateY(-8px);
  }
}

@media (max-width: 430px) {
  .map-back {
    left: 8px;
    top: 8px;
    font-size: 11.5px;
    padding: 6px 11px 6px 9px;
    letter-spacing: 0.02em;
  }
  .map-back-arrow {
    font-size: 13px;
  }
}

/* ================= 库区排布编辑工具条 ================= */
.layout-bar {
  position: absolute;
  left: 50%;
  top: 16px;
  transform: translateX(-50%);
  z-index: 700;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font: inherit;
  font-size: 12px;
  color: var(--ink);
  background: rgba(9, 17, 14, 0.94);
  border: 1px solid var(--line-strong);
  border-top: 2px solid var(--accent);
  padding: 6px 10px;
  border-radius: 3px;
  backdrop-filter: blur(12px) saturate(1.1);
  box-shadow: 0 10px 26px rgba(0, 0, 0, 0.45);
  animation: back-in 300ms var(--ease-out) both;
  max-width: min(92vw, 720px);
}
.layout-bar[hidden] {
  display: none;
}
.lb-name {
  max-width: 30vw;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--accent-bright);
  font-size: 12.5px;
}
.lb-gap {
  width: 1px;
  height: 16px;
  background: var(--line);
  margin: 0 4px;
  flex: none;
}
.lb-btn {
  font: inherit;
  font-size: 11.5px;
  font-family: var(--font-mono);
  color: var(--ink-2);
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--line);
  border-radius: 3px;
  padding: 4px 8px;
  cursor: pointer;
  transition: color var(--dur-fast), border-color var(--dur-fast);
  white-space: nowrap;
}
.lb-btn:hover {
  color: var(--accent-bright);
  border-color: color-mix(in srgb, var(--accent) 55%, transparent);
}
.lb-btn:disabled {
  opacity: 0.45;
  cursor: default;
}
.lb-ok {
  color: #0a1310;
  background: var(--accent);
  border-color: var(--accent);
  font-weight: 600;
}
.lb-ok:hover {
  color: #0a1310;
  border-color: var(--accent-bright);
}
.lb-cancel {
  color: var(--muted);
}
.lb-deg {
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--ink-2);
  min-width: 36px;
  text-align: center;
}

/* 手机：工具条换行两排，旋转一排 + 名称/保存一排 */
@media (max-width: 640px) {
  .layout-bar {
    flex-wrap: wrap;
    justify-content: center;
    row-gap: 6px;
    top: 10px;
    padding: 7px 8px;
  }
  .lb-name {
    max-width: 82vw;
    flex: 1 1 100%;
    text-align: center;
    white-space: normal;
  }
}

/* ==========================================================================
   v17 · 手机端可用性收口（对应测试报告 D-02 / D-03 / D-04 / D-07 / D-08）
   --------------------------------------------------------------------------
   只落在窄屏媒体查询里，桌面三栏布局不受影响。
   写在本文件末尾而不是 style.css：screen.css 是最后加载的样式表，
   同特异度按顺序决定胜负——放在前面会被这里的 .map-tools .tool、
   .tab 等规则原样盖掉（v17 第一版就栽在这上面）。
   ========================================================================== */

/* 三维模块按需拉取（见 app.js 的 loadViewer）：画布到位前先铺一句人话，
   否则那是一块纯黑，最容易被当成"三维坏了"。 */
.scene {
  position: relative;
}
.scene-hint {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  text-align: center;
  font-size: 12.5px;
  letter-spacing: 0.04em;
  color: var(--muted);
  background: rgba(4, 9, 7, 0.78);
  pointer-events: none;
}

@media (max-width: 860px) {
  /* ---------- D-04：手指比鼠标粗，主操作 40 起、关键动作 44 ---------- */
  .map-tools .tool {
    min-height: 44px;
    font-size: 12px;
  }
  .hud-nav .tab {
    min-height: 40px;
    font-size: 12px;
  }
  #btn-settings {
    min-width: 44px;
    min-height: 44px;
  }
  /* 管理模式角标只是状态指示，真正的入口是「运营台账」标签，给到 40 即可 */
  .admin-chip {
    min-width: 40px;
    min-height: 40px;
    justify-content: center;
  }
  .rail-right .sheet-close {
    min-height: 44px;
    padding: 10px 16px;
    font-size: 12px;
  }
  .ctx-back {
    width: 44px;
    height: 44px;
  }
  .map-back {
    min-height: 44px;
  }
  /* 地图控件原为 30×30，缩放手边最容易误触 */
  .maplibregl-ctrl-group button {
    width: 40px;
    height: 40px;
  }
  .maplibregl-ctrl-group button + button {
    border-top: 1px solid var(--line);
  }
  .rail-right .ctx-actions .btn {
    min-height: 46px;
  }

  /* ---------- D-03：详情抽屉的操作条固定在底部 ----------
     抽屉最高 58vh，详情内容 542 px 而可视只有 399 px，
     三维/盘点码/盘点三个高价值入口原本要上滑才看得到。
     让 ctx-body 变纵向 flex，操作条 margin-top:auto 沉底 + sticky 跟随滚动。 */
  .rail-right .ctx-body {
    display: flex;
    flex-direction: column;
  }
  .rail-right .ctx-body > * {
    flex: none;
  }
  .rail-right .ctx-body {
    /* 底部留白交给操作条自己填，否则按钮下会漏出 16px 的正文 */
    padding-bottom: 0;
  }
  .rail-right .ctx-body::-webkit-scrollbar {
    width: 0;
    height: 0;
  }
  .rail-right .ctx-actions {
    position: sticky;
    bottom: 0;
    z-index: 2;
    margin-top: auto;
    padding: 10px 0 calc(18px + env(safe-area-inset-bottom));
    background: linear-gradient(180deg, rgba(5, 10, 8, 0) 0%, rgba(5, 10, 8, 0.94) 26%, rgba(5, 10, 8, 1) 100%);
    backdrop-filter: blur(8px);
  }

  /* ---------- D-07：说明性文字抬到 12 px 起 ---------- */
  .rank-no {
    font-size: 10.5px;
  }
  .rank-name {
    font-size: 12px;
  }
  .rank-val {
    font-size: 11.5px;
  }
  .metric-sub em {
    font-size: 10.5px;
  }
  .type-vol {
    font-size: 11px;
  }
  .tchip {
    font-size: 11px;
  }
  .spread-k {
    font-size: 11.5px;
  }
  .m-label {
    font-size: 12px;
  }
  .spec dd {
    font-size: 11.5px;
  }
  .kicker-tag {
    font-size: 10px;
  }
  .brand-mark {
    font-size: 10px;
  }
  /* 正文类（说明、副标题、提示）一律 12 起；只有等宽英文小标与密集排行榜
     保留 10.5–11.5，那是刻意的排版密度，抬上去会把固定列宽挤爆 */
  .ctx-desc {
    font-size: 12px;
  }
  .ctx-hint {
    font-size: 12px;
  }
  .m-sub {
    font-size: 11.5px;
  }
  .ctx-kicker {
    font-size: 10px;
  }
  /* 英文小标保留 10 px，但加字重，小屏上不至于虚成一片 */
  .ctx-kicker,
  .rail-kicker span {
    font-size: 10px;
    font-weight: 600;
  }
  /* 底图失败提示条里的「去填写」也是可点目标 */
  .banner-btn {
    min-height: 40px;
    padding: 8px 14px;
  }
}

/* ---------- D-02：375/360 宽顶栏溢出 ----------
   登录管理模式后顶栏内容固定 389 px：375 溢出 14、360 溢出 29、320 溢出 69，
   「系统设置」被挤出屏幕。品牌名是这里唯一的弹性项——手机上一律收成 4 字徽标，
   完整标题仍在 <title>、设置面板与桌面端；省下的 119 px 全部让给操作按钮。 */
@media (max-width: 430px) {
  .hud-brand .brand-text {
    display: none;
  }
  /* 40×40 的空框比一个点更抢眼，而身份已经由「运营台账」标签表达 */
  .admin-chip {
    display: none;
  }
  .hud-top {
    gap: 8px;
    padding-left: 12px;
    padding-right: 12px;
  }
  .hud-meta {
    gap: 8px;
  }
}

/* 底图瓦片取不到时会弹出提示条，它和「拍照入库」占同一个位置（都贴底部 62px），
   两者叠在一起按钮正好压住提示文字。有提示条时把按钮抬到它上面。 */
@media (max-width: 860px) {
  body:has(#map-banner:not([hidden])) .quick-add {
    bottom: 156px;
  }
}

/* 431–860 之间品牌名与按钮并排，标题允许省略，避免极端配置下再次溢出 */
@media (max-width: 860px) {
  .hud-brand {
    flex: 0 1 auto;
    min-width: 0;
  }
  .brand-text {
    min-width: 0;
  }
  #brand-title {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
}

/* ==========================================================================
   手机横屏：底部抽屉改成右侧面板
   --------------------------------------------------------------------------
   横屏可用高度只有 ~390px，底部抽屉一升起来就吃掉 58vh（约 226px），
   地图只剩顶上一条窄带；中间那块又被抽屉盖住，手指拖拽全落在抽屉上，
   表现为「只能看到一部分、也不能缩放平移」。改成右侧面板后地图仍占左侧
   大部分，也不会和系统手势条抢位置。
   取 max-height 560px 是为了把「手机横屏」和「平板竖屏」区分开：后者
   高度充足，继续用底部抽屉更顺手。
   ========================================================================== */
@media (orientation: landscape) and (max-height: 560px) {
  .rail-right {
    left: auto;
    right: 0;
    top: 52px;
    bottom: 0;
    width: min(52vw, 400px);
    max-height: none;
    border-top: none;
    border-left: 1px solid var(--line-strong);
    border-radius: 14px 0 0 0;
    transform: translateX(calc(100% + 24px));
    padding-bottom: env(safe-area-inset-bottom);
  }
  .rail-right.is-open {
    transform: none;
  }
  .rail-right .ctx-body {
    padding: 6px 14px 14px;
  }
  /* 侧面板不需要抓手，靠标题栏右侧的「关闭」收起 */
  .rail-right .sheet-handle {
    display: none;
  }
  .rail-right .sheet-head {
    padding: 6px 12px 4px;
  }
  /* 顶栏在横屏里很占地方，压薄一点，把高度还给地图。
     main 的高度是写死的 calc(100% - 62px)，这里必须一起改，
     否则顶栏少了 10px、地图却没长高，底部会留一条死带。 */
  .hud-top {
    height: 52px;
    gap: 14px;
    padding: 0 12px;
  }
  main {
    height: calc(100% - 52px);
  }
  /* 手机横屏：左栏统计不要盖在地图上（816×148 会吃掉半个 844×338 画布） */
  .rail-left {
    display: none;
  }
  /* 工具条默认 translateX(-50%)，在横屏 + 侧栏偏移下会被甩到屏幕外 */
  .map-tools {
    left: 12px;
    right: auto;
    bottom: 12px;
    transform: none;
    width: auto;
    max-width: calc(100% - 24px);
  }
  .banner {
    left: 12px;
    right: auto;
    bottom: 58px;
    transform: none;
    max-width: calc(100% - 24px);
  }
  .rail-right ~ .map-tools {
    left: 12px;
  }
}

/* 手机/平板竖屏：把「进入市级视图」吸在抽屉底部
   --------------------------------------------------------------------------
   城市卡内容普遍比抽屉高（实测 731px vs 可见 401px），按钮在滚动区最下方，
   不滚到底就点不到，点到了也常被底部手势条压住 —— 用户反馈「点了没反应」。
   吸底之后不用滚动就能点，且始终避开安全区。 */
@media (max-width: 860px) {
  .rail-right .ctx-body {
    padding-bottom: calc(14px + env(safe-area-inset-bottom));
  }
  .rail-right .ctx-enter {
    position: sticky;
    bottom: 0;
    z-index: 2;
    margin-top: 12px;
    box-shadow: 0 -16px 26px rgba(3, 8, 6, 0.92), 0 10px 0 10px rgba(3, 8, 6, 0.92);
  }
}

/* 县列表：无登记的区县压暗，别让人以为是没加载出来 */
.wh-item.is-empty {
  opacity: 0.55;
}
.wh-item.is-empty .wh-item-meta {
  color: var(--muted-2);
}

/* 手机/横屏：保留备案号，收成一条 40px 的法定信息栏；图例/注释让位。
   之前 .hud-foot 在手机上整条 display:none，ICP/公安号都看不到，不合规。
   文字 ≥10px、链接命中高度 40px，满足移动可读性/触摸目标检查。 */
@media (max-width: 860px) {
  .hud-foot {
    display: flex;
    height: calc(40px + env(safe-area-inset-bottom));
    padding: 0 10px env(safe-area-inset-bottom);
    gap: 10px;
    justify-content: center;
    background: rgba(3, 8, 6, 0.96);
    font-size: 10px;
  }
  .foot-legend,
  .foot-note {
    display: none;
  }
  .foot-icp {
    display: inline-flex;
    align-items: center;
    min-height: 40px;
    padding: 0 4px;
    font-size: 10px;
    letter-spacing: 0;
  }
  .map-tools {
    bottom: calc(50px + env(safe-area-inset-bottom));
  }
  .banner {
    bottom: calc(98px + env(safe-area-inset-bottom));
  }
}
