:root {
  --bg-start: #f7f2e8;
  --bg-end: #fefaf4;
  --surface: rgba(255, 255, 255, 0.84);
  --text: #1d2a2f;
  --muted: #526067;
  --primary: #0f8d85;
  --primary-dark: #08635d;
  --accent: #ef6b45;
  --free: #dff0d8;
  --booked: #f7c99f;
  --border: rgba(13, 34, 42, 0.12);
  --shadow: 0 18px 45px rgba(15, 55, 67, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Outfit", sans-serif;
  color: var(--text);
  background: linear-gradient(180deg, var(--bg-start), var(--bg-end));
  overflow-x: hidden;
}

.bg-orb {
  position: fixed;
  border-radius: 50%;
  pointer-events: none;
  z-index: 0;
  filter: blur(8px);
}

.orb-a {
  width: 220px;
  height: 220px;
  background: radial-gradient(circle, rgba(239, 107, 69, 0.35), transparent 70%);
  top: -70px;
  right: -50px;
}

.orb-b {
  width: 280px;
  height: 280px;
  background: radial-gradient(circle, rgba(15, 141, 133, 0.28), transparent 72%);
  bottom: -90px;
  left: -90px;
}

.app-shell {
  position: relative;
  z-index: 1;
  width: min(1080px, 100% - 1.5rem);
  margin: 1rem auto 2rem;
  display: grid;
  gap: 1rem;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(7px);
}

.hero {
  position: relative;
  z-index: 20;
  padding: 1.1rem 1.2rem 1.3rem;
}

.hero-brand {
  display: flex;
  align-items: center;
  gap: 0.62rem;
}

.club-logo {
  width: 72px;
  height: 72px;
  object-fit: cover;
  border-radius: 50%;
  box-shadow: 0 6px 14px rgba(14, 76, 70, 0.12);
}

.club-name {
  margin: 0;
  font-weight: 700;
  font-size: 1.2rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--primary-dark);
}

.admin-gear-btn {
  display: none;
  position: absolute;
  top: 0.7rem;
  right: 8.2rem;
  min-width: 8.4rem;
  height: 40px;
  padding: 0 0.75rem;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.85);
  color: var(--primary-dark);
  align-items: center;
  justify-content: center;
  font-size: 0.9rem;
  font-weight: 600;
  line-height: 1;
}

body.admin-role .admin-gear-btn {
  display: inline-flex;
}

.admin-gear-btn:hover {
  background: #fff;
  transform: translateY(-1px);
}

body.member-role .admin-gear-btn {
  display: none !important;
}

.stats-gear-btn {
  right: 17.2rem;
}


.header-logout-btn {
  position: absolute;
  top: 0.7rem;
  right: 0.7rem;
}

.header-auth-status {
  position: absolute;
  top: 3.25rem;
  right: 0.7rem;
  margin: 0;
  padding: 0.2rem 0.45rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.9);
  font-size: 0.76rem;
  text-align: right;
}

.header-menu-toggle {
  display: none;
  width: 40px;
  height: 40px;
  padding: 0;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.85);
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 4px;
}

.header-menu-toggle:hover {
  background: #fff;
}

.header-menu-toggle span {
  display: block;
  width: 18px;
  height: 2px;
  border-radius: 2px;
  background: var(--primary-dark);
}

.header-menu-panel {
  display: contents;
}

.header-back-link {
  display: none;
}

.kicker {
  margin: 0;
  color: var(--primary);
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-size: 0.78rem;
}

h1,
h2,
h3 {
  font-family: "Sora", sans-serif;
}

.hero h1 {
  margin: 0.4rem 0 0.45rem;
  font-size: clamp(1.45rem, 5vw, 2.2rem);
  line-height: 1.08;
}

.hero p {
  margin: 0;
  color: var(--muted);
}

.toolbar {
  padding: 0.9rem;
  display: grid;
  gap: 0.9rem;
}

.date-controls {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 0.7rem;
}

.date-current {
  min-width: 220px;
  text-align: center;
}

.label {
  margin: 0;
  font-size: 0.73rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.date-label {
  margin: 0.08rem 0 0;
  font-weight: 700;
  font-size: 1rem;
}

.week-nav-btn {
  width: 2.1rem;
  height: 2.1rem;
  padding: 0;
  border-radius: 10px;
  display: grid;
  place-items: center;
  font-size: 1.3rem;
  line-height: 1;
}

.actions {
  display: flex;
  gap: 0.7rem;
  justify-content: flex-end;
  flex-wrap: wrap;
}

.auth-controls {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.24rem 0.36rem;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.72);
}

.auth-status {
  margin: 0;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--muted);
}

