/* ClassHQ design system — friendly, calm, and readable for non-technical staff. */
:root {
  --bg: #f2f5fa;
  --panel: #ffffff;
  --ink: #202741;
  --muted: #69718c;
  --line: #e4e8f2;
  --accent: #4f7cff;
  --accent-dark: #3b63d8;
  --accent-soft: #eef3ff;
  --green: #1fa26a;
  --green-soft: #e3f6ec;
  --red: #d5484f;
  --red-soft: #fbe8e9;
  --amber: #d9930d;
  --amber-soft: #fdf3dd;
  --sidebar: #171e30;
  --sidebar-2: #202942;
  --sidebar-ink: #c9d1e6;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(23, 30, 48, .04), 0 6px 20px rgba(23, 30, 48, .05);
  --shadow-lift: 0 4px 10px rgba(23, 30, 48, .08), 0 14px 34px rgba(23, 30, 48, .10);
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', sans-serif;
  background: var(--bg); color: var(--ink); font-size: 14.5px; line-height: 1.45;
}
.hidden { display: none !important; }
::selection { background: #cdddff; }

/* ---------- Auth ---------- */
.auth-screen {
  position: fixed; inset: 0; display: flex; align-items: center; justify-content: center;
  background: radial-gradient(1100px 700px at 20% -10%, #33406b 0%, #171e30 55%, #10141f 100%);
}
.auth-card {
  background: var(--panel); padding: 38px 42px 34px; border-radius: 22px; width: 380px; max-width: calc(100vw - 28px);
  box-shadow: 0 30px 80px rgba(0, 0, 0, .45); animation: pop-in .35s cubic-bezier(.2, .9, .3, 1.2);
}
.auth-card .logo { display: block; width: 64px; height: 64px; margin: 0 auto 12px; border-radius: 16px; box-shadow: var(--shadow); }
.auth-card h1 { margin: 0 0 4px; text-align: center; letter-spacing: -1px; font-size: 28px; }
.auth-card .welcome { text-align: center; color: var(--muted); font-size: 14px; margin: 0 0 18px; }
.auth-card h1 span, .brand-name span { color: var(--accent); }
.auth-card input { font-size: 15px; padding: 11px 13px; }
.auth-card button { padding: 12px 16px; font-size: 15px; border-radius: 12px; }

/* ---------- Layout ---------- */
.app { display: flex; min-height: 100vh; }
.sidebar {
  width: 232px; background: linear-gradient(180deg, var(--sidebar-2), var(--sidebar) 40%);
  color: var(--sidebar-ink); display: flex; flex-direction: column; position: fixed; top: 0; bottom: 0; z-index: 10;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 18px 18px 12px; }
.brand img { width: 34px; height: 34px; border-radius: 9px; }
.brand-name { font-size: 19px; font-weight: 800; color: #fff; letter-spacing: -0.4px; line-height: 1.1; }
.brand-sub { font-size: 10.5px; color: #8a94b5; text-transform: uppercase; letter-spacing: 1.4px; }
.gym-switch { padding: 0 14px 8px; }
.gym-switch select, .gym-switch input {
  width: 100%; background: rgba(255, 255, 255, .07); color: #fff; border: 1px solid rgba(255, 255, 255, .12);
  border-radius: 10px; padding: 8px 10px; font-size: 13px; transition: border-color .15s, background .15s;
}
.gym-switch select:focus, .gym-switch input:focus { outline: none; border-color: var(--accent); background: rgba(255, 255, 255, .1); }
.gym-switch input::placeholder { color: #7d87a8; }
nav { flex: 1; overflow-y: auto; padding: 4px 10px 10px; scrollbar-width: thin; }
nav a {
  display: flex; align-items: center; gap: 10px; padding: 8px 12px; margin: 1px 0;
  color: var(--sidebar-ink); text-decoration: none; font-size: 13.5px; font-weight: 500;
  border-radius: 10px; transition: background .15s, color .15s;
}
nav a .ico { width: 20px; text-align: center; font-size: 15px; filter: grayscale(25%); }
nav a:hover { background: rgba(255, 255, 255, .07); color: #fff; }
nav a.active { background: var(--accent); color: #fff; box-shadow: 0 4px 14px rgba(79, 124, 255, .35); }
nav a.active .ico { filter: none; }
nav .nav-group { padding: 14px 12px 4px; font-size: 10px; text-transform: uppercase; letter-spacing: 1.6px; color: #6d779b; font-weight: 700; }
.sidebar-footer { padding: 12px 18px 14px; border-top: 1px solid rgba(255, 255, 255, .08); font-size: 12.5px; color: #8a94b5; }
.sidebar-footer #whoami { color: #cfd6ea; margin-bottom: 4px; font-weight: 600; }
main { flex: 1; min-width: 0; margin-left: 232px; padding: 26px 34px 60px; max-width: 1280px; animation: view-in .28s ease; }

@keyframes view-in { from { opacity: 0; transform: translateY(6px); } }
@keyframes pop-in { from { opacity: 0; transform: translateY(14px) scale(.97); } }
.loading { display: flex; justify-content: center; padding: 80px 0; }
.spin { width: 34px; height: 34px; border: 3px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Type & controls ---------- */
h2 { margin: 0 0 4px; letter-spacing: -0.6px; font-size: 24px; }
h3 { letter-spacing: -0.3px; }
.sub { color: var(--muted); margin-bottom: 18px; font-size: 13.5px; }
.toolbar { display: flex; gap: 10px; align-items: center; margin-bottom: 16px; flex-wrap: wrap; }
.toolbar .spacer { flex: 1; }
button, .btn {
  background: var(--accent); border: none; color: #fff; padding: 9px 16px; border-radius: 10px;
  cursor: pointer; font-size: 13.5px; font-weight: 600; font-family: inherit;
  transition: background .15s, transform .1s, box-shadow .15s;
}
button:hover { background: var(--accent-dark); box-shadow: 0 4px 12px rgba(79, 124, 255, .3); }
button:active { transform: translateY(1px); }
button.ghost { background: var(--panel); color: var(--accent); border: 1.5px solid #cdd9f7; box-shadow: none; }
button.ghost:hover { background: var(--accent-soft); border-color: var(--accent); box-shadow: none; }
button.small { padding: 5px 11px; font-size: 12px; border-radius: 8px; }
button.danger { background: var(--red); }
button.danger:hover { background: #b93b41; box-shadow: 0 4px 12px rgba(213, 72, 79, .3); }
button.green { background: var(--green); }
button.green:hover { background: #178a59; box-shadow: 0 4px 12px rgba(31, 162, 106, .3); }
.link-btn { background: none; border: none; color: #9fb4ff; cursor: pointer; padding: 0; font-size: 12.5px; font-family: inherit; }
.link-btn:hover { color: #fff; background: none; box-shadow: none; }
main .link-btn { color: var(--accent); }
main .link-btn:hover { color: var(--accent-dark); }
input, select, textarea {
  border: 1.5px solid var(--line); border-radius: 10px; padding: 8px 11px; font-size: 13.5px;
  font-family: inherit; background: #fff; color: var(--ink); transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(79, 124, 255, .15); }
label { display: block; font-size: 11.5px; font-weight: 700; color: var(--muted); margin: 12px 0 4px; text-transform: uppercase; letter-spacing: .4px; }

/* ---------- Cards, stats, tables ---------- */
.card {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 20px; margin-bottom: 16px; box-shadow: var(--shadow);
}
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(175px, 1fr)); gap: 12px; margin-bottom: 18px; }
.stat {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 15px 17px; box-shadow: var(--shadow); transition: transform .15s, box-shadow .15s;
}
.stat:hover { transform: translateY(-2px); box-shadow: var(--shadow-lift); }
.stat .num { font-size: 25px; font-weight: 800; letter-spacing: -0.8px; }
.stat .lbl { color: var(--muted); font-size: 12px; margin-top: 2px; }
table {
  width: 100%; border-collapse: separate; border-spacing: 0; background: var(--panel);
  border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow);
}
th {
  text-align: left; font-size: 10.5px; text-transform: uppercase; letter-spacing: .9px;
  color: var(--muted); padding: 11px 14px; border-bottom: 1px solid var(--line); background: #f8fafd; font-weight: 700;
}
td { padding: 11px 14px; border-bottom: 1px solid var(--line); }
tr:last-child td { border-bottom: none; }
tbody tr { transition: background .12s; }
tbody tr:hover { background: #f7f9ff; }
tr.clickable { cursor: pointer; }
/* CRUD row buttons wrap instead of pushing the table wider than the screen */
td.row-actions { text-align: right; min-width: 180px; }
/* wide lists scroll inside their box rather than widening the page */
.table-wrap { overflow-x: auto; border-radius: var(--radius); box-shadow: var(--shadow); }
.table-wrap > table { box-shadow: none; }
td.row-actions button { margin: 2px 0; }

.badge { display: inline-block; padding: 2.5px 10px; border-radius: 20px; font-size: 11.5px; font-weight: 700; }
.badge.green { background: var(--green-soft); color: var(--green); }
.badge.red { background: var(--red-soft); color: var(--red); }
.badge.amber { background: var(--amber-soft); color: var(--amber); }
.badge.blue { background: var(--accent-soft); color: var(--accent); }
.badge.gray { background: #eef0f5; color: var(--muted); }

/* ---------- Modal ---------- */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(16, 20, 33, .5); backdrop-filter: blur(3px);
  display: flex; align-items: flex-start; justify-content: center; padding: 44px 16px;
  overflow-y: auto; z-index: 50; animation: fade .18s ease;
}
@keyframes fade { from { opacity: 0; } }
.modal {
  background: var(--panel); border-radius: 18px; width: 580px; max-width: 100%; padding: 26px 28px;
  box-shadow: 0 30px 90px rgba(0, 0, 0, .35); animation: pop-in .28s cubic-bezier(.2, .9, .3, 1.15);
}
.modal.wide { width: fit-content; min-width: 580px; max-width: min(1300px, 96vw); }
.modal.wide table { width: 100%; }
.modal.wide td, .modal.wide th { padding: 8px 10px; }
.modal h3 { margin: 0 0 6px; font-size: 19px; }
.modal h4 { margin: 18px 0 6px; font-size: 13px; text-transform: uppercase; letter-spacing: .6px; color: var(--muted); }
.modal .actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 20px; flex-wrap: wrap; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }
.form-grid .full { grid-column: 1 / -1; }
.form-grid input, .form-grid select, .form-grid textarea { width: 100%; }

/* ---------- Toast ---------- */
#toast-root { position: fixed; bottom: 22px; right: 22px; z-index: 100; display: flex; flex-direction: column; gap: 8px; }
.toast {
  background: #202741; color: #fff; padding: 12px 18px 12px 15px; border-radius: 12px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, .3); font-size: 13.5px; font-weight: 500;
  border-left: 4px solid var(--green); animation: toast-in .25s cubic-bezier(.2, .9, .3, 1.2); max-width: 380px;
}
.toast.error { border-left-color: var(--red); }
@keyframes toast-in { from { transform: translateX(30px); opacity: 0; } }

/* ---------- Schedule grid ---------- */
.sched { display: grid; grid-template-columns: repeat(7, 1fr); gap: 10px; }
.sched .day { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 11px; min-height: 130px; box-shadow: var(--shadow); }
.sched .day h4 { margin: 0 0 8px; font-size: 11px; text-transform: uppercase; letter-spacing: 1px; color: var(--muted); }
.sched .cls {
  border-left: 3px solid var(--accent); background: #f6f8ff; border-radius: 8px; padding: 7px 9px;
  margin-bottom: 6px; cursor: pointer; font-size: 12.5px; transition: transform .12s, box-shadow .12s;
}
.sched .cls:hover { transform: translateY(-1px); box-shadow: var(--shadow); }
.sched .cls .t { color: var(--muted); font-size: 11px; margin-top: 1px; }

/* ---------- Tabs ---------- */
.tabs { display: flex; gap: 2px; border-bottom: 2px solid var(--line); margin-bottom: 18px; flex-wrap: wrap; }
.tabs button {
  background: none; color: var(--muted); border-radius: 10px 10px 0 0; padding: 10px 16px;
  font-weight: 600; box-shadow: none; text-transform: capitalize;
}
.tabs button:hover { background: var(--accent-soft); color: var(--accent); box-shadow: none; }
.tabs button.active { color: var(--accent); box-shadow: inset 0 -2.5px 0 var(--accent); background: none; }
.hint { font-size: 12px; color: var(--muted); margin-top: 4px; line-height: 1.55; }
.mono { font-family: ui-monospace, 'Cascadia Code', Consolas, monospace; font-size: 12px; }

/* ---------- Skill matrix ---------- */
.matrix { overflow-x: auto; }
.matrix td.sk { cursor: pointer; text-align: center; user-select: none; border-radius: 6px; transition: background .12s; }
.matrix td.sk:hover { background: var(--accent-soft); }

/* ---------- Help / getting started ---------- */
.check-item { display: flex; align-items: center; gap: 12px; padding: 9px 0; border-bottom: 1px solid var(--line); }
.check-item:last-child { border-bottom: none; }
.check-item .dot {
  width: 26px; height: 26px; border-radius: 50%; flex-shrink: 0; display: flex; align-items: center;
  justify-content: center; font-size: 13px; font-weight: 800; background: var(--accent-soft); color: var(--accent);
}
.check-item.done .dot { background: var(--green-soft); color: var(--green); }
.check-item.done span { color: var(--muted); text-decoration: line-through; }
.help-section { margin-bottom: 14px; }
.help-section b { display: block; margin-bottom: 3px; }
.help-section p { margin: 0; color: var(--muted); font-size: 13px; line-height: 1.55; }

/* ---------- Class schedule editor ---------- */
.mtg-row { display: flex; gap: 6px; align-items: center; margin: 4px 0; flex-wrap: wrap; }
.mtg-row select { flex: 1.3 1 0; min-width: 0; }
.mtg-row input { flex: 1 1 0; min-width: 0; }

/* Trend sparklines (Reports) */
.trend-row { display: flex; align-items: center; gap: 12px; padding: 4px 0; border-bottom: 1px solid var(--line); }
.trend-row > span:first-child { flex: 1; min-width: 0; }
.trend-row .sub { margin: 0; min-width: 84px; text-align: right; }
.spark { display: inline-flex; align-items: flex-end; gap: 2px; height: 24px; flex-shrink: 0; }
.spark i { display: block; width: 7px; border-radius: 2px 2px 0 0; }
.spark i.none { height: 2px; background: var(--line); }

/* Checkbox chips (coach picker) */
label.chip { display: inline-flex; align-items: center; gap: 6px; margin: 0; padding: 6px 11px; border: 1.5px solid var(--line);
  border-radius: 9px; cursor: pointer; font-size: 13px; color: var(--ink); text-transform: none; letter-spacing: 0; font-weight: 500; }
label.chip input { margin: 0; }
label.chip:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }

/* Closure notice (dashboard, attendance, schedule) */
.closed-banner { background: var(--red-soft); color: #9b2c31; border-radius: 10px; padding: 9px 13px; margin: 0 0 12px; font-weight: 600; font-size: 13.5px; }
.closed-banner a { color: inherit; }

/* Phone-only chrome, hidden on larger screens */
.topbar, .nav-scrim { display: none; }

@media (max-width: 940px) {
  .sidebar { width: 68px; }
  .brand { justify-content: center; padding: 14px 6px 8px; }
  .brand img { width: 30px; height: 30px; }
  .brand > div, .gym-switch, nav .nav-group, nav a span:not(.ico), .sidebar-footer #whoami { display: none; }
  nav a { justify-content: center; padding: 10px 6px; }
  nav a .ico { width: auto; font-size: 18px; }
  .sidebar-footer { text-align: center; padding: 10px 4px; }
  main { margin-left: 68px; padding: 18px 14px 60px; }
  .sched { grid-template-columns: 1fr; }
  .sched .day { min-height: 0; }
  .sched .day:not(:has(.cls)) { display: none; }
  .form-grid { grid-template-columns: 1fr; }
  h2 { font-size: 21px; }
}

/* ---------- Phones: top bar + slide-out menu, tables as cards ---------- */
@media (max-width: 760px) {
  body { font-size: 15px; }
  .app { display: block; }
  .topbar {
    display: flex; align-items: center; gap: 10px; position: sticky; top: 0; z-index: 20;
    height: 54px; padding: 0 12px; background: var(--sidebar); color: #fff; box-shadow: 0 2px 10px rgba(0, 0, 0, .2);
  }
  .menu-btn { background: none; font-size: 22px; padding: 6px 10px; line-height: 1; box-shadow: none; }
  .menu-btn:hover { background: rgba(255, 255, 255, .08); box-shadow: none; }
  .topbar-logo { width: 28px; height: 28px; border-radius: 8px; }
  .topbar-title { font-weight: 700; font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

  /* drawer: undo the icon-rail rules from the 940px breakpoint */
  .sidebar {
    width: 280px; max-width: 86vw; z-index: 40; transform: translateX(-102%);
    transition: transform .22s ease; box-shadow: 8px 0 30px rgba(0, 0, 0, .35);
  }
  body.menu-open .sidebar { transform: none; }
  body.menu-open .nav-scrim { display: block; position: fixed; inset: 0; z-index: 35; background: rgba(16, 20, 33, .5); }
  body.menu-open { overflow: hidden; }
  .brand { justify-content: flex-start; padding: 18px 18px 12px; }
  .brand > div, .gym-switch, .sidebar-footer #whoami { display: block; }
  nav .nav-group { display: block; }
  nav a span:not(.ico) { display: inline; }
  nav a { justify-content: flex-start; padding: 11px 12px; font-size: 15px; }
  nav a .ico { width: 22px; font-size: 16px; }
  .sidebar-footer { text-align: left; padding: 12px 18px 16px; font-size: 14px; }
  .sidebar-footer .link-btn { font-size: 14px; padding: 4px 0; }

  main { margin-left: 0; padding: 16px 12px 80px; max-width: none; }
  h2 { font-size: 22px; }
  .sub { margin-bottom: 14px; }

  /* 16px inputs stop iOS zooming in on focus */
  input, select, textarea { font-size: 16px; }
  .toolbar { gap: 8px; }
  .toolbar .spacer { display: none; }
  .toolbar > input, .toolbar > select { flex: 1 1 100%; min-width: 0; }
  .tabs { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
  .tabs button { white-space: nowrap; }
  .cards { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .stat .num { font-size: 22px; }
  .card { padding: 16px 14px; }

  /* modals fill the screen width */
  .modal-backdrop { padding: 10px 8px 30px; }
  .modal { padding: 20px 16px; border-radius: 16px; }
  .modal.wide { min-width: 0; width: 100%; }
  .modal .actions button { flex: 1 1 auto; }
  .mtg-row select { flex-basis: 100%; }

  #toast-root { left: 12px; right: 12px; bottom: 14px; }
  .toast { max-width: none; }
}

/* ---------- Tablets & phones: data tables become one card per row ---------- */
@media (max-width: 940px) {
  /* column name on the left, value on the right */
  table:not(.grid) { display: block; border: 0; background: none; box-shadow: none; overflow: visible; border-radius: 0; }
  table:not(.grid) thead { display: none; }
  table:not(.grid) tbody { display: block; }
  table:not(.grid) tr {
    display: block; background: var(--panel); border: 1px solid var(--line); border-radius: 12px;
    padding: 4px 14px; margin-bottom: 10px; box-shadow: var(--shadow);
  }
  table:not(.grid) tbody tr:hover { background: var(--panel); }
  table:not(.grid) td {
    display: block; position: relative; padding: 8px 0 8px 38%; min-height: 34px;
    border-bottom: 1px solid var(--line); text-align: left !important; overflow-wrap: anywhere;
  }
  table:not(.grid) tr td:last-child { border-bottom: none; }
  table:not(.grid) td::before {
    content: attr(data-label); position: absolute; left: 0; top: 10px; width: 34%;
    font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .6px; color: var(--muted);
  }
  table:not(.grid) td[data-label=""], table:not(.grid) td:not([data-label]) { padding-left: 0; }
  table:not(.grid) td[data-label=""]::before, table:not(.grid) td:not([data-label])::before { display: none; }
  table:not(.grid) td button { margin: 2px 0; }
  table:not(.grid) td.row-actions { min-width: 0; }
  .table-wrap { overflow: visible; box-shadow: none; border-radius: 0; }
  table:not(.grid) td[style*="white-space:nowrap"], table:not(.grid) td [style*="white-space:nowrap"] { white-space: normal !important; }
  table:not(.grid) td:empty { display: none; }

}
