/*
  Component — Markets page (行情)
*/

.market-page {
  padding-bottom: var(--space-8);
}

.market-tabs {
  padding-top: var(--space-3);
  border-bottom: 1px solid var(--color-border);
}

.market-tabs__list {
  display: flex;
}

.market-tab {
  flex: 1;
  position: relative;
  padding: var(--space-2) var(--space-1) 10px;
  color: var(--color-text-tertiary);
  font-size: var(--font-size-md);
  font-weight: var(--font-weight-medium);
  text-align: center;
}

.market-tab.is-active {
  color: var(--color-brand-blue);
  font-weight: var(--font-weight-bold);
}

.market-tab.is-active::after {
  content: '';
  position: absolute;
  left: 24%;
  right: 24%;
  bottom: -1px;
  height: 2.5px;
  border-radius: 2px 2px 0 0;
  background: var(--color-brand-blue);
}

.market-panel { display: none; }
.market-panel.is-active { display: block; }

.market-section {
  padding: var(--space-4) 0 0;
}

.market-section--last {
  padding-bottom: var(--space-6);
}

.market-section__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  margin-bottom: var(--space-3);
}

.market-section__title {
  font-size: 16px;
  font-weight: var(--font-weight-bold);
  color: var(--color-text-primary);
}

.market-section__time {
  flex-shrink: 0;
  color: var(--color-text-tertiary);
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-medium);
}

.market-section__sub {
  margin-top: 2px;
  color: var(--color-text-tertiary);
  font-size: var(--font-size-xs);
  font-weight: var(--font-weight-medium);
}

.market-index-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: var(--space-2);
}

.market-index-card {
  min-width: 0;
  padding: var(--space-3);
  border-radius: var(--radius-md);
  background: var(--color-surface);
  box-shadow: var(--shadow-sm);
  text-align: left;
}

.market-index-card__top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
}

.market-index-card__name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--color-text-primary);
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-bold);
}

.market-index-card__tag {
  flex-shrink: 0;
  padding: 2px 6px;
  border-radius: var(--radius-sm);
  background: rgba(10, 120, 209, 0.08);
  color: var(--color-brand-blue);
  font-size: var(--font-size-xs);
  font-weight: var(--font-weight-semibold);
}

.market-index-card__value {
  margin-top: var(--space-2);
  color: var(--color-text-primary);
  font-size: var(--font-size-lg);
  font-weight: var(--font-weight-black);
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
}

.market-index-card__change {
  margin-top: 2px;
  font-size: var(--font-size-xs);
  font-weight: var(--font-weight-semibold);
  white-space: nowrap;
}

.market-index-card.is-up .market-index-card__change,
.market-contract.is-up em { color: var(--color-up); }

.market-index-card.is-down .market-index-card__change,
.market-contract.is-down em { color: var(--color-down); }

.market-spark {
  width: 100%;
  height: 34px;
  margin-top: var(--space-3);
  color: var(--color-flat);
}

.market-spark__svg {
  display: block;
  width: 100%;
  height: 100%;
  overflow: visible;
}

.market-spark__area {
  fill: currentColor;
  opacity: 0.10;
  stroke: none;
}

.market-spark__line {
  fill: none;
  stroke: currentColor;
  stroke-width: 3.2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.market-spark__dot {
  fill: var(--color-surface);
  stroke: currentColor;
  stroke-width: 2.4;
}

.market-spark--up { color: var(--color-up); }
.market-spark--down { color: var(--color-down); }

.market-chip-row {
  display: flex;
  gap: var(--space-2);
  max-width: 64%;
  overflow-x: auto;
  scrollbar-width: none;
}

.market-chip-row::-webkit-scrollbar { display: none; }

.market-chip {
  flex-shrink: 0;
  padding: 5px 12px;
  border-radius: var(--radius-full);
  border: 1px solid var(--color-border);
  color: var(--color-text-secondary);
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-semibold);
  white-space: nowrap;
}

.market-chip.is-active {
  border-color: var(--color-brand-blue);
  background: var(--color-brand-blue);
  color: var(--color-text-inverse);
}

