:root {
  --green-950: #243426;
  --green-900: #30472f;
  --green-800: #39543a;
  --green-700: #5d785f;
  --sage: #8ba38d;
  --sage-soft: #edf3ee;
  --mint: #dfe9e0;
  --gold: #c9a44f;
  --ink: #15231d;
  --muted: #65756e;
  --line: #dce5df;
  --paper: #f7faf7;
  --white: #ffffff;
  --danger: #b43b31;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background: var(--paper);
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
}

.sidebar {
  min-height: 100vh;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 28px;
  color: var(--white);
  background: linear-gradient(180deg, var(--green-950), var(--green-800));
}

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

.brand img {
  width: 48px;
  height: 48px;
  object-fit: contain;
}

.brand strong,
.brand span,
.training-card strong,
.training-card small {
  display: block;
}

.brand span,
.training-card span,
.training-card small,
.eyebrow {
  color: rgba(255, 255, 255, .72);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0;
}

.nav {
  display: grid;
  gap: 8px;
}

.nav-item {
  min-height: 44px;
  border: 1px solid rgba(255, 255, 255, .13);
  border-radius: 8px;
  padding: 0 14px;
  color: var(--white);
  background: rgba(255, 255, 255, .05);
  text-align: left;
  text-decoration: none;
  font-weight: 800;
  font: inherit;
  cursor: pointer;
}

.nav-link {
  display: flex;
  align-items: center;
}

.nav-item.is-active {
  color: var(--green-900);
  background: var(--mint);
}

.training-card {
  margin-top: auto;
  border: 1px solid rgba(255, 255, 255, .18);
  border-radius: 8px;
  padding: 14px;
  background: rgba(255, 255, 255, .07);
}

.training-card strong,
.training-card small {
  margin-top: 6px;
}

.app-shell {
  min-width: 0;
  padding: 28px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 22px;
}

.topbar .eyebrow,
.panel .eyebrow {
  color: var(--green-700);
  margin: 0 0 4px;
  font-weight: 900;
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: 32px;
}

h2 {
  font-size: 20px;
}

.status-pill,
.sync-note {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0 14px;
  color: var(--green-800);
  background: var(--white);
  font-weight: 800;
  white-space: nowrap;
}

.status-pill span {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #23b26d;
}

.sync-note {
  min-height: 30px;
  color: #755615;
  background: rgba(201, 164, 79, .16);
  border: 0;
  font-size: 12px;
  text-transform: uppercase;
}

.view {
  display: none;
}

.view.is-active {
  display: block;
}

.hero-live {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  padding: 24px;
  margin-bottom: 18px;
  border-radius: 8px;
  color: var(--white);
  background: linear-gradient(135deg, var(--green-950), var(--green-700));
  box-shadow: 0 18px 45px rgba(15, 61, 46, .16);
}

.hero-live h2 {
  font-size: 30px;
  margin-bottom: 8px;
}

.hero-live p:not(.eyebrow) {
  margin: 0;
  max-width: 720px;
  color: rgba(255, 255, 255, .78);
  line-height: 1.5;
}

.live-total {
  min-width: 112px;
  border: 1px solid rgba(255, 255, 255, .18);
  border-radius: 8px;
  display: grid;
  place-items: center;
  padding: 14px;
  background: rgba(255, 255, 255, .1);
}

.live-total strong {
  font-size: 34px;
}

.live-total span {
  font-size: 13px;
  font-weight: 800;
}

.panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
  margin-bottom: 18px;
  background: rgba(255, 255, 255, .9);
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 16px;
}

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

label span {
  display: block;
  margin-bottom: 6px;
  color: var(--green-700);
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}

.formula-note {
  margin: 14px 0 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px 14px;
  color: var(--green-800);
  background: var(--sage-soft);
  font-size: 15px;
  font-weight: 900;
  line-height: 1.45;
}

input,
select {
  width: 100%;
  height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--white);
  color: var(--ink);
  padding: 0 12px;
  font: inherit;
  font-weight: 700;
}

input:focus,
select:focus {
  outline: 3px solid rgba(19, 86, 64, .14);
  border-color: var(--green-700);
}

button {
  font: inherit;
}

.primary-action,
.secondary-action,
.validated-action {
  min-height: 46px;
  border: 0;
  border-radius: 8px;
  padding: 0 16px;
  font-weight: 950;
  cursor: pointer;
}

.primary-action {
  color: var(--white);
  border: 1px solid rgba(139, 163, 141, .52);
  background: linear-gradient(180deg, var(--green-800), var(--green-950));
  box-shadow: 0 6px 16px rgba(36, 52, 38, .16);
}

.primary-action:disabled,
.secondary-action:disabled {
  opacity: .42;
  cursor: not-allowed;
}

.primary-action.compact {
  width: 150px;
}

