*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --court-green: #2D6A4F;
  --court-green-light: #40916C;
  --accent: #F4A261;
  --accent-dark: #E76F51;
  --bg: #0B1420;
  --sidebar-bg: #0F1B2A;
  --surface: #16273A;
  --surface2: #1F3145;
  --border: #26394E;
  --text: #E8F0EC;
  --text-muted: #8CA3B5;
  --success: #52B788;
  --danger: #E76F51;
  --warning: #F4A261;
  --radius-lg: 16px;
  --radius-md: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgba(0,0,0,.2), 0 8px 24px rgba(0,0,0,.25);
  --input-color-scheme: dark;
  --sidebar-w: 240px;
}

:root[data-theme="light"] {
  --court-green: #2D6A4F;
  --court-green-light: #40916C;
  --accent: #B5651D;
  --accent-dark: #9C3D22;
  --bg: #F2F5F3;
  --sidebar-bg: #FFFFFF;
  --surface: #FFFFFF;
  --surface2: #F0F3F1;
  --border: #E1E8E3;
  --text: #16241D;
  --text-muted: #5C7268;
  --success: #1E7A4C;
  --danger: #C1502E;
  --warning: #B5651D;
  --shadow: 0 1px 2px rgba(20,40,30,.04), 0 8px 20px rgba(20,40,30,.06);
  --input-color-scheme: light;
}

html, body { height: 100%; }

body {
  font-family: "Inter", -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; }
h1, h2, h3 { font-weight: 700; letter-spacing: -0.01em; }
button { font-family: inherit; }

/* ===== LAYOUT SHELL ===== */
.sidebar {
  position: fixed;
  top: 0; left: 0; bottom: 0;
  width: var(--sidebar-w);
  background: var(--sidebar-bg);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 1.1rem 0.9rem;
  z-index: 50;
  overflow-y: auto;
  transition: transform 0.2s ease;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  text-decoration: none;
  color: var(--text);
  padding: 0.4rem 0.6rem 1.2rem;
  font-weight: 800;
  font-size: 1.05rem;
}
.sidebar-brand-icon { font-size: 1.5rem; }

.sidebar-nav { display: flex; flex-direction: column; gap: 0.2rem; }

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  padding: 0.6rem 0.7rem;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
  list-style: none;
}
.sidebar-link svg { flex-shrink: 0; }
.sidebar-link:hover { background: var(--surface2); color: var(--text); }
.sidebar-link.active { background: var(--court-green); color: #fff; }

.sidebar-group { margin-top: 0.1rem; }
.sidebar-group summary { list-style: none; }
.sidebar-group summary::-webkit-details-marker { display: none; }
.sidebar-group-toggle { justify-content: flex-start; }
.sidebar-group-toggle span:first-of-type { flex: 1; }
.sidebar-group-chevron { transition: transform 0.15s ease; flex-shrink: 0; }
.sidebar-group[open] .sidebar-group-chevron { transform: rotate(90deg); }

.sidebar-subnav {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  padding: 0.2rem 0 0.3rem 2.35rem;
}
.sidebar-sublink {
  padding: 0.45rem 0.6rem;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.82rem;
  font-weight: 600;
  transition: background 0.15s ease, color 0.15s ease;
}
.sidebar-sublink:hover { background: var(--surface2); color: var(--text); }
.sidebar-sublink.active { background: var(--surface2); color: var(--accent); }

.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.5);
  z-index: 45;
}
.sidebar-backdrop.visible { display: block; }

.app-main {
  margin-left: var(--sidebar-w);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 0.9rem;
  padding: 0.9rem 1.75rem;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}
.sidebar-toggle {
  display: none;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  color: var(--text);
  padding: 0.3rem;
  cursor: pointer;
}
.topbar-title {
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}
.topbar-spacer { flex: 1; }

.theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  padding: 0;
  border-radius: 50%;
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text-muted);
  cursor: pointer;
  flex-shrink: 0;
  transition: border-color 0.15s ease, color 0.15s ease;
}
.theme-toggle:hover { border-color: var(--accent); color: var(--text); }
.theme-icon-sun { display: none; }
.theme-icon-moon { display: block; }
:root[data-theme="light"] .theme-icon-sun { display: block; }
:root[data-theme="light"] .theme-icon-moon { display: none; }

.topbar-user { font-size: 0.82rem; font-weight: 600; color: var(--text-muted); white-space: nowrap; }
.logout-btn {
  display: inline-flex; align-items: center; gap: 0.4rem;
  background: var(--surface2); border: 1px solid var(--border); color: var(--text);
  font-size: 0.82rem; font-weight: 600; padding: 0.5rem 0.9rem; border-radius: var(--radius-sm);
  cursor: pointer; flex-shrink: 0; transition: border-color 0.15s ease, color 0.15s ease;
}
.logout-btn:hover { border-color: var(--danger); color: var(--danger); }

.no-sidebar .app-main { margin-left: 0; }

.page-content {
  padding: 1.75rem 2rem;
  width: 100%;
}

@media (max-width: 960px) {
  .sidebar { transform: translateX(-100%); box-shadow: var(--shadow); }
  .sidebar.open { transform: translateX(0); }
  .app-main { margin-left: 0; }
  .sidebar-toggle { display: flex; }
  .topbar { padding: 0.8rem 1.1rem; }
  .page-content { padding: 1.1rem; }
}

@media (max-width: 560px) {
  .topbar-user { display: none; }
}

/* ===== LOGIN PAGE ===== */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  padding: 1.5rem;
}
.login-wrap {
  width: 100%;
  max-width: 380px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.25rem;
}
.login-brand {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-size: 1.3rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--text);
}
.login-card { width: 100%; }
.login-card form { display: flex; flex-direction: column; gap: 1rem; }
.login-card button[type="submit"] { width: 100%; justify-content: center; margin-top: 0.25rem; }

.login-notice {
  width: 100%;
  background: rgba(244, 162, 97, 0.14);
  border: 1px solid var(--accent);
  color: var(--accent);
  border-radius: var(--radius-sm);
  padding: 0.75rem 1rem;
  font-size: 0.82rem;
  font-weight: 500;
  line-height: 1.5;
  text-align: center;
}
.login-notice a { color: inherit; font-weight: 700; text-decoration: underline; }

/* ===== FLASH ===== */
.flash-banner {
  background: rgba(82, 183, 136, 0.12);
  border: 1px solid var(--success);
  color: var(--success);
  border-radius: var(--radius-sm);
  padding: 0.7rem 1rem;
  margin-bottom: 1.1rem;
  font-size: 0.88rem;
  font-weight: 600;
}
.flash-banner p { margin: 0; }
.flash-banner p + p { margin-top: 0.2rem; }

/* ===== PAGE HEADER (inline, inside content, no hero) ===== */
.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 1.25rem;
}
.page-header h2 { font-size: 1.35rem; font-weight: 800; letter-spacing: -0.01em; }
.page-header .muted { color: var(--text-muted); font-size: 0.88rem; margin-top: 0.15rem; }
.back-link {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  text-decoration: none;
  font-size: 0.83rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 0.7rem;
  transition: gap 0.15s ease, color 0.15s ease;
}
.back-link:hover { gap: 0.55rem; color: var(--text); }

/* ===== CARDS / PANELS ===== */
.card, .panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.25rem 1.4rem;
  margin-bottom: 1.1rem;
  box-shadow: var(--shadow);
}
.card-heading { font-size: 1rem; font-weight: 700; margin-bottom: 0.9rem; }

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem;
}

