/* ==========================================================================
   Morlotti Academy Manager - visual identity
   Matches morlottiacademy.com: near-black surfaces, white uppercase display
   type, tennis-green accent. Change the three brand values below to retune
   the whole application.
   ========================================================================== */
:root {
  --black:        #0E0E0E;
  --charcoal:     #1A1A1A;
  --green:        #8DC63F;
  --green-dark:   #6BA22E;
  --green-soft:   rgba(141, 198, 63, .12);

  --surface:      #FFFFFF;
  --canvas:       #F3F4F1;
  --line:         #E3E5DF;
  --text:         #1B1B1B;
  --muted:        #7A7D75;

  --danger:       #C0392B;
  --warn:         #D98C00;
  --warn-solid:   #C77700;
  --info:         #2C6E9B;
  --radius:       10px;
}

* { -webkit-font-smoothing: antialiased; }

body {
  background: var(--canvas);
  color: var(--text);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif;
  font-size: 15px;
}

h1,h2,h3,h4,h5,.display {
  font-weight: 800;
  letter-spacing: .02em;
}

/* ---------- Login ---------- */
.login-wrap {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: radial-gradient(circle at 20% 20%, #232323 0%, var(--black) 70%);
}
.login-card {
  background: var(--surface); padding: 2.75rem; border-radius: var(--radius);
  width: 380px; box-shadow: 0 24px 70px rgba(0,0,0,.5);
  border-top: 4px solid var(--green);
}
.login-brand { font-size: 1.35rem; font-weight: 800; text-transform: uppercase; letter-spacing: .12em; }
.login-logo { width: 175px; max-width: 80%; height: auto; }
.login-sub { color: var(--muted); font-size: .78rem; text-transform: uppercase; letter-spacing: .18em; }

/* ---------- Sidebar navigation ---------- */
#sidebar {
  position: fixed; top: 0; left: 0; bottom: 0; width: 218px; background: var(--black);
  display: flex; flex-direction: column; z-index: 1040;
  border-right: 3px solid var(--green); transition: transform .18s ease;
}
.sb-brand { padding: 1.1rem 1rem .9rem; border-bottom: 1px solid rgba(255,255,255,.09); }
.sb-brand a {
  color: #fff; text-decoration: none; font-weight: 800; font-size: .92rem;
  letter-spacing: .08em; text-transform: uppercase;
}
.sb-brand .accent { color: var(--green); }
.sb-brand a { display: block; }
.sb-logo { width: 150px; max-width: 100%; height: auto; display: block; margin: 0 auto; }
.topbar-logo { height: 26px; width: auto; }
#nav-links { flex: 1; overflow-y: auto; padding: .5rem 0; }
#nav-links a {
  display: flex; align-items: center; gap: .6rem; padding: .52rem 1rem;
  color: rgba(255,255,255,.72); text-decoration: none; font-size: .74rem;
  font-weight: 600; text-transform: uppercase; letter-spacing: .05em;
  border-left: 3px solid transparent;
}
#nav-links a:hover { color: #fff; background: rgba(255,255,255,.06); }
#nav-links a.active { color: #fff; background: rgba(141,198,63,.16); border-left-color: var(--green); }
#nav-links a i { width: 15px; text-align: center; font-size: .8rem; opacity: .85; }
#nav-links .nav-sep {
  padding: .8rem 1rem .3rem; font-size: .6rem; letter-spacing: .16em;
  color: rgba(255,255,255,.32); text-transform: uppercase; font-weight: 700;
}
.nav-alert-dot {
  margin-left: auto; background: var(--danger); color: #fff; border-radius: 9px;
  font-size: .62rem; font-weight: 700; padding: 1px 6px; min-width: 18px; text-align: center;
}
.sb-foot { padding: .8rem 1rem 1rem; border-top: 1px solid rgba(255,255,255,.09); }
#nav-user { font-size: .66rem; text-transform: uppercase; letter-spacing: .07em; color: rgba(255,255,255,.6); }

#content-area { margin-left: 218px; min-height: 100vh; }
.topbar {
  display: none; align-items: center; gap: .75rem; background: var(--black);
  padding: .55rem .9rem; position: sticky; top: 0; z-index: 1030;
  border-bottom: 2px solid var(--green);
}
.topbar-title { color: #fff; font-weight: 700; text-transform: uppercase; letter-spacing: .07em; font-size: .82rem; }
.sb-toggle { background: none; border: 1px solid rgba(255,255,255,.3); color: #fff; border-radius: 6px; padding: .25rem .55rem; }
#sb-scrim { display: none; }

@media (max-width: 991.98px) {
  #sidebar { transform: translateX(-100%); }
  #sidebar.open { transform: translateX(0); }
  #content-area { margin-left: 0; }
  .topbar { display: flex; }
  #sb-scrim.show {
    display: block; position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 1035;
  }
}

/* ---------- Structure ---------- */
.page-title {
  font-size: 1.45rem; font-weight: 800; text-transform: uppercase;
  letter-spacing: .06em; color: var(--black); margin: 0;
}
.page-title:after {
  content: ""; display: block; width: 46px; height: 3px;
  background: var(--green); margin-top: .45rem;
}
.page-sub { color: var(--muted); font-size: .85rem; margin-top: .6rem; max-width: 780px; }

.card { border: 1px solid var(--line); border-radius: var(--radius); box-shadow: none; background: var(--surface); }
.card-header {
  background: var(--surface); border-bottom: 1px solid var(--line);
  font-weight: 700; text-transform: uppercase; letter-spacing: .07em; font-size: .74rem;
  color: var(--muted); padding: .8rem 1rem;
}

/* ---------- KPI tiles ---------- */
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
       padding: 1.1rem 1.2rem; height: 100%; position: relative; overflow: hidden; }