.view-toggle {
  display: inline-flex;
  gap: 0.38rem;
  padding: 0.24rem;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.72);
}

.toggle-btn {
  padding: 0.48rem 0.68rem;
  border-radius: 10px;
}

.toggle-btn.active {
  color: #fff;
  border-color: transparent;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
}

button {
  border: none;
  border-radius: 14px;
  font: inherit;
  cursor: pointer;
}

button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.primary-btn,
.secondary-btn,
.ghost-btn,
.mini-btn {
  padding: 0.62rem 0.9rem;
  font-weight: 600;
}

.primary-btn {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: #fff;
}

.secondary-btn {
  background: #fff;
  color: var(--text);
  border: 1px solid var(--border);
}

.ghost-btn {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
}

.danger-btn {
  border-color: #d9534f;
  color: #d9534f;
  margin-right: auto;
}

.danger-btn:hover {
  background: #d9534f;
  color: #fff;
}

.schedule {
  display: grid;
  gap: 0.8rem;
}

.schedule.week-mode {
  grid-template-columns: 1fr;
}

.schedule.mobile-week-mode {
  gap: 0.6rem;
}

.mobile-week-selector {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 0.35rem;
}

.mobile-week-day {
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.85);
  color: #2a3b46;
  border-radius: 10px;
  padding: 0.42rem 0.2rem;
  font-size: 0.72rem;
  font-weight: 600;
}

.mobile-week-day.active {
  color: #fff;
  border-color: transparent;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
}

.week-planner-wrap {
  overflow-x: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: var(--shadow);
}

.week-planner {
  width: 100%;
  min-width: 940px;
  border-collapse: collapse;
  table-layout: fixed;
  font-size: 0.84rem;
}

.week-planner.day-planner {
  min-width: 300px;
}

.week-planner th,
.week-planner td {
  border: 1px solid rgba(28, 57, 69, 0.2);
}

.week-planner .time-head,
.week-planner .time-cell {
  width: 64px;
  text-align: center;
  background: #eef3f7;
  color: #1b3540;
  font-weight: 700;
  padding: 0.35rem 0.25rem;
}

.week-planner .day-head {
  background: #dce6f5;
  color: #0f2940;
  text-align: center;
  font-family: "Sora", sans-serif;
  font-size: 0.88rem;
  font-weight: 700;
  padding: 0.5rem 0.3rem;
}

.week-planner .court-head {
  background: #ecf1f9;
  color: #223447;
  text-align: center;
  font-weight: 700;
  font-size: 0.82rem;
  padding: 0.2rem;
}

.week-planner .day-group-end {
  border-right: 6px solid var(--surface, #fff);
}

.planner-cell {
  height: 44px;
  padding: 0.12rem 0.15rem;
  color: #112430;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-align: left;
  vertical-align: middle;
}

.planner-cell.free {
  background: #ffffff;
  cursor: pointer;
}

.planner-cell.free:hover {
  background: #eef3f7;
}

.planner-cell.free.past {
  background: #e6e6e6;
  cursor: default;
}

.planner-cell.free.past:hover {
  background: #e6e6e6;
}

.planner-cell.booked {
  cursor: pointer;
}

.planner-cell.booked.deletable:hover {
  filter: brightness(0.95);
}

.court-column {
  background: var(--surface);
  border-radius: 18px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.court-title {
  margin: 0;
  padding: 0.8rem 0.9rem;
  background: linear-gradient(120deg, rgba(15, 141, 133, 0.18), rgba(239, 107, 69, 0.12));
  font-size: 1rem;
}

.slots {
  display: grid;
  gap: 0.55rem;
  padding: 0.75rem;
}

.slot {
  border-radius: 14px;
  padding: 0.62rem;
  border: 1px solid transparent;
  display: grid;
  gap: 0.25rem;
}

.slot header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.slot h3 {
  margin: 0;
  font-size: 0.96rem;
}

.slot p {
  margin: 0;
}

.status {
  font-size: 0.79rem;
  font-weight: 700;
}

.free-slot {
  background: var(--free);
  border-color: rgba(8, 99, 93, 0.2);
}

.booked-slot {
  background: var(--booked);
  border-color: rgba(179, 74, 45, 0.22);
}

.mini-btn {
  justify-self: start;
  margin-top: 0.15rem;
  padding: 0.4rem 0.68rem;
  background: #fff;
  border: 1px solid var(--border);
}

.booking-dialog {
  border: none;
  padding: 0;
  width: min(450px, calc(100% - 1rem));
  border-radius: 20px;
}

#userAdminDialog {
  width: min(980px, calc(100% - 2rem));
}

.booking-dialog::backdrop {
  background: rgba(15, 39, 44, 0.52);
}

.dialog-card {
  padding: 1rem;
  display: grid;
  gap: 0.75rem;
}

.dialog-card h2 {
  margin: 0 0 0.3rem;
}

.selected-court-info {
  margin: -0.25rem 0 0.15rem;
  padding: 0.45rem 0.6rem;
  border-radius: 10px;
  background: rgba(15, 141, 133, 0.12);
  border: 1px solid rgba(15, 141, 133, 0.25);
  color: #0d5f59;
  font-weight: 700;
}

.court-display {
  display: grid;
  gap: 0.35rem;
}

.court-display-label {
  margin: 0;
  font-weight: 600;
}

.court-display-value {
  margin: 0;
  padding: 0.6rem 0.65rem;
  border: 1px solid var(--border);
  border-radius: 11px;
  background: #eef3f7;
  color: #1b3540;
  font-weight: 700;
}

label {
  display: grid;
  gap: 0.35rem;
  font-weight: 600;
}

input,
select {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 11px;
  padding: 0.6rem 0.65rem;
  font: inherit;
}

.time-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.65rem;
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.6rem;
}

