:root {
  color-scheme: light;
  --ink: #17211f;
  --muted: #65706d;
  --line: #d9e0dd;
  --soft: #eef3f0;
  --paper: #fbfcfa;
  --panel: #ffffff;
  --green: #1c7c54;
  --green-dark: #0d5638;
  --teal: #116a6b;
  --amber: #c87918;
  --red: #b84438;
  --blue: #3867b7;
  --shadow: 0 18px 45px rgba(23, 33, 31, 0.13);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

body.dark-theme {
  color-scheme: dark;
  --ink: #eef5f2;
  --muted: #a7b4b0;
  --line: #32413c;
  --soft: #1f2a27;
  --paper: #101614;
  --panel: #17211f;
  --green: #3aa874;
  --green-dark: #7ad0a4;
  --blue: #82a9ff;
  --shadow: 0 18px 45px rgba(0, 0, 0, 0.35);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
}

button,
input,
select,
textarea {
  font: inherit;
}

.app-shell {
  position: sticky;
  top: 0;
  z-index: 10;
  background: rgba(251, 252, 250, 0.93);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(16px);
}

body.dark-theme .app-shell {
  background: rgba(16, 22, 20, 0.93);
}

.topbar {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 18px;
  width: min(1180px, calc(100% - 32px));
  min-height: 72px;
  margin: 0 auto;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--ink);
  font-weight: 800;
  text-decoration: none;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 8px;
  background: var(--green);
  color: white;
}

.header-tools {
  display: flex;
  justify-self: end;
  align-items: center;
  gap: 10px;
}

.login-button {
  white-space: nowrap;
}

.logout-form {
  margin: 0;
}

.filter-chip {
  min-height: 36px;
  border: 0;
  border-radius: 6px;
  padding: 0 12px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  white-space: nowrap;
}

.theme-toggle {
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--ink);
  cursor: pointer;
}

.theme-toggle:hover,
.theme-toggle:focus-visible {
  box-shadow: 0 2px 10px rgba(23, 33, 31, 0.08);
}

.filter-chip.active {
  background: var(--panel);
  color: var(--ink);
  box-shadow: 0 2px 10px rgba(23, 33, 31, 0.08);
}

.member-button {
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--ink);
  cursor: pointer;
}

.member-button[hidden],
[data-trainer-only][hidden] {
  display: none !important;
}

.person-icon {
  position: relative;
  width: 18px;
  height: 18px;
}

.compact-person {
  width: 16px;
  height: 16px;
}

.theme-icon {
  display: block;
  grid-area: 1 / 1;
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.theme-toggle .sun-icon {
  display: none;
}

body.dark-theme .theme-toggle .moon-icon {
  display: none;
}

body.dark-theme .theme-toggle .sun-icon {
  display: block;
}

.person-icon::before,
.person-icon::after {
  content: "";
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  background: currentColor;
}

.person-icon::before {
  top: 1px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.person-icon::after {
  bottom: 1px;
  width: 16px;
  height: 8px;
  border-radius: 999px 999px 4px 4px;
}

.hero {
  position: relative;
  min-height: 560px;
  overflow: hidden;
}

.hero img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.hero-shade {
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, rgba(10, 22, 19, 0.82), rgba(10, 22, 19, 0.45) 45%, rgba(10, 22, 19, 0.06));
}

.hero-content {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: center;
  width: min(1180px, calc(100% - 32px));
  min-height: 560px;
  margin: 0 auto;
  padding: 56px 0 92px;
  color: white;
}

.eyebrow {
  margin: 0 0 10px;
  color: var(--green);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.hero .eyebrow,
.hero-copy {
  color: rgba(255, 255, 255, 0.82);
}

h1,
h2,
h3,
h4,
p {
  margin-top: 0;
}

.hero h1 {
  max-width: 680px;
  margin-bottom: 16px;
  font-size: 5.35rem;
  line-height: 0.96;
  letter-spacing: 0;
}

.hero-copy {
  max-width: 520px;
  font-size: 1.18rem;
  line-height: 1.55;
}

.login-strip {
  display: grid;
  grid-template-columns: auto minmax(220px, 360px) auto;
  align-items: center;
  gap: 12px;
  width: fit-content;
  max-width: 100%;
  margin-top: 22px;
  padding: 10px;
  border: 1px solid rgba(255, 255, 255, 0.32);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.12);
  backdrop-filter: blur(12px);
}

.login-strip label {
  padding-left: 8px;
  font-weight: 700;
}

input,
select,
textarea {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--panel);
  color: var(--ink);
  padding: 9px 11px;
}

