:root {
  --primary: #15803d;
  --primary-dark: #14532d;
  --primary-light: #22c55e;
  --bg: #f3f5f7;
  --card-bg: #ffffff;
  --text: #1f2937;
  --muted: #6b7280;
  --border: #e5e7eb;
  --danger: #dc2626;
  --danger-dark: #b91c1c;
  --sidebar-bg: #0f172a;
  --sidebar-text: #cbd5e1;
  --sidebar-active-bg: rgba(34, 197, 94, 0.18);
  --topbar-height: 56px;
  --sidebar-width: 250px;
  --radius: 10px;
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  -webkit-tap-highlight-color: transparent;
}

a {
  color: inherit;
  text-decoration: none;
}

img {
  max-width: 100%;
}

button, input, select, textarea {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
}

[hidden] {
  display: none !important;
}

/* ---------- App shell ---------- */

.app-shell {
  min-height: 100vh;
}

.topbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--topbar-height);
  padding-top: env(safe-area-inset-top, 0px);
  background: var(--sidebar-bg);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 12px;
  padding-left: 16px;
  padding-right: 16px;
  z-index: 20;
}

.topbar-title {
  font-weight: 700;
  font-size: 1.05rem;
  letter-spacing: 0.02em;
}

.menu-toggle {
  background: none;
  border: none;
  color: #fff;
  font-size: 1.4rem;
  line-height: 1;
  padding: 4px 8px;
  cursor: pointer;
}

/* ---------- Sidebar ---------- */

.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: 82%;
  max-width: 300px;
  background: var(--sidebar-bg);
  color: var(--sidebar-text);
  display: flex;
  flex-direction: column;
  transform: translateX(-100%);
  transition: transform 0.25s ease;
  z-index: 40;
  padding-top: env(safe-area-inset-top, 0px);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}

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

.sidebar-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 20px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}

.brand {
  color: #fff;
  font-weight: 800;
  font-size: 1.2rem;
  letter-spacing: 0.02em;
}

.sidebar-close {
  background: none;
  border: none;
  color: #fff;
  font-size: 1.6rem;
  line-height: 1;
  cursor: pointer;
  padding: 0 4px;
}

.nav-links {
  list-style: none;
  margin: 0;
  padding: 12px;
  flex: 1;
  overflow-y: auto;
}

.nav-links li + li {
  margin-top: 4px;
}

.nav-links a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border-radius: var(--radius);
  color: var(--sidebar-text);
  font-weight: 600;
  font-size: 0.95rem;
}

.nav-links a:hover {
  background: rgba(255,255,255,0.06);
}

.nav-links a.active {
  background: var(--sidebar-active-bg);
  color: #fff;
}

.nav-icon {
  font-size: 1.05rem;
  width: 22px;
  text-align: center;
}

.sidebar-bottom {
  padding: 16px 20px 20px;
  border-top: 1px solid rgba(255,255,255,0.08);
}

.logout-btn {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: rgba(255,255,255,0.06);
  color: #fff;
  border: none;
  padding: 12px;
  border-radius: var(--radius);
  font-weight: 700;
  font-size: 0.95rem;
  cursor: pointer;
}

.logout-btn:hover {
  background: rgba(255,255,255,0.12);
}

.copyright {
  margin: 14px 0 0;
  text-align: center;
  font-size: 0.75rem;
  color: rgba(255,255,255,0.4);
}

.sidebar-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
  z-index: 30;
}

.sidebar-overlay.visible {
  opacity: 1;
  pointer-events: auto;
}

/* ---------- Content ---------- */

.content {
  padding: 20px 16px calc(32px + env(safe-area-inset-bottom, 0px));
  margin-top: var(--topbar-height);
  max-width: 960px;
}

.page-title {
  font-size: 1.4rem;
  margin: 0 0 16px;
}

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.page-header .page-title {
  margin: 0;
}

/* ---------- Flash messages ---------- */

.flash {
  padding: 12px 16px;
  border-radius: var(--radius);
  margin-bottom: 16px;
  font-size: 0.9rem;
  font-weight: 600;
}

.flash-success {
  background: #dcfce7;
  color: #166534;
}

.flash-error {
  background: #fee2e2;
  color: #991b1b;
}

/* ---------- Cards ---------- */

.card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  margin-bottom: 16px;
}

.card h2 {
  margin: 4px 0 4px;
  font-size: 1.15rem;
}

.card h3 {
  margin: 0 0 4px;
  font-size: 1rem;
}

.divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: 20px 0;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.card-header h3 {
  margin: 0;
}

.muted {
  color: var(--muted);
  font-size: 0.88rem;
}

.link {
  color: var(--primary);
  font-weight: 600;
  font-size: 0.88rem;
}

.empty-state {
  text-align: center;
  color: var(--muted);
}

.empty-state .btn {
  margin-top: 10px;
}

.card-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* ---------- Badges / pills / tags ---------- */

.badge {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  padding: 3px 9px;
  border-radius: 999px;
  margin-bottom: 6px;
}

.badge-active {
  background: #dcfce7;
  color: var(--primary-dark);
}

.pill {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 4px 12px;
  font-size: 0.82rem;
  font-weight: 700;
  white-space: nowrap;
}

.tag {
  display: inline-block;
  font-size: 0.75rem;
  padding: 2px 8px;
  border-radius: 999px;
}

.tag-muted {
  background: #f1f5f9;
  color: var(--muted);
}

