.buy-sell-chart {
  margin: 1.5rem 0;
  padding: clamp(1rem, 3vw, 1.5rem);
  background: #fff;
  border: 1px solid var(--report-border);
  border-radius: 8px;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.08);
}

.report-figure > .buy-sell-chart {
  margin: 0;
  padding: 0;
  border: 0;
  box-shadow: none;
}

.buy-sell-chart__header {
  display: flex;
  align-items: end;
  justify-content: flex-end;
  gap: 1rem;
  margin-bottom: 1rem;
}

.buy-sell-chart__header h4,
.buy-sell-chart__header p {
  margin: 0;
}

.buy-sell-chart__header h4 {
  color: var(--report-text);
  font-size: 1.1rem;
}

.buy-sell-chart__header p {
  margin-top: 0.2rem;
  color: var(--report-muted);
  font-size: 0.82rem;
}

.buy-sell-chart__header label {
  display: grid;
  gap: 0.3rem;
  color: var(--report-muted);
  font-size: 0.75rem;
  font-weight: 650;
}

.buy-sell-chart__header select {
  min-height: 40px;
  max-width: 230px;
  padding: 0.45rem 2rem 0.45rem 0.65rem;
  color: var(--report-text);
  background: #fff;
  border: 1px solid #94a3b8;
  border-radius: 6px;
  font: inherit;
}

.buy-sell-chart__header select:focus-visible,
.buy-sell-chart__bar:focus-visible,
.buy-sell-chart__canvas:focus-visible {
  outline: 3px solid rgba(37, 99, 235, 0.35);
  outline-offset: 2px;
}

.buy-sell-chart__filter-note {
  margin: -0.25rem 0 0.9rem;
  color: var(--report-muted);
  font-size: 0.72rem;
  text-align: right;
}

.buy-sell-chart__legend {
  display: flex;
  justify-content: center;
  gap: 1.25rem;
  margin-bottom: 0.75rem;
  color: var(--report-muted);
  font-size: 0.78rem;
}

.buy-sell-chart__legend span {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}

.buy-sell-chart__key {
  width: 12px;
  height: 12px;
  border-radius: 2px;
}

.buy-sell-chart__key--buy,
.buy-sell-chart__bar--buy {
  background: #16a34a;
}

.buy-sell-chart__key--sell,
.buy-sell-chart__bar--sell {
  background: #dc2626;
}

.buy-sell-chart__canvas {
  display: grid;
  grid-template-columns: 5.5rem minmax(480px, 1fr);
  grid-template-rows: 280px auto;
  overflow-x: auto;
}

.buy-sell-chart__outcomes {
  display: grid;
  grid-template-rows: repeat(3, minmax(0, 1fr));
  padding-right: 0.75rem;
  color: var(--report-muted);
  font-size: 0.76rem;
  text-align: right;
}

.buy-sell-chart__outcomes strong {
  align-self: center;
}

.buy-sell-chart__plot {
  position: relative;
  display: grid;
  grid-template-rows: repeat(3, minmax(0, 1fr));
  border-bottom: 1px solid #94a3b8;
  border-left: 1px solid #94a3b8;
}

.buy-sell-chart__gridline {
  position: absolute;
  top: 0;
  bottom: 0;
  left: var(--grid-position);
  border-left: 1px dashed rgba(100, 116, 139, 0.35);
  pointer-events: none;
}

.buy-sell-chart__bars {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 4px;
  min-width: 0;
}

.buy-sell-chart__bar {
  position: relative;
  width: var(--bar-width);
  height: 28px;
  min-width: 2px;
  padding: 0;
  border: 0;
  border-radius: 0 4px 4px 0;
  cursor: help;
  transition: filter 140ms ease, width 180ms ease;
}

.buy-sell-chart__bar:hover,
.buy-sell-chart__bar:focus-visible {
  filter: brightness(0.9);
}

.buy-sell-chart__value {
  position: absolute;
  top: 50%;
  left: calc(100% + 0.35rem);
  color: var(--report-text);
  font-size: 0.68rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  line-height: 1;
  pointer-events: none;
  transform: translateY(-50%);
  white-space: nowrap;
}

.buy-sell-chart__tooltip {
  position: absolute;
  bottom: calc(100% + 0.35rem);
  left: 100%;
  z-index: 2;
  width: max-content;
  padding: 0.35rem 0.5rem;
  color: #fff;
  background: #0f172a;
  border-radius: 4px;
  box-shadow: 0 2px 6px rgba(15, 23, 42, 0.25);
  font-size: 0.72rem;
  font-weight: 650;
  opacity: 0;
  pointer-events: none;
  transform: translateX(-50%) translateY(0.2rem);
  transition: opacity 120ms ease, transform 120ms ease;
}

.buy-sell-chart__bar:hover .buy-sell-chart__tooltip,
.buy-sell-chart__bar:focus-visible .buy-sell-chart__tooltip {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.buy-sell-chart__x-axis {
  display: flex;
  grid-column: 2;
  justify-content: space-between;
  padding-top: 0.4rem;
  color: var(--report-muted);
  font-size: 0.7rem;
  line-height: 1;
}

.buy-sell-chart__axis-label {
  margin: 0.75rem 0 0;
  color: var(--report-muted);
  font-size: 0.76rem;
  text-align: center;
}

.buy-sell-chart [data-chart-data] {
  display: none;
}

@media (max-width: 600px) {
  .buy-sell-chart__header {
    display: grid;
    align-items: stretch;
  }

  .buy-sell-chart__header select {
    width: 100%;
    max-width: none;
  }

  .buy-sell-chart__canvas {
    grid-template-columns: 4.75rem minmax(220px, 1fr);
  }

  .buy-sell-chart__outcomes {
    padding-right: 0.5rem;
    font-size: 0.7rem;
  }

  .buy-sell-chart__bar {
    height: 26px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .buy-sell-chart__bar,
  .buy-sell-chart__tooltip {
    transition: none;
  }
}

@media print {
  .buy-sell-chart {
    break-inside: avoid;
    box-shadow: none;
  }

  .buy-sell-chart__header label {
    display: none;
  }
}