.kpi:before { content:""; position:absolute; left:0; top:0; bottom:0; width:3px; background: var(--green); }
.kpi-value { font-size: 1.65rem; font-weight: 800; color: var(--black); line-height: 1.1; }
.kpi-label { color: var(--muted); font-size: .68rem; text-transform: uppercase; letter-spacing: .12em; margin-top: .3rem; }
.kpi-note { font-size: .72rem; color: var(--muted); margin-top: .35rem; }
.kpi.alert:before { background: var(--danger); }
.kpi.alert .kpi-value { color: var(--danger); }
.kpi.dark { background: var(--black); }
.kpi.dark .kpi-value { color: #fff; }
.kpi.dark .kpi-label { color: rgba(255,255,255,.6); }

/* ---------- Tables ---------- */
.table { font-size: .88rem; margin-bottom: 0; }
.table thead th {
  background: var(--black); color: #fff; text-transform: uppercase;
  font-size: .66rem; letter-spacing: .1em; font-weight: 700;
  border: none; padding: .65rem .75rem; white-space: nowrap;
}
.table tbody td { padding: .6rem .75rem; vertical-align: middle; border-color: var(--line); }
.table tbody tr:hover { background: var(--green-soft); }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.table-empty { text-align: center; color: var(--muted); padding: 2.5rem 1rem; }

/* Long lists: everything above the column headings stays put, the rows scroll
   underneath, and the totals row (if any) stays pinned to the bottom. */
.table-sticky {
  max-height: calc(100vh - 300px);
  min-height: 240px;
  overflow-y: auto;
}
.table-sticky thead th {
  position: sticky; top: 0; z-index: 3;
}
.table-sticky tfoot tr.table-total td {
  position: sticky; bottom: 0; z-index: 3;
}
@media (max-width: 991.98px) {
  .table-sticky { max-height: calc(100vh - 240px); }
}

/* ---------- Buttons ---------- */
.btn { font-size: .8rem; font-weight: 600; border-radius: 7px; }
.btn-brand { background: var(--green); border-color: var(--green); color: var(--black); font-weight: 700; }
.btn-brand:hover { background: var(--green-dark); border-color: var(--green-dark); color: #fff; }
.btn-dark-brand { background: var(--black); border-color: var(--black); color: #fff; }
.btn-dark-brand:hover { background: #2b2b2b; border-color: #2b2b2b; color: var(--green); }
.btn-sm { font-size: .72rem; padding: .22rem .5rem; }
.btn-icon { padding: .2rem .45rem; }

/* ---------- Status pills ---------- */
.pill {
  display: inline-block; padding: .18rem .55rem; border-radius: 20px;
  font-size: .66rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em;
  border: 1px solid transparent; white-space: nowrap;
}
.pill-paid          { background: var(--green-soft); color: var(--green-dark); border-color: var(--green); }
.pill-partially_paid{ background: #FFF3DC; color: var(--warn-solid); border-color: #E8B85B; }
.pill-unpaid        { background: #FDECEA; color: var(--danger); border-color: #E9A79F; }
.pill-overdue       { background: #FDECEA; color: var(--danger); border-color: var(--danger); }
.pill-draft         { background: #EEEFEC; color: var(--muted); border-color: var(--line); }
.pill-sent          { background: #E7F0F7; color: var(--info); border-color: #A8C8DE; }
.pill-cancelled     { background: #EEEFEC; color: var(--muted); border-color: var(--line); }
.pill-overpaid      { background: #E7F0F7; color: var(--info); border-color: #A8C8DE; }
.pill-matched       { background: var(--green-soft); color: var(--green-dark); border-color: var(--green); }
.pill-unmatched     { background: #FFF3DC; color: var(--warn-solid); border-color: #E8B85B; }
.pill-ignored       { background: #EEEFEC; color: var(--muted); border-color: var(--line); }
.pill-KIS           { background: #E7F0F7; color: var(--info); border-color: #A8C8DE; }
.pill-WYCOMBE       { background: #F3E8F7; color: #7B3F9D; border-color: #C9A5D8; }
.pill-STANDARD      { background: #EEEFEC; color: var(--muted); border-color: var(--line); }
.pill-lg { font-size: .74rem; padding: .3rem .7rem; }

/* ---------- Reconciliation ---------- */
.recon-row { border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: .85rem; background: var(--surface); }
.recon-head { padding: .8rem 1rem; display: flex; justify-content: space-between; gap: 1rem; flex-wrap: wrap; align-items: center; }
.recon-amount { font-size: 1.15rem; font-weight: 800; color: var(--black); }
.recon-meta { font-size: .78rem; color: var(--muted); }
.suggestion {
  display: flex; justify-content: space-between; align-items: center; gap: .75rem;
  padding: .55rem .85rem; border-top: 1px dashed var(--line); font-size: .82rem; flex-wrap: wrap;
}
.confidence { font-weight: 800; font-size: .78rem; min-width: 44px; }
.conf-high { color: var(--green-dark); }
.conf-mid  { color: var(--warn-solid); }
.conf-low  { color: var(--muted); }

/* ---------- Invoice document ---------- */
.doc { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 2rem; }
.doc-head { display: flex; justify-content: space-between; align-items: flex-start;
            border-bottom: 3px solid var(--black); padding-bottom: 1rem; margin-bottom: 1.25rem; }
.doc-brand { font-size: 1.2rem; font-weight: 800; text-transform: uppercase; letter-spacing: .1em; }
.doc-logo { width: 155px; height: auto; }
.doc-brand .accent { color: var(--green); }
.doc-meta { text-align: right; font-size: .82rem; }
.doc-total-row { display: flex; justify-content: flex-end; gap: 2.5rem; padding: .3rem 0; font-size: .9rem; }
.doc-total-row.grand { border-top: 2px solid var(--black); margin-top: .5rem; padding-top: .6rem;
                       font-size: 1.05rem; font-weight: 800; }
.line-detail { font-size: .76rem; color: var(--muted); margin-top: .2rem; }

/* ---------- Rate matrix ---------- */
.rate-table { font-size: .8rem; }
.rate-table th.cat { font-size: .58rem; }
.rate-table td.rate-cell { text-align: right; font-variant-numeric: tabular-nums; }
.rate-group-STANDARD { background: #fff; }
.rate-group-KIS { background: #F4F9FC; }
.rate-group-WYCOMBE { background: #FAF5FC; }

/* ---------- Misc ---------- */
.modal-header { background: var(--black); color: #fff; }
.modal-header .btn-close { filter: invert(1) grayscale(1) brightness(2); }
.modal-title { text-transform: uppercase; letter-spacing: .06em; font-size: .95rem; font-weight: 800; }
.form-label { font-size: .72rem; text-transform: uppercase; letter-spacing: .07em;
              font-weight: 700; color: var(--muted); margin-bottom: .25rem; }
.form-control, .form-select { font-size: .87rem; border-color: var(--line); }
.form-control:focus, .form-select:focus { border-color: var(--green); box-shadow: 0 0 0 .18rem var(--green-soft); }
.small-muted { color: var(--muted); font-size: .78rem; }
.money-pos { color: var(--green-dark); font-weight: 600; }
.money-neg { color: var(--danger); font-weight: 600; }
/* Bootstrap paints every table cell with its own colour variable, at a
   higher specificity than a bare class, so money inside a table needs a
   rule that can answer it. Money owed has to read as money owed. */
.table > :not(caption) > * > .money-pos { color: var(--green-dark); }
.table > :not(caption) > * > .money-neg { color: var(--danger); font-weight: 700; }
.section-gap { margin-top: 2rem; }
.filter-bar { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
              padding: .75rem 1rem; margin-bottom: 1rem; }
.report-card { border: 1px solid var(--line); border-radius: var(--radius); background: #fff;
               padding: 1.1rem; height: 100%; display: flex; flex-direction: column; }
.report-card h6 { font-weight: 800; text-transform: uppercase; font-size: .78rem; letter-spacing: .05em; }
.spinner-wrap { text-align: center; padding: 3.5rem 0; }
.tab-strip { border-bottom: 2px solid var(--line); margin-bottom: 1.25rem; display: flex; gap: .25rem; flex-wrap: wrap; }
.tab-strip button {
  background: none; border: none; padding: .55rem .95rem; font-size: .76rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: .06em; color: var(--muted); border-bottom: 3px solid transparent;
  margin-bottom: -2px;
}
.tab-strip button.active { color: var(--black); border-bottom-color: var(--green); }
@media print {
  .app-navbar, .btn, .tab-strip, .no-print { display: none !important; }
  body { background: #fff; }
  .doc { border: none; padding: 0; }
}

/* ---------- Compact tables & sortable headers ---------- */
.table-compact tbody td { padding: .34rem .6rem; font-size: .84rem; }
.table-compact thead th { padding: .45rem .6rem; }
.nowrap { white-space: nowrap; }
.sort-h { color: inherit; text-decoration: none; }
.sort-h:hover { color: var(--green); }
.sort-h.on { color: var(--green); }

.build-badge { font-size: .58rem; letter-spacing: .1em; color: rgba(255,255,255,.35);
               text-transform: uppercase; margin-top: .25rem; }

/* ---------- Duplicate merge ---------- */
.dup-pair { display: flex; align-items: stretch; gap: .75rem; border: 1px solid var(--line);
            border-radius: var(--radius); padding: .7rem .9rem; margin-bottom: .6rem; background: #fff; }
.dup-score { min-width: 46px; font-weight: 800; color: var(--green-dark); align-self: center; font-size: .95rem; }
.dup-side { flex: 1; border-left: 3px solid var(--line); padding-left: .75rem; }
.dup-side:hover { border-left-color: var(--green); }
.dup-plus { align-self: center; font-weight: 800; color: var(--muted); }
.dup-act { align-self: center; }
.dup-choice { border: 1px solid var(--line); border-radius: 8px; padding: .45rem .8rem;
              display: flex; align-items: center; gap: .5rem; cursor: pointer; font-size: .88rem; }
.dup-choice:has(input:checked) { border-color: var(--green); background: var(--green-soft); font-weight: 600; }

/* ---------- Visible error bar ---------- */
#err-bar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 3000;
           background: #7f1d1d; color: #fff; padding: .6rem .9rem; font-size: .82rem; }
#err-bar .err-where { opacity: .75; font-size: .72rem; margin-top: .15rem; }
#err-bar button { background: #fff; color: #7f1d1d; border: none; border-radius: 5px;
                  padding: .12rem .55rem; font-size: .72rem; font-weight: 700; margin-left: .4rem; }

.form-section { font-size: .68rem; font-weight: 800; text-transform: uppercase; letter-spacing: .12em;
                color: var(--muted); border-bottom: 2px solid var(--line); padding-bottom: .3rem;
                margin: .4rem 0 .9rem; }

/* ---------- Unpaid-balance block ---------- */
.debt-block { border: 2px solid var(--danger); border-radius: var(--radius); overflow: hidden; margin-bottom: 1rem; }
.debt-block .db-title { background: var(--danger); color: #fff; font-weight: 800; font-size: .78rem;
                        letter-spacing: .04em; padding: .5rem .8rem; }
.debt-block .db-body { padding: .6rem .8rem; font-size: .85rem; background: #FDECEA; color: #7f1d1d; }
/* ---------- Unpaid balance, coach's own form ----------
   A coach is warned about an unsettled account but is not stopped from
   recording the lesson they have just taught - the office follows it up. */
.debt-warn { border: 2px solid var(--warn); border-radius: var(--radius); overflow: hidden; margin-bottom: 1rem; }
.debt-warn .dw-title { background: var(--warn); color: #fff; font-weight: 800; font-size: .78rem;
                       letter-spacing: .04em; padding: .5rem .8rem; }
.debt-warn .dw-body { padding: .6rem .8rem; font-size: .85rem; background: #FFF7E6; color: #7A5C00; }

/* ---------- What a player owes, on the coach's own lesson form ---------- */
.cl-bal { font-size: .78rem; white-space: nowrap; }
.cl-bal.over { color: var(--danger); font-weight: 700; }
.cl-bal.owing { color: var(--warn-solid); }
.cl-bal.clear { color: var(--muted); }

.payer-box { background: var(--green-soft); border: 1px solid var(--green); border-radius: 8px;
             padding: .5rem .75rem; font-size: .85rem; }
.path-box { background: #F2F3F0; border: 1px solid var(--line); border-radius: 6px;
            padding: .5rem .7rem; font-family: monospace; font-size: .78rem; word-break: break-all; }

.freshness { background: var(--green-soft); border: 1px solid var(--green); border-radius: 8px;
             padding: .5rem .8rem; font-size: .82rem; margin-bottom: 1rem; }
.freshness.stale { background: #FDECEA; border-color: var(--danger); color: #7f1d1d; }

/* ---------- Totals row at the foot of a table ---------- */
table tfoot tr.table-total td { background: var(--charcoal); color: #fff; font-weight: 800;
                                border-top: 2px solid var(--charcoal); white-space: nowrap; }
table tfoot tr.table-total td.money-neg { color: #FFB4AB; }

/* ---------- Client account statement ---------- */
.st-table tr.st-pay td { background: var(--green-soft); font-weight: 600; }
.st-table tr.st-open td { background: #F2F3F0; font-style: italic; }

/* ---------- Number fields without the up/down arrows ---------- */
input.no-spin::-webkit-outer-spin-button,
input.no-spin::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
input.no-spin { -moz-appearance: textfield; appearance: textfield; }
input.no-spin[readonly] { background: #F2F3F0; color: var(--muted); cursor: default; }

/* ---------- Filling schedule ----------------------------------------------
   The week grid is drawn to scale: a column per day, and every lesson placed
   by its real start and length, so an empty hour looks empty. Overlapping
   lessons share the column width side by side. */
.sched-toolbar {
  display: flex; gap: .6rem; align-items: flex-end; flex-wrap: wrap;
  margin-bottom: 1rem;
}
.sched-toolbar .form-label { font-size: .7rem; margin-bottom: .15rem; }

/* The week scrolls both ways inside this box. The day names stay pinned to
   the top and the hour column to the left, so neither is ever lost - which
   matters once the cells are big enough to hold a whole group. */
.sched-scroll {
  overflow: auto; max-height: calc(100vh - 230px);
  border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface);
}
.sched-grid {
  display: grid; grid-template-columns: 62px repeat(7, minmax(230px, 1fr));
  min-width: max-content;
}
.sched-grid-head {
  position: sticky; top: 0; z-index: 4; background: var(--black); color: #fff;
  font-size: .7rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em;
  padding: .5rem .4rem; text-align: center; border-left: 1px solid rgba(255,255,255,.12);
}
.sched-grid-head.corner { border-left: 0; left: 0; z-index: 6; }
.sched-grid-head small { display: block; font-weight: 400; letter-spacing: 0; opacity: .7; text-transform: none; }
.sched-grid-head.is-today { background: var(--green-dark); }

.sched-hours {
  position: sticky; left: 0; z-index: 3;
  border-right: 1px solid var(--line); background: var(--canvas);
}
.sched-hour-label {
  position: absolute; right: .35rem; font-size: .66rem; color: var(--muted);
  padding-top: 2px; font-variant-numeric: tabular-nums;
}
.sched-day {
  position: relative; border-left: 1px solid var(--line);
  background-image: repeating-linear-gradient(to bottom,
    var(--line) 0 1px, transparent 1px var(--sched-hour, 48px));
}
.sched-day.is-weekend { background-color: #FAFBF8; }

.sched-item {
  position: absolute; overflow: hidden; cursor: pointer;
  border-radius: 6px; padding: .3rem .4rem; font-size: .7rem; line-height: 1.3;
  border: 1px solid; border-left-width: 4px; color: #111;
}
.sched-item:hover { filter: brightness(.97); }
.sched-item .si-time { font-weight: 700; font-variant-numeric: tabular-nums;
  display: flex; justify-content: space-between; gap: .3rem; align-items: baseline; }
.sched-item .si-mins { font-weight: 400; opacity: .7; font-size: .62rem; }
.sched-item .si-who { font-weight: 600; margin: .12rem 0; }
.sched-item .si-sub { opacity: .78; }
.sched-item .si-note { opacity: .72; font-style: italic; font-size: .64rem; margin-top: .1rem; }
.sched-item .si-flag {
  font-size: .56rem; font-weight: 800; letter-spacing: .05em;
  background: rgba(0,0,0,.16); border-radius: 3px; padding: 0 .22rem; white-space: nowrap;
}

/* Three states, three colours. Green is the ordinary standing lesson, blue a
   trial with a date agreed, yellow a trial nobody has confirmed yet - the
   one that needs chasing, so it is the colour that carries a warning. */
/* The same bright fills the coaches already use in the workbooks: the term
   tabs paint a confirmed lesson #00FF00 and a query #FFFF00. Blue is the one
   Excel has no convention for, so it takes Excel's own light blue. Text is
   near-black throughout - these are strong colours and anything paler on
   them stops being readable. */
.sched-item.st-confirmed       { background: #00FF00; border-color: #12B312; border-left-color: #0A7A0A; }
.sched-item.st-trial_confirmed { background: #00B0F0; border-color: #0079A8; border-left-color: #005778; }
.sched-item.st-trial_waiting   { background: #FFFF00; border-color: #C9A400; border-left-color: #8A7000; }

/* One line per player: given name, the ball they play with, then age and
   level small enough to skim past when you are only looking for a name. */
.sched-item .si-p { display: flex; align-items: center; gap: .22rem; }
.sched-item .si-name { font-weight: 600; }
.sched-item .si-meta { opacity: .72; font-size: .63rem; }
.si-ball {
  width: .52rem; height: .52rem; border-radius: 50%; flex: 0 0 auto;
  border: 1px solid rgba(0,0,0,.25); background: #CCC;
}
.si-ball.b-red    { background: #D9443F; }
.si-ball.b-orange { background: #E98B27; }
.si-ball.b-green  { background: #4E9A3F; }
.si-ball.b-yellow { background: #EFD02B; }
.sched-item.si-ended { background: #EEEFEC; border-color: var(--line); border-left-color: var(--muted); }
.sched-item.si-done { border-left-color: var(--green-dark); }
.sched-item.si-notdone { background: #FDECEA; border-color: #E9A79F; border-left-color: var(--danger); }
.sched-item.si-changed { background: #FFF3DC; border-color: #E8B85B; border-left-color: var(--warn-solid); }

.sched-legend { display: flex; gap: 1rem; flex-wrap: wrap; font-size: .72rem; color: var(--muted); margin-top: .6rem; }
.sched-legend span::before {
  content: ""; display: inline-block; width: .7rem; height: .7rem; border-radius: 3px;
  margin-right: .3rem; vertical-align: -1px; background: var(--green-soft); border: 1px solid var(--green);
}
.sched-legend .lg-notdone::before { background: #FDECEA; border-color: #E9A79F; }
.sched-legend .lg-changed::before { background: #FFF3DC; border-color: #E8B85B; }
.sched-legend .lg-ended::before { background: #EEEFEC; border-color: var(--line); }

/* Day list used by the week detail, where reading matters more than scale.
   One day per row across the full width: a week reads top to bottom in the
   order it is taught, which a two-column split breaks - Friday used to sit
   at the top of the second column, level with Monday. */
.sched-days { display: flex; flex-direction: column; gap: .8rem; }
.sched-daybox { border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.sched-daybox > header {
  padding: .5rem .85rem; border-bottom: 1px solid var(--line); background: var(--canvas);
  font-weight: 700; font-size: .78rem; display: flex; justify-content: space-between; align-items: center;
}
.sched-daybox.is-empty > header { color: var(--muted); font-weight: 600; }
/* The full width buys real columns, so every lesson lines up down the day:
   when it is, what it is and who is on court, where, and what the coach said.
   Below 900px it falls back to stacking, which is how a phone reads it. */
.sched-line {
  display: grid; gap: .25rem .9rem; align-items: baseline;
  grid-template-columns: 104px minmax(0, 1fr) minmax(0, 15rem) 11rem 2.6rem auto;
  padding: .55rem .85rem; border-top: 1px dashed var(--line);
}
.sched-line:first-of-type { border-top: 0; }
.sched-line .sl-time { font-weight: 700; font-variant-numeric: tabular-nums; }
.sched-line .sl-body { font-size: .82rem; min-width: 0; }
.sched-line .sl-type { font-weight: 600; }
.sched-line .sl-who { color: var(--ink); }
.sched-line .sl-where { font-size: .78rem; color: var(--muted); min-width: 0; }
/* Two pills answer two questions - did it run, and who pays - so they sit
   one under the other. Side by side they read as a single long label. */
.sched-line .sl-state { font-size: .78rem; line-height: 1.9; }
.sched-line .sl-state .pill { display: inline-block; }

/* The office's tick, in its own narrow column so a week can be read down. */
.sched-line .sl-check { justify-self: center; }
.sl-tick {
  border: 0; background: none; padding: .1rem .2rem; font-size: 1.05rem;
  line-height: 1; cursor: pointer; color: var(--line);
}
.sl-tick.is-on { color: var(--green-dark); }
.sl-tick.is-off:hover, .sl-tick.is-off:focus-visible { color: var(--muted); }
.sl-tick.is-na { color: var(--line); cursor: default; }
.sched-line .sl-act { justify-self: end; white-space: nowrap; }
.sched-line .sl-sub { color: var(--muted); font-size: .74rem; }

@media (max-width: 900px) {
  .sched-line { grid-template-columns: 104px minmax(0, 1fr) 2.6rem auto; }
  .sched-line .sl-where { grid-column: 2 / -1; }
  .sched-line .sl-state { grid-column: 2 / -1; }
}
@media (max-width: 560px) {
  .sched-line { grid-template-columns: 1fr 2.6rem auto; }
  .sched-line .sl-body,
  .sched-line .sl-where,
  .sched-line .sl-state { grid-column: 1 / -1; }
}

.pill-not_prepared { background: #EEEFEC; color: var(--muted); border-color: var(--line); }
.pill-not_published{ background: #EEEFEC; color: var(--muted); border-color: var(--line); }
.pill-done         { background: var(--green-soft); color: var(--green-dark); border-color: var(--green); }
.pill-changed      { background: #FFF3DC; color: var(--warn-solid); border-color: #E8B85B; }
.pill-notdone      { background: #FDECEA; color: var(--danger); border-color: #E9A79F; }
.pill-absent       { background: #FDECEA; color: var(--danger); border-color: #E9A79F; }
.pill-present      { background: var(--green-soft); color: var(--green-dark); border-color: var(--green); }

.sched-chip {
  display: inline-flex; align-items: center; gap: .35rem;
  padding: .18rem .3rem .18rem .55rem; border-radius: 20px; font-size: .76rem;
  background: var(--canvas); border: 1px solid var(--line); color: var(--text);
}
.sched-chip a { color: var(--muted); text-decoration: none; font-size: .95rem; line-height: 1; padding: 0 .2rem; }
.sched-chip a:hover { color: var(--danger); }

/* ---------- Coach day sheet -----------------------------------------------
   Built for a phone held in one hand on a court, and merely narrow on a
   desktop. Touch targets stay big; nothing needs a second hand. */
.day-wrap { max-width: 560px; margin: 0 auto; padding-bottom: 5rem; }

.day-head { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: .9rem 1rem; margin-bottom: 1rem; }
.day-coach { font-weight: 800; font-size: 1.05rem; letter-spacing: .01em; }
.day-date { color: var(--muted); font-size: .82rem; }

.day-progress { margin-top: .8rem; }
.dp-bar { height: 5px; background: var(--canvas); border-radius: 3px; overflow: hidden; }
.dp-bar span { display: block; height: 100%; background: var(--green); transition: width .25s ease; }
.dp-label { font-size: .72rem; color: var(--muted); margin-top: .3rem; }

.day-strip { display: flex; gap: .3rem; margin-top: .85rem; }
.day-pip { flex: 1; border: 1px solid var(--line); background: var(--surface); border-radius: 8px;
  padding: .35rem .1rem; text-align: center; line-height: 1.25; cursor: pointer; }
.day-pip.on { background: var(--black); border-color: var(--black); color: #fff; }
.day-pip .dp-dow { display: block; font-size: .6rem; text-transform: uppercase; letter-spacing: .06em; opacity: .7; }
.day-pip .dp-num { display: block; font-weight: 700; font-size: .84rem; }
.day-pip .dp-dot { display: block; font-size: .62rem; color: var(--muted); }
.day-pip.on .dp-dot { color: rgba(255,255,255,.75); }
.day-pip.pip-done .dp-dot { color: var(--green-dark); font-weight: 800; }
.day-pip.pip-todo .dp-dot { color: var(--warn-solid); font-weight: 800; }

.day-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  margin-bottom: .7rem; overflow: hidden; }
.day-card.is-done { border-left: 3px solid var(--green); }
/* The stripe says at a glance what happened: green it ran, red it did not.
   is-off also fades the card, so the two together read without being read. */
.day-card.is-off { opacity: .72; border-left: 3px solid var(--danger); }
.dc-head { display: flex; gap: .7rem; padding: .8rem .9rem; cursor: pointer; align-items: flex-start; }
.dc-head:hover { background: var(--canvas); }
.dc-when { font-weight: 800; font-variant-numeric: tabular-nums; min-width: 52px; flex-shrink: 0; }
.dc-when small { display: block; font-weight: 400; font-size: .66rem; color: var(--muted); }
.dc-main { flex: 1; min-width: 0; }
.dc-type { font-weight: 700; font-size: .86rem; }
.dc-where { font-size: .74rem; color: var(--muted); }
.dc-roster { font-size: .78rem; margin-top: .2rem; }
.dc-roster .out { text-decoration: line-through; color: var(--muted); }
.dc-state { text-align: right; white-space: nowrap; flex-shrink: 0; }

.dc-body { border-top: 1px solid var(--line); padding: .85rem .9rem 1rem; }
.dc-sect { font-size: .66rem; font-weight: 700; text-transform: uppercase; letter-spacing: .08em;
  color: var(--muted); margin: .2rem 0 .5rem; }
.dc-player { display: flex; justify-content: space-between; align-items: center; gap: .6rem;
  padding: .4rem 0; border-bottom: 1px dashed var(--line); font-size: .88rem; }
.dc-player:last-of-type { border-bottom: 0; }
.dc-player.absent > span { text-decoration: line-through; color: var(--muted); }
.dc-toggle { border: 1px solid var(--green); background: var(--green-soft); color: var(--green-dark);
  border-radius: 20px; padding: .3rem .85rem; font-size: .72rem; font-weight: 700; min-width: 82px; }
.dc-toggle.absent { border-color: #E9A79F; background: #FDECEA; color: var(--danger); }

.dc-note { background: var(--canvas); border-radius: 8px; padding: .55rem .7rem; font-size: .76rem;
  color: var(--text); margin: .6rem 0; line-height: 1.45; }
.dc-chips { display: flex; gap: .4rem; flex-wrap: wrap; }
.dc-chip { border: 1px solid var(--line); background: var(--surface); border-radius: 20px;
  padding: .4rem .85rem; font-size: .76rem; font-weight: 600; }
.dc-chip.on { background: var(--green-soft); border-color: var(--green); color: var(--green-dark); }
.dc-chip.danger.on { background: #FDECEA; border-color: #E9A79F; color: var(--danger); }
.dc-ref { font-size: .68rem; color: var(--muted); margin-top: .6rem; }
.dc-actions { margin-top: .85rem; }

.day-foot { position: sticky; bottom: 0; background: var(--black); color: #fff;
  border-radius: var(--radius); padding: .7rem .9rem; display: flex; gap: 1rem;
  align-items: center; justify-content: space-between; margin-top: 1rem; }
.df-a { font-weight: 800; font-variant-numeric: tabular-nums; }
.df-b { font-size: .68rem; opacity: .7; }

.pill-charge { background: var(--green-soft); color: var(--green-dark); border-color: var(--green); }
.pill-waive  { background: #E7F0F7; color: var(--info); border-color: #A8C8DE; }

/* ---------- The week's final check ---------- */
.wk-check { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: .8rem 1rem; margin-bottom: 1rem; }
.wk-stats { display: flex; gap: 1.6rem; flex-wrap: wrap; }
.wk-stat { text-align: center; min-width: 62px; color: var(--muted); }
.wk-stat .ws-n { font-size: 1.3rem; font-weight: 800; line-height: 1.1; }
.wk-stat .ws-l { font-size: .66rem; text-transform: uppercase; letter-spacing: .06em; }
.wk-stat.ok .ws-n   { color: var(--green-dark); }
.wk-stat.warn .ws-n { color: var(--warn-solid); }
.wk-stat.bad .ws-n  { color: var(--danger); }
.wk-loose { margin-top: .7rem; padding-top: .6rem; border-top: 1px dashed var(--line);
  font-size: .78rem; color: var(--warn-solid); }
.wk-loose.ok { color: var(--green-dark); }

.pill-returned { background: #FFF3DC; color: var(--warn-solid); border-color: #E8B85B; }
.pill-checked  { background: var(--green-soft); color: var(--green-dark); border-color: var(--green); }

/* How a lesson settled, on the office's screens. */
.pill-rain_short  { background: #FFF3DC; color: var(--warn-solid); border-color: #E8B85B; }
.pill-rain_long   { background: #FFF3DC; color: var(--warn-solid); border-color: #E8B85B; }
.pill-late_cancel { background: #FDECEA; color: var(--danger); border-color: #E9A79F; }
/* A lesson that did not happen is the opposite of one that did, so it reads
   red against the green - not grey, which looks like nobody has said yet. */
.pill-none        { background: #FDECEA; color: var(--danger); border-color: #E9A79F; }

/* ---------- Charts -------------------------------------------------------
   A canvas with a fixed aspect ratio collapses to a sliver on a phone, so
   the chart gets a box with a real height instead and fills it. */
.chart-box { position: relative; height: 300px; }
/* Fifteen named players need room to be read; a 300px box crushes them. */
.chart-box.tall { height: 460px; }
@media (max-width: 575.98px) {
  .chart-box { height: 240px; }
}

/* ---------- A coach's lesson list, built for a phone ---------- */
.les-total { display: flex; justify-content: space-between; align-items: center;
  background: var(--black); color: #fff; border-radius: var(--radius);
  padding: .7rem .9rem; margin-bottom: .8rem; }
.les-total .lt-n { font-weight: 800; }
.les-total .lt-h { font-size: .7rem; opacity: .7; }
.les-total .lt-fee { font-weight: 800; font-size: 1.15rem; font-variant-numeric: tabular-nums; }

.les-card { background: var(--surface); border: 1px solid var(--line);
  border-left: 3px solid var(--green); border-radius: var(--radius);
  padding: .7rem .85rem; margin-bottom: .6rem; }
.lc-top { display: flex; justify-content: space-between; align-items: flex-start; gap: .75rem; }
.lc-when { font-weight: 700; font-size: .88rem; }
.lc-time { font-size: .74rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.lc-fee { font-weight: 800; font-variant-numeric: tabular-nums; white-space: nowrap; }
.lc-what { margin-top: .45rem; display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }
.lc-venue { font-size: .74rem; color: var(--muted); }
.lc-who { margin-top: .35rem; font-size: .82rem; }

@media (min-width: 576px) {
  .les-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: .6rem; }
  .les-card { margin-bottom: 0; }
}

/* ---------- Phones ------------------------------------------------------
   Added to the home screen the app paints edge to edge, so anything pinned
   to an edge has to clear the notch and the home indicator itself. */
.topbar { padding-top: env(safe-area-inset-top); }
#sidebar { padding-top: env(safe-area-inset-top); }
.day-foot { bottom: env(safe-area-inset-bottom); }
.day-wrap { padding-bottom: calc(5rem + env(safe-area-inset-bottom)); }

@media (max-width: 575.98px) {
  /* Room for a thumb: the phone screens are used one-handed, on a court. */
  .btn { padding: .5rem .85rem; }
  .btn-sm { padding: .35rem .6rem; }
  .dc-toggle { min-height: 40px; }
  .dc-chip { min-height: 40px; }
  .day-pip { padding: .45rem .1rem; }
  .page-title { font-size: 1.15rem; }
  main.container-fluid { padding-left: .75rem; padding-right: .75rem; }
  /* A wide table is never readable on a phone - let it scroll on its own
     rather than pushing the whole page sideways. */
  .table-responsive { -webkit-overflow-scrolling: touch; }
}

/* The worksheet comment behind a shared transfer, shown while deciding. */
.recon-split { border-top: 1px dashed var(--line); background: var(--canvas);
  padding: .6rem .85rem; font-size: .8rem; }
.recon-split .rs-quote { font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: .76rem; color: var(--text); margin: .25rem 0 .15rem; }
.recon-split .rs-sub { font-size: .72rem; color: var(--muted); }

/* What the three colours on the master mean. */
.sched-key { display: flex; gap: .6rem; flex-wrap: wrap; font-size: .7rem; }
.sched-key > span { display: inline-flex; align-items: center; gap: .3rem; color: var(--muted); }
.sched-key > span::before {
  content: ""; width: .7rem; height: .7rem; border-radius: 3px; border: 1px solid;
}
.sched-key .k-confirmed::before       { background: #00FF00; border-color: #12B312; }
.sched-key .k-trial_confirmed::before { background: #00B0F0; border-color: #0079A8; }
.sched-key .k-trial_waiting::before   { background: #FFFF00; border-color: #C9A400; }

/* A week at a time, with a way out of it. The strip only ever shows seven
   days, so a coach confirming on Monday what happened on Saturday needs the
   arrows to get back there. */
.day-week { display: flex; align-items: center; gap: .4rem; }
.day-week .day-strip { flex: 1 1 auto; min-width: 0; }
.day-nav {
  flex: 0 0 auto; width: 2rem; height: 2.4rem; border-radius: 8px;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  font-size: .8rem; cursor: pointer;
}
.day-nav:hover { background: var(--canvas); }

/* The next question after "no show": is it charged for. Indented under the
   player it belongs to, so it reads as part of that name rather than a new
   decision about the whole lesson. */
.dc-charge {
  display: flex; align-items: center; gap: .4rem; flex-wrap: wrap;
  padding: .35rem .6rem .6rem 1.1rem; border-left: 2px solid var(--line); margin-left: .6rem;
}
.dc-charge .dc-ask { font-size: .72rem; color: var(--muted); }
