/* ==========================================================================
   「顺差去哪了」顺差解剖图 - 核心设计系统与样式表 (Pixel-Perfect 16:9 Desktop Edition)
   ========================================================================== */

:root {
  --ink: #111111;
  --ink-2: #555555;
  --ink-3: #8A8A8A;
  --ink-4: #A0A0A0;

  --line: #EAEAEA;
  --line-2: #F4F4F4;
  --line-subtle: #F4F4F4;
  --line-strong: #D9D9D9;

  --surplus: #0B3D91;     /* 顺差 / 主叙事蓝 */
  --surplus-bg: #EEF4FD;
  --deficit: #B23A2E;     /* 逆差 / 下跌红 */
  --deficit-bg: #FDF1EF;

  --private: #0B3D91;     /* 民营 */
  --foreign: #C9A227;     /* 外资 */
  --state: #5B6770;       /* 国企 */
  --gap: #D9D9D9;         /* 统计差异 / 未解释节点 */

  --gap-pattern: repeating-linear-gradient(
    45deg,
    #D9D9D9,
    #D9D9D9 4px,
    #FFFFFF 4px,
    #FFFFFF 8px
  );

  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Noto Sans SC", "Microsoft YaHei", sans-serif;
  --font-mono: ui-monospace, Consolas, "Courier New", monospace;

  --duration-micro: 80ms;
  --duration-quick: 150ms;
  --duration-fast: 220ms;
  --duration-medium: 320ms;

  --ease-smooth-out: cubic-bezier(0.2, 0.8, 0.2, 1);
  --ease-bounce: cubic-bezier(0.2, 0.8, 0.2, 1);

  --shadow-popup: 0 1px 2px rgba(0,0,0,.04), 0 8px 24px rgba(0,0,0,.06);
}

/* Base Reset */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 15px;
  background-color: #FFFFFF;
  color: var(--ink);
  font-family: var(--font-sans);
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}

body {
  min-height: 100vh;
  background-color: #FFFFFF;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
}

button, input, select, textarea {
  font-family: inherit;
  color: inherit;
  outline: none;
}

a {
  color: inherit;
  text-decoration: none;
}

/* Typography Hierarchy */
.display-num {
  font-size: 72px;
  font-weight: 300;
  line-height: 1.0;
  letter-spacing: -0.03em;
  font-feature-settings: "tnum" 1, "ss01" 1;
}

.num-l {
  font-size: 30px;
  font-weight: 400;
  line-height: 1.1;
  font-feature-settings: "tnum" 1, "ss01" 1;
}

h1, .h1 {
  font-size: 26px;
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1.2;
}

h2, .h2 {
  font-size: 17px;
  font-weight: 600;
  letter-spacing: -0.01em;
  line-height: 1.3;
}

.body-text {
  font-size: 13.5px;
  font-weight: 400;
  line-height: 1.6;
}

.caption {
  font-size: 11.5px;
  font-weight: 400;
  line-height: 1.5;
  color: var(--ink-3);
}

.micro {
  font-size: 10.5px;
  font-weight: 600;
  line-height: 1.4;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--ink-3);
}

.font-mono {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--ink-3);
  font-feature-settings: "tnum" 1;
  overflow-wrap: anywhere;
}

.tnum {
  font-feature-settings: "tnum" 1, "ss01" 1;
}

.val-up {
  color: var(--surplus);
}

.val-down {
  color: var(--deficit);
}

.val-flat {
  color: var(--ink-3);
}

.hatched-box {
  background: var(--gap-pattern);
  border: 1px solid rgba(0, 0, 0, 0.12);
}

/* ==========================================================================
   Header Component (56px) with Horizontal Month Track
   ========================================================================== */
#app-header {
  height: 56px;
  background-color: #FFFFFF;
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 48px;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  user-select: none;
}

.header-logo {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--ink);
}

.header-badge {
  font-size: 11.5px;
  color: var(--ink-3);
}

.header-center {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}

.month-caption {
  font-size: 10.5px;
  font-family: var(--font-mono);
  color: var(--ink-3);
  letter-spacing: 0.02em;
}

.month-controller {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 8px;
}

.month-nav-btn {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: #FFFFFF;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--ink-2);
  transition: all var(--duration-fast) var(--ease-smooth-out);
}

.month-nav-btn:hover:not(:disabled) {
  background: var(--ink);
  color: #FFFFFF;
  border-color: var(--ink);
  transform: scale(1.1);
}

.month-nav-btn:disabled {
  opacity: 0.25;
  cursor: not-allowed;
}

/* Month segmented buttons */
.month-segment-track {
  display: flex;
  align-items: center;
  gap: 2px;
  background: #F4F4F5;
  padding: 3px;
  border-radius: 6px;
}

.month-segment-btn {
  padding: 4px 12px;
  font-size: 12px;
  font-weight: 500;
  border: none;
  background: transparent;
  color: var(--ink-2);
  border-radius: 5px;
  cursor: pointer;
  transition: all var(--duration-fast) var(--ease-smooth-out);
  font-family: var(--font-mono);
}

.month-segment-btn:hover {
  color: var(--ink);
  background: rgba(0,0,0,0.03);
}

.month-segment-btn.active {
  background: var(--ink);
  color: #FFFFFF;
  font-weight: 600;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.header-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.view-segment-control {
  display: flex;
  align-items: center;
  background-color: #F1F1F3;
  padding: 3px;
  border-radius: 8px;
}

.view-btn {
  padding: 4px 12px;
  font-size: 12px;
  font-weight: 500;
  border: none;
  background: transparent;
  color: var(--ink-2);
  border-radius: 6px;
  cursor: pointer;
  transition: all var(--duration-fast) var(--ease-smooth-out);
}

.view-btn:hover {
  color: var(--ink);
}

.view-btn.active {
  background-color: #FFFFFF;
  color: var(--ink);
  font-weight: 600;
  box-shadow: var(--shadow-sm);
}

.tool-btn {
  height: 30px;
  padding: 0 10px;
  border-radius: 6px;
  border: 1px solid var(--line);
  background-color: #FFFFFF;
  font-size: 12px;
  font-weight: 500;
  color: var(--ink);
  display: inline-flex;
  align-items: center;
  gap: 5px;
  cursor: pointer;
  transition: all var(--duration-fast) var(--ease-smooth-out);
}

.tool-btn:hover {
  background-color: #F7F7F8;
  border-color: var(--ink-3);
  transform: translateY(-1px);
}

.kbd-shortcut-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 4px;
  font-size: 10px;
  font-family: var(--font-mono);
  background: #F0F0F2;
  border-radius: 4px;
  color: var(--ink-3);
  border: 1px solid rgba(0,0,0,0.06);
}

