@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700;800&family=DM+Sans:ital,opsz,wght@0,9..40,300;0,9..40,400;0,9..40,500;0,9..40,600;1,9..40,400&display=swap');

/* ============ DESIGN TOKENS ============ */
:root {
  --bg-primary: #050507;
  --bg-secondary: #0b0b0f;
  --bg-card: #101014;
  --bg-input: #16161c;
  --border: #1e1e28;
  --border-subtle: #151520;
  --text-primary: #eaeaf0;
  --text-secondary: #6e6e82;
  --accent: #aaaaaa;
  --accent-hover: #cccccc;
  --accent-dim: rgba(170, 170, 170, 0.08);
  --danger: #ef4444;
  --success: #22c55e;
  --warning: #f59e0b;
  --glow: rgba(170, 170, 170, 0.06);
  --card-shadow: 0 1px 3px rgba(0,0,0,0.4), 0 8px 24px rgba(0,0,0,0.2);
  --card-shadow-hover: 0 4px 12px rgba(0,0,0,0.5), 0 16px 40px rgba(0,0,0,0.3);
  --radius: 14px;
  --radius-sm: 10px;
  --radius-xs: 7px;
  --transition-fast: 0.15s cubic-bezier(0.4, 0, 0.2, 1);
  --transition: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-slow: 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  --font-display: 'Outfit', sans-serif;
  --font-body: 'DM Sans', sans-serif;
}

/* ============ RESET & BASE ============ */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: var(--font-body);
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-size: 15px;
  line-height: 1.6;
}

h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-display);
  line-height: 1.25;
  letter-spacing: -0.02em;
}

::selection {
  background: var(--accent);
  color: var(--bg-primary);
}

/* ============ ANIMATIONS ============ */
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes slideInLeft {
  from { opacity: 0; transform: translateX(-16px); }
  to { opacity: 1; transform: translateX(0); }
}

@keyframes shimmer {
  0% { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}

@keyframes pulseGlow {
  0%, 100% { box-shadow: 0 0 0 0 var(--accent-dim); }
  50% { box-shadow: 0 0 0 6px transparent; }
}

@keyframes borderFlow {
  0% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}

/* ============ LOGIN ============ */
.login-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 2rem;
  background:
    radial-gradient(ellipse 60% 50% at 50% 0%, rgba(170,170,170,0.04) 0%, transparent 60%),
    var(--bg-primary);
  animation: fadeIn 0.6s ease-out;
}

.login-logo {
  width: 140px;
  margin-bottom: 2.5rem;
  filter: drop-shadow(0 4px 24px rgba(170,170,170,0.08));
  animation: fadeInUp 0.5s ease-out;
}

.login-box {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 2.75rem;
  width: 100%;
  max-width: 420px;
  box-shadow: var(--card-shadow), 0 0 0 1px var(--border-subtle);
  backdrop-filter: blur(20px);
  animation: fadeInUp 0.6s ease-out 0.1s both;
}

.login-box h2 {
  text-align: center;
  margin-bottom: 2rem;
  font-weight: 700;
  font-size: 1.35rem;
  color: var(--text-primary);
  font-family: var(--font-display);
  letter-spacing: -0.02em;
}

/* ============ LAYOUT ============ */
.app-layout {
  display: flex;
  min-height: 100vh;
}

.over-cap {
  color: var(--danger) !important;
  animation: pulseCap 1.2s ease-in-out infinite;
}

@keyframes pulseCap {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.55; }
}

.impersonate-banner {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 1000;
  background: #e67e22;
  color: #fff;
  padding: 0.55rem 1.25rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  font-size: 0.9rem;
  font-weight: 500;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.impersonate-banner .btn {
  background: rgba(255, 255, 255, 0.2);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.45);
  padding: 0.35rem 0.85rem;
  font-size: 0.85rem;
}

.impersonate-banner .btn:hover {
  background: rgba(255, 255, 255, 0.3);
}

.app-layout.with-banner {
  padding-top: 44px;
}