/* ---------- Buttons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: none;
  border-radius: var(--radius);
  padding: 11px 16px;
  font-size: 0.92rem;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
}

.btn-primary {
  background: var(--primary);
  color: #fff;
}

.btn-primary:hover {
  background: var(--primary-dark);
}

.btn-secondary {
  background: #eef2f6;
  color: var(--text);
}

.btn-secondary:hover {
  background: #e2e8f0;
}

.btn-danger {
  background: #fef2f2;
  color: var(--danger);
}

.btn-danger:hover {
  background: var(--danger);
  color: #fff;
}

.btn-sm {
  padding: 8px 12px;
  font-size: 0.82rem;
}

.btn-block {
  width: 100%;
}

.quick-links {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

/* ---------- Forms ---------- */

.stacked-form {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.stacked-form label {
  font-weight: 700;
  font-size: 0.85rem;
  margin-top: 10px;
}

.stacked-form input,
.stacked-form textarea,
.stacked-form select {
  padding: 11px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.95rem;
  font-family: inherit;
  width: 100%;
  background: #fff;
  color: var(--text);
}

.stacked-form input:focus,
.stacked-form textarea:focus,
.stacked-form select:focus {
  outline: 2px solid var(--primary-light);
  outline-offset: 1px;
}

.stacked-form select {
  padding-right: 36px;
  appearance: none;
  -webkit-appearance: none;
  cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 14px;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 18px;
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 14px;
  font-weight: 600;
  font-size: 0.9rem;
}

.checkbox-label input {
  width: 18px;
  height: 18px;
}

.danger-zone {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-color: #fecaca;
  flex-wrap: wrap;
}

/* ---------- Login page ---------- */

.login-body {
  background: linear-gradient(160deg, var(--sidebar-bg), var(--primary-dark));
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px calc(16px + env(safe-area-inset-right, 0px)) 24px calc(16px + env(safe-area-inset-left, 0px));
}

.login-wrap {
  width: 100%;
  max-width: 380px;
}

.login-card {
  background: #fff;
  border-radius: 16px;
  padding: 32px 28px;
  box-shadow: 0 20px 40px rgba(0,0,0,0.25);
}

.login-title {
  margin: 0;
  font-size: 1.8rem;
  color: var(--primary-dark);
  text-align: center;
  letter-spacing: 0.02em;
}

.login-subtitle {
  text-align: center;
  color: var(--muted);
  margin: 6px 0 22px;
}

.login-form {
  display: flex;
  flex-direction: column;
}

.login-form label {
  font-weight: 700;
  font-size: 0.85rem;
  margin-top: 14px;
  margin-bottom: 6px;
}

.login-form input {
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 1rem;
}

.login-form .btn {
  margin-top: 22px;
  padding: 13px;
  font-size: 1rem;
}

.login-copyright {
  text-align: center;
  color: rgba(255,255,255,0.75);
  font-size: 0.8rem;
  margin-top: 18px;
}

/* ---------- Seasons / Members cards ---------- */

.season-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.season-card,
.member-card,
.training-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.member-card.inactive {
  opacity: 0.6;
}

.season-card-actions,
.member-card-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.training-card {
  cursor: pointer;
}

.training-card:hover {
  border-color: var(--primary-light);
}

/* ---------- Payments table ---------- */

.table-card {
  padding: 0;
  overflow: hidden;
}

.table-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.payments-table {
  border-collapse: collapse;
  width: 100%;
}

.payments-table th,
.payments-table td {
  padding: 10px;
  text-align: center;
  border-bottom: 1px solid var(--border);
  font-size: 0.82rem;
  white-space: nowrap;
}

.payments-table thead th {
  background: var(--bg);
  color: var(--muted);
  font-weight: 700;
}

.col-left {
  text-align: left !important;
  font-weight: 700;
}

.total-row td {
  border-top: 2px solid var(--text);
  font-weight: 700;
}

.sticky-col {
  position: sticky;
  left: 0;
  background: #fff;
  text-align: left !important;
  font-weight: 700;
  z-index: 1;
  box-shadow: 1px 0 0 var(--border);
}

thead .sticky-col {
  background: var(--bg);
  z-index: 2;
}

.pay-cell {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  border: none;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
}

.pay-cell.paid {
  background: #dcfce7;
  color: var(--primary-dark);
}

.pay-cell.unpaid {
  background: #fef2f2;
  color: #b91c1c;
}

/* ---------- Attendance checklist ---------- */

.attendance-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.attendance-list li + li {
  border-top: 1px solid var(--border);
}

.attendance-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 13px 4px;
  font-weight: 600;
  cursor: pointer;
}

.attendance-row input {
  width: 20px;
  height: 20px;
  accent-color: var(--primary);
}

/* ---------- Dashboard quick actions ---------- */

.quick-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px;
}

.quick-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 28px 12px;
  text-align: center;
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--text);
  cursor: pointer;
}

.quick-btn:hover {
  border-color: var(--primary-light);
  box-shadow: 0 4px 14px rgba(21, 128, 61, 0.12);
}

.quick-icon {
  font-size: 2rem;
}

@media (min-width: 480px) {
  .quick-grid {
    grid-template-columns: repeat(4, 1fr);
  }

  .quick-btn {
    padding: 24px 10px;
  }
}

/* ---------- Desktop layout ---------- */

@media (min-width: 768px) {
  .topbar {
    display: none;
  }

  .sidebar {
    transform: none;
    width: var(--sidebar-width);
    max-width: var(--sidebar-width);
    box-shadow: 1px 0 0 rgba(255,255,255,0.05);
  }

  .sidebar-close {
    display: none;
  }

  .sidebar-overlay {
    display: none;
  }

  .content {
    margin-top: 0;
    margin-left: var(--sidebar-width);
    padding: 36px 40px;
    max-width: 900px;
  }

}

@media (max-width: 480px) {
  .form-row {
    grid-template-columns: 1fr;
  }
}
