:root {
  color-scheme: light;
  --bg: #f6f8f5;
  --panel: #ffffff;
  --ink: #17201b;
  --muted: #6d776f;
  --line: #e1e8e1;
  --green: #11784a;
  --green-dark: #073f2d;
  --green-deep: #052d21;
  --green-soft: #e8f6ee;
  --red: #c43d32;
  --red-soft: #fae9e7;
  --blue: #4f46e5;
  --blue-soft: #ececff;
  --gold: #a36500;
  --gold-soft: #fff3d8;
  --shadow: 0 18px 45px rgba(16, 31, 24, 0.08);
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--ink);
  -webkit-tap-highlight-color: transparent;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  overscroll-behavior-y: none;
}

button, input, textarea, select { font: inherit; }
button { cursor: pointer; }
h1, h2, h3, p { margin-top: 0; }

.dashboard-shell {
  display: grid;
  grid-template-columns: 260px 1fr;
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  height: auto;
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 22px 18px;
  background:
    radial-gradient(circle at 10% 0%, rgba(255, 255, 255, 0.14), transparent 30%),
    linear-gradient(160deg, var(--green-dark), var(--green-deep));
  color: #fff;
}

.brand-block {
  display: grid;
  grid-template-columns: 54px 1fr;
  gap: 12px;
  align-items: center;
}

.brand-logo, .settings-logo {
  display: grid;
  place-items: center;
  width: 54px;
  height: 54px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.16);
  border: 1px solid rgba(255, 255, 255, 0.22);
  color: #fff;
  font-weight: 900;
  overflow: hidden;
}

.brand-logo img, .settings-logo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.brand-block strong { display: block; font-size: 1.08rem; }
.brand-block span { display: block; color: rgba(255,255,255,.72); font-size: .82rem; }

.side-nav { display: grid; gap: 6px; }
.side-nav p {
  margin: 14px 8px 4px;
  color: rgba(255,255,255,.58);
  font-size: .68rem;
  font-weight: 900;
  text-transform: uppercase;
}
.side-nav a, .side-nav button {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 42px;
  border: 0;
  border-radius: 8px;
  padding: 0 12px;
  background: transparent;
  color: rgba(255,255,255,.86);
  text-decoration: none;
  font-weight: 800;
  text-align: left;
}
.side-nav a.active, .side-nav a:hover, .side-nav .nav-link.active, .side-nav button:hover { background: rgba(255,255,255,.12); color: #fff; }
.side-nav span { width: 18px; text-align: center; }

.support-card {
  margin-top: 10px;
  border: 1px solid rgba(255,255,255,.13);
  border-radius: 8px;
  background: rgba(255,255,255,.08);
  padding: 14px;
}
.support-card strong { display: block; }
.support-card span { color: rgba(255,255,255,.7); font-size: .82rem; }

/* --- Mobile app bar + hamburger drawer (hidden on desktop) --- */
.mobile-appbar { display: none; }
.hamburger {
  position: relative;
  flex: none;
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.14);
  transition: background 160ms ease, transform 120ms ease;
}
.hamburger:active { transform: scale(0.92); }
.hamburger span {
  position: absolute;
  width: 20px;
  height: 2px;
  border-radius: 2px;
  background: #fff;
  transition: transform 320ms cubic-bezier(0.4, 0, 0.2, 1), opacity 200ms ease;
}
.hamburger span:nth-child(1) { transform: translateY(-6px); }
.hamburger span:nth-child(3) { transform: translateY(6px); }
body.nav-open .hamburger span:nth-child(1) { transform: translateY(0) rotate(45deg); }
body.nav-open .hamburger span:nth-child(2) { opacity: 0; }
body.nav-open .hamburger span:nth-child(3) { transform: translateY(0) rotate(-45deg); }
.mobile-appbar-title {
  flex: 1;
  min-width: 0;
  font-size: 1.08rem;
  font-weight: 850;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.mobile-appbar-add {
  flex: none;
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.16);
  color: #fff;
  font-size: 1.6rem;
  line-height: 1;
  transition: transform 120ms ease, background 160ms ease;
}
.mobile-appbar-add:active { transform: scale(0.9); }
.sidebar-scrim {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 50;
  background: rgba(6, 24, 17, 0.5);
  opacity: 0;
  pointer-events: none;
  transition: opacity 320ms ease;
  -webkit-backdrop-filter: blur(1px);
  backdrop-filter: blur(1px);
}

.main-content {
  min-width: 0;
  padding: 24px 28px 34px;
}

.view {
  display: none;
}

.view.active {
  display: block;
  animation: viewEnter 340ms cubic-bezier(0.22, 0.61, 0.36, 1);
}