.secondary-action {
  color: var(--green-800);
  background: var(--sage-soft);
}

.danger-action {
  color: var(--danger);
  background: rgba(180, 59, 49, .1);
}

.validated-action {
  color: var(--green-800);
  background: rgba(19, 86, 64, .14);
  cursor: default;
}

.add-player {
  display: flex;
  gap: 10px;
  margin-bottom: 16px;
}

.score-cta {
  width: 100%;
  min-height: 54px;
  margin-top: 16px;
  border: 1px solid rgba(139, 163, 141, .65);
  border-radius: 8px;
  color: var(--white);
  background: linear-gradient(180deg, var(--sage), var(--green-700));
  box-shadow: 0 10px 24px rgba(48, 71, 47, .18);
  font-weight: 950;
  cursor: pointer;
}

.score-cta:disabled {
  opacity: .44;
  cursor: not-allowed;
}

.group-list,
.run-board {
  display: grid;
  gap: 12px;
}

.group-card,
.judge-run-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: #fbfdfb;
}

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

.group-card strong,
.judge-run-card strong {
  display: block;
  font-size: 18px;
}

.group-card span,
.judge-run-card span {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-weight: 700;
}

.order-badge {
  display: inline-grid;
  place-items: center;
  width: 30px;
  height: 30px;
  margin-right: 8px;
  border-radius: 50%;
  color: var(--white);
  background: var(--green-800);
  font-weight: 950;
}

.judge-run-card {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) repeat(3, minmax(130px, 170px)) 130px;
  gap: 12px;
  align-items: stretch;
}

.run-cell {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: var(--white);
}

.run-cell header {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
  font-weight: 900;
}

.run-inputs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.run-cell button {
  width: 100%;
  margin-top: 8px;
}

.run-cell.is-valid {
  border-color: rgba(19, 86, 64, .32);
  background: rgba(19, 86, 64, .06);
}

.run-feedback {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.player-total {
  display: grid;
  align-content: center;
  justify-items: end;
  gap: 8px;
}

.player-total strong {
  color: var(--green-800);
  font-size: 30px;
}

.run-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 52px;
  height: 26px;
  border-radius: 999px;
  padding: 0 10px;
  color: #755615;
  background: rgba(201, 164, 79, .15);
  font-size: 12px;
  font-weight: 950;
}

.run-pill.ready {
  color: var(--green-800);
  background: rgba(19, 86, 64, .12);
}

.podium-grid {
  display: grid;
  grid-template-columns: minmax(0, .9fr) minmax(0, 1.3fr);
  gap: 18px;
}

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

.podium-card {
  min-height: 170px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  background: #fbfdfb;
}

.podium-card.rank-1 {
  border-color: rgba(201, 164, 79, .7);
  background: linear-gradient(180deg, rgba(201, 164, 79, .16), #fbfdfb);
}

.podium-card span {
  display: inline-grid;
  place-items: center;
  min-width: 42px;
  height: 34px;
  border-radius: 999px;
  color: var(--white);
  background: var(--green-800);
  font-weight: 950;
}

.podium-card strong {
  display: block;
  margin-top: 14px;
  font-size: 20px;
}

.podium-card small {
  display: block;
  margin-top: 6px;
  color: var(--muted);
  font-weight: 750;
}

.podium-card b {
  display: block;
  margin-top: 14px;
  color: var(--green-800);
  font-size: 30px;
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 13px 10px;
  text-align: left;
  white-space: nowrap;
}

th {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
}

.empty-row {
  color: var(--muted);
  font-weight: 800;
  text-align: center;
}

@media (max-width: 1120px) {
  body {
    grid-template-columns: 1fr;
  }

  .sidebar {
    min-height: auto;
    padding: 16px;
  }

  .training-card {
    display: none;
  }

  .nav {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .nav-item {
    text-align: center;
  }

  .nav-link {
    justify-content: center;
  }

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

@media (max-width: 760px) {
  .app-shell {
    padding: 18px 10px;
  }

  .topbar,
  .hero-live,
  .panel-head,
  .group-card {
    align-items: stretch;
    flex-direction: column;
  }

  .competition-settings,
  .podium {
    grid-template-columns: 1fr;
  }

  .add-player {
    flex-direction: column;
  }

  .primary-action.compact {
    width: 100%;
  }

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

  h1 {
    font-size: 28px;
  }

  .hero-live h2 {
    font-size: 26px;
  }

  table,
  thead,
  tbody,
  tr,
  th,
  td {
    display: block;
  }

  thead {
    display: none;
  }

  tr {
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 10px;
    margin-bottom: 10px;
    background: #fbfdfb;
  }

  td {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    border: 0;
    padding: 7px 0;
    white-space: normal;
  }

  td::before {
    content: attr(data-label);
    color: var(--muted);
    font-weight: 900;
    text-transform: uppercase;
    font-size: 12px;
  }
}