/* ===== STAT TILES (dashboard) ===== */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
  margin-bottom: 1.25rem;
}
.stat-tile {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.1rem 1.25rem;
  box-shadow: var(--shadow);
}
.stat-tile-label {
  font-size: 0.76rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 0.4rem;
}
.stat-tile-icon {
  width: 26px; height: 26px;
  border-radius: 7px;
  display: inline-flex; align-items: center; justify-content: center;
  background: rgba(45, 106, 79, 0.15);
  color: var(--court-green-light);
  flex-shrink: 0;
}
.stat-tile-value {
  font-size: 1.9rem;
  font-weight: 800;
  margin-top: 0.4rem;
  letter-spacing: -0.02em;
}
.stat-tile-sub { font-size: 0.8rem; color: var(--text-muted); margin-top: 0.15rem; }

.progress-track {
  display: block;
  height: 8px;
  background: var(--surface2);
  border-radius: 999px;
  overflow: hidden;
  margin-top: 0.6rem;
}
.progress-fill {
  display: block;
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--court-green), var(--court-green-light));
  transition: width 0.3s ease;
}

/* ===== BUTTONS ===== */
button, .btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  background: var(--court-green);
  color: #fff;
  border: none;
  padding: 0.62rem 1.1rem;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: filter 0.15s ease, transform 0.1s ease;
}
button:hover { filter: brightness(1.1); }
button:active { transform: scale(0.98); }
button:disabled { opacity: 0.5; cursor: not-allowed; filter: none; }

.btn-secondary {
  background: var(--surface2);
  color: var(--text);
  border: 1px solid var(--border);
}
.btn-secondary:hover { border-color: var(--accent); filter: none; }

/* ===== FORMS ===== */
.field { display: flex; flex-direction: column; gap: 0.35rem; margin-bottom: 1rem; }
.field:last-child { margin-bottom: 0; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; margin-bottom: 1rem; }
.field-row-3 { grid-template-columns: repeat(3, 1fr); }
.field-row .field, .field-row-3 .field { margin-bottom: 0; }
.field-label {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.field-label-sub {
  display: block;
  font-size: 0.7rem;
  font-weight: 500;
  text-transform: none;
  letter-spacing: 0;
  color: var(--text-muted);
  margin-top: 0.1rem;
}
.field-hint { font-size: 0.78rem; color: var(--text-muted); }

input[type="text"], input[type="password"], input[type="date"], input[type="month"], input[type="number"], select, textarea {
  padding: 0.6rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.92rem;
  font-family: inherit;
  background: var(--surface2);
  color: var(--text);
  transition: border-color 0.15s ease;
  color-scheme: var(--input-color-scheme);
  width: 100%;
}
textarea { resize: vertical; min-height: 4.5rem; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); }
input::placeholder, textarea::placeholder { color: var(--text-muted); }

/* Force DD/MM/YYYY display on native date/month inputs regardless of browser
   locale: an opaque overlay covers the browser's own (often US-formatted)
   text while leaving its calendar icon visible and clickable underneath. */
.date-field { position: relative; }
.date-field input[type="date"], .date-field input[type="month"] { position: relative; }
.date-field-display {
  position: absolute;
  left: 1px; top: 1px; bottom: 1px; right: 38px;
  display: flex;
  align-items: center;
  padding-left: 0.75rem;
  background: var(--surface2);
  border-radius: calc(var(--radius-sm) - 1px) 0 0 calc(var(--radius-sm) - 1px);
  pointer-events: none;
  font-size: 0.92rem;
  color: var(--text);
  overflow: hidden;
  white-space: nowrap;
}
.date-field-display.placeholder { color: var(--text-muted); }

select {
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%238CA3B5' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.7rem center;
  background-size: 16px;
  padding-right: 2.2rem;
  cursor: pointer;
}

