*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body,
#root {
  min-height: 100%;
}

body {
  margin: 0;
  font-family: var(--font-family-base);
  font-size: var(--font-size-body);
  line-height: var(--line-height-base);
  background: var(--color-bg);
  color: var(--color-text);
}

a {
  color: inherit;
  text-decoration: none;
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-rows: auto 1fr auto;
}

.app-shell__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  padding: var(--space-4) var(--space-6);
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
}

.app-shell__brand {
  font-size: var(--font-size-h2);
  font-weight: 700;
}

.app-shell__nav {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.app-shell__link {
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-sm);
  color: var(--color-text-muted);
}

.app-shell__link:hover,
.app-shell__link:focus-visible {
  color: var(--color-text);
  background: #eef2f6;
  outline: none;
}

.app-shell__link--active,
.app-shell__link--active:hover,
.app-shell__link--active:focus-visible {
  color: var(--color-surface);
  background: var(--color-accent);
}

.app-shell__main {
  width: min(1080px, 100%);
  margin: 0 auto;
  padding: var(--space-6);
}

.app-shell__footer {
  margin-top: auto;
  padding: var(--space-3) var(--space-6);
  border-top: 1px solid var(--color-border);
  background: var(--color-surface);
}

.app-shell__footer-versions {
  margin: 0;
  text-align: center;
  font-size: var(--font-size-caption);
  color: var(--color-text-muted);
}

.app-shell__footer-sep {
  user-select: none;
}

.page {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: var(--space-6);
}

.page__title {
  margin: 0 0 var(--space-2);
  font-size: var(--font-size-h1);
}

.page__subtitle {
  margin: 0;
  color: var(--color-text-muted);
}

.page__subtitle--error {
  color: var(--color-error);
}

.dashboard-grid {
  margin-top: var(--space-6);
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-4);
}

.dashboard-card {
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: var(--space-5);
  background: #fcfdff;
  transition:
    transform 0.15s ease,
    box-shadow 0.15s ease;
}

.dashboard-card:hover,
.dashboard-card:focus-within {
  transform: scale(1.02);
  box-shadow: var(--shadow-card-lift);
}

.dashboard-card--linked {
  padding: 0;
}

.dashboard-card__link-surface {
  display: flex;
  flex-direction: column;
  height: 100%;
  padding: var(--space-5);
  border-radius: var(--radius-md);
  color: inherit;
  text-decoration: none;
  outline: none;
}

.dashboard-card__link-surface:hover,
.dashboard-card__link-surface:focus-visible {
  outline: none;
}

.dashboard-card__title {
  margin: 0 0 var(--space-3);
  font-size: var(--font-size-body);
  color: var(--color-text-muted);
}

.dashboard-card__value {
  margin: 0;
  font-size: var(--font-size-h2);
  font-weight: 700;
  color: var(--color-text);
}

.dashboard-card__meta {
  margin: var(--space-2) 0 0;
  color: var(--color-text);
}

.dashboard-card__hint,
.dashboard-card__empty {
  margin: var(--space-2) 0 0;
  color: var(--color-text-muted);
  font-size: var(--font-size-caption);
}

.dashboard-section {
  margin-top: var(--space-6);
}

.dashboard-section__title {
  margin: 0 0 var(--space-4);
  font-size: var(--font-size-h2);
}

.dashboard-section__intro {
  margin: calc(var(--space-2) * -1) 0 var(--space-4);
  max-width: 42rem;
  color: var(--color-text-muted);
  font-size: var(--font-size-caption);
  line-height: 1.5;
}

.dashboard-grid--pr {
  margin-top: 0;
}

.comparison-table-wrapper {
  overflow-x: auto;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: #fcfdff;
}

.comparison-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 720px;
}

.comparison-table th,
.comparison-table td {
  padding: var(--space-3);
  text-align: left;
  border-bottom: 1px solid var(--color-border);
}

.comparison-table th {
  color: var(--color-text-muted);
  font-size: var(--font-size-caption);
  font-weight: 600;
}

.comparison-table tbody tr:last-child td {
  border-bottom: none;
}

.race-lists {
  margin-top: var(--space-6);
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-4);
}

.race-list {
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: var(--space-5);
  background: #fcfdff;
}

.race-list__title {
  margin: 0 0 var(--space-4);
  font-size: var(--font-size-h2);
}

.race-list__items {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: var(--space-3);
}

.race-list__empty {
  margin: 0;
  color: var(--color-text-muted);
}

.race-card {
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: var(--space-3);
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-3);
  background: var(--color-surface);
}

.race-card__title {
  margin: 0;
  font-weight: 600;
}

.race-card__meta {
  margin: var(--space-2) 0 0;
  color: var(--color-text-muted);
  font-size: var(--font-size-caption);
}

