.tabs,
.subtabs,
.legend,
.range-controls,
.controls {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.tabs {
  justify-content: center;
  margin: 24px 0;
}

.tab,
.subtab,
.legend-item {
  border: 0.8px solid var(--line);
  border-radius: 0;
  background: var(--card);
  color: var(--ink-soft);
  cursor: pointer;
  font-family: var(--font-sans);
  font-weight: 500;
  transition: border-color 150ms ease, background-color 150ms ease, color 150ms ease;
}

.tab {
  padding: 8px 13px;
  font-size: 14px;
}

.tab.active,
.subtab.active {
  border-color: var(--line);
  background: var(--hover);
  color: var(--ink);
}

@media (hover: hover) and (pointer: fine) {
  .tab:hover,
  .subtab:hover,
  .legend-item:hover {
    background: var(--hover);
    color: var(--ink);
  }
}

.tab.restricted {
  display: inline-flex;
  align-items: center;
  color: var(--dm-muted, #9ca3af);
  background: var(--surface-soft);
  cursor: not-allowed;
  gap: 7px;
  opacity: 0.72;
}
@media (hover: hover) and (pointer: fine) {
  .tab.restricted:hover {
    display: inline-flex;
    align-items: center;
    color: var(--dm-muted, #9ca3af);
    background: var(--surface-soft);
    cursor: not-allowed;
    gap: 7px;
    opacity: 0.72;
  }
}

.tab-lock {
  font-size: 15px;
  line-height: 1;
}

.tabs-break {
  flex-basis: 100%;
  height: 0;
}

.subtabs {
  display: none;
  justify-content: center;
  margin: 0 2px 18px;
}

.subtabs.visible {
  display: flex;
}

.subtab {
  padding: 7px 10px;
  font-size: 13px;
}

.tracking-page {
  padding-top: 32px;
}

.tracking-header {
  display: block;
  max-width: 760px;
  margin: 0 auto 24px;
  padding: 0 0 28px;
  text-align: center;
}

.tracking-header h1 {
  font-size: clamp(34px, 5.4vw, 50px);
  line-height: 1.08;
}

.tracking-header .subtitle {
  max-width: 720px;
  margin-right: auto;
  margin-left: auto;
  font-size: 16px;
  line-height: 1.65;
}

#trackingPage .card {
  padding: 22px;
  border-radius: 0;
}

.chart-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  margin: 4px 2px 12px;
}

.chart-title {
  margin: 0 0 6px;
  font-family: var(--font-display);
  font-size: 27px;
  font-weight: 300;
  letter-spacing: -0.02em;
}

.chart-desc {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.5;
}

.controls {
  justify-content: flex-end;
  gap: 8px;
}

.legend {
  margin: 0 2px 14px;
}

.range-controls {
  gap: 8px;
}

.chart-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin: 2px 2px 16px;
}

.chart-toolbar .range-controls,
.chart-toolbar .controls {
  margin: 0;
}

.chart-toolbar .controls {
  margin-left: auto;
}

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  user-select: none;
  font-size: 12px;
  font-weight: 400;
}

.legend-item.off {
  opacity: 0.36;
}

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

.canvas-wrap {
  position: relative;
  height: min(84vh, 960px);
  min-height: 680px;
  overflow: hidden;
  border: 0.8px solid var(--line);
  border-radius: 0;
  background: var(--card);
}

.canvas-wrap canvas {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  cursor: crosshair;
}

.canvas-wrap .chart-overlay {
  z-index: 2;
  pointer-events: none;
}

.tooltip {
  position: absolute;
  z-index: 3;
  display: none;
  max-width: 280px;
  padding: 10px 12px;
  border-radius: 0;
  background: rgba(17, 24, 39, 0.94);
  color: #fff;
  font-size: 12px;
  line-height: 1.45;
  pointer-events: none;
}

.hint,
.data-note {
  color: var(--muted);
  font-size: 13px;
}

.hint {
  margin: 10px 2px 0;
}

.data-note {
  margin-top: 16px;
  line-height: 1.5;
}

.metrics {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  margin-top: 16px;
}

.metric-card,
.leg-card {
  padding: 16px;
  border: 0.8px solid var(--line);
  border-radius: 0;
  background: var(--card);
}

.metric-title {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
  font-weight: 600;
}

.metric-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px 12px;
  font-size: 13px;
}

.metric-label {
  color: var(--muted);
}

.metric-value {
  font-weight: 600;
  text-align: right;
}

.leg-details {
  display: none;
  margin-top: 18px;
}

.leg-details.visible {
  display: block;
}

.leg-details h3 {
  margin: 0 0 6px;
  font-size: 18px;
  letter-spacing: -0.02em;
}

.leg-details-note,
.leg-subtitle {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.leg-details-note {
  margin: 0 0 12px;
}

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

.leg-title {
  margin-bottom: 8px;
  font-weight: 600;
}

.leg-subtitle {
  margin-bottom: 10px;
}

#trackingPage button.small {
  min-height: 34px;
  padding: 6px 10px;
  border-radius: 0;
  color: var(--ink-soft);
  font-family: var(--font-sans);
  font-size: 13px;
  font-weight: 500;
  transition: background-color 150ms ease, color 150ms ease;
}

@media (hover: hover) and (pointer: fine) {
  #trackingPage button.small:hover {
    background: var(--hover);
    color: var(--ink);
  }
}

.tracking-meta {
  margin: 22px 0 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 400;
  line-height: 1.6;
  text-align: center;
  white-space: pre-line;
}