.app-layout.with-banner .sidebar {
  top: 44px;
}

.sidebar {
  width: 272px;
  background: var(--bg-secondary);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 100;
  overflow-y: auto;
  overflow-x: hidden;
}

.sidebar-header {
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  position: sticky;
  top: 0;
  background: var(--bg-secondary);
  z-index: 2;
}

.sidebar-logo {
  width: 120px;
  height: 80px;
  object-fit: contain;
  border-radius: var(--radius-xs);
}

.sidebar-header h3 {
  font-size: 0.92rem;
  font-weight: 700;
  color: var(--text-primary);
  font-family: var(--font-display);
  letter-spacing: -0.01em;
}

.sidebar-nav {
  flex: 1;
  padding: 0.75rem 0;
  overflow-y: auto;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.72rem 1.25rem 0.72rem 1.5rem;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition-fast);
  font-size: 0.88rem;
  font-weight: 450;
  border-left: 3px solid transparent;
  position: relative;
  margin: 1px 0;
}

.nav-item:hover {
  color: var(--text-primary);
  background: rgba(255,255,255,0.03);
}

.nav-item.active {
  color: var(--accent);
  background: var(--accent-dim);
  border-left-color: var(--accent);
  font-weight: 550;
}

.nav-item svg { width: 19px; height: 19px; flex-shrink: 0; opacity: 0.8; }
.nav-item.active svg { opacity: 1; }

.nav-subitems {
  max-height: 0;
  overflow: hidden;
  transition: max-height var(--transition) ease;
}

.nav-subitems.open { max-height: 320px; }

.nav-subitem {
  padding: 0.5rem 1.5rem 0.5rem 3.1rem;
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 0.82rem;
  transition: all var(--transition-fast);
  border-left: 3px solid transparent;
  font-weight: 400;
}

.nav-subitem:hover {
  color: var(--text-primary);
  background: rgba(255,255,255,0.025);
}

.nav-subitem.active {
  color: var(--accent);
  border-left-color: var(--accent);
  background: var(--accent-dim);
  font-weight: 500;
}

.sidebar-footer {
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--border);
  position: sticky;
  bottom: 0;
  background: var(--bg-secondary);
}

.user-info {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.user-info span {
  font-size: 0.84rem;
  color: var(--text-primary);
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.btn-logout {
  background: rgba(239,68,68,0.08);
  border: 1px solid rgba(239,68,68,0.15);
  color: var(--danger);
  cursor: pointer;
  padding: 0.4rem 0.65rem;
  border-radius: var(--radius-xs);
  transition: all var(--transition-fast);
  display: flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.76rem;
  font-family: var(--font-body);
  white-space: nowrap;
  flex-shrink: 0;
}

.btn-logout:hover {
  background: rgba(239,68,68,0.18);
  border-color: rgba(239,68,68,0.3);
}

.btn-logout svg { width: 14px; height: 14px; }

.main-content {
  flex: 1;
  margin-left: 272px;
  padding: 2.25rem 2.5rem;
  min-height: 100vh;
  background:
    radial-gradient(ellipse 70% 40% at 75% 0%, rgba(170,170,170,0.015) 0%, transparent 60%),
    var(--bg-primary);
  animation: fadeIn 0.35s ease-out;
}

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 2rem;
  gap: 1rem;
  flex-wrap: wrap;
}

.page-header h1 {
  font-size: 1.65rem;
  font-weight: 700;
  font-family: var(--font-display);
  letter-spacing: -0.025em;
  color: var(--text-primary);
}

/* ============ STAT CARDS ============ */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 1rem;
  margin-bottom: 2rem;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.35rem 1.5rem;
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
  transition: all var(--transition);
  position: relative;
  overflow: hidden;
}

.stat-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--accent-dim), transparent);
  opacity: 0;
  transition: opacity var(--transition);
}

.stat-card:hover {
  border-color: var(--border);
  box-shadow: var(--card-shadow);
  transform: translateY(-1px);
}