.race-card__status {
  display: inline-flex;
  align-items: center;
  white-space: nowrap;
  border-radius: 999px;
  padding: 0.2rem 0.5rem;
  font-size: var(--font-size-caption);
  font-weight: 600;
}

.race-card__status--planned {
  background: #edf3ff;
  color: var(--color-accent);
}

.race-card__status--completed {
  background: #ecf8f1;
  color: var(--color-success);
}

.race-card__status--registered {
  background: #fff4e0;
  color: #8a5a00;
}

.race-card__status--needs-result {
  outline: 1px solid var(--color-warning);
}

.race-card--action {
  padding: 0;
  overflow: visible;
  transition:
    transform 0.15s ease,
    box-shadow 0.15s ease;
}

.race-card--action:hover,
.race-card--action:focus-within {
  transform: scale(1.02);
  box-shadow: var(--shadow-card-lift);
}

.race-card__link-surface {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-3);
  width: 100%;
  padding: var(--space-3);
  border-radius: var(--radius-sm);
  color: inherit;
  text-decoration: none;
  outline: none;
}

.race-card__link-surface:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
}

.race-card__title-text {
  font-weight: 600;
}

.race-details-past-hint {
  margin: 0 0 var(--space-4);
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-md);
  border: 1px solid var(--color-warning);
  background: #fffaf0;
  color: var(--color-text);
  font-size: var(--font-size-caption);
}

.race-details-past-hint__link {
  color: var(--color-accent);
  font-weight: 600;
  text-decoration: underline;
}

.race-details-past-hint__link:hover,
.race-details-past-hint__link:focus-visible {
  outline: none;
}

.races-filter {
  margin-top: var(--space-5);
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-4);
  align-items: flex-end;
}

.races-filter__field {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  min-width: 10rem;
}

.races-filter__label {
  font-size: var(--font-size-caption);
  font-weight: 600;
  color: var(--color-text-muted);
}

.races-filter__select {
  font: inherit;
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-sm);
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  color: var(--color-text);
}

.pace-chart {
  margin-top: var(--space-4);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: var(--space-4);
  background: #fcfdff;
}

.pace-chart__svg {
  display: block;
  width: 100%;
  max-width: 560px;
  height: auto;
}

.pace-chart__line {
  stroke: var(--color-accent);
  stroke-width: 1.5;
  vector-effect: non-scaling-stroke;
}

.pace-chart__caption {
  margin: var(--space-3) 0 0;
  font-size: var(--font-size-caption);
  color: var(--color-text-muted);
}

.pace-chart__empty {
  margin: var(--space-2) 0 0;
  color: var(--color-text-muted);
  font-size: var(--font-size-body);
}

.page-link {
  margin-top: var(--space-4);
  display: inline-flex;
  color: var(--color-accent);
  font-weight: 600;
}

.page-link:hover,
.page-link:focus-visible {
  text-decoration: underline;
  outline: none;
}

.race-details-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-4);
}

.race-details-grid {
  margin-top: var(--space-6);
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-4);
}

.race-details-card {
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: var(--space-5);
  background: #fcfdff;
}

.race-details-card--notes {
  margin-top: var(--space-4);
}

.race-details-card__title {
  margin: 0 0 var(--space-3);
  font-size: var(--font-size-body);
  color: var(--color-text-muted);
}

.race-details-card__empty,
.race-details-card__notes {
  margin: 0;
  color: var(--color-text-muted);
}

.race-details-meta {
  margin: 0;
  display: grid;
  gap: var(--space-3);
}

.race-details-meta__item {
  display: grid;
  gap: var(--space-1);
}

.race-details-meta__key {
  color: var(--color-text-muted);
  font-size: var(--font-size-caption);
}

.race-details-meta__value {
  margin: 0;
  font-weight: 600;
  color: var(--color-text);
}

/* ─── Buttons ──────────────────────────────────────────── */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-2) var(--space-4);
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  font: inherit;
  font-weight: 600;
  font-size: var(--font-size-caption);
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
  transition: background 0.15s, color 0.15s;
}

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

.btn--primary {
  background: var(--color-accent);
  color: var(--color-surface);
}

.btn--primary:hover:not(:disabled) {
  background: #1766be;
}

.btn--secondary {
  background: var(--color-surface);
  color: var(--color-text);
  border-color: var(--color-border);
}

.btn--secondary:hover:not(:disabled) {
  background: #eef2f6;
}

.btn--danger {
  background: var(--color-error);
  color: var(--color-surface);
}

.btn--danger:hover:not(:disabled) {
  background: #a82e2e;
}

/* ─── Confirm banner ───────────────────────────────────── */

.confirm-banner {
  margin-top: var(--space-4);
  padding: var(--space-4);
  border: 1px solid var(--color-error);
  border-radius: var(--radius-md);
  background: #fef2f2;
}

