:root {
  --bg: #f6f4ef;
  --surface: #ffffff;
  --surface-strong: #eef3ed;
  --ink: #18211f;
  --muted: #66706d;
  --line: #d8ded7;
  --green: #285d46;
  --green-dark: #173f32;
  --gold: #b5812b;
  --blue: #305f86;
  --red: #a94438;
  --shadow: 0 18px 45px rgba(24, 33, 31, 0.08);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

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

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  min-height: 100vh;
  transition: grid-template-columns 180ms ease;
}

.app-shell.sidebar-collapsed {
  grid-template-columns: 0 minmax(0, 1fr);
}

.sidebar {
  background: var(--green-dark);
  color: #f8fbf6;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 28px;
  min-width: 0;
  overflow: hidden;
  transition: opacity 160ms ease, padding 180ms ease, transform 180ms ease;
}

.app-shell.sidebar-collapsed .sidebar {
  opacity: 0;
  padding-left: 0;
  padding-right: 0;
  pointer-events: none;
  transform: translateX(-18px);
}

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

.brand-mark {
  width: 52px;
  height: 52px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  background: #f8fbf6;
  color: var(--green-dark);
  font-weight: 800;
}

.brand-block h1,
.topbar h2,
.section-heading h3,
.panel-heading h4,
.danger-zone h4 {
  margin: 0;
}

.brand-block h1 {
  font-size: 1.08rem;
  line-height: 1.25;
}

.eyebrow {
  margin: 0 0 5px;
  color: inherit;
  opacity: 0.68;
  font-size: 0.76rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0;
}

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

.nav-button {
  border: 1px solid transparent;
  border-radius: 8px;
  color: #f8fbf6;
  background: transparent;
  padding: 12px 14px;
  text-align: left;
}

.nav-button:hover,
.nav-button:focus-visible,
.nav-button.is-active {
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(255, 255, 255, 0.18);
  outline: none;
}

.sidebar-note {
  margin-top: auto;
  border-top: 1px solid rgba(255, 255, 255, 0.18);
  padding-top: 18px;
}

.sidebar-note p,
.sidebar-note span {
  margin: 0;
}

.sidebar-note p {
  font-weight: 800;
}

.sidebar-note span {
  display: block;
  color: rgba(255, 255, 255, 0.72);
  margin-top: 4px;
  font-size: 0.9rem;
}

.workspace {
  padding: 24px;
  min-width: 0;
}

