:root {
  --primary: #0b1f2a;
  --bg: #f5f6f8;
  --panel: #ffffff;
  --text: #101418;
  --muted: #68737d;
  --accent: #ffcc00;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Space Grotesk", system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 24px;
  background: var(--primary);
  color: #fff;
}

.brand {
  display: flex;
  gap: 12px;
  align-items: center;
  font-weight: 600;
}

.brand-link {
  color: #ffffff;
  text-decoration: none;
  display: inline-flex;
  gap: 12px;
  align-items: center;
}

.brand-link:hover {
  text-decoration: underline;
}
.topbar nav a {
  color: #ffffff;
  text-decoration: none;
  margin-left: 12px;
  opacity: 0.9;
  font-weight: 500;
}

.topbar nav a:hover {
  opacity: 1;
  text-decoration: underline;
}

.logo {
  width: 28px;
  height: 28px;
  object-fit: contain;
}

.container {
  padding: 24px;
  flex: 1;
}

.site-footer {
  margin-top: 40px;
  border-top: 1px solid #e6e8eb;
  background: #f9fbfd;
}

.footer-inner {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
  padding: 20px 24px;
  font-size: 14px;
  color: var(--muted);
}

.footer-col {
  display: grid;
  gap: 8px;
}

.footer-col a {
  color: inherit;
  text-decoration: none;
}

.footer-col a:hover {
  color: var(--primary);
  text-decoration: underline;
}

.footer-social,
.footer-links {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.print-mode .topbar,
.print-mode .actions,
.print-mode .tabs,
.print-mode .tabs-mobile,
.print-mode .search,
.print-mode .show-more-bar,
.print-mode .cards,
.print-mode .site-footer {
  display: none !important;
}

.print-mode .table {
  display: table !important;
}

@media (max-width: 900px) {
  .footer-inner {
    grid-template-columns: 1fr;
  }
}

.page-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  position: relative;
  z-index: 50;
  overflow: visible;
}

.actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  position: relative;
  z-index: 10;
  justify-content: flex-end;
}

.actions-menu {
  position: relative;
  display: inline-flex !important;
  z-index: 6;
}

.actions-dropdown {
  position: fixed;
  background: #fff;
  border: 1px solid #e2e6ea;
  border-radius: 10px;
  padding: 8px;
  display: none;
  min-width: 190px;
  box-shadow: 0 8px 24px rgba(15, 23, 32, 0.12);
  z-index: 2000;
  pointer-events: auto;
}

.actions-dropdown.open {
  display: grid;
  gap: 6px;
}

.actions-dropdown .button {
  justify-content: flex-start;
  width: 100%;
}

.print-contest-title {
  margin-top: 6px;
  font-size: 20px;
  font-weight: 600;
  color: #1b2730;
}

.button, button {
  background: var(--primary);
  color: #fff;
  border: none;
  padding: 10px 14px;
  border-radius: 8px;
  text-decoration: none;
  cursor: pointer;
}

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

.button.danger {
  background: #b42318;
  color: #fff;
  border: 1px solid #b42318;
}

.table-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.table-actions form {
  margin: 0;
}

.show-more-bar {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 12px;
  margin: 16px 0 8px;
}

.show-more-info {
  color: var(--muted);
  font-size: 13px;
}

@media (max-width: 900px) {
  .show-more-bar {
    position: sticky;
    bottom: 12px;
    z-index: 6;
  }
  .show-more-bar .button {
    background: var(--primary);
    color: #fff;
  }
}

.table {
  width: 100%;
  border-collapse: collapse;
  background: var(--panel);
  border-radius: 12px;
  overflow: hidden;
}

.table th, .table td {
  padding: 10px 12px;
  border-bottom: 1px solid #e6e8eb;
  text-align: left;
  font-size: 14px;
}

.table th {
  background: #f0f2f5;
  font-weight: 600;
}

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

.stats {
  display: flex;
  gap: 16px;
  margin-bottom: 16px;
}

.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 16px;
}

.sticky {
  position: sticky;
  top: 0;
  background: var(--bg);
  padding: 8px 0;
  z-index: 10;
}