.confirm-banner__text {
  margin: 0 0 var(--space-3);
  font-weight: 600;
  color: var(--color-error);
}

.confirm-banner__actions {
  display: flex;
  gap: var(--space-3);
}

/* ─── Race details actions ─────────────────────────────── */

.race-details-actions {
  margin-top: var(--space-4);
  display: flex;
  gap: var(--space-3);
}

.race-details-meta__link {
  color: var(--color-accent);
  word-break: break-all;
}

.race-details-meta__link:hover {
  text-decoration: underline;
}

.race-details-hero {
  position: relative;
  min-height: 21rem;
  display: flex;
  align-items: flex-end;
  overflow: hidden;
  margin: calc(var(--space-6) * -1) calc(var(--space-6) * -1) var(--space-6);
  padding: var(--space-8);
  border-radius: var(--radius-md) var(--radius-md) 0 0;
  background: var(--color-bg-deep);
  box-shadow: var(--shadow-hero);
}

.race-details-hero__image,
.race-details-hero__shade {
  position: absolute;
  inset: 0;
}

.race-details-hero__image {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.race-details-hero__image--contain {
  padding: var(--space-5);
  object-fit: contain;
  background:
    radial-gradient(circle at 20% 10%, rgba(185, 242, 74, 0.22), transparent 18rem),
    linear-gradient(135deg, rgba(17, 104, 216, 0.38), rgba(7, 25, 39, 0.96)),
    var(--color-bg-deep);
}

.race-details-hero__shade {
  background:
    linear-gradient(90deg, rgba(7, 25, 39, 0.92), rgba(7, 25, 39, 0.58) 48%, rgba(7, 25, 39, 0.18)),
    linear-gradient(0deg, rgba(7, 25, 39, 0.72), transparent 58%);
}

.race-details-hero__content {
  position: relative;
  z-index: 1;
  width: min(42rem, 100%);
}

.race-details-hero__back {
  display: inline-flex;
  width: fit-content;
  margin-bottom: var(--space-5);
  color: rgba(255, 255, 255, 0.84);
  font-size: var(--font-size-caption);
  font-weight: 800;
}

.race-details-hero__back:hover,
.race-details-hero__back:focus-visible {
  color: #ffffff;
  text-decoration: underline;
  outline: none;
}

.race-details-hero__eyebrow {
  margin: 0 0 var(--space-2);
  color: var(--color-lime);
  font-size: var(--font-size-caption);
  font-weight: 900;
  letter-spacing: 0;
  text-transform: uppercase;
}

.race-details-hero .page__title {
  max-width: 38rem;
  color: #ffffff;
}

.race-details-hero .page__subtitle {
  color: rgba(255, 255, 255, 0.78);
}

.race-details-hero .race-card__status {
  width: fit-content;
  margin-top: var(--space-4);
  box-shadow: 0 12px 24px rgba(7, 25, 39, 0.18);
}

/* ─── Race form ────────────────────────────────────────── */

.race-form {
  margin-top: var(--space-6);
}

.race-form__group {
  margin: 0 0 var(--space-6);
  padding: var(--space-5);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: #fcfdff;
}

.race-form__legend {
  font-size: var(--font-size-body);
  font-weight: 700;
  color: var(--color-text);
  padding: 0 var(--space-2);
}

.race-form__field {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  margin-top: var(--space-4);
}

.race-form__field:first-of-type {
  margin-top: var(--space-3);
}

.race-form__label {
  font-size: var(--font-size-caption);
  font-weight: 600;
  color: var(--color-text-muted);
}

.race-form__input {
  font: inherit;
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-sm);
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  color: var(--color-text);
}

.race-form__input:focus {
  outline: 2px solid var(--color-accent);
  outline-offset: -1px;
  border-color: var(--color-accent);
}

.race-form__input--textarea {
  resize: vertical;
  min-height: 5rem;
}

.race-form__time-picker {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: var(--space-2);
}

.race-form__time-picker__unit {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}

.race-form__time-picker__label {
  font-size: var(--font-size-caption);
  font-weight: 600;
  color: var(--color-text-muted);
}

.race-form__time-picker__select {
  min-width: 4.25rem;
}

.race-form__time-picker__sep {
  color: var(--color-text-muted);
  font-weight: 600;
  padding-bottom: var(--space-2);
}

.date-picker {
  position: relative;
  width: min(100%, 22rem);
}

.date-picker__control {
  display: flex;
  align-items: stretch;
}

.date-picker__input {
  min-width: 0;
  border-top-right-radius: 0;
  border-bottom-right-radius: 0;
}

.date-picker__toggle {
  width: 3rem;
  border: 1px solid var(--color-border);
  border-left: none;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  background: var(--color-bg-deep);
  color: #ffffff;
  font: inherit;
  font-weight: 900;
  cursor: pointer;
}

