:root {
  --bg: #f3f5f1;
  --ink: #070707;
  --muted: #656862;
  --line: rgba(7, 7, 7, 0.14);
  --line-strong: rgba(7, 7, 7, 0.24);
  --surface: #ffffff;
  --surface-alt: #f8f8f3;
  --accent: #55d23b;
  --accent-dark: #42b52d;
  --accent-soft: #e5f7df;
  --warn: #a95c00;
  --danger: #b40065;
  --danger-soft: #ffe8f4;
  --focus: #55d23b;
  --shadow: 0 18px 36px rgba(7, 7, 7, 0.08);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

:root[data-theme="dark"] {
  --bg: #0e1411;
  --ink: #edf5ef;
  --muted: #aab8ae;
  --line: rgba(237, 245, 239, 0.14);
  --line-strong: rgba(237, 245, 239, 0.26);
  --surface: #171f1a;
  --surface-alt: #101813;
  --accent: #68d853;
  --accent-dark: #86e874;
  --accent-soft: #203a24;
  --warn: #f2b86b;
  --danger: #ff74b2;
  --danger-soft: #3b1428;
  --focus: #86e874;
  --shadow: 0 18px 38px rgba(0, 0, 0, 0.42);
  color-scheme: dark;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  color: var(--ink);
  background: var(--bg);
  font-size: 15px;
  line-height: 1.45;
}

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

button,
.file-button,
.download-button {
  max-width: 100%;
  min-width: 0;
  min-height: 38px;
  border: 2px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  border-radius: 6px;
  padding: 8px 12px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  white-space: normal;
  overflow-wrap: anywhere;
  text-align: center;
  line-height: 1.2;
  text-decoration: none;
  font-weight: 850;
}

button:hover,
.file-button:hover,
.download-button:hover {
  border-color: var(--ink);
}

button:focus-visible,
.file-button:focus-within,
.download-button:focus-visible,
input:focus,
select:focus,
textarea:focus {
  outline: 2px solid var(--focus);
  outline-offset: 3px;
}

button.primary,
.download-button.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--ink);
}

button.primary:hover,
.download-button.primary:hover {
  background: var(--accent-dark);
  border-color: var(--accent-dark);
}

button.secondary,
.file-button.secondary {
  background: #fff;
}

button.secondary.active {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--ink);
}

button:disabled,
.file-button.disabled,
.download-button[aria-disabled="true"] {
  cursor: not-allowed;
  opacity: 0.58;
}

button.ghost {
  background: transparent;
}

button.danger {
  background: var(--danger);
  border-color: var(--danger);
  color: #fff;
}

button.small,
.small-button {
  min-height: 30px;
  padding: 5px 9px;
  font-size: 13px;
}

.file-button {
  position: relative;
  overflow: hidden;
}

.file-button input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.file-button.disabled input {
  cursor: not-allowed;
}

#saveStatus {
  display: none !important;
}

.topbar {
  min-height: 76px;
  padding: 14px 22px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(7, 7, 7, 0.9);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  position: sticky;
  top: 0;
  z-index: 5;
  backdrop-filter: blur(16px);
}

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

.brand-button {
  border: 0;
  background: transparent;
  color: inherit;
  min-height: 0;
  padding: 0;
  text-align: left;
  justify-content: flex-start;
}

.brand-button:hover {
  border-color: transparent;
}

.brand-button:focus-visible {
  outline-color: var(--accent);
}

.brand-mark {
  width: 46px;
  height: 46px;
  border-radius: 6px;
  border: 2px solid var(--accent);
  background: var(--accent);
  color: var(--ink);
  display: grid;
  place-items: center;
  font-weight: 800;
  letter-spacing: 0;
}

.brand-title-row {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  flex-wrap: wrap;
}

.brand h1,
.brand-heading {
  display: block;
  margin: 0;
  font-size: 20px;
  font-weight: 850;
  letter-spacing: 0;
  color: #fff;
}

.alpha-note {
  display: inline-flex;
  align-items: center;
  max-width: 100%;
  min-height: 22px;
  padding: 2px 7px;
  border: 1px solid rgba(255, 255, 255, 0.26);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.1);
  color: rgba(255, 255, 255, 0.82);
  font-size: 11px;
  font-weight: 800;
  line-height: 1.15;
  letter-spacing: 0;
  text-transform: uppercase;
  white-space: normal;
}

.brand p,
.brand-subline {
  display: block;
  margin: 2px 0 0;
  color: rgba(255, 255, 255, 0.78);
  font-size: 13px;
}

.brand p span:first-child,
.brand-subline span:first-child {
  color: var(--accent);
  font-weight: 850;
}

.brand-subline {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 5px 7px;
}

.server-autosave-pill {
  display: inline-flex;
  align-items: center;
  max-width: 100%;
  min-height: 19px;
  padding: 1px 7px;
  border: 1px solid rgba(255, 255, 255, 0.24);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.1);
  color: rgba(255, 255, 255, 0.82);
  font-size: 11px;
  font-weight: 800;
  line-height: 1.2;
  white-space: nowrap;
}

.server-autosave-pill.is-idle,
.server-autosave-pill.is-saved {
  border-color: rgba(36, 178, 117, 0.36);
  background: rgba(36, 178, 117, 0.14);
  color: #bff6dd;
}

.server-autosave-pill.is-pending,
.server-autosave-pill.is-saving {
  border-color: rgba(252, 211, 77, 0.42);
  background: rgba(252, 211, 77, 0.13);
  color: #fde9a3;
}

.server-autosave-pill.is-error,
.server-autosave-pill.is-blocked {
  border-color: rgba(248, 113, 113, 0.42);
  background: rgba(248, 113, 113, 0.13);
  color: #fecaca;
}

.mobile-menu-toggle {
  display: none;
}

.menu-bars {
  display: grid;
  gap: 3px;
  width: 18px;
}

.menu-bars span {
  display: block;
  height: 2px;
  border-radius: 999px;
  background: currentColor;
}

.category-toggle {
  display: inline-grid;
  grid-template-columns: 1fr 1fr;
  gap: 2px;
  padding: 3px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.08);
}

.category-toggle button {
  min-width: 82px;
  min-height: 34px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: rgba(255, 255, 255, 0.72);
  font-weight: 850;
}

.category-toggle button.active {
  background: var(--accent);
  color: var(--ink);
}

.top-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 8px;
}

.auth-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 8px;
  margin-left: auto;
}

.auth-pill {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 5px 9px;
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-radius: 6px;
  color: #fff;
  font-size: 13px;
  font-weight: 850;
}

.header-race-switcher {
  display: grid;
  gap: 2px;
  min-width: 220px;
  max-width: 340px;
  color: rgba(255, 255, 255, 0.82);
  font-size: 10px;
  font-weight: 850;
  letter-spacing: 0;
  text-transform: uppercase;
}

.header-race-switcher select {
  min-height: 34px;
  max-width: 100%;
  overflow: hidden;
  border-color: rgba(255, 255, 255, 0.28);
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  font-size: 13px;
  text-overflow: ellipsis;
  text-transform: none;
}

.header-race-switcher select:disabled {
  opacity: 0.72;
}

.header-race-switcher option {
  color: #14221b;
}

.auth-locked .tabs,
.auth-locked .category-toggle,
.auth-locked .top-actions,
.auth-locked .mobile-menu-toggle,
.admin-mode .tabs,
.admin-mode .category-toggle,
.admin-mode .top-actions,
.admin-mode .mobile-menu-toggle,
.onboarding-mode .tabs {
  display: none;
}