input[type="file"] { font-size: 0.85rem; color: var(--text-muted); width: 100%; }
input[type="file"]::file-selector-button {
  background: var(--surface2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.45rem 0.85rem;
  margin-right: 0.7rem;
  font-family: inherit;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
}

.form-narrow { max-width: 480px; }

/* Checkbox list (batches, programs) */
.checkbox-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 0.5rem; margin-bottom: 1rem; }
.checkbox-list-item {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.55rem 0.7rem;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 0.88rem;
  transition: border-color 0.15s ease, background 0.15s ease;
}
.checkbox-list-item:hover { border-color: var(--court-green-light); }
.checkbox-list-item input[type="checkbox"] {
  appearance: none; -webkit-appearance: none;
  width: 18px; height: 18px; border-radius: 5px;
  border: 2px solid var(--text-muted);
  background: var(--surface);
  position: relative; cursor: pointer; flex-shrink: 0;
  transition: background 0.15s ease, border-color 0.15s ease;
}
.checkbox-list-item input[type="checkbox"]:checked { background: var(--court-green); border-color: var(--court-green-light); }
.checkbox-list-item input[type="checkbox"]:checked::after {
  content: ""; position: absolute; left: 4px; top: 0px;
  width: 5px; height: 9px; border: solid #fff; border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}
.checkbox-list-item:has(input:checked) { border-color: var(--court-green-light); background: rgba(45, 106, 79, 0.15); }

/* Toggle pill group (strokes cascading selector, attendance status) */
.toggle-group { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.toggle-btn {
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text-muted);
  padding: 0.5rem 0.95rem;
  border-radius: var(--radius-sm);
  font-size: 0.84rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.15s ease;
}
.toggle-btn:hover { border-color: var(--accent); color: var(--text); }
.toggle-btn.active { background: var(--court-green); border-color: var(--court-green-light); color: #fff; }

.toggle-pill {
  position: relative;
  cursor: pointer;
  padding: 0.4rem 0.85rem;
  border-radius: 20px;
  border: 1px solid var(--border);
  background: var(--surface2);
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-muted);
  transition: all 0.15s ease;
}
.toggle-pill input { position: absolute; opacity: 0; pointer-events: none; }
.toggle-pill:hover { border-color: var(--accent); }
.toggle-pill.present:has(input:checked) { background: rgba(82, 183, 136, 0.18); border-color: var(--success); color: var(--success); }
.toggle-pill.absent:has(input:checked) { background: rgba(231, 111, 81, 0.18); border-color: var(--danger); color: var(--danger); }
.toggle-pill.no_class:has(input:checked) { background: var(--surface2); border-color: var(--text-muted); color: var(--text); }
.toggle-pill.role-option:has(input:checked) { background: var(--court-green); border-color: var(--court-green-light); color: #fff; }

/* ===== STATUS PILLS ===== */
.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.2rem 0.6rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 700;
}
.status-pill.up, .status-pill.success { background: rgba(82, 183, 136, 0.15); color: var(--success); }
.status-pill.down, .status-pill.danger { background: rgba(231, 111, 81, 0.15); color: var(--danger); }
.status-pill.flat, .status-pill.neutral { background: var(--surface2); color: var(--text-muted); }

/* ===== AVATAR ===== */
.avatar {
  flex-shrink: 0;
  width: 38px; height: 38px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, var(--court-green), var(--accent-dark));
  color: #fff;
  font-weight: 700;
  font-size: 0.95rem;
}
.avatar-photo { object-fit: cover; }
.avatar-lg { width: 72px; height: 72px; font-size: 1.7rem; border: 3px solid var(--court-green-light); }

/* ===== DATA TABLE ===== */
.table-wrap { overflow-x: auto; border-radius: var(--radius-lg); border: 1px solid var(--border); }
.data-table { width: 100%; border-collapse: collapse; background: var(--surface); min-width: 560px; }
.data-table th {
  text-align: left;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  padding: 0.85rem 1rem;
  border-bottom: 1px solid var(--border);
  background: var(--surface2);
  white-space: nowrap;
}
.data-table td {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border);
  font-size: 0.88rem;
  vertical-align: middle;
}
.data-table tr:last-child td { border-bottom: none; }
.data-table tbody tr { transition: background 0.15s ease; }
.data-table tbody tr:hover { background: var(--surface2); }
.data-table-link { text-decoration: none; color: inherit; display: flex; align-items: center; gap: 0.65rem; }
.data-table-name { font-weight: 700; }
.data-table-sub { font-size: 0.78rem; color: var(--text-muted); }
.data-table .actions-cell { text-align: right; white-space: nowrap; }

