/* ---------- Dashboard layout ---------- */

.dashboard {
  position: relative;
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) clamp(292px, 23vw, 360px);
  gap: clamp(10px, 1vw, 16px);
  align-items: stretch;
}

.leader-overlay {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 8;
}

.panel {
  position: relative;
  z-index: 1;
  min-width: 0;
  border-radius: var(--radius);
  border: 1px solid var(--panel-border);
  background:
    linear-gradient(180deg, rgba(18, 28, 44, 0.72), rgba(9, 15, 25, 0.86)),
    radial-gradient(700px 240px at 12% 0%, rgba(255, 77, 79, 0.05), transparent 70%);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
}

.chart-panel {
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}

.panel-head {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 16px 10px;
  flex-wrap: wrap;
}

.chart-title {
  display: flex;
  align-items: center;
  gap: 9px;
  min-width: 0;
}

.chart-title h2 {
  margin: 0;
  font-size: 14.5px;
  font-weight: 600;
  letter-spacing: 0.3px;
  white-space: nowrap;
}

.chart-title .unit {
  color: var(--dim);
  font-size: 10.5px;
  letter-spacing: 0.4px;
  white-space: nowrap;
}

.live-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--dim);
  flex: 0 0 auto;
}

.live-dot.is-live {
  background: var(--red);
  box-shadow: 0 0 10px rgba(255, 77, 79, 0.8);
  animation: pulse 1.8s infinite;
}

.legend {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--muted);
  font-size: 11px;
  margin-left: auto;
}

.legend span {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.swatch {
  width: 14px;
  height: 3px;
  border-radius: 2px;
  display: inline-block;
}

.swatch-in {
  background: var(--red);
  box-shadow: 0 0 8px rgba(255, 77, 79, 0.55);
}

.swatch-out {
  background: var(--green);
  box-shadow: 0 0 8px rgba(22, 199, 132, 0.5);
}

.chart-tools {
  display: flex;
  align-items: center;
  gap: 8px;
}

.chart-wrap {
  position: relative;
  flex: 1;
  min-height: 0;
  margin: 0 6px 4px;
  border-radius: 13px;
  overflow: hidden;
}

.chart-wrap canvas {
  display: block;
  width: 100%;
  height: 100%;
}

/* ---------- Rank panel ---------- */

.rank-panel {
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}

.rank-head {
  justify-content: space-between;
  align-items: flex-start;
  padding-bottom: 8px;
}

.rank-head h2 {
  margin: 0;
  font-size: 14.5px;
  font-weight: 600;
  letter-spacing: 0.3px;
}

.rank-hint {
  margin: 4px 0 0;
  color: var(--dim);
  font-size: 10.5px;
  letter-spacing: 0.3px;
}

.rank-total {
  color: var(--muted);
  font-size: 11px;
  padding: 4px 8px;
  border-radius: 999px;
  background: rgba(148, 163, 184, 0.06);
  border: 1px solid var(--panel-border);
  white-space: nowrap;
}

.rank-list {
  position: relative;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 2px 6px 6px;
  scrollbar-width: thin;
  scrollbar-color: rgba(148, 163, 184, 0.24) transparent;
}

.rank-list::-webkit-scrollbar {
  width: 6px;
}

.rank-list::-webkit-scrollbar-thumb {
  background: rgba(148, 163, 184, 0.22);
  border-radius: 3px;
}

.rank-track {
  position: relative;
  width: 100%;
}

.rank-row {
  position: absolute;
  left: 0;
  right: 0;
  height: var(--row-h);
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 8px;
  border-radius: 8px;
  cursor: pointer;
  transition:
    transform 240ms cubic-bezier(0.2, 0.8, 0.2, 1),
    background-color 0.16s,
    opacity 0.2s;
  will-change: transform;
  contain: layout style;
}

.rank-row::before {
  content: "";
  position: absolute;
  left: 0;
  top: 5px;
  bottom: 5px;
  width: calc(var(--bar, 0) * 100%);
  border-radius: 6px;
  background: var(--row-color, var(--muted));
  opacity: 0.06;
  pointer-events: none;
}

.rank-row:hover,
.rank-row.is-hovered {
  background: rgba(148, 163, 184, 0.09);
}

.rank-row.is-selected {
  background: rgba(240, 195, 109, 0.1);
  box-shadow: inset 0 0 0 1px rgba(240, 195, 109, 0.28);
}

.rank-row.is-first-out {
  border-top: 1px dashed rgba(148, 163, 184, 0.18);
  border-top-left-radius: 0;
  border-top-right-radius: 0;
}

.rank-row.is-dim {
  opacity: 0.42;
}

.rank-no {
  position: relative;
  z-index: 1;
  width: 22px;
  flex: 0 0 22px;
  text-align: right;
  color: var(--dim);
  font-family: var(--font-mono);
  font-size: 10px;
}

.rank-swatch {
  position: relative;
  z-index: 1;
  width: 5px;
  height: 5px;
  flex: 0 0 5px;
  border-radius: 50%;
  background: var(--row-color);
  box-shadow: 0 0 8px var(--row-color);
}

.rank-name {
  position: relative;
  z-index: 1;
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text-soft);
  font-size: 12.5px;
}