.date-picker__toggle:hover,
.date-picker__toggle:focus-visible {
  background: var(--color-accent-strong);
  outline: none;
}

.date-picker__popover {
  position: absolute;
  top: calc(100% + var(--space-2));
  left: 0;
  z-index: 12;
  width: min(20rem, calc(100vw - var(--space-8)));
  padding: var(--space-4);
  border: 1px solid rgba(17, 104, 216, 0.2);
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.98);
  box-shadow: var(--shadow-card-lift);
}

.date-picker__header {
  display: grid;
  grid-template-columns: 2.25rem minmax(0, 1fr) 2.25rem;
  align-items: center;
  gap: var(--space-2);
  margin-bottom: var(--space-3);
}

.date-picker__title {
  margin: 0;
  color: var(--color-bg-deep);
  font-weight: 900;
  text-align: center;
}

.date-picker__nav {
  width: 2.25rem;
  height: 2.25rem;
  border: none;
  border-radius: var(--radius-sm);
  background: rgba(17, 104, 216, 0.08);
  color: var(--color-accent);
  font: inherit;
  font-size: 1.25rem;
  font-weight: 900;
  cursor: pointer;
}

.date-picker__nav:hover,
.date-picker__nav:focus-visible {
  background: var(--color-lime);
  color: #071927;
  outline: none;
}

.date-picker__weekdays,
.date-picker__cells {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 2px;
}

.date-picker__weekdays {
  margin-bottom: var(--space-1);
}

.date-picker__weekday {
  color: var(--color-text-muted);
  font-size: 0.72rem;
  font-weight: 800;
  text-align: center;
}

.date-picker__cell,
.date-picker__day {
  min-height: 2.25rem;
}

.date-picker__day {
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--color-text);
  font: inherit;
  font-size: var(--font-size-caption);
  font-weight: 700;
  cursor: pointer;
}

.date-picker__day:hover,
.date-picker__day:focus-visible {
  background: #e8f1ff;
  border-color: rgba(17, 104, 216, 0.2);
  outline: none;
}

.date-picker__day--today {
  border-color: var(--color-accent);
}

.date-picker__day--selected {
  background: var(--color-lime);
  color: #071927;
}

.race-form__actions {
  display: flex;
  gap: var(--space-3);
  align-items: center;
}

.form-errors {
  margin: var(--space-3) 0 0;
  padding: var(--space-3) var(--space-5);
  border: 1px solid var(--color-error);
  border-radius: var(--radius-sm);
  background: #fef2f2;
  color: var(--color-error);
  font-size: var(--font-size-caption);
}

.form-errors__item {
  margin: var(--space-1) 0;
}

.races-view-toggle {
  display: inline-flex;
  margin-top: var(--space-5);
  padding: var(--space-1);
  border-radius: var(--radius-md);
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  gap: var(--space-1);
}

.races-view-toggle__btn {
  font: inherit;
  font-size: var(--font-size-caption);
  font-weight: 600;
  padding: var(--space-2) var(--space-4);
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--color-text-muted);
  cursor: pointer;
}

.races-view-toggle__btn:hover,
.races-view-toggle__btn:focus-visible {
  color: var(--color-text);
  outline: none;
}

.races-view-toggle__btn--active {
  background: #eef2f6;
  color: var(--color-text);
}

.races-cal-wrap {
  margin-top: var(--space-6);
}

.races-cal__filter-hint {
  margin-top: var(--space-3);
  color: var(--color-text-muted);
  font-size: var(--font-size-caption);
}

.races-cal__hint {
  margin: 0 0 var(--space-4);
  color: var(--color-text-muted);
  font-size: var(--font-size-caption);
}

.races-cal__year {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: var(--space-5);
}

.races-cal__month {
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: var(--space-3);
  background: var(--color-surface);
}

.races-cal__month--compact .races-cal__month-title {
  font-size: var(--font-size-caption);
}

.races-cal__month--compact .races-cal__weekday {
  font-size: 0.65rem;
}

.races-cal__month--compact .races-cal__day-btn {
  font-size: var(--font-size-caption);
  min-height: 1.65rem;
}

.races-cal__month-title {
  margin: 0 0 var(--space-2);
  font-size: var(--font-size-body);
  font-weight: 600;
  color: var(--color-text);
}

.races-cal__weekdays {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 1px;
  margin-bottom: var(--space-1);
}

.races-cal__weekday {
  font-size: var(--font-size-caption);
  font-weight: 600;
  color: var(--color-text-muted);
  text-align: center;
}

.races-cal__cells {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 2px;
}

.races-cal__cell {
  position: relative;
  min-height: 2rem;
}

.races-cal__cell--empty {
  min-height: 0;
}