/* Stack tables into cards on narrow screens - never scroll sideways */
@media (max-width: 700px) {
  .table-wrap { overflow-x: visible; border: none; border-radius: 0; }
  .data-table { min-width: 0; }
  .data-table thead { display: none; }
  .data-table, .data-table tbody, .data-table tr, .data-table td { display: block; width: 100%; }
  .data-table tr {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 0.7rem 0.9rem;
    margin-bottom: 0.7rem;
  }
  .data-table tr:last-child { margin-bottom: 0; }
  .data-table td {
    border-bottom: none;
    padding: 0.4rem 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
  }
  .data-table td[data-label]::before {
    content: attr(data-label);
    font-size: 0.68rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-muted);
    flex-shrink: 0;
  }
  .data-table td:first-child { padding-top: 0; }
  .data-table td:first-child::before { display: none; }
  .data-table td:first-child { justify-content: flex-start; }
  .data-table .actions-cell { justify-content: flex-end; padding-top: 0.5rem; }
  .data-table .actions-cell::before { display: none; }
  .data-table td.status-cell { flex-direction: column; align-items: flex-start; gap: 0.35rem; }
}

/* ===== BATCH CHIP / PROGRAM LIST (reused patterns) ===== */
.batch-chips { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.batch-chip {
  background: var(--surface2);
  border: 1px solid var(--court-green-light);
  color: var(--success);
  font-size: 0.76rem;
  font-weight: 600;
  padding: 0.18rem 0.6rem;
  border-radius: 999px;
}

.program-list { list-style: none; }
.program-row {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding: 0.75rem 0; border-top: 1px solid var(--border);
}
.program-row:first-child { border-top: none; }
.program-info { display: flex; flex-direction: column; gap: 0.15rem; }
.program-name { font-weight: 700; font-size: 0.92rem; }
.program-category {
  font-size: 0.74rem; font-weight: 600; color: var(--accent);
  text-transform: uppercase; letter-spacing: 0.04em;
}

/* ===== PROGRAM CHECKLIST ===== */
.program-checklist { list-style: none; display: flex; flex-direction: column; gap: 0.6rem; margin-bottom: 1rem; }
.program-checklist-item {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 0.85rem 1rem;
  background: var(--surface);
  transition: border-color 0.15s ease, background 0.15s ease;
}
.program-checklist-item:has(input:checked) { border-color: var(--court-green-light); background: rgba(45, 106, 79, 0.12); }
.program-checklist-label { display: flex; align-items: center; gap: 0.75rem; cursor: pointer; }
.program-checklist-label input[type="checkbox"] {
  appearance: none; -webkit-appearance: none; flex-shrink: 0;
  width: 22px; height: 22px; border-radius: 6px;
  border: 2px solid var(--text-muted);
  background: var(--surface2);
  position: relative; cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
}
.program-checklist-label input[type="checkbox"]:checked { background: var(--court-green); border-color: var(--court-green-light); }
.program-checklist-label input[type="checkbox"]:checked::after {
  content: ""; position: absolute; left: 6px; top: 2px;
  width: 6px; height: 11px; border: solid #fff; border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}
.program-checklist-info { display: flex; flex-direction: column; gap: 0.15rem; }
.program-checklist-item .fitness-history { margin-top: 0.7rem; }

/* ===== DELETE BUTTON ===== */
.delete-btn {
  background: var(--surface2);
  color: var(--text-muted);
  border: 1px solid var(--border);
  width: 30px; height: 30px;
  padding: 0;
  border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  line-height: 0;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}
.delete-btn:hover { background: rgba(231, 111, 81, 0.15); color: var(--danger); border-color: var(--danger); filter: none; }
.delete-text-btn {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 0.8rem;
  padding: 0.4rem 0.9rem;
}
.delete-text-btn:hover { border-color: var(--danger); color: var(--danger); background: rgba(231, 111, 81, 0.1); filter: none; }

/* ===== INFO TOOLTIP (fitness component descriptions) ===== */
.info-tooltip { position: relative; display: inline-flex; }
.info-tooltip-btn {
  width: 18px; height: 18px;
  border-radius: 50%;
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text-muted);
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 0.68rem; font-weight: 700;
  padding: 0; cursor: help;
}
.info-tooltip-text {
  display: none;
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  width: 240px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.6rem 0.75rem;
  font-size: 0.76rem;
  font-weight: 400;
  color: var(--text);
  line-height: 1.4;
  box-shadow: var(--shadow);
  z-index: 20;
}
.info-tooltip:hover .info-tooltip-text, .info-tooltip:focus-within .info-tooltip-text { display: block; }

/* ===== EMPTY STATE ===== */
.empty-state { text-align: center; padding: 2.75rem 1.5rem; color: var(--text-muted); }
.empty-icon { font-size: 2.2rem; margin-bottom: 0.6rem; }
.inline-link { color: var(--accent); font-weight: 600; text-decoration: none; }
.inline-link:hover { text-decoration: underline; }

/* ===== FITNESS ===== */
.fitness-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 1rem; }
.fitness-card { display: flex; flex-direction: column; gap: 0.6rem; }
.fitness-card-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 0.75rem; }
.fitness-card-title { font-size: 1.02rem; font-weight: 700; display: flex; align-items: center; gap: 0.35rem; }
.fitness-card-test { display: block; font-size: 0.74rem; color: var(--text-muted); margin-top: 0.1rem; }
.fitness-latest { text-align: right; flex-shrink: 0; }
.fitness-latest-value { display: block; font-size: 1.5rem; font-weight: 800; color: var(--accent); line-height: 1; }
.fitness-latest-unit { font-size: 0.75rem; font-weight: 600; color: var(--text-muted); margin-left: 0.2rem; }
.fitness-latest-empty { font-size: 0.78rem; color: var(--text-muted); font-style: italic; }
.fitness-history summary {
  list-style: none; cursor: pointer; display: flex; align-items: center; gap: 0.4rem;
  font-size: 0.76rem; font-weight: 600; color: var(--text-muted); padding: 0.3rem 0;
}
.fitness-history summary::-webkit-details-marker { display: none; }
.chevron-icon { transition: transform 0.15s ease; }
.fitness-history[open] summary .chevron-icon { transform: rotate(90deg); color: var(--accent); }
.fitness-history-table { width: 100%; border-collapse: collapse; margin-top: 0.4rem; font-size: 0.8rem; }
.fitness-history-table td { padding: 0.35rem 0.2rem; border-top: 1px solid var(--border); }
.fitness-history-date { color: var(--text-muted); }
.fitness-history-value { font-weight: 600; text-align: right; }
.fitness-history-delete { width: 30px; text-align: right; }
.fitness-history-delete .delete-btn { width: 22px; height: 22px; opacity: 0.5; }
.fitness-history-delete .delete-btn:hover { opacity: 1; }
.fitness-input-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 1rem; margin-bottom: 1rem; }