/* ==========================================================================
   Breadcrumb Bar (40px)
   ========================================================================== */
#breadcrumb-bar {
  height: 40px;
  background-color: #FFFFFF;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 28px;
  font-size: 12.5px;
  position: sticky;
  top: 56px;
  z-index: 90;
}

#breadcrumb-bar.hidden {
  display: none;
}

.breadcrumb-trail {
  display: flex;
  align-items: center;
  gap: 6px;
  overflow-x: auto;
  white-space: nowrap;
}

.crumb-item {
  color: var(--ink-2);
  cursor: pointer;
  transition: color var(--duration-micro) var(--ease-smooth-out);
}

.crumb-item:hover {
  color: var(--surplus);
  text-decoration: underline;
}

.crumb-item.current {
  color: var(--ink);
  font-weight: 600;
  cursor: default;
  text-decoration: none;
}

.crumb-sep {
  color: var(--ink-4);
  font-size: 11px;
}

.reset-drilldown-btn {
  font-size: 11.5px;
  color: var(--ink-3);
  background: transparent;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 3px 6px;
  border-radius: 4px;
  transition: all var(--duration-fast) var(--ease-smooth-out);
}

.reset-drilldown-btn:hover {
  color: var(--deficit);
  background-color: var(--deficit-bg);
}

/* ==========================================================================
   App Body & 16:9 PC Layout
   ========================================================================== */
#app-body {
  flex: 1;
  max-width: 1760px;
  width: 100%;
  margin: 0 auto;
  padding: 24px 48px 48px 48px;
  display: flex;
  gap: 24px;
  position: relative;
}

#view-viewport {
  flex: 1;
  min-width: 0;
  background-color: #FFFFFF;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 24px 32px;
}

/* ==========================================================================
   Right Inspect Panel (400px Sticky Sidebar)
   ========================================================================== */
#inspect-panel {
  width: 400px;
  flex-shrink: 0;
  background-color: #FFFFFF;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 20px;
  align-self: flex-start;
  position: sticky;
  top: 80px;
  max-height: calc(100vh - 100px);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

#inspect-panel::-webkit-scrollbar {
  width: 4px;
}
#inspect-panel::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, 0.12);
  border-radius: 4px;
}

.panel-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
}

.panel-close-btn {
  background: transparent;
  border: none;
  font-size: 18px;
  color: var(--ink-3);
  cursor: pointer;
  padding: 2px 4px;
  border-radius: 4px;
  transition: all var(--duration-fast) var(--ease-smooth-out);
}

.panel-close-btn:hover {
  color: var(--ink);
  background: #F4F4F5;
}

.panel-main-stat {
  display: flex;
  align-items: baseline;
  gap: 6px;
}

.panel-grid-2x2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px 12px;
  background-color: #F8F9FA;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid rgba(0,0,0,0.03);
}

.panel-grid-row {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.panel-grid-label {
  font-size: 11px;
  color: var(--ink-3);
}

.panel-grid-val {
  font-size: 13px;
  font-weight: 600;
  font-family: var(--font-mono);
}

.panel-section-divider {
  height: 1px;
  background-color: var(--line);
  margin: 2px 0;
}

.panel-judge-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
  margin-bottom: 8px;
}

.judge-metric-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
  font-size: 12px;
}

.judge-sparkline {
  width: 56px;
  height: 18px;
}

.judge-conclusion-box {
  background-color: #F8F9FA;
  border-left: 3px solid var(--ink);
  padding: 8px 10px;
  font-size: 11.5px;
  line-height: 1.5;
  color: var(--ink-2);
  margin-top: 8px;
  border-radius: 0 4px 4px 0;
}

.stacked-bar-container {
  display: flex;
  width: 100%;
  height: 14px;
  border-radius: 4px;
  overflow: hidden;
  margin: 6px 0;
}

.stacked-segment {
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 9.5px;
  color: #FFFFFF;
  font-weight: 500;
}

.owner-list-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 11.5px;
  margin-top: 5px;
}

.owner-dot-label {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--ink-2);
}

.owner-color-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.methodology-mini-card {
  background-color: #F8F9FA;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 11px;
}

.method-row {
  display: flex;
  margin-bottom: 4px;
  gap: 6px;
  line-height: 1.4;
}

.method-key {
  color: var(--ink-3);
  width: 44px;
  flex-shrink: 0;
}

.method-val {
  color: var(--ink-2);
  overflow-wrap: anywhere;
}

.method-link {
  display: inline-block;
  color: var(--surplus);
  font-weight: 500;
  margin-top: 5px;
  cursor: pointer;
}

.method-link:hover {
  text-decoration: underline;
}