.stat-card:hover::before { opacity: 1; }

.stat-card .label {
  font-size: 0.72rem;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.07em;
  font-weight: 600;
  font-family: var(--font-display);
}

.stat-card .value {
  font-size: 1.9rem;
  font-weight: 700;
  color: var(--accent);
  margin-top: 0.45rem;
  font-family: var(--font-display);
  letter-spacing: -0.03em;
  line-height: 1.1;
}

.stat-card .sub {
  font-size: 0.78rem;
  color: var(--text-secondary);
  margin-top: 0.3rem;
}

/* ============ CARDS ============ */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 1.5rem;
  box-shadow: 0 2px 8px rgba(0,0,0,0.12);
  transition: box-shadow var(--transition);
}

.card:hover { box-shadow: var(--card-shadow); }

.card-header {
  padding: 1.15rem 1.5rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.card-header h3 {
  font-size: 0.95rem;
  font-weight: 650;
  font-family: var(--font-display);
  letter-spacing: -0.01em;
}

.card-body { padding: 1.5rem; }

/* ============ TABLE ============ */
table { width: 100%; border-collapse: collapse; }

th, td {
  padding: 0.8rem 1.15rem;
  text-align: left;
  border-bottom: 1px solid var(--border-subtle);
  font-size: 0.86rem;
}

th {
  color: var(--text-secondary);
  font-weight: 600;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-family: var(--font-display);
  background: rgba(255,255,255,0.01);
}

tr:last-child td { border-bottom: none; }

tr {
  transition: background var(--transition-fast);
}

tr:hover td {
  background: rgba(255,255,255,0.018);
}

td strong {
  font-weight: 600;
  color: var(--text-primary);
}

/* ============ FORMS ============ */
.form-group { margin-bottom: 1.15rem; }

.form-group label {
  display: block;
  font-size: 0.78rem;
  color: var(--text-secondary);
  margin-bottom: 0.4rem;
  font-weight: 550;
  font-family: var(--font-display);
  letter-spacing: 0.01em;
}

.form-control {
  width: 100%;
  padding: 0.68rem 0.9rem;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  color: var(--text-primary);
  font-size: 0.9rem;
  font-family: var(--font-body);
  transition: all var(--transition-fast);
  outline: none;
}

.form-control:hover {
  border-color: var(--border-hover, #2a2a38);
}

.form-control:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-dim), 0 0 0 1px var(--accent);
  background: var(--bg-primary);
}

.form-control::placeholder {
  color: var(--text-secondary);
  opacity: 0.5;
}

textarea.form-control {
  resize: vertical;
  min-height: 44px;
}

select.form-control {
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236e6e82' stroke-width='2.5'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.75rem center;
  padding-right: 2.25rem;
}

input[type="checkbox"] {
  accent-color: var(--accent);
  width: 15px;
  height: 15px;
  cursor: pointer;
}

input[type="color"] {
  cursor: pointer;
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  background: var(--bg-input);
  padding: 2px;
}

.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.form-row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 1rem; }