.tabs {
  padding: 10px 22px 0;
  background: rgba(243, 245, 241, 0.96);
  border-bottom: 1px solid var(--line);
  display: flex;
  gap: 2px;
  overflow-x: auto;
  position: sticky;
  top: var(--topbar-height, 75px);
  z-index: 4;
  backdrop-filter: blur(16px);
}

.tabs button {
  border: 0;
  border-bottom: 3px solid transparent;
  border-radius: 6px 6px 0 0;
  background: transparent;
  color: var(--muted);
  padding: 10px 13px;
  font-weight: 700;
}

.tabs button.active {
  color: var(--ink);
  background: var(--surface);
  border-bottom-color: var(--accent);
}

.workspace {
  width: min(1440px, calc(100vw - 32px));
  margin: 18px auto 18px;
}

.site-footer {
  width: min(1440px, calc(100vw - 32px));
  margin: 0 auto 34px;
  padding: 6px 2px;
  color: var(--muted);
  font-size: 13px;
  text-align: right;
  display: flex;
  justify-content: flex-end;
  gap: 14px;
  flex-wrap: wrap;
}

.site-footer a,
.site-footer button,
.site-footer span {
  min-height: 0;
  border: 0;
  background: transparent;
  padding: 0;
  color: var(--muted);
  font-size: inherit;
  font-weight: 750;
}

.site-footer a,
.site-footer button {
  text-decoration: underline;
  text-underline-offset: 3px;
}

.site-footer a:hover,
.site-footer button:hover {
  color: var(--accent);
}

.support-page .brand {
  color: #fff;
  text-decoration: none;
}

.support-topbar {
  justify-content: flex-start;
}

.support-workspace {
  display: grid;
  gap: 18px;
}

.support-page .panel-header h2 {
  margin: 0;
  font-size: 16px;
}

.support-page .panel-body {
  display: grid;
  gap: 10px;
  align-content: start;
}

.view-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 16px;
  padding: 18px;
  border-radius: 8px;
  background: var(--ink);
  color: #fff;
}

.auth-grid {
  align-items: start;
}

.public-results-home {
  margin-top: 16px;
}

.auth-modal-panel {
  width: min(1040px, calc(100vw - 32px));
  max-height: calc(100vh - 40px);
  overflow: auto;
}

.auth-modal-grid {
  margin: 0;
}

.auth-modal-panel .panel,
.auth-modal-panel .panel-body {
  min-width: 0;
}

.rider-import-panel {
  width: min(1180px, calc(100vw - 24px));
  max-height: calc(100vh - 32px);
  overflow: auto;
}

.rider-import-table-wrap {
  max-height: min(58vh, 620px);
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.rider-import-table {
  min-width: 1120px;
  margin: 0;
}

.rider-import-table th,
.rider-import-table td {
  vertical-align: top;
}

.rider-import-table .table-input {
  min-width: 96px;
}

.rider-import-table [data-import-field="firstName"],
.rider-import-table [data-import-field="lastName"],
.rider-import-table [data-import-field="team"] {
  min-width: 138px;
}

.chip-preview-panel h4 {
  margin: 14px 0 4px;
}

.chip-format-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 10px;
  margin: 12px 0 14px;
}

.chip-format-card {
  display: grid;
  gap: 8px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-alt);
  min-width: 0;
}

.chip-format-card strong,
.chip-format-card .hint {
  display: block;
}

.chip-format-selects {
  align-items: end;
  gap: 8px;
}

.chip-format-selects .field {
  min-width: 0;
}

.chip-preview-table {
  min-width: 900px;
}

.chip-preview-times {
  min-width: 220px;
  line-height: 1.45;
}

.import-warning-cell {
  min-width: 180px;
  max-width: 240px;
}

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

.forgot-password-box {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: end;
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.forgot-password-box .field {
  margin: 0;
}

.verified-results-panel {
  order: -1;
}

.home-dashboard .assigned-races-panel {
  order: -2;
}

.assigned-race-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 340px), 1fr));
  gap: 12px;
}

.assigned-race-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.assigned-race-title-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.assigned-race-main p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.assigned-race-actions {
  display: flex;
  justify-content: flex-end;
}

.verified-results-panel .panel-header {
  align-items: flex-start;
}

.verified-results-panel .panel-header .hint {
  margin: 4px 0 0;
}

.verified-search-row {
  align-items: center;
  margin-bottom: 12px;
}

.verified-search-row input {
  min-width: min(320px, 100%);
  flex: 1 1 320px;
}

.verified-results-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 390px), 1fr));
  gap: 12px;
}

.verified-result-item {
  --race-primary: var(--accent);
  --race-secondary: var(--accent-soft);
  --race-on-primary: #fff;
  position: relative;
  display: grid;
  grid-template-columns: 82px minmax(0, 1fr);
  gap: 12px 14px;
  align-items: start;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  overflow: hidden;
}

.verified-result-item::before {
  content: "";
  position: absolute;
  inset: 0 0 auto;
  height: 5px;
  background: var(--race-primary);
}

.verified-result-brand {
  min-height: 70px;
  padding: 8px;
  border: 1px solid color-mix(in srgb, var(--race-primary) 22%, var(--line));
  border-radius: 8px;
  background: color-mix(in srgb, var(--race-secondary) 52%, #fff);
  display: grid;
  align-content: center;
  justify-items: center;
  gap: 6px;
}

.verified-result-brand img {
  display: block;
  width: 100%;
  max-width: 64px;
  max-height: 42px;
  object-fit: contain;
}

.verified-result-initials {
  display: grid;
  place-items: center;
  width: 50px;
  height: 50px;
  border-radius: 8px;
  background: var(--race-primary);
  color: var(--race-on-primary);
  font-size: 17px;
  font-weight: 950;
}

.verified-result-copy {
  min-width: 0;
}

.verified-result-title-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
}

.verified-result-title-row strong {
  min-width: 0;
  font-size: 16px;
  line-height: 1.2;
  overflow-wrap: anywhere;
}

.verified-result-category {
  flex: 0 0 auto;
  max-width: 100%;
  padding: 3px 7px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--race-secondary) 72%, #fff);
  color: color-mix(in srgb, var(--race-primary) 70%, var(--ink));
  font-size: 11px;
  font-weight: 900;
  text-transform: uppercase;
}

.verified-result-actions {
  grid-column: 2;
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  align-items: center;
}

.verified-result-link.primary {
  background: var(--race-primary);
  border-color: var(--race-primary);
  color: var(--race-on-primary);
}

.verified-result-link.secondary {
  background: #fff;
  border-color: color-mix(in srgb, var(--race-primary) 35%, var(--line));
  color: color-mix(in srgb, var(--race-primary) 78%, var(--ink));
}

.verified-result-item p {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 13px;
  overflow-wrap: anywhere;
}

.verified-result-note {
  font-weight: 750;
}

.status-badge {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  margin-left: 6px;
  padding: 2px 7px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 900;
  text-transform: uppercase;
}

.verified-badge {
  background: var(--accent-soft);
  color: var(--accent-dark);
}

.pending-badge {
  background: #fff4d7;
  color: #7a4a00;
}

.ok-badge {
  background: #dff3ea;
  color: #0f5b47;
}

.danger-badge {
  background: #ffe2de;
  color: #9b1c11;
}

.turnstile-field {
  display: grid;
  gap: 6px;
}

.readonly-notice {
  margin-bottom: 14px;
}

.view-header h2 {
  margin: 0;
  font-size: 32px;
  line-height: 1.08;
  letter-spacing: 0;
  color: #fff;
}

.view-header p {
  margin: 5px 0 0;
  color: rgba(255, 255, 255, 0.76);
  max-width: 850px;
}