.panel-action-btns {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.panel-btn {
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  font-size: 11.5px;
  font-weight: 500;
  background-color: #FFFFFF;
  border: 1px solid var(--line);
  border-radius: 6px;
  cursor: pointer;
  transition: all var(--duration-fast) var(--ease-smooth-out);
}

.panel-btn:hover {
  background-color: #F8F9FA;
  border-color: var(--ink-3);
  transform: translateY(-1px);
}

/* ==========================================================================
   River View (Hero 7:5 & Flow)
   ========================================================================== */
.river-hero {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
  margin-bottom: 20px;
}

.hero-left {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.hero-stats-line {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 12.5px;
  color: var(--ink-2);
}

.hero-explain-line {
  font-size: 12px;
  color: var(--ink-3);
  line-height: 1.6;
}

.hero-right-cards {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 10px;
}

.mini-card {
  background-color: #FFFFFF;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  height: 116px;
  cursor: default;
  transition: border-color var(--duration-fast) var(--ease-smooth-out);
}

.mini-card:hover {
  border-color: var(--ink-2);
}

.mini-card-title {
  font-size: 11.5px;
  font-weight: 600;
  color: var(--ink);
  margin-bottom: 2px;
}

.mini-card-desc {
  font-size: 10.5px;
  color: var(--ink-3);
  line-height: 1.35;
}

.price-segments-grid {
  display: flex;
  gap: 2px;
  height: 12px;
  margin: 6px 0;
}

.price-segment-cell {
  background-color: #DDE2E8;
  border-radius: 1px;
  cursor: pointer;
  transition: transform var(--duration-micro) var(--ease-smooth-out);
}

.price-segment-cell:hover {
  transform: scaleY(1.3);
}

.price-segment-cell.down {
  background-color: var(--deficit);
}

.gap-mini-card {
  background: #F8F9FA;
  border: 1px solid var(--line);
  cursor: pointer;
}

.sankey-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 16px;
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--line);
}

.color-mode-pills {
  display: flex;
  gap: 6px;
}

.color-pill-btn {
  padding: 3px 8px;
  font-size: 11px;
  border-radius: 4px;
  border: 1px solid var(--line);
  background: #FFFFFF;
  color: var(--ink-2);
  cursor: pointer;
  transition: all var(--duration-fast) var(--ease-smooth-out);
}

.color-pill-btn:hover {
  background: #F4F4F5;
  color: var(--ink);
}

.color-pill-btn.active {
  background: var(--ink);
  color: #FFFFFF;
  border-color: var(--ink);
}

.sankey-columns-header {
  display: grid;
  grid-template-columns: 0.18fr 0.28fr 0.26fr 0.28fr;
  font-size: 11px;
  font-weight: 600;
  color: var(--ink-3);
  margin-bottom: 10px;
}

#drilldown-sankey-section {
  margin-top: 24px;
  padding-top: 18px;
  border-top: 1px dashed var(--line-strong);
  scroll-margin-top: 100px;
}

.drilldown-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.drilldown-title {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--surplus);
}

.drilldown-collapse-btn {
  font-size: 11px;
  color: var(--ink-3);
  background: transparent;
  border: none;
  cursor: pointer;
}

.drilldown-collapse-btn:hover {
  color: var(--ink);
}

.drilldown-columns-header {
  display: grid;
  grid-template-columns: 0.3fr 0.28fr 0.26fr 0.16fr;
  font-size: 11px;
  font-weight: 600;
  color: var(--ink-3);
  margin-bottom: 8px;
}

/* ==========================================================================
   Treemap View
   ========================================================================== */
#treemap-view-container {
  display: flex;
  flex-direction: column;
  gap: 14px;
  position: relative;
}

.treemap-breadcrumb-cards {
  display: flex;
  gap: 10px;
  align-items: stretch;
}

.tm-crumb-card {
  background-color: #FFFFFF;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 12px;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: all var(--duration-fast) var(--ease-smooth-out);
}

.tm-crumb-card:hover {
  border-color: var(--surplus);
  transform: translateY(-2px);
  box-shadow: var(--shadow-hover);
}

#treemap-canvas-container {
  position: relative;
  width: 100%;
  height: 640px;
  background-color: #FAFAFA;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}

.treemap-node {
  position: absolute;
  box-sizing: border-box;
  border: 1px solid #FFFFFF;
  border-radius: 6px;
  cursor: pointer;
  transition: transform var(--duration-fast) var(--ease-smooth-out), box-shadow var(--duration-fast) var(--ease-smooth-out);
  overflow: hidden;
}

.treemap-node:hover {
  z-index: 10;
  transform: translateY(-2px);
  box-shadow: var(--shadow-popup);
  border-color: var(--ink);
}

.tm-stripe {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
}

.tm-stripe.up {
  background-color: var(--surplus);
}

.tm-stripe.down {
  background-color: var(--deficit);
}

#treemap-tooltip {
  position: fixed;
  pointer-events: none;
  background-color: #FFFFFF;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px 14px;
  box-shadow: var(--shadow-popup);
  z-index: 1000;
  opacity: 0;
  transition: opacity var(--duration-fast) var(--ease-smooth-out);
  width: 220px;
}

/* ==========================================================================
   Time View
   ========================================================================== */
#time-view-container {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.time-section-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 6px;
}

.small-multiples-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 10px;
}

.spark-card {
  background-color: #FFFFFF;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  box-shadow: var(--shadow-sm);
  transition: all var(--duration-fast) var(--ease-smooth-out);
}

.spark-card:hover {
  transform: translateY(-2px);
  border-color: var(--surplus);
  box-shadow: var(--shadow-hover);
}

.spark-card.active {
  border-color: var(--surplus);
  box-shadow: 0 0 0 2px rgba(11, 61, 145, 0.2);
}

/* ==========================================================================
   Where Attribution View
   ========================================================================== */
#where-view-container {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.where-header {
  display: flex;
  align-items: baseline;
  gap: 10px;
}

.waterfall-guideline {
  stroke: #C8C8C8;
  stroke-width: 1;
  stroke-dasharray: 3 3;
}

.waterfall-explaining-card {
  background-color: #F8F9FA;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px 16px;
  display: flex;
  align-items: center;
  gap: 14px;
}

.waterfall-hatch-preview {
  width: 28px;
  height: 28px;
  border-radius: 4px;
  flex-shrink: 0;
}

.waterfall-path-list {
  display: flex;
  flex-direction: column;
  gap: 3px;
  font-size: 11px;
}

.waterfall-path-item {
  padding: 4px 6px;
  border-radius: 4px;
  color: var(--ink-2);
}

/* ==========================================================================
   Ledger View
   ========================================================================== */
#ledger-view-container {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.ledger-hero-title {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.ledger-main-layout {
  display: grid;
  grid-template-columns: 180px 1fr;
  gap: 20px;
}