/* ============ BUTTONS ============ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  padding: 0.62rem 1.15rem;
  border: none;
  border-radius: var(--radius-xs);
  font-size: 0.86rem;
  font-weight: 550;
  cursor: pointer;
  transition: all var(--transition-fast);
  font-family: var(--font-display);
  letter-spacing: 0.005em;
  white-space: nowrap;
  text-decoration: none;
  line-height: 1.4;
}

.btn svg { width: 16px; height: 16px; flex-shrink: 0; }

.btn-primary {
  background: var(--accent);
  color: #0a0a0a;
  font-weight: 650;
  box-shadow: 0 1px 3px rgba(0,0,0,0.2), inset 0 1px 0 rgba(255,255,255,0.1);
}

.btn-primary:hover {
  background: var(--accent-hover);
  color: #0a0a0a;
  box-shadow: 0 2px 8px rgba(0,0,0,0.3), inset 0 1px 0 rgba(255,255,255,0.15);
  transform: translateY(-1px);
}

.btn-primary:active {
  transform: translateY(0);
  box-shadow: 0 1px 2px rgba(0,0,0,0.2);
}

.btn-secondary {
  background: var(--bg-input);
  color: var(--text-primary);
  border: 1px solid var(--border);
}

.btn-secondary:hover {
  background: var(--border);
  border-color: var(--border-hover, #2a2a38);
}

.btn-danger {
  background: rgba(239,68,68,0.1);
  color: var(--danger);
  border: 1px solid rgba(239,68,68,0.12);
}

.btn-danger:hover {
  background: rgba(239,68,68,0.2);
  border-color: rgba(239,68,68,0.25);
}

.btn-sm {
  padding: 0.4rem 0.72rem;
  font-size: 0.78rem;
  border-radius: 6px;
}

.btn[disabled] {
  opacity: 0.4;
  cursor: not-allowed;
  pointer-events: none;
}

/* ============ MODAL ============ */
/* Edit forms open as a full page (not a floating hover dialog). */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: var(--bg-primary);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  visibility: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  transition: opacity var(--transition), visibility var(--transition);
  padding: 2rem 1.5rem 4rem;
}

.modal-overlay.active {
  opacity: 1;
  visibility: visible;
}

.modal {
  background: transparent;
  border: none;
  border-radius: 0;
  width: 100%;
  max-width: 680px;
  padding: 0;
  box-shadow: none;
  animation: fadeInUp 0.2s ease-out;
}

.modal h2 {
  font-size: 1.5rem;
  margin-bottom: 1.75rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border-subtle);
  color: var(--text-primary);
  font-family: var(--font-display);
  font-weight: 700;
  letter-spacing: -0.02em;
}

.modal-actions {
  display: flex;
  gap: 0.65rem;
  justify-content: flex-end;
  margin-top: 1.75rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--border-subtle);
}

/* ============ CHARTS ============ */
.charts-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(420px, 1fr));
  gap: 1.25rem;
  margin-bottom: 1.5rem;
}

.chart-container {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  box-shadow: 0 2px 8px rgba(0,0,0,0.12);
}

.chart-container h4 {
  font-size: 0.82rem;
  color: var(--text-secondary);
  margin-bottom: 1rem;
  font-weight: 600;
  font-family: var(--font-display);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* ============ BADGES ============ */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.22rem 0.6rem;
  border-radius: 20px;
  font-size: 0.72rem;
  font-weight: 600;
  font-family: var(--font-display);
  letter-spacing: 0.02em;
}

.badge-active {
  background: rgba(34,197,94,0.1);
  color: var(--success);
  border: 1px solid rgba(34,197,94,0.15);
}

.badge-inactive {
  background: rgba(110,110,130,0.1);
  color: var(--text-secondary);
  border: 1px solid rgba(110,110,130,0.12);
}

.badge-overdue {
  background: rgba(239,68,68,0.1);
  color: var(--danger);
  border: 1px solid rgba(239,68,68,0.15);
}

/* ============ TABS ============ */
.tabs {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--border);
  margin-bottom: 1.5rem;
}

.tab {
  padding: 0.7rem 1.15rem;
  font-size: 0.86rem;
  color: var(--text-secondary);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: all var(--transition-fast);
  background: none;
  border-top: none;
  border-left: none;
  border-right: none;
  font-family: var(--font-display);
  font-weight: 500;
  letter-spacing: 0;
}

.tab:hover { color: var(--text-primary); }

.tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
  font-weight: 600;
}

/* ============ ALERT ============ */
.alert {
  padding: 0.85rem 1.15rem;
  border-radius: var(--radius-sm);
  font-size: 0.86rem;
  margin-bottom: 1rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.alert-error {
  background: rgba(239,68,68,0.08);
  color: var(--danger);
  border: 1px solid rgba(239,68,68,0.12);
}

.alert-success {
  background: rgba(34,197,94,0.08);
  color: var(--success);
  border: 1px solid rgba(34,197,94,0.12);
}

.alert-warning {
  background: rgba(245,158,11,0.08);
  color: var(--warning);
  border: 1px solid rgba(245,158,11,0.12);
}

/* ============ ATHLETE SELECT ============ */
.athlete-select-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.15rem 1.25rem;
  cursor: pointer;
  transition: all var(--transition);
  display: flex;
  align-items: center;
  gap: 0.9rem;
  box-shadow: 0 1px 4px rgba(0,0,0,0.1);
}