.topbar,
.section-heading,
.panel-heading,
.danger-zone {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.topbar {
  margin-bottom: 22px;
}

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

.topbar h2 {
  font-size: clamp(1.55rem, 2vw, 2.1rem);
}

.sidebar-toggle-button {
  width: 42px;
  height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  display: inline-grid;
  place-items: center;
  gap: 4px;
  padding: 9px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.sidebar-toggle-button span {
  display: block;
  width: 18px;
  height: 2px;
  border-radius: 999px;
  background: var(--green-dark);
}

.sidebar-toggle-button:hover,
.sidebar-toggle-button:focus-visible {
  border-color: var(--green);
  outline: 3px solid rgba(40, 93, 70, 0.15);
}

.topbar-actions,
.button-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.league-switcher {
  display: inline-flex;
  align-items: center;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.league-button {
  min-height: 36px;
  border: 0;
  border-radius: 6px;
  padding: 8px 12px;
  background: transparent;
  color: var(--muted);
  font-weight: 900;
}

.league-button.is-active {
  background: var(--green);
  color: #fff;
}

.league-button:focus-visible {
  outline: 3px solid rgba(40, 93, 70, 0.18);
}

.select-label {
  color: var(--muted);
  font-weight: 700;
}

.view {
  display: none;
}

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

.section-heading {
  margin-bottom: 18px;
}

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

.metric-card,
.panel,
.form-band,
.danger-zone {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.metric-card {
  padding: 18px;
  min-height: 122px;
}

.metric-card span,
.metric-card small,
.panel-heading span,
.helper-text {
  color: var(--muted);
}

.metric-card span {
  display: block;
  font-size: 0.9rem;
  font-weight: 700;
}

.metric-card strong {
  display: block;
  margin-top: 10px;
  font-size: 1.7rem;
  line-height: 1.1;
}

.metric-card small {
  display: block;
  margin-top: 8px;
}

.dashboard-grid,
.email-layout,
.settings-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
}

.panel {
  padding: 18px;
}

.panel-heading {
  margin-bottom: 14px;
}

.panel-heading h4 {
  font-size: 1rem;
}

.panel-copy,
.danger-zone p {
  color: var(--muted);
  line-height: 1.55;
  margin: 0;
}

.form-band {
  padding: 16px;
  display: grid;
  grid-template-columns: repeat(5, minmax(150px, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

label {
  color: var(--muted);
  display: grid;
  gap: 6px;
  font-size: 0.85rem;
  font-weight: 700;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 10px 11px;
  color: var(--ink);
  background: #fff;
}

input[type="checkbox"] {
  width: auto;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--blue);
  outline: 3px solid rgba(48, 95, 134, 0.16);
}

.button {
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 10px 14px;
  font-weight: 800;
  min-height: 42px;
}

.button.primary {
  background: var(--green);
  color: #fff;
}

.button.secondary {
  background: var(--surface);
  border-color: var(--line);
  color: var(--ink);
}

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

.button:focus-visible {
  outline: 3px solid rgba(181, 129, 43, 0.28);
}

.notice {
  border-radius: 8px;
  padding: 12px 14px;
  margin-bottom: 18px;
  background: var(--surface-strong);
  color: var(--green-dark);
  border: 1px solid var(--line);
  line-height: 1.45;
}

.notice.has-errors {
  background: #fff3ef;
  color: var(--red);
  border-color: #e5bab1;
}

.score-table-shell {
  width: 100%;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

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

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 10px;
  text-align: left;
  vertical-align: middle;
}

th {
  color: var(--muted);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0;
  background: #fbfcfa;
}

.score-table th,
.score-table td {
  min-width: 56px;
  text-align: center;
}

.score-table th:first-child,
.score-table td:first-child {
  position: sticky;
  left: 0;
  z-index: 1;
  text-align: left;
  min-width: 210px;
  background: #fff;
}

.score-table th:first-child {
  background: #fbfcfa;
}

.skins-matrix th,
.skins-matrix td {
  min-width: 70px;
  text-align: center;
}

.skins-matrix th:first-child,
.skins-matrix td:first-child {
  position: sticky;
  left: 0;
  z-index: 1;
  min-width: 220px;
  text-align: left;
  background: #fff;
}

.skins-matrix thead th:first-child {
  background: #fbfcfa;
}

.skins-matrix tbody th {
  font-size: 0.9rem;
  text-transform: none;
}

.skins-matrix tbody th span,
.skins-matrix tbody th small,
.skins-matrix td strong,
.skins-matrix td small {
  display: block;
}

.skins-matrix tbody th small,
.skins-matrix td small {
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.74rem;
}

.skins-matrix .meta-row td,
.skins-matrix .meta-row th {
  background: var(--surface-strong);
  color: var(--green-dark);
  font-weight: 800;
}

.skins-matrix .skin-winner {
  background: #fff5db;
  box-shadow: inset 0 0 0 2px rgba(181, 129, 43, 0.38);
}

.course-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 16px;
  margin-bottom: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-strong);
}

.course-banner strong,
.course-banner span {
  display: block;
}

.course-banner strong {
  font-size: 1.05rem;
}

.course-banner span {
  color: var(--muted);
  margin-top: 4px;
}

.course-banner div:last-child {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.skin-summary-block {
  margin-top: 18px;
}

.skin-summary-block h4 {
  margin: 0 0 10px;
}

.scorecard-table {
  table-layout: fixed;
  width: 100%;
  min-width: 980px;
  border-collapse: collapse;
  background: #fff;
}

.scorecard-table th,
.scorecard-table td {
  border: 1px solid #d9dfd8;
  padding: 6px 4px;
  min-width: 0;
  height: 44px;
  text-align: center;
  vertical-align: middle;
  color: #0f1916;
  font-size: 0.95rem;
  line-height: 1.1;
  overflow: hidden;
  overflow-wrap: anywhere;
  white-space: normal;
}

.scorecard-table th:first-child,
.scorecard-table td:first-child {
  position: sticky;
  left: 0;
  z-index: 2;
  width: 13%;
  min-width: 120px;
  text-align: center;
}

.scorecard-table th:nth-last-child(-n + 3),
.scorecard-table td:nth-last-child(-n + 3) {
  width: 5.8%;
}

.scorecard-table .hole-row th {
  background: #3f7739;
  color: #fff;
  font-size: 0.95rem;
  font-weight: 900;
  text-transform: none;
  overflow-wrap: normal;
  white-space: nowrap;
}

.scorecard-table .hole-row th:nth-last-child(-n + 3) {
  font-size: 0.72rem;
}

.scorecard-table .hole-row th:first-child {
  z-index: 4;
  background: #3f7739;
  color: #fff;
  font-size: 0.95rem;
}

.scorecard-table .par-row th,
.scorecard-table .par-row td {
  background: #dcefd4;
  font-weight: 900;
  font-size: 0.96rem;
}

.scorecard-table .par-row th:first-child {
  background: #dcefd4;
  color: #0f1916;
}

.scorecard-table .handicap-row th,
.scorecard-table .handicap-row td {
  background: #fff;
  font-weight: 800;
  font-size: 0.9rem;
}

.scorecard-table .handicap-row th:first-child {
  background: #fff;
  color: #0f1916;
}

.scorecard-table tbody tr:nth-child(odd) .player-name-cell,
.scorecard-table tbody tr:nth-child(odd) .score-cell {
  background: #edf7ed;
}

.scorecard-table tbody tr:nth-child(even) .player-name-cell,
.scorecard-table tbody tr:nth-child(even) .score-cell {
  background: #fff;
}

.scorecard-table .player-name-cell {
  z-index: 3;
  text-transform: none;
  padding-inline: 5px;
}

.scorecard-table .player-name-cell span,
.scorecard-table .player-name-cell small,
.scorecard-table .score-cell strong,
.scorecard-table .score-cell small {
  display: block;
}

.scorecard-table .player-name-cell small,
.scorecard-table .score-cell small {
  margin-top: 4px;
  color: #5f6965;
  font-size: 0.68rem;
}

.scorecard-table .player-cell {
  place-items: center;
  gap: 4px;
}

.scorecard-table .inline-controls {
  justify-content: center;
  gap: 6px;
  font-size: 0.68rem;
}

.scorecard-table .totals-cell {
  background: #e3f0cf;
  font-weight: 900;
  font-size: 0.95rem;
}

.scorecard-table .score-input,
.scorecard-table .score-display {
  display: inline-grid;
  place-items: center;
  width: min(42px, 100%);
  height: 30px;
  margin: 0 auto;
  border: 2px solid #cfd3cf;
  border-radius: 0;
  background: #fff;
  color: #0f1916;
  font-size: 0.96rem;
  font-weight: 800;
  line-height: 1;
}

.scorecard-table .score-cell {
  overflow: visible;
  position: relative;
}

.scorecard-table .score-entry-control {
  position: relative;
  display: inline-grid;
  place-items: center;
  width: min(42px, 100%);
  margin: 0 auto;
}

.scorecard-table .score-entry-control .score-input {
  width: 100%;
}

.scorecard-table .score-input {
  padding: 3px;
}

.scorecard-table .score-input::-webkit-outer-spin-button,
.scorecard-table .score-input::-webkit-inner-spin-button {
  margin: 0;
  -webkit-appearance: none;
}

.scorecard-table .score-input[type="number"] {
  appearance: textfield;
  -moz-appearance: textfield;
}

.scorecard-table .score-input:focus {
  border-color: #0a45ff;
  outline: 3px solid rgba(10, 69, 255, 0.2);
}

.scorecard-table .skin-winner {
  background: inherit;
  box-shadow: none;
}

.scorecard-table .skin-winner .score-display {
  border: 4px solid #0647ff;
  border-radius: 999px;
  box-shadow: none;
}

.scorecard-table .net-score-display {
  position: relative;
  border-color: #cfd3cf;
}

.scorecard-table .entry-score-cell .score-input {
  border-color: #cfd3cf;
  box-shadow: none;
}

.scorecard-table .stroke-badge {
  position: absolute;
  top: -8px;
  right: -9px;
  display: inline-grid;
  place-items: center;
  min-width: 18px;
  height: 16px;
  padding: 0 3px;
  border: 1px solid #9fa7a3;
  border-radius: 999px;
  background: #fff;
  color: #0f1916;
  font-size: 0.58rem;
  font-weight: 900;
  line-height: 1;
}

.score-input {
  width: 44px;
  padding: 8px 5px;
  text-align: center;
}

.player-cell {
  display: grid;
  gap: 6px;
}

.player-cell strong {
  font-size: 0.95rem;
}

.inline-controls {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  color: var(--muted);
  font-size: 0.82rem;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  border-radius: 999px;
  padding: 4px 10px;
  background: var(--surface-strong);
  color: var(--green-dark);
  border: 1px solid var(--line);
  font-weight: 800;
  font-size: 0.82rem;
}

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

.list-table input,
.list-table select {
  min-width: 110px;
}

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

.mini-item,
.winner-row,
.recipient-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fff;
}

.mini-item span,
.winner-row span {
  color: var(--muted);
}

.recipient-row {
  justify-content: flex-start;
}

#email-preview {
  white-space: pre-wrap;
  min-height: 420px;
  margin: 0;
  color: var(--ink);
  background: #fbfcfa;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  line-height: 1.55;
  overflow: auto;
}

.rule-list {
  margin: 0;
  padding-left: 18px;
  color: var(--muted);
  line-height: 1.6;
}

.danger-zone {
  margin-top: 18px;
  padding: 18px;
}

.settings-grid + .panel {
  margin-top: 18px;
}

.helper-text {
  align-self: end;
  margin: 0;
  line-height: 1.45;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@media (max-width: 1100px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .app-shell.sidebar-collapsed {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    padding: 18px;
  }

  .app-shell.sidebar-collapsed .sidebar {
    max-height: 0;
    padding-top: 0;
    padding-bottom: 0;
  }

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

  .sidebar-note {
    display: none;
  }

  .metric-grid,
  .dashboard-grid,
  .email-layout,
  .settings-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

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

@media (max-width: 720px) {
  .workspace {
    padding: 16px;
  }

  .topbar,
  .section-heading,
  .danger-zone,
  .course-banner {
    align-items: stretch;
    flex-direction: column;
  }

  .topbar-title-group {
    width: 100%;
  }

  .course-banner div:last-child {
    justify-content: flex-start;
  }

  .nav-list,
  .metric-grid,
  .dashboard-grid,
  .email-layout,
  .settings-grid,
  .form-band {
    grid-template-columns: 1fr;
  }

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

  .topbar-actions,
  .button-row {
    width: 100%;
  }

  .button,
  .league-switcher,
  .topbar-actions select {
    width: 100%;
  }

  .league-button {
    flex: 1;
  }
}