.ledger-sidebar {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.ledger-filter-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 7px 10px;
  border-radius: 6px;
  font-size: 12px;
  cursor: pointer;
  color: var(--ink-2);
  transition: all var(--duration-fast) var(--ease-smooth-out);
}

.ledger-filter-item:hover {
  background-color: #F1F1F3;
  color: var(--ink);
}

.ledger-filter-item.active {
  background-color: var(--ink);
  color: #FFFFFF;
  font-weight: 600;
}

.ledger-badge {
  font-size: 10px;
  font-family: var(--font-mono);
  padding: 1px 5px;
  border-radius: 8px;
  background-color: #E8E8E8;
  color: var(--ink-2);
}

.ledger-filter-item.active .ledger-badge {
  background-color: rgba(255, 255, 255, 0.2);
  color: #FFFFFF;
}

.ledger-search-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  background-color: #FFFFFF;
  border: 1px solid var(--line);
  border-radius: 6px;
  margin-bottom: 12px;
}

.ledger-search-input {
  flex: 1;
  border: none;
  background: transparent;
  font-size: 12.5px;
}

.ledger-table-container {
  background-color: #FFFFFF;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.ledger-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
  text-align: left;
}

.ledger-table th {
  background-color: #F8F9FA;
  padding: 8px 12px;
  font-weight: 600;
  color: var(--ink-2);
  border-bottom: 1px solid var(--line);
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
}

.ledger-table td {
  padding: 8px 12px;
  border-bottom: 1px solid var(--line-subtle);
  color: var(--ink);
}

.ledger-table tr:hover td {
  background-color: #FBFBFC;
}

/* ==========================================================================
   Command Palette (Cmd+K / Ctrl+K)
   ========================================================================== */
.command-dialog-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.35);
  z-index: 9999;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: 15vh;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--duration-fast) var(--ease-smooth-out);
}

.command-dialog-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.command-dialog-card {
  width: 100%;
  max-width: 560px;
  background: #FFFFFF;
  border-radius: 12px;
  border: 1px solid var(--line);
  box-shadow: var(--shadow-popup);
  overflow: hidden;
  transform: scale(0.98);
  transition: transform var(--duration-fast) var(--ease-smooth-out);
}

.command-dialog-overlay.active .command-dialog-card {
  transform: scale(1);
}

.command-search-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
}

.command-search-input {
  flex: 1;
  border: none;
  font-size: 14px;
  background: transparent;
}

.command-results-list {
  max-height: 320px;
  overflow-y: auto;
  padding: 6px;
}

.command-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 10px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 12.5px;
  transition: background var(--duration-micro) var(--ease-smooth-out);
}

.command-item:hover, .command-item.selected {
  background: #F1F1F4;
}

.command-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 14px;
  border-top: 1px solid var(--line);
  background: #FAFAFA;
  font-size: 10.5px;
  color: var(--ink-3);
}

/* ==========================================================================
   Modals & Toasts
   ========================================================================== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.35);
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--duration-fast) var(--ease-smooth-out);
}

.badge-allocated {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 10.5px;
  color: var(--foreign);
  background: #FFFDF5;
  border: 1px solid #EAD8A4;
  padding: 2px 6px;
  border-radius: 4px;
  font-weight: 500;
  letter-spacing: 0.02em;
}

.modal-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.modal-card {
  background-color: #FFFFFF;
  border-radius: 12px;
  border: 1px solid var(--line);
  box-shadow: var(--shadow-popup);
  width: 100%;
  max-width: 460px;
  padding: 20px;
  transform: scale(0.98);
  transition: transform var(--duration-fast) var(--ease-smooth-out);
}

.modal-overlay.active .modal-card {
  transform: scale(1);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}

#toast-msg {
  position: fixed;
  bottom: 28px;
  right: 28px;
  background: var(--ink);
  color: #FFFFFF;
  padding: 10px 18px;
  border-radius: 8px;
  font-size: 12.5px;
  font-weight: 500;
  box-shadow: var(--shadow-popup);
  z-index: 3000;
  opacity: 0;
  transform: translateY(10px);
  pointer-events: none;
  transition: all var(--duration-fast) var(--ease-smooth-out);
}

#toast-msg.show {
  opacity: 1;
  transform: translateY(0);
}

#app-footer {
  background-color: #FFFFFF;
  border-top: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 8px 16px;
  font-size: 11px;
  color: var(--ink-3);
  margin-top: auto;
}
#app-footer .footer-row {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 0 6px;
  line-height: 1.6;
}
#app-footer .footer-row--brand { color: var(--ink-4); }
#app-footer .footer-sep { color: var(--ink-4); }
#app-footer a {
  color: inherit;
  text-decoration: none;
  border-bottom: 1px solid transparent;
}
#app-footer a:hover { color: var(--ink-2); border-bottom-color: var(--line); }
#app-footer .footer-brand-link { color: var(--ink-2); font-weight: 500; }
#app-footer .footer-beian-icon {
  width: 12px; height: 12px;
  vertical-align: -2px;
  margin-right: 3px;
}
#app-footer .footer-kbd-hint { margin-left: 10px; color: var(--ink-4); }

/* ==========================================================================
   New Views Extensions (Province, PriceQty, HS4, Industry, Truth Badges)
   ========================================================================== */

.truth-badge-pill {
  transition: all 0.15s ease;
}
.truth-badge-pill:hover {
  background: #E4E4E7 !important;
  color: #000000 !important;
}

.prov-rank-item:hover {
  background: var(--line-2) !important;
}

.ledger-table th, .ledger-table td {
  border-bottom: 1px solid var(--line-2);
}

.ledger-table tr:hover {
  background: #F8FAFC;
}

/* Placeholder for missing data */
.data-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px 20px;
  color: var(--ink-3);
  font-size: 13px;
  text-align: center;
  line-height: 1.6;
}

/* Pending data text - uniform gray, normal weight */
.pending-data {
  color: var(--ink-3);
  font-weight: 400;
}

/* nowrap utility */
.nowrap {
  white-space: nowrap;
}

