:root {
  --bg: #f4f6f5;
  --surface: #ffffff;
  --surface-2: #f8faf9;
  --line: #e2e7e5;
  --line-strong: #cfd7d4;
  --text: #17231f;
  --muted: #64716c;
  --brand: #0e7c86;
  --brand-ink: #0a5c64;
  --brand-soft: #e3f2f3;
  --accent: #e89a2c;
  --accent-soft: #fdf1df;
  --rental: #5b6ee1;
  --rental-soft: #eceffd;
  --ok: #2f8a4f;
  --ok-soft: #e4f3e8;
  --warn: #a8670b;
  --warn-soft: #fdf3e1;
  --err: #c0392b;
  --err-soft: #fbe9e7;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 32, 28, .06), 0 2px 8px rgba(16, 32, 28, .04);
  --font: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #101615; --surface: #172020; --surface-2: #1b2524; --line: #26332f; --line-strong: #334440;
    --text: #e6eeeb; --muted: #94a39e; --brand: #3fb3bc; --brand-ink: #7fd3d9; --brand-soft: #173436;
    --accent: #f2b45c; --accent-soft: #3a2c16; --rental: #8d9bf0; --rental-soft: #22284a;
    --ok: #5cc27f; --ok-soft: #173322; --warn: #e4a948; --warn-soft: #382a12; --err: #f07163; --err-soft: #3d1c19;
    --shadow: none; color-scheme: dark;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body { font-family: var(--font); font-size: 14px; line-height: 1.45; color: var(--text); background: var(--bg); -webkit-font-smoothing: antialiased; }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 24px; margin: 0 0 4px; letter-spacing: -.01em; }
