:root {
  --bg: #f6f7f5;
  --fg: #1d2b1f;
  --muted: #5b6b5d;
  --line: #d9dfd8;
  --accent: #2f6b3a;
  --error: #a3261b;
  --ok: #2f6b3a;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  margin: 0; min-height: 100vh; display: flex; flex-direction: column;
  background: var(--bg); color: var(--fg);
}
main { flex: 1; width: 100%; max-width: 880px; margin: 0 auto; padding: 1.5rem 1rem; }
h1, h2 { margin: 0 0 .5rem; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.center { text-align: center; padding-top: 20vh; }
.app-header {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding: .75rem 1rem; background: #fff; border-bottom: 1px solid var(--line);
}
.brand { font-weight: 600; color: var(--fg); text-decoration: none; }
.user { display: flex; align-items: center; gap: .75rem; font-size: .9rem; }
.card { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 1.5rem; }
.narrow { max-width: 420px; margin: 8vh auto 0; }
.stack { display: flex; flex-direction: column; gap: .6rem; margin-top: 1rem; }
.row { display: flex; align-items: center; justify-content: space-between; }
label { display: flex; flex-direction: column; gap: .25rem; font-size: .9rem; }
input { font: inherit; padding: .55rem .7rem; border: 1px solid var(--line); border-radius: 8px; }
.btn {
  font: inherit; padding: .6rem 1rem; border-radius: 8px; border: 1px solid var(--line);
  background: #fff; color: var(--fg); cursor: pointer; text-align: center; text-decoration: none;
}
.btn:disabled { opacity: .5; cursor: default; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-quiet { padding: .35rem .7rem; }
.btn-link { font: inherit; background: none; border: 0; color: var(--accent); cursor: pointer; padding: 0; align-self: flex-start; }
.divider { display: flex; align-items: center; gap: .75rem; margin: 1.25rem 0 0; color: var(--muted); font-size: .85rem; }
.divider::before, .divider::after { content: ""; flex: 1; border-top: 1px solid var(--line); }
.notice { background: #eef4ec; border-radius: 8px; padding: .6rem .8rem; }
.error { color: var(--error); }
.success { color: var(--ok); }
.banner { background: #fdf6e3; border: 1px solid #ecd9a4; margin-bottom: 1rem; }
.banner p { margin: 0 0 .5rem; }
.row-inline { display: flex; flex-wrap: wrap; gap: .5rem; }
a.btn[aria-disabled="true"] { opacity: .5; pointer-events: none; }
.list { list-style: none; padding: 0; margin: 1rem 0 0; display: flex; flex-direction: column; gap: .5rem; }
.list .item {
  background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: .8rem 1rem;
  display: flex; justify-content: space-between; align-items: center; gap: 1rem;
  color: inherit; text-decoration: none;
}
.list .item:hover, .list .item:focus-visible { border-color: var(--accent); }
.list .name { font-weight: 600; }
.list .meta { color: var(--muted); font-size: .85rem; }
.empty { background: #fff; border: 1px dashed var(--line); border-radius: 10px; padding: 1.5rem; text-align: center; margin-top: 1rem; }
.empty p { margin: 0 0 .5rem; }
.empty .btn { display: inline-block; margin-top: 1rem; }
.tag { font-size: .75rem; border: 1px solid var(--line); border-radius: 999px; padding: .1rem .5rem; white-space: nowrap; }
.tag-draft { background: #f1f1ee; color: #555; }
.tag-registration { background: #e6f0fb; border-color: #b9d3f0; color: #1f4f86; }
.tag-paired { background: #f3ecfa; border-color: #d8c4ee; color: #5b3486; }
.tag-in_progress { background: #fdf3e1; border-color: #f0d6a4; color: #85570f; }
.tag-final { background: #e6f2e8; border-color: #b8d8be; color: var(--ok); }
footer { text-align: center; padding: 1rem; }

/* W3 wizard */
h3 { margin: 1.25rem 0 .25rem; font-size: 1rem; }
fieldset { border: 0; padding: 0; margin: 0; min-width: 0; }
legend { font-weight: 600; font-size: 1.1rem; margin-bottom: .75rem; }
select { font: inherit; padding: .5rem .6rem; border: 1px solid var(--line); border-radius: 8px; background: #fff; }
input[aria-invalid="true"], select[aria-invalid="true"] { border-color: var(--error); background: #fdf1ef; }
.field-error { color: var(--error); font-size: .8rem; }
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: .75rem 1rem; margin: .75rem 0; }
.choice { display: flex; flex-wrap: wrap; align-items: center; gap: .4rem 1rem; margin: .75rem 0; font-size: .9rem; }
.choice > span:first-child { font-weight: 600; min-width: 5rem; }
.choice label, label.inline { flex-direction: row; align-items: center; gap: .35rem; }
.steps { list-style: none; display: flex; gap: .5rem; padding: 0; margin: .5rem 0 1rem; counter-reset: step; }
.steps li { flex: 1; padding: .45rem .7rem; border-radius: 8px; border: 1px solid var(--line); background: #fff; font-size: .9rem; color: var(--muted); }
.steps li::before { counter-increment: step; content: counter(step) ". "; }
.steps li.current { border-color: var(--accent); color: var(--fg); font-weight: 600; }
.steps li.done { color: var(--accent); cursor: pointer; }
.holes-wrap { overflow-x: auto; display: flex; flex-direction: column; gap: .5rem; margin: .5rem 0; }
table.holes { border-collapse: collapse; font-size: .85rem; }
table.holes th, table.holes td { border: 1px solid var(--line); padding: .15rem; text-align: center; min-width: 2.6rem; }
table.holes th[scope="row"], table.holes th[scope="col"] { background: #f1f3f0; }
table.holes th[scope="row"] { padding: .15rem .5rem; white-space: nowrap; }
table.holes input { width: 2.4rem; padding: .3rem; text-align: center; border-radius: 4px; }
.summary { display: grid; grid-template-columns: max-content 1fr; gap: .3rem 1rem; margin: .5rem 0; }
.summary dt { color: var(--muted); }
.summary dd { margin: 0; }
.actions { margin-top: 1.25rem; gap: .5rem; }
.actions span { flex: 1; }

/* W4 dashboard */
#tournament-detail > .card { margin-top: 1rem; }
#tournament-detail h3 { margin-top: 0; }
.dash-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 1rem; margin-top: 1rem; }
.dash-grid .card { padding: 1rem 1.25rem; }
.cap { font-size: 1.6rem; font-weight: 600; margin: .25rem 0; }
.cap.over { color: var(--error); }
.checklist { list-style: none; padding: 0; margin: .75rem 0 0; display: flex; flex-direction: column; gap: .4rem; }
.checklist li { display: flex; align-items: center; gap: .75rem; padding: .5rem .25rem; border-bottom: 1px solid var(--line); }
.checklist li:last-child { border-bottom: 0; }
.checklist .step-label { flex: 1; }
.checklist .step-detail { color: var(--muted); font-size: .85rem; }
.checklist .mark { width: 1.5rem; height: 1.5rem; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; font-size: .8rem; border: 1px solid var(--line); flex: none; }
.checklist .state-done .mark { background: var(--ok); border-color: var(--ok); color: #fff; }
.checklist .state-in_progress .mark { background: #fdf3e1; border-color: #f0d6a4; color: #85570f; }
.checklist .state-not_needed { opacity: .6; }
.organizers { list-style: none; padding: 0; margin: .5rem 0; display: flex; flex-direction: column; gap: .35rem; }
.organizers li { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.invite-form { display: flex; align-items: flex-end; gap: .5rem; margin-top: .75rem; }
.invite-form label { flex: 1; }
.invite-link { margin-top: .75rem; }
.invite-link p { margin: 0 0 .5rem; }
.invite-link-row { display: flex; gap: .5rem; }
.invite-link-row input { flex: 1; min-width: 0; }

/* W8 flights */
#fl-detail > .card { margin-top: 1rem; }
#fl-detail h3 { margin-top: 0; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.table-wrap { overflow-x: auto; margin: .5rem 0; }
table.data { border-collapse: collapse; width: 100%; font-size: .9rem; }
table.data th, table.data td { border-bottom: 1px solid var(--line); padding: .35rem .4rem; text-align: left; vertical-align: middle; }
table.data th { font-weight: 600; color: var(--muted); font-size: .8rem; }
table.data input.w-num { width: 4.5rem; }
table.data input.w-name { width: 9rem; }
table.data td.range { white-space: nowrap; color: var(--muted); }
.fl-boundaries input { max-width: 16rem; }
fieldset.fl-ties { border: 1px solid var(--line); border-radius: 8px; margin: .75rem 0; padding: .5rem .8rem; }
fieldset.fl-ties legend { font-weight: 600; font-size: .9rem; }
.msg-list { margin: .5rem 0; padding-left: 1.2rem; }
.msg-list.warn { background: #fdf6e3; border: 1px solid #ecd9a4; border-radius: 8px; padding: .5rem .8rem .5rem 1.8rem; color: #6b4d0c; }
.tag-locked { background: #f3ecfa; border-color: #d8c4ee; color: #5b3486; }
.flight-board { border-top: 1px solid var(--line); padding-top: .75rem; margin-top: .75rem; }
.flight-board h4 { margin: 0 0 .25rem; font-size: .95rem; }
.flight-board .prizes { margin: 0 0 .5rem; }
.boards { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 1rem; }
.board h4 { color: var(--muted); font-size: .85rem; }

/* W5 players */
#pl-detail > .card { margin-top: 1rem; }
#pl-detail h3 { margin-top: 0; }
.player-form { display: flex; flex-direction: column; gap: .6rem; }
.player-form p { margin: 0; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: .6rem .75rem; }
.toolbar { align-items: flex-end; }
.toolbar .grow { flex: 1; min-width: 200px; }
.warn-text { color: #6b4d0c; }
table.data th button.sort { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; font-weight: 600; }
table.data th .arrow { font-size: .7rem; }
table.players td.num { text-align: right; padding-right: 1rem; }
table.players th[data-sort="handicap"] { text-align: right; padding-right: 1rem; }
table.players .pname { font-weight: 600; }
table.players td.contact { font-size: .85rem; word-break: break-all; }
table.players td.row-actions { white-space: nowrap; text-align: right; }
table.players td .tag { margin-left: .35rem; }
.tag-app { background: #e6f0fb; border-color: #b9d3f0; color: #1f4f86; }
.tag-guest { background: #f1f1ee; color: #555; }
.tag-st-registered { background: #e6f2e8; border-color: #b8d8be; color: var(--ok); }
.tag-st-waitlist { background: #fdf3e1; border-color: #f0d6a4; color: #85570f; }
.tag-st-withdrawn { background: #f1f1ee; color: #777; text-decoration: line-through; }
tr[data-status="withdrawn"] .pname { color: var(--muted); }
.btn-danger { background: var(--error); border-color: var(--error); color: #fff; }
dialog { border: 1px solid var(--line); border-radius: 12px; padding: 1.25rem; max-width: 420px; }
dialog::backdrop { background: rgba(0, 0, 0, .3); }

/* W5 "Add from club members" (E3-2) */
.card-head { justify-content: space-between; align-items: center; }
.card-head h3 { margin: 0; }
table.club-members input[type="checkbox"] { width: auto; }
table.club-members input.hcp { width: 4.5rem; }
table.club-members tr[data-conflict] { color: #777; }
table.club-members tr.selected { background: #f4f8fd; }
#pl-club-error.notice { color: inherit; }