.races-cal__cell--has-race .races-cal__day-btn {
  font-weight: 700;
  color: var(--color-accent);
}

.races-cal__cell--open {
  z-index: 2;
}

.races-cal__day-btn {
  width: 100%;
  height: 100%;
  min-height: 2rem;
  font: inherit;
  font-size: var(--font-size-caption);
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--color-text);
  cursor: pointer;
}

.races-cal__day-btn:hover,
.races-cal__day-btn:focus-visible {
  background: #eef2f6;
  border-color: var(--color-border);
  outline: none;
}

.races-cal__cell--has-race .races-cal__day-btn:hover,
.races-cal__cell--has-race .races-cal__day-btn:focus-visible {
  background: #e8f0fc;
  border-color: var(--color-accent);
}

.races-cal__popover {
  position: absolute;
  top: calc(100% + var(--space-1));
  left: 50%;
  transform: translateX(-50%);
  min-width: 11rem;
  max-width: 16rem;
  padding: var(--space-3);
  border-radius: var(--radius-sm);
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  box-shadow: var(--shadow-card-lift);
  z-index: 5;
}

.races-cal__popover-list {
  margin: 0 0 var(--space-2);
  padding: 0;
  list-style: none;
}

.races-cal__popover-item {
  margin: 0 0 var(--space-1);
}

.races-cal__popover-link {
  color: var(--color-accent);
  font-weight: 600;
  font-size: var(--font-size-caption);
  text-decoration: none;
}

.races-cal__popover-link:hover,
.races-cal__popover-link:focus-visible {
  text-decoration: underline;
  outline: none;
}

.races-cal__popover-empty {
  margin: 0 0 var(--space-2);
  font-size: var(--font-size-caption);
  color: var(--color-text-muted);
}

.races-cal__popover-add {
  width: 100%;
  justify-content: center;
  text-align: center;
  font-size: var(--font-size-caption);
  padding: var(--space-2);
}

.races-cal__month-focus .races-cal__month {
  max-width: 28rem;
  margin-top: var(--space-4);
}

.races-cal__month-nav {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  margin-top: var(--space-4);
}

.races-cal__month-nav-item {
  font: inherit;
  font-size: var(--font-size-caption);
  padding: var(--space-1) var(--space-2);
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--color-accent);
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.races-cal__month-nav-item:hover,
.races-cal__month-nav-item:focus-visible {
  outline: none;
  color: var(--color-text);
}

.races-cal__month-nav-item--active {
  font-weight: 700;
  text-decoration: none;
  background: #eef2f6;
  color: var(--color-text);
}

.races-cal__month-nav-item--all {
  color: var(--color-text-muted);
}

.race-day__list {
  margin: var(--space-5) 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.race-day__item {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  padding: var(--space-3);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: var(--color-surface);
}

.race-day__link {
  font-weight: 600;
  color: var(--color-accent);
  text-decoration: none;
}

.race-day__link:hover,
.race-day__link:focus-visible {
  text-decoration: underline;
  outline: none;
}

.race-day__meta {
  font-size: var(--font-size-caption);
  color: var(--color-text-muted);
}

.race-day__actions {
  margin-top: var(--space-5);
}

/* ─── Sport dashboard refresh ─────────────────────────── */

body {
  background:
    radial-gradient(circle at 12% 8%, rgba(185, 242, 74, 0.24), transparent 24rem),
    radial-gradient(circle at 88% 0%, rgba(255, 111, 94, 0.16), transparent 22rem),
    linear-gradient(180deg, #f5f9fb 0%, var(--color-bg) 46%, #e8f0f4 100%);
}

.app-shell__header {
  position: sticky;
  top: 0;
  z-index: 10;
  background: rgba(255, 255, 255, 0.86);
  box-shadow: 0 1px 0 rgba(14, 31, 45, 0.06);
  backdrop-filter: blur(16px);
}

.app-shell__brand {
  color: var(--color-bg-deep);
}

.app-shell__link {
  font-size: var(--font-size-caption);
  font-weight: 700;
  transition:
    background 0.15s ease,
    color 0.15s ease,
    transform 0.15s ease;
}

.app-shell__link:hover,
.app-shell__link:focus-visible {
  transform: translateY(-1px);
}

.app-shell__link--active,
.app-shell__link--active:hover,
.app-shell__link--active:focus-visible {
  color: #071927;
  background: var(--color-lime);
}

.app-shell__main {
  width: min(1180px, 100%);
  padding: var(--space-8) var(--space-6);
}

.page {
  box-shadow: var(--shadow-card);
}

.page--dashboard,
.page--races,
.page--race-day {
  padding: 0;
  border: none;
  background: transparent;
  box-shadow: none;
}

.page__title {
  letter-spacing: 0;
  line-height: 1.08;
  color: var(--color-bg-deep);
}

.dashboard-hero,
.races-hero,
.race-day-hero {
  position: relative;
  overflow: hidden;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-hero);
}

.dashboard-hero {
  min-height: 24rem;
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(18rem, 0.8fr);
  gap: var(--space-6);
  align-items: end;
  padding: var(--space-8);
  color: #ffffff;
  background:
    linear-gradient(90deg, rgba(7, 25, 39, 0.9) 0%, rgba(7, 25, 39, 0.58) 46%, rgba(7, 25, 39, 0.1) 100%),
    url("/images/runner-hero.png") center / cover;
}

.dashboard-hero__content,
.dashboard-hero__panel {
  position: relative;
  z-index: 1;
}

.dashboard-hero__eyebrow,
.races-hero__eyebrow,
.race-day-hero__eyebrow {
  margin: 0 0 var(--space-2);
  color: var(--color-lime);
  font-size: var(--font-size-caption);
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.dashboard-hero__title {
  margin: 0;
  max-width: 28rem;
  color: #ffffff;
  font-size: 4.25rem;
  line-height: 0.95;
  letter-spacing: 0;
}

.dashboard-hero__text {
  max-width: 33rem;
  margin: var(--space-4) 0 0;
  color: rgba(255, 255, 255, 0.84);
  font-size: 1.08rem;
}

.dashboard-hero__actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3);
  margin-top: var(--space-6);
}

