:root {
  --blue: #1596d4;
  --blue-dark: #117db5;
  --cyan: #19b9e5;
  --purple: #963fb0;
  --yellow: #f2d84b;
  --green: #4eb36d;
  --red: #d9534f;
  --ink: #26394a;
  --muted: #73879a;
  --line: #d9e2ea;
  --panel: #fff;
  --bg: #f4f7fa;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background: var(--bg);
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}

button,
input {
  font: inherit;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: grid;
  grid-template-columns: 260px 1fr auto;
  align-items: center;
  height: 62px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.32);
  background: linear-gradient(90deg, #0788c5, #20b4dc);
  color: #fff;
  box-shadow: 0 2px 8px rgba(18, 48, 71, 0.16);
}

.brand {
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 0 24px;
}

.brand-mark,
.login-mark {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 7px;
  background: #fff;
  color: var(--blue);
  font-weight: 900;
}

.brand-name {
  font-size: 14px;
  font-weight: 800;
}

.brand-sub {
  font-size: 11px;
  opacity: 0.82;
}

.tabs {
  display: flex;
  height: 100%;
}

.tab {
  border: 0;
  border-left: 1px solid rgba(255, 255, 255, 0.14);
  padding: 0 22px;
  color: rgba(255, 255, 255, 0.86);
  background: transparent;
  cursor: pointer;
}

.tab.active,
.tab:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.12);
}

.top-actions {
  display: flex;
  gap: 10px;
  align-items: center;
  padding-right: 18px;
}

.icon-btn,
.ghost-btn,
.primary-btn,
.range-control button {
  border: 1px solid transparent;
  border-radius: 5px;
  cursor: pointer;
}

.icon-btn,
.ghost-btn {
  height: 34px;
  padding: 0 14px;
  color: #fff;
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(255, 255, 255, 0.28);
}

.shell {
  width: min(1180px, calc(100vw - 48px));
  margin: 0 auto;
  padding: 30px 0 46px;
}

.hidden {
  display: none !important;
}

.login-panel {
  display: grid;
  min-height: calc(100vh - 120px);
  place-items: center;
}

.login-card {
  width: min(420px, 100%);
  padding: 34px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 18px 42px rgba(31, 56, 76, 0.14);
}

.login-card h1 {
  margin: 20px 0 8px;
  font-size: 28px;
}

.login-card p {
  margin: 0 0 24px;
  color: var(--muted);
}

label {
  display: grid;
  gap: 8px;
  margin: 14px 0;
  font-size: 13px;
  font-weight: 700;
  color: var(--ink);
}

input {
  height: 44px;
  border: 1px solid var(--line);
  border-radius: 5px;
  padding: 0 12px;
  outline: none;
}

input:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(21, 150, 212, 0.14);
}

.primary-btn {
  width: 100%;
  height: 44px;
  margin-top: 10px;
  color: #fff;
  background: var(--blue);
  font-weight: 800;
}

.form-error {
  min-height: 20px;
  margin-top: 14px;
  color: var(--red);
  font-size: 13px;
}

.page-head {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  align-items: end;
  margin-bottom: 18px;
}

.page-head h1 {
  margin: 0;
  font-size: 22px;
}

.page-head p,
.panel header p {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.range-control {
  display: flex;
  gap: 6px;
  padding: 4px;
  background: #eaf1f6;
  border-radius: 6px;
}

.range-control button {
  min-width: 46px;
  height: 32px;
  color: var(--muted);
  background: transparent;
}

.range-control button.active {
  color: #fff;
  background: var(--blue);
}

.metric-grid {
  display: grid;
  grid-template-columns: 1.45fr 1fr 1fr 1fr;
  gap: 16px;
  margin-bottom: 16px;
}

.metric-card,
.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 4px;
  box-shadow: 0 1px 3px rgba(31, 56, 76, 0.08);
}

.metric-card {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  align-items: center;
  min-height: 108px;
  padding: 18px;
}