.content-band,
.workspace {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 48px 0;
}

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

.section-heading h1,
.section-heading h2 {
  margin-bottom: 0;
  font-size: 2rem;
  letter-spacing: 0;
}

.toolbar,
.button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.event-filters {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr) auto;
  align-items: start;
  gap: 12px;
  margin-bottom: 24px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 8px 24px rgba(23, 33, 31, 0.05);
}

.filter-group {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

.filter-group legend {
  flex-basis: 100%;
  margin-bottom: 2px;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 800;
}

.run-grid {
  display: grid;
  gap: 18px;
}

.run-grid[data-panel="visitor"] [data-role-only],
.run-grid[data-panel="runner"] [data-role-only="trainer"],
.run-grid[data-panel="trainer"] [data-role-only="runner"] {
  display: none !important;
}

.run-grid[data-panel="runner"] [data-role-only="member"],
.run-grid[data-panel="trainer"] [data-role-only="member"],
.run-grid[data-panel="trainer"] [data-role-only="trainer"] {
  display: grid;
}

.run-grid[data-panel="trainer"] .reminder-status[data-role-only="trainer"] {
  display: inline-flex;
}

.add-run-card {
  display: grid;
  place-items: center;
  min-height: 136px;
  border: 1px dashed #aebbb6;
  border-radius: 8px;
  background: var(--panel);
  color: var(--green-dark);
  cursor: pointer;
}

.add-run-card span {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  margin-bottom: 8px;
  border-radius: 8px;
  background: var(--soft);
  border: 1px solid var(--line);
  font-size: 2rem;
  line-height: 1;
}

.add-run-card strong {
  font-size: 1.1rem;
}

.run-card,
.ops-panel,
.metric,
.sidebar,
.admin-form {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.run-card {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
  min-height: 190px;
  overflow: hidden;
  box-shadow: 0 10px 30px rgba(23, 33, 31, 0.07);
}

.run-card.selected {
  border-color: rgba(28, 124, 84, 0.45);
  box-shadow: 0 18px 40px rgba(28, 124, 84, 0.16);
}

.run-card.muted {
  background: #f6f8f6;
}

body.dark-theme .run-card.muted {
  background: #202623;
  border-color: #48524d;
}

body.dark-theme .run-card.muted .run-visual {
  opacity: 0.72;
}

.table-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.status {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  border-radius: 999px;
  padding: 0 10px;
  font-size: 0.82rem;
  font-weight: 800;
}

.status.open {
  background: #def4e8;
  color: var(--green-dark);
}

.status.registered {
  background: var(--green);
  color: white;
}

.status.waitlist {
  background: #fff0d8;
  color: #8a4d05;
}

.status.closed {
  background: #f7dedb;
  color: var(--red);
}

.run-visual-button {
  display: block;
  width: 100%;
  height: 100%;
  min-height: 220px;
  border: 0;
  background: var(--soft);
  padding: 0;
  cursor: zoom-in;
  overflow: hidden;
}

.run-visual {
  display: block;
  width: 100%;
  height: 100%;
  min-height: 220px;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  object-position: center top;
}

.run-visual.crop-right {
  object-position: 72% top;
}

.run-visual.crop-center {
  object-position: 50% top;
}

.run-visual.crop-left {
  object-position: 12% top;
}

.run-summary {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 150px 150px;
  align-items: start;
  gap: 24px;
  padding: 24px;
}

.public-runs .run-summary {
  grid-template-columns: minmax(0, 1fr) 150px;
}

.run-card h3 {
  margin: 0 0 12px;
  font-size: 1.55rem;
}

.badge-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 14px;
}

.info-badge {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  border-radius: 999px;
  padding: 0 10px;
  background: var(--soft);
  color: var(--ink);
  font-size: 0.82rem;
  font-weight: 800;
}

.info-badge.cup {
  background: #deebff;
  color: var(--blue);
}

.run-date {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.run-date span,
.run-date small {
  color: var(--muted);
  font-weight: 800;
}

.run-date strong {
  font-size: 1.45rem;
}

.run-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  min-width: 0;
}

.run-actions .primary-button,
.run-actions .secondary-button,
.run-actions .danger-button,
.run-actions .disabled-button,
.run-actions .waitlist-button {
  width: 128px;
}

.trainer-actions .secondary-button {
  width: 72px;
}

.trainer-actions .primary-button,
.trainer-actions .danger-button,
.trainer-actions .disabled-button,
.trainer-actions .waitlist-button {
  width: 128px;
}

.trainer-actions {
  display: grid;
  justify-items: end;
}

.trainer-tools {
  display: grid;
  grid-template-columns: repeat(2, 42px);
  gap: 8px;
  margin-top: 8px;
}

.participants-button {
  grid-column: 1;
  grid-row: 2;
}

.icon-button {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--panel);
  color: var(--ink);
  cursor: pointer;
  font-size: 1.05rem;
  font-weight: 800;
}

