* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: #071d49;
  color: #ffffff;
  font-family: Arial, Helvetica, sans-serif;
}

.page-actions {
  position: fixed;
  top: calc(env(safe-area-inset-top, 0px) + 10px);
  right: 10px;
  z-index: 50;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
  max-width: calc(100vw - 20px);
}

.page-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 36px;
  padding: 8px 11px;
  border: 2px solid rgba(255, 255, 255, 0.9);
  border-radius: 6px;
  background: rgba(7, 29, 73, 0.94);
  color: #fff;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.32);
  font-size: 11px;
  font-weight: 900;
  line-height: 1;
  text-decoration: none;
  text-transform: uppercase;
  white-space: nowrap;
}

.page-action:hover,
.page-action:focus-visible {
  color: #071d49;
  background: #f2d34b;
  outline: none;
}

.analytics-shell {
  width: min(1180px, calc(100vw - 28px));
  margin: 0 auto;
  padding: 58px 0 28px;
}

.topbar,
.race-card,
.controls,
.chart-card,
.table-card {
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.08);
  box-shadow: 0 14px 34px rgba(0, 0, 0, 0.22);
}

.topbar {
  display: grid;
  grid-template-columns: 160px 1fr 160px;
  gap: 16px;
  align-items: center;
  padding: 14px 16px;
}

.topbar span,
.race-card span,
.controls label {
  display: block;
  color: rgba(255, 255, 255, 0.72);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

.analytics-brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.analytics-brand img {
  display: block;
  width: min(260px, 48vw);
  height: auto;
  max-height: 54px;
  object-fit: contain;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: clamp(24px, 4vw, 42px);
  line-height: 1;
}

.topbar p {
  color: rgba(255, 255, 255, 0.72);
  font-size: 12px;
  text-align: right;
}

.race-card {
  display: grid;
  grid-template-columns: 1fr 1fr 160px;
  gap: 12px;
  margin-top: 12px;
  padding: 12px 16px;
}

.race-card strong {
  display: block;
  margin-top: 3px;
  font-size: 17px;
}

.controls {
  display: grid;
  grid-template-columns: 1.1fr 1fr 1fr 1fr;
  gap: 12px;
  margin-top: 12px;
  padding: 12px;
}

select {
  width: 100%;
  margin-top: 5px;
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: 6px;
  background: #ffffff;
  color: #071d49;
  font: inherit;
  font-size: 13px;
  font-weight: 700;
}

.chart-card {
  margin-top: 12px;
  padding: 14px;
}

.chart-head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: baseline;
  margin-bottom: 10px;
}

.chart-head h2 {
  font-size: 20px;
}

.chart-head p {
  color: rgba(255, 255, 255, 0.72);
  font-size: 12px;
}

.chart {
  min-height: 420px;
}

.chart svg {
  display: block;
  width: 100%;
  height: 420px;
  overflow: visible;
}

.axis,
.grid {
  stroke: rgba(255, 255, 255, 0.22);
  stroke-width: 1;
}

.grid {
  stroke-dasharray: 4 6;
}

.series {
  fill: none;
  stroke-width: 3;
}

.series.global {
  stroke-dasharray: 7 6;
}

.point {
  stroke: #071d49;
  stroke-width: 2;
}

.label {
  fill: rgba(255, 255, 255, 0.8);
  font-size: 11px;
  font-weight: 800;
}

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
  margin-top: 8px;
  font-size: 12px;
  font-weight: 800;
}

.legend span::before {
  content: "";
  display: inline-block;
  width: 18px;
  height: 4px;
  margin-right: 6px;
  vertical-align: middle;
  background: var(--c);
}

.regularity-chart {
  display: grid;
  gap: 6px;
  max-height: min(68vh, 860px);
  overflow-y: auto;
  padding-right: 4px;
}

.regularity-row {
  display: grid;
  grid-template-columns: 42px minmax(170px, 0.8fr) minmax(220px, 1fr) 86px;
  gap: 10px;
  align-items: center;
  min-height: 34px;
  padding: 5px 8px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.08);
}

.regularity-rank,
.regularity-value,
.regularity-id strong {
  font-weight: 950;
}

.regularity-rank {
  color: #bfe9ff;
  text-align: center;
}

.regularity-id {
  display: flex;
  align-items: baseline;
  gap: 9px;
  min-width: 0;
}

.regularity-id strong {
  color: #ffea00;
}

.regularity-id span {
  min-width: 0;
  overflow: hidden;
  color: rgba(255, 255, 255, 0.9);
  font-size: 12px;
  font-weight: 800;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.regularity-track {
  height: 13px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.14);
}

.regularity-track i {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #ffea00, #ff9f1c, #ff4d6d);
}

.regularity-value {
  color: #ffffff;
  font-size: 13px;
  text-align: right;
}

.table-card {
  margin-top: 12px;
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  padding: 9px 10px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.13);
  font-size: 13px;
  text-align: left;
}

th {
  color: rgba(255, 255, 255, 0.74);
  font-size: 11px;
  text-transform: uppercase;
}

td.num {
  color: #ffea00;
  font-weight: 900;
}

@media (max-width: 760px) {
  .page-actions {
    right: 8px;
    gap: 4px;
  }

  .page-action {
    min-height: 34px;
    padding: 7px 8px;
    border-width: 1px;
    font-size: 9px;
  }

  .analytics-shell {
    width: 100%;
    padding: 54px 8px 20px;
  }

  .topbar,
  .race-card,
  .controls {
    grid-template-columns: 1fr;
  }

  .topbar p {
    text-align: left;
  }

  .chart {
    min-height: 340px;
  }

  .chart svg {
    height: 340px;
  }

  .regularity-chart {
    max-height: 62vh;
  }

  .regularity-row {
    grid-template-columns: 30px minmax(95px, 0.9fr) minmax(90px, 1fr) 70px;
    gap: 6px;
    padding: 5px 6px;
  }

  .regularity-id {
    gap: 6px;
  }

  .regularity-id span {
    font-size: 11px;
  }

  .regularity-value {
    font-size: 11px;
  }
}
