* { box-sizing: border-box; }
body { font-family: system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif; margin: 0; background: #f6f7fb; color: #1f2937; }
header { display:flex; justify-content: space-between; align-items: center; padding: 12px 16px; background: #111827; color: #fff; }
h1 { font-size: 18px; margin: 0; }
.card { background: #fff; margin: 12px; padding: 12px; border-radius: 8px; width: 100%; max-width: none; box-shadow: 0 2px 8px rgba(0,0,0,0.06); }
.hidden { display: none; }
label { display: flex; flex-direction: column; font-size: 12px; color: #374151; gap: 6px; }
input, select, button { padding: 6px 8px; font-size: 13px; }
#login-form { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 8px; align-items: end; }
#login-form button { height: 32px; }
.hint { color: #6b7280; font-size: 12px; margin-top: 6px; }

/* Floating active filters bar */
.floating-box { position: sticky; top: 0; z-index: 1000; background: #ffffffcc; backdrop-filter: blur(4px); padding: 8px 12px; border-bottom: 1px solid #e5e7eb; box-shadow: 0 4px 10px rgba(0,0,0,0.05); }
.floating-row { display: flex; flex-wrap: nowrap; gap: 8px; align-items: center; overflow-x: auto; padding: 4px 0; }
.toggle-inline { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: #374151; }
.btn-small { padding: 4px 8px; font-size: 12px; border: 1px solid #e5e7eb; background: #fff; border-radius: 6px; cursor: pointer; }
.btn-small:hover { background: #f9fafb; }
.chip-group { display: flex; align-items: center; gap: 8px; }
.group-title { font-size: 12px; color: #6b7280; white-space: nowrap; }
.chip-row { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 2px; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 2px 8px; font-size: 12px; border-radius: 999px; border: 1px solid #e5e7eb; background: #fff; color: #111827; cursor: pointer; white-space: nowrap; }
.chip:hover { background: #f3f4f6; }
.chip.active { background: #111827; color: #fff; border-color: #111827; }

.filters, .sorts { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 8px; }
.sorts { margin-top: 8px; align-items: end; }
#grid-container { overflow-x: auto; }
#workouts-grid { border-collapse: collapse; width: 100%; min-width: 800px; }
#workouts-grid thead th { position: sticky; top: 0; background: #f3f4f6; border-bottom: 1px solid #e5e7eb; padding: 4px 6px; font-weight: 600; text-align: center; z-index: 3; }
#workouts-grid th, #workouts-grid td { border: 1px solid #e5e7eb; padding: 4px; vertical-align: top; background: #fff; }
#workouts-grid th.time-col { position: sticky; left: 0; z-index: 2; width: 72px; background: #f9fafb; font-size: 12px; text-align: left; }
#workouts-grid td:first-child { position: sticky; left: 0; z-index: 1; background: #f9fafb; }
/* Header date layout */
.date-header { display: inline-flex; flex-direction: column; align-items: center; gap: 2px; line-height: 1.1; }
.date-header .date-line { font-size: 11px; font-weight: 600; color: #111827; white-space: nowrap; }
.date-header .weekday-line { font-size: 10px; color: #6b7280; white-space: nowrap; }
.week-chip { display: inline-block; margin-left: 6px; padding: 0 6px; font-size: 10px; line-height: 16px; height: 16px; border-radius: 999px; background: #e5e7eb; color: #374151; border: 1px solid #d1d5db; vertical-align: middle; }
/* Week separator (before Mondays) */
th.week-sep, td.week-sep { border-left-width: 3px !important; border-left-color: #9ca3af !important; }
/* Workout item */
.cell-item { position: relative; display: block; background: #f3f4f6; border: 1px solid #e5e7eb; border-left: 4px solid transparent; border-radius: 4px; padding: 4px 6px 4px 6px; margin-bottom: 2px; overflow: visible; font-size: 12px; line-height: 1.25; }
.cell-item.bookable { background: #bbf7d0; border-color: #34d399; }
.cell-item .line-main { display: block; font-weight: 600; color: #111827; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; cursor: pointer; }
.cell-item .line-sub { display: block; font-size: 11px; color: #4b5563; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; cursor: pointer; }
.time-label { font-weight: 600; color: #374151; font-size: 12px; }
/* Global tooltip (JS-driven) */
#tooltip { position: fixed; display: none; max-width: 640px; background: #111827; color: #fff; padding: 10px 12px; border-radius: 6px; z-index: 9999; box-shadow: 0 8px 24px rgba(0,0,0,0.35); pointer-events: auto; font-size: 13px; line-height: 1.35; }
#tooltip p { margin: 0 0 6px 0; }
#tooltip p:last-child { margin-bottom: 0; }

/* Team badge */
.badge-team { display: inline-block; margin-left: 6px; padding: 0 6px; font-size: 10px; font-weight: 700; border-radius: 999px; background: #1f2937; color: #fef9c3; border: 1px solid #f59e0b; line-height: 16px; height: 16px; vertical-align: baseline; }
.cell-item.team { border-style: solid; }

/* Capacity chip */
.cap-chip { position: absolute; top: 2px; right: 4px; padding: 0 6px; font-size: 10px; line-height: 16px; height: 16px; border-radius: 999px; background: #eef2ff; color: #3730a3; border: 1px solid #c7d2fe; }
.cell-item.bookable .cap-chip { background: #dcfce7; color: #065f46; border-color: #bbf7d0; }

/* Schedule header controls */
.schedule-header { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.schedule-focus { display: flex; gap: 8px; align-items: center; }
.focus-chip { display: inline-flex; align-items: center; gap: 6px; padding: 2px 8px; font-size: 12px; border-radius: 999px; border: 1px solid #d1d5db; background: #f9fafb; color: #111827; }
.focus-chip .clear { cursor: pointer; padding: 0 6px; color: #6b7280; }
.focus-chip .clear:hover { color: #111827; }
.schedule-selected { display: flex; align-items: center; gap: 8px; }
.selected-list { display: flex; gap: 6px; flex-wrap: wrap; }
.selected-chip { display: inline-flex; align-items: center; gap: 6px; padding: 2px 8px; font-size: 12px; border-radius: 999px; border: 1px solid #111827; background: #fff; color: #111827; }
.selected-chip .remove { cursor: pointer; padding: 0 6px; color: #6b7280; }
.selected-chip .remove:hover { color: #ef4444; }

/* Selected workout styling */
.cell-item.selected { border-width: 2px; }

/* Booked workout emphasis */
.cell-item.booked {
  outline: 2px solid #7c3aed; /* Purple accent */
  box-shadow: 0 0 0 2px rgba(124,58,237,0.15), 0 6px 16px rgba(124,58,237,0.2);
  position: relative;
}
.badge-booked {
  position: absolute;
  top: -8px;
  left: -8px;
  background: #7c3aed;
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 4px;
  box-shadow: 0 2px 4px rgba(0,0,0,0.15);
}
.badge-booked.waiting {
  background: #dc2626; /* red for waiting list */
}

/* Availability vertical bar */
.cell-item .avail-bar { position: absolute; right: 0; top: 0; bottom: 0; width: 4px; background: linear-gradient(to bottom, #22c55e 0%, #22c55e var(--free-pct, 0%), #3b82f6 var(--free-pct, 0%), #3b82f6 100%); border-top-right-radius: 4px; border-bottom-right-radius: 4px; }
.cell-item .avail-bar.no-slots { background: #ef4444; }


/* Toggle switch */
.switch { position: relative; width: 40px; height: 22px; display: inline-block; }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch .switch-track { position: absolute; inset: 0; background: #e5e7eb; border: 1px solid #d1d5db; border-radius: 999px; transition: background .2s, border-color .2s; }
.switch .switch-thumb { position: absolute; top: 1px; left: 1px; width: 18px; height: 18px; border-radius: 999px; background: #fff; box-shadow: 0 1px 2px rgba(0,0,0,0.2); transition: transform .2s; }
.switch input:checked + .switch-track { background: #111827; border-color: #111827; }
.switch input:checked + .switch-track .switch-thumb { transform: translateX(18px); }
.switch input:focus + .switch-track { outline: 2px solid rgba(17,24,39,0.35); outline-offset: 2px; }
.switch-label { white-space: nowrap; }

/* Time slider */
.range-group { display: flex; flex-direction: column; gap: 4px; min-width: 240px; }
.range-group input[type=range] { -webkit-appearance: none; appearance: none; width: 100%; height: 4px; background: #e5e7eb; border-radius: 999px; outline: none; }
.range-group input[type=range]::-webkit-slider-runnable-track { height: 4px; background: #e5e7eb; border-radius: 999px; }
.range-group input[type=range]::-webkit-slider-thumb { -webkit-appearance: none; appearance: none; width: 16px; height: 16px; border-radius: 50%; background: #111827; margin-top: -6px; cursor: pointer; border: 2px solid #fff; box-shadow: 0 1px 2px rgba(0,0,0,0.2); }
.range-group input[type=range]::-moz-range-track { height: 4px; background: #e5e7eb; border: none; border-radius: 999px; }
.range-group input[type=range]::-moz-range-thumb { width: 16px; height: 16px; border-radius: 50%; background: #111827; cursor: pointer; border: 2px solid #fff; box-shadow: 0 1px 2px rgba(0,0,0,0.2); }
.range-labels { display: flex; justify-content: space-between; gap: 4px; }
.range-label { padding: 2px 6px; font-size: 11px; border: 1px solid transparent; background: none; color: #374151; cursor: pointer; border-radius: 999px; }
.range-label:hover { background: #f3f4f6; }
.range-label.active { color: #111827; border-color: #111827; background: #fff; }

.tip-header { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
.tip-info { flex: 1 1 auto; }
.tip-body { margin-top: 6px; }
.tip-actions { display: flex; gap: 6px; margin-left: 12px; }
.btn-tip { padding: 4px 8px; font-size: 12px; border: 1px solid #d1d5db; background: #ffffff; color: #111827; border-radius: 6px; cursor: pointer; }
.btn-tip:hover { background: #f3f4f6; }

.topbar-box { border: 1px solid #e5e7eb; background: #ffffff; border-radius: 10px; padding: 8px 10px; box-shadow: 0 2px 6px rgba(0,0,0,0.04); }
.floating-box .topbar-box { margin: 6px 0; }
.topbar-box .group-title { font-weight: 600; color: #374151; }