:root {
  --bg: #f7f8f9;
  --surface: #ffffff;
  --ink: #16202b;
  --muted: #6b7684;
  --line: #e2e6ea;
  --accent: #1f6f8b;
  --accent-ink: #ffffff;
  --free: #2e8b57;
  --free-bg: #e7f4ec;
  --part: #c9770a;
  --part-bg: #fdf1e0;
  --full: #b23b3b;
  --full-bg: #fbeaea;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 32, 43, .06), 0 6px 20px rgba(16, 32, 43, .05);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #12161a;
    --surface: #1a1f25;
    --ink: #e8edf2;
    --muted: #96a2ae;
    --line: #2b333b;
    --accent: #4aa3c0;
    --accent-ink: #0d1418;
    --free: #6fcf97;
    --free-bg: #1d3229;
    --part: #e0a458;
    --part-bg: #33291a;
    --full: #e07a7a;
    --full-bg: #351e1e;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 6px 20px rgba(0, 0, 0, .25);
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 { font-weight: 600; letter-spacing: -0.01em; margin: 0 0 .4em; }
h1 { font-size: 1.4rem; }
h2 { font-size: 1.15rem; }
h3 { font-size: 1rem; }
h4 { font-size: .82rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin-top: 1.4em; }

.muted { color: var(--muted); }
.small { font-size: .82rem; }
.error { color: var(--full); font-size: .9rem; }
.note { font-size: .88rem; color: var(--muted); min-height: 1.2em; }

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 22px;
}

label { display: block; font-size: .84rem; color: var(--muted); margin: 14px 0 5px; }
label.radio, label.checkline { display: inline-flex; align-items: center; gap: 6px; color: var(--ink); font-size: .92rem; margin-right: 16px; }

input[type=text], input[type=email], input[type=password], input[type=date], input[type=number], select {
  width: 100%;
  padding: 9px 11px;
  font: inherit;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 7px;
}
input:focus, select:focus { outline: 2px solid var(--accent); outline-offset: 1px; border-color: transparent; }

button { font: inherit; cursor: pointer; border-radius: 7px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); padding: 9px 14px; }
button:hover { border-color: var(--muted); }
button.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 500; }
button.primary:hover { filter: brightness(1.08); }
button.ghost { background: transparent; }
button.link { border: none; background: none; color: var(--muted); padding: 4px 6px; text-decoration: underline; }
button.danger { color: var(--full); border-color: var(--full); background: transparent; }
button[disabled] { opacity: .5; cursor: default; }

/* ------------------------------------------------------------- landing */
.landing { padding: 0 22px 80px; }
.landing-inner { max-width: 760px; margin: 0 auto; }

.landing-head { padding: 72px 0 8px; }
.landing-head h1 { font-size: 1.75rem; line-height: 1.25; max-width: 30ch; }
.lede { font-size: 1.02rem; color: var(--muted); max-width: 58ch; margin: 0; }

.booking-block { margin-top: 44px; }
.booking-block h2 { font-size: 1.1rem; margin-bottom: 14px; }
.login-card { width: 100%; max-width: 380px; }
.login-card button { width: 100%; margin-top: 20px; }
.login-card label:first-of-type { margin-top: 0; }