.section-heading {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-width: 0;
  max-width: 100%;
}

.panel-header > .section-heading,
.collapsible-summary > .section-heading {
  margin-right: auto;
}

.section-heading h2,
.section-heading h3,
.section-heading h4,
.section-heading strong {
  min-width: 0;
  overflow-wrap: anywhere;
}

.section-info {
  position: relative;
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  justify-content: center;
  width: 19px;
  height: 19px;
  color: var(--accent);
  cursor: help;
  outline: none;
}

.section-info-mark {
  display: grid;
  place-items: center;
  width: 17px;
  height: 17px;
  border: 1.5px solid currentColor;
  border-radius: 999px;
  background: #fff;
  font-size: 11px;
  font-weight: 900;
  line-height: 1;
  font-family: Georgia, "Times New Roman", serif;
}

.section-info-tooltip {
  position: absolute;
  left: 0;
  top: calc(100% + 8px);
  width: min(320px, calc(100vw - 44px));
  padding: 10px 11px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  box-shadow: var(--shadow);
  font-family: inherit;
  font-size: 12px;
  font-weight: 650;
  line-height: 1.35;
  text-align: left;
  text-transform: none;
  letter-spacing: 0;
  opacity: 0;
  pointer-events: none;
  transform: translateY(-2px);
  transition: opacity 120ms ease, transform 120ms ease;
  z-index: 40;
}

.section-info:hover .section-info-tooltip,
.section-info:focus .section-info-tooltip,
.section-info:focus-within .section-info-tooltip {
  opacity: 1;
  transform: translateY(0);
}

.section-info:focus-visible .section-info-mark {
  outline: 3px solid color-mix(in srgb, var(--accent) 24%, transparent);
  outline-offset: 2px;
}

.view-header .section-info {
  color: #fff;
}

.view-header .section-info-mark {
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(255, 255, 255, 0.88);
}

.view-header .section-info-tooltip {
  border-color: rgba(13, 45, 38, 0.22);
}

.action-row,
.inline-actions,
.form-row,
.toolbar {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

.toolbar {
  margin-bottom: 14px;
  justify-content: space-between;
}

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

.span-12 { grid-column: span 12; }
.span-9 { grid-column: span 9; }
.span-8 { grid-column: span 8; }
.span-7 { grid-column: span 7; }
.span-6 { grid-column: span 6; }
.span-5 { grid-column: span 5; }
.span-4 { grid-column: span 4; }
.span-3 { grid-column: span 3; }
.span-2 { grid-column: span 2; }

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  overflow: hidden;
}

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

.danger-zone {
  border-color: rgba(180, 0, 101, 0.32);
  background: #fff;
}

.danger-zone .panel-header {
  background: var(--danger-soft);
}

.danger-zone .panel-body {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.danger-zone .hint {
  max-width: 760px;
}

.collapsed-tools {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  background: #fff;
}

.collapsed-tools > div {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.panel-header {
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  background: #fff;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.panel-header h3 {
  margin: 0;
  font-size: 16px;
  letter-spacing: 0;
  color: var(--ink);
}

.panel-body {
  padding: 16px;
}

.collapsible-section {
  overflow: hidden;
}

.collapsible-section > summary {
  list-style: none;
  cursor: pointer;
}

.collapsible-section > summary::-webkit-details-marker {
  display: none;
}

.collapsible-summary {
  user-select: none;
}

.collapsible-summary:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--accent) 35%, transparent);
  outline-offset: -3px;
}

.summary-side {
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  min-width: 0;
  margin-left: auto;
}

.summary-side .hint {
  text-align: right;
}

.collapse-indicator {
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  position: relative;
  background: #fff;
}

.collapse-indicator::before {
  content: "";
  position: absolute;
  left: 5px;
  top: 4px;
  width: 6px;
  height: 6px;
  border-right: 2px solid var(--muted);
  border-bottom: 2px solid var(--muted);
  transform: rotate(45deg);
  transition: transform 0.16s ease;
}

.collapsible-section[open] .collapse-indicator::before {
  top: 6px;
  transform: rotate(225deg);
}

.section-tools {
  margin-bottom: 12px;
}

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

.field {
  display: flex;
  flex-direction: column;
  gap: 5px;
  min-width: 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 850;
  text-transform: uppercase;
  letter-spacing: 0;
}

.field-help {
  color: var(--muted);
  font-size: 11px;
  font-weight: 650;
  line-height: 1.25;
  text-transform: none;
}

.field-action {
  align-self: end;
  min-width: 0;
}

.compact-field {
  width: 112px;
  max-width: 100%;
}

.start-time-tools {
  display: grid;
  gap: 8px;
  margin-bottom: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-alt);
}

.start-time-tool-grid {
  display: grid;
  grid-template-columns: minmax(190px, 1.35fr) minmax(130px, 0.9fr) minmax(160px, 1.05fr) minmax(240px, 1.8fr) auto;
  gap: 10px;
  align-items: end;
}

.start-interval-field > span {
  display: block;
}

.interval-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  min-width: 0;
}

.interval-buttons button {
  min-width: 58px;
}

.color-row {
  display: grid;
  grid-template-columns: 56px minmax(0, 1fr);
  gap: 8px;
  align-items: center;
}

.color-row input[type="color"] {
  min-width: 56px;
  padding: 4px;
}

.sponsor-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

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

.logo-upload {
  display: grid;
  gap: 8px;
  min-width: 0;
}

.sponsor-preview {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 54px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  color: var(--muted);
  text-transform: none;
  font-weight: 600;
  font-size: 13px;
}

.sponsor-preview img {
  width: 72px;
  height: 38px;
  object-fit: contain;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 5px;
}

input,
select,
textarea {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  min-height: 38px;
  border: 2px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  padding: 8px 10px;
}

textarea {
  min-height: 90px;
  resize: vertical;
}

input[type="checkbox"] {
  width: 18px;
  min-height: 18px;
  padding: 0;
}

.checkbox {
  display: flex;
  align-items: center;
  gap: 9px;
  color: var(--ink);
  font-weight: 700;
  text-transform: none;
  font-size: 14px;
}

.stage-feature-group {
  display: grid;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-alt);
}

.stage-feature-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}

.stage-feature-heading strong {
  font-size: 13px;
  text-transform: uppercase;
}