/* Task 2: Hero thesis line */
.hero-thesis {
  font-size: 15px;
  font-weight: 600;
  color: var(--ink);
  line-height: 1.45;
  margin-top: 10px;
}

/* Task 3: Mover chips */
.mover-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  font-size: 11.5px;
  font-weight: 500;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #FFFFFF;
  cursor: pointer;
  transition: all var(--duration-fast) var(--ease-smooth-out);
  font-family: inherit;
}
.mover-chip:hover {
  background: var(--ink);
  color: #FFFFFF;
  border-color: var(--ink);
}
.mover-chip:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 2px;
}
.mover-chip.chip-positive { color: var(--surplus); }
.mover-chip.chip-negative { color: var(--deficit); }
.mover-chip.chip-positive:hover,
.mover-chip.chip-negative:hover { color: #FFFFFF; }

.mover-chips-caption {
  font-size: 11px;
  color: var(--ink-3);
  margin-bottom: 4px;
}

/* Task 7: View question subtitle */
.view-question {
  font-size: 13px;
  color: var(--ink-2);
  margin-bottom: 8px;
}

/* Task 9: Global focus-visible */
:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 2px;
}

/* Task 6: Drilldown caption */
.drilldown-edge-caption {
  font-size: 11px;
  color: var(--ink-3);
  margin-bottom: 8px;
}

/* Task 9: View treemap button in drilldown */
.drilldown-view-treemap-btn {
  padding: 4px 10px;
  font-size: 11.5px;
  font-weight: 500;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #FFFFFF;
  cursor: pointer;
  transition: all var(--duration-fast) var(--ease-smooth-out);
  font-family: inherit;
  color: var(--ink);
}
.drilldown-view-treemap-btn:hover {
  background: var(--ink);
  color: #FFFFFF;
  border-color: var(--ink);
}


/* ==========================================================================
   首屏骨架 / 启动帮助 / 首次访问引导（首次价值触达）
   ========================================================================== */
.boot-skeleton { position: relative; min-height: 420px; }
.skeleton-line, .skeleton-block {
  border-radius: 4px;
  background: linear-gradient(90deg, #F4F4F5 25%, #FAFAFA 50%, #F4F4F5 75%);
  background-size: 400% 100%;
  animation: skeleton-shimmer 1.4s ease-in-out infinite;
}
.skeleton-block { width: 100%; }
@keyframes skeleton-shimmer { 0% { background-position: 100% 0; } 100% { background-position: 0 0; } }
.boot-status {
  position: absolute; left: 0; right: 0; top: 240px;
  text-align: center; font-size: 12.5px; color: var(--ink-3);
}

.boot-help { max-width: 560px; margin: 48px auto; }
.boot-help-title { font-size: 22px; font-weight: 700; color: var(--ink); margin-top: 4px; }
.boot-help-desc { font-size: 13.5px; line-height: 1.7; color: var(--ink-2); margin-top: 10px; }
.boot-help-detail { color: var(--ink-4); font-size: 12px; }
.boot-help-desc a, .boot-help-steps a { color: var(--ink); text-decoration: underline; }
.boot-help-desc code, .boot-help-steps code {
  font-family: var(--font-mono); font-size: 12.5px; background: #F4F4F5; padding: 1px 6px; border-radius: 4px; color: var(--ink);
}
.boot-help-steps { margin: 14px 0 0 18px; font-size: 13.5px; line-height: 1.8; color: var(--ink-2); }
.boot-help-copy { margin-top: 20px; padding: 8px 14px; font-weight: 500; }
.boot-help-side { font-size: 12.5px; line-height: 1.7; color: var(--ink-3); padding: 8px 4px; }

.first-run-hint {
  position: fixed; left: 48px; bottom: 56px; z-index: 40;
  width: 340px; padding: 16px 18px;
  background: #FFFFFF; border: 1px solid var(--line-strong); border-radius: 8px;
  box-shadow: var(--shadow-popup);
  animation: hint-in var(--duration-medium) var(--ease-smooth-out);
}
.first-run-hint.leaving { opacity: 0; transform: translateY(6px); transition: opacity var(--duration-fast), transform var(--duration-fast); }
@keyframes hint-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.first-run-hint-title { font-size: 13.5px; font-weight: 600; color: var(--ink); }
.first-run-hint-steps { margin: 10px 0 0 18px; font-size: 12.5px; line-height: 1.65; color: var(--ink-2); }
.first-run-hint-steps li + li { margin-top: 4px; }
.first-run-hint-footer {
  display: flex; justify-content: space-between; align-items: center;
  margin-top: 12px; padding-top: 10px; border-top: 1px solid var(--line-2);
  font-size: 11.5px; color: var(--ink-3);
}


/* ==========================================================================
   响应式适配（平板 ≤1099px / 手机 ≤767px）
   阈值与 js/responsive.js 的 Layout 一致，改一处必须同时改另一处。
   视图层大量使用内联样式，故此处的覆盖多数必须带 !important。
   ========================================================================== */

:root {
  --m-nav-h: 50px;     /* 手机端底部视图导航条高度 */
  --m-sheet-h: 46px;   /* 手机端检视面板把手高度 */
  --safe-b: env(safe-area-inset-bottom, 0px);
}

/* 仅手机端出现的元素（搜索入口、横滑提示等），桌面端隐藏 */
.mobile-only,
.mobile-only-block { display: none !important; }

/* 抽屉把手 / 遮罩 / 收起按钮：桌面端完全不存在 */
.panel-sheet-handle,
.sheet-backdrop,
.sheet-collapse-btn { display: none; }

/* --------------------------------------------------------------------------
   平板与窄桌面：单列，检视面板落到内容下方
   -------------------------------------------------------------------------- */
@media (max-width: 1099px) {
  #app-header {
    height: auto;
    flex-wrap: wrap;
    align-items: stretch;
    padding: 0 20px;
  }
  .header-left  { order: 1; height: 52px; flex: 1 1 auto; }
  .header-right { order: 2; height: 52px; }
  .header-center {
    order: 3;
    flex: 1 0 100%;
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 6px !important;
    padding-bottom: 8px;
  }
  .header-center > div:first-child { min-width: 0; }
  .month-caption { text-align: left !important; }
  .month-controller { justify-content: flex-start; }
  .month-segment-track { flex: 1; overflow-x: auto; scrollbar-width: none; }
  .month-segment-track::-webkit-scrollbar { display: none; }
  .month-segment-btn { flex: 0 0 auto; }

  #app-header .view-segment-control {
    overflow-x: auto;
    justify-content: flex-start;
    scrollbar-width: none;
  }
  #app-header .view-segment-control::-webkit-scrollbar { display: none; }
  #app-header .view-btn { flex: 0 0 auto; }

  #breadcrumb-bar { position: static; padding: 0 20px; }

  #app-body {
    flex-direction: column;
    padding: 16px 20px 32px;
    gap: 16px;
  }
  #inspect-panel {
    position: static;
    top: auto;
    width: 100%;
    max-height: none;
    overflow: visible;
    order: 2;
  }
  .panel-content { height: auto !important; overflow: visible !important; }

  /* 视图内部的独立滚动容器在单列下交回给页面滚动 */
  .hs4-view-layout,
  .industry-view-layout,
  .ledger-view-layout,
  .price-qty-view-layout,
  .time-view-layout,
  .where-view-layout,
  .treemap-view-layout,
  .province-view-layout {
    height: auto !important;
    overflow: visible !important;
    padding-right: 0 !important;
  }
}