.market-table {
  padding: 0 var(--space-3);
  border-radius: var(--radius-md);
  background: var(--color-surface);
  box-shadow: var(--shadow-sm);
}

.market-overview {
  display: grid;
  grid-template-columns: 1.45fr 1fr;
  gap: var(--space-3);
}

.market-bars,
.market-breadth {
  border-radius: var(--radius-md);
  background: var(--color-surface);
  box-shadow: var(--shadow-sm);
}

.market-bars {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  align-items: end;
  gap: var(--space-2);
  min-height: 160px;
  padding: var(--space-4) var(--space-3) var(--space-3);
}

.market-bar {
  display: grid;
  grid-template-rows: 1fr auto;
  align-items: end;
  gap: var(--space-2);
  height: 132px;
}

.market-bar span {
  width: 100%;
  min-height: 8px;
  align-self: end;
  border-radius: var(--radius-sm) var(--radius-sm) 2px 2px;
  background: linear-gradient(180deg, var(--color-brand-blue), #74B4E8);
}

.market-bar em {
  color: var(--color-text-tertiary);
  font-size: var(--font-size-xs);
  font-style: normal;
  text-align: center;
  white-space: nowrap;
}

.market-breadth {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: var(--space-3);
  padding: var(--space-4);
}

.market-breadth__row {
  display: flex;
  justify-content: space-between;
  gap: var(--space-2);
  color: var(--color-text-secondary);
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-semibold);
}

.market-breadth__row .is-up { color: var(--color-up); }
.market-breadth__row .is-down { color: var(--color-down); }

.market-breadth__track {
  display: flex;
  overflow: hidden;
  height: 12px;
  border-radius: var(--radius-full);
  background: var(--color-bg);
}

.market-breadth__track span.is-up { background: var(--color-up); }
.market-breadth__track span.is-down { background: var(--color-down); }

.market-heatmap-preview {
  display: grid;
  grid-template-columns: 1.35fr 1fr 1fr;
  grid-auto-rows: minmax(56px, auto);
  gap: 3px;
  width: 100%;
  min-height: 188px;
  padding: 3px;
  border-radius: var(--radius-md);
  background: var(--color-surface);
  box-shadow: var(--shadow-sm);
  text-align: left;
}

.market-heatmap-tile {
  display: flex;
  min-width: 0;
  min-height: 56px;
  flex-direction: column;
  justify-content: center;
  gap: 3px;
  padding: var(--space-2);
  border-radius: var(--radius-sm);
  color: var(--color-text-primary);
  overflow: hidden;
}

.market-heatmap-tile--xl {
  grid-row: span 2;
}

.market-heatmap-tile--lg {
  grid-row: span 2;
}

.market-heatmap-tile strong,
.market-heatmap-tile em {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
}

.market-heatmap-tile strong {
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-bold);
  line-height: 1.25;
}

.market-heatmap-tile em {
  font-size: var(--font-size-sm);
  font-style: normal;
  font-weight: var(--font-weight-bold);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.market-heatmap-tile--up {
  background: var(--color-up-bg);
}

.market-heatmap-tile--up em {
  color: var(--color-up);
}

.market-heatmap-tile--down {
  background: var(--color-down-bg);
}

.market-heatmap-tile--down em {
  color: var(--color-down);
}

.market-heatmap-tile--flat {
  background: var(--color-flat-bg);
}

.market-heatmap-tile--flat em {
  color: var(--color-flat);
}

.market-toggle {
  display: inline-flex;
  flex-shrink: 0;
  padding: 2px;
  border-radius: var(--radius-full);
  background: var(--color-bg);
}

.market-toggle button {
  padding: 5px 10px;
  border-radius: var(--radius-full);
  color: var(--color-text-tertiary);
  font-size: var(--font-size-xs);
  font-weight: var(--font-weight-semibold);
}

.market-toggle button.is-active {
  background: var(--color-surface);
  color: var(--color-brand-blue);
  box-shadow: var(--shadow-sm);
}

.market-info-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: var(--space-2);
}

