/* Split Sheets. Layout: account bar and sheet switcher on top, then a court-green scoreboard for the open sheet (one cell per person,
   split by net lines), then the working area: entry form on the left, month-by-month ledger on the right. */
:root {
  --bg: #eef3ef;
  --surface: #ffffff;
  --ink: #13211a;
  --muted: #5a6b62;
  --line: #d4ded7;
  --accent: #1d6b4a;
  --accent-ink: #ffffff;
  --accent-soft: #dcebe2;
  --court: #1f6f4c;
  --court-line: rgba(255,255,255,.78);
  --court-ink: #ffffff;
  --shuttle: #e9c63b;
  --owe: #b24530;
  --gets: #1d6b4a;
  --focus: #e9c63b;
  --display: "Barlow Condensed", "Arial Narrow", "Helvetica Neue", Arial, sans-serif;
  --body: "Barlow", "Helvetica Neue", Arial, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0e1612; --surface: #15201a; --ink: #e4eee8; --muted: #93a69b; --line: #26362d;
    --accent: #52c18d; --accent-ink: #06140d; --accent-soft: #1b3326;
    --court: #164f37; --court-line: rgba(255,255,255,.62); --court-ink: #f2f8f4;
    --shuttle: #f1d457; --owe: #f08b73; --gets: #6fd3a2; --focus: #f1d457;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0e1612; --surface: #15201a; --ink: #e4eee8; --muted: #93a69b; --line: #26362d;
  --accent: #52c18d; --accent-ink: #06140d; --accent-soft: #1b3326;
  --court: #164f37; --court-line: rgba(255,255,255,.62); --court-ink: #f2f8f4;
  --shuttle: #f1d457; --owe: #f08b73; --gets: #6fd3a2; --focus: #f1d457;
  color-scheme: dark;
}
* { box-sizing: border-box; }
body { background: var(--bg); color: var(--ink); font-family: var(--body); font-size: 15px; line-height: 1.45; }
.wrap { max-width: 1100px; margin: 0 auto; padding-inline: 16px; padding-block: 20px 48px; display: grid; gap: 20px; }
h1, h2, h3 { font-family: var(--display); font-weight: 700; margin: 0; text-wrap: balance; letter-spacing: .01em; }
h1 { font-size: 2rem; line-height: 1; text-transform: uppercase; overflow-wrap: anywhere; }
h2 { font-size: 1.25rem; text-transform: uppercase; letter-spacing: .04em; }
.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
button, input, select { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.label { font-size: .72rem; text-transform: uppercase; letter-spacing: .09em; color: var(--muted); font-weight: 600; }

/* Sheet switcher + header */
.sheetbar { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 2px; scrollbar-width: thin; }
.sheetbar button { flex: none; border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: 5px 13px; font-weight: 600; cursor: pointer; white-space: nowrap; }
.sheetbar button[aria-current="true"] { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.sheetbar .new { border-style: dashed; color: var(--accent); }
.top { display: flex; flex-wrap: wrap; gap: 8px 16px; align-items: end; justify-content: space-between; }
.top > div:first-child { min-width: 0; }
.who { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; font-size: .92rem; }
.linkish { background: none; border: 0; padding: 0; color: var(--accent); text-decoration: underline; text-underline-offset: 2px; cursor: pointer; }

/* Identity picker */
.claim { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 14px 16px; display: grid; gap: 10px; }
.claim-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }

/* Scoreboard */
.court { background: var(--court); color: var(--court-ink); border-radius: 6px; padding: 10px; }
.court-lines { border: 2px solid var(--court-line); display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
.side { padding: 16px 18px 18px; border-left: 2px dashed var(--court-line); display: grid; gap: 2px; min-width: 0; }
.side:first-child { border-left: 0; }
.side .pname { font-family: var(--display); font-weight: 600; font-size: 1.05rem; text-transform: uppercase; letter-spacing: .06em; opacity: .9; overflow-wrap: anywhere; }
.side .pnet { font-family: var(--display); font-weight: 700; font-size: 2.6rem; line-height: 1; font-variant-numeric: tabular-nums; }
.side .pnote { font-size: .85rem; opacity: .85; }
.verdict { border: 2px solid var(--court-line); border-top: 0; padding: 12px 18px; display: grid; gap: 8px; }
.verdict .line { display: flex; flex-wrap: wrap; gap: 8px 14px; align-items: center; justify-content: space-between; }
.verdict strong { font-family: var(--display); font-size: 1.5rem; font-weight: 700; letter-spacing: .01em; }
.verdict .amt { box-shadow: inset 0 -0.32em 0 color-mix(in srgb, var(--shuttle) 70%, transparent); }
.court .btn { background: var(--court-ink); color: var(--court); border-color: var(--court-ink); }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px 20px; padding: 12px 8px 2px; }
.stat .v { font-family: var(--display); font-size: 1.45rem; font-weight: 600; font-variant-numeric: tabular-nums; }
.stat .k { font-size: .75rem; text-transform: uppercase; letter-spacing: .08em; opacity: .8; }

/* Main grid */
.main { display: grid; gap: 20px; align-items: start; }
@media (min-width: 900px) { .main { grid-template-columns: 380px minmax(0, 1fr); } }
.left { display: grid; gap: 20px; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 16px; display: grid; gap: 14px; min-width: 0; }

/* Form */
.tabs, .seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; background: var(--bg); border-radius: 8px; padding: 3px; gap: 3px; }
.tabs button, .seg button { border: 0; background: none; padding: 7px; border-radius: 6px; font-weight: 600; cursor: pointer; color: var(--muted); }
.seg button { padding: 4px 8px; font-size: .88rem; }
.tabs button[aria-pressed="true"], .seg button[aria-pressed="true"] { background: var(--surface); color: var(--ink); box-shadow: 0 1px 2px rgba(0,0,0,.12); }
.field { display: grid; gap: 5px; min-width: 0; }
.stack { display: grid; gap: 14px; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.label-row { display: flex; flex-wrap: wrap; gap: 6px 10px; align-items: center; justify-content: space-between; }
input[type="text"], input[type="date"], input[type="search"], input[inputmode="decimal"], select {
  width: 100%; min-width: 0; padding: 9px 10px; border: 1px solid var(--line); border-radius: 7px; background: var(--surface);
}
input:focus, select:focus { border-color: var(--accent); }
.money { position: relative; }
.money span { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.money input { padding-left: 22px; font-variant-numeric: tabular-nums; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: 4px 11px; font-size: .88rem; cursor: pointer; }
.chip:hover { border-color: var(--accent); }
.chip[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.split-rows { display: grid; border: 1px solid var(--line); border-radius: 8px; }
.srow { display: grid; grid-template-columns: minmax(0, 1fr) 110px 72px; gap: 10px; align-items: center; padding: 6px 10px; border-bottom: 1px solid var(--line); }
.srow:last-child { border-bottom: 0; }
.srow .sn { font-weight: 600; overflow-wrap: anywhere; }
.srow .sv { text-align: right; color: var(--muted); font-size: .9rem; font-variant-numeric: tabular-nums; }
.srow input { padding: 6px 8px; text-align: right; }
.srow .money input { padding-left: 20px; }
.each { font-size: .9rem; color: var(--muted); }
.each.bad { color: var(--owe); }
.actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.btn { border: 1px solid var(--line); background: var(--surface); padding: 8px 14px; border-radius: 7px; font-weight: 600; cursor: pointer; }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn.danger { color: var(--owe); border-color: color-mix(in srgb, var(--owe) 45%, var(--line)); }
.btn.danger.armed { background: var(--owe); color: var(--surface); border-color: var(--owe); }
.btn:disabled { opacity: .55; cursor: default; }
.spacer { flex: 1; }
.note { font-size: .88rem; color: var(--muted); }
.err { color: var(--owe); font-size: .88rem; }

/* Players */
.players { display: grid; gap: 6px; }
.player { display: flex; gap: 10px; align-items: center; justify-content: space-between; padding: 6px 0; border-bottom: 1px solid var(--line); }
.player:last-child { border-bottom: 0; }
.player .n { font-weight: 600; overflow-wrap: anywhere; }
.tag { font-size: .7rem; text-transform: uppercase; letter-spacing: .08em; background: var(--accent-soft); color: var(--accent); border-radius: 4px; padding: 1px 6px; margin-left: 6px; font-weight: 600; }
.pos { color: var(--gets); } .neg { color: var(--owe); }
.addp { display: flex; gap: 8px; }
.addp input { flex: 1; }

/* Ledger */
.ledger-head { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; justify-content: space-between; }
.ledger-head input { max-width: 240px; }
.months { display: grid; gap: 10px; }
details.month { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
details.month > summary { list-style: none; cursor: pointer; padding: 12px 16px; display: flex; flex-wrap: wrap; gap: 4px 16px; align-items: baseline; justify-content: space-between; }
details.month > summary::-webkit-details-marker { display: none; }
details.month > summary h3 { font-size: 1.15rem; text-transform: uppercase; letter-spacing: .05em; }
details.month > summary h3::before { content: "▸"; display: inline-block; width: 1em; color: var(--muted); transition: transform .15s; }
details.month[open] > summary h3::before { transform: rotate(90deg); }
.msum { font-size: .85rem; color: var(--muted); display: flex; flex-wrap: wrap; gap: 4px 12px; }
.rows { border-top: 1px solid var(--line); }
.item { display: grid; grid-template-columns: 52px minmax(0, 1fr) auto; gap: 4px 12px; align-items: center; padding: 10px 16px; border-bottom: 1px solid var(--line); width: 100%; text-align: left; background: none; border-left: 0; border-right: 0; border-top: 0; }
.item:last-child { border-bottom: 0; }
button.item { cursor: pointer; }
button.item:hover { background: var(--accent-soft); }
.item.editing { background: var(--accent-soft); box-shadow: inset 3px 0 0 var(--accent); }
.day { font-family: var(--display); font-weight: 600; line-height: 1.05; text-transform: uppercase; color: var(--muted); font-size: .85rem; }
.day b { display: block; font-size: 1.35rem; color: var(--ink); font-variant-numeric: tabular-nums; }
.what { font-weight: 600; overflow-wrap: anywhere; }
.meta { font-size: .84rem; color: var(--muted); overflow-wrap: anywhere; }
.amt-col { text-align: right; }
.amt-col .a { font-family: var(--display); font-size: 1.25rem; font-weight: 600; font-variant-numeric: tabular-nums; }
.amt-col .by { font-size: .8rem; color: var(--muted); }
.pill { font-size: .68rem; text-transform: uppercase; letter-spacing: .08em; border: 1px solid currentColor; border-radius: 4px; padding: 0 5px; margin-left: 6px; font-weight: 600; vertical-align: 2px; }
.pill.pay { color: var(--gets); } .pill.adj { color: var(--muted); } .pill.unev { color: var(--accent); }
.empty { padding: 28px 16px; text-align: center; color: var(--muted); background: var(--surface); border: 1px dashed var(--line); border-radius: 10px; }

.newsheet { max-width: 560px; }
.toast { position: fixed; left: 50%; bottom: calc(env(safe-area-inset-bottom, 0px) + 18px); transform: translateX(-50%); background: var(--ink); color: var(--bg); padding: 9px 16px; border-radius: 8px; font-weight: 500; max-width: calc(100% - 32px); }
@media (max-width: 480px) { .side .pnet { font-size: 2.1rem; } h1 { font-size: 1.7rem; } .row2 { grid-template-columns: 1fr; } .srow { grid-template-columns: minmax(0, 1fr) 96px 64px; gap: 8px; } }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }

/* App shell additions */
.appbar { display: flex; flex-wrap: wrap; gap: 8px 14px; align-items: center; justify-content: space-between; }
.brand { font-family: var(--display); font-weight: 700; font-size: 1.15rem; text-transform: uppercase; letter-spacing: .08em; display: flex; align-items: center; gap: 8px; }
.brand svg { width: 26px; height: 26px; }
.account { font-size: .88rem; color: var(--muted); display: flex; gap: 10px; align-items: center; flex-wrap: wrap; min-width: 0; }
.account span { overflow-wrap: anywhere; }
.auth { max-width: 420px; margin: 8vh auto 0; }
.auth h1 { font-size: 2.2rem; }
.code-input { font-size: 1.6rem !important; letter-spacing: .4em; text-align: center; font-variant-numeric: tabular-nums; }
.inline-edit { display: grid; gap: 6px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.inline-edit .row2 { gap: 8px; }
.player .sub { font-size: .8rem; color: var(--muted); font-weight: 400; overflow-wrap: anywhere; }
.status-dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--gets); margin-right: 5px; vertical-align: 1px; }
.status-dot.off { background: var(--line); }