/* --------------------------------------------------------------------------
   手机端
   -------------------------------------------------------------------------- */
@media (max-width: 767px) {
  /* 底部固定：视图导航 + 面板把手，页面需要为它们留出空间 */
  body { padding-bottom: calc(var(--m-nav-h) + var(--m-sheet-h) + var(--safe-b)); }

  .mobile-only { display: inline-flex !important; }
  .mobile-only-block { display: block !important; }

  /* 可横滑的表格/图表，右缘留一道阴影提示"右边还有" */
  .table-scroll, .chart-scroll-x {
    background: linear-gradient(to left, rgba(0, 0, 0, 0.07), rgba(0, 0, 0, 0)) right center / 16px 100% no-repeat;
  }

  /* ---- 顶栏 ---- */
  #app-header { padding: 0 14px; }
  .header-left  { height: 46px; }
  .header-right { height: 46px; gap: 6px; }
  .header-logo { font-size: 15px; }
  .header-badge { display: none; }
  #truth-badge-top { display: none !important; }
  .tool-btn { height: 30px; padding: 0 9px; font-size: 11.5px; }
  .header-center { gap: 4px !important; padding-bottom: 6px; }
  .month-caption { font-size: 10px; }
  .month-nav-btn { display: none; }
  .month-segment-btn { padding: 6px 14px; font-size: 12.5px; }

  /* ---- 视图切换 → 底部固定导航 ---- */
  #app-header .view-segment-control {
    position: fixed !important;
    left: 0; right: 0; bottom: 0;
    height: calc(var(--m-nav-h) + var(--safe-b));
    padding: 0 2px var(--safe-b) 2px !important;
    background: rgba(255, 255, 255, 0.97) !important;
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
    border-top: 1px solid var(--line);
    border-radius: 0 !important;
    display: flex !important;
    gap: 0 !important;
    justify-content: space-between;
    z-index: 1300;
  }
  #app-header .view-btn {
    flex: 1 1 0;
    min-width: 0;
    height: var(--m-nav-h);
    padding: 0 4px;
    font-size: 12.5px;
    border-radius: 0;
    color: var(--ink-3);
    white-space: nowrap;
  }
  #app-header .view-btn.active {
    background: transparent !important;
    box-shadow: inset 0 -2px 0 var(--ink) !important;
    color: var(--ink);
  }

  .breadcrumb-trail { min-width: 0; }
  .crumb-item.current {
    max-width: 58vw;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .reset-drilldown-btn { flex-shrink: 0; white-space: nowrap; }

  /* 下钻后面包屑要一直看得见（"重置"是唯一的返回口），吸在顶栏下沿 */
  #breadcrumb-bar {
    position: sticky;
    top: var(--header-h, 92px);
    padding: 0 14px;
    height: 38px;
    font-size: 12px;
  }

  /* ---- 主体 ---- */
  #app-body { padding: 12px 12px 24px; gap: 12px; }
  #view-viewport { padding: 14px 12px; }
  #app-footer {
    padding: 12px 16px 16px;
    font-size: 10.5px;
    line-height: 1.7;
    text-align: center;
    gap: 6px;
  }
  /* 只藏那条快捷键提示（手机端没有键盘），「最近更新」与备案信息必须留着 */
  #app-footer .footer-kbd-hint { display: none; }

  /* ---- 检视面板 → 底部抽屉 ---- */
  #inspect-panel {
    position: fixed;
    /* 桌面端的 sticky top:80px 必须清掉，否则 fixed 元素按 top 定位、bottom 失效 */
    top: auto;
    left: 0; right: 0; bottom: 0;
    width: 100%;
    max-height: 78vh;
    padding: 0;
    gap: 0;
    border: 1px solid var(--line);
    border-bottom: none;
    border-radius: 14px 14px 0 0;
    box-shadow: 0 -6px 28px rgba(0, 0, 0, 0.16);
    transform: translateY(105%);
    transition: transform var(--duration-medium) var(--ease-smooth-out);
    overflow-y: auto;
    overscroll-behavior: contain;
    z-index: 1500;
  }
  body.sheet-open #inspect-panel { transform: none; }
  #inspect-panel .panel-content {
    padding: 16px 14px calc(var(--m-nav-h) + var(--safe-b) + 56px) 14px !important;
    gap: 14px !important;
  }

  .panel-sheet-handle {
    position: fixed;
    left: 0; right: 0;
    bottom: calc(var(--m-nav-h) + var(--safe-b));
    height: var(--m-sheet-h);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 0 14px;
    background: #FFFFFF;
    border: none;
    border-top: 1px solid var(--line);
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.04);
    cursor: pointer;
    text-align: left;
    z-index: 1400;
    transition: opacity var(--duration-fast) var(--ease-smooth-out);
  }
  .sheet-handle-text { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
  .sheet-handle-title {
    font-size: 12.5px; font-weight: 600; color: var(--ink);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  }
  .sheet-handle-value {
    font-size: 11px; font-family: var(--font-mono); color: var(--ink-2);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  }
  .sheet-handle-cue {
    display: inline-flex; align-items: center; gap: 3px;
    flex-shrink: 0; font-size: 11.5px; font-weight: 500; color: var(--ink-3);
  }
  body.sheet-open .panel-sheet-handle { opacity: 0; pointer-events: none; }

  .sheet-collapse-btn {
    position: fixed;
    left: 50%;
    bottom: calc(var(--m-nav-h) + var(--safe-b) + 12px);
    transform: translateX(-50%) translateY(8px);
    display: block;
    height: 32px;
    padding: 0 16px;
    border: 1px solid var(--line-strong);
    border-radius: 16px;
    background: #FFFFFF;
    font-size: 12px;
    font-weight: 500;
    color: var(--ink-2);
    box-shadow: var(--shadow-popup);
    opacity: 0;
    pointer-events: none;
    z-index: 1600;
    transition: all var(--duration-fast) var(--ease-smooth-out);
  }
  body.sheet-open .sheet-collapse-btn {
    opacity: 1;
    pointer-events: auto;
    transform: translateX(-50%) translateY(0);
  }

  .sheet-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.28);
    opacity: 0;
    pointer-events: none;
    z-index: 1450;
    transition: opacity var(--duration-fast) var(--ease-smooth-out);
  }
  body.sheet-open .sheet-backdrop { opacity: 1; pointer-events: auto; }

  /* ---- 排版 ---- */
  .display-num { font-size: 42px; letter-spacing: -0.02em; }
  .num-l { font-size: 24px; }
  h1, .h1 { font-size: 21px; }
  h2, .h2 { font-size: 16px; }

  /* ---- 河流视图 ---- */
  .river-hero { gap: 14px; margin-bottom: 16px; }
  .hero-stats-line { flex-wrap: wrap; gap: 4px 8px; font-size: 12px; }
  .hero-right-cards { grid-template-columns: 1fr 1fr; gap: 8px; }
  #hero-gap-card { grid-column: 1 / -1; }
  .mini-card { height: auto; min-height: 100px; padding: 10px; }
  .sankey-toolbar { flex-direction: column; align-items: stretch; gap: 8px; }
  .color-mode-pills { overflow-x: auto; scrollbar-width: none; }
  .color-mode-pills::-webkit-scrollbar { display: none; }
  .color-pill-btn { flex: 0 0 auto; padding: 5px 10px; }
  .sankey-columns-header, .drilldown-columns-header { font-size: 9.5px; }
  #drilldown-sankey-section { margin-top: 18px; }

  /* ---- 表格：横向滑动，不压缩列 ---- */
  .table-scroll {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  /* 660px 时"商品名称"列会被数字列挤成竖排单字，给足到 860px 再横滑 */
  .table-scroll > .ledger-table { min-width: 860px; }
  .table-scroll > .ledger-table td, .table-scroll > .ledger-table th { min-width: 56px; }
  .ledger-table th, .ledger-table td { padding: 7px 9px !important; font-size: 11.5px; }

  /* ---- 省份视图 ---- */
  .province-view-layout { flex-direction: column !important; gap: 12px !important; }
  .province-ranking-pane {
    width: 100% !important;
    height: auto !important;
    border-right: none !important;
    border-bottom: 1px solid var(--line);
    padding-right: 0 !important;
    padding-bottom: 12px;
  }
  .province-list-scroll { max-height: 38vh; }
  .province-chapters-pane { height: auto !important; overflow: visible !important; }
  #province-treemap-container { height: 340px !important; }

  /* ---- 版图视图 ---- */
  .tm-canvas-stack { overflow: visible !important; }
  #treemap-chapters-canvas { flex: none !important; height: 320px; }
  .tm-provinces-box { flex: none !important; }
  #treemap-provinces-canvas { height: 260px; }
  #treemap-canvas-container { height: 420px; }
  #treemap-tooltip { display: none !important; }  /* 触屏没有 hover，改由底部面板承接 */

  /* ---- 品目 / 行业 / 量价 ---- */
  #hs4-treemap-container { height: 360px !important; }
  .scatter-box { height: 340px !important; }
  .view-head-row { flex-direction: column; align-items: flex-start !important; gap: 8px; }

  /* ---- 时间视图 ---- */
  .time-charts-grid { grid-template-columns: 1fr !important; }
  #customs-small-multiples { grid-template-columns: repeat(2, 1fr) !important; }
  .small-multiples-grid { grid-template-columns: repeat(2, 1fr); }
  #industry-select-dropdown { max-width: 100%; }

  /* ---- 归属视图 ---- */
  .where-triplet-grid { grid-template-columns: 1fr !important; gap: 10px !important; }
  .chart-scroll-x { overflow-x: auto; -webkit-overflow-scrolling: touch; }

  /* ---- 账本视图 ---- */
  .ledger-main-layout { grid-template-columns: 1fr; }
  .ledger-filter-row { flex-wrap: wrap; }

  /* ---- 弹层 ---- */
  .modal-overlay { padding: 0 14px; }
  .modal-card { max-width: none; padding: 16px; }
  .command-dialog-overlay { padding: 8vh 12px 0; }
  .command-dialog-card { max-width: none; }
  .command-results-list { max-height: 46vh; }
  .command-footer { display: none; }

  #toast-msg {
    left: 12px; right: 12px;
    bottom: calc(var(--m-nav-h) + var(--m-sheet-h) + var(--safe-b) + 12px);
    text-align: center;
  }
  .first-run-hint {
    left: 12px; right: 12px; width: auto;
    bottom: calc(var(--m-nav-h) + var(--m-sheet-h) + var(--safe-b) + 12px);
  }
  .first-run-hint-footer > span { display: none; }

  .boot-skeleton { min-height: 300px; }
  .boot-status { top: 200px; }
  .boot-help { margin: 24px auto; }
  .boot-help-title { font-size: 19px; }

  /* Task 2: hero-thesis mobile */
  .hero-thesis { font-size: 14px; }

  /* Task 4: drilldown scroll-margin mobile */
  #drilldown-sankey-section { scroll-margin-top: 80px; }

  /* Task 9: minimum caption sizes */
  .caption { font-size: 11.5px; color: var(--ink-2); }
  .mover-chips-caption { font-size: 11.5px; }
  .drilldown-edge-caption { font-size: 11.5px; }
}