/* ===== PROFILE ===== */
.profile-header-card { display: flex; align-items: flex-start; gap: 1.5rem; flex-wrap: wrap; }
.profile-info { flex: 1; min-width: 220px; }
.profile-facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 0.9rem; }
.profile-fact dt { font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-muted); margin-bottom: 0.2rem; }
.profile-fact dd { font-size: 0.92rem; font-weight: 600; }
.profile-fact-wide { grid-column: 1 / -1; }
.edit-profile-btn {
  display: inline-flex; align-items: center; gap: 0.4rem;
  background: var(--surface2); border: 1px solid var(--border); color: var(--text);
  font-size: 0.82rem; font-weight: 600; padding: 0.5rem 0.9rem; border-radius: var(--radius-sm);
  text-decoration: none; flex-shrink: 0; transition: border-color 0.15s ease;
}
.edit-profile-btn:hover { border-color: var(--accent); }
.profile-photo { flex-shrink: 0; width: 88px; height: 88px; border-radius: 50%; object-fit: cover; border: 3px solid var(--court-green-light); }
.profile-photo-placeholder {
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, var(--court-green), var(--accent-dark));
  font-size: 2rem; font-weight: 700; color: #fff;
}
.link-card-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 1rem; margin-bottom: 1.1rem; }
.link-card {
  display: flex; flex-direction: column; gap: 0.3rem;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
  padding: 1.1rem 1.25rem; text-decoration: none; color: var(--text);
  transition: border-color 0.15s ease, transform 0.15s ease; box-shadow: var(--shadow);
}
.link-card:hover { border-color: var(--accent); transform: translateY(-2px); }
.link-card-static { cursor: default; }
.link-card-static:hover { border-color: var(--border); transform: none; }
.link-card-title { font-weight: 700; font-size: 0.95rem; }
.link-card-desc { font-size: 0.8rem; color: var(--text-muted); }
.profile-delete-form { text-align: right; }