.accred-block { margin-top: 64px; border-top: 1px solid var(--line); padding-top: 34px; }
.accred-block h2 { font-size: 1.1rem; margin-bottom: 16px; }
.accred-grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }
.accred-empty {
  grid-column: 1 / -1; margin: 0;
  font-size: .92rem; padding: 26px; text-align: center;
  border: 1px dashed var(--line); border-radius: var(--radius);
}
.accred-card {
  display: flex; align-items: center; gap: 14px; text-decoration: none; color: inherit;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px 16px; box-shadow: var(--shadow);
}
.accred-card:hover { border-color: var(--accent); }
.accred-logo {
  flex: 0 0 auto; width: 46px; height: 46px; border-radius: 8px;
  display: grid; place-items: center; overflow: hidden; background: var(--bg);
}
.accred-logo img { max-width: 100%; max-height: 100%; object-fit: contain; }
.accred-logo.is-text { font-weight: 600; font-size: .9rem; color: var(--accent); letter-spacing: .04em; }
.accred-body { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.accred-name { font-weight: 500; }
.accred-note { font-size: .84rem; color: var(--muted); }

@media (max-width: 640px) {
  .landing { padding: 0 16px 60px; }
  .landing-head { padding: 44px 0 6px; }
  .landing-head h1 { font-size: 1.45rem; }
}

/* -------------------------------------------------------------- topbar */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 26px; background: var(--surface); border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 5;
}
.brand { font-weight: 600; letter-spacing: -0.01em; }
.topbar nav { display: flex; align-items: center; gap: 8px; }
.tab { border: none; background: transparent; color: var(--muted); padding: 6px 10px; }
.tab.is-active { color: var(--ink); background: var(--bg); }
.who { color: var(--muted); font-size: .88rem; margin: 0 6px 0 14px; }

main { max-width: 1020px; margin: 0 auto; padding: 28px 22px 70px; }

/* ------------------------------------------------------------ calendar */
.month-head { display: flex; align-items: center; gap: 14px; margin-bottom: 18px; }
.month-head h2 { margin: 0; min-width: 190px; }

.calendar { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; }
.cal-head { font-size: .76rem; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); padding-bottom: 4px; text-align: center; }

.day {
  background: var(--surface); border: 1px solid var(--line); border-radius: 8px;
  min-height: 88px; padding: 8px; display: flex; flex-direction: column; gap: 5px;
}
.day.empty { background: transparent; border-color: transparent; }
.day.past { opacity: .45; }
.day .num { font-size: .8rem; color: var(--muted); }
.day.today .num { color: var(--accent); font-weight: 600; }

.chip {
  display: flex; align-items: center; justify-content: space-between; gap: 6px;
  width: 100%; text-align: left; font-size: .78rem; line-height: 1.25;
  padding: 5px 7px; border-radius: 6px; border: 1px solid transparent;
}
.chip .lbl { font-weight: 600; }
.chip .cnt { font-variant-numeric: tabular-nums; opacity: .85; white-space: nowrap; }
.chip.free { background: var(--free-bg); color: var(--free); border-color: color-mix(in srgb, var(--free) 30%, transparent); }
.chip.part { background: var(--part-bg); color: var(--part); border-color: color-mix(in srgb, var(--part) 30%, transparent); }
.chip.full { background: var(--full-bg); color: var(--full); border-color: color-mix(in srgb, var(--full) 30%, transparent); }
.chip.mine { box-shadow: inset 0 0 0 2px var(--accent); }
.chip:hover { filter: brightness(.97); }

.key { display: flex; flex-wrap: wrap; gap: 18px; margin-top: 22px; font-size: .85rem; color: var(--muted); }
.key-item { display: inline-flex; align-items: center; gap: 7px; }
.dot { width: 11px; height: 11px; border-radius: 3px; display: inline-block; }
.dot.free { background: var(--free-bg); border: 1px solid var(--free); }
.dot.part { background: var(--part-bg); border: 1px solid var(--part); }
.dot.full { background: var(--full-bg); border: 1px solid var(--full); }
.dot.mine { background: transparent; border: 2px solid var(--accent); }
.key-note { margin-left: auto; }

.booking-note {
  margin: 16px 0 0; padding: 11px 14px; font-size: .88rem; color: var(--muted);
  background: var(--surface); border: 1px solid var(--line);
  border-left: 3px solid var(--accent); border-radius: 8px;
}

.mine-panel { margin-top: 30px; }
.mine-panel ul { list-style: none; padding: 0; margin: 8px 0 0; }
.mine-panel li { padding: 9px 0; border-top: 1px solid var(--line); font-size: .92rem; display: flex; justify-content: space-between; gap: 12px; }

