body {
  margin: 0;
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: linear-gradient(180deg, #f4f6fb 0%, #eef2ff 100%);
  color: #132238;
  overflow-x: hidden;
  overflow-y: auto;
}

* {
  box-sizing: border-box;
}

.page-shell {
  max-width: 1600px;
  margin: 0 auto;
  padding: 12px 16px 10px;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.card {
  background: #ffffff;
  border: 1px solid #e3e8f0;
  border-radius: 18px;
  padding: 14px 16px;
  box-shadow: 0 12px 32px rgba(15, 23, 42, 0.06);
  margin-bottom: 10px;
}

.hero-card {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  flex-wrap: wrap;
}

.eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.18em;
  font-size: 0.72rem;
  font-weight: 700;
  color: #4f46e5;
  margin: 0 0 6px;
}

h1, h2 {
  margin: 0;
}

h1 {
  font-size: 1.8rem;
}

h2 {
  font-size: 1.2rem;
}

.subtext {
  margin: 6px 0 0;
  color: #64748b;
}

.hero-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: flex-end;
}

.hero-controls {
  display: flex;
  flex-direction: column;
  gap: 10px;
  align-items: flex-end;
}

.hero-meta {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.hero-meta-left {
  justify-content: flex-start;
}

.btn {
  border: 1px solid #cbd5e1;
  background: #ffffff;
  color: #132238;
  border-radius: 999px;
  padding: 9px 14px;
  cursor: pointer;
  font-size: 0.95rem;
  text-decoration: none;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
}

.btn:hover:not(:disabled) {
  background: #f8fafc;
}

.btn:disabled {
  opacity: 0.65;
  cursor: not-allowed;
}

.btn-scorecard {
  padding-inline: 16px;
  font-weight: 600;
}

.btn-refresh {
  min-width: 98px;
}

.error-card {
  border-color: #fda4af;
  background: #fff1f2;
  color: #9f1239;
}

.control-row {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  align-items: flex-end;
}

label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 0.92rem;
  color: #334155;
}

select {
  border: 1px solid #cbd5e1;
  border-radius: 10px;
  padding: 8px 10px;
  min-width: 180px;
  background: #fff;
}

.checkbox-row {
  flex-direction: row;
  align-items: center;
  gap: 8px;
  padding-top: 2px;
}

.stats-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 14px;
}

.stat-pill {
  background: #eef2ff;
  color: #4338ca;
  border-radius: 999px;
  padding: 6px 10px;
  font-size: 0.84rem;
}

.section-heading {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}

.scoreboard-card {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  position: relative;
  overflow: hidden;
}

.refresh-progress {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: rgba(59, 130, 246, 0.12);
  overflow: hidden;
  border-radius: 18px 18px 0 0;
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.35) inset;
}

.refresh-progress span {
  display: block;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, rgba(59, 130, 246, 0.15), #3b82f6 50%, rgba(59, 130, 246, 0.15));
  transform-origin: left center;
  animation-name: refreshSweep;
  animation-timing-function: linear;
  animation-fill-mode: forwards;
}

@keyframes refreshSweep {
  from {
    transform: scaleX(0);
  }
  to {
    transform: scaleX(1);
  }
}

.control-pill {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 0.84rem;
}

.control-pill select {
  min-width: 150px;
}

.scoreboard-meta {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.group-meta {
  display: block;
  margin-top: 2px;
  color: #64748b;
}

.group-summary-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.group-grid {
  display: grid;
  gap: 14px;
}

.pager-shell {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.pager-meta {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.pager-text {
  color: #475569;
  font-size: 0.7rem;
  font-weight: 600;
}

.group-card {
  border: 1px solid #e2e8f0;
  border-radius: 16px;
  padding: 12px;
  background: #fbfdff;
}

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

.group-card-header h3,
.gender-column-header h4 {
  margin: 0;
}

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

.gender-column {
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  padding: 10px;
  background: #ffffff;
}

.gender-column-header {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  align-items: baseline;
  margin-bottom: 10px;
}

.competitor-list {
  display: grid;
  gap: 8px;
}

.competitor-row {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  padding: 8px 10px;
  border-radius: 10px;
  background: #f8fafc;
}

.competitor-rank {
  font-weight: 700;
  color: #4338ca;
}

.competitor-name {
  font-weight: 600;
}

.competitor-subtext {
  color: #64748b;
  font-size: 0.85rem;
}

.competitor-stats {
  display: flex;
  gap: 10px;
  color: #334155;
  font-weight: 600;
}

.more-indicator {
  color: #64748b;
  font-size: 0.84rem;
  padding-top: 2px;
}

.scorecard-item {
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  padding: 10px;
}

.scorecard-item-header {
  font-size: 1rem;
  font-weight: 700;
  margin-bottom: 8px;
}

.scorecard-item-body {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  font-size: 0.9rem;
}

.scorecard-loading {
  color: #64748b;
  padding: 12px 0;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.95rem;
}

th, td {
  padding: 10px 12px;
  border-bottom: 1px solid #e2e8f0;
  text-align: left;
  font-size: 1rem;
}

th {
  color: #475569;
  background: #f8fafc;
}

tbody tr:hover {
  background: #f8fafc;
}

.empty-state {
  text-align: center;
  color: #64748b;
  padding: 18px;
}

.print-sheet {
  background: #fff;
}

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

.print-subheader {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.print-label {
  font-size: 0.76rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #64748b;
  margin-bottom: 4px;
}

.print-line {
  border-bottom: 1px solid #0f172a;
  height: 18px;
}

.print-line .print-value {
  line-height: 1;
}

.print-value {
  display: block;
  font-size: 1rem;
  font-weight: 600;
  padding-top: 1px;
}

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

.gender-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.gender-table th,
.gender-table td {
  padding: 8px 8px;
  border-bottom: 1px solid #e2e8f0;
  text-align: left;
}

.gender-table th {
  color: #475569;
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.gender-table tbody tr:last-child td {
  border-bottom: 0;
}

.print-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.78rem;
}

.print-table th,
.print-table td {
  border: 1px solid #1f2937;
  padding: 5px 6px;
}

.print-table th {
  background: #f8fafc;
}

.signature-cell {
  min-width: 90px;
}

@media print {
  body {
    background: white;
    overflow: visible;
  }

  .page-shell {
    padding: 0;
    max-width: none;
  }

  .card, .btn {
    box-shadow: none;
    border: 0;
  }

  .no-print {
    display: none !important;
  }

  .print-sheet {
    border: 0;
    padding: 0;
  }

  @page {
    size: letter landscape;
    margin: 0.4in;
  }
}

@media (max-width: 700px) {
  .page-shell {
    padding: 12px;
  }

  .card {
    padding: 16px;
  }

  .hero-card {
    flex-direction: column;
  }

  .hero-controls,
  .hero-actions,
  .hero-meta,
  .scoreboard-meta,
  .pager-meta {
    width: 100%;
  }

  .hero-actions,
  .scoreboard-meta,
  .group-card-header,
  .gender-columns {
    display: flex;
    flex-direction: column;
    align-items: stretch;
  }

  .hero-meta,
  .hero-meta-left {
    justify-content: flex-start;
  }

  .competitor-row {
    grid-template-columns: 28px minmax(0, 1fr);
  }

  .competitor-stats {
    grid-column: 1 / -1;
    justify-content: space-between;
  }
}
