.ranking-panel {
  margin-top: 16px;
  padding: 16px 18px 18px;
  border-top: 3px solid #283237;
}

.ranking-panel-head,
.ranking-panel-title,
.ranking-card-head,
.ranking-card-head > div {
  display: flex;
  align-items: baseline;
}

.ranking-panel-head { justify-content: space-between; gap: 14px; }
.ranking-panel-title { gap: 10px; }
.ranking-panel-title h2 {
  margin: 0;
  color: var(--text);
  font-size: 16px;
}
.ranking-panel-title h2::before { content: "> "; color: var(--accent-dim); }
.ranking-panel-title span { color: var(--muted-2); font-size: 11px; }
.ranking-status { margin: 0; color: var(--muted); font-size: 11px; }
.ranking-status[hidden] { display: none; }
.ranking-panel[data-state="error"] .ranking-status { color: var(--down); cursor: help; }

.ranking-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-top: 13px;
}
.ranking-card {
  min-width: 0;
  border: 1px solid var(--line);
  background: var(--surface-4);
}
.ranking-card-head {
  min-height: 62px;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line-soft);
  background: var(--surface-2);
}
.ranking-card-head > div { gap: 9px; }
.ranking-card-head h3 { margin: 0; color: var(--text); font-size: 16px; }
.ranking-card-head p { margin: 0; color: var(--muted-2); font-size: 11px; }
.ranking-info { color: var(--muted-2); font-size: 14px; cursor: help; }
.ranking-info:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.ranking-empty {
  min-height: 470px;
  display: grid;
  place-items: center;
  margin: 0;
  padding: 24px;
  color: var(--muted);
  font-size: 12px;
}
.ranking-color {
  width: 11px;
  height: 11px;
  flex: 0 0 11px;
  border: 1px solid rgba(32, 40, 44, .32);
  border-radius: 50%;
  background: var(--sku-color, #879397);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .38);
}
.ranking-colors {
  display: inline-flex;
  align-items: center;
  flex: 0 0 auto;
  min-width: 11px;
}
.ranking-colors.is-multiple .ranking-color + .ranking-color { margin-left: -3px; }
.ranking-colors.is-multiple .ranking-color {
  box-shadow: 0 0 0 1px var(--surface-4), inset 0 0 0 1px rgba(255, 255, 255, .38);
}
.ranking-store-count {
  color: var(--muted-2);
  font-family: var(--numeric);
  font-size: 10px;
  font-weight: 700;
  white-space: nowrap;
}

/* A: fixed Top 10 horizontal bars with one continuous 100% reference line. */
.rate-chart { min-height: 534px; padding: 10px 12px 12px; }
.rate-ranking {
  display: grid;
  grid-template-columns: minmax(165px, 1.55fr) minmax(135px, 1.7fr) minmax(90px, .8fr);
  gap: 8px;
  min-width: 0;
}
.rate-labels,
.rate-values { padding-top: 24px; }
.rate-label,
.rate-value,
.rate-bar-row {
  height: 52px;
  display: flex;
  align-items: center;
}
.rate-label {
  min-width: 0;
  display: grid;
  grid-template-columns: 17px minmax(0, 1fr);
  gap: 7px;
  color: var(--text);
  font-size: 12px;
}
.rate-label b {
  width: 17px;
  flex: 0 0 17px;
  color: var(--muted-2);
  font-family: var(--numeric);
  text-align: right;
}
.rate-label-copy {
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 3px;
}
.rate-model,
.rate-storage,
.rate-color-name {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.rate-model { font-size: 12px; line-height: 1.2; }
.rate-label-meta {
  width: 100%;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 4px;
  color: var(--muted);
  font-size: 10px;
  line-height: 1.2;
}
.rate-storage { flex: 0 0 auto; font-family: var(--numeric); font-weight: 700; }
.rate-color-name { min-width: 0; }
.rate-plot { position: relative; min-width: 0; }
.rate-axis {
  height: 24px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  position: relative;
  color: var(--muted-2);
  font-family: var(--numeric);
  font-size: 10px;
}
.rate-axis-base {
  position: absolute;
  top: 0;
  transform: translateX(-50%);
  color: var(--down);
  font-weight: 800;
}
.rate-baseline {
  position: absolute;
  z-index: 3;
  top: 22px;
  bottom: 0;
  left: var(--baseline-position);
  border-left: 2px dashed var(--down);
  opacity: .8;
  pointer-events: none;
}
.rate-bars { position: relative; }
.rate-bar-row { position: relative; }
.rate-bar-row::before {
  content: "";
  position: absolute;
  inset: 17px 0;
  border-top: 1px solid var(--line-soft);
}
.rate-bar {
  position: relative;
  z-index: 2;
  min-width: 2px;
  height: 12px;
  background: var(--accent);
  box-shadow: inset 0 -1px 0 rgba(0, 0, 0, .15);
}
.rate-bar.over-base { background: var(--up); }
.rate-value {
  align-content: center;
  flex-wrap: wrap;
  gap: 1px 6px;
  padding-left: 2px;
  font-family: var(--numeric);
}
.rate-value strong {
  width: 100%;
  color: var(--text);
  font-size: 16px;
  font-variant-numeric: tabular-nums;
}
.rate-value small {
  color: var(--muted);
  font-size: 10px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* C: Top 3 cards plus a compact 4-10 ranking list. */
.discount-control {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
}
.discount-control span {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-family: var(--numeric);
}
.discount-control input {
  width: 59px;
  height: 34px;
  border: 1px solid var(--accent-line);
  border-radius: 2px;
  padding: 0 7px;
  color: var(--text);
  background: var(--surface);
  font-family: var(--numeric);
  font-size: 14px;
  font-weight: 800;
  text-align: right;
  outline-color: var(--accent);
}
.profit-card-panel {
  display: flex;
  flex-direction: column;
}
.profit-chart {
  min-height: 534px;
  display: flex;
  flex: 1;
  flex-direction: column;
  padding: 12px;
}
.profit-podium {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 7px;
}
.profit-card {
  position: relative;
  min-width: 0;
  min-height: 145px;
  display: flex;
  flex-direction: column;
  padding: 10px;
  border: 1px solid var(--line);
  border-top: 3px solid var(--accent-line);
  background: var(--surface);
}
.profit-card.rank-1 { border-top-color: var(--up); background: #f2f7f2; }
.profit-rank {
  position: absolute;
  top: 7px;
  right: 8px;
  color: var(--muted-2);
  font-family: var(--numeric);
  font-size: 20px;
  font-weight: 800;
}
.profit-rank::before { content: "#"; font-size: 10px; }
.profit-sku {
  min-width: 0;
  display: flex;
  align-items: flex-start;
  gap: 6px;
  padding-right: 28px;
  color: var(--text);
  font-size: 12px;
  line-height: 1.45;
}
.profit-sku .ranking-colors { margin-top: 2px; }
.profit-sku b {
  display: -webkit-box;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
}
.profit-meta {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 4px 6px;
  margin-top: auto;
  padding-top: 9px;
}
.ranking-profit {
  width: 100%;
  font-family: var(--numeric);
  font-size: 19px;
  font-variant-numeric: tabular-nums;
}
.ranking-profit.positive { color: var(--up); }
.ranking-profit.negative { color: var(--down); }
.ranking-profit.flat { color: var(--muted); }
.ranking-average {
  color: var(--muted);
  font-family: var(--numeric);
  font-size: 10px;
  white-space: nowrap;
}
.profit-list {
  display: grid;
  flex: 1;
  grid-template-rows: repeat(7, minmax(47px, 1fr));
  margin: 10px 0 0;
  padding: 0;
  list-style-position: inside;
  counter-reset: profit-rank 3;
}
.profit-list li {
  min-height: 47px;
  display: grid;
  grid-template-columns: 17px minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  border-top: 1px solid var(--line-soft);
  color: var(--muted-2);
  counter-increment: profit-rank;
  font-family: var(--numeric);
  font-size: 12px;
}
.profit-list li::before { content: counter(profit-rank); grid-column: 1; text-align: right; }
.profit-list-sku {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 6px;
  grid-column: 2;
  color: var(--text);
  font-family: inherit;
}
.profit-list-sku b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.profit-list-meta {
  display: grid;
  grid-template-columns: auto auto;
  align-items: baseline;
  gap: 1px 6px;
  grid-column: 3;
  grid-row: 1;
  text-align: right;
}
.profit-list-meta .ranking-profit { grid-column: 1 / -1; font-size: 17px; }
.profit-list-meta .ranking-average { display: none; }

@media (max-width: 1040px) {
  .ranking-grid { grid-template-columns: 1fr; }
}

@media (max-width: 720px) {
  .ranking-panel { margin-top: 14px; padding: 14px 11px 16px; }
  .ranking-panel-title { display: block; }
  .ranking-panel-title h2 { font-size: 15px; }
  .ranking-panel-title span { display: block; margin-top: 2px; }
  .ranking-grid { gap: 10px; margin-top: 11px; }
  .ranking-card-head { min-height: 58px; padding: 9px 10px; }
  .ranking-card-head > div { display: block; }
  .ranking-card-head p { margin-top: 2px; }
  .rate-chart { min-height: 510px; padding: 9px 8px 10px; overflow-x: auto; }
  .rate-ranking {
    min-width: 350px;
    grid-template-columns: 138px minmax(110px, 1fr) 82px;
    gap: 5px;
  }
  .rate-label { grid-template-columns: 14px minmax(0, 1fr); gap: 5px; font-size: 11px; }
  .rate-label b { width: 14px; flex-basis: 14px; }
  .rate-model { font-size: 11px; }
  .rate-label-meta { font-size: 9px; }
  .rate-value strong { font-size: 15px; }
  .profit-chart { min-height: 0; padding: 10px; }
  .profit-podium { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .profit-card.rank-1 { grid-column: 1 / -1; min-height: 118px; }
  .profit-card:not(.rank-1) { min-height: 132px; }
  .profit-list { grid-template-rows: repeat(7, minmax(50px, auto)); }
  .profit-list li { min-height: 50px; }
}

@media print {
  .ranking-panel { break-before: page; border: 0; }
  .ranking-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