.stage-feature-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.stage-feature-toggle {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 10px;
  align-items: start;
  min-width: 0;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.stage-feature-toggle strong,
.stage-feature-toggle small {
  display: block;
}

.stage-feature-toggle strong {
  font-size: 14px;
}

.stage-feature-toggle small {
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
}

.stage-lap-settings {
  display: grid;
  grid-template-columns: minmax(140px, 1fr) minmax(180px, 1.2fr);
  gap: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.stage-lap-help {
  grid-column: 1 / -1;
  margin: -3px 0 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
}

.hint {
  color: var(--muted);
  font-size: 13px;
  overflow-wrap: anywhere;
}

.classification-note {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.preference-preview {
  display: grid;
  gap: 8px;
  margin: 0;
}

.preference-preview div {
  display: grid;
  grid-template-columns: minmax(96px, 0.8fr) minmax(0, 1fr);
  gap: 10px;
  align-items: baseline;
  padding: 8px 0;
  border-bottom: 1px solid var(--line);
}

.preference-preview div:last-child {
  border-bottom: 0;
}

.preference-preview dt {
  color: var(--muted);
  font-size: 12px;
  font-weight: 850;
  text-transform: uppercase;
}

.preference-preview dd {
  margin: 0;
  min-width: 0;
  overflow-wrap: anywhere;
  font-weight: 750;
}

.audit-log-table table {
  min-width: 820px;
}

.audit-actor,
.audit-action {
  white-space: normal;
  overflow-wrap: anywhere;
}

.badge {
  display: inline-flex;
  align-items: center;
  max-width: 100%;
  min-height: 24px;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--ink);
  font-size: 12px;
  font-weight: 850;
  letter-spacing: 0;
  text-transform: uppercase;
  white-space: normal;
  overflow-wrap: anywhere;
  line-height: 1.2;
}

.badge.warn {
  color: var(--warn);
  background: #f7eadc;
}

.badge.danger {
  color: var(--danger);
  background: var(--danger-soft);
}

.badge.muted {
  color: var(--muted);
  background: #edf1ee;
}

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

.stat {
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: 8px;
  padding: 14px;
  position: relative;
  box-shadow: var(--shadow);
}

.stat strong {
  display: block;
  font-size: 24px;
  color: var(--ink);
}

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

.publish-status-grid .stat strong {
  font-size: 19px;
  line-height: 1.2;
}

.publish-status-grid .stat span {
  display: block;
  margin-top: 4px;
}

.stat-help {
  cursor: help;
}

.stat-tooltip {
  position: absolute;
  right: 0;
  bottom: calc(100% + 10px);
  width: min(340px, 82vw);
  padding: 12px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  box-shadow: var(--shadow);
  opacity: 0;
  pointer-events: none;
  transform: translateY(4px);
  transition: opacity 120ms ease, transform 120ms ease;
  z-index: 10;
  font-size: 13px;
}

.stat-tooltip strong {
  font-size: 13px;
}

.stat-tooltip ul {
  margin: 8px 0 0;
  padding-left: 18px;
}

.stat-tooltip p {
  margin: 6px 0 0;
  color: var(--muted);
}

.stat-help:hover .stat-tooltip,
.stat-help:focus .stat-tooltip,
.stat-help:focus-within .stat-tooltip {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}

.table-wrap {
  width: 100%;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 780px;
}

.gc-table table {
  min-width: 0;
  table-layout: fixed;
}

.gc-table th,
.gc-table td {
  padding-left: 6px;
  padding-right: 6px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.gc-table .pos-col {
  width: 42px;
}

.gc-table .bib-col {
  width: 44px;
}

.gc-table .nation-col {
  width: 58px;
}

.gc-table .time-col {
  width: 82px;
}

.gc-table .gap-col {
  width: 64px;
}

.team-car-table table {
  min-width: 860px;
}

.team-car-table tr.no-car-row td {
  background: #f5f7f5;
  color: var(--muted);
}

.team-car-draw-panel {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 0 0 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fbf9;
}

.team-car-draw-panel.active {
  display: grid;
  gap: 12px;
  align-items: stretch;
  border-left: 4px solid var(--primary);
}

.team-car-draw-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.team-car-draw-order {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 6px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.team-car-draw-order li {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.team-car-draw-order li strong {
  display: inline-grid;
  place-items: center;
  min-width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
}

.team-car-draw-buttons {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 8px;
}

.team-car-draw-buttons button {
  justify-content: space-between;
  min-height: 48px;
  text-align: left;
}

.team-car-draw-buttons button span {
  display: block;
  color: inherit;
  font-size: 12px;
  font-weight: 700;
  opacity: 0.8;
}

.small-empty {
  padding: 10px;
}

.compact-checkbox {
  white-space: nowrap;
}

.team-band-table table {
  min-width: 620px;
}

.bib-order-panel,
.mix-group-panel {
  margin-top: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: #fff;
}

.inner-header {
  border-bottom: 1px solid var(--line);
  box-shadow: none;
}

.bib-order-list {
  display: grid;
  gap: 10px;
  padding: 12px;
}

.mix-group-panel > .hint {
  margin: 0;
  padding: 12px;
}

.mix-group-panel > .table-wrap {
  margin: 12px;
}

.bib-order-team {
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: var(--surface);
}

.bib-order-team-head,
.bib-order-rider {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-width: 0;
}

.bib-order-team-head {
  padding: 10px 12px;
  background: var(--surface-alt);
  border-bottom: 1px solid var(--line);
}

.bib-order-team-head > div:first-child,
.bib-order-rider > span {
  min-width: 0;
  overflow-wrap: anywhere;
}

.bib-order-team-head strong {
  display: block;
}

.bib-order-riders {
  display: grid;
}

.bib-order-rider {
  padding: 8px 12px;
  border-bottom: 1px solid var(--line);
}

.bib-order-rider:last-child {
  border-bottom: 0;
}

.compact-actions {
  gap: 6px;
  justify-content: flex-end;
  margin: 0;
}

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 8px 9px;
  text-align: left;
  vertical-align: middle;
  overflow-wrap: anywhere;
}

th {
  background: #f4f4ef;
  color: var(--ink);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0;
  position: sticky;
  top: 0;
  z-index: 1;
}

tr:last-child td {
  border-bottom: 0;
}

td.num,
th.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.time-with-speed {
  display: inline-flex;
  align-items: baseline;
  justify-content: flex-end;
  gap: 6px;
  max-width: 100%;
  white-space: nowrap;
}

.time-speed {
  color: var(--muted);
  font-size: 0.82em;
  font-weight: 800;
  white-space: nowrap;
}

.table-input {
  min-width: 86px;
  min-height: 32px;
  padding: 5px 7px;
  border-radius: 6px;
}

.table-input.short {
  width: 72px;
  min-width: 72px;
}

.table-input.name {
  min-width: 118px;
}

.table-input.input-warning {
  border-color: var(--warn);
  background: #fff7ed;
}

tr.row-warning td {
  background: #fffaf3;
}

tr.reserve-row td {
  background: #f6faf8;
}

tr.reserve-row .status-note {
  color: var(--primary);
}

tr.dns-row td,
tr.dns-row input.table-input,
tr.withdrawn-row td,
tr.withdrawn-row input.table-input {
  color: var(--muted);
  text-decoration: line-through;
}

tr.dns-row input.table-input,
tr.withdrawn-row input.table-input {
  background: #f3f5f3;
}

tr.dns-row button,
tr.withdrawn-row button,
tr.withdrawn-row .status-note {
  text-decoration: none;
}

.status-note {
  color: var(--warn);
  font-weight: 800;
  white-space: nowrap;
}

.start-check {
  display: grid;
  gap: 8px;
  margin-bottom: 12px;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #fff;
}

.start-check.ok {
  border-color: var(--line-strong);
  background: #f4fff1;
}

.start-check.warning {
  border-color: #efc08b;
  background: #fff7ed;
}

.start-check strong {
  font-size: 13px;
}

.readiness-summary {
  display: grid;
  gap: 10px;
  margin-bottom: 12px;
}

.readiness-summary strong {
  display: block;
  font-size: 22px;
}

.readiness-summary span {
  color: var(--muted);
  font-weight: 700;
}

.readiness-meter {
  height: 10px;
  overflow: hidden;
  border-radius: 999px;
  background: #e9eee8;
}

.readiness-meter span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--accent);
}

.readiness-next {
  margin-bottom: 12px;
  padding: 10px 12px;
  border-left: 4px solid var(--warn);
  border-radius: 0 8px 8px 0;
  background: #fff7ed;
}

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

.readiness-list-compact {
  gap: 8px;
  padding-top: 10px;
}

.readiness-section {
  display: grid;
  gap: 8px;
}

.readiness-section h4 {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.readiness-item {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: start;
  gap: 10px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.readiness-collapsed-list {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  overflow: hidden;
}

.readiness-collapsed-list summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  cursor: pointer;
  color: var(--ink);
  font-weight: 900;
}

.readiness-collapsed-list summary strong {
  display: inline-grid;
  place-items: center;
  min-width: 28px;
  height: 26px;
  padding: 0 8px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--ink);
  font-size: 12px;
}

.readiness-collapsed-list .readiness-list {
  padding: 0 10px 10px;
}

.readiness-section-label {
  color: var(--muted);
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.readiness-list-compact .readiness-item {
  box-shadow: none;
}

.readiness-item strong,
.readiness-item span {
  display: block;
}

.readiness-item > div > span {
  color: var(--muted);
  font-size: 13px;
}

.readiness-badge {
  min-width: 64px;
  border-radius: 999px;
  padding: 4px 8px;
  background: #eef2ed;
  color: var(--muted);
  font-size: 11px;
  font-weight: 900;
  text-align: center;
  text-transform: uppercase;
}

.readiness-item.done .readiness-badge {
  background: var(--accent-soft);
  color: var(--ink);
}

.readiness-item.todo .readiness-badge,
.readiness-item.warning .readiness-badge {
  background: #fff0dc;
  color: var(--warn);
}

.readiness-item.optional .readiness-badge {
  background: #f3f5f3;
}

.empty {
  padding: 24px;
  border: 1px dashed var(--line-strong);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.8);
  color: var(--muted);
}

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

.stage-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.stage-card summary {
  cursor: pointer;
  padding: 12px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.stage-card summary::-webkit-details-marker {
  display: none;
}

.summary-title {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  flex: 1 1 260px;
}

.summary-title strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.stage-editor {
  padding: 0 14px 14px;
  border-top: 1px solid var(--line);
}

.chip-list {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  max-width: 100%;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 4px 8px;
  background: #fff;
  font-size: 13px;
  white-space: normal;
  overflow-wrap: anywhere;
  line-height: 1.2;
}

.chip button {
  border: 0;
  min-height: 20px;
  padding: 0 3px;
  background: transparent;
  color: var(--danger);
  flex: 0 0 auto;
}

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

.notice-item {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fff;
}

.notice-item h4 {
  margin: 0 0 4px;
}

.notice-meta {
  color: var(--muted);
  font-size: 13px;
  margin-bottom: 6px;
}

.server-status {
  margin: 0 0 12px;
  color: var(--muted);
  font-weight: 700;
}

.server-card {
  display: grid;
  gap: 5px;
  margin: 12px 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.server-card p {
  margin: 0;
}

.race-lookup-panel {
  width: min(720px, calc(100vw - 32px));
}

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

.race-lookup-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.race-lookup-item p {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 13px;
}

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

.race-request-item {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.race-request-item p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
  overflow-wrap: anywhere;
}

.admin-race-item {
  align-items: start;
}

.admin-request-item {
  align-items: start;
}

.admin-race-item button {
  justify-self: end;
}

.admin-race-actions {
  display: grid;
  gap: 8px;
  justify-items: end;
}

.admin-user-card {
  grid-template-columns: minmax(0, 1fr);
}

.admin-user-actions {
  display: grid;
  grid-template-columns: minmax(140px, 1fr) minmax(120px, 160px) auto auto;
  gap: 8px;
  align-items: end;
}

.server-pin-box {
  display: grid;
  grid-template-columns: minmax(160px, 240px) minmax(0, 1fr);
  gap: 12px;
  align-items: end;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-alt);
}

.server-pin-intro {
  grid-column: 1 / -1;
  max-width: 760px;
}

.server-pin-box strong {
  display: block;
  margin-bottom: 3px;
}

.server-pin-box .hint,
.server-pin-box .server-status {
  margin: 0;
}

.server-pin-box .server-status {
  grid-column: 1 / -1;
}

.published-result-box {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: end;
  padding-top: 4px;
}

.published-result-box .field {
  min-width: 0;
}

.published-result-box .inline-actions {
  align-self: end;
}

.more-grid {
  align-items: stretch;
}

.more-tool-card .panel-body {
  display: grid;
  gap: 12px;
  align-content: space-between;
}

.more-tool-card p {
  margin: 0;
  color: var(--muted);
}

.team-contact-table table {
  min-width: 900px;
}

.team-contact-table th:nth-child(3),
.team-contact-table td:nth-child(3) {
  width: 70px;
  text-align: right;
}

.team-contact-table input {
  min-width: 150px;
}

.qr-preview {
  grid-column: 1 / -1;
  width: 148px;
  height: 148px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  padding: 8px;
}

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

.plain-list li {
  margin-bottom: 6px;
}

.report-preview {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  max-height: 680px;
  overflow: auto;
}

.social-preview-wrap {
  display: grid;
  place-items: center;
  min-width: 0;
  padding: 18px;
  background: #f7faf8;
}

.social-preview-frame {
  position: relative;
  display: grid;
  gap: 14px;
  width: min(380px, 100%);
  aspect-ratio: 4 / 5;
  padding: 24px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 18px 45px rgba(7, 7, 7, 0.12);
}

.social-preview-frame.story {
  width: min(320px, 100%);
  aspect-ratio: 9 / 16;
}

.social-preview-topline {
  position: absolute;
  inset: 0 0 auto;
  height: 6px;
  background: var(--preview-accent);
}

.social-preview-header {
  display: grid;
  gap: 4px;
  min-width: 0;
  padding-top: 8px;
}

.social-preview-header span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 850;
  text-transform: uppercase;
}

.social-preview-header strong {
  min-width: 0;
  color: var(--preview-accent);
  font-size: clamp(24px, 6vw, 34px);
  line-height: 1.02;
  overflow-wrap: anywhere;
}

.social-preview-header em {
  color: var(--muted);
  font-size: 12px;
  font-style: normal;
  overflow-wrap: anywhere;
}

.social-preview-list {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.social-preview-list li {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr) minmax(70px, auto);
  gap: 2px 10px;
  align-items: center;
  min-width: 0;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.social-preview-list li span {
  grid-row: 1 / 4;
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: var(--preview-soft);
  color: var(--preview-accent);
  font-weight: 900;
  line-height: 1;
}

.social-preview-list li strong,
.social-preview-list li small,
.social-preview-list li em {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.social-preview-list li small,
.social-preview-list li em {
  color: var(--muted);
  font-size: 11px;
}

.social-preview-list li b {
  grid-column: 3 / 4;
  grid-row: 1 / 4;
  justify-self: end;
  max-width: 120px;
  overflow-wrap: anywhere;
  text-align: right;
  font-size: 15px;
  line-height: 1.1;
}

.social-preview-list li em {
  font-style: normal;
}

:root[data-theme="dark"] button.primary,
:root[data-theme="dark"] .download-button.primary,
:root[data-theme="dark"] .brand-mark,
:root[data-theme="dark"] .category-toggle button.active,
:root[data-theme="dark"] .tabs button.active {
  color: #07100b;
}

:root[data-theme="dark"] button.secondary,
:root[data-theme="dark"] .file-button.secondary,
:root[data-theme="dark"] .download-button.secondary,
:root[data-theme="dark"] .small-button {
  background: var(--surface-alt);
  color: var(--ink);
}

:root[data-theme="dark"] input,
:root[data-theme="dark"] select,
:root[data-theme="dark"] textarea {
  background: #0c1511;
  color: var(--ink);
  border-color: var(--line-strong);
}

:root[data-theme="dark"] input::placeholder,
:root[data-theme="dark"] textarea::placeholder {
  color: #7f8c84;
}

:root[data-theme="dark"] .topbar {
  background: rgba(4, 7, 6, 0.96);
}

:root[data-theme="dark"] .tabs {
  background: rgba(14, 20, 17, 0.96);
}

:root[data-theme="dark"] .tabs button.active {
  background: var(--accent);
}

:root[data-theme="dark"] .view-header {
  background: #0b100d;
}

:root[data-theme="dark"] .panel-header,
:root[data-theme="dark"] .stat-tooltip,
:root[data-theme="dark"] .section-info-tooltip,
:root[data-theme="dark"] .collapsed-tools,
:root[data-theme="dark"] .danger-zone,
:root[data-theme="dark"] .table-wrap,
:root[data-theme="dark"] .bib-order-panel,
:root[data-theme="dark"] .mix-group-panel,
:root[data-theme="dark"] .stage-card,
:root[data-theme="dark"] .stage-feature-toggle,
:root[data-theme="dark"] .sponsor-preview,
:root[data-theme="dark"] .chip,
:root[data-theme="dark"] .notice-item,
:root[data-theme="dark"] .server-card,
:root[data-theme="dark"] .assigned-race-card,
:root[data-theme="dark"] .rider-import-table-wrap,
:root[data-theme="dark"] .race-lookup-item,
:root[data-theme="dark"] .race-request-item,
:root[data-theme="dark"] .verified-result-item,
:root[data-theme="dark"] .readiness-item,
:root[data-theme="dark"] .start-check,
:root[data-theme="dark"] .report-preview,
:root[data-theme="dark"] .modal-panel {
  background: var(--surface);
  color: var(--ink);
}

:root[data-theme="dark"] .verified-result-brand {
  background: color-mix(in srgb, var(--race-secondary) 18%, var(--surface));
}

:root[data-theme="dark"] .verified-result-category {
  background: color-mix(in srgb, var(--race-secondary) 24%, var(--surface));
  color: var(--ink);
}

:root[data-theme="dark"] .stage-feature-group,
:root[data-theme="dark"] .start-time-tools,
:root[data-theme="dark"] .server-pin-box,
:root[data-theme="dark"] .bib-order-team-head,
:root[data-theme="dark"] .social-preview-wrap {
  background: var(--surface-alt);
}

:root[data-theme="dark"] .social-preview-frame,
:root[data-theme="dark"] .social-preview-list li {
  background: #fff;
  color: #14221b;
}

:root[data-theme="dark"] .social-preview-header span,
:root[data-theme="dark"] .social-preview-header em,
:root[data-theme="dark"] .social-preview-list li small {
  color: #5d6a62;
}

:root[data-theme="dark"] th {
  background: #222c25;
}

:root[data-theme="dark"] .badge.warn,
:root[data-theme="dark"] .readiness-item.todo .readiness-badge,
:root[data-theme="dark"] .readiness-item.warning .readiness-badge {
  background: #3b2815;
  color: var(--warn);
}

:root[data-theme="dark"] .badge.danger,
:root[data-theme="dark"] .danger-zone .panel-header {
  background: var(--danger-soft);
  color: #ffbed9;
}

:root[data-theme="dark"] .badge.muted,
:root[data-theme="dark"] .readiness-badge,
:root[data-theme="dark"] .readiness-item.optional .readiness-badge {
  background: #202923;
  color: var(--muted);
}

:root[data-theme="dark"] .readiness-item.done .readiness-badge,
:root[data-theme="dark"] .badge,
:root[data-theme="dark"] button.secondary.active {
  background: var(--accent-soft);
  color: var(--ink);
}

:root[data-theme="dark"] .empty {
  background: rgba(23, 31, 26, 0.82);
}

:root[data-theme="dark"] .start-check.ok,
:root[data-theme="dark"] tr.reserve-row td {
  background: #132415;
}

:root[data-theme="dark"] .start-check.warning,
:root[data-theme="dark"] .readiness-next,
:root[data-theme="dark"] tr.row-warning td,
:root[data-theme="dark"] .table-input.input-warning {
  background: #2d2114;
  border-color: rgba(242, 184, 107, 0.58);
}

:root[data-theme="dark"] tr.dns-row input.table-input,
:root[data-theme="dark"] tr.withdrawn-row input.table-input,
:root[data-theme="dark"] tr.no-car-row td {
  background: #101813;
}

:root[data-theme="dark"] .readiness-meter {
  background: #263027;
}

:root[data-theme="dark"] .modal-backdrop {
  background: rgba(0, 0, 0, 0.58);
}

:root[data-theme="dark"] .section-info-mark {
  background: var(--surface-alt);
}

:root[data-theme="dark"] .view-header .section-info-mark {
  background: rgba(255, 255, 255, 0.1);
}

:root[data-theme="dark"] .site-footer a:hover {
  color: var(--accent);
}

.print-page {
  --print-primary: #111111;
  --print-secondary: #efefef;
  width: 210mm;
  min-height: 297mm;
  margin: 0 auto 14px;
  padding: 13mm;
  background: #fff !important;
  color: #111;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
}

.print-header {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  position: relative;
  border-bottom: 1px solid #222;
  padding: 9px 0 8px;
  margin-bottom: 10px;
  background: #fff;
}

.print-header::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  width: 44mm;
  height: 2px;
  background: linear-gradient(90deg, var(--print-primary) 0 24mm, var(--print-secondary) 24mm 100%);
  z-index: 0;
}

.print-header > * {
  position: relative;
  z-index: 1;
}

.print-header h1,
.print-section h2 {
  margin: 0;
  letter-spacing: 0;
}

.print-header h1 {
  font-size: 20px;
  color: var(--print-primary);
}

.print-sponsor {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 4px;
  color: #111;
  font-size: 10px;
  font-weight: 700;
  background: #fff;
}

.print-sponsor img {
  max-width: 30mm;
  max-height: 13mm;
  object-fit: contain;
  background: #fff;
}

.print-header p,
.print-meta,
.print-footer {
  margin: 2px 0 0;
  font-size: 10px;
  color: #444;
}

.print-section {
  margin: 0 0 12px;
}

.print-section h2 {
  font-size: 13px;
  text-transform: uppercase;
  color: #111;
  border-bottom: 1px solid #b8b8b8;
  padding: 0 0 3px;
  margin-bottom: 6px;
  background: #fff;
}

.print-section table {
  min-width: 0;
  font-size: 10px;
  table-layout: fixed;
  break-inside: auto;
  page-break-inside: auto;
}

.print-section th,
.print-section td {
  padding: 3px 4px;
  border-bottom: 1px solid #d7d7d7;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.print-section th {
  background: #f4f4f4;
  color: #111;
  border-bottom-color: #cfcfcf;
  position: static;
}

.signon-table th,
.signon-table td {
  vertical-align: top;
}

.signon-table td {
  height: 11mm;
}

.signon-manager-table td {
  height: 14mm;
}

.signon-count {
  display: inline-block;
  margin-top: 2px;
  color: #555;
  font-size: 0.88em;
  font-weight: 700;
}

.signon-blank {
  background: #fff;
}

.signon-signature {
  min-width: 34mm;
}

.print-section .time-with-speed {
  gap: 4px;
}

.print-section .time-speed {
  color: #555;
  font-size: 0.9em;
  font-weight: 700;
}

.compact-start-list {
  margin-bottom: 6px;
}

.compact-start-list > .print-meta {
  margin-bottom: 5px;
}

.compact-team-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 5px 7px;
  align-items: start;
}

.compact-team-card {
  border: 1px solid #d3d9d5;
  border-left: 2px solid var(--print-primary);
  break-inside: avoid;
  page-break-inside: avoid;
  background: #fff;
}

.compact-team-card h3,
.compact-individuals h3 {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 6px;
  margin: 0;
  padding: 3px 4px;
  background: #f4f7f5;
  color: #111;
  font-size: 9.5px;
  line-height: 1.15;
  border-bottom: 1px solid #d9dfdb;
}

.compact-team-card h3 small,
.compact-individuals h3 small {
  color: #555;
  font-size: 8px;
  font-weight: 700;
  text-align: right;
}

.compact-rider-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.compact-rider-list li {
  display: grid;
  grid-template-columns: 12mm minmax(0, 1.05fr) minmax(0, 1fr);
  gap: 3px;
  align-items: start;
  padding: 2px 4px;
  border-top: 1px solid #e5e9e6;
  font-size: 8.7px;
  line-height: 1.18;
  break-inside: avoid;
  page-break-inside: avoid;
}

.compact-rider-list li:first-child {
  border-top: 0;
}

.compact-bib {
  font-weight: 900;
  color: #111;
}

.compact-rider-name {
  min-width: 0;
  font-weight: 800;
  color: #111;
  overflow-wrap: anywhere;
}

.compact-rider-meta {
  min-width: 0;
  color: #555;
  font-size: 8px;
  font-weight: 700;
  overflow-wrap: anywhere;
}

.compact-rider-list li.withdrawn-row span {
  color: #777;
  text-decoration: line-through;
}

.compact-rider-list li.reserve-row {
  background: #f7fbf9;
}

.compact-rider-list li.reserve-row .compact-rider-meta {
  color: var(--print-primary);
}

.compact-individuals {
  margin-top: 6px;
  border: 1px solid #d3d9d5;
  break-inside: avoid;
  page-break-inside: avoid;
}

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

.individual-list li {
  border-top: 1px solid #e5e9e6;
}

.compact-start-count {
  margin-top: 5px;
  font-weight: 700;
}

.tt-start-order {
  margin-bottom: 6px;
}

.tt-start-table th,
.tt-start-table td {
  vertical-align: top;
}

.tt-start-table .tt-start-time {
  color: #111;
  font-weight: 900;
  white-space: nowrap;
}

.tt-start-table .tt-start-bib {
  color: #111;
  font-weight: 900;
}

.tt-start-table .tt-start-rider {
  min-width: 0;
  color: #111;
  font-weight: 800;
  overflow-wrap: anywhere;
}

.tt-start-table .tt-start-note {
  color: #555;
  font-weight: 700;
}

.tt-start-table tr.reserve-row .tt-start-note {
  color: var(--print-primary);
}

.print-section h2,
.print-section h3 {
  break-after: avoid;
  page-break-after: avoid;
}

.print-footer {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  border-top: 1px solid #999;
  padding-top: 4px;
  margin-top: 10px;
  font-weight: 700;
}

.warning-list {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.warning-list li {
  border-left: 4px solid var(--warn);
  background: #fff7ed;
  padding: 8px 10px;
  border-radius: 0 7px 7px 0;
}

.two-column {
  columns: 2 260px;
  column-gap: 20px;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 20px;
}

.modal[hidden] {
  display: none !important;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(20, 30, 25, 0.36);
}

.modal-panel {
  position: relative;
  width: min(460px, calc(100vw - 32px));
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  box-shadow: 0 22px 60px rgba(18, 34, 27, 0.22);
  overflow: hidden;
}

.export-option {
  margin: 14px 0 18px;
}

.modal-actions {
  justify-content: flex-end;
}

.backup-panel {
  width: min(620px, calc(100vw - 32px));
}

.backup-panel .download-button {
  width: 100%;
  margin-bottom: 10px;
}

.backup-panel .backup-json {
  min-height: 160px;
  margin: 10px 0 16px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
  text-transform: none;
  letter-spacing: 0;
}

@media (max-width: 980px) {
  .view-header,
  .toolbar {
    align-items: stretch;
    flex-direction: column;
  }

  .topbar {
    flex-wrap: wrap;
  }

  .category-toggle {
    align-self: flex-start;
  }

  .top-actions {
    justify-content: flex-start;
  }

  .server-pin-box {
    grid-template-columns: 1fr;
    align-items: stretch;
  }

  .published-result-box {
    grid-template-columns: 1fr;
  }

  .race-lookup-item {
    grid-template-columns: 1fr;
    align-items: stretch;
  }

  .assigned-race-card {
    grid-template-columns: 1fr;
    align-items: stretch;
  }

  .assigned-race-actions {
    justify-content: stretch;
  }

  .assigned-race-actions .small {
    width: 100%;
  }

  .grid,
  .form-grid,
  .logo-grid,
  .stage-feature-grid,
  .stage-lap-settings,
  .start-time-tool-grid,
  .stat-grid {
    grid-template-columns: 1fr;
  }

  .stage-feature-heading {
    display: grid;
  }

  .readiness-item {
    grid-template-columns: 1fr;
  }

  .readiness-badge {
    width: max-content;
  }

  .readiness-item button {
    width: 100%;
  }

  .collapsible-summary {
    align-items: flex-start;
  }

  .section-heading {
    align-items: flex-start;
  }

  .summary-side {
    width: 100%;
    margin-left: 0;
    justify-content: space-between;
  }

  .summary-side .hint {
    text-align: left;
  }

  .span-12,
  .span-9,
  .span-8,
  .span-7,
  .span-6,
  .span-5,
  .span-4,
  .span-3,
  .span-2 {
    grid-column: auto;
  }
}

@media (max-width: 760px) {
  .topbar {
    min-height: 58px;
    padding: 10px 12px;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: 9px;
  }

  .brand {
    gap: 10px;
  }

  .brand-mark {
    width: 38px;
    height: 38px;
    font-size: 12px;
    flex: 0 0 auto;
  }

  .brand h1,
  .brand-heading {
    font-size: 16px;
    line-height: 1.15;
    overflow-wrap: anywhere;
  }

  .brand-title-row {
    gap: 5px;
  }

  .alpha-note {
    min-height: 20px;
    padding: 2px 6px;
    font-size: 10px;
  }

  .brand p,
  .brand-subline {
    font-size: 12px;
    line-height: 1.2;
  }

  .brand-subline {
    gap: 4px 5px;
  }

  .server-autosave-pill {
    min-height: 17px;
    padding: 1px 6px;
    font-size: 10px;
  }

  .mobile-menu-toggle {
    display: inline-flex;
    width: auto;
    min-height: 36px;
    padding: 7px 10px;
    border-color: var(--accent);
    background: var(--accent);
    color: var(--ink);
    justify-self: end;
  }

  .topbar .auth-actions {
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: 1fr;
    justify-content: flex-start;
    width: 100%;
    margin-left: 0;
  }

  .header-race-switcher {
    width: 100%;
    max-width: none;
    min-width: 0;
  }

  .header-race-switcher select {
    width: 100%;
  }

  .auth-locked .mobile-menu-toggle,
  .admin-mode .mobile-menu-toggle,
  .onboarding-mode .mobile-menu-toggle {
    display: none;
  }

  .topbar .category-toggle,
  .topbar .top-actions {
    display: none;
    grid-column: 1 / -1;
  }

  #app.mobile-menu-open .topbar .category-toggle {
    display: inline-grid;
    justify-self: start;
  }

  #app.mobile-menu-open .topbar .top-actions {
    display: grid;
    grid-template-columns: 1fr;
    width: 100%;
    gap: 8px;
  }

  #app.mobile-menu-open .topbar .top-actions button,
  #app.mobile-menu-open .topbar .top-actions .file-button {
    width: 100%;
  }

  .tabs {
    display: none;
    position: static;
    top: auto;
    padding: 8px 12px;
    background: #fff;
    flex-wrap: wrap;
    overflow: visible;
    backdrop-filter: none;
  }

  #app.mobile-menu-open .tabs {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 6px;
  }

  .tabs button {
    width: 100%;
    min-height: 38px;
    border: 2px solid var(--line);
    border-radius: 6px;
    background: #fff;
    padding: 8px;
    color: var(--ink);
  }

  .tabs button.active {
    border-color: var(--accent);
    background: var(--accent);
    color: var(--ink);
  }

  .workspace {
    width: calc(100vw - 18px);
    margin-top: 10px;
  }

  .view-header {
    padding: 14px 12px;
  }

  .view-header h2 {
    font-size: 24px;
  }

  .section-info-tooltip {
    width: min(280px, calc(100vw - 32px));
  }

  .admin-user-actions {
    grid-template-columns: 1fr;
  }

  .verified-result-item,
  .race-lookup-item {
    grid-template-columns: 1fr;
  }

  .verified-result-actions {
    grid-column: auto;
  }

  .verified-result-item .download-button,
  .admin-race-actions,
  .admin-race-actions button {
    justify-self: stretch;
    width: 100%;
  }
}