@keyframes viewEnter {
  from { opacity: 0; transform: translateX(22px); }
  to { opacity: 1; transform: translateX(0); }
}

/* Native-style press feedback on tappable surfaces */
.stat-card, .member-card, .trainer-card, .history-member-card,
.payment-customer-card, .nav-shortcut, .tab, .primary-action,
.secondary-action, .attendance-button, .collect-fee-button {
  transition: transform 110ms ease, box-shadow 160ms ease, background 160ms ease, border-color 160ms ease;
}
@media (hover: none) {
  .member-card:active, .trainer-card:active, .history-member-card:active,
  .payment-customer-card:active, .nav-shortcut:active, .tab:active,
  .primary-action:active, .secondary-action:active,
  .attendance-button:active, .collect-fee-button:active,
  .side-nav button:active, .side-nav a:active {
    transform: scale(0.97);
  }
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 22px;
}
.topbar h1 { margin-bottom: 6px; font-size: clamp(1.5rem, 3vw, 2.15rem); line-height: 1.08; }
.topbar p { margin-bottom: 0; color: var(--muted); }
.topbar-actions { display: flex; align-items: center; gap: 10px; }
.date-pill {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 0 12px;
  color: var(--ink);
  font-weight: 850;
}

.primary-action, .secondary-action, .present-action, .paid-action, .whatsapp-action {
  min-height: 46px;
  border: 0;
  border-radius: 8px;
  padding: 0 16px;
  font-weight: 850;
}
.primary-action { display: inline-flex; align-items: center; justify-content: center; gap: 8px; background: var(--green); color: #fff; }
.primary-action span { display: grid; place-items: center; width: 22px; height: 22px; border-radius: 50%; background: rgba(255,255,255,.16); }
.secondary-action { border: 1px solid var(--line); background: #fff; color: var(--ink); }
.present-action { background: var(--green); color: #fff; }
.paid-action { background: var(--blue); color: #fff; }
.whatsapp-action { background: #25d366; color: #062d19; }

.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 14px; margin-bottom: 18px; }
.stat-card, .panel, .member-card, .detail-grid article, .payment-row {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}
.stat-card { position: relative; min-height: 118px; padding: 18px 18px 16px 70px; overflow: hidden; }
.stat-card span { display: block; color: var(--muted); font-size: .82rem; font-weight: 850; }
.stat-card strong { display: block; margin-top: 7px; font-size: 2rem; line-height: 1; }
.stat-card small { display: block; margin-top: 8px; color: var(--muted); }
.stat-icon { position: absolute; top: 20px; left: 18px; display: grid; place-items: center; width: 38px; height: 38px; border-radius: 50%; font-weight: 900; }
.stat-card.total { background: linear-gradient(135deg, #f8fffb, #eef9f3); border-color: #cdebd9; }
.stat-card.total .stat-icon { background: #d9f2e4; color: var(--green); }
.stat-card.due { background: linear-gradient(135deg, #fff7f6, #fae9e7); border-color: #f0cac5; }
.stat-card.due .stat-icon { background: #ffd9d5; color: var(--red); }
.stat-card.paid { background: linear-gradient(135deg, #fbfbff, var(--blue-soft)); border-color: #d7d8ff; }
.stat-card.paid .stat-icon { background: #dedfff; color: var(--blue); }
.stat-card.attend { background: linear-gradient(135deg, #fffaf0, var(--gold-soft)); border-color: #f2dca8; }
.stat-card.attend .stat-icon { background: #ffe2a4; color: var(--gold); }
.stat-card.trainers { background: linear-gradient(135deg, #f9fbff, var(--blue-soft)); border-color: #d7d8ff; }
.stat-card.trainers .stat-icon { background: #dedfff; color: var(--blue); }

.dashboard-grid { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 16px; align-items: start; }
.left-stack, .right-stack { display: grid; gap: 16px; }
.panel { padding: 16px; }
.panel-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.panel-head h2 { margin-bottom: 4px; font-size: 1.08rem; }
.panel-head h3 { margin-bottom: 4px; }
.panel-head p { margin-bottom: 0; color: var(--muted); font-size: .86rem; }
.compact { margin-bottom: 10px; }

.toast { position: fixed; top: 16px; left: 50%; z-index: 20; transform: translate(-50%, -120%); width: min(92vw, 420px); border: 1px solid #b9dfc7; border-radius: 8px; background: #f0fbf4; color: var(--green); padding: 12px 14px; box-shadow: var(--shadow); font-weight: 850; opacity: 0; transition: transform 180ms ease, opacity 180ms ease; }
.toast.show { transform: translate(-50%, 0); opacity: 1; }

.date-picker, .search-box, .settings-form label, .photo-field label, .form-grid label, .logo-upload {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: .8rem;
  font-weight: 850;
}
.date-picker { min-width: min(100%, 210px); }
input, textarea, select {
  width: 100%;
  min-height: 46px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  padding: 10px 12px;
  outline: none;
}
textarea { resize: vertical; }
input:focus, textarea:focus, select:focus { border-color: var(--green); box-shadow: 0 0 0 3px rgba(17,120,74,.12); }

.attendance-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
  border: 1px solid #cdebd9;
  border-radius: 8px;
  background: #f3fbf6;
  padding: 12px 14px;
  color: var(--green);
}
.attendance-summary strong { font-size: 1rem; }
.attendance-summary span { color: var(--muted); font-weight: 750; }
.attendance-list { display: grid; gap: 10px; }
.attendance-row {
  display: grid;
  grid-template-columns: 58px minmax(160px, 1fr) minmax(190px, .75fr) minmax(160px, auto);
  gap: 12px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 12px;
  box-shadow: 0 10px 24px rgba(16, 31, 24, 0.04);
}
.attendance-row.is-present { border-color: #b9dfc7; background: #fbfffc; }
.attendance-row.is-pending { border-left: 4px solid #d8ded8; }
.attendance-member-copy { min-width: 0; }
.attendance-row h3 { margin: 0 0 2px; font-size: .98rem; }
.attendance-row p { margin: 0; color: var(--muted); font-size: .84rem; }
.attendance-status-cell { display: grid; gap: 4px; justify-items: start; }
.attendance-status-cell small { color: var(--muted); font-size: .75rem; line-height: 1.25; }
.attendance-status {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  border-radius: 999px;
  padding: 0 10px;
  font-size: .78rem;
  font-weight: 900;
}
.attendance-status.present { background: var(--green-soft); color: var(--green); }
.attendance-status.pending { background: #eef2ef; color: var(--muted); }
.attendance-actions { display: flex; justify-content: flex-end; }
.attendance-confirm-actions { display: flex; gap: 8px; }
.attendance-button {
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  padding: 0 12px;
  font-weight: 850;
  white-space: nowrap;
}
.attendance-button.mark-present { border-color: var(--green); background: var(--green); color: #fff; }
.attendance-button.correction { border-color: #f0cac5; color: var(--red); background: #fff; }
.attendance-button.danger { border-color: var(--red); background: var(--red); color: #fff; }
.attendance-button.ghost { background: #fff; color: var(--muted); }

.history-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; border: 1px solid var(--line); border-radius: 8px; background: #fff; padding: 10px 12px; }
.history-row + .history-row { margin-top: 8px; }
.history-row span { font-weight: 850; }
.history-row strong, .badge { border-radius: 999px; padding: 5px 8px; font-size: .74rem; font-weight: 850; }
.history-row strong { background: var(--green-soft); color: var(--green); }
.history-empty { margin: 0; border: 1px dashed var(--line); border-radius: 8px; padding: 12px; color: var(--muted); }


.history-filters {
  display: grid;
  grid-template-columns: 1.4fr repeat(3, minmax(130px, 1fr));
  gap: 10px;
  margin-bottom: 16px;
}
.history-filters label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: .8rem;
  font-weight: 850;
}
.history-filters select {
  width: 100%;
  min-height: 46px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  padding: 10px 12px;
}
.history-workspace {
  display: grid;
  grid-template-columns: minmax(240px, 360px) 1fr;
  gap: 14px;
  align-items: start;
}
.subhead {
  margin-bottom: 10px;
  font-size: .96rem;
}
.history-member-grid {
  display: grid;
  gap: 10px;
}
.history-member-card {
  display: grid;
  grid-template-columns: 54px 1fr;
  gap: 10px;
  align-items: center;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 10px;
  text-align: left;
}
.history-member-card.active {
  border-color: var(--green);
  background: var(--green-soft);
}
.history-member-card h3 {
  margin: 0 0 2px;
  font-size: .96rem;
}
.history-member-card p,
.history-member-card span {
  display: block;
  margin: 0;
  color: var(--muted);
  font-size: .82rem;
}
.history-report {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 14px;
}
.history-report-head {
  display: grid;
  grid-template-columns: 58px 1fr;
  gap: 12px;
  align-items: center;
  margin-bottom: 14px;
}
.history-report-head h3 {
  margin: 0 0 3px;
}
.history-report-head p {
  margin: 0;
  color: var(--muted);
}
.history-stat-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 14px;
}
.history-stat-grid article {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfdfb;
  padding: 10px;
}
.history-stat-grid span {
  display: block;
  color: var(--muted);
  font-size: .76rem;
  font-weight: 850;
}
.history-stat-grid strong {
  display: block;
  margin-top: 5px;
  font-size: 1.3rem;
}
.attendance-chart {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(18px, 1fr));
  gap: 5px;
  margin-bottom: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: #fbfdfb;
}
.chart-day {
  aspect-ratio: 1;
  min-width: 14px;
  border-radius: 5px;
  background: #edf0ed;
}
.chart-day.present { background: var(--green); }
.chart-day.absent { background: var(--red-soft); border: 1px solid #f0cac5; }
.chart-day.holiday { background: var(--gold-soft); border: 1px solid #f2dca8; }
.history-date-list {
  display: grid;
  gap: 8px;
  max-height: 380px;
  overflow: auto;
}
.history-date-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
}
.history-date-row strong {
  border-radius: 999px;
  padding: 5px 8px;
  font-size: .74rem;
  text-transform: capitalize;
}
.history-date-row strong.present { background: var(--green-soft); color: var(--green); }
.history-date-row strong.absent { background: var(--red-soft); color: var(--red); }
.history-date-row strong.holiday { background: var(--gold-soft); color: var(--gold); }


.billing-card-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}
.billing-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 12px;
}
.billing-card.is-paid {
  background: #fbfffc;
  border-color: #c9ead6;
}
.billing-card-head,
.payment-detail-head {
  display: grid;
  grid-template-columns: 58px 1fr auto;
  gap: 10px;
  align-items: center;
  margin-bottom: 12px;
}
.billing-card-head h3,
.payment-detail-head h3,
.payment-customer-card h3 {
  margin: 0 0 3px;
  font-size: 1rem;
}
.billing-card-head p,
.payment-detail-head p,
.payment-customer-card p {
  margin: 0;
  color: var(--muted);
  font-size: .84rem;
}
.payment-customer-card span {
  display: block;
  margin-top: 3px;
  color: var(--green);
  font-size: .78rem;
  font-weight: 850;
}
.billing-meta {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 12px;
}
.billing-meta div {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
}
.billing-meta span {
  display: block;
  color: var(--muted);
  font-size: .76rem;
  font-weight: 850;
}
.billing-meta strong {
  display: block;
  margin-top: 4px;
}
.collect-fee-button {
  width: 100%;
  min-height: 44px;
  border: 0;
  border-radius: 8px;
  background: var(--green);
  color: #fff;
  font-weight: 850;
}
.collect-fee-button:disabled {
  cursor: not-allowed;
  background: #d9ded9;
  color: #7d867f;
}

.fee-dialog-panel {
  padding: 18px;
}
.fee-dialog-panel .dialog-head p {
  margin-bottom: 0;
  color: var(--muted);
}
.fee-month-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-radius: 8px;
  background: var(--green-soft);
  color: var(--green);
  padding: 12px;
  margin-bottom: 12px;
}
.fee-month-summary strong {
  font-size: 1.25rem;
}
.fee-month-summary span {
  color: var(--muted);
  font-weight: 850;
}
.fee-month-list {
  display: grid;
  gap: 8px;
  max-height: 340px;
  overflow: auto;
}
.fee-month-option {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 10px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 10px 12px;
  font-weight: 850;
}
.fee-month-option input {
  width: 18px;
  min-height: 18px;
  accent-color: var(--green);
}
.fee-month-option span {
  color: var(--ink);
}
.fee-month-option strong {
  color: var(--green);
}

.payment-customer-grid {
  display: grid;
  gap: 10px;
  max-height: 640px;
  overflow: auto;
  padding-right: 2px;
}
.payment-customer-card {
  display: grid;
  grid-template-columns: 54px 1fr;
  gap: 10px;
  align-items: center;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 10px;
  text-align: left;
}
.payment-customer-card.active {
  border-color: var(--green);
  background: var(--green-soft);
}
.payment-workspace .payment-customer-detail {
  margin-top: 0;
}
.payment-customer-detail {
  margin-top: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 14px;
}
.compact-collect {
  width: auto;
  min-width: 170px;
  padding: 0 14px;
}
.payment-history-list {
  display: grid;
  gap: 8px;
}
.payment-history-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
}
.payment-history-row span {
  color: var(--muted);
}

.billing-list { display: grid; gap: 10px; }
.billing-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; border: 1px solid var(--line); border-radius: 8px; background: #fff; padding: 12px; }
.billing-row strong { display: block; margin-bottom: 3px; }
.billing-row span { color: var(--muted); font-size: .86rem; }

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

.summary-list { display: grid; }
.summary-list div { display: flex; align-items: center; justify-content: space-between; min-height: 42px; border-bottom: 1px solid var(--line); color: var(--muted); }
.summary-list div:last-child { border-bottom: 0; }
.summary-list strong { color: var(--ink); }

.settings-form { display: grid; gap: 12px; }
.settings-logo-row { display: flex; align-items: center; gap: 12px; }
.settings-logo { background: var(--green-soft); color: var(--green); border-color: #cdebd9; }
.logo-upload input { max-width: 100%; }
.theme-settings,
.membership-options,
.billing-cycle-settings {
  display: grid;
  gap: 10px;
  margin: 2px 0 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
}
.theme-settings legend,
.membership-options legend,
.billing-cycle-settings legend {
  padding: 0 6px;
  color: var(--ink);
  font-size: .9rem;
  font-weight: 900;
}
.membership-option,
.billing-cycle-option {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 10px;
  align-items: start;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 10px;
}
.membership-option input, .billing-cycle-option input { width: auto; min-height: auto; margin-top: 4px; }
.membership-option strong, .billing-cycle-option strong { display: block; color: var(--ink); }
.membership-option small, .billing-cycle-option small { display: block; margin-top: 3px; color: var(--muted); line-height: 1.35; }
.package-months-field[hidden] { display: none; }
.custom-billing-days input:disabled { background: #f2f5f2; color: var(--muted); }
.holiday-settings .holiday-hint { color: var(--muted); font-size: .82rem; line-height: 1.35; }
.weekday-picker { display: flex; flex-wrap: wrap; gap: 8px; }
.weekday-chip { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); border-radius: 999px; background: #fff; padding: 8px 12px; cursor: pointer; font-weight: 800; font-size: .82rem; color: var(--muted); user-select: none; }
.weekday-chip input { width: auto; min-height: auto; margin: 0; }
.weekday-chip:has(input:checked) { background: var(--green-soft); border-color: var(--green); color: var(--green-dark); }
.holiday-date-add { display: grid; grid-template-columns: 1fr auto; gap: 10px; align-items: end; }
.holiday-date-add .secondary-action { min-height: 44px; white-space: nowrap; }
.holiday-date-list { display: flex; flex-wrap: wrap; gap: 8px; }
.holiday-chip { display: inline-flex; align-items: center; gap: 8px; border: 1px solid var(--line); border-radius: 999px; background: #fff; padding: 6px 6px 6px 12px; font-weight: 800; font-size: .82rem; color: var(--ink); }
.holiday-chip-remove { width: 22px; height: 22px; border-radius: 50%; border: none; background: var(--red-soft); color: var(--red); font-weight: 900; line-height: 1; cursor: pointer; padding: 0; }
.holiday-empty { color: var(--muted); font-size: .82rem; margin: 0; }
.theme-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.theme-grid label { display: grid; grid-template-columns: 1fr 52px; align-items: center; gap: 10px; color: var(--muted); font-size: .82rem; font-weight: 850; }
.theme-grid input { width: 52px; min-height: 40px; padding: 4px; }

.action-panel { display: grid; grid-template-columns: 1fr auto; gap: 12px; align-items: end; margin-top: 16px; }
.filter-tabs { display: grid; grid-template-columns: repeat(4, minmax(72px, 1fr)); gap: 8px; }
.tab { min-height: 46px; border: 1px solid var(--line); border-radius: 8px; background: #fff; color: var(--muted); font-weight: 850; }
.tab.active { border-color: var(--green); background: var(--green); color: #fff; }

.member-section { margin-top: 16px; }
#monthLabel { flex: 0 0 auto; border-radius: 999px; background: var(--green-soft); color: var(--green); padding: 7px 10px; font-size: .78rem; font-weight: 850; }
.member-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.member-card { display: grid; gap: 10px; width: 100%; border: 1px solid var(--line); padding: 12px; text-align: left; }
.member-card-main {
  display: grid;
  grid-template-columns: 58px 1fr;
  gap: 12px;
  width: 100%;
  border: 0;
  background: transparent;
  padding: 0;
  text-align: left;
  color: inherit;
}
.member-card h3 { margin: 0 0 3px; font-size: 1rem; }
.member-card p { margin: 0; color: var(--muted); font-size: .86rem; }
.member-whatsapp-action {
  width: 100%;
  min-height: 40px;
  border: 0;
  border-radius: 8px;
  background: #25d366;
  color: #062d19;
  font-weight: 850;
}
.member-whatsapp-action:disabled {
  cursor: not-allowed;
  background: #eef2ef;
  color: var(--muted);
}

.trainer-section { margin-top: 16px; }
.trainer-toolbar {
  display: grid;
  grid-template-columns: 1fr minmax(180px, 240px);
  gap: 12px;
  align-items: end;
  margin-bottom: 14px;
}
.trainer-toolbar label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: .8rem;
  font-weight: 850;
}
.trainer-summary {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}
.trainer-summary article {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: linear-gradient(145deg, #fff, color-mix(in srgb, var(--green-soft) 50%, #fff));
  padding: 12px;
}
.trainer-summary span {
  display: block;
  color: var(--muted);
  font-size: .76rem;
  font-weight: 850;
}
.trainer-summary strong {
  display: block;
  margin-top: 5px;
  font-size: 1.45rem;
}
.trainer-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}
.trainer-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
  padding: 12px;
}
.trainer-card-main {
  display: grid;
  grid-template-columns: 58px 1fr;
  gap: 12px;
  width: 100%;
  border: 0;
  background: transparent;
  padding: 0;
  color: inherit;
  text-align: left;
}
.trainer-card-headline {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 3px;
}
.trainer-card h3 { margin: 0; font-size: 1rem; }
.trainer-card p { margin: 0 0 3px; color: var(--muted); font-size: .86rem; }
.trainer-card small { display: block; margin-top: 8px; color: var(--muted); line-height: 1.4; }
.trainer-card:hover { border-color: color-mix(in srgb, var(--green) 40%, var(--line)); }
.trainer-attendance-panel {
  border: 1px solid color-mix(in srgb, var(--blue) 18%, var(--line));
  border-radius: 8px;
  background: linear-gradient(145deg, #fff, color-mix(in srgb, var(--blue-soft) 45%, #fff));
  padding: 14px;
  margin-bottom: 14px;
}
.trainer-attendance-summary { margin-bottom: 12px; }
.trainer-attendance-list { display: grid; gap: 10px; }
.trainer-attendance-row {
  display: grid;
  grid-template-columns: 58px minmax(150px, 1fr) auto auto;
  gap: 12px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 12px;
}
.trainer-attendance-row.is-present { border-color: #b9dfc7; background: #fbfffc; }
.trainer-attendance-row h3 { margin: 0 0 2px; font-size: .98rem; }
.trainer-attendance-row p { margin: 0; color: var(--muted); font-size: .84rem; }
.member-badges { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.badge.overdue { background: var(--red-soft); color: var(--red); }
.badge.paid { background: var(--blue-soft); color: var(--blue); }
.badge.present { background: var(--green-soft); color: var(--green); }
.badge.pending { background: var(--gold-soft); color: var(--gold); }

.member-photo, .avatar-fallback, #detailPhoto, #photoPreview, #trainerPhotoPreview { width: 58px; height: 58px; border-radius: 8px; object-fit: cover; background: var(--green-soft); }
.avatar-fallback { display: grid; place-items: center; color: var(--green); font-size: 1.2rem; font-weight: 900; }
.empty-state { display: none; place-items: center; padding: 28px 18px; text-align: center; }
.empty-state.show { display: grid; }
.empty-avatar { display: grid; place-items: center; width: 66px; height: 66px; margin-bottom: 14px; border-radius: 50%; background: var(--green-soft); color: var(--green); font-size: 1.8rem; font-weight: 900; }
.empty-state p { max-width: 360px; color: var(--muted); }
.compact-empty { padding: 24px 16px; }

dialog { width: min(94vw, 720px); border: 0; border-radius: 12px; padding: 0; box-shadow: 0 24px 80px rgba(23,32,27,.26); }
dialog::backdrop { background: rgba(23,32,27,.42); }
.member-form { padding: 18px; }
.detail-panel {
  padding: 18px;
  background:
    linear-gradient(180deg, var(--green-soft), transparent 170px),
    var(--panel);
}
.dialog-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.detail-panel .dialog-head {
  align-items: center;
  border: 1px solid color-mix(in srgb, var(--green) 20%, var(--line));
  border-radius: 8px;
  background: color-mix(in srgb, var(--panel) 88%, var(--green-soft));
  padding: 12px;
}

.eyebrow { margin: 0 0 4px; color: var(--green); font-size: .76rem; font-weight: 900; text-transform: uppercase; letter-spacing: .08em; }
.icon-button { flex: 0 0 auto; width: 44px; height: 44px; border: 1px solid var(--line); border-radius: 8px; background: #fff; color: var(--ink); font-size: 1.5rem; line-height: 1; }
.photo-field { display: grid; grid-template-columns: 84px 1fr; gap: 14px; align-items: center; margin-bottom: 14px; }
#photoPreview, #trainerPhotoPreview { width: 84px; height: 84px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.form-grid .wide { grid-column: 1 / -1; }
.form-actions { display: flex; justify-content: space-between; gap: 10px; margin-top: 16px; }
.member-title { display: grid; grid-template-columns: 64px 1fr; gap: 12px; align-items: center; }
.member-title p { margin-bottom: 0; color: var(--muted); }
.detail-actions { display: grid; grid-template-columns: 1fr; gap: 10px; margin-bottom: 14px; }
.detail-actions .secondary-action { background: var(--panel); border-color: color-mix(in srgb, var(--green) 28%, var(--line)); }
.detail-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; margin-bottom: 16px; }
.detail-grid article {
  position: relative;
  min-height: 92px;
  padding: 14px;
  overflow: hidden;
  border: 1px solid color-mix(in srgb, var(--green) 16%, var(--line));
  background: linear-gradient(145deg, var(--panel), color-mix(in srgb, var(--green-soft) 68%, var(--panel)));
  box-shadow: none;
}
.detail-grid article::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 4px;
  background: var(--green);
}
.detail-grid article:nth-child(2)::before { background: var(--gold); }
.detail-grid article:nth-child(3)::before { background: var(--blue); }
.detail-grid article:nth-child(4)::before { background: var(--red); }
.detail-grid span { display: block; color: var(--muted); font-size: .78rem; font-weight: 900; }
.detail-grid strong { display: block; margin-top: 8px; font-size: 1.05rem; line-height: 1.2; }
.calendar-section, .payment-history { border-top: 1px solid var(--line); padding-top: 16px; }
.calendar-section .panel-head { margin-bottom: 10px; }
.calendar-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 8px; }
.day-cell {
  aspect-ratio: 1;
  min-height: 64px;
  border: 1px solid color-mix(in srgb, var(--green) 14%, var(--line));
  border-radius: 8px;
  background: linear-gradient(180deg, var(--panel), color-mix(in srgb, var(--bg) 58%, var(--panel)));
  color: var(--muted);
  font-weight: 900;
  box-shadow: 0 8px 18px rgba(16, 31, 24, 0.05);
}
.day-cell:hover { border-color: var(--green); color: var(--green); }
.day-cell.present {
  border-color: var(--green);
  background: linear-gradient(145deg, var(--green), color-mix(in srgb, var(--green) 72%, #ffffff));
  color: #fff;
}
.day-cell.today {
  outline: 3px solid color-mix(in srgb, var(--blue) 22%, transparent);
  border-color: var(--blue);
}
.payment-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: color-mix(in srgb, var(--panel) 92%, var(--green-soft));
  box-shadow: none;
}
.payment-row + .payment-row { margin-top: 8px; }
.payment-row span { color: var(--muted); }


@media (max-width: 1060px) {
  .dashboard-grid { grid-template-columns: 1fr; }
}

/* ---- Mobile app mode: fixed app bar + slide-in hamburger drawer ---- */
@media (max-width: 900px) {
  .dashboard-shell { grid-template-columns: 1fr; }

  .mobile-appbar {
    display: flex;
    align-items: center;
    gap: 10px;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 65;
    height: calc(56px + env(safe-area-inset-top));
    padding: env(safe-area-inset-top) max(14px, env(safe-area-inset-right)) 0 max(14px, env(safe-area-inset-left));
    background:
      radial-gradient(circle at 12% 0%, rgba(255, 255, 255, 0.14), transparent 40%),
      linear-gradient(160deg, var(--green-dark), var(--green-deep));
    color: #fff;
    box-shadow: 0 4px 18px rgba(5, 30, 21, 0.32);
  }

  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 60;
    width: min(84vw, 300px);
    height: 100vh;
    height: 100dvh;
    padding: calc(64px + env(safe-area-inset-top)) 16px calc(16px + env(safe-area-inset-bottom));
    border-radius: 0 18px 18px 0;
    box-shadow: 12px 0 40px rgba(5, 30, 21, 0.35);
    transform: translateX(-100%);
    transition: transform 340ms cubic-bezier(0.4, 0, 0.2, 1);
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    will-change: transform;
  }
  body.nav-open .sidebar { transform: translateX(0); }

  .side-nav { grid-template-columns: 1fr; }
  .side-nav a, .side-nav button { min-height: 48px; }

  .sidebar-scrim { display: block; }
  body.nav-open .sidebar-scrim { opacity: 1; pointer-events: auto; }
  body.nav-open { overflow: hidden; }

  .main-content {
    padding-top: calc(56px + env(safe-area-inset-top) + 14px);
    padding-left: max(14px, env(safe-area-inset-left));
    padding-right: max(14px, env(safe-area-inset-right));
    padding-bottom: calc(28px + env(safe-area-inset-bottom));
  }

  .toast { top: calc(60px + env(safe-area-inset-top)); z-index: 80; }

  /* the add button now lives in the fixed app bar */
  .topbar #openAddMember { display: none; }
}

@media (max-width: 760px) {
  .topbar, .topbar-actions, .panel-head { display: grid; align-items: stretch; }
  .stats-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .action-panel, .quick-actions-grid, .history-filters, .history-workspace, .payment-workspace, .trainer-toolbar { grid-template-columns: 1fr; }
  .member-list, .billing-card-grid, .trainer-list { grid-template-columns: 1fr; }
  .detail-actions, .detail-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 520px) {
  .main-content { padding-left: 10px; padding-right: 10px; }
  .stats-grid { gap: 8px; }
  .stat-card { min-height: 108px; padding: 14px 12px 12px 58px; }
  .stat-icon { left: 12px; top: 16px; width: 34px; height: 34px; }
  .stat-card strong { font-size: 1.55rem; }
  .filter-tabs { grid-template-columns: repeat(2, 1fr); }
  .attendance-row { grid-template-columns: 52px 1fr; }
  .attendance-status-cell, .attendance-actions { grid-column: 1 / -1; }
  .trainer-attendance-row { grid-template-columns: 52px 1fr; }
  .trainer-attendance-row .attendance-status, .trainer-attendance-row .attendance-button { grid-column: 1 / -1; }
  .attendance-actions, .attendance-confirm-actions { width: 100%; }
  .attendance-button { flex: 1; }
  .billing-card-head, .payment-detail-head { grid-template-columns: 52px 1fr; }
  .billing-card-head .badge, .compact-collect { grid-column: 1 / -1; }
  .form-grid, .detail-actions, .detail-grid, .history-stat-grid, .theme-grid, .trainer-summary { grid-template-columns: 1fr; }
  .day-cell { min-height: 48px; }
  dialog { width: 100vw; max-width: 100vw; min-height: 100dvh; border-radius: 0; }
  .member-form, .detail-panel, .fee-dialog-panel { padding: 14px; }
  .form-actions { position: sticky; bottom: 0; margin: 16px -14px -14px; padding: 10px 14px; background: #fff; border-top: 1px solid var(--line); }
  .fee-month-option { grid-template-columns: auto 1fr; }
  .fee-month-option strong { grid-column: 2; }
  .form-actions button { flex: 1; }
}

/* QR Check-in view */
.checkin-status-panel { margin-bottom: 16px; }
.checkin-status {
  display: flex;
  align-items: center;
  gap: 14px;
}
.checkin-status .status-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--muted);
  flex: none;
  box-shadow: 0 0 0 4px rgba(109, 119, 111, 0.15);
}
.checkin-status strong { display: block; }
.checkin-status p { margin: 2px 0 0; color: var(--muted); font-size: .86rem; }
.checkin-status #checkinRetry { margin-left: auto; }
.checkin-status[data-state="online"] .status-dot { background: var(--green); box-shadow: 0 0 0 4px var(--green-soft); }
.checkin-status[data-state="offline"] .status-dot { background: var(--red); box-shadow: 0 0 0 4px var(--red-soft); }
.checkin-status[data-state="online"] #checkinRetry { display: none; }

.checkin-grid {
  display: grid;
  grid-template-columns: minmax(280px, 360px) 1fr;
  gap: 16px;
  align-items: start;
}
.qr-frame {
  display: flex;
  justify-content: center;
  padding: 16px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 16px;
  margin: 4px 0 14px;
}
.qr-frame img { width: 100%; max-width: 260px; height: auto; image-rendering: pixelated; }
.checkin-url-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: var(--green-soft);
  border-radius: 12px;
  margin-bottom: 14px;
}
.checkin-url-row span {
  flex: 1;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: .82rem;
  word-break: break-all;
  color: var(--green-dark);
}
.checkin-url-row button { flex: none; }
.checkin-steps {
  margin: 0;
  padding-left: 18px;
  color: var(--muted);
  font-size: .88rem;
  line-height: 1.7;
}
.checkin-feed {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 60vh;
  overflow-y: auto;
}
.checkin-feed-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
}
.checkin-feed-row.is-new { border-color: var(--green); background: var(--green-soft); }
.checkin-feed-row .feed-avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: #d9f2e4;
  color: var(--green);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 850;
  flex: none;
}
.checkin-feed-row .feed-avatar.unknown { background: var(--red-soft); color: var(--red); }
.checkin-feed-row div { flex: 1; min-width: 0; }
.checkin-feed-row strong { display: block; }
.checkin-feed-row span { color: var(--muted); font-size: .82rem; }
.checkin-feed-row time { color: var(--muted); font-size: .82rem; white-space: nowrap; }

@media (max-width: 760px) {
  .checkin-grid { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  .view.active { animation: none; }
  .sidebar, .sidebar-scrim, .hamburger span,
  .stat-card, .member-card, .trainer-card, .primary-action, .secondary-action {
    transition: none !important;
  }
}
