:root {
  --red: #E1001A;
  --text: #1a1a1a;
  --muted: #666;
  --border: #e2e2e2;
  --bg: #f5f5f5;
  --card: #fff;
  --radius: 6px;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; background: var(--bg); color: var(--text); min-height: 100vh; }

/* ── Login ── */
#login-screen { display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: 24px; }
.login-card { background: var(--card); border-radius: var(--radius); box-shadow: 0 2px 16px rgba(0,0,0,.1); padding: 40px 36px; width: 100%; max-width: 380px; }
.login-card h2 { font-size: 1.4rem; margin-bottom: 6px; }
.login-card p { font-size: .85rem; color: var(--muted); margin-bottom: 28px; }
.va-dot { color: var(--red); }

/* ── Fields ── */
.field { margin-bottom: 16px; }
label { display: block; font-size: .8rem; font-weight: 600; margin-bottom: 5px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
input[type=text], input[type=email], input[type=password], input[type=date], input[type=time],
select {
  width: 100%; padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--radius);
  font-size: .95rem; outline: none; transition: border-color .15s; background: #fff;
  appearance: none; -webkit-appearance: none;
}
select { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%23666' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; padding-right: 32px; cursor: pointer; }
select:disabled { background-color: #f3f4f6; color: var(--muted); cursor: default; opacity: .7; }
input:focus, select:focus { border-color: var(--red); }
input[type=checkbox] { width: 16px; height: 16px; accent-color: var(--red); cursor: pointer; }

/* ── Buttons ── */
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 10px 18px; border-radius: var(--radius); font-size: .88rem; font-weight: 600; cursor: pointer; border: none; transition: opacity .15s, background .15s; }
.btn:hover:not(:disabled) { opacity: .85; }
.btn:disabled { opacity: .45; cursor: default; }
.btn-primary { background: var(--red); color: #fff; }
.btn-sm  { padding: 5px 12px; font-size: .78rem; }
.btn-cal { padding: 6px 10px; font-size: .78rem; }
.btn-ghost { background: rgba(255,255,255,.15); border: 1px solid rgba(255,255,255,.4); color: #fff; }
.btn-cancel { background: #fee2e2; color: #b91c1c; }
.btn-book   { background: #dcfce7; color: #15803d; }
.btn-wl     { background: #fef9c3; color: #854d0e; }

/* ── Header ── */
header { background: var(--red); color: #fff; padding: 14px 24px; display: flex; align-items: center; justify-content: space-between; }
header h1 { font-size: 1.1rem; font-weight: 800; letter-spacing: .06em; }
#user-name  { font-size: .88rem; font-weight: 600; }
#user-email { font-size: .75rem; opacity: .75; }

/* ── Tabs ── */
.tabs { display: flex; background: var(--card); border-bottom: 2px solid var(--border); padding: 0 24px; }
.tab-btn { padding: 13px 18px; font-size: .9rem; font-weight: 600; border: none; background: none; cursor: pointer; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -2px; transition: color .15s, border-color .15s; }
.tab-btn.active { color: var(--red); border-bottom-color: var(--red); }

/* ── Content ── */
.content { padding: 24px; max-width: 1080px; margin: 0 auto; }

/* ── Search form ── */
.search-form { background: var(--card); border-radius: var(--radius); padding: 20px 24px; margin-bottom: 20px; box-shadow: 0 1px 4px rgba(0,0,0,.05); }
.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 12px; margin-bottom: 14px; }
.form-row { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.checkbox-row { display: flex; align-items: center; gap: 8px; font-size: .88rem; cursor: pointer; }

/* ── Card / Table ── */
.card { background: var(--card); border-radius: var(--radius); box-shadow: 0 1px 4px rgba(0,0,0,.06); overflow: hidden; }
table { width: 100%; border-collapse: collapse; font-size: .86rem; }
thead tr { background: #f9f9f9; }
th { padding: 10px 14px; text-align: left; font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); white-space: nowrap; }
td { padding: 11px 14px; border-top: 1px solid var(--border); vertical-align: middle; }
tbody tr:hover td { background: #fafafa; }

/* ── Badges ── */
.badge { display: inline-block; padding: 3px 9px; border-radius: 99px; font-size: .72rem; font-weight: 700; }
.badge-green  { background: #dcfce7; color: #15803d; }
.badge-blue   { background: #dbeafe; color: #1d4ed8; }
.badge-yellow { background: #fef9c3; color: #854d0e; }
.badge-red    { background: #fee2e2; color: #b91c1c; }

/* ── States ── */
.error-box { background: #fee2e2; color: #b91c1c; padding: 12px 16px; border-radius: var(--radius); margin-bottom: 16px; font-size: .88rem; }
.empty   { padding: 52px; text-align: center; color: var(--muted); }
.loading { padding: 52px; text-align: center; color: var(--muted); }

/* ── Spinner ── */
.spinner { display: inline-block; width: 22px; height: 22px; border: 3px solid rgba(0,0,0,.1); border-top-color: var(--red); border-radius: 50%; animation: spin .7s linear infinite; vertical-align: middle; margin-right: 8px; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Confirm modal ── */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.5); display: flex; align-items: center; justify-content: center; z-index: 10000; }
.modal-box { background: var(--card); border-radius: var(--radius); padding: 28px; max-width: 360px; width: calc(100% - 48px); box-shadow: 0 8px 32px rgba(0,0,0,.25); }
.modal-msg { font-size: .95rem; line-height: 1.5; margin-bottom: 20px; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; }
.btn-outline { background: transparent; border: 1px solid var(--border); color: var(--text); }

/* ── Toast ── */
#toast { position: fixed; bottom: 24px; right: 24px; padding: 12px 20px; border-radius: var(--radius); font-size: .88rem; color: #fff; opacity: 0; pointer-events: none; transition: opacity .3s; z-index: 9999; max-width: 320px; }
#toast.show { opacity: 1; }

.hidden { display: none !important; }

/* ═══════════════════════════════ MOBILE ════════════════════════════════ */
@media (max-width: 640px) {
  /* Header */
  header { padding: 10px 14px; }
  #user-email { display: none; }

  /* Tabs — horizontal scroll strip */
  .tabs { padding: 0 6px; overflow-x: auto; -webkit-overflow-scrolling: touch; scrollbar-width: none; }
  .tabs::-webkit-scrollbar { display: none; }
  .tab-btn { padding: 10px 12px; font-size: .78rem; white-space: nowrap; }

  /* Content */
  .content, .content.wide { padding: 12px; }

  /* Login */
  .login-card { padding: 28px 18px; }

  /* Toast: full-width */
  #toast { bottom: 14px; right: 12px; left: 12px; max-width: none; text-align: center; }

  /* ── Search form ── */
  .form-grid { grid-template-columns: 1fr 1fr; }

  /* ── Tables → card layout ── */
  .card { overflow: visible; }
  .card table { width: 100%; }
  .card thead { display: none; }
  .card tbody tr { display: block; border-bottom: 1px solid var(--border); padding: 12px 14px; }
  .card tbody tr:last-child { border-bottom: none; }
  .card td { display: flex; align-items: flex-start; justify-content: space-between;
             padding: 3px 0; border-top: none; font-size: .84rem; gap: 8px; }
  .card td[data-label]::before { content: attr(data-label); font-size: .68rem; font-weight: 700;
    color: var(--muted); text-transform: uppercase; letter-spacing: .04em;
    flex-shrink: 0; min-width: 72px; padding-top: 2px; }
  .card td.td-action { justify-content: flex-end; padding-top: 8px; }

  /* ── Calendar controls: two rows ── */
  .cal-controls { flex-direction: column; gap: 8px; }
  .cal-left { flex-wrap: wrap; gap: 6px; }
  .cal-gym-sel select { min-width: 0; flex: 1; }
  .cal-gym-sel { flex: 1 1 140px; }
  #cal-filter-class, #cal-filter-instructor { min-width: 0; flex: 1 1 130px; }
  .cal-sep { display: none; }

  /* ── Favourites ── */
  #tab-favourites { max-width: 100% !important; }
}

/* ── Calendar ── */
.cal-controls { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; flex-wrap: wrap; gap: 12px; }
.cal-left { display: flex; align-items: center; gap: 10px; }
.cal-nav { display: flex; align-items: center; gap: 8px; }
.cal-nav-btn { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 6px 14px; font-size: .88rem; font-weight: 700; cursor: pointer; color: var(--text); transition: background .15s; }
.cal-nav-btn:hover { background: #f0f0f0; }
.cal-today-btn { background: var(--red); color: #fff; border: none; border-radius: var(--radius); padding: 6px 12px; font-size: .8rem; font-weight: 700; cursor: pointer; transition: opacity .15s; }
.cal-today-btn:hover { opacity: .85; }
.cal-week-label { font-weight: 700; font-size: .95rem; min-width: 210px; text-align: center; }
.cal-gym-sel select { width: auto; min-width: 180px; }
.cal-scroll { overflow-x: auto; }
.cal-grid { display: grid; grid-template-columns: repeat(7, minmax(148px, 1fr)); gap: 8px; min-width: 700px; }
.cal-day { background: var(--card); border-radius: var(--radius); box-shadow: 0 1px 4px rgba(0,0,0,.06); overflow: hidden; }
.cal-day-header { padding: 10px 8px 8px; border-bottom: 1px solid var(--border); text-align: center; background: #f9f9f9; }
.cal-day-header.today { background: var(--red); color: #fff; }
.cal-day-header .day-name { font-size: .68rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; opacity: .7; }
.cal-day-header.today .day-name { opacity: .85; }
.cal-day-header .day-num { font-size: 1.3rem; font-weight: 800; line-height: 1.1; }
.cal-day-header .day-mon { font-size: .72rem; font-weight: 600; opacity: .75; }
.cal-classes { padding: 6px; display: flex; flex-direction: column; gap: 5px; min-height: 80px; }
.cal-empty { color: var(--muted); font-size: .75rem; text-align: center; padding: 18px 6px; }
.cal-card { border-radius: 4px; padding: 12px 14px; font-size: .82rem; border-left: 3px solid var(--border); background: #fafafa; border: 1px solid var(--border); }
.cal-card.available   { border-left: 3px solid #15803d; }
.cal-card.waitlist    { border-left: 3px solid #f59e0b; }
.cal-card.on-waitlist { border-left: 3px solid #2563eb; background: #eff6ff; }
.cal-card.full        { border-left: 3px solid #9ca3af; opacity: .6; }
.cal-card.booked      { border-left: 3px solid #15803d; background: #dcfce7; }
.cal-card.past      { opacity: .35; border-left-color: #9ca3af !important; }
.cal-card.blocked   { border-left-color: #9ca3af !important; opacity: .45; filter: grayscale(.4); }
.cal-blocked-toggle { display: flex; align-items: center; gap: 5px; width: 100%; padding: 4px 6px; margin-top: 2px; background: none; border: 1px dashed var(--border); border-radius: 4px; font-size: .72rem; color: var(--muted); cursor: pointer; text-align: left; transition: background .15s; }
.cal-blocked-toggle:hover { background: #f3f4f6; }
.cal-blocked-toggle span { font-size: .65rem; transition: transform .2s; }
.cal-blocked-toggle.open span { transform: rotate(90deg); }
.cal-card-time  { font-weight: 700; font-size: .7rem; color: var(--muted); }
.cal-card-name  { font-weight: 700; font-size: .9rem; line-height: 1.2; margin: 3px 0 2px; }
.cal-card-instr { color: var(--muted); font-size: .7rem; margin-bottom: 5px; }
.cal-card-footer { display: flex; align-items: center; justify-content: space-between; gap: 4px; flex-wrap: wrap; }
.content.wide { max-width: 1380px; }

/* ── Instructor picker ── */
.ins-picker { display: flex; flex-direction: column; gap: 6px; }
.ins-filter { width: 100%; }
.ins-list {
  width: 100%; max-height: 180px; overflow-y: auto;
  border: 1px solid var(--border); border-radius: var(--radius);
  background: #fff; font-size: .88rem;
}
.ins-list-item {
  padding: 10px 12px; cursor: pointer; border-bottom: 1px solid var(--border);
  user-select: none; -webkit-user-select: none;
  transition: background .1s;
}
.ins-list-item:last-child { border-bottom: none; }
.ins-list-item:active { background: #f3f4f6; }
.ins-list-item.selected { background: var(--red); color: #fff; }
.ins-list-empty { padding: 12px; color: var(--muted); font-size: .82rem; text-align: center; }

/* ── Multi-select ── */
.ms-wrap { position: relative; }
.ms-btn { width: 100%; padding: 10px 32px 10px 12px; border: 1px solid var(--border); border-radius: var(--radius); font-size: .95rem; text-align: left; background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%23666' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E") no-repeat right 12px center; cursor: pointer; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ms-btn:focus { border-color: var(--red); outline: none; }
.ms-btn.open  { border-color: var(--red); }
.ms-btn.disabled { background-color: #f3f4f6; color: var(--muted); cursor: default; opacity: .7; pointer-events: none; }
.ms-drop { position: absolute; top: calc(100% + 2px); left: 0; right: 0; z-index: 200; background: #fff; border: 1px solid var(--border); border-radius: var(--radius); box-shadow: 0 4px 16px rgba(0,0,0,.12); display: none; }
.ms-drop.open { display: block; }
.ms-drop-search { padding: 8px; border-bottom: 1px solid var(--border); }
.ms-drop-search input { width: 100%; padding: 6px 10px; border: 1px solid var(--border); border-radius: 4px; font-size: .85rem; background: #fff; }
.ms-drop-search input:focus { outline: none; border-color: var(--red); }
.ms-drop-list { max-height: 200px; overflow-y: auto; }
.ms-opt { display: flex; align-items: center; gap: 8px; padding: 9px 12px; cursor: pointer; border-bottom: 1px solid #f3f3f3; font-size: .88rem; user-select: none; -webkit-user-select: none; }
.ms-opt:last-child { border-bottom: none; }
.ms-opt:hover { background: #f9f9f9; }
.ms-opt.selected { background: #fff0f0; }
.ms-opt input[type=checkbox] { flex-shrink: 0; margin: 0; width: 15px; height: 15px; }
.ms-empty { padding: 16px; text-align: center; color: var(--muted); font-size: .82rem; }
.ms-drop-footer { padding: 8px 12px; border-top: 1px solid var(--border); }
.ms-drop-footer .btn { font-size: .75rem; padding: 4px 10px; }

/* ── Calendar sync banner ── */
.cal-sync-banner { background: var(--card); border-radius: var(--radius); padding: 14px 16px; margin-bottom: 20px; box-shadow: 0 1px 4px rgba(0,0,0,.06); border-left: 3px solid var(--red); }
.cal-sync-apps { display: flex; gap: 8px; flex-wrap: wrap; }
.cal-sync-app { display: flex; flex-direction: column; align-items: center; gap: 5px; padding: 10px 16px; border-radius: var(--radius); border: 1px solid var(--border); background: var(--bg); font-size: .75rem; font-weight: 600; color: var(--text); text-decoration: none; cursor: pointer; transition: background .15s, border-color .15s; min-width: 72px; }
.cal-sync-app:hover { background: var(--card); border-color: #aaa; }
.cal-icon { width: 32px; height: 32px; border-radius: 8px; display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; }

/* hidden on desktop */
#cal-date-strip { display: none; }

/* ── Calendar: single-day overrides (must be after base calendar styles) ── */
@media (max-width: 640px) {
  /* single-day grid */
  .cal-scroll { overflow-x: visible; }
  .cal-grid { display: block; min-width: unset; }
  .cal-day-header { display: none; }
  .cal-day { box-shadow: none; border-radius: 0; background: transparent; }
  .cal-classes { padding: 0; gap: 8px; min-height: unset; }
  .cal-card { border-radius: var(--radius); }

  /* hide old nav, show date strip */
  .cal-nav { display: none; }
  #cal-date-strip { display: flex; align-items: center; gap: 6px; width: 100%; margin: 4px 0; }
  .cal-strip-inner { display: flex; flex: 1; gap: 2px; }
  .cal-strip-day { display: flex; flex-direction: column; align-items: center; padding: 7px 0; border: none; background: none; border-radius: 8px; cursor: pointer; flex: 1; gap: 1px; color: var(--text); }
  .cal-strip-day.selected { background: var(--red); color: #fff; }
  .cal-strip-day.today { color: var(--red); }
  .cal-strip-day.sun { color: var(--red); }
  .strip-letter { font-size: .62rem; font-weight: 700; text-transform: uppercase; }
  .strip-num { font-size: 1.1rem; font-weight: 800; line-height: 1.1; }
  .strip-mon { font-size: .58rem; opacity: .7; }
  .cal-strip-arrow { background: none; border: 1px solid var(--border); border-radius: 6px; padding: 6px 10px; font-size: 1rem; font-weight: 700; cursor: pointer; color: var(--text); flex-shrink: 0; line-height: 1; }
}