@media (max-width: 620px) {
  .modal {
    padding: 10px;
  }

  .auth-modal-panel {
    width: calc(100vw - 20px);
    max-height: calc(100dvh - 20px);
  }

  .rider-import-panel {
    width: calc(100vw - 12px);
    max-height: calc(100dvh - 12px);
  }

  .rider-import-table-wrap {
    max-height: 62dvh;
  }

  .auth-modal-panel > .panel-header,
  .auth-modal-panel > .panel-body {
    padding-left: 12px;
    padding-right: 12px;
  }

  .forgot-password-box {
    grid-template-columns: 1fr;
  }

  .forgot-password-box button {
    width: 100%;
  }

  .workspace {
    width: calc(100vw - 18px);
    margin-top: 10px;
  }

  .topbar {
    padding: 12px;
  }

  .tabs {
    padding-left: 8px;
    padding-right: 8px;
  }

  .panel-body,
  .panel-header {
    padding: 12px;
  }

  button,
  .file-button {
    width: 100%;
  }

  .inline-actions button,
  .inline-actions .file-button,
  .interval-buttons button,
  .action-row button,
  .action-row .file-button,
  .mobile-menu-toggle,
  .category-toggle button {
    width: auto;
  }

  #mainMenu.tabs button {
    width: 100%;
  }

  .print-page {
    width: 100%;
    min-height: auto;
    padding: 18px;
  }

  .section-info {
    width: 21px;
    height: 21px;
  }
}

