:root {
  --bg: #f6f7f9; --card: #fff; --ink: #1b1f24; --muted: #6b7280; --line: #e4e7eb;
  --brand: #0f766e; --brand-ink: #fff; --brand-soft: #e6f4f2;
  --warn: #b45309; --warn-soft: #fef3c7; --bad: #b91c1c; --bad-soft: #fee2e2; --ok-soft: #dcfce7; --ok: #15803d;
  --radius: 10px;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #111418; --card: #1a1f25; --ink: #e8eaed; --muted: #9aa3ad; --line: #2b323a;
    --brand: #2dd4bf; --brand-ink: #062b27; --brand-soft: #123a36;
    --warn: #fbbf24; --warn-soft: #3b2f10; --bad: #f87171; --bad-soft: #3d1717; --ok-soft: #12321f; --ok: #4ade80; }
}
* { box-sizing: border-box; }
body { margin: 0; font: 15px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; background: var(--bg); color: var(--ink); }
#topbar { background: var(--card); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5; }
#topbar .inner { max-width: 1000px; margin: auto; padding: 10px 16px; display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
#topbar .brand { font-weight: 700; margin-right: auto; }
#topbar nav { display: flex; gap: 4px; flex-wrap: wrap; }
#topbar nav a { padding: 6px 10px; border-radius: 8px; color: var(--ink); text-decoration: none; font-size: 14px; }
#topbar nav a.active { background: var(--brand-soft); color: var(--brand); font-weight: 600; }
.badge-dot { display: inline-block; min-width: 18px; padding: 0 5px; border-radius: 9px; background: var(--bad); color: #fff; font-size: 11px; text-align: center; margin-left: 4px; }
main { max-width: 1000px; margin: auto; padding: 16px; }
h1 { font-size: 22px; margin: 4px 0 14px; }
h2 { font-size: 17px; margin: 18px 0 8px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; margin-bottom: 12px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }
.grid { display: grid; gap: 10px; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 4px; }
label.inline { display: inline-flex; gap: 6px; align-items: center; color: var(--ink); font-size: 14px; margin: 0; }
input, select, textarea { width: 100%; padding: 9px 10px; border: 1px solid var(--line); border-radius: 8px; font: inherit; background: var(--card); color: var(--ink); }
input[type=checkbox] { width: auto; }
button, .btn { padding: 9px 14px; border-radius: 8px; border: 1px solid var(--line); background: var(--card); color: var(--ink); font: inherit; cursor: pointer; text-decoration: none; display: inline-block; }
button.primary { background: var(--brand); color: var(--brand-ink); border-color: var(--brand); font-weight: 600; }
button.danger { color: var(--bad); border-color: var(--bad); }
button.small { padding: 5px 10px; font-size: 13px; }
button:disabled { opacity: .5; cursor: default; }
.weekdays { display: flex; gap: 6px; flex-wrap: wrap; }
.weekdays label { display: inline-flex; align-items: center; gap: 4px; border: 1px solid var(--line); padding: 6px 10px; border-radius: 8px; color: var(--ink); margin: 0; }
.day { margin-bottom: 14px; }
.day-head { font-weight: 600; padding: 6px 2px; display: flex; gap: 8px; align-items: center; }
.day-head.today { color: var(--brand); }
.sess { display: flex; gap: 10px; align-items: center; padding: 10px 12px; background: var(--card); border: 1px solid var(--line); border-radius: 8px; margin-bottom: 6px; }
.sess .time { font-variant-numeric: tabular-nums; font-weight: 600; min-width: 92px; }
.sess .who { flex: 1; min-width: 0; }
.sess.cancelled { opacity: .6; }
.sess.cancelled .who { text-decoration: line-through; }
.sess.opening { border-style: dashed; background: var(--brand-soft); }
.tag { display: inline-block; font-size: 11px; padding: 2px 7px; border-radius: 10px; background: var(--line); color: var(--ink); white-space: nowrap; }
.tag.warn { background: var(--warn-soft); color: var(--warn); }
.tag.bad { background: var(--bad-soft); color: var(--bad); }
.tag.ok { background: var(--ok-soft); color: var(--ok); }
.tag.brand { background: var(--brand-soft); color: var(--brand); }
.bulkbar { position: sticky; bottom: 0; background: var(--card); border: 1px solid var(--brand); border-radius: var(--radius); padding: 10px 12px; box-shadow: 0 -4px 16px rgba(0,0,0,.08); display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: 12px; color: var(--muted); font-weight: 600; }
.note { padding: 10px 12px; border-radius: 8px; background: var(--warn-soft); color: var(--warn); margin-bottom: 12px; }
.info { padding: 10px 12px; border-radius: 8px; background: var(--brand-soft); color: var(--ink); margin-bottom: 12px; }
.notif { border-left: 3px solid var(--line); padding: 8px 12px; margin-bottom: 8px; background: var(--card); border-radius: 0 8px 8px 0; }
.notif.unread { border-left-color: var(--brand); }
.notif pre { white-space: pre-wrap; font: inherit; margin: 6px 0 0; color: var(--muted); }
.auth { max-width: 380px; margin: 40px auto; }
.auth .card > * + * { margin-top: 10px; }
#toast { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 8px; max-width: 90vw; z-index: 20; }
dialog { border: 1px solid var(--line); border-radius: var(--radius); background: var(--card); color: var(--ink); max-width: 460px; width: calc(100% - 32px); padding: 18px; }
dialog::backdrop { background: rgba(0,0,0,.4); }
.slotlist { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 6px; max-height: 50vh; overflow: auto; }
.slotlist button.sel { background: var(--brand); color: var(--brand-ink); }
.copy { font-family: ui-monospace, monospace; font-size: 12px; word-break: break-all; }
@media (max-width: 600px) {
  .sess { flex-wrap: wrap; }
  .sess .time { min-width: 70px; }
  .hide-sm { display: none; }
}

/* ---- week grid (iCal style) */
:root { --ev: #e3f1f5; --ev-bar: #5fb3c9; --ev-ink: #1f4e5a; --open: #fbeefa; --open-bar: #d58fd0; --open-ink: #8a3b84;
  --lost: #fde2e8; --lost-bar: #e0486b; --closed: rgba(0,0,0,.035); --now: #e5383b; }
@media (prefers-color-scheme: dark) {
  :root { --ev: #17323a; --ev-bar: #4fa3b8; --ev-ink: #cfeaf1; --open: #3a1f38; --open-bar: #c47bbf; --open-ink: #f0c9ec;
    --lost: #3d1a22; --lost-bar: #e0486b; --closed: rgba(255,255,255,.035); }
}
main:has(.cal) { max-width: 1400px; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.seg button { border: 0; border-radius: 0; padding: 7px 12px; }
.seg button.on { background: var(--brand-soft); color: var(--brand); font-weight: 600; }
.cal-wrap { overflow-x: auto; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); }
.cal { display: grid; grid-template-columns: 52px repeat(7, minmax(108px, 1fr)); min-width: 820px; }
.cal-head { position: sticky; top: 0; z-index: 2; background: var(--card); padding: 8px 6px; font-size: 13px; color: var(--muted); border-bottom: 1px solid var(--line); border-left: 1px solid var(--line); }
.cal-head b { font-size: 18px; color: var(--ink); font-weight: 600; margin-left: 2px; }
.cal-head.today b { background: var(--now); color: #fff; border-radius: 50%; padding: 1px 6px; }
.cal-gutter { position: relative; }
.cal-gutter .hr { position: absolute; right: 6px; transform: translateY(-50%); font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; }
.cal-gutter .hr:first-child { transform: none; }
.cal-col { position: relative; border-left: 1px solid var(--line); cursor: copy;
  background-image: repeating-linear-gradient(to bottom, var(--line) 0 1px, transparent 1px var(--hour)); }
.cal-col.today { background-color: color-mix(in srgb, var(--brand-soft) 35%, transparent); }
.cal-col .closed { position: absolute; left: 0; right: 0; background: var(--closed); pointer-events: none; }
.ev { position: absolute; background: var(--ev); border-left: 3px solid var(--ev-bar); border-radius: 5px; padding: 3px 6px; color: var(--ev-ink);
  font-size: 12.5px; line-height: 1.25; overflow: hidden; cursor: pointer; z-index: 1; }
.ev:hover { filter: brightness(.97); box-shadow: 0 1px 4px rgba(0,0,0,.12); }
.ev b { display: block; font-weight: 500; opacity: .85; font-variant-numeric: tabular-nums; }
.ev span { display: block; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ev em { font-style: normal; font-size: 10.5px; font-weight: 700; letter-spacing: .03em; }
.ev.open { background: var(--open); border-left-color: var(--open-bar); color: var(--open-ink); border-style: dashed solid dashed solid; }
.ev.lost { background: var(--lost); border-left-color: var(--lost-bar); color: var(--lost-bar); }
.ev.cx { opacity: .5; background: transparent; border: 1px dashed var(--line); border-left: 3px solid var(--muted); color: var(--muted); }
.ev.cx span { text-decoration: line-through; }
.ev.past { opacity: .6; }
.ev.sel { outline: 2px solid var(--brand); outline-offset: 1px; z-index: 3; }
.nowline { position: absolute; left: -1px; right: 0; height: 2px; background: var(--now); z-index: 4; pointer-events: none; }
.nowline::before { content: ''; position: absolute; left: -5px; top: -4px; width: 10px; height: 10px; border-radius: 50%; background: var(--now); }
details summary { color: var(--brand); }

/* blocked personal time */
:root { --blk: #ffd3df; --blk-bar: #e64b74; --blk-ink: #b3264d; }
@media (prefers-color-scheme: dark) { :root { --blk: #4a1f2b; --blk-bar: #e64b74; --blk-ink: #ffb3c6; } }
.ev.block { background: var(--blk); border-left-color: var(--blk-bar); color: var(--blk-ink); }
.ev.block span { font-weight: 700; }
.ev .via { font-style: normal; font-size: 10px; font-weight: 700; background: var(--brand); color: var(--brand-ink); border-radius: 4px; padding: 0 4px; margin-left: 2px; }

/* session types + yearly allowance */
:root { --add: #fff1d6; --add-ink: #9a5b00; --rs: #e5ecff; --rs-ink: #2f4fb5; }
@media (prefers-color-scheme: dark) { :root { --add: #3d2e10; --add-ink: #fbbf24; --rs: #1c2645; --rs-ink: #a5b8ff; } }
.tag.add { background: var(--add); color: var(--add-ink); }
.tag.rs { background: var(--rs); color: var(--rs-ink); }
.ev .via.add { background: #f59e0b; color: #fff; }
.ev .via.rs { background: #4f6bd8; color: #fff; }
.card.allow .big { font-size: 26px; font-weight: 700; line-height: 1.1; }
table.yt td, table.yt th { white-space: nowrap; }
button.linkish { border: 1px dashed var(--line); background: transparent; }
.okc { color: var(--ok); }
.seg button[data-m] { font-size: 14px; }

[hidden] { display: none !important; }

/* ---- Podfit brand top bar (matches podfit.co.uk: black bar, white/teal logo, teal accents) */
:root { --pf-bar: #1a1a1a; --pf-teal: #03989e; }
#topbar { background: var(--pf-bar); border-bottom: 1px solid #000; }
#topbar .inner { padding: 8px 16px; font-family: 'Montserrat', -apple-system, BlinkMacSystemFont, sans-serif; }
#topbar .brand { display: flex; align-items: center; margin-right: auto; }
#topbar .brand img { height: 46px; width: auto; display: block; }
#topbar nav a { color: rgba(255,255,255,.75); font-weight: 500; letter-spacing: .02em; }
#topbar nav a:hover { color: #fff; }
#topbar nav a.active { background: rgba(3,152,158,.18); color: #3fd0d6; font-weight: 600; }
#topbar #logout { background: transparent; color: rgba(255,255,255,.8); border-color: rgba(255,255,255,.25); }
#topbar #logout:hover { color: #fff; border-color: var(--pf-teal); }
@media (max-width: 600px) { #topbar .brand img { height: 38px; } }
#topbar .inner { flex-wrap: nowrap; }
#topbar .brand { margin-right: 0; flex: none; }
#topbar nav { margin-left: auto; min-width: 0; flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
#topbar nav::-webkit-scrollbar { display: none; }
#topbar nav a { white-space: nowrap; }
#topbar #logout { flex: none; }
@media (max-width: 1020px) {
  #topbar .inner { flex-wrap: wrap; row-gap: 6px; }
  #topbar #logout { margin-left: auto; }
  #topbar nav { order: 3; width: 100%; margin-left: 0; padding-bottom: 2px; }
}

/* ---- client week calendar */
.cal.client { grid-template-columns: 44px repeat(7, minmax(84px, 1fr)); min-width: 640px; }
main:has(.cal.client) { max-width: 1400px; }
.cal-col.client { cursor: default; }
.ev.mine { cursor: pointer; }
.ev.free { background: var(--ok-soft); border-left-color: var(--ok); color: var(--ok); border-style: dashed solid dashed solid; opacity: .9; }
.ev.free span, .ev.open span { font-weight: 600; }
.cal-col.client .closed { background: rgba(0,0,0,.06); }
@media (prefers-color-scheme: dark) { .cal-col.client .closed { background: rgba(255,255,255,.06); } }
.legend { display: flex; flex-wrap: wrap; gap: 6px 14px; color: var(--muted); }
.legend .sw { display: inline-block; width: 12px; height: 12px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; border-left: 3px solid; }
.legend .sw.mine { background: var(--ev); border-color: var(--ev-bar); }
.legend .sw.open { background: var(--open); border-color: var(--open-bar); }
.legend .sw.free { background: var(--ok-soft); border-color: var(--ok); }
.legend .sw.busy { background: rgba(0,0,0,.1); border-color: transparent; }
.cal-col.client.bookable { cursor: pointer; }
.legend .sw.white { background: var(--card); border: 1px solid var(--line); }
/* keep the time column visible while the week scrolls sideways */
.cal > div:first-child, .cal-gutter { position: sticky; left: 0; z-index: 5; background: var(--card); }
.cal > div:first-child { z-index: 6; top: 0; }
.cal-gutter { border-right: 1px solid var(--line); }

/* ---- group classes */
:root { --cls: #ece7ff; --cls-bar: #7c5cff; --cls-ink: #4b2fc7; }
@media (prefers-color-scheme: dark) { :root { --cls: #2a2350; --cls-bar: #9b84ff; --cls-ink: #cfc4ff; } }
.ev.cls { background: var(--cls); border-left-color: var(--cls-bar); color: var(--cls-ink); }
.ev.cls.full { opacity: .65; }
.ev.cls.in { box-shadow: inset 0 0 0 2px var(--cls-bar); }
.tag.cls { background: var(--cls); color: var(--cls-ink); }
.legend .sw.cls { background: var(--cls); border-color: var(--cls-bar); }
a.btn.primary { background: var(--brand); color: var(--brand-ink); border-color: var(--brand); font-weight: 600; }

a.btn.small { padding: 5px 10px; font-size: 13px; }
/* booked count on class blocks (trainer view) */
.ev.cls .cnt { position: absolute; top: 3px; right: 4px; font-style: normal; font-size: 11px; font-weight: 700; line-height: 1;
  background: var(--cls-bar); color: #fff; border-radius: 9px; padding: 3px 6px; }
.ev.cls .cnt.full { background: var(--bad); }
.ev.cls b, .ev.cls span { padding-right: 34px; }

/* keep the top bar above the pinned time column */
#topbar { z-index: 30; }