h2 { font-size: 16px; margin: 0 0 12px; }
h3 { font-size: 13px; margin: 16px 0 8px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
code, pre { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; }
code { background: var(--surface-2); border: 1px solid var(--line); padding: 1px 5px; border-radius: 5px; word-break: break-all; }
pre.code { background: var(--surface-2); border: 1px solid var(--line); padding: 10px; border-radius: 8px; overflow-x: auto; white-space: pre-wrap; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.right { text-align: right; }
.nowrap { white-space: nowrap; }
.danger-text { color: var(--err) !important; }
.owes { color: var(--err); font-weight: 600; }
.credit { color: var(--ok); font-weight: 600; }
.pos { color: var(--ok); }
.neg { color: var(--err); }

/* ---------- shell ---------- */
.shell { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }
.sidebar { position: sticky; top: 0; height: 100vh; background: var(--surface); border-right: 1px solid var(--line); display: flex; flex-direction: column; padding: 16px 12px; }
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 18px; }
.brand strong { display: block; font-size: 15px; }
.brand small { color: var(--muted); font-size: 12px; }
/* Club logo: shown on a white circle so it reads in light and dark mode */
.logo { display: block; flex: none; width: 46px; height: 46px; border-radius: 50%; background: #fff; padding: 2px; object-fit: contain; box-shadow: 0 0 0 1px var(--line); }
.brand.big { flex-direction: column; text-align: center; gap: 12px; }
.brand.big .logo { width: 120px; height: 120px; padding: 4px; }
.logo.sm { width: 28px; height: 28px; padding: 1px; display: inline-block; vertical-align: middle; margin-right: 8px; }
.brand.big strong { font-size: 18px; }
nav { display: flex; flex-direction: column; gap: 2px; flex: 1; overflow-y: auto; }
nav a { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 8px; color: var(--text); font-weight: 500; }
nav a:hover { background: var(--surface-2); text-decoration: none; }
nav a.active { background: var(--brand-soft); color: var(--brand-ink); }
nav .ico { width: 18px; text-align: center; opacity: .75; }
.me { border-top: 1px solid var(--line); padding: 12px 8px 0; display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.me strong { display: block; font-size: 13px; }
.me small { color: var(--muted); }
.topbar { display: none; }
main { min-width: 0; outline: none; }
.page { max-width: 1180px; margin: 0 auto; padding: 24px 28px 64px; }
.page.loading { color: var(--muted); }

/* ---------- login ---------- */
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; background: linear-gradient(160deg, var(--brand-soft), var(--bg) 60%); }
.login-card { width: 100%; max-width: 360px; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 28px; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 12px; }

/* ---------- controls ---------- */
label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; font-weight: 600; color: var(--muted); margin-bottom: 10px; }
input, select, textarea { font: inherit; font-size: 14px; color: var(--text); background: var(--surface); border: 1px solid var(--line-strong); border-radius: 8px; padding: 8px 10px; width: 100%; min-height: 38px; font-weight: 400; }
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid color-mix(in srgb, var(--brand) 35%, transparent); border-color: var(--brand); }
input[readonly] { background: var(--surface-2); }
fieldset { border: 0; padding: 0; margin: 0; min-width: 0; }
fieldset:disabled { opacity: .7; }
label.check { flex-direction: row; align-items: center; gap: 8px; color: var(--text); font-weight: 500; font-size: 14px; }
label.check input { width: auto; min-height: 0; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; font: inherit; font-weight: 600; font-size: 13px; padding: 8px 14px; border-radius: 8px; border: 1px solid var(--line-strong); background: var(--surface); color: var(--text); cursor: pointer; white-space: nowrap; min-height: 36px; }
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { background: var(--brand-ink); }
.btn.accent { background: var(--accent); border-color: var(--accent); color: #241703; }
.btn.danger { background: var(--err); border-color: var(--err); color: #fff; }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.ghost:hover { background: var(--surface-2); }
.btn.sm { padding: 5px 10px; min-height: 30px; font-size: 12px; }
.btn.big { padding: 12px 22px; font-size: 15px; }
.btn.block { width: 100%; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.icon-btn { background: none; border: 0; cursor: pointer; font-size: 16px; color: var(--muted); padding: 6px; border-radius: 6px; }
.icon-btn:hover { background: var(--surface-2); }
.with-btn { display: flex; gap: 6px; }
.with-btn select { width: auto; }
.row { display: flex; gap: 8px; align-items: center; margin: 8px 0; }
.row.wrap { flex-wrap: wrap; }
.grid2, .grid3 { display: grid; gap: 0 12px; }
.grid2 { grid-template-columns: 1fr 1fr; }
.grid3 { grid-template-columns: repeat(3, 1fr); }
.span3 { grid-column: 1 / -1; }

/* ---------- layout pieces ---------- */
.page-head, .profile-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.back { display: inline-block; margin-bottom: 8px; color: var(--muted); font-size: 13px; }
.day-title { color: var(--muted); margin-top: 4px; }
.date-nav { display: flex; align-items: center; gap: 6px; margin-top: 8px; }
.date-nav input { width: auto; }
.today-pill { background: var(--brand-soft); color: var(--brand-ink); padding: 4px 10px; border-radius: 99px; font-size: 12px; font-weight: 600; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; margin-bottom: 16px; box-shadow: var(--shadow); }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 12px; flex-wrap: wrap; }
.card-head h2 { margin: 0; }
.cols { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.cols > .card { margin-bottom: 0; }
.cols + .card, .cols + section { margin-top: 16px; }
.count { display: inline-grid; place-items: center; min-width: 22px; height: 22px; padding: 0 6px; border-radius: 99px; background: var(--err); color: #fff; font-size: 12px; margin-left: 6px; }
.banner { padding: 10px 14px; border-radius: 9px; margin-bottom: 16px; background: var(--brand-soft); color: var(--brand-ink); border: 1px solid color-mix(in srgb, var(--brand) 25%, transparent); }
.banner.warn { background: var(--warn-soft); color: var(--warn); border-color: color-mix(in srgb, var(--warn) 30%, transparent); }
.banner.err { background: var(--err-soft); color: var(--err); border-color: color-mix(in srgb, var(--err) 30%, transparent); }
.banner.closed { background: var(--surface-2); color: var(--text); border-color: var(--line-strong); }
.banner a { font-weight: 600; }
.note { padding: 10px 12px; border-radius: 8px; background: var(--surface-2); border: 1px solid var(--line); margin-bottom: 12px; font-size: 13px; }
.note.warn { background: var(--warn-soft); border-color: color-mix(in srgb, var(--warn) 30%, transparent); color: var(--text); }
.filters { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.filters input, .filters select { width: auto; min-height: 32px; padding: 5px 8px; font-size: 13px; }
.filters.bar { margin-bottom: 12px; }
.filters.bar label { flex-direction: row; align-items: center; gap: 6px; margin: 0; }
.searchbar input { font-size: 15px; padding: 11px 14px; margin-bottom: 12px; }

/* ---------- stats ---------- */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; margin-bottom: 16px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: 9px; padding: 10px 12px; }
.card .stat { background: var(--surface-2); }
.stat span { display: block; font-size: 12px; color: var(--muted); }
.stat strong { display: block; font-size: 20px; margin-top: 2px; font-variant-numeric: tabular-nums; }
.stat small { color: var(--muted); font-size: 12px; }
.small-stats .stat strong { font-size: 17px; }
.summary-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 10px; margin-bottom: 16px; }
.sc { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; box-shadow: var(--shadow); }
.sc span { font-size: 12px; color: var(--muted); font-weight: 600; }
.sc strong { display: block; font-size: 21px; margin: 4px 0 2px; font-variant-numeric: tabular-nums; }
.sc strong.bal { font-size: 17px; line-height: 1.35; }
.sc small { color: var(--muted); font-size: 11px; }
.sc.alert { border-color: color-mix(in srgb, var(--err) 40%, var(--line)); background: color-mix(in srgb, var(--err-soft) 50%, var(--surface)); }

/* ---------- tables ---------- */
.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
.tbl th { text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; padding: 8px 10px; border-bottom: 1px solid var(--line-strong); white-space: nowrap; }
.tbl td { padding: 9px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
.tbl.compact td { padding: 6px 10px; }
.tbl .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.tbl tr.clickable { cursor: pointer; }
.tbl tr.clickable:hover td { background: var(--surface-2); }
.tbl tr.total td { font-weight: 700; border-top: 1px solid var(--line-strong); }
.tbl tr.voided td, .tbl tr.inactive td { opacity: .5; }
.tbl tr.voided td { text-decoration: line-through; }
.tbl tr.hl td { background: var(--warn-soft); }
section > .tbl, .card > .tbl, #list > .tbl, #timeline > .tbl { display: table; }
.card, #list { overflow-x: auto; }
.timeline .kind-info td { color: var(--muted); }
.act { font-weight: 600; }
.act-payment { color: var(--ok); }
.act-rental { color: var(--rental); }

/* ---------- badges ---------- */
.badge { display: inline-block; padding: 2px 8px; border-radius: 99px; font-size: 11px; font-weight: 600; background: var(--surface-2); border: 1px solid var(--line); color: var(--muted); white-space: nowrap; vertical-align: middle; }
.st-planned { background: var(--brand-soft); color: var(--brand-ink); border-color: transparent; }
.st-completed { background: var(--ok-soft); color: var(--ok); border-color: transparent; }
.st-cancelled { background: var(--surface-2); color: var(--muted); text-decoration: line-through; }
.st-on_water { background: var(--rental-soft); color: var(--rental); border-color: transparent; }
.sync-success { background: var(--ok-soft); color: var(--ok); border-color: transparent; }
.sync-failed { background: var(--err-soft); color: var(--err); border-color: transparent; }
.sync-pending, .sync-running { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.sync-local { background: var(--surface-2); color: var(--muted); }
.match-new { background: var(--brand-soft); color: var(--brand-ink); border-color: transparent; }
.match-email, .match-phone { background: var(--ok-soft); color: var(--ok); border-color: transparent; }
.match-conflict { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.type-tag { display: inline-block; font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; padding: 2px 6px; border-radius: 5px; margin-right: 6px; }
.type-tag.lesson { background: var(--brand-soft); color: var(--brand-ink); }
.type-tag.rental { background: var(--rental-soft); color: var(--rental); }

/* ---------- schedule ---------- */
.schedule-list { display: flex; flex-direction: column; gap: 8px; }
.act-card { display: grid; grid-template-columns: 76px 1fr auto; gap: 14px; align-items: center; background: var(--surface); border: 1px solid var(--line); border-left: 4px solid var(--brand); border-radius: var(--radius); padding: 12px 14px; cursor: pointer; box-shadow: var(--shadow); }
.act-card:hover { border-color: var(--line-strong); border-left-color: var(--brand); }
.act-card.rental { border-left-color: var(--rental); }
.act-card.completed { border-left-color: var(--ok); }
.act-card.cancelled { opacity: .6; border-left-color: var(--line-strong); }
.act-card .time { font-size: 18px; font-weight: 700; font-variant-numeric: tabular-nums; }
.act-card .time small { display: block; font-size: 11px; font-weight: 500; color: var(--muted); }
.act-card .line1 { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 15px; }
.act-card .line2 { color: var(--muted); margin-top: 2px; }
.act-card .line2 strong { color: var(--text); font-weight: 600; }
.warn-line { color: var(--warn); font-size: 12px; margin-top: 4px; font-weight: 600; }
.quick { display: flex; gap: 6px; align-items: center; }
.quick input { width: 88px; min-height: 30px; padding: 4px 8px; }
.open-hint { color: var(--muted); font-size: 12px; }
.close-state { padding: 6px 14px; border-radius: 99px; font-weight: 700; font-size: 13px; }
.close-state.st-incomplete { background: var(--err-soft); color: var(--err); }
.close-state.st-ready { background: var(--accent-soft); color: var(--warn); }
.close-state.st-closed { background: var(--ok-soft); color: var(--ok); }
.attention { border-color: color-mix(in srgb, var(--err) 35%, var(--line)); }
.close-bar { display: flex; align-items: center; gap: 14px; margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--line); flex-wrap: wrap; }
.mini-list { list-style: none; padding: 0; margin: 0; }
.mini-list li { display: flex; align-items: center; gap: 8px; padding: 7px 0; border-bottom: 1px solid var(--line); flex-wrap: wrap; cursor: default; }
.mini-list li[data-l], .mini-list li[data-r] { cursor: pointer; }
.mini-list .t { font-weight: 700; font-variant-numeric: tabular-nums; width: 46px; }

/* ---------- profile ---------- */
.contact { color: var(--muted); display: flex; flex-wrap: wrap; gap: 4px 0; }
.contact .sep { margin: 0 8px; opacity: .5; }
.notes-card textarea { border-style: dashed; }
.reg { border-top: 1px solid var(--line); padding: 10px 0; }

/* ---------- modal ---------- */
.modal-backdrop { position: fixed; inset: 0; background: rgba(12, 22, 20, .45); display: grid; place-items: start center; padding: 6vh 16px; overflow-y: auto; z-index: 50; animation: fade .12s ease-out; }
.modal { width: 100%; max-width: 540px; background: var(--surface); border-radius: 14px; box-shadow: 0 20px 60px rgba(0, 0, 0, .25); border: 1px solid var(--line); }
.modal.wide { max-width: 720px; }
.modal header { display: flex; justify-content: space-between; align-items: center; padding: 16px 20px 0; }
.modal header h2 { margin: 0; font-size: 17px; }
.modal-body { padding: 16px 20px 4px; }
.modal footer { display: flex; justify-content: space-between; gap: 8px; padding: 12px 20px 16px; border-top: 1px solid var(--line); margin-top: 8px; }
.modal footer .right, .modal footer .left { display: flex; gap: 8px; }
.form-error { background: var(--err-soft); color: var(--err); padding: 9px 12px; border-radius: 8px; margin: 8px 0; font-weight: 600; font-size: 13px; }
.rec-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 14px; }
.big-link { font-size: 17px; font-weight: 700; }
.outcome { background: var(--surface-2); border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; margin: 4px 0 12px; }
.outcome h3 { margin: 0 0 8px; }
.seg { display: inline-flex; border: 1px solid var(--line-strong); border-radius: 9px; overflow: hidden; margin-bottom: 12px; }
.seg label { margin: 0; flex-direction: row; }
.seg input { position: absolute; opacity: 0; pointer-events: none; width: 1px; }
.seg span { display: block; padding: 7px 14px; font-size: 13px; font-weight: 600; color: var(--muted); cursor: pointer; background: var(--surface); border-right: 1px solid var(--line); }
.seg label:last-child span { border-right: 0; }
.seg input:checked + span { background: var(--brand); color: #fff; }
.seg input:focus-visible + span { outline: 2px solid var(--brand); outline-offset: -3px; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 4px; }
.chip { font: inherit; font-size: 12px; font-weight: 600; padding: 3px 10px; border-radius: 99px; border: 1px solid var(--line-strong); background: var(--surface); color: var(--text); cursor: pointer; }
.chip:hover { border-color: var(--brand); color: var(--brand); }
.calc { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; background: var(--brand-soft); border-radius: 10px; padding: 12px 14px; margin: 8px 0; }
.calc span { display: block; font-size: 11px; font-weight: 600; }
.calc strong { display: block; font-size: 19px; font-variant-numeric: tabular-nums; }
.calc small { color: var(--muted); font-size: 11px; }
.hist { margin-top: 10px; font-size: 12px; color: var(--muted); }
.hist ul { margin: 6px 0; padding-left: 18px; }
details summary { cursor: pointer; font-weight: 600; font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.course-opt { margin: 4px 0 8px; }
.dl { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; margin: 0; }
.dl dt { color: var(--muted); font-size: 12px; font-weight: 600; }
.dl dd { margin: 0; overflow-wrap: anywhere; }
.dup-row { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 6px 0; border-bottom: 1px solid var(--line); }

/* ---------- customer picker ---------- */
.picker { position: relative; font-weight: 400; color: var(--text); }
.picker-results { position: absolute; z-index: 5; left: 0; right: 0; top: 42px; background: var(--surface); border: 1px solid var(--line-strong); border-radius: 9px; box-shadow: 0 10px 30px rgba(0, 0, 0, .12); max-height: 290px; overflow-y: auto; }
.pick { display: block; width: 100%; text-align: left; font: inherit; background: none; border: 0; border-bottom: 1px solid var(--line); padding: 8px 12px; cursor: pointer; color: var(--text); }
.pick small { display: block; color: var(--muted); font-size: 12px; }
.pick:hover, .pick.on { background: var(--brand-soft); }
.pick.new { color: var(--brand); font-weight: 600; }
.picker-info { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 12px; color: var(--muted); margin-top: 4px; font-weight: 500; }
.cust-note { color: var(--warn); }

/* ---------- products ---------- */
.tier-product { border-top: 1px solid var(--line); padding: 12px 0; }
.tier-product:first-of-type { border-top: 0; padding-top: 0; }
.tp-head { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.tp-head .btn { margin-left: auto; }
.tiers { max-width: 520px; }
.examples { margin-top: 6px; }
.tier-row, .tier-head { display: grid; grid-template-columns: 1fr 1fr 32px; gap: 8px; margin-bottom: 6px; }
.tier-head { font-size: 11px; font-weight: 600; color: var(--muted); }

/* ---------- reports ---------- */
.report-form { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; }
.report-form label { margin: 0; }
.report-form input { width: 190px; }
.pie-wrap { display: flex; gap: 18px; align-items: center; flex-wrap: wrap; }
.pie { width: 160px; height: 160px; flex: none; }
.legend { list-style: none; padding: 0; margin: 0; flex: 1; min-width: 180px; }
.legend li { display: flex; align-items: center; gap: 8px; padding: 4px 0; }
.legend i { width: 10px; height: 10px; border-radius: 3px; flex: none; }
.legend span { margin-left: auto; color: var(--muted); font-variant-numeric: tabular-nums; }
.pie-basis { width: 100%; }

/* ---------- empty / toasts ---------- */
.empty { text-align: center; padding: 48px 16px; background: var(--surface); border: 1px dashed var(--line-strong); border-radius: var(--radius); }
.empty-mark { font-size: 28px; color: var(--brand); }
.empty h3 { text-transform: none; letter-spacing: 0; font-size: 16px; color: var(--text); margin: 8px 0 4px; }
.empty p { color: var(--muted); margin: 0 0 14px; }
#toasts { position: fixed; bottom: 18px; right: 18px; display: flex; flex-direction: column; gap: 8px; z-index: 100; max-width: calc(100vw - 36px); }
.toast { background: #17231f; color: #fff; padding: 10px 14px; border-radius: 9px; box-shadow: 0 8px 24px rgba(0, 0, 0, .2); font-weight: 500; transition: opacity .4s, transform .4s; max-width: 420px; }
.toast.err { background: var(--err); }
.toast.warn { background: #8a5a12; }
.toast.out { opacity: 0; transform: translateY(8px); }
@keyframes fade { from { opacity: 0; } }

/* ---------- responsive ---------- */
@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; z-index: 40; left: 0; top: 0; width: 260px; transform: translateX(-100%); transition: transform .2s; box-shadow: 0 0 40px rgba(0, 0, 0, .2); }
  .shell.nav-open .sidebar { transform: none; }
  .topbar { display: flex; align-items: center; gap: 10px; padding: 10px 16px; background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 30; }
  .brand-sm { font-weight: 700; color: var(--brand-ink); }
  .page { padding: 16px 16px 48px; }
  .cols { grid-template-columns: 1fr; }
  .grid3 { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 560px) {
  .grid2, .grid3 { grid-template-columns: 1fr; }
  .act-card { grid-template-columns: 58px 1fr; }
  .act-card .quick { grid-column: 1 / -1; }
  .act-card .time { font-size: 15px; }
  h1 { font-size: 20px; }
  .modal-backdrop { padding: 0; }
  .modal { border-radius: 0; min-height: 100vh; }
}
.pair-sub { display: block; font-size: .72em; font-weight: 600; color: var(--muted); }
td .pair-sub { display: inline; margin-left: 6px; font-size: 1em; font-weight: 400; }

/* ---------- time grid (instructors × hours, calendar week/day) ---------- */
.view-seg { margin: 4px 0 12px; }
.tg-wrap { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); overflow: auto; max-height: calc(100vh - 150px); }
.tg { display: grid; min-width: min-content; position: relative; }
.tg-corner, .tg-colhead { position: sticky; top: 0; z-index: 3; background: var(--surface); border-bottom: 1px solid var(--line-strong); }
.tg-corner { left: 0; z-index: 4; }
.tg-colhead { padding: 8px 10px; font-weight: 700; border-left: 1px solid var(--line); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tg-colhead a { color: var(--text); }
.tg-colhead small { display: block; font-weight: 500; font-size: 11px; color: var(--muted); }
.tg-colhead.today, .tg-colhead.today a { color: var(--brand-ink); background: var(--brand-soft); }
.tg-colhead.rental-col { color: var(--rental); }
.tg-times { position: sticky; left: 0; z-index: 2; background: var(--surface); border-right: 1px solid var(--line); }
.tg-times span { position: absolute; right: 6px; transform: translateY(-50%); font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; }
.tg-times span:first-child { transform: none; top: 2px !important; }
.tg-col { position: relative; border-left: 1px solid var(--line);
  background-image: linear-gradient(var(--line) 1px, transparent 1px), linear-gradient(color-mix(in srgb, var(--line) 50%, transparent) 1px, transparent 1px);
  background-size: 100% 64px, 100% 32px; }
.tg-col[data-add] { cursor: copy; }
.tg-col[data-add]:hover { background-color: color-mix(in srgb, var(--brand-soft) 35%, transparent); }
.tg-col.muted-col { background-color: var(--surface-2); }
.tg-col.today { background-color: color-mix(in srgb, var(--brand-soft) 40%, transparent); }
.tg-ev { position: absolute; overflow: hidden; border-radius: 6px; padding: 3px 6px; font-size: 12px; line-height: 1.3; cursor: pointer;
  background: var(--brand-soft); color: var(--brand-ink); border-left: 3px solid var(--brand); box-shadow: 0 1px 2px rgba(0,0,0,.08); }
.tg-ev:hover, .tg-ev:focus-visible { z-index: 2; outline: 2px solid var(--brand); outline-offset: 0; }
.tg-ev .ev-t { font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tg-ev .ev-s { color: var(--text); opacity: .75; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tg-ev.short .ev-s { display: none; }
.tg-ev.st-completed { background: var(--ok-soft); color: var(--ok); border-left-color: var(--ok); }
.tg-ev.st-cancelled { background: var(--surface-2); color: var(--muted); border-left-color: var(--line-strong); text-decoration: line-through; opacity: .75; }
.tg-ev.has-warn { box-shadow: inset 0 0 0 1px var(--warn); }
.tg-ev.rental { background: var(--rental-soft); color: var(--rental); border-left-color: var(--rental); }
.tg-ev.rental.st-completed { border-left-style: double; }
.tg-ev .ev-ico { margin-right: 4px; }
.tg-now { position: absolute; left: 0; right: 0; height: 2px; background: var(--err); z-index: 1; pointer-events: none; }
.tg-times + .tg-col .tg-now::before { content: ""; position: absolute; left: -4px; top: -3px; width: 8px; height: 8px; border-radius: 50%; background: var(--err); }
.tg-untimed { padding: 10px 12px; border-top: 1px solid var(--line); display: flex; flex-wrap: wrap; gap: 6px; align-items: center; position: sticky; left: 0; }
.chip-btn { border: 1px solid var(--line-strong); background: var(--rental-soft); color: var(--rental); border-radius: 99px; padding: 3px 10px; font: inherit; font-size: 12px; cursor: pointer; }
.tg-hint { margin-top: 8px; }

/* ---------- calendar ---------- */
.cal-views a { display: block; padding: 7px 16px; font-size: 13px; font-weight: 600; color: var(--muted); background: var(--surface); border-right: 1px solid var(--line); text-decoration: none; }
.cal-views a:last-child { border-right: 0; }
.cal-views a.on { background: var(--brand); color: #fff; }
.cal-title { font-size: 17px; font-weight: 700; color: var(--text); }
.cal-dayhead { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.cal-dayhead .btn { margin-left: auto; }
.cal-month { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); background: var(--line); gap: 1px; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); margin-bottom: 8px; }
.cal-dow { background: var(--surface-2); padding: 6px 8px; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.cal-cell { background: var(--surface); min-height: 112px; padding: 6px 7px; display: flex; flex-direction: column; gap: 3px; color: var(--text); text-decoration: none !important; min-width: 0; }
.cal-cell:hover { background: var(--surface-2); }
.cal-cell.other { background: var(--surface-2); color: var(--muted); }
.cal-cell.other .cal-items { opacity: .6; }
.cal-cell.sel { box-shadow: inset 0 0 0 2px var(--brand); }
.cal-num { display: flex; justify-content: space-between; align-items: center; font-weight: 700; font-size: 13px; }
.cal-cell.today .cal-num span:first-child { background: var(--brand); color: #fff; border-radius: 99px; min-width: 24px; height: 24px; display: inline-grid; place-items: center; }
.cal-flag { font-size: 11px; }
.cal-flag.open { color: var(--warn); }
.cal-items { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.cal-chip { font-size: 11px; padding: 1px 5px; border-radius: 4px; background: var(--brand-soft); color: var(--brand-ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cal-chip.st-completed { background: var(--ok-soft); color: var(--ok); }
.cal-more { font-size: 11px; color: var(--muted); font-weight: 600; }
.cal-sum { margin-top: auto; font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; }
@media (max-width: 700px) {
  .cal-cell { min-height: 64px; padding: 4px; }
  .cal-items { display: none; }
  .cal-sum { font-size: 10px; }
  .cal-dow { padding: 4px; font-size: 10px; }
}
.chip-btn.cancelled { background: var(--surface-2); color: var(--muted); text-decoration: line-through; }

/* ---------- drag & drop on the time grid ---------- */
.tg-ev[data-drag] { cursor: grab; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
.ev-resize { position: absolute; left: 0; right: 0; bottom: 0; height: 10px; cursor: ns-resize; }
.ev-resize::after { content: ""; position: absolute; left: 50%; bottom: 2px; width: 18px; height: 3px; margin-left: -9px; border-radius: 2px; background: currentColor; opacity: 0; transition: opacity .15s; }
.tg-ev:hover .ev-resize::after { opacity: .45; }
.tg-ev.drag-src { opacity: .3; }
.tg-ev.drag-ghost { z-index: 5; cursor: grabbing; box-shadow: 0 8px 20px rgba(0, 0, 0, .25); outline: 2px solid var(--brand); pointer-events: none; opacity: .95; }
.tg-ev.drag-ghost.saving { opacity: .6; }
.drag-time { font-size: 11px; font-weight: 700; font-variant-numeric: tabular-nums; color: var(--text); }
body.is-dragging, body.is-dragging * { cursor: grabbing !important; }
.tg-col.drop-target { background-color: color-mix(in srgb, var(--brand-soft) 70%, transparent); }
.tg-col.drop-no { background-color: color-mix(in srgb, var(--err-soft) 60%, transparent); cursor: not-allowed; }
.toast.has-action { display: flex; align-items: center; gap: 14px; }
.toast.has-action button { background: none; border: 0; color: #7fd3d9; font: inherit; font-weight: 700; cursor: pointer; padding: 2px 4px; text-transform: uppercase; font-size: 12px; letter-spacing: .04em; }

/* ---------- incomes ---------- */
.income-stats { grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); }
.stat-btn { font: inherit; text-align: left; color: var(--text); cursor: pointer; }
.stat-btn:hover { border-color: var(--line-strong); }
.stat-btn.on { border-color: var(--brand); box-shadow: inset 0 0 0 1px var(--brand); background: var(--brand-soft); }
.quick-ranges { display: inline-flex; gap: 2px; }
.itype { display: inline-block; font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 99px; background: var(--surface-2); color: var(--muted); border: 1px solid var(--line); }
.itype.it-course { background: var(--brand-soft); color: var(--brand-ink); border-color: transparent; }
.itype.it-rental { background: var(--rental-soft); color: var(--rental); border-color: transparent; }
.itype.it-shop { background: var(--accent-soft); color: var(--warn); border-color: transparent; }
.itype.it-other { background: var(--ok-soft); color: var(--ok); border-color: transparent; }
.type-seg { display: inline-flex; flex-wrap: wrap; }
.tbl-wrap { overflow-x: auto; }

/* ---------- New income dialog ---------- */
.lbl { display: flex; flex-direction: column; gap: 4px; font-size: 12px; font-weight: 600; color: var(--muted); margin-bottom: 10px; }
.lbl .seg { margin-bottom: 0; align-self: flex-start; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin: -4px 0 16px; }
.tabs [role=tab] { font: inherit; font-weight: 700; font-size: 14px; background: none; border: 0; border-bottom: 2px solid transparent; padding: 8px 14px; color: var(--muted); cursor: pointer; margin-bottom: -1px; }
.tabs [role=tab][aria-selected=true] { color: var(--brand-ink); border-bottom-color: var(--brand); }
.tabs [role=tab]:hover { color: var(--text); }
.items-head, .item-row { display: grid; grid-template-columns: minmax(0, 1fr) 64px 96px 96px 30px; gap: 8px; align-items: center; }
.items-head { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin-bottom: 4px; }
.items-head span:nth-child(4) { text-align: right; }
.item-row { margin-bottom: 6px; }
.item-row .item-total { text-align: right; font-variant-numeric: tabular-nums; font-size: 13px; }
.item-row:has([name=item_desc]:not([hidden])) { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) 64px 96px 72px 96px 30px; }
.items-head:has(+ .items .item-row [name=item_desc]:not([hidden])) { display: none; }
.owed-box { background: var(--surface-2); border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; margin-bottom: 14px; }
.owed-figs { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
.owed-figs span { display: block; font-size: 11px; }
.owed-figs strong { font-size: 17px; font-variant-numeric: tabular-nums; }
.owed-main strong { font-size: 20px; }
.owed-detail { margin: 10px 0 0; padding-left: 18px; font-size: 12px; color: var(--muted); }
.owed-detail strong { color: var(--text); }
.pay-box { border-top: 1px solid var(--line); padding-top: 14px; margin-top: 4px; }
.pay-grid { display: grid; grid-template-columns: 1fr auto 1fr; gap: 0 12px; align-items: start; }
.pay-grid [name=amount] { font-size: 18px; font-weight: 700; }
.conv-line { font-size: 13px; color: var(--muted); margin: -2px 0 12px; min-height: 18px; }
.conv-line strong { color: var(--text); }
@media (max-width: 640px) {
  .owed-figs { grid-template-columns: 1fr 1fr; }
  .pay-grid { grid-template-columns: 1fr; }
  .items-head { display: none; }
  .item-row, .item-row:has([name=item_desc]:not([hidden])) { grid-template-columns: 1fr 1fr 1fr; }
  .item-row select[name=item_product], .item-row [name=item_desc] { grid-column: 1 / -1; }
}

/* Customers: registration link buttons and personal details */
.btn.icon-only { padding: 8px; width: 36px; }
.contact.personal { margin-top: 4px; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: 0.02em; }

/* Group course tiers: an extra "Persons" column in the tier editor */
.tier-row .gs, .tier-head .gs { display: none; }
.tier-block.is-group .tier-row, .tier-block.is-group .tier-head { grid-template-columns: 90px 1fr 1fr 32px; }
.tier-block.is-group .gs { display: block; }

/* Group lessons on the grid */
.tg-ev.lesson.is-group { border-left-width: 4px; background-image: repeating-linear-gradient(135deg, transparent 0 10px, rgba(255,255,255,.18) 10px 20px); }
.ev-group { display: inline-block; font-size: 10.5px; font-weight: 700; padding: 0 5px; margin-right: 4px; border-radius: 8px; background: rgba(0,0,0,.12); vertical-align: 1px; }
.group-box { border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; margin: 10px 0; background: var(--surface-2); }
.group-box h3 { margin: 0 0 6px; font-size: 14px; }
.group-box ul { list-style: none; margin: 0 0 8px; padding: 0; }
.group-box li { display: flex; justify-content: space-between; gap: 8px; padding: 4px 0; border-bottom: 1px dashed var(--line); font-size: 13px; }
.group-box li:last-child { border-bottom: 0; }
.group-box .me { font-weight: 700; }

/* Partnerships */
.month-nav { align-items: center; gap: 10px; }
.badge.partner { background: var(--accent-soft); color: var(--text); }
.partner-custs .caret { width: 18px; color: var(--muted); transition: transform .15s; }
.partner-custs tr.open .caret { transform: rotate(90deg); }
.partner-custs .hist-row > td { background: var(--surface-2); padding-top: 4px; padding-bottom: 12px; }
.tbl.inner { margin: 0; background: var(--surface); }
.err-text { color: var(--err); }
ol.steps { padding-left: 18px; margin: 8px 0 12px; }
ol.steps li { margin-bottom: 4px; }
