/* ReitsBand 行情看板 */

.page.market-page {
  max-width: 1340px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.market-page > .panel + .panel,
.market-columns .panel + .panel {
  margin-top: 0;
}

.market-header {
  margin-bottom: 0;
  align-items: flex-end;
}

.market-header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 0 0 auto;
}

.market-stamp {
  color: var(--muted);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* ---------------------------- 指标卡片 ---------------------------- */

.metric-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}

.metric-card {
  min-height: 104px;
  padding: 16px 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 6px;
}

.metric-card.skeleton {
  background: linear-gradient(100deg, var(--surface-2) 30%, var(--line-soft) 50%, var(--surface-2) 70%);
  background-size: 220% 100%;
  animation: market-shimmer 1.4s linear infinite;
}

@keyframes market-shimmer {
  from { background-position: 120% 0; }
  to { background-position: -120% 0; }
}

.metric-label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.metric-value {
  font-size: 26px;
  font-weight: 800;
  line-height: 1.15;
  font-variant-numeric: tabular-nums;
}

.metric-foot {
  color: var(--muted);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

.metric-foot .up,
.metric-value.up {
  color: var(--red);
}

.metric-foot .down,
.metric-value.down {
  color: var(--green);
}

/* ------------------------------ 面板 ------------------------------ */

.market-panel {
  padding: 18px 20px 20px;
}

.panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
}

.panel-head h2 {
  margin-bottom: 3px;
  font-size: 17px;
}

.panel-sub {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
}

.market-columns {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 18px;
  align-items: stretch;
}

.market-columns > .market-panel {
  height: 100%;
}

/* ---------------------------- 区间切换 ---------------------------- */

.range-switch {
  display: inline-flex;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
  flex: 0 0 auto;
}

.range-switch button {
  min-height: 28px;
  padding: 3px 12px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.range-switch button:hover {
  background: var(--surface);
  color: var(--ink);
}

.range-switch button.active {
  background: var(--surface);
  color: var(--brand);
  box-shadow: var(--shadow);
}

/* 板块指标切换 */
.metric-switch {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 3px;
  margin-bottom: 12px;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
}

.metric-switch button {
  min-height: 28px;
  padding: 3px 14px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.metric-switch button:hover {
  background: var(--surface);
  color: var(--ink);
}

.metric-switch button.active {
  background: var(--surface);
  color: var(--brand);
  box-shadow: var(--shadow);
}

.sector-totals {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px 16px;
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--line-soft);
}

.sector-total {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  font-size: 12px;
}

.sector-total span {
  color: var(--muted);
}

.sector-total b {
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}

.sector-total b.up {
  color: var(--red);
}

.sector-total b.down {
  color: var(--green);
}

/* ---------------------------- 图表区域 ---------------------------- */

.chart-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 18px;
  margin-bottom: 6px;
}

.chart-legend span {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: var(--ink-2);
  font-size: 12px;
  font-weight: 650;
}

.chart-legend i {
  width: 14px;
  height: 3px;
  border-radius: 2px;
  background: currentColor;
}

.chart-host {
  position: relative;
  width: 100%;
  min-height: 300px;
}

.chart-host-bar {
  min-height: 260px;
}

.chart-host-kline {
  min-height: 340px;
}

.kline-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 22px;
  margin-bottom: 10px;
}

.kline-stat {
  display: flex;
  align-items: baseline;
  gap: 7px;
  font-size: 12px;
}

.kline-stat span {
  color: var(--muted);
}

.kline-stat b {
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}

.chart-host svg {
  display: block;
  width: 100%;
  overflow: visible;
}

.chart-tooltip {
  position: absolute;
  z-index: 5;
  min-width: 158px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface);
  box-shadow: var(--shadow);
  color: var(--ink-2);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.12s ease;
}

.chart-tooltip.show {
  opacity: 1;
}

.chart-tooltip b {
  display: block;
  margin-bottom: 4px;
  color: var(--ink);
  font-size: 12px;
}

.chart-tooltip em {
  display: inline-block;
  width: 8px;
  height: 8px;
  margin-right: 6px;
  border-radius: 50%;
  background: currentColor;
  vertical-align: middle;
}

.chart-tooltip .row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.sector-chart {
  display: grid;
  gap: 9px;
}

.sector-row {
  display: grid;
  grid-template-columns: minmax(96px, 132px) minmax(0, 1fr) 68px;
  align-items: center;
  gap: 12px;
}

.sector-name {
  display: flex;
  flex-direction: column;
  color: var(--ink);
  font-size: 13px;
  font-weight: 650;
  line-height: 1.3;
}