/* --------------------------------------------------------------- panel */
.overlay { position: fixed; inset: 0; background: rgba(16, 32, 43, .42); display: grid; place-items: center; padding: 20px; z-index: 20; }
.panel { width: 100%; max-width: 460px; max-height: 86vh; overflow: auto; position: relative; }
.close { position: absolute; top: 10px; right: 12px; border: none; background: none; font-size: 24px; line-height: 1; color: var(--muted); padding: 2px 6px; }
.notes { font-size: .92rem; }

.slots { list-style: none; padding: 0; margin: 6px 0 0; display: grid; gap: 6px; }
.slots li { display: flex; }
.slot {
  width: 100%; text-align: left; display: flex; justify-content: space-between; align-items: center;
  padding: 10px 12px; font-size: .93rem; border: 1px dashed var(--line); background: transparent;
}
.slot.taken { border-style: solid; background: var(--bg); cursor: default; }
.slot.taken:hover { border-color: var(--line); }
.slot.is-mine { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 10%, transparent); }
.slot .tag { font-size: .76rem; color: var(--muted); }
.slot.selected { border: 2px solid var(--accent); }

.confirm { margin-top: 14px; padding: 14px; border-radius: 8px; background: var(--bg); }
.confirm p { margin: 0 0 12px; font-size: .92rem; }
.confirm button { margin-right: 8px; }
.admin-actions { margin-top: 18px; border-top: 1px solid var(--line); padding-top: 14px; }

/* --------------------------------------------------------------- admin */
.admin-grid { display: grid; gap: 18px; grid-template-columns: 1fr; align-items: start; }
.admin-side { display: grid; gap: 18px; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); align-items: start; }

.list { list-style: none; padding: 0; margin: 0 0 12px; }
.list li { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line); font-size: .92rem; }
.list li > div:first-child { min-width: 0; flex: 1 1 auto; }
.list li > div:last-child { display: flex; gap: 2px; white-space: nowrap; flex: 0 0 auto; }
.list li.off { opacity: .45; }
.list .sub { color: var(--muted); font-size: .82rem; }
.inline-form { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 12px; }
.inline-form input[type=text], .inline-form input[type=email] { flex: 1 1 130px; width: auto; }
.radios { margin-bottom: 4px; }
.codebox { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 1.05rem; letter-spacing: 2px; }

@media (max-width: 640px) {
  main { padding: 20px 12px 60px; }
  .calendar { gap: 5px; }
  .day { min-height: 72px; padding: 6px; }
  .chip { font-size: .64rem; padding: 4px 4px; gap: 3px; }
  .chip .lbl { font-size: .72rem; }
  .topbar { padding: 12px 14px; }
  .topbar nav { flex-wrap: nowrap; }
  .brand { font-size: .92rem; }
  button.link, .tab { white-space: nowrap; padding: 5px 7px; }
  .who { display: none; }
}

#f-session button[type=submit] { display: block; width: 100%; margin-top: 18px; }
#f-session .checkline { margin-top: 16px; }

/* trainer subject assignment + booking notices */
.list li.stacked { flex-direction: column; align-items: stretch; gap: 6px; }
.list li.stacked .row-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.list li.stacked .row-head > div:first-child { min-width: 0; flex: 1 1 auto; }
.subj-picks { display: flex; flex-wrap: wrap; gap: 4px 12px; padding: 2px 0 4px; }
.pick { display: inline-flex; align-items: center; gap: 5px; margin: 0; font-size: .84rem; color: var(--ink); }
.notice-box {
  margin-top: 14px; padding: 10px 12px; border-radius: 8px; font-size: .88rem;
  background: var(--part-bg); color: var(--part);
  border: 1px solid color-mix(in srgb, var(--part) 30%, transparent);
}
#p-subject-pick { margin-bottom: 12px; }
#p-subject-pick label { margin-top: 0; }