.rank-row.is-highlight .rank-name {
  color: var(--text);
  font-weight: 550;
}

.rank-value {
  position: relative;
  z-index: 1;
  flex: 0 0 auto;
  color: var(--row-color);
  font-family: var(--font-mono);
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: -0.2px;
}

.rank-foot {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 9px 10px 11px;
  border-top: 1px solid var(--panel-border);
  color: var(--dim);
  font-size: 10px;
  letter-spacing: 0.3px;
}

/* ---------- Replay bar ---------- */

.replay-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 14px 12px;
  border-top: 1px solid var(--panel-border);
  background: rgba(5, 9, 15, 0.36);
}

.replay-bar[hidden] {
  display: none;
}

.play-btn {
  width: 34px;
  height: 34px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  border-radius: 50%;
  border: 1px solid rgba(240, 195, 109, 0.4);
  background: linear-gradient(145deg, rgba(240, 195, 109, 0.22), rgba(232, 137, 74, 0.12));
  color: #ffe3b0;
  transition: transform 0.15s, background 0.15s;
}

.play-btn:hover {
  background: linear-gradient(145deg, rgba(240, 195, 109, 0.34), rgba(232, 137, 74, 0.18));
}

.play-btn:active {
  transform: scale(0.96);
}

.play-btn svg {
  width: 17px;
  height: 17px;
}

.play-btn .icon-pause {
  display: none;
}

.play-btn.is-playing .icon-play {
  display: none;
}

.play-btn.is-playing .icon-pause {
  display: block;
}

.replay-time,
.replay-end {
  color: var(--text-soft);
  font-family: var(--font-mono);
  font-size: 11px;
  flex: 0 0 auto;
}

.replay-end {
  color: var(--dim);
}

#replay-slider {
  appearance: none;
  -webkit-appearance: none;
  flex: 1;
  min-width: 60px;
  height: 4px;
  border-radius: 2px;
  background: linear-gradient(90deg, rgba(240, 195, 109, 0.65), rgba(148, 163, 184, 0.18));
  outline: none;
}

#replay-slider::-webkit-slider-thumb {
  appearance: none;
  -webkit-appearance: none;
  width: 13px;
  height: 13px;
  border-radius: 50%;
  background: #ffe3b0;
  border: 2px solid #0b111b;
  box-shadow: 0 0 10px rgba(240, 195, 109, 0.5);
  cursor: pointer;
}

#replay-slider::-moz-range-thumb {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #ffe3b0;
  border: 2px solid #0b111b;
  box-shadow: 0 0 10px rgba(240, 195, 109, 0.5);
  cursor: pointer;
}

.speed-wrap select {
  padding: 6px 25px 6px 9px;
  font-size: 11px;
}