.sector-name em {
  color: var(--muted);
  font-size: 11px;
  font-style: normal;
  font-weight: 500;
}

.sector-track {
  position: relative;
  height: 16px;
  border-radius: 4px;
  background: var(--surface-2);
  border: 1px solid var(--line-soft);
}

.sector-track::before {
  content: "";
  position: absolute;
  top: -2px;
  bottom: -2px;
  left: 50%;
  width: 1px;
  background: var(--line);
}

.sector-track i {
  position: absolute;
  top: 2px;
  bottom: 2px;
  border-radius: 3px;
}

.sector-track i.pos {
  background: var(--red);
  opacity: 0.82;
}

.sector-track i.neg {
  background: var(--green);
  opacity: 0.82;
}

.sector-track i.neutral {
  background: var(--brand);
  opacity: 0.7;
}

.sector-value {
  text-align: right;
  font-size: 13px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.sector-value.up {
  color: var(--red);
}

.sector-value.down {
  color: var(--green);
}

.sector-value.flat {
  color: var(--muted);
}

/* ------------------------------ 表格 ------------------------------ */

.table-scroll {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.market-table {
  min-width: 640px;
  font-size: 13px;
}

.market-table.compact {
  min-width: 420px;
}

.market-table th,
.market-table td {
  padding: 9px 12px;
}

.market-table thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  white-space: nowrap;
}

.market-table tbody tr:hover {
  background: var(--surface-2);
}

.market-table tbody tr[data-code] {
  cursor: pointer;
}

.market-table tbody tr.selected {
  background: var(--brand-soft);
  box-shadow: inset 3px 0 0 var(--brand);
}

.market-table tbody tr.selected:hover {
  background: var(--brand-soft);
}

.market-table .num {
  text-align: right;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.market-table .sortable {
  cursor: pointer;
  user-select: none;
}

.market-table .sortable::after {
  content: "";
  display: inline-block;
  width: 0;
  height: 0;
  margin-left: 6px;
  border-left: 4px solid transparent;
  border-right: 4px solid transparent;
  border-top: 5px solid var(--line);
  vertical-align: middle;
  opacity: 0.6;
}

.market-table .sortable.asc::after {
  border-top: 0;
  border-bottom: 5px solid var(--brand);
  opacity: 1;
}

.market-table .sortable.desc::after {
  border-top-color: var(--brand);
  opacity: 1;
}

.market-table .code {
  color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
}

.market-table .name {
  color: var(--ink);
  font-weight: 650;
}

.market-table .up {
  color: var(--red);
  font-weight: 700;
}

.market-table .down {
  color: var(--green);
  font-weight: 700;
}

.market-table .flat {
  color: var(--muted);
}

.market-table .tag {
  display: inline-block;
  padding: 1px 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--ink-2);
  font-size: 11px;
  font-weight: 650;
  white-space: nowrap;
}

.market-table .empty {
  padding: 34px 16px;
}

/* 数据源不提供多周期涨跌幅时隐藏整列，避免出现半空表格 */
.market-table.hide-60d .col-60d,
.market-table.hide-ytd .col-ytd,
.market-table.hide-since .col-since {
  display: none;
}

/* ---------------------------- 筛选区域 ---------------------------- */

.market-filters {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 12px;
  margin-bottom: 14px;
}

.filter-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 150px;
}

.filter-field span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.filter-field input,
.filter-field select {
  min-height: 36px;
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface);
  color: var(--ink);
  font-size: 13px;
}

.market-filters button {
  min-height: 36px;
}

/* ---------------------------- 免责声明 ---------------------------- */

.market-disclaimer {
  margin: 0;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-left: 4px solid var(--amber);
  border-radius: 7px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 12px;
  line-height: 1.7;
}

.market-disclaimer a {
  color: var(--brand);
}

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

@media (max-width: 1080px) {
  .metric-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

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

@media (max-width: 720px) {
  .page.market-page {
    padding: 18px 14px 26px;
    gap: 14px;
  }

  .market-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }

  .market-header-actions {
    width: 100%;
    justify-content: space-between;
  }

  .metric-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .metric-value {
    font-size: 22px;
  }

  .panel-head {
    flex-direction: column;
    gap: 10px;
  }

  .chart-host {
    min-height: 240px;
  }

  .chart-host-kline {
    min-height: 300px;
  }

  .sector-totals {
    grid-template-columns: minmax(0, 1fr);
  }

  .metric-switch button {
    padding: 3px 10px;
  }

  .filter-field {
    flex: 1 1 140px;
    min-width: 0;
  }
}