.tab {
  padding: 8px 12px;
  border-radius: 999px;
  background: #e9edf1;
  color: #24313a;
  text-decoration: none;
  font-size: 13px;
}

.tab.active {
  background: var(--primary);
  color: #fff;
  border: 2px solid transparent;
}

.tab.has-match {
  background: #f3f5f7;
  color: #1f1300;
  border: 2px solid #ff9f1a;
}

.tab.active.has-match {
  background: var(--primary);
  color: #fff;
  border-color: #ff9f1a;
  box-shadow: 0 0 0 2px rgba(255,159,26,0.2);
}

.tab .tab-count {
  margin-left: 6px;
  font-size: 12px;
  opacity: 0.8;
}
.search {
  margin-bottom: 16px;
  display: flex;
  gap: 8px;
}

.auto-refresh {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--muted);
  padding: 6px 8px;
  border: 1px solid #d5d9dd;
  border-radius: 8px;
  background: #fff;
}

.search input {
  flex: 1;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid #d5d9dd;
}

.search select {
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid #d5d9dd;
  background: #fff;
}

@media (max-width: 900px) {
  .search {
    flex-wrap: wrap;
  }
  .search input {
    flex: 1 1 100%;
  }
}

.form {
  background: var(--panel);
  padding: 16px;
  border-radius: 12px;
  max-width: 520px;
}

.form.wide {
  max-width: 960px;
}

.form p {
  display: grid;
  gap: 6px;
}

.form input, .form select {
  padding: 8px 10px;
  border: 1px solid #d5d9dd;
  border-radius: 6px;
}

.form-grid {
  display: grid;
  grid-template-columns: 180px 1fr;
  gap: 8px 12px;
  margin-bottom: 12px;
}

.form-grid label {
  font-weight: 600;
  padding-top: 8px;
}

.form-grid .muted {
  grid-column: 2;
  margin-top: -4px;
  margin-bottom: 6px;
}

.form-errors {
  background: #ffeaea;
  color: #8a1f1f;
  border: 1px solid #f5c2c2;
  padding: 10px;
  border-radius: 8px;
  margin-bottom: 12px;
  font-size: 13px;
}

.mapping {
  display: grid;
  gap: 8px;
  margin: 12px 0 16px;
}

.mapping-head,
.mapping-row {
  display: grid;
  grid-template-columns: 40px 1.2fr 2.2fr 0.8fr 0.6fr 0.6fr;
  gap: 8px;
  align-items: center;
}

.mapping-head {
  font-weight: 600;
  color: var(--muted);
}

.mapping-row input[type="text"],
.mapping-row input[type="number"] {
  width: 100%;
}

.stack {
  display: grid;
  gap: 6px;
}

.mapping-row select {
  width: 100%;
}

.drag-handle {
  cursor: grab;
  color: var(--muted);
  font-weight: 600;
  user-select: none;
  text-align: center;
}

.mapping-row.dragging {
  opacity: 0.6;
  background: #f3f5f8;
  border-radius: 8px;
}
.cards {
  display: none;
  gap: 12px;
  margin-top: 16px;
}

.tabs-mobile {
  display: none;
  margin-bottom: 12px;
}

.tabs-mobile select {
  width: 100%;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid #d5d9dd;
  background: #fff;
}

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

@media (max-width: 1200px) {
  .cards-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 700px) {
  .cards-grid {
    grid-template-columns: 1fr;
  }
}