.market-info-grid button {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-2);
  min-height: 86px;
  padding: var(--space-3) var(--space-2);
  border-radius: var(--radius-md);
  background: var(--color-surface);
  box-shadow: var(--shadow-sm);
  color: var(--color-text-primary);
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-semibold);
}

.market-info-grid img {
  width: 24px;
  height: 24px;
  opacity: 0.72;
}

.market-contract-group,
.market-region {
  margin-bottom: var(--space-4);
}

.market-contract-group h3,
.market-region h3 {
  margin-bottom: var(--space-2);
  color: var(--color-text-secondary);
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-bold);
}

.market-contract-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: var(--space-2);
}

.market-contract {
  min-width: 0;
  padding: var(--space-3);
  border-radius: var(--radius-md);
  background: var(--color-surface);
  box-shadow: var(--shadow-sm);
  text-align: left;
}

.market-contract span,
.market-contract em {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.market-contract span {
  color: var(--color-text-tertiary);
  font-size: var(--font-size-xs);
  font-weight: var(--font-weight-semibold);
}

.market-contract strong {
  display: block;
  margin-top: var(--space-1);
  color: var(--color-text-primary);
  font-size: var(--font-size-md);
  font-weight: var(--font-weight-bold);
  font-variant-numeric: tabular-nums;
}

.market-contract em {
  margin-top: 2px;
  font-size: var(--font-size-sm);
  font-style: normal;
  font-weight: var(--font-weight-semibold);
  font-variant-numeric: tabular-nums;
}

/* 產業熱力圖 page */
.heatmap-page {
  padding-bottom: var(--space-8);
}

.heatmap-page__header {
  display: grid;
  grid-template-columns: 40px minmax(0, 1fr) 40px;
  align-items: center;
  gap: var(--space-2);
  padding-top: var(--space-3);
  padding-bottom: var(--space-4);
}

.heatmap-page__back,
.heatmap-page__icon {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: var(--radius-full);
  background: var(--color-surface);
  box-shadow: var(--shadow-sm);
}

.heatmap-page__back img,
.heatmap-page__icon img {
  width: 20px;
  height: 20px;
}

.heatmap-page__title {
  color: var(--color-text-primary);
  font-size: var(--font-size-xl);
  font-weight: var(--font-weight-black);
  line-height: 1.15;
}

.heatmap-page__meta {
  margin-top: 2px;
  color: var(--color-text-tertiary);
  font-size: var(--font-size-xs);
  font-weight: var(--font-weight-medium);
}

.heatmap-control-stack {
  display: grid;
  gap: var(--space-3);
  margin-bottom: var(--space-3);
}

.heatmap-segment {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 2px;
  padding: 2px;
  border-radius: var(--radius-full);
  background: var(--color-surface);
  box-shadow: var(--shadow-sm);
}

.heatmap-segment--compact {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  min-width: 156px;
}

.heatmap-segment button {
  min-height: 34px;
  border-radius: var(--radius-full);
  color: var(--color-text-tertiary);
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-semibold);
}

.heatmap-segment button.is-active {
  background: var(--color-brand-blue);
  color: var(--color-text-inverse);
}

.heatmap-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
}

.heatmap-filter-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-1);
  min-height: 38px;
  padding: 0 var(--space-3);
  border-radius: var(--radius-full);
  background: var(--color-surface);
  box-shadow: var(--shadow-sm);
  color: var(--color-text-secondary);
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-semibold);
  white-space: nowrap;
}

.heatmap-filter-btn img {
  width: 16px;
  height: 16px;
}

.heatmap-controls {
  display: flex;
  gap: var(--space-2);
  overflow-x: auto;
  scrollbar-width: none;
}

.heatmap-controls::-webkit-scrollbar {
  display: none;
}

.heatmap-controls button {
  flex-shrink: 0;
  min-height: 34px;
  padding: 0 var(--space-3);
  border-radius: var(--radius-full);
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  color: var(--color-text-secondary);
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-semibold);
}

.heatmap-controls button.is-active {
  border-color: var(--color-brand-blue);
  background: var(--color-brand-blue);
  color: var(--color-text-inverse);
}

