#panel-structure-buy {
  background: var(--bg-primary);
}

.structure-buy-panel {
  --sb-price-axis-width: 72px;
  height: 100%;
  display: grid;
  grid-template-rows: auto 1fr;
  gap: 8px;
  padding: 8px;
  overflow: hidden;
  background: #0f141b;
}

.structure-buy-topbar {
  display: grid;
  grid-template-columns: 1.35fr repeat(8, minmax(72px, 1fr));
  gap: 3px;
  align-items: stretch;
  padding: 3px;
  border: 1px solid rgba(139, 148, 158, 0.16);
  border-radius: 8px;
  background: linear-gradient(180deg, rgba(255,255,255,0.035), rgba(255,255,255,0.015));
}

.sb-symbol-block,
.sb-metric {
  min-height: 42px;
  border-right: 1px solid rgba(139, 148, 158, 0.14);
  background: rgba(22, 27, 34, 0.62);
  border-radius: 4px;
  padding: 6px 9px;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.sb-metric:last-child {
  border-right: 0;
}

.sb-symbol {
  font-size: 16px;
  font-weight: 800;
  color: var(--text-primary);
  font-family: var(--font-mono);
}

.sb-name,
.sb-metric span {
  font-size: 10px;
  color: var(--text-muted);
}

.sb-metric b {
  margin-top: 2px;
  font-family: var(--font-mono);
  font-size: 15px;
  color: var(--text-primary);
}

.sb-metric.good b,
.sb-status.good {
  color: var(--signal-high);
}

.sb-metric.watch b,
.sb-status.watch {
  color: #e3b341;
}

.sb-metric.risk b,
.sb-status.risk {
  color: var(--signal-warn);
}

.structure-buy-main {
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 240px;
  gap: 8px;
}

.sb-chart-stack {
  min-width: 0;
  min-height: 0;
  display: grid;
  grid-template-rows: 88px minmax(260px, 1fr) 130px 110px;
  gap: 6px;
}

.sb-signal-bands {
  position: relative;
  border: 1px solid rgba(139, 148, 158, 0.14);
  background: rgba(13, 17, 23, 0.55);
  border-radius: 6px;
  overflow: hidden;
}

.sb-signal-bands #structure-buy-band-chart {
  position: absolute;
  top: 0;
  right: var(--sb-price-axis-width);
  bottom: 0;
  left: 0;
  width: auto;
  height: 100%;
}

/* 色带图 overlay */
.sb-signal-bands #structure-buy-band-chart .sb-band-overlay {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: block;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

/* 价格图 overlay（Buy Alert / Buy Ready / SEPA 竖线） */
#structure-buy-price-chart .sb-band-overlay {
  position: absolute;
  inset: 0;
  z-index: 3;
  display: block;
  pointer-events: none;
}

.sb-band-labels {
  position: absolute;
  z-index: 3;
  left: 0;
  top: 0;
  bottom: 0;
  width: 150px;
  display: grid;
  grid-template-rows: repeat(3, 1fr);
  pointer-events: none;
}

.sb-band-labels span {
  display: flex;
  align-items: center;
  padding-left: 12px;
  font-size: 12px;
  font-weight: 700;
  color: var(--text-primary);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.8);
  background: linear-gradient(90deg, rgba(13, 17, 23, 0.82), rgba(13, 17, 23, 0.24), transparent);
}

.sb-chart {
  position: relative;
  border: 1px solid rgba(139, 148, 158, 0.14);
  background: #11161d;
  border-radius: 4px;
  overflow: hidden;
}

.sb-chart-legend {
  position: absolute;
  top: 7px;
  left: 10px;
  z-index: 5;
  display: flex;
  gap: 10px;
  align-items: center;
  pointer-events: none;
  padding: 3px 7px;
  border: 1px solid rgba(139, 148, 158, 0.18);
  border-radius: 3px;
  background: rgba(13, 17, 23, 0.72);
  color: var(--text-secondary);
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 700;
}

.sb-chart-legend-item {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  white-space: nowrap;
}

.sb-chart-legend-item i {
  display: inline-block;
  width: 14px;
  height: 2px;
  border-radius: 99px;
}

.sb-legend-val {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 700;
  margin-left: 1px;
  min-width: 36px;
  display: inline-block;
  text-align: right;
}

.sb-sidebar {
  min-height: 0;
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.sb-card {
  border: 1px solid rgba(139, 148, 158, 0.14);
  background: rgba(22, 27, 34, 0.74);
  border-radius: 4px;
  padding: 9px;
}

.sb-card h3 {
  margin: 0 0 7px;
  font-size: 12px;
  color: var(--text-primary);
}

.sb-card p {
  margin: 6px 0 0;
  line-height: 1.38;
  font-size: 11px;
  color: var(--text-secondary);
}

.sb-status {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 3px 8px;
  border-radius: 4px;
  background: var(--bg-elevated);
  font-weight: 800;
  font-size: 13px;
}

.sb-score-row {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 4px 0;
  border-bottom: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  font-size: 11px;
}

.sb-score-row:last-child {
  border-bottom: none;
}

.sb-score-row b {
  font-family: var(--font-mono);
  color: var(--text-primary);
}

.sb-rule-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-height: 220px;
  overflow: auto;
}

.sb-rule {
  display: grid;
  grid-template-columns: 32px 1fr;
  gap: 6px;
  align-items: center;
  font-size: 11px;
  color: var(--text-secondary);
}

.sb-rule b {
  font-size: 9px;
  text-align: center;
  border-radius: 3px;
  padding: 2px 4px;
  color: var(--text-primary);
  background: var(--bg-elevated);
}

.sb-rule.pass b {
  color: var(--signal-high);
}

.sb-rule.fail b {
  color: var(--signal-warn);
}

/* 买入风险格中的次行（距20日线） */
.sb-metric-sub {
  margin-top: 2px;
  font-size: 10px;
  font-family: var(--font-mono);
  color: var(--text-muted);
  line-height: 1;
}

@media (max-width: 1200px) {
  .structure-buy-topbar {
    grid-template-columns: repeat(4, 1fr);
  }

  .structure-buy-main {
    grid-template-columns: 1fr;
  }

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

/* SEPA 买点卡片（图表内浮层） */
.sb-sepa-badge {
  position: absolute;
  z-index: 10;
  bottom: 8px;
  left: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 10px;
  border-radius: 5px;
  border: 1px solid rgba(63, 185, 80, 0.45);
  background: rgba(13, 17, 23, 0.88);
  font-size: 11px;
  font-family: var(--font-mono);
  color: #3fb950;
  pointer-events: none;
}

.sb-sepa-badge.ready {
  color: #00c896;
  border-color: rgba(0, 200, 150, 0.4);
}

.sb-sepa-badge .sb-sepa-stop {
  color: #f85149;
  font-weight: 700;
}