/* trainer hours + row actions */
.hours { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; padding: 2px 0 6px; }
.hours-label { font-size: .78rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin-right: 2px; }
.hour-tag {
  display: inline-flex; align-items: center; gap: 4px; font-size: .82rem;
  background: var(--bg); border: 1px solid var(--line); border-radius: 20px; padding: 2px 4px 2px 10px;
}
.hour-tag .x { border: none; background: none; color: var(--muted); padding: 0 4px; line-height: 1; font-size: 15px; }
.hour-tag .x:hover { color: var(--full); }
.hour-add { display: inline-flex; align-items: center; gap: 4px; font-size: .82rem; color: var(--muted); }
.hour-add input[type=time] {
  width: auto; padding: 3px 6px; font-size: .82rem; font-family: inherit;
  color: var(--ink); background: var(--surface); border: 1px solid var(--line); border-radius: 6px;
}
.inline-err { color: var(--full); font-size: .8rem; flex-basis: 100%; }

.row-actions { display: inline-flex; align-items: center; gap: 12px; white-space: nowrap; }
.link-a { color: var(--muted); font-size: .9rem; }
.link-a:hover { color: var(--accent); }

/* admin date picker */
.month-head.compact { margin: 6px 0 12px; gap: 10px; }
.month-head.compact h4 { margin: 0; min-width: 150px; color: var(--ink); font-size: .95rem;
  text-transform: none; letter-spacing: 0; }
.month-head.compact button { padding: 4px 10px; }

.admin-cal .day { min-height: 62px; }
.day.pickable { cursor: pointer; }
.day.pickable:hover { border-color: var(--accent); }
.day.past.pickable { cursor: default; }
.day.past.pickable:hover { border-color: var(--line); }
.day.picked { border-color: var(--accent); box-shadow: inset 0 0 0 2px var(--accent); }

.taken-mark {
  align-self: flex-start; font-size: .68rem; font-weight: 600; letter-spacing: .04em;
  padding: 1px 6px; border-radius: 4px; background: var(--bg);
  border: 1px solid var(--line); color: var(--muted);
}
.pick-hint { margin: 8px 0 0; }
.chosen { font-size: .95rem; font-weight: 500; margin: 18px 0 4px; padding-top: 16px;
  border-top: 1px solid var(--line); }
#a-fields label:first-of-type { margin-top: 10px; }
#a-fields input[type=text], #a-fields input[type=date], #a-fields select,
#a-fields button[type=submit] { max-width: 420px; }
#a-fields .muted.small { max-width: 420px; }

/* trainer calendar feed row */
.feed-row { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; padding: 2px 0 4px; }
.feed-row .link-a { font-size: .84rem; }
.feed-row button.link { font-size: .84rem; padding: 2px 4px; }

/* destructive list action */
button.link.danger-link { color: var(--full); }
button.link.danger-link:disabled { color: var(--muted); text-decoration: none; opacity: .55; }
#p-person-pick { margin-bottom: 12px; }
#p-person-pick label { margin-top: 0; }

/* people roles */
.person-head { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.person-name { font-weight: 500; }
.person-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 2px 6px; margin-top: 2px; }
.person-actions .role-select { margin-right: 6px; }
.role-tag {
  font-size: .7rem; text-transform: uppercase; letter-spacing: .05em; font-weight: 600;
  padding: 1px 7px; border-radius: 20px; border: 1px solid var(--line); color: var(--muted);
}
.role-admin  { color: var(--accent); border-color: color-mix(in srgb, var(--accent) 40%, transparent); }
.role-trainer{ color: var(--free);   border-color: color-mix(in srgb, var(--free) 40%, transparent); }
.role-select { width: auto; padding: 3px 6px; font-size: .82rem; margin-right: 4px; }
button.taken-mark { cursor: pointer; font-family: inherit; }
button.taken-mark:hover { border-color: var(--accent); color: var(--accent); }