.heatmap-view {
  display: none;
}

.heatmap-view.is-active {
  display: block;
}

.heatmap-board {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  grid-auto-rows: minmax(76px, auto);
  gap: 3px;
  min-height: 520px;
  padding: 3px;
  border-radius: var(--radius-md);
  background: var(--color-surface);
  box-shadow: var(--shadow-sm);
}

.heatmap-card {
  display: flex;
  min-width: 0;
  flex-direction: column;
  justify-content: center;
  gap: 4px;
  padding: var(--space-2);
  border-radius: var(--radius-sm);
  color: var(--color-text-primary);
  text-align: left;
  overflow: hidden;
}

.heatmap-card--hero {
  grid-column: span 2;
  grid-row: span 3;
}

.heatmap-card--wide {
  grid-column: span 2;
  grid-row: span 2;
}

.heatmap-card strong,
.heatmap-card span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
}

.heatmap-card strong {
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-bold);
  line-height: 1.25;
}

.heatmap-card span {
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-bold);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.heatmap-card--hero strong {
  font-size: var(--font-size-lg);
}

.heatmap-card--hero span {
  font-size: var(--font-size-xl);
}

.heatmap-card--up { background: var(--color-up-bg); }
.heatmap-card--up span { color: var(--color-up); }
.heatmap-card--down { background: var(--color-down-bg); }
.heatmap-card--down span { color: var(--color-down); }
.heatmap-card--flat { background: var(--color-flat-bg); }
.heatmap-card--flat span { color: var(--color-flat); }
.heatmap-card.is-selected,
.heatmap-list__row.is-selected {
  box-shadow: inset 0 0 0 2px var(--color-brand-blue);
}

.heatmap-legend {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  overflow: hidden;
  margin-top: var(--space-3);
  border-radius: var(--radius-full);
  background: var(--color-surface);
  box-shadow: var(--shadow-sm);
}

.heatmap-legend span {
  padding: 6px 2px;
  color: var(--color-text-tertiary);
  font-size: var(--font-size-xs);
  font-weight: var(--font-weight-semibold);
  text-align: center;
}

.heatmap-legend .is-up {
  color: var(--color-up);
  background: var(--color-up-bg);
}

.heatmap-legend .is-down {
  color: var(--color-down);
  background: var(--color-down-bg);
}

.heatmap-list,
.heatmap-detail,
.heatmap-stock-list {
  border-radius: var(--radius-md);
  background: var(--color-surface);
  box-shadow: var(--shadow-sm);
}

.heatmap-list {
  overflow: hidden;
}

.heatmap-list__head,
.heatmap-list__row {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) 72px 76px 62px;
  align-items: center;
  gap: var(--space-2);
  width: 100%;
  min-height: 46px;
  padding: 0 var(--space-3);
  text-align: left;
}

.heatmap-list__head {
  color: var(--color-text-tertiary);
  font-size: var(--font-size-xs);
  font-weight: var(--font-weight-semibold);
}

.heatmap-list__head button {
  color: inherit;
  font: inherit;
  text-align: inherit;
}

.heatmap-list__row {
  border-top: 1px solid var(--color-border);
  color: var(--color-text-primary);
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-semibold);
}

.heatmap-list__row strong,
.heatmap-list__row em {
  font-style: normal;
  font-variant-numeric: tabular-nums;
}

.heatmap-list__row.is-up strong { color: var(--color-up); }
.heatmap-list__row.is-down strong { color: var(--color-down); }
.heatmap-list__row.is-selected {
  background: rgba(10, 120, 209, 0.05);
}

.heatmap-detail {
  margin-top: var(--space-4);
  padding: var(--space-4);
}

.heatmap-detail__summary {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-3);
}

.heatmap-detail__summary h2 {
  color: var(--color-text-primary);
  font-size: var(--font-size-lg);
  font-weight: var(--font-weight-black);
}

.heatmap-detail__summary p {
  margin-top: 2px;
  color: var(--color-text-tertiary);
  font-size: var(--font-size-xs);
  font-weight: var(--font-weight-medium);
}