.athlete-select-card:hover {
  border-color: var(--accent);
  background: var(--accent-dim);
  box-shadow: var(--card-shadow);
  transform: translateY(-2px);
}

.athlete-avatar {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--accent-dim), rgba(170,170,170,0.04));
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--accent);
  font-weight: 700;
  font-size: 1rem;
  flex-shrink: 0;
  font-family: var(--font-display);
}

.athlete-select-info h4 {
  font-size: 0.92rem;
  font-weight: 600;
  font-family: var(--font-display);
}

.athlete-select-info p {
  font-size: 0.78rem;
  color: var(--text-secondary);
  margin-top: 0.1rem;
}

/* ============ EMPTY STATE ============ */
.empty-state {
  text-align: center;
  padding: 3.5rem 2rem;
  color: var(--text-secondary);
}

.empty-state svg { width: 48px; height: 48px; margin-bottom: 1rem; opacity: 0.2; }
.empty-state p { font-size: 0.92rem; }

/* ============ SCROLLBAR ============ */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 10px; }
::-webkit-scrollbar-thumb:hover { background: #333; }

/* thin scrollbar for Firefox */
* { scrollbar-width: thin; scrollbar-color: var(--border) transparent; }

/* ============ DELTA INDICATORS ============ */
.delta {
  font-size: 0.76rem;
  font-weight: 600;
  font-family: var(--font-display);
}

.delta-up { color: var(--success); }
.delta-down { color: var(--danger); }
.delta-neutral { color: var(--text-secondary); }

.metric-mini {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
}

.metric-mini .current {
  font-size: 1.5rem;
  font-weight: 700;
  font-family: var(--font-display);
  letter-spacing: -0.02em;
}

/* ============ CALENDAR ============ */
.calendar-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  max-width: 700px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.12);
}

.cal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.15rem;
}

.cal-header h3 {
  font-size: 1.02rem;
  font-weight: 650;
  font-family: var(--font-display);
}

.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
}

.cal-weekday {
  text-align: center;
  font-size: 0.68rem;
  color: var(--text-secondary);
  font-weight: 650;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding-bottom: 0.5rem;
  font-family: var(--font-display);
}

.cal-cell {
  aspect-ratio: 1;
  border-radius: var(--radius-xs);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  font-size: 0.85rem;
  color: var(--text-secondary);
  position: relative;
  background: rgba(255,255,255,0.015);
  border: 1px solid transparent;
  transition: all var(--transition-fast);
}

.cal-empty { background: none; }

.cal-cell:not(.cal-empty):hover {
  background: rgba(255,255,255,0.04);
}

.cal-today {
  border-color: var(--accent);
  color: var(--text-primary);
  font-weight: 600;
  box-shadow: 0 0 0 1px var(--accent-dim);
}

.cal-has-workout {
  background: var(--accent-dim);
  color: var(--text-primary);
}

.cal-day {
  font-size: 0.8rem;
  line-height: 1;
  font-family: var(--font-display);
  font-weight: 500;
}

.cal-dots {
  display: flex;
  gap: 3px;
  flex-wrap: wrap;
  justify-content: center;
  max-width: 100%;
}

.cal-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  flex-shrink: 0;
  cursor: pointer;
  transition: transform var(--transition-fast);
}

.cal-dot:hover { transform: scale(1.4); }