/* 触屏：去掉悬停位移与阴影，避免点一下就"抖" */
@media (hover: none) {
  .tool-btn:hover,
  .mini-card:hover,
  .spark-card:hover,
  .panel-btn:hover,
  .tm-crumb-card:hover,
  .treemap-node:hover,
  .month-nav-btn:hover:not(:disabled) {
    transform: none;
  }
  .treemap-node:hover { box-shadow: none; }
}

/* 手机端把手内容更新时的一次轻提示 */
@media (max-width: 767px) {
  .panel-sheet-handle.updated { animation: sheet-handle-flash 900ms var(--ease-smooth-out); }
  @keyframes sheet-handle-flash {
    0%   { background: #EEF4FD; }
    100% { background: #FFFFFF; }
  }
  .panel-sheet-handle.updated .sheet-handle-cue { color: var(--surplus); }
}

/* ==========================================================================
   Price & Qty View — 四象限金额看板 + 蜂群带
   ========================================================================== */
.price-qty-view-layout {
  container: price-qty / inline-size;
}

.pq-head-tools {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.pq-capsule {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--ink-2);
  background: #F4F4F5;
  padding: 6px 12px;
  border-radius: 6px;
  white-space: nowrap;
}
.pq-capsule strong { color: var(--ink); }
.pq-capsule-muted { background: #FFFFFF; border: 1px solid var(--line); color: var(--ink-3); }
.pq-capsule-click {
  background: #FFFFFF;
  border: 1px solid var(--line);
  cursor: pointer;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.03);
}
.pq-capsule-click:hover { border-color: var(--line-strong); }
.pq-dot { width: 6px; height: 6px; border-radius: 50%; display: inline-block; }

/* ---- 四象限金额卡片 ---- */
.pq-cards-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.pq-card {
  position: relative;
  background: #FAFAFA;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px 16px;
  cursor: pointer;
  transition: background var(--duration-quick) var(--ease-smooth-out),
              border-color var(--duration-quick) var(--ease-smooth-out),
              box-shadow var(--duration-quick) var(--ease-smooth-out),
              transform var(--duration-quick) var(--ease-smooth-out);
}
.pq-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  border-radius: 8px 8px 0 0;
  background: var(--pq-c, var(--line-strong));
}
.pq-card:hover,
.pq-card.active {
  background: #FFFFFF;
  border-color: var(--line-strong);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
  transform: translateY(-2px);
}
.pq-card.active { border-color: var(--pq-c, var(--line-strong)); }

.pq-card-tag {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 12px;
  font-weight: 700;
  margin-bottom: 8px;
}
.pq-card-count { font-size: 11px; font-weight: 600; color: var(--ink-3); white-space: nowrap; }
.pq-card-amount {
  font-size: clamp(17px, 1.45vw, 21px);
  font-weight: 700;
  font-family: var(--font-mono);
  color: var(--ink);
  white-space: nowrap;
}
.pq-card-share { font-size: 12px; color: var(--ink-3); margin-top: 2px; }
.pq-card-share strong { color: var(--ink-2); }
.pq-card-bar {
  height: 4px;
  background: var(--line);
  border-radius: 2px;
  margin: 10px 0;
  overflow: hidden;
}
.pq-card-bar-fill { height: 100%; border-radius: 2px; }
.pq-card-items { font-size: 11.5px; color: var(--ink-2); line-height: 1.5; }

/* ---- 蜂群带 ---- */
/* 视图列足够宽时四张卡片一行排开，窄列自动折成 2×2 */
@container price-qty (min-width: 880px) {
  .pq-cards-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

.pq-swarm-box {
  background: #FFFFFF;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px 16px 8px;
}
.pq-swarm-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 4px;
}
.pq-swarm-title { font-size: 13px; font-weight: 600; color: var(--ink); }
.pq-swarm-hint { font-size: 11.5px; color: var(--ink-3); white-space: nowrap; }
.pq-swarm-canvas { width: 100%; height: 300px; position: relative; }

/* ---- 账本联动 ---- */
.pq-row {
  border-bottom: 1px solid var(--line-2);
  cursor: pointer;
  transition: background var(--duration-quick) var(--ease-smooth-out);
}
.pq-row:hover { background: #F8FAFC; }
.pq-row.pq-row-flash { background: #FEF3C7; }

/* ---- 浮动 Tooltip ---- */
.pq-tooltip {
  position: fixed;
  pointer-events: none;
  z-index: 1000;
  opacity: 0;
  width: 236px;
  background: #FFFFFF;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  box-shadow: var(--shadow-popup);
  transition: opacity var(--duration-fast) var(--ease-smooth-out);
}
.pq-tt-title { font-size: 12.5px; font-weight: 700; color: var(--ink); margin-bottom: 6px; }
.pq-tt-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-size: 11.5px;
  color: var(--ink-3);
  line-height: 1.8;
}
.pq-tt-row span:last-child { font-family: var(--font-mono); color: var(--ink); }
.pq-tt-note { margin-top: 6px; font-size: 11px; color: #B45309; }

@media (max-width: 767px) {
  .pq-cards-grid { gap: 10px; }
  .pq-card-amount { font-size: 19px; }
  .pq-swarm-canvas { height: 340px; }
  .pq-swarm-hint { display: none; }
  .pq-tooltip { display: none !important; }  /* 触屏没有 hover，改由底部面板承接 */
}