.form-message {
  margin: 0;
  min-height: 1.2rem;
  font-weight: 600;
  color: var(--accent);
}

.users-list {
  margin: 0;
  padding-left: 0;
  list-style: none;
  max-height: 360px;
  overflow-y: auto;
  color: var(--muted);
}

.users-list-item {
  margin: 0;
  padding: 0.5rem 0.4rem;
  border-bottom: 1px solid rgba(23, 54, 76, 0.08);
  background: rgba(202, 217, 236, 0.42);
  display: grid;
  grid-template-columns: 1.6fr 1.1fr 0.9fr 1.5fr auto;
  align-items: center;
  gap: 0.5rem;
}

.users-list-item:nth-child(even) {
  background: rgba(189, 207, 230, 0.45);
}

.members-toolbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 0.6rem;
  align-items: center;
}

.members-filter-label {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.members-filter-input {
  border-radius: 6px;
  padding: 0.58rem 0.68rem;
}

.members-csv-btn,
.members-new-btn {
  border-radius: 6px;
  padding: 0.42rem 0.72rem;
  min-height: 2.4rem;
  white-space: nowrap;
}

.members-new-btn {
  justify-self: end;
  min-width: 9.5rem;
  font-size: 0.95rem;
  font-weight: 700;
}

.member-count-badge {
  margin: 0;
  justify-self: start;
  min-width: 32px;
  text-align: center;
  font-size: 0.75rem;
  font-weight: 700;
  color: #fff;
  background: #2f6fdb;
  border-radius: 999px;
  padding: 0.1rem 0.35rem;
}

.stats-content {
  display: grid;
  gap: 1rem;
  margin-top: 0.4rem;
}

.stats-section {
  display: grid;
  gap: 0.5rem;
}

.stats-section-title {
  margin: 0;
  font-family: "Sora", sans-serif;
  font-size: 1rem;
  color: #0f2940;
}

.stats-court-row {
  display: grid;
  gap: 0.25rem;
}

.stats-court-label {
  margin: 0;
  font-size: 0.88rem;
  color: #1d2a2f;
}

.stats-bar {
  height: 10px;
  border-radius: 999px;
  background: #e6edf5;
  overflow: hidden;
}

.stats-bar-fill {
  height: 100%;
  background: #2f6fdb;
  border-radius: 999px;
}

.stats-top-list {
  margin: 0;
  padding-left: 1.2rem;
  display: grid;
  gap: 0.3rem;
  font-size: 0.9rem;
  color: #1d2a2f;
}

.stats-empty {
  margin: 0;
  font-size: 0.9rem;
  color: #5a6b73;
}


.members-table-head {
  display: grid;
  grid-template-columns: 1.6fr 1.1fr 0.9fr 1.5fr auto;
  gap: 0.5rem;
  padding: 0.22rem 0.4rem 0.38rem;
  font-weight: 700;
  color: #1d2a2f;
}

.member-form-fields {
  border: 1px solid var(--border);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.72);
  padding: 0.7rem;
  display: grid;
  gap: 0.6rem;
  margin-top: 0.35rem;
}

.member-form-fields[hidden] {
  display: none !important;
}

.member-form-title {
  margin: 0;
  font-size: 0.98rem;
}

.member-checkbox-label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 500;
}
.member-checkbox-label input[type="checkbox"] {
  width: auto;
}

.member-save-btn {
  justify-self: end;
}

.users-list-actions {
  display: inline-flex;
  gap: 0.35rem;
}

