:root {
  --bg: #f4f6f2;
  --surface: #ffffff;
  --surface-2: #eef2ec;
  --text: #1c2420;
  --muted: #5f6b64;
  --border: #d9e0d8;
  --brand: #1f6b3a;
  --brand-ink: #ffffff;
  --brand-soft: #dcefe2;
  --yes: #1f8a4c;
  --yes-bg: #e2f4e8;
  --no: #b3402f;
  --no-bg: #f8e4e0;
  --warn: #9a6400;
  --warn-bg: #fdf1d8;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(0,0,0,.05), 0 2px 10px rgba(0,0,0,.04);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #111613; --surface: #1a211d; --surface-2: #222b26; --text: #e6ece8; --muted: #9aa8a0;
    --border: #2f3a34; --brand: #3fa565; --brand-ink: #0b1a10; --brand-soft: #1f3a2a;
    --yes: #5cc787; --yes-bg: #1c3527; --no: #ec7b68; --no-bg: #3a201c; --warn: #f0bb55; --warn-bg: #3a2e15;
    --shadow: none; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #111613; --surface: #1a211d; --surface-2: #222b26; --text: #e6ece8; --muted: #9aa8a0;
  --border: #2f3a34; --brand: #3fa565; --brand-ink: #0b1a10; --brand-soft: #1f3a2a;
  --yes: #5cc787; --yes-bg: #1c3527; --no: #ec7b68; --no-bg: #3a201c; --warn: #f0bb55; --warn-bg: #3a2e15;
  --shadow: none; color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg); color: var(--text);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
a { color: var(--brand); }
h1 { font-size: 1.6rem; margin: 0 0 4px; }
h2 { font-size: 1.1rem; margin: 0 0 12px; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.nowrap { white-space: nowrap; }
.grow { flex: 1; min-width: 0; }

/* Top bar */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
  padding: 10px 16px; background: var(--brand); color: var(--brand-ink);
}
.brand { display: flex; align-items: center; gap: 8px; color: inherit; text-decoration: none; font-weight: 700; font-size: 1.1rem; }
#nav { display: flex; gap: 4px; overflow-x: auto; max-width: 100%; scrollbar-width: none; }
#nav a {
  color: inherit; text-decoration: none; padding: 6px 12px; border-radius: 999px;
  opacity: .85; white-space: nowrap; font-weight: 500;
}
#nav a:hover { opacity: 1; background: rgba(255,255,255,.12); }
#nav a.active { opacity: 1; background: rgba(255,255,255,.22); }

main { max-width: 1100px; margin: 0 auto; padding: 20px 16px 60px; }

/* Cards */
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 18px; margin-bottom: 16px; box-shadow: var(--shadow);
}
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 8px; }
.card-head h2 { margin: 0; }
.hero { margin: 4px 0 18px; }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 16px; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; }
.stat b { display: block; font-size: 1.6rem; font-variant-numeric: tabular-nums; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; gap: 6px; justify-content: center;
  border: 1px solid var(--brand); background: var(--brand); color: var(--brand-ink);
  padding: 9px 16px; border-radius: 8px; font: inherit; font-weight: 600; cursor: pointer;
}
.btn:hover { filter: brightness(1.07); }
.btn:disabled { opacity: .4; cursor: default; }
.btn.ghost { background: transparent; color: var(--brand); }
.btn.danger { background: transparent; border-color: var(--no); color: var(--no); }
.btn.sm { padding: 6px 12px; font-size: .9rem; }
.btn.xs { padding: 3px 9px; font-size: .82rem; font-weight: 500; }
.btns { display: flex; flex-wrap: wrap; gap: 6px; }
.btns + .btns { margin-top: 6px; }

/* Forms */
.grid-form { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; align-items: end; }
.field { display: flex; flex-direction: column; gap: 4px; font-size: .85rem; color: var(--muted); }
.field.wide { grid-column: 1 / -1; }
input, select, textarea {
  font: inherit; color: var(--text); background: var(--surface);
  border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; width: 100%;
}
input[type="checkbox"], input[type="radio"] { width: auto; accent-color: var(--brand); }
textarea { resize: vertical; margin: 8px 0; }
.form-actions { display: flex; gap: 8px; }
details { margin-top: 14px; }
summary { cursor: pointer; font-weight: 600; }
.daypick { display: flex; flex-wrap: wrap; gap: 6px; }
.daypick label, .chk {
  display: inline-flex; align-items: center; gap: 6px; padding: 6px 10px;
  border: 1px solid var(--border); border-radius: 999px; cursor: pointer; color: var(--text); background: var(--surface);
}
.daypick label:has(input:checked), .chk.on { background: var(--brand-soft); border-color: var(--brand); }
.radio-row { display: flex; flex-wrap: wrap; gap: 16px; color: var(--text); }
.radio-row label { display: flex; gap: 6px; align-items: flex-start; max-width: 340px; }

.toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 10px 0 14px; }
.toolbar select, .toolbar input { width: auto; }
.seg { display: inline-flex; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.seg button { border: 0; background: var(--surface); color: var(--text); padding: 6px 12px; font: inherit; cursor: pointer; }
.seg button.on { background: var(--brand); color: var(--brand-ink); }

/* Tables */
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: 8px; }
.table { border-collapse: collapse; width: 100%; font-size: .92rem; }
.table th, .table td { padding: 8px 10px; border-bottom: 1px solid var(--border); text-align: left; }
.table thead th { background: var(--surface-2); font-weight: 600; white-space: nowrap; }
.table tr.inactive td { opacity: .5; }
.table .c { text-align: center; padding: 4px; }
.table .sticky { position: sticky; left: 0; background: var(--surface); z-index: 1; white-space: nowrap; font-weight: 500; }
.table thead .sticky, .table tfoot .sticky { background: var(--surface-2); }
.table tfoot td, .table tfoot th { background: var(--surface-2); }
.cell {
  width: 34px; height: 30px; border-radius: 6px; border: 0; cursor: pointer; font-weight: 700;
}
.cell.yes { background: var(--yes-bg); color: var(--yes); }
.cell.no { background: var(--no-bg); color: var(--no); }