.dashboard-hero__secondary {
  color: #ffffff;
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(255, 255, 255, 0.36);
}

.dashboard-hero__secondary:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.2);
}

.dashboard-hero__panel {
  padding: var(--space-5);
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: var(--radius-md);
  background: rgba(7, 25, 39, 0.58);
  backdrop-filter: blur(14px);
}

.dashboard-hero__panel-label,
.dashboard-hero__empty {
  margin: 0;
  color: rgba(255, 255, 255, 0.72);
  font-size: var(--font-size-caption);
  font-weight: 700;
}

.dashboard-hero__race-link {
  display: grid;
  gap: var(--space-2);
  margin-top: var(--space-2);
}

.dashboard-hero__race-title {
  font-size: 1.45rem;
  font-weight: 800;
  line-height: 1.12;
}

.dashboard-hero__race-meta,
.dashboard-hero__race-countdown {
  color: rgba(255, 255, 255, 0.78);
}

.dashboard-hero__race-countdown {
  width: fit-content;
  padding: 0.25rem 0.6rem;
  border-radius: 999px;
  color: #071927;
  background: var(--color-lime);
  font-size: var(--font-size-caption);
  font-weight: 800;
}

.dashboard-grid {
  gap: var(--space-5);
}

.dashboard-card,
.race-list,
.race-details-card,
.race-form__group,
.comparison-table-wrapper,
.pace-chart,
.races-cal__month,
.race-day__item {
  border-color: rgba(214, 225, 234, 0.92);
  background: rgba(255, 255, 255, 0.9);
  box-shadow: var(--shadow-card);
}

.dashboard-card {
  position: relative;
  overflow: hidden;
}

.dashboard-card::before {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 0.28rem;
  content: "";
  background: var(--color-accent);
}

.dashboard-card--accent-blue::before {
  background: var(--color-accent);
}

.dashboard-card--accent-coral::before {
  background: var(--color-coral);
}

.dashboard-card--accent-lime::before {
  background: var(--color-lime);
}

.dashboard-card--accent-violet::before {
  background: var(--color-violet);
}

.dashboard-card__title,
.race-details-card__title,
.race-form__label,
.races-filter__label {
  color: #516372;
}

.dashboard-card__value {
  font-size: 2rem;
  line-height: 1.1;
}

.dashboard-card__progress {
  height: 0.55rem;
  margin-top: var(--space-4);
  overflow: hidden;
  border-radius: 999px;
  background: #e6eef4;
}

.dashboard-card__progress span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--color-lime), var(--color-violet));
}

.dashboard-section__title {
  color: var(--color-bg-deep);
}

.pace-chart {
  overflow: hidden;
  padding: var(--space-5);
  background:
    linear-gradient(135deg, rgba(17, 104, 216, 0.08), rgba(185, 242, 74, 0.16)),
    #ffffff;
}

.pace-chart__svg {
  max-width: 100%;
}

.pace-chart__grid-line {
  stroke: rgba(14, 31, 45, 0.12);
  stroke-width: 0.8;
  vector-effect: non-scaling-stroke;
}

.pace-chart__line {
  stroke-width: 2.2;
}

.pace-chart__dot {
  fill: #ffffff;
  stroke: var(--color-accent);
  stroke-width: 1;
  vector-effect: non-scaling-stroke;
}