.reminder-status,
.dialog-copy {
  margin: 12px 0 0;
  color: var(--muted);
  line-height: 1.45;
}

.reminder-status {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  min-height: 32px;
  font-weight: 800;
}

.reminder-status.sent {
  color: var(--green-dark);
}

.reminder-status.unsent {
  color: var(--red);
}

.mail-emoji {
  display: inline-grid;
  place-items: center;
  width: 20px;
  height: 20px;
  color: currentColor;
  font-size: 1.1rem;
  line-height: 1;
}

.flag-emoji {
  display: inline-grid;
  place-items: center;
  width: 20px;
  height: 20px;
  font-size: 1.1rem;
  line-height: 1;
}

.vertical-actions {
  display: grid;
  gap: 10px;
}

.primary-button,
.secondary-button,
.ghost-button,
.disabled-button,
.danger-button {
  min-height: 42px;
  border-radius: 7px;
  padding: 0 16px;
  font-weight: 800;
  cursor: pointer;
}

.primary-button {
  border: 1px solid var(--green);
  background: var(--green);
  color: white;
}

.secondary-button {
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--ink);
}

.ghost-button {
  border: 1px solid var(--line);
  background: transparent;
  color: var(--ink);
}

.disabled-button {
  border: 1px solid var(--line);
  background: #e9eeeb;
  color: #7a8581;
  cursor: not-allowed;
}

.danger-button {
  border: 1px solid #e7c7c3;
  background: #fff1ef;
  color: var(--red);
}

.waitlist-button {
  min-height: 42px;
  border: 1px solid #f0c56e;
  border-radius: 7px;
  background: #fff0d8;
  color: #8a4d05;
  padding: 0 16px;
  font-weight: 800;
  cursor: pointer;
}

.full {
  width: 100%;
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.workspace {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
  gap: 22px;
}

.sidebar {
  position: sticky;
  top: 96px;
  align-self: start;
  padding: 20px;
}

.side-label {
  display: block;
  margin-bottom: 20px;
  color: var(--green);
  font-weight: 800;
  text-transform: uppercase;
}

.sidebar p {
  color: var(--muted);
  line-height: 1.5;
}

.dashboard-main {
  min-width: 0;
}

.compact {
  align-items: center;
}

.toolbar input,
.toolbar select {
  width: auto;
}

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

.metric {
  padding: 16px;
}

.metric span {
  display: block;
  color: var(--muted);
  font-size: 0.9rem;
}

.metric strong {
  display: block;
  margin-top: 6px;
  font-size: 2rem;
}

.ops-panel {
  padding: 18px;
  box-shadow: 0 10px 28px rgba(23, 33, 31, 0.06);
}

.table-header p {
  margin-bottom: 0;
  color: var(--muted);
}

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

.participant-list {
  min-height: 240px;
  padding: 14px;
  border-radius: 8px;
  background: var(--soft);
}

.participant-list label {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 8px;
  margin-bottom: 12px;
  font-weight: 700;
}

.participant-list label span {
  grid-column: 2;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 500;
}

.queue-item {
  margin-bottom: 10px;
  color: var(--muted);
  line-height: 1.45;
}

.admin-grid {
  grid-template-columns: minmax(0, 1.25fr) minmax(300px, 0.75fr);
  align-items: start;
}

.admin-form {
  display: grid;
  gap: 14px;
  padding: 18px;
}

.admin-form label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-weight: 700;
}

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

.admin-stack {
  display: grid;
  gap: 14px;
}

.compact-panel {
  box-shadow: none;
}

dialog {
  max-width: 620px;
  border: 0;
  border-radius: 8px;
  padding: 0;
  box-shadow: var(--shadow);
}

dialog::backdrop {
  background: rgba(23, 33, 31, 0.42);
}

.image-preview-dialog {
  width: min(980px, calc(100% - 32px));
  max-width: none;
}

.image-preview-card {
  position: relative;
  display: grid;
  padding: 0;
  background: var(--panel);
}

.image-preview-card img {
  display: block;
  width: 100%;
  max-height: min(78vh, 760px);
  object-fit: contain;
  background: #0b0f0e;
}

