:root {
  --black: #171516; --ink: #171516; --muted: #5E5A5C; --line: #E4E2E3; --ground: #F3F2EE; --white: #FFFFFF;
  --lime: #AEFC0E; --lime-hover: #C8FF55;
  --res-bg: #EEFBD0; --res-line: #6A9A00; --res-ink: #2D4200;
  --in-bg: #DCEFC4; --in-ink: #24400A;
  --op-bg: #E4ECFA; --op-line: #3D64B3; --op-ink: #1C3566;
  --gone-bg: #F3E3E0; --gone-ink: #8A2414;
  --due-bg: #EEEDEC; --due-ink: #3F3B3D;
  --warn-bg: #FBEFD6; --warn-ink: #7A4B00;
}
* { box-sizing: border-box; min-width: 0; }
body { margin: 0; background: var(--ground); color: var(--ink); font: 14px/1.5 Inter, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
h1, h2 { margin: 0; line-height: 1.15; }
h1 { font-family: Montserrat, Inter, sans-serif; font-weight: 800; font-size: 30px; }
h2 { font-size: 16px; font-weight: 600; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: #3D5C00; }
:focus-visible { outline: 3px solid #5C8A00; outline-offset: 2px; }
.sr-only { position: absolute; left: 0; top: 0; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
[hidden] { display: none !important; }

/* sign-in */
.signin { min-height: 100vh; background: var(--black); color: #fff; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 28px; padding: 40px 20px; }
.signin-logo { width: 260px; max-width: 70%; height: auto; }
.signin-card { width: 100%; max-width: 400px; background: #211F20; border-radius: 20px; padding: 28px; display: flex; flex-direction: column; gap: 16px; }
.signin-card h1 { font-size: 28px; }
.signin-card .muted { color: #B3AEB0; margin: 4px 0 0; }
.input.dark { background: var(--black); border-color: #4A4648; color: #fff; letter-spacing: .15em; }
.signin .credit, .side .credit { color: #B3AEB0; text-decoration: none; font-size: 13px; }
.signin .credit span, .side .credit span { text-decoration: underline; color: #D6D2D4; }

/* layout */
.app { display: flex; flex-wrap: wrap; min-height: 100vh; }
.side { flex: 1 1 220px; max-width: 100%; background: var(--black); color: #fff; padding: 20px 14px; display: flex; flex-direction: column; gap: 20px; }
.side-brand { display: flex; flex-direction: column; gap: 6px; padding: 0 8px; }
.side-brand img { width: 150px; height: auto; }
.side-brand span { font-size: 12px; color: #B3AEB0; }
.side-nav { display: flex; flex-direction: column; gap: 2px; }
.side-nav a { height: 44px; padding: 0 12px; border-radius: 10px; color: #D6D2D4; text-decoration: none; display: flex; align-items: center; justify-content: space-between; }
.side-nav a:hover { background: #2A2829; color: #fff; }
.side-nav a[aria-current="page"] { background: var(--lime); color: var(--black); font-weight: 700; }
.badge { min-width: 22px; height: 22px; padding: 0 7px; border-radius: 11px; background: var(--lime); color: var(--black); font-size: 12px; font-weight: 700; display: inline-flex; align-items: center; justify-content: center; }
.side-nav a[aria-current="page"] .badge { background: var(--black); color: var(--lime); }
.side-foot { margin-top: auto; display: flex; flex-direction: column; gap: 6px; padding: 0 8px; font-size: 13px; color: #D6D2D4; }
.link { background: none; border: 0; padding: 0; color: #fff; text-decoration: underline; text-align: left; }
@media (max-width: 760px) {
  .side { flex-basis: 100%; flex-direction: row; flex-wrap: wrap; align-items: center; gap: 10px 16px; padding: 12px; }
  .side-brand img { width: 110px; }
  .side-brand span { display: none; }
  .side-nav { flex-direction: row; flex-wrap: wrap; }
  .side-nav a { height: 40px; }
  .side-foot { margin: 0; flex-direction: row; flex-wrap: wrap; gap: 4px 12px; align-items: center; }
}
.main { flex: 999 1 560px; padding: 24px 28px 40px; display: flex; flex-direction: column; gap: 18px; }
@media (max-width: 760px) { .main { padding: 16px 14px 32px; } }
.view { display: flex; flex-direction: column; gap: 18px; }
.topbar { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 12px; }
.tools { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.row { display: flex; flex-wrap: wrap; gap: 8px; }
.row-between { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 8px; }
.cols { display: flex; flex-wrap: wrap; gap: 16px; align-items: flex-start; }
.card { background: var(--white); border-radius: 16px; padding: 18px 20px; display: flex; flex-direction: column; gap: 12px; }
.card.flush { padding: 0 0 6px; gap: 0; }
.card .pad { padding: 18px 20px 10px; }
.stack { display: flex; flex-direction: column; gap: 10px; }
.scroll { overflow-x: auto; position: relative; }

/* controls */
.input { height: 44px; border-radius: 10px; border: 1px solid #C9C5C7; background: #fff; padding: 0 12px; font-size: 15px; width: 100%; }
.tools .input { width: auto; }
.field { display: flex; flex-direction: column; gap: 5px; font-weight: 500; font-size: 13px; }
.grid-form { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; }
.grid-form.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.check { display: flex; align-items: center; gap: 8px; cursor: pointer; }
.check input { width: 18px; height: 18px; accent-color: #5C8A00; }
.switch { display: flex; align-items: center; gap: 8px; font-weight: 600; cursor: pointer; height: 44px; padding: 0 12px; background: #fff; border: 1px solid #C9C5C7; border-radius: 10px; }
.switch input { width: 18px; height: 18px; accent-color: #5C8A00; }
.btn { height: 44px; padding: 0 16px; border-radius: 10px; border: 0; background: var(--black); color: #fff; font-weight: 600; white-space: nowrap; }
.btn:hover { background: #000; }
.btn.lime { background: var(--lime); color: var(--black); font-weight: 700; }
.btn.lime:hover { background: var(--lime-hover); }
.btn.ghost { background: #fff; color: var(--ink); border: 1px solid #B9B4B6; }
.btn.ghost:hover { border-color: var(--ink); }
.btn.sm { height: 34px; padding: 0 12px; font-size: 13px; border-radius: 8px; }
.btn:disabled { opacity: .5; cursor: wait; }
.btn.danger { background: #fff; color: #8A2414; border: 1px solid #E3B9B1; }
.error { color: #A3341F; margin: 0; font-size: 13px; }
.error:empty { display: none; }
.flash { position: sticky; top: 8px; z-index: 5; background: var(--black); color: #fff; border-radius: 12px; padding: 12px 16px; font-weight: 500; box-shadow: 0 6px 20px rgba(0,0,0,.15); }
.flash.bad { background: #8A2414; }

/* stats */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }
.stat { background: #fff; border-radius: 14px; padding: 14px 16px; display: flex; flex-direction: column; gap: 2px; }
.stat b { font-family: Montserrat, Inter, sans-serif; font-weight: 800; font-size: 28px; line-height: 1.15; }
.stat span { font-size: 13px; color: var(--muted); }
.notice { background: var(--black); color: var(--lime); border-radius: 12px; padding: 12px 16px; font-weight: 600; text-decoration: none; }

/* timeline */
.legend { display: flex; flex-wrap: wrap; gap: 12px; font-size: 12px; color: var(--muted); }
.legend span { display: flex; align-items: center; gap: 5px; }
.legend i { width: 12px; height: 12px; border-radius: 3px; display: inline-block; }
.k-res { background: var(--res-bg); border: 1px solid var(--res-line); }
.k-in { background: #8FCB3B; }
.k-coach { background: var(--black); }
.k-op { background: var(--op-bg); border: 1px dashed var(--op-line); }
.k-gone { background: var(--gone-bg); border: 1px dashed #C97A6C; }
.timeline { display: grid; gap: 4px; min-width: 760px; position: relative; }
.tl-head { font-size: 11px; color: var(--muted); }
.tl-court { font-weight: 600; display: flex; align-items: center; }
.tl-cell { height: 52px; border-radius: 6px; background: #F7F6F3; }
.tl-cell.op { background: var(--op-bg); border: 1px dashed #A9BCE3; }
.tl-block { height: 52px; border-radius: 8px; padding: 4px 8px; display: flex; flex-direction: column; justify-content: center; overflow: hidden; font-size: 12px; line-height: 1.25; border: 1px solid transparent; text-align: left; }
.tl-block b { font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tl-block span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tl-block.res { background: var(--res-bg); border-color: var(--res-line); color: var(--res-ink); }
.tl-block.in { background: #8FCB3B; color: #1B3006; }
.tl-block.coach { background: var(--black); color: #fff; }
.tl-block.coach.in { box-shadow: inset 0 0 0 3px #8FCB3B; }
.tl-block.gone { background: var(--gone-bg); border: 1px dashed #C97A6C; color: var(--gone-ink); }
.tl-now { position: absolute; top: 18px; bottom: 0; width: 2px; background: #D4351C; border-radius: 1px; pointer-events: none; }

/* tables */
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; vertical-align: middle; }
.table th { font-size: 12px; font-weight: 500; color: var(--muted); }
.table th:first-child, .table td:first-child { padding-left: 20px; }
.table th:last-child, .table td:last-child { padding-right: 20px; }
.table tbody tr:last-child td { border-bottom: 0; }
.table td.num, .table th.num { text-align: right; }
.table .acts { display: flex; gap: 6px; justify-content: flex-end; }
.table .empty-row td { color: var(--muted); text-align: center; padding: 22px; white-space: normal; }
.sub { display: block; font-size: 12px; color: var(--muted); }
.code { font-weight: 700; letter-spacing: .03em; }
.pill { display: inline-flex; align-items: center; height: 24px; padding: 0 10px; border-radius: 12px; font-size: 12px; font-weight: 600; background: var(--due-bg); color: var(--due-ink); }
.pill.in, .pill.paid, .pill.active { background: #E4F0D8; color: #2F5520; }
.pill.gone, .pill.cancelled, .pill.declined { background: var(--gone-bg); color: var(--gone-ink); }
.pill.requested, .pill.break { background: var(--warn-bg); color: var(--warn-ink); }
.pill.playing { background: var(--black); color: var(--lime); }
.pill.confirmed { background: var(--res-bg); color: var(--res-ink); }

/* open play */
.courts { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 12px; }
.court { background: #fff; border-radius: 16px; padding: 16px 18px; display: flex; flex-direction: column; gap: 10px; border: 2px solid transparent; }
.court.live { border-color: var(--black); }
.teams { display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); gap: 8px; align-items: center; }
.team { background: var(--ground); border-radius: 10px; padding: 8px 10px; display: flex; flex-direction: column; gap: 6px; }
.team input { height: 40px; text-align: center; font-weight: 700; font-size: 18px; }
.vs { font-weight: 700; color: var(--muted); }

/* coaching */
.req { border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; display: flex; flex-wrap: wrap; gap: 10px 16px; align-items: center; justify-content: space-between; }
.req .who { display: flex; flex-direction: column; gap: 2px; }
.req .acts { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.req select { width: auto; height: 36px; }
.types { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 10px; }
.type { background: var(--ground); border-radius: 12px; padding: 12px 14px; display: flex; justify-content: space-between; gap: 10px; }

/* print */
.print-head, .print-foot { display: none; }
@media print {
  @page { margin: 12mm; }
  body { background: #fff; font-size: 11pt; }
  .side, .tools, .no-print, .flash, .notice, .walkin, #view-today .card:has(.timeline), .acts, .legend { display: none !important; }
  .main { padding: 0; }
  .card, .stat { border: 1px solid #ccc; break-inside: avoid; }
  .print-head { display: block; font-family: Montserrat, Inter, sans-serif; font-weight: 800; font-size: 16pt; margin-bottom: 4mm; }
  .print-foot { display: block; margin-top: 8mm; font-size: 9pt; color: #555; border-top: 1px solid #ccc; padding-top: 3mm; }
  .scroll { overflow: visible; }
  .table th, .table td { padding: 5px 8px; }
}