.pace-chart__dot--last {
  fill: var(--color-lime);
  stroke: var(--color-bg-deep);
}

.pace-chart__stats {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3);
}

.pace-chart__caption {
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.72);
  color: var(--color-text);
}

.pace-chart__caption--best {
  color: #0e5d3d;
}

.races-hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(18rem, 0.58fr);
  gap: var(--space-6);
  align-items: end;
  min-height: 18rem;
  padding: var(--space-8);
  background:
    linear-gradient(90deg, rgba(7, 25, 39, 0.88), rgba(7, 25, 39, 0.48), rgba(7, 25, 39, 0.08)),
    url("/images/race-half.png") center / cover;
}

.races-hero .page__title,
.race-day-hero .page__title {
  color: #ffffff;
}

.races-hero .page__subtitle,
.race-day-hero .page__subtitle {
  color: rgba(255, 255, 255, 0.76);
}

.races-hero__filters {
  padding: var(--space-5);
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.14);
  backdrop-filter: blur(14px);
}

.races-hero__filters .races-filter {
  margin-top: 0;
}

.races-hero__filters .races-filter__label {
  color: rgba(255, 255, 255, 0.78);
}

.races-hero__filters .races-filter__select {
  border-color: rgba(255, 255, 255, 0.24);
  background: rgba(255, 255, 255, 0.94);
}

.races-view-toggle {
  border-color: rgba(255, 255, 255, 0.24);
  background: rgba(7, 25, 39, 0.28);
}

.races-view-toggle__btn {
  color: rgba(255, 255, 255, 0.78);
}

.races-view-toggle__btn:hover,
.races-view-toggle__btn:focus-visible {
  color: #ffffff;
}

.races-view-toggle__btn--active {
  color: #071927;
  background: var(--color-lime);
}

.race-list {
  padding: 0;
  border: none;
  background: transparent;
  box-shadow: none;
}

.race-list__title {
  color: var(--color-bg-deep);
}

.race-card--poster {
  overflow: hidden;
  padding: 0;
  border-radius: var(--radius-md);
}

.race-card--poster .race-card__link-surface {
  display: grid;
  grid-template-columns: 8.75rem minmax(0, 1fr);
  gap: 0;
  min-height: 10rem;
  padding: 0;
}

.race-card__image-wrap {
  position: relative;
  min-height: 100%;
  overflow: hidden;
  background: var(--color-bg-deep);
}

.race-card__image {
  width: 100%;
  height: 100%;
  min-height: 10rem;
  display: block;
  object-fit: cover;
  transition: transform 0.22s ease;
}

.race-card__image--contain {
  padding: var(--space-2);
  object-fit: contain;
  background:
    linear-gradient(135deg, rgba(17, 104, 216, 0.24), rgba(185, 242, 74, 0.14)),
    var(--color-bg-deep);
}

.race-card--poster:hover .race-card__image,
.race-card--poster:focus-within .race-card__image {
  transform: scale(1.05);
}

.race-card--poster:hover .race-card__image--contain,
.race-card--poster:focus-within .race-card__image--contain {
  transform: scale(1.02);
}

.race-card__date-badge {
  position: absolute;
  top: var(--space-2);
  left: var(--space-2);
  display: grid;
  min-width: 3rem;
  padding: 0.25rem 0.45rem;
  border-radius: var(--radius-sm);
  color: #071927;
  background: rgba(255, 255, 255, 0.9);
  text-align: center;
  font-weight: 900;
  line-height: 1.05;
  box-shadow: 0 8px 18px rgba(7, 25, 39, 0.18);
}

.race-card__date-badge span:last-child {
  color: var(--color-text-muted);
  font-size: 0.68rem;
  text-transform: uppercase;
}

.race-card__content {
  display: flex;
  min-width: 0;
  flex-direction: column;
  justify-content: space-between;
  gap: var(--space-4);
  padding: var(--space-4);
}

.race-card__kicker,
.race-day__kicker {
  margin: 0 0 var(--space-1);
  color: var(--color-accent);
  font-size: 0.72rem;
  font-weight: 900;
  letter-spacing: 0;
  text-transform: uppercase;
}

.race-card__title {
  line-height: 1.18;
}

.race-card__title-text {
  font-size: 1.05rem;
  font-weight: 800;
}

.race-card__footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
}

.race-card__cta {
  color: var(--color-accent);
  font-size: var(--font-size-caption);
  font-weight: 800;
}

.race-card__status {
  border: 1px solid transparent;
}

.race-card__status--planned {
  background: #e8f1ff;
  color: var(--color-accent-strong);
}

.race-card__status--completed {
  background: #e7f8ef;
  color: var(--color-success);
}

.race-card__status--registered {
  background: #fff0da;
  color: #8a5100;
}