/* ===== PERFORMANCE OVERVIEW ===== */
.perf-section-title {
  font-size: 1.05rem; font-weight: 800; margin: 1.6rem 0 0.8rem;
  display: flex; align-items: center; gap: 0.5rem;
}
.perf-section-title:first-of-type { margin-top: 0; }
.perf-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 1rem; }

/* Circular progress rings */
.ring-row { display: flex; gap: 1.75rem; flex-wrap: wrap; justify-content: flex-start; align-items: flex-start; }
.ring-stat { display: flex; flex-direction: column; align-items: center; gap: 0.5rem; text-align: center; width: 122px; }
.ring-wrap { position: relative; width: 112px; height: 112px; }
.ring-wrap svg { transform: rotate(-90deg); }
.ring-track { stroke: var(--surface2); }
.ring-value-circle { stroke-linecap: round; transition: stroke-dashoffset 0.4s ease; }
.ring-center {
  position: absolute; inset: 0; display: flex; flex-direction: column;
  align-items: center; justify-content: center;
}
.ring-number { font-size: 1.35rem; font-weight: 800; letter-spacing: -0.02em; }
.ring-label { font-size: 0.82rem; font-weight: 700; }
.ring-sub { font-size: 0.72rem; color: var(--text-muted); }

/* Chips for strengths / weaknesses */
.chip-row { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-bottom: 0.9rem; }
.chip {
  display: inline-flex; align-items: center; gap: 0.3rem;
  font-size: 0.76rem; font-weight: 700; padding: 0.32rem 0.7rem; border-radius: 999px;
}
.chip.strength { background: rgba(45, 106, 79, 0.18); color: var(--court-green-light); }
.chip.weakness { background: rgba(231, 111, 81, 0.15); color: var(--danger); }

