:root {
  color-scheme: light;
  --ink: #18211f;
  --muted: #61706b;
  --line: #d7dedb;
  --surface: #ffffff;
  --band: #f4f7f5;
  --green: #12603f;
  --green-dark: #0b432c;
  --gold: #b88934;
  --red: #9a2734;
  --blue: #245b7a;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--band);
  color: var(--ink);
  font: 15px/1.45 system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.topbar {
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 clamp(16px, 4vw, 40px);
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}

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

.brand-mark {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: inline-block;
  background:
    linear-gradient(90deg, transparent 48%, var(--surface) 48% 54%, transparent 54%),
    radial-gradient(circle at 50% 50%, var(--surface) 0 3px, transparent 4px),
    var(--green);
  border: 2px solid var(--gold);
}

main {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 24px 0 48px;
}

.page-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  margin-bottom: 18px;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 28px;
  font-weight: 750;
}

h2 {
  font-size: 16px;
  font-weight: 750;
}

p {
  color: var(--muted);
}

.section-title {
  padding: 18px 0 10px;
}

.tabs {
  display: flex;
  gap: 6px;
  margin: 0 0 16px;
  border-bottom: 1px solid var(--line);
}

.tab {
  min-height: 42px;
  display: inline-flex;
  align-items: center;
  padding: 9px 14px;
  color: var(--muted);
  text-decoration: none;
  border-bottom: 3px solid transparent;
  font-weight: 750;
}

.tab.active {
  color: var(--green);
  border-bottom-color: var(--green);
}

.table-section,
.form-section {
  margin-top: 8px;
}

.table-wrap {
  overflow-x: auto;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
}

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

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

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

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

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

.status {
  display: inline-flex;
  min-width: 74px;
  justify-content: center;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 12px;
  text-transform: capitalize;
  background: #e8eee9;
  color: var(--muted);
}

.status.queued {
  background: #eaf2f7;
  color: var(--blue);
}

.status.succeeded {
  background: #e6f3ec;
  color: var(--green);
}

.status.failed {
  background: #f7e9eb;
  color: var(--red);
}

.rule-form,
.login-panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
}

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

label,
legend {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
}

select,
input {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  font: inherit;
  padding: 8px 10px;
}

.field-control {
  align-content: start;
}

.select-wrap {
  position: relative;
  display: block;
}

.select-wrap select {
  padding-right: 38px;
}

.select-spinner {
  position: absolute;
  right: 12px;
  top: 50%;
  width: 18px;
  height: 18px;
  margin-top: -9px;
  border: 2px solid #c8d4d0;
  border-top-color: var(--green);
  border-radius: 50%;
  animation: spin 0.75s linear infinite;
  pointer-events: none;
}

.inline-status {
  min-height: 18px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

.inline-status.active {
  color: var(--green);
}

input[readonly] {
  background: #f8faf9;
}

fieldset {
  border: 0;
  padding: 18px 0 0;
  margin: 0;
}

.player-step {
  padding-top: 0;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 18px;
}

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

.check-row {
  min-height: 42px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--ink);
  font-weight: 500;
}

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

.fallback-row {
  margin-top: 14px;
}

.actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 18px;
}

.inline-actions {
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.primary-button,
.ghost-button,
.secondary-button,
.danger-button {
  min-height: 40px;
  border: 1px solid transparent;
  border-radius: 6px;
  padding: 8px 14px;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

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

.primary-button:hover {
  background: var(--green-dark);
}

.primary-button:disabled,
.secondary-button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.secondary-button {
  background: #eef4f1;
  color: var(--green);
  border-color: #cbd9d3;
}

.secondary-button:hover {
  background: #e2ece7;
}

.ghost-button {
  background: transparent;
  color: var(--green);
  border-color: var(--line);
}

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

.danger-button:hover {
  background: #f8eaec;
}

.field-note {
  margin: 6px 0 10px;
  font-size: 13px;
}

.messages {
  display: grid;
  gap: 10px;
  margin-bottom: 16px;
}

.message {
  padding: 10px 12px;
  border-radius: 6px;
  background: #edf3f7;
  color: var(--blue);
  border: 1px solid #d6e6ef;
}

.message.error {
  background: #f8eaec;
  color: var(--red);
  border-color: #ebc9ce;
}

.message.success {
  background: #e8f4ed;
  color: var(--green);
  border-color: #cce3d6;
}

.login-shell {
  min-height: calc(100vh - 140px);
  display: grid;
  place-items: center;
}

.login-panel {
  width: min(420px, 100%);
  display: grid;
  gap: 16px;
}

.booking-overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(14, 22, 19, 0.58);
  backdrop-filter: blur(4px);
}

.booking-overlay[hidden] {
  display: none;
}

.booking-loader {
  width: min(360px, 100%);
  display: grid;
  justify-items: center;
  gap: 10px;
  padding: 26px 24px;
  background: var(--surface);
  border: 1px solid rgba(255, 255, 255, 0.5);
  border-radius: 8px;
  box-shadow: 0 18px 45px rgba(12, 20, 17, 0.24);
  text-align: center;
}

.booking-loader strong {
  font-size: 18px;
}

.booking-loader span:last-child {
  color: var(--muted);
}

.loader-ring {
  width: 42px;
  height: 42px;
  border: 4px solid #d8e1dc;
  border-top-color: var(--gold);
  border-right-color: var(--green);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@media (max-width: 860px) {
  .form-grid,
  .member-grid {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 700px) {
  .page-head {
    align-items: flex-start;
  }

  h1 {
    font-size: 24px;
  }

  .table-wrap {
    overflow: visible;
    background: transparent;
    border: 0;
    border-radius: 0;
  }

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

  table {
    min-width: 0;
  }

  thead {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
  }

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

  td {
    min-height: 40px;
    display: grid;
    grid-template-columns: 112px minmax(0, 1fr);
    gap: 12px;
    align-items: start;
    padding: 8px 12px;
    border-bottom: 0;
    overflow-wrap: anywhere;
  }

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

  .empty-row {
    display: block;
    text-align: center;
  }

  .empty-row::before {
    content: "";
    display: none;
  }
}

@media (max-width: 560px) {
  main {
    width: min(100% - 20px, 1180px);
    padding-top: 16px;
  }

  .topbar {
    padding: 0 12px;
  }

  .tabs {
    gap: 0;
  }

  .tab {
    flex: 1;
    justify-content: center;
  }

  .form-grid,
  .member-grid {
    grid-template-columns: 1fr;
  }

  .rule-form,
  .login-panel {
    padding: 14px;
  }

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

  .primary-button,
  .ghost-button,
  .danger-button {
    min-height: 44px;
  }

  td .danger-button {
    width: 100%;
  }
}