/* Dashboard list */
.list { display: flex; flex-direction: column; }
.row-item { display: flex; align-items: center; gap: 14px; padding: 12px 0; border-bottom: 1px solid var(--border); }
.row-item:last-child { border-bottom: 0; }
.row-item .title { font-weight: 600; }
.date-badge {
  width: 52px; text-align: center; border-radius: 10px; background: var(--brand-soft); padding: 4px 0; flex-shrink: 0;
}
.date-badge span { display: block; font-size: .72rem; text-transform: uppercase; color: var(--muted); }
.date-badge b { font-size: 1.3rem; }
.bar { height: 6px; background: var(--surface-2); border-radius: 3px; margin: 6px 0 4px; overflow: hidden; }
.bar i { display: block; height: 100%; background: var(--yes); }
.pill { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: .75rem; background: var(--surface-2); color: var(--muted); font-weight: 600; }
.pill.ok { background: var(--yes-bg); color: var(--yes); }
.tag { font-size: .72rem; color: var(--no); }
.onboard ol { padding-left: 20px; }
.onboard li { margin: 4px 0; }

/* Mini month calendar */
.month { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; max-width: 460px; }
.month .dow { text-align: center; font-size: .75rem; color: var(--muted); }
.month .day { aspect-ratio: 1; display: flex; align-items: center; justify-content: center; border-radius: 8px; color: var(--muted); opacity: .5; font-size: .9rem; }
.month button.day { opacity: 1; border: 0; cursor: pointer; font: inherit; font-weight: 700; }
.month button.day.yes { background: var(--yes-bg); color: var(--yes); outline: 2px solid var(--yes); outline-offset: -2px; }
.month button.day.no { background: var(--no-bg); color: var(--no); text-decoration: line-through; }

/* Pairings */
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0; }
.chk { font-size: .9rem; }
.chk .muted { font-size: .8rem; }
.groups { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 12px; margin-top: 10px; }
.group { border: 1px solid var(--border); border-radius: var(--radius); padding: 12px; background: var(--surface); }
.group.target { border-style: dashed; border-color: var(--brand); }
.group-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 8px; gap: 8px; }
.group-head b { font-size: 1.05rem; color: var(--brand); }
.group ul { list-style: none; padding: 0; margin: 0 0 8px; }
.group li { display: flex; gap: 4px; margin-bottom: 4px; }
.player {
  flex: 1; display: flex; justify-content: space-between; gap: 8px; text-align: left;
  border: 1px solid var(--border); background: var(--surface-2); color: var(--text);
  padding: 7px 10px; border-radius: 8px; font: inherit; cursor: pointer;
}
.player.sel { border-color: var(--brand); background: var(--brand-soft); box-shadow: 0 0 0 2px var(--brand) inset; }
.player.guest { font-style: italic; }
.player .hcp { color: var(--muted); font-variant-numeric: tabular-nums; }
.x { border: 0; background: transparent; color: var(--muted); font-size: 1.2rem; cursor: pointer; padding: 0 6px; border-radius: 6px; }
.x:hover { color: var(--no); background: var(--no-bg); }
.warn { color: var(--warn); background: var(--warn-bg); padding: 4px 8px; border-radius: 6px; margin-top: 6px; }
.hint { background: var(--surface-2); border-radius: 8px; padding: 8px 12px; margin: 8px 0; }

/* Cloud / auth / golfer view */
.sync { margin-left: auto; font-size: .8rem; opacity: .85; white-space: nowrap; }
.sync.offline { color: #ffd27a; opacity: 1; }
body.member-mode #nav, body.member-mode .sync, body.signed-out #nav { display: none; }
.auth-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 16px; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.banner { border-color: var(--brand); background: var(--brand-soft); }
.code { font-family: ui-monospace, Consolas, monospace; font-size: 1.15em; letter-spacing: .12em; background: var(--surface); padding: 1px 8px; border-radius: 6px; border: 1px solid var(--border); }
.month-h { font-size: .95rem; margin: 18px 0 4px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.inout { min-width: 104px; }
.center { text-align: center; }

#toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%) translateY(20px);
  background: var(--text); color: var(--bg); padding: 10px 18px; border-radius: 10px;
  opacity: 0; pointer-events: none; transition: .2s; z-index: 50; max-width: calc(100% - 32px);
}
#toast.show { opacity: 1; transform: translateX(-50%); }

@media (max-width: 600px) {
  main { padding: 14px 12px 60px; }
  .card { padding: 14px; }
  .topbar { gap: 6px; padding: 8px 12px; }
  #nav a { padding: 6px 10px; }
}

@media print {
  .no-print, .topbar, button.x, .btn, details, .toolbar, .hint, #toast { display: none !important; }
  body { background: #fff; color: #000; }
  .card { border: 0; box-shadow: none; padding: 0; }
  .groups { grid-template-columns: repeat(2, 1fr); }
  .group { break-inside: avoid; }
  .player { border: 0; background: none; padding: 2px 0; }
}