.races-cal-wrap {
  padding: var(--space-5);
  border-radius: var(--radius-lg);
  background: rgba(255, 255, 255, 0.72);
  box-shadow: var(--shadow-card);
}

.races-cal__hint,
.races-cal__filter-hint {
  color: #516372;
}

.races-cal__month {
  transition:
    transform 0.15s ease,
    box-shadow 0.15s ease;
}

.races-cal__month:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-card-lift);
}

.races-cal__month-title {
  color: var(--color-bg-deep);
  font-weight: 800;
}

.races-cal__cell--has-race .races-cal__day-btn {
  color: #071927;
  background: linear-gradient(135deg, rgba(185, 242, 74, 0.7), rgba(17, 104, 216, 0.14));
  border-color: rgba(17, 104, 216, 0.18);
}

.races-cal__cell--has-race .races-cal__day-btn:hover,
.races-cal__cell--has-race .races-cal__day-btn:focus-visible {
  background: var(--color-lime);
  border-color: var(--color-bg-deep);
}

.races-cal__popover {
  border-color: rgba(17, 104, 216, 0.2);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-card-lift);
}

.races-cal__popover-link {
  color: var(--color-bg-deep);
}

.races-cal__month-nav-item {
  color: var(--color-accent);
  text-decoration: none;
  background: rgba(17, 104, 216, 0.08);
}

.races-cal__month-nav-item--active {
  background: var(--color-bg-deep);
  color: #ffffff;
}

.race-day-hero {
  min-height: 14rem;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  padding: var(--space-8);
  background:
    linear-gradient(90deg, rgba(7, 25, 39, 0.9), rgba(7, 25, 39, 0.5), rgba(7, 25, 39, 0.08)),
    url("/images/race-short.png") center / cover;
}

.race-day-hero .page-link {
  width: fit-content;
  margin: 0 0 var(--space-5);
  color: #ffffff;
}

.race-day__list {
  gap: var(--space-4);
}

.race-day__item {
  overflow: hidden;
  padding: 0;
  border-radius: var(--radius-md);
}

.race-day__link {
  display: grid;
  grid-template-columns: 11rem minmax(0, 1fr);
  color: inherit;
  text-decoration: none;
}

.race-day__link:hover,
.race-day__link:focus-visible {
  text-decoration: none;
}

.race-day__image {
  width: 100%;
  height: 100%;
  min-height: 8.5rem;
  object-fit: cover;
}

.race-day__image--contain {
  padding: var(--space-3);
  object-fit: contain;
  background:
    linear-gradient(135deg, rgba(17, 104, 216, 0.22), rgba(185, 242, 74, 0.16)),
    var(--color-bg-deep);
}

.race-day__body {
  display: grid;
  gap: var(--space-2);
  align-content: center;
  padding: var(--space-4);
}

.race-day__title {
  color: var(--color-bg-deep);
  font-size: 1.18rem;
  font-weight: 800;
  line-height: 1.18;
}

.btn {
  box-shadow: 0 8px 18px rgba(14, 31, 45, 0.08);
}

.btn--primary {
  background: var(--color-lime);
  color: #071927;
}

.btn--primary:hover:not(:disabled) {
  background: #aee83c;
}

.btn--secondary:hover:not(:disabled) {
  background: #f2f6f9;
}

.dashboard-hero .dashboard-hero__secondary:hover:not(:disabled) {
  color: #ffffff;
  background: rgba(255, 255, 255, 0.2);
}

/* ─── Responsive ───────────────────────────────────────── */

@media (max-width: 900px) {
  .dashboard-grid,
  .race-lists,
  .race-details-grid {
    grid-template-columns: 1fr;
  }

  .races-cal__year {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .dashboard-hero,
  .races-hero {
    grid-template-columns: 1fr;
  }

  .dashboard-hero {
    min-height: 34rem;
    background-position: 62% center;
  }

  .races-hero {
    background-position: 62% center;
  }

  .race-details-header {
    flex-direction: column;
  }

  .race-form__actions {
    flex-direction: column;
    align-items: stretch;
  }
}

@media (max-width: 560px) {
  .app-shell__header {
    align-items: flex-start;
    flex-direction: column;
  }

  .app-shell__nav {
    width: 100%;
    overflow-x: auto;
  }

  .app-shell__main {
    padding: var(--space-4);
  }

  .dashboard-hero,
  .races-hero,
  .race-day-hero {
    padding: var(--space-5);
    border-radius: var(--radius-md);
  }

  .dashboard-hero__title {
    font-size: 3rem;
  }

  .race-card--poster .race-card__link-surface,
  .race-day__link {
    grid-template-columns: 1fr;
  }

  .race-card__image,
  .race-day__image {
    max-height: 12rem;
  }

  .races-cal__year {
    grid-template-columns: 1fr;
  }
}