.heatmap-detail__summary > strong {
  color: var(--color-flat);
  font-size: var(--font-size-xl);
  font-weight: var(--font-weight-black);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.heatmap-detail__summary > strong.is-up { color: var(--color-up); }
.heatmap-detail__summary > strong.is-down { color: var(--color-down); }

.heatmap-breadth {
  margin-top: var(--space-4);
}

.heatmap-breadth__labels {
  display: flex;
  justify-content: space-between;
  gap: var(--space-2);
  color: var(--color-text-tertiary);
  font-size: var(--font-size-xs);
  font-weight: var(--font-weight-semibold);
}

.heatmap-breadth__labels .is-up { color: var(--color-up); }
.heatmap-breadth__labels .is-down { color: var(--color-down); }

.heatmap-breadth__track {
  display: flex;
  overflow: hidden;
  height: 10px;
  margin-top: var(--space-2);
  border-radius: var(--radius-full);
  background: var(--color-bg);
}

.heatmap-breadth__track .is-up { background: var(--color-up); }
.heatmap-breadth__track .is-flat { background: var(--color-flat); }
.heatmap-breadth__track .is-down { background: var(--color-down); }

.heatmap-stock-list {
  overflow: hidden;
  margin-top: var(--space-4);
}

.heatmap-stock-list__head,
.heatmap-stock-list__row {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) 68px 68px 72px;
  align-items: center;
  gap: var(--space-2);
  min-height: 48px;
  padding: 0 var(--space-3);
}

.heatmap-stock-list__head {
  color: var(--color-text-tertiary);
  font-size: var(--font-size-xs);
  font-weight: var(--font-weight-semibold);
}

.heatmap-stock-list__row {
  width: 100%;
  border-top: 1px solid var(--color-border);
  color: var(--color-text-primary);
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-semibold);
  text-align: left;
}

.heatmap-stock-list__row span:not(:first-child) {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.heatmap-stock-list__row strong,
.heatmap-stock-list__row em {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
}

.heatmap-stock-list__row em {
  margin-top: 2px;
  color: var(--color-text-tertiary);
  font-size: var(--font-size-xs);
  font-style: normal;
}

.heatmap-stock-list__row.is-up span:nth-child(3) { color: var(--color-up); }
.heatmap-stock-list__row.is-down span:nth-child(3) { color: var(--color-down); }

.heatmap-sheet-overlay {
  position: fixed;
  inset: 0;
  z-index: 300;
  display: none;
  background: rgba(0, 0, 0, 0.34);
}

.heatmap-sheet-overlay.is-visible {
  display: block;
}

.heatmap-sheet {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 310;
  display: none;
  max-height: min(76vh, 620px);
  overflow-y: auto;
  padding: var(--space-3) var(--space-4) calc(var(--space-4) + env(safe-area-inset-bottom, 0px));
  border-radius: 20px 20px 0 0;
  background: var(--color-surface);
  box-shadow: 0 -8px 28px rgba(0, 0, 0, 0.14);
}

.heatmap-sheet.is-visible {
  display: block;
}

.heatmap-sheet__handle {
  width: 44px;
  height: 4px;
  margin: 0 auto var(--space-4);
  border-radius: var(--radius-full);
  background: var(--color-border);
}

.heatmap-sheet h2 {
  color: var(--color-text-primary);
  font-size: var(--font-size-xl);
  font-weight: var(--font-weight-black);
}

.heatmap-sheet__group {
  margin-top: var(--space-4);
}

.heatmap-sheet__group h3 {
  margin-bottom: var(--space-2);
  color: var(--color-text-secondary);
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-bold);
}

.heatmap-sheet__options {
  display: flex;
  gap: var(--space-2);
}

.heatmap-sheet__options--grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.heatmap-sheet__options button {
  flex: 1;
  min-height: 42px;
  border-radius: var(--radius-md);
  background: var(--color-bg);
  color: var(--color-text-secondary);
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-semibold);
}

.heatmap-sheet__options button.is-active {
  box-shadow: inset 0 0 0 1.5px var(--color-brand-blue);
  background: var(--color-surface);
  color: var(--color-brand-blue);
}