/* Horizontal bar list (fitness components, shot-type breakdown) */
.bar-list { display: flex; flex-direction: column; gap: 0.65rem; }
.bar-row-item { display: flex; align-items: center; gap: 0.75rem; }
.bar-row-label { flex: 0 0 40%; min-width: 0; font-size: 0.82rem; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-row-label-sub { display: block; font-size: 0.7rem; font-weight: 500; color: var(--text-muted); }
.bar-row-track { flex: 1; height: 10px; background: var(--surface2); border-radius: 999px; overflow: hidden; }
.bar-row-fill { display: block; height: 100%; border-radius: 999px; background: linear-gradient(90deg, var(--court-green), var(--court-green-light)); transition: width 0.3s ease; }
.bar-row-fill.weak { background: linear-gradient(90deg, var(--accent-dark), var(--accent)); }
.bar-row-value { flex: 0 0 48px; text-align: right; font-size: 0.8rem; font-weight: 700; color: var(--text-muted); }

/* Sparkline (strokes accuracy trend) */
.sparkline-wrap { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; }
.sparkline { width: 100%; max-width: 260px; height: 56px; flex-shrink: 0; }
.sparkline-stat { display: flex; flex-direction: column; }
.sparkline-stat .stat-tile-value { font-size: 1.7rem; margin-top: 0; }

/* Fee history dot strip */
.dot-strip { display: flex; gap: 0.7rem; }
.dot-item { display: flex; flex-direction: column; align-items: center; gap: 0.3rem; }
.dot { width: 16px; height: 16px; border-radius: 5px; background: var(--surface2); border: 1px solid var(--border); }
.dot.paid { background: var(--court-green); border-color: var(--court-green-light); }
.dot.unpaid { background: rgba(231, 111, 81, 0.25); border-color: var(--danger); }
.dot-item-label { font-size: 0.68rem; color: var(--text-muted); font-weight: 600; }

/* Squad snapshot (dashboard) */
.squad-split { display: flex; height: 12px; border-radius: 999px; overflow: hidden; margin-top: 0.6rem; background: var(--surface2); }
.squad-split-professional { background: linear-gradient(90deg, var(--court-green), var(--court-green-light)); }
.squad-split-regular { background: var(--accent); }
.squad-split-legend { display: flex; gap: 1.1rem; margin-top: 0.55rem; font-size: 0.78rem; color: var(--text-muted); }
.squad-split-legend span { display: inline-flex; align-items: center; gap: 0.35rem; }
.legend-dot { width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0; }
.legend-dot.professional { background: var(--court-green-light); }
.legend-dot.regular { background: var(--accent); }

/* Coach's Notes */
.note-form { margin-bottom: 1rem; }
.note-form button { margin-top: 0.7rem; }
.note-list { list-style: none; display: flex; flex-direction: column; gap: 0.6rem; }
.note-item {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 0.75rem;
  padding: 0.75rem 0.9rem; border-radius: var(--radius-md);
  background: var(--surface2); border: 1px solid var(--border);
}
.note-item-body { min-width: 0; }
.note-item-text { font-size: 0.86rem; line-height: 1.45; white-space: pre-wrap; word-break: break-word; }
.note-item-date { display: block; font-size: 0.72rem; color: var(--text-muted); margin-top: 0.3rem; }
.note-item .delete-btn { flex-shrink: 0; }

/* Mini trend sparkline attached to a bar row (own-history only) */
.bar-row-trend { flex-shrink: 0; width: 60px; height: 22px; }

@media (max-width: 700px) {
  .ring-row { justify-content: center; }
  .bar-row-label { flex-basis: 34%; }
  .bar-row-trend { display: none; }
}

/* ===== PHOTO UPLOAD ===== */
.form-photo-row { display: flex; align-items: center; gap: 1.1rem; margin-bottom: 1rem; }
.photo-preview {
  flex-shrink: 0; width: 68px; height: 68px; border-radius: 50%;
  background: var(--surface2); border: 2px dashed var(--court-green-light);
  display: flex; align-items: center; justify-content: center; overflow: hidden; font-size: 1.5rem;
}
.photo-preview img { width: 100%; height: 100%; object-fit: cover; }
.photo-upload-field { flex: 1; min-width: 0; }

/* ===== ATTENDANCE ===== */
.attendance-selector-form { display: flex; align-items: flex-end; flex-wrap: wrap; gap: 1rem; }
.attendance-selector-form .field-row { flex: 1; min-width: 260px; margin: 0; }
.attendance-selector-form button { height: 42px; }
.attendance-stale-warning {
  display: none;
  background: rgba(244, 162, 97, 0.12);
  border: 1px solid var(--warning);
  color: var(--warning);
  border-radius: var(--radius-sm);
  padding: 0.6rem 0.85rem;
  font-size: 0.82rem;
  margin-bottom: 1rem;
}
.attendance-stale-warning.visible { display: block; }

/* ===== RESPONSIVE ===== */
@media (max-width: 640px) {
  .field-row, .field-row-3 { grid-template-columns: 1fr; }
  .form-photo-row { flex-direction: column; align-items: flex-start; }
  .profile-header-card { flex-direction: column; }
  .card, .panel { padding: 1rem 1.1rem; }
}