/* ============ TOOLTIP ============ */
.tooltip {
  position: fixed;
  background: #1a1a24;
  color: var(--text-primary);
  padding: 0.42rem 0.72rem;
  border-radius: 8px;
  font-size: 0.76rem;
  font-weight: 500;
  pointer-events: none;
  z-index: 2000;
  white-space: nowrap;
  opacity: 0;
  transition: opacity 0.12s;
  box-shadow: 0 8px 24px rgba(0,0,0,0.5);
  border: 1px solid var(--border);
  font-family: var(--font-display);
}

.tooltip.visible { opacity: 1; }
.tooltip::after { display: none; }

/* ============ WORKOUT ============ */
.workout-badge {
  display: inline-flex;
  align-items: center;
  padding: 0.25rem 0.65rem;
  border-radius: 20px;
  font-size: 0.74rem;
  font-weight: 650;
  letter-spacing: 0.02em;
  font-family: var(--font-display);
}

.workout-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.workout-item {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.8rem 1.1rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  transition: all var(--transition-fast);
}

.workout-item:hover {
  border-color: var(--border-hover, #2a2a38);
  background: rgba(255,255,255,0.01);
}

.workout-item .workout-date {
  font-size: 0.84rem;
  color: var(--text-secondary);
  min-width: 80px;
  font-weight: 500;
  font-family: var(--font-display);
}

.workout-item .workout-notes {
  font-size: 0.82rem;
  color: var(--text-secondary);
  flex: 1;
}

.workout-item .workout-actions { margin-left: auto; display: flex; gap: 0.35rem; }

/* ============ COLOR INPUTS ============ */
.color-input-wrap {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.color-input-wrap input[type="color"] {
  width: 40px;
  height: 34px;
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  background: var(--bg-input);
  cursor: pointer;
  padding: 2px;
}

.color-preview {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  display: inline-block;
  border: 1px solid rgba(255,255,255,0.08);
}

/* ============ RESPONSIVE ============ */

/* Mobile hamburger toggle */
.sidebar-toggle {
  display: none;
  position: fixed;
  top: 1rem;
  left: 1rem;
  z-index: 200;
  width: 42px;
  height: 42px;
  border-radius: var(--radius-sm);
  background: var(--bg-card);
  border: 1px solid var(--border);
  cursor: pointer;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 8px rgba(0,0,0,0.3);
  color: var(--text-primary);
}

.sidebar-toggle svg { width: 20px; height: 20px; }

/* ============ WOD LIVE BAR (sticky timer for athletes) ============ */
.wod-live-bar {
  position: sticky;
  top: 0;
  z-index: 30;
  background: var(--bg-card);
  border: 2px solid var(--accent);
  border-radius: 14px;
  padding: 0.9rem 1.2rem;
  margin-bottom: 1rem;
  box-shadow: 0 4px 16px rgba(0,0,0,0.18);
}
.wlb-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.72rem;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 600;
}
.wlb-main {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  margin-top: 0.35rem;
}
.wlb-label {
  font-family: var(--font-display);
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--accent);
  min-width: 0;
  overflow-wrap: anywhere;
}
.wlb-remaining {
  font-family: var(--font-display);
  font-size: 3.6rem;
  font-weight: 800;
  color: var(--accent);
  line-height: 1;
  flex-shrink: 0;
}
.wlb-next {
  margin-top: 0.55rem;
  padding-top: 0.5rem;
  border-top: 1px solid var(--border);
  font-size: 0.85rem;
  color: var(--text-secondary);
}
.wlb-next strong { color: var(--text-primary); }
@media (max-width: 600px) {
  .wlb-remaining { font-size: 2.8rem; }
  .wlb-label { font-size: 1.3rem; }
}