.heatmap-sheet__actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-3);
  margin-top: var(--space-5);
}

.heatmap-sheet__actions button {
  min-height: 46px;
  border-radius: var(--radius-full);
  border: 1px solid var(--color-border);
  color: var(--color-text-secondary);
  font-size: var(--font-size-base);
  font-weight: var(--font-weight-bold);
}

.heatmap-sheet__actions button.is-primary {
  border-color: var(--color-brand-blue);
  background: var(--color-brand-blue);
  color: var(--color-text-inverse);
}

.heatmap-info-copy {
  display: grid;
  gap: var(--space-3);
  margin-top: var(--space-4);
  color: var(--color-text-secondary);
  font-size: var(--font-size-sm);
  line-height: 1.65;
}

.heatmap-info-copy strong {
  color: var(--color-text-primary);
  font-weight: var(--font-weight-bold);
}

@media (max-width: 430px) {
  .market-index-grid,
  .market-overview,
  .market-contract-grid {
    grid-template-columns: 1fr;
  }

  .market-chip-row {
    max-width: 100%;
    order: 2;
    width: 100%;
  }

  .market-section__header {
    flex-wrap: wrap;
  }

  .market-info-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .market-heatmap-preview {
    grid-template-columns: 1.2fr 1fr;
  }

  .heatmap-board {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    min-height: 500px;
  }

  .heatmap-card--hero,
  .heatmap-card--wide {
    grid-column: span 2;
  }

  .heatmap-list__head,
  .heatmap-list__row {
    grid-template-columns: minmax(0, 1.2fr) 66px 64px 52px;
  }

  .heatmap-stock-list__head,
  .heatmap-stock-list__row {
    grid-template-columns: minmax(0, 1.15fr) 58px 62px 62px;
  }
}

/* 期貨 / 國際: larger cards in horizontal rails */
.market-panel[data-market-panel="futures"] .market-contract-grid,
.market-panel[data-market-panel="global"] .market-index-grid {
  display: flex;
  grid-template-columns: none;
  gap: var(--space-3);
  overflow-x: auto;
  overscroll-behavior-x: contain;
  scroll-snap-type: x proximity;
  scrollbar-width: none;
  padding: 2px var(--space-1) var(--space-2);
  margin: 0 calc(var(--space-1) * -1);
}

.market-panel[data-market-panel="futures"] .market-contract-grid::-webkit-scrollbar,
.market-panel[data-market-panel="global"] .market-index-grid::-webkit-scrollbar {
  display: none;
}

.market-panel[data-market-panel="futures"] .market-contract {
  flex: 0 0 calc((100% - var(--space-3) * 2) / 3);
  min-height: 160px;
  scroll-snap-align: start;
  padding: var(--space-4);
}

.market-panel[data-market-panel="global"] .market-index-card {
  flex: 0 0 calc((100% - var(--space-3) * 2) / 3);
  min-height: 150px;
  scroll-snap-align: start;
  padding: var(--space-4);
}

.market-panel[data-market-panel="futures"] .market-contract strong,
.market-panel[data-market-panel="global"] .market-index-card__value {
  font-size: var(--font-size-xl);
}

.market-panel[data-market-panel="futures"] .market-contract em,
.market-panel[data-market-panel="global"] .market-index-card__change {
  font-size: var(--font-size-base);
}

.market-panel[data-market-panel="global"] .market-spark {
  height: 48px;
}

.market-panel[data-market-panel="futures"] .market-spark {
  height: 42px;
  margin-top: var(--space-3);
}

@media (min-width: 768px) {
  .market-panel[data-market-panel="futures"] .market-contract {
    flex-basis: calc((100% - var(--space-3) * 2) / 3);
  }

  .market-panel[data-market-panel="global"] .market-index-card {
    flex-basis: calc((100% - var(--space-3) * 2) / 3);
  }
}

@media (max-width: 430px) {
  .market-panel[data-market-panel="futures"] .market-contract,
  .market-panel[data-market-panel="global"] .market-index-card {
    flex-basis: 100%;
  }
}