.dialog-card {
  position: relative;
  display: grid;
  gap: 14px;
  padding: 28px;
}

.dialog-card label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-weight: 700;
}

.edit-dialog h2 {
  margin-bottom: 0;
}

.check-row {
  display: flex !important;
  grid-template-columns: none;
  align-items: center;
  gap: 10px;
}

.check-row input {
  width: auto;
  min-height: auto;
}

.dialog-close {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 34px;
  height: 34px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--panel);
  cursor: pointer;
}

.member-toolbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
}

.add-member-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 16px;
  min-height: 76px;
  border: 1px dashed #aebbb6;
  border-radius: 8px;
  background: var(--panel);
  color: var(--muted);
  padding: 14px 16px;
  text-align: left;
  cursor: pointer;
}

.add-member-card strong {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--soft);
  color: var(--green-dark);
  font-size: 1.8rem;
  line-height: 1;
}

.member-list {
  display: grid;
  gap: 10px;
}

.member-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(180px, 0.9fr) auto auto;
  align-items: center;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--soft);
}

.member-row span {
  font-weight: 800;
}

.member-row small {
  color: var(--muted);
}

.delete-member-button {
  color: var(--red);
}

.discipline-list {
  display: grid;
  gap: 10px;
  margin: 0;
  padding: 0;
  border: 0;
}

.discipline-list legend {
  margin-bottom: 2px;
  color: var(--muted);
  font-weight: 700;
}

.discipline-row,
.participant-actions {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 150px;
  gap: 10px;
  align-items: end;
}

.switch-row {
  display: flex !important;
  grid-template-columns: none;
  align-items: center;
  gap: 12px;
}

.switch-row input {
  width: 46px;
  min-height: 24px;
  accent-color: var(--green);
}

.mail-preview {
  display: grid;
  gap: 8px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--soft);
}

.mail-preview p {
  margin-bottom: 0;
  color: var(--muted);
  line-height: 1.45;
}

.mail-preview textarea {
  resize: none;
}

.participant-row {
  display: grid;
  grid-template-columns: minmax(280px, 1fr) minmax(360px, 1.25fr) auto;
  align-items: center;
  gap: 10px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.participant-row span {
  font-weight: 800;
}

.participant-row small {
  color: var(--muted);
  font-weight: 800;
}

#participants-dialog {
  width: min(960px, calc(100vw - 32px));
  max-width: none;
}

.participants-dialog {
  width: 100%;
}

.demo-divider {
  height: 4px;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.demo-heading {
  margin-bottom: 0;
  font-size: 1rem;
}

.demo-login-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.login-help,
.login-error {
  margin-bottom: 0;
  color: var(--muted);
  line-height: 1.45;
}

.login-error {
  color: var(--red);
  font-weight: 800;
}

@media (max-width: 980px) {
  .event-filters {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

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

  .run-card {
    grid-template-columns: 220px minmax(0, 1fr);
  }

  .run-summary {
    grid-template-columns: minmax(0, 1fr) 120px;
  }

  .public-runs .run-summary {
    grid-template-columns: minmax(0, 1fr) 120px;
  }

  .run-actions {
    grid-column: 1 / -1;
    justify-content: flex-start;
  }

  .trainer-actions {
    justify-items: start;
  }

  .workspace,
  .admin-grid,
  .participant-layout {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
  }
}

@media (max-width: 720px) {
  .topbar,
  .section-heading,
  .table-header {
    align-items: stretch;
  }

  .topbar {
    grid-template-columns: 1fr;
  }

  .header-tools {
    justify-self: stretch;
    justify-content: space-between;
  }

  .hero,
  .hero-content {
    min-height: 620px;
  }

  .hero h1 {
    font-size: 3rem;
  }

  .login-strip,
  .run-grid,
  .metric-row,
  .two-col {
    grid-template-columns: 1fr;
  }

  .run-card,
  .run-summary {
    grid-template-columns: 1fr;
  }

  .run-visual {
    height: auto;
    min-height: 0;
  }

  .run-visual-button {
    height: auto;
    min-height: 0;
  }

  .run-actions .primary-button,
  .run-actions .secondary-button,
  .run-actions .danger-button,
  .run-actions .disabled-button {
    width: 100%;
  }

  .trainer-actions .secondary-button {
    width: 100%;
  }

  .member-toolbar,
  .member-row,
  .discipline-row,
  .participant-actions,
  .participant-row {
    grid-template-columns: 1fr;
  }

  .toolbar input,
  .toolbar select {
    width: 100%;
  }

  .event-filters {
    grid-template-columns: 1fr;
  }
}