.race-filters {
  display: flex;
  gap: 10px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.race-filters input,
.race-filters select {
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid #d5d9dd;
  background: #fff;
}

.race-filters button {
  background: var(--primary);
  color: #fff;
  border: none;
  padding: 10px 14px;
  border-radius: 8px;
  cursor: pointer;
}

.race-card {
  background: var(--panel);
  border-radius: 14px;
  padding: 0;
  border: 1px solid #e6e8eb;
  text-decoration: none;
  color: var(--text);
  display: grid;
  grid-template-columns: 160px 1fr;
  min-height: 160px;
  overflow: hidden;
}

.race-media {
  height: 100%;
}

.race-image {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.race-image.placeholder {
  background: linear-gradient(135deg, #e6edf3, #f7f9fb);
}

.race-body {
  padding: 14px 16px;
  display: grid;
  gap: 6px;
}

.race-card:hover {
  border-color: var(--primary);
  box-shadow: 0 4px 20px rgba(0,0,0,0.06);
}

.race-title {
  font-size: 18px;
  font-weight: 700;
}

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

.race-location {
  color: #3a4650;
  font-size: 13px;
}

.race-desc {
  color: #2f3b45;
  font-size: 14px;
  min-height: 40px;
  max-height: 48px;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.race-open {
  color: var(--primary);
  font-weight: 600;
  font-size: 13px;
}

@media (max-width: 900px) {
  .race-card {
    grid-template-columns: 96px 1fr;
  }
  .race-card {
    min-height: 120px;
  }
  .card summary strong {
    white-space: normal;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
  }
}

.card {
  background: var(--panel);
  border-radius: 12px;
  padding: 12px;
  border: 1px solid #e6e8eb;
}

.card summary {
  display: grid;
  grid-template-columns: 48px 60px minmax(0, 1fr) 72px;
  gap: 8px;
  cursor: pointer;
  list-style: none;
}

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

.card summary span {
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-size: 13px;
  min-width: 0;
}

.card summary span:last-child {
  align-items: flex-end;
  text-align: right;
}

.card summary strong {
  font-size: 14px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.card summary span:nth-child(3) strong {
  white-space: normal;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.card summary span.is-name strong {
  display: block;
  white-space: normal;
  word-break: break-word;
  overflow: visible;
  text-overflow: clip;
  -webkit-line-clamp: unset;
  -webkit-box-orient: initial;
}

.card summary span.is-name {
  position: relative;
  padding-right: 16px;
}

.card summary span.is-name .yellow-card-badge {
  position: absolute;
  right: 0;
  top: 2px;
}

@media (max-width: 900px) {
  .card summary span.is-name strong {
    line-height: 1.15;
  }
}

.card summary small {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.card summary small {
  color: var(--muted);
}

.card-body {
  margin-top: 10px;
  border-top: 1px solid #e6e8eb;
  padding-top: 8px;
  display: grid;
  gap: 6px;
  font-size: 13px;
}

.card-body .row {
  display: flex;
  justify-content: space-between;
  gap: 8px;
}

.yellow-card-badge {
  display: inline-block;
  width: 12px;
  height: 16px;
  background: #ffcf33;
  border: 1px solid #c99b00;
  border-radius: 2px;
  vertical-align: middle;
}

@media (max-width: 900px) {
  .table { display: none; }
  .cards { display: grid; }
  .tabs { overflow-x: auto; }
  .tabs { display: none; }
  .tabs-mobile { display: block; }
}

@media print {
  body {
    background: #fff;
  }
  .topbar,
  .actions,
  .tabs,
  .tabs-mobile,
  .search,
  .show-more-bar,
  .cards,
  .site-footer {
    display: none !important;
  }
  .table {
    display: table !important;
  }
  .container {
    padding: 0 12px;
  }
  .print-contest-title {
    margin-top: 2px;
    margin-bottom: 10px;
    font-size: 18px;
    color: #000;
  }
}

pre {
  background: #0f1720;
  color: #e6edf3;
  padding: 12px;
  border-radius: 10px;
  overflow-x: auto;
}

code {
  background: #eef2f6;
  padding: 2px 6px;
  border-radius: 6px;
}

pre code {
  background: transparent;
  padding: 0;
}

.csv-log {
  background: var(--panel);
  padding: 12px;
  border-radius: 10px;
  margin-bottom: 16px;
  font-size: 14px;
}

.ops-pill {
  display: inline-block;
  padding: 4px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
}

.ops-pill.ok {
  background: #e9f8ef;
  color: #1f7a3a;
  border: 1px solid #b9e7c8;
}

.ops-pill.warn {
  background: #fff5e8;
  color: #9a5b0b;
  border: 1px solid #ffd6a3;
}

.ops-checklist-text {
  width: 100%;
  margin-top: 12px;
  min-height: 180px;
  display: none;
}