.metric-card.large {
  grid-template-columns: 86px repeat(3, minmax(0, 1fr));
}

.metric-card span,
.stat-row span,
.queue-grid span {
  display: block;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
}

.metric-card strong,
.stat-row strong,
.queue-grid strong {
  display: block;
  margin-top: 5px;
  font-size: 22px;
}

.metric-card small {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}

.metric-card small.up {
  color: var(--green);
}

.metric-card small.down {
  color: var(--red);
}

.metric-ring {
  display: grid;
  place-items: center;
  width: 74px;
  height: 74px;
  border-radius: 50%;
  background: conic-gradient(var(--blue) 0deg, var(--blue) 250deg, #e8edf2 250deg);
  color: var(--blue-dark);
  font-size: 18px;
  font-weight: 800;
}

.metric-ring::before {
  content: "";
  position: absolute;
}

.metric-ring.blue {
  background: conic-gradient(var(--cyan) 0deg, var(--cyan) 360deg, #e8edf2 0deg);
}

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

.span-2 {
  grid-column: span 2;
}

.panel {
  min-height: 260px;
  padding: 18px;
}

.panel header {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: start;
  margin-bottom: 14px;
}

.panel h2 {
  margin: 0;
  font-size: 15px;
}

.pill {
  display: inline-flex;
  align-items: center;
  height: 25px;
  padding: 0 10px;
  border-radius: 999px;
  color: var(--blue-dark);
  background: #eaf7fd;
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.stat-row,
.queue-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  padding: 12px 0 14px;
  border-bottom: 1px solid var(--line);
}

.rank-list {
  margin: 12px 0 0;
  padding-left: 20px;
}

.rank-list li,
.table-row,
.athlete-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 14px;
  align-items: center;
  padding: 9px 0;
  border-bottom: 1px solid #eef3f7;
  font-size: 13px;
}

.rank-list li span,
.table-row span,
.athlete-row span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.rank-list li strong,
.table-row strong,
.athlete-row strong {
  color: var(--ink);
  font-size: 13px;
}

canvas {
  width: 100%;
  max-width: 100%;
}

.legend {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px 14px;
  margin-top: 8px;
  font-size: 12px;
  color: var(--muted);
}

.legend-item {
  display: flex;
  gap: 7px;
  align-items: center;
  min-width: 0;
}

.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex: 0 0 auto;
}

.bar-list {
  display: grid;
  gap: 12px;
}

.bar-item {
  display: grid;
  gap: 5px;
}

.bar-top {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-size: 13px;
}

.bar-track {
  height: 7px;
  border-radius: 99px;
  background: #e8edf2;
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  border-radius: inherit;
  background: var(--blue);
}

.queue-grid {
  border-bottom: 0;
}

.queue-grid div {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: #fbfdff;
}

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

.athlete-row {
  grid-template-columns: 34px 1fr auto;
}

.avatar {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  color: #fff;
  background: var(--blue);
  font-size: 12px;
  font-weight: 800;
}

.empty {
  color: var(--muted);
  font-size: 13px;
}

@media (max-width: 980px) {
  .topbar {
    grid-template-columns: 1fr auto;
    height: auto;
    min-height: 62px;
  }

  .tabs {
    grid-column: 1 / -1;
    overflow-x: auto;
    border-top: 1px solid rgba(255, 255, 255, 0.18);
  }

  .metric-grid,
  .grid-3 {
    grid-template-columns: 1fr;
  }

  .metric-card.large,
  .metric-card,
  .athlete-list {
    grid-template-columns: 1fr;
  }

  .span-2 {
    grid-column: auto;
  }
}

@media (max-width: 640px) {
  .shell {
    width: min(100vw - 24px, 1180px);
    padding-top: 16px;
  }

  .brand {
    padding: 0 14px;
  }

  .page-head {
    align-items: stretch;
    flex-direction: column;
  }

  .range-control {
    justify-content: space-between;
  }
}