@media print {
  @page {
    size: A4;
    margin: 0;
  }

  html {
    margin: 0;
    padding: 0;
  }

  body {
    background: #fff;
    margin: 0;
    padding: 0;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  html,
  #printArea,
  .print-page,
  .print-section,
  .print-header,
  .print-sponsor,
  .print-footer {
    background: #fff !important;
  }

  #app {
    display: none !important;
  }

  .section-info {
    display: none !important;
  }

  #exportDialog {
    display: none !important;
  }

  #printArea {
    display: block !important;
    width: 210mm;
    margin: 0;
    padding: 0;
  }

  .print-page {
    width: 210mm;
    min-height: 297mm;
    padding: 13mm;
    margin: 0;
    box-shadow: none;
    break-after: page;
    -webkit-box-decoration-break: clone;
    box-decoration-break: clone;
  }

  .print-page:last-child {
    break-after: auto;
  }

  .print-mode-startlist {
    padding: 10mm;
  }

  .print-mode-signon {
    padding: 10mm;
  }

  .print-mode-ttstarts {
    padding: 9mm;
  }

  .print-mode-startlist .print-header,
  .print-mode-signon .print-header,
  .print-mode-ttstarts .print-header {
    padding: 6px 0 6px;
    margin-bottom: 6px;
  }

  .print-mode-startlist .print-header h1,
  .print-mode-signon .print-header h1,
  .print-mode-ttstarts .print-header h1 {
    font-size: 17px;
  }

  .print-mode-startlist .print-header p,
  .print-mode-startlist .print-meta,
  .print-mode-signon .print-header p,
  .print-mode-signon .print-meta,
  .print-mode-ttstarts .print-header p,
  .print-mode-ttstarts .print-meta {
    font-size: 8.5px;
  }

  .print-mode-startlist .print-sponsor img,
  .print-mode-signon .print-sponsor img,
  .print-mode-ttstarts .print-sponsor img {
    max-height: 10mm;
  }

  .print-mode-startlist .print-section h2,
  .print-mode-signon .print-section h2,
  .print-mode-ttstarts .print-section h2 {
    font-size: 11px;
    margin-bottom: 4px;
    padding-bottom: 2px;
  }

  .print-mode-startlist .compact-start-count,
  .print-mode-ttstarts .compact-start-count {
    margin: 0 0 4px;
  }

  .print-mode-startlist .compact-team-grid {
    display: block;
    column-count: 2;
    column-gap: 7px;
  }

  .print-mode-startlist .compact-team-card {
    display: block;
    width: 100%;
    margin: 0 0 4px;
    break-inside: auto;
    page-break-inside: auto;
    -webkit-box-decoration-break: clone;
    box-decoration-break: clone;
  }

  .print-mode-startlist .compact-individuals {
    margin-top: 4px;
    break-inside: auto;
    page-break-inside: auto;
    -webkit-box-decoration-break: clone;
    box-decoration-break: clone;
  }

  .print-mode-startlist .individual-list {
    display: block;
    column-count: 2;
    column-gap: 7px;
  }

  .print-mode-startlist .compact-rider-list li {
    padding: 1.8px 3px;
    font-size: 8.3px;
    line-height: 1.12;
  }

  .print-mode-startlist .compact-rider-meta {
    font-size: 7.4px;
  }

  .print-mode-ttstarts .tt-start-table {
    font-size: 7.9px;
  }

  .print-mode-ttstarts .tt-start-table th,
  .print-mode-ttstarts .tt-start-table td {
    padding: 1.8px 3px;
    line-height: 1.15;
  }

  .print-mode-ttstarts .tt-start-note {
    font-size: 7px;
  }

  .print-mode-signon .signon-section + .signon-section {
    break-before: page;
    page-break-before: always;
  }

  .print-mode-signon .signon-table {
    font-size: 8.4px;
  }

  .print-mode-signon .signon-table th,
  .print-mode-signon .signon-table td {
    padding: 2px 3px;
    line-height: 1.15;
  }

  .print-mode-signon .signon-manager-table td {
    height: 10mm;
  }

  .print-mode-signon .signon-rider-table td {
    height: 7.2mm;
  }

  .print-section {
    break-inside: auto;
    page-break-inside: auto;
  }

  .print-section:not(:has(table)) {
    break-inside: avoid;
    page-break-inside: avoid;
  }

  .print-mode-startlist .compact-start-list,
  .print-mode-ttstarts .tt-start-order {
    break-inside: auto;
    page-break-inside: auto;
  }

  .print-section table {
    break-inside: auto;
    page-break-inside: auto;
  }

  .print-section thead {
    display: table-header-group;
  }

  .print-section thead th {
    border-top: 3mm solid #fff;
  }

  .print-section tfoot {
    display: table-footer-group;
  }

  .print-section tr {
    break-inside: avoid;
    page-break-inside: avoid;
  }
}

#printArea {
  display: none;
}