/* ============ COUNTDOWN OVERLAY ============ */
.countdown-overlay {
  position: fixed;
  inset: 0;
  z-index: 3000;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.8);
  backdrop-filter: blur(6px);
}
.countdown-num {
  font-family: var(--font-display);
  font-size: 9rem;
  font-weight: 800;
  color: #fff;
  line-height: 1;
  animation: countdownPop 0.45s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.countdown-num.go {
  color: var(--accent);
  font-size: 7rem;
  letter-spacing: 0.05em;
}
@keyframes countdownPop {
  0% { transform: scale(0.4); opacity: 0; }
  60% { transform: scale(1.1); opacity: 1; }
  100% { transform: scale(1); opacity: 1; }
}

/* ============ WOD BLOCK BUILDER ============ */
/* Compact WOD + athlete edit forms (scoped so other forms keep their spacing). */
#wod-form .form-group, #ath-form .form-group { margin-bottom: 0.7rem; }
#wod-form .form-group label, #ath-form .form-group label { margin-bottom: 0.25rem; }
#wod-form .form-control, #ath-form .form-control { padding: 0.45rem 0.65rem; }
#wod-form textarea.form-control, #ath-form textarea.form-control { padding: 0.5rem 0.65rem; }
#wod-form .modal-actions, #ath-form .modal-actions { margin-top: 1rem; padding-top: 0.85rem; }
#wod-form #blocks-list { margin-bottom: 0.4rem; }
/* Athlete WOD-assignment checklist: tighter rows. */
#ath-wods-list label { padding: 0.4rem 0.6rem; gap: 0.55rem; font-size: 0.88rem; }
/* Athlete + WOD forms: label beside the box (notes/description stay stacked). */
#ath-form .inline-field, #wod-form .inline-field { display: flex; align-items: center; gap: 1rem; margin-bottom: 0.55rem; }
#ath-form .inline-field label, #wod-form .inline-field label { flex: 0 0 7.5rem; margin-bottom: 0; }
#ath-form .inline-field .form-control, #wod-form .inline-field .form-control { flex: 1; min-width: 0; }

.wod-block-row {
  display: flex;
  gap: 0.35rem;
  align-items: center;
  padding: 0.3rem 0.4rem;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: var(--bg-input);
  margin-bottom: 0.3rem;
}
.wod-block-row .block-actions .btn-sm { padding: 0.15rem 0.4rem; line-height: 1; }
.wod-block-row .block-num { color: var(--text-secondary); font-size: 0.8rem; width: 1.5rem; text-align: center; flex-shrink: 0; }
.wod-block-row .block-rest-label { flex: 2; color: var(--text-secondary); }
.wod-block-row .block-ex { flex: 2; min-width: 0; }
.wod-block-row .block-mode { width: 110px; flex-shrink: 0; }
.wod-block-row .block-value { width: 80px; flex-shrink: 0; }
.wod-block-row .block-spacer { width: 80px; flex-shrink: 0; }
.wod-block-row select.form-control, .wod-block-row input.form-control { font-size: 0.85rem; padding: 0.35rem 0.5rem; }
.wod-block-row .block-actions { display: flex; gap: 0.4rem; flex-shrink: 0; }

@media (max-width: 900px) {
  .sidebar {
    transform: translateX(-100%);
    transition: transform var(--transition);
    width: 260px;
    box-shadow: 8px 0 32px rgba(0,0,0,0.5);
  }

  .sidebar.open { transform: translateX(0); }

  body.app-active .sidebar-toggle { display: flex; }
  .sidebar-logo { width: 96px; height: 60px; }

  .main-content {
    margin-left: 0;
    padding: 1.1rem;
    padding-top: 4.25rem;
  }

  .page-header { flex-wrap: wrap; gap: 0.6rem; margin-bottom: 1.25rem; }
  .page-header h1 { font-size: 1.3rem; }

  .form-row, .form-row-3 { grid-template-columns: 1fr; }
  .charts-grid { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: 1fr 1fr; }

  .modal {
    padding: 0;
    border-radius: 0;
    max-width: 100%;
  }
  .modal-overlay { padding: 1.25rem 1rem 3rem; }
}

/* Phones: shrink the rem base so everything scales down proportionally,
   then fix the few oversized inline elements (WOD timers) and tighten layout. */
@media (max-width: 600px) {
  html { font-size: 14.5px; }

  /* Never let the page scroll sideways; keep all content within the screen.
     Use `clip` (not `hidden`) so it doesn't create a scroll container that
     would break position: sticky on the WOD live bar. */
  html, body { overflow-x: clip; }
  .main-content { padding: 0.9rem; padding-top: 4rem; overflow-x: clip; max-width: 100%; }
  #app, #page-content { max-width: 100%; overflow-x: clip; }
  .stats-grid, .stat-card { min-width: 0; }
  .stat-card .value, .stat-card .label { overflow-wrap: anywhere; }
  .card > table { max-width: 100%; }
  .page-header h1 { font-size: 1.2rem; }
  .card { padding: 1rem; border-radius: 12px; }

  .login-box { padding: 1.75rem; border-radius: 16px; }
  .login-logo { width: 100px; margin-bottom: 1.5rem; }

  .stats-grid { grid-template-columns: 1fr 1fr; gap: 0.6rem; }
  .stat-card { padding: 1rem; }
  .stat-card .value { font-size: 1.5rem; }

  /* horizontal-scroll tabs instead of wrapping/overflowing */
  .tabs { overflow-x: auto; -webkit-overflow-scrolling: touch; flex-wrap: nowrap; }
  .tab { white-space: nowrap; flex: 0 0 auto; }

  /* Tables wrap to fit the screen instead of scrolling sideways */
  table { width: 100%; }
  th, td { padding: 0.5rem 0.45rem; font-size: 0.8rem; overflow-wrap: anywhere; }
  th { font-size: 0.6rem; }
  th:last-child, td:last-child { white-space: nowrap; }  /* keep action buttons on one line */
  td .btn-sm { padding: 0.3rem 0.4rem; }

  /* WOD library: drop format + time-cap columns, let the name wrap so it fits the screen */
  .table-wods { display: table; width: 100%; }
  .table-wods th:nth-child(2), .table-wods td:nth-child(2),
  .table-wods th:nth-child(3), .table-wods td:nth-child(3) { display: none; }
  .table-wods td:first-child { white-space: normal; }

  /* WOD block builder: stack so the dropdowns fit — exercise on its own row,
     then mode + value + reorder buttons underneath */
  .wod-block-row { flex-wrap: wrap; }
  .wod-block-row .block-num { order: 0; }
  .wod-block-row .block-ex, .wod-block-row .block-rest-label { flex: 1 1 calc(100% - 2.2rem); order: 1; }
  .wod-block-row .block-mode { order: 2; flex: 1 1 auto; width: auto; }
  .wod-block-row .block-value { order: 3; flex: 0 0 4.5rem; width: auto; }
  .wod-block-row .block-spacer { display: none; }
  .wod-block-row .block-actions { order: 4; margin-left: auto; }

  .btn { padding: 0.5rem 0.85rem; font-size: 0.85rem; }
  .btn-sm { padding: 0.35rem 0.55rem; }

  /* WOD live: stack the current-block panel, shrink the giant countdown */
  #current-block-panel, #my-current-block-panel {
    flex-direction: column; align-items: stretch !important;
    gap: 0.6rem; padding: 1rem !important; text-align: center;
  }
  #cb-remaining, #my-cb-remaining {
    font-size: 2.6rem !important; min-width: 0 !important; text-align: center !important;
  }
  #cb-label, #my-cb-label { font-size: 1.35rem !important; }
  #group-timer { font-size: 2.1rem !important; min-width: 0 !important; }
  .athlete-timer { font-size: 1.3rem !important; }
}

@media (max-width: 400px) {
  html { font-size: 13.5px; }
  .stats-grid { grid-template-columns: 1fr; }
  .page-header h1 { font-size: 1.1rem; }
}

/* ============ HR ============ */
hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 1rem 0;
}

/* ============ LINKS ============ */
a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); }

/* ============ FOCUS VISIBLE ============ */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

button:focus:not(:focus-visible),
input:focus:not(:focus-visible),
select:focus:not(:focus-visible),
textarea:focus:not(:focus-visible) {
  outline: none;
}