.users-list-name {
  font-size: 0.94rem;
  color: #2270df;
  text-decoration: underline;
  background: transparent;
  border: none;
  padding: 0;
  justify-self: start;
}

.users-list-username,
.users-list-email,
.users-list-role,
.users-list-contact {
  color: #223447;
  font-size: 0.92rem;
}

.users-list-email,
.users-list-contact {
  color: #2f6fdb;
  text-decoration: underline;
}

.users-edit-btn {
  margin-top: 0;
  padding: 0.22rem 0.5rem;
  white-space: nowrap;
}

.users-delete-btn {
  margin-top: 0;
  padding: 0.22rem 0.5rem;
  white-space: nowrap;
  border: 1px solid rgba(159, 34, 34, 0.35);
  color: #7f1d1d;
  background: rgba(255, 237, 237, 0.8);
}

.users-delete-btn:hover {
  background: rgba(255, 219, 219, 0.95);
}

.reveal {
  opacity: 0;
  transform: translateY(14px);
  animation: reveal 540ms ease forwards;
}

.reveal:nth-of-type(2) {
  animation-delay: 90ms;
}

.reveal:nth-of-type(3) {
  animation-delay: 160ms;
}

.reveal:nth-of-type(4) {
  animation-delay: 220ms;
}

@keyframes reveal {
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (min-width: 900px) {
  .schedule {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .schedule.week-mode {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 900px) {
  .mobile-week-selector {
    gap: 0.28rem;
  }

  .mobile-week-day {
    font-size: 0.68rem;
    padding: 0.38rem 0.15rem;
  }

  .week-planner {
    border-collapse: separate;
    border-spacing: 0.3rem 0.4rem;
  }

  .week-planner th,
  .week-planner td {
    border: none;
  }

  .week-planner .time-head,
  .week-planner .time-cell,
  .week-planner .court-head {
    border-radius: 8px;
  }

  .planner-cell {
    border-radius: 8px;
  }

  .planner-cell.free {
    border: 1px solid rgba(28, 57, 69, 0.12);
  }

  .planner-cell.free.past {
    border-color: rgba(28, 57, 69, 0.08);
  }

  .members-toolbar {
    grid-template-columns: 1fr;
  }

  .members-table-head,
  .users-list-item {
    grid-template-columns: 1fr;
  }

  .members-table-head span:nth-child(2),
  .members-table-head span:nth-child(3),
  .members-table-head span:nth-child(4),
  .members-table-head span:nth-child(5),
  .users-list-username,
  .users-list-role,
  .users-list-email,
  .users-list-contact,
  .users-list-actions {
    display: none;
  }
}

@media (max-width: 760px) {
  .hero {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 0.45rem;
    align-items: start;
    padding: 0.85rem 0.85rem 0.95rem;
  }

  .hero-brand {
    grid-column: 1 / 2;
    grid-row: 1;
    min-width: 0;
  }

  .club-logo {
    width: 58px;
    height: 58px;
  }

  .club-name {
    font-size: 1rem;
    letter-spacing: 0.02em;
  }

  .header-menu-toggle {
    display: flex;
    grid-column: 2 / 3;
    grid-row: 1;
    justify-self: end;
  }

  .header-menu-panel {
    display: none;
    position: absolute;
    top: 3.6rem;
    right: 0.85rem;
    z-index: 30;
    flex-direction: column;
    align-items: stretch;
    gap: 0.5rem;
    min-width: 190px;
    padding: 0.65rem;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: var(--surface);
    box-shadow: var(--shadow);
  }

  .header-menu-panel.open {
    display: flex;
  }

  .header-menu-panel .admin-gear-btn,
  .header-menu-panel .header-logout-btn,
  .header-menu-panel .header-back-link,
  .header-menu-panel .header-auth-status {
    position: static;
    top: auto;
    right: auto;
    grid-column: auto;
    grid-row: auto;
    justify-self: stretch;
    width: 100%;
    max-width: none;
    text-align: left;
    white-space: normal;
  }

  body.admin-role .header-menu-panel .admin-gear-btn,
  .header-menu-panel .header-logout-btn {
    height: 34px;
    min-width: 0;
    padding: 0 0.6rem;
    border-radius: 10px;
    font-size: 0.82rem;
  }

  .header-menu-panel .header-back-link {
    display: block;
    box-sizing: border-box;
    height: 34px;
    line-height: 34px;
    padding: 0 0.6rem;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.85);
    color: var(--primary-dark);
    font-size: 0.82rem;
    font-weight: 600;
    text-decoration: none;
    text-align: center;
  }

  .header-menu-panel .header-back-link:hover {
    background: #fff;
  }
}
