/* Colors are tokens here, with dark-mode overrides below. */
:root {
  --bg: #f4f5f7;
  --card: #ffffff;
  --text: #1c2230;
  --muted: #667085;
  --line: #e3e6eb;
  --accent: #e4572e;
  --accent-text: #ffffff;
  --accent-soft: #fde8e1;
  --warn-bg: #fff6db;
  --warn-line: #f0d27a;
  --error: #c0362c;
  --ok: #1f7a4d;
  --ok-bg: #e2f4ea;
  --demo-bg: #2f3a52;
  --demo-text: #ffffff;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .08);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #12151c;
    --card: #1c212b;
    --text: #e9ecf2;
    --muted: #9aa3b5;
    --line: #2c3340;
    --accent: #ff7a52;
    --accent-text: #1a0d08;
    --accent-soft: #3a2219;
    --warn-bg: #3a3118;
    --warn-line: #6b5a24;
    --error: #ff7b70;
    --ok: #5fd39a;
    --ok-bg: #173a29;
    --demo-bg: #3b4a6b;
    --shadow: none;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #12151c;
  --card: #1c212b;
  --text: #e9ecf2;
  --muted: #9aa3b5;
  --line: #2c3340;
  --accent: #ff7a52;
  --accent-text: #1a0d08;
  --accent-soft: #3a2219;
  --warn-bg: #3a3118;
  --warn-line: #6b5a24;
  --error: #ff7b70;
  --ok: #5fd39a;
  --ok-bg: #173a29;
  --demo-bg: #3b4a6b;
  --shadow: none;
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
#app {
  max-width: 640px;
  margin: 0 auto;
  padding: 0 16px 160px;
}
a { color: var(--accent); }
h1, h2, h3 { line-height: 1.2; }

.muted { color: var(--muted); }
.small { font-size: 14px; }
.center { text-align: center; }
.grow { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.grow strong, .grow span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.empty { text-align: center; color: var(--muted); padding: 32px 8px; list-style: none; }
.error { color: var(--error); margin: 0; font-size: 15px; }

.demo {
  margin: 0 -16px;
  padding: 6px 16px;
  background: var(--demo-bg);
  color: var(--demo-text);
  font-size: 13px;
  text-align: center;
}

/* Top bar */
.top {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 0;
}
.top h1 { flex: 1; margin: 0; font-size: 20px; text-align: center; }
.icon-btn {
  width: 40px; height: 40px;
  display: grid; place-items: center;
  border-radius: 10px;
  color: var(--text);
  text-decoration: none;
  font-size: 24px;
}
a.icon-btn:active { background: var(--line); }
.icon-btn.refresh { border: 0; background: none; cursor: pointer; font: inherit; font-size: 22px; color: var(--muted); }
.icon-btn.refresh:active { background: var(--line); }

/* Cards and forms */
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px 16px;
  margin: 0;
  box-shadow: var(--shadow);
}
.card.warn { background: var(--warn-bg); border-color: var(--warn-line); }
.card.pre { white-space: pre-wrap; overflow-wrap: anywhere; }
.card p { margin: 0; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 360px) { .two { grid-template-columns: 1fr; } }
.section {
  margin: 20px 4px 8px;
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--muted);
}
form.stack > .section { margin-bottom: -4px; }

label { display: flex; flex-direction: column; gap: 4px; font-size: 14px; font-weight: 600; min-width: 0; }
input, textarea, select {
  width: 100%;
  font: inherit;
  font-weight: 400;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
  min-height: 44px;
}
input:focus, textarea:focus, select:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
textarea { resize: vertical; }
label.check { flex-direction: row; align-items: center; flex-wrap: wrap; gap: 8px; font-weight: 400; font-size: 16px; }
label.check input { width: 22px; height: 22px; min-height: 0; accent-color: var(--accent); }

.btn {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 44px;
  padding: 0 18px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--text);
  font: inherit;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
}
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.btn:disabled { opacity: .6; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }
.actions.end { justify-content: flex-end; margin-top: 8px; }

/* Sign in */
.login { padding-top: 48px; text-align: center; }
.login h1 { margin: 12px 0 4px; }
.login form { text-align: left; margin-top: 24px; }
.logo {
  width: 64px; height: 64px; margin: 0 auto;
  display: grid; place-items: center;
  border-radius: 18px;
  background: var(--accent); color: var(--accent-text);
  font-weight: 800; font-size: 24px;
}

/* Member list */
.tools { display: flex; flex-direction: column; gap: 10px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--text);
  border-radius: 999px;
  padding: 6px 14px;
  font: inherit; font-size: 14px;
  cursor: pointer;
}
.chip.on { background: var(--accent-soft); border-color: var(--accent); color: var(--text); font-weight: 600; }
#count { margin: 12px 4px 6px; }
.list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.row {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 14px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  color: var(--text);
  text-decoration: none;
  box-shadow: var(--shadow);
}
.row:active { background: var(--line); }
.avatar {
  flex: none;
  width: 42px; height: 42px;
  display: grid; place-items: center;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 700;
  text-transform: uppercase;
}
.avatar.big { width: 72px; height: 72px; font-size: 26px; margin: 0 auto; }
.tag {
  flex: none;
  font-size: 12px; font-weight: 600;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--line);
  color: var(--muted);
}
button.row { width: 100%; font: inherit; text-align: left; cursor: pointer; }
button.row:disabled { opacity: .5; }
li.row { padding: 0 4px 0 0; }
.row-link {
  flex: 1; min-width: 0;
  display: flex; align-items: center; gap: 12px;
  padding: 10px 0 10px 14px;
  color: var(--text); text-decoration: none;
}
.icon-btn.remove { border: 0; background: none; color: var(--muted); font-size: 18px; cursor: pointer; }
.icon-btn.remove:active { background: var(--line); }
.add { flex: none; color: var(--accent); font-weight: 700; font-size: 14px; }
.tag.full { background: var(--warn-bg); color: var(--text); border: 1px solid var(--warn-line); }
.section .tag { margin-left: 6px; text-transform: none; letter-spacing: 0; vertical-align: 1px; }
.faded .row { opacity: .65; }

/* Bottom tabs on the main screens */
.tabs {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  display: flex;
  justify-content: center;
  background: var(--card);
  border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
  z-index: 5;
}
.tab {
  flex: 1;
  max-width: 320px;
  padding: 14px 0;
  text-align: center;
  color: var(--muted);
  font-weight: 600;
  text-decoration: none;
  border-top: 3px solid transparent;
}
.tab.on { color: var(--accent); border-top-color: var(--accent); }

.fab {
  position: fixed;
  z-index: 6;
  right: max(16px, calc(50% - 304px));
  bottom: calc(76px + env(safe-area-inset-bottom));
  padding: 14px 20px;
  border-radius: 999px;
  background: var(--accent);
  color: var(--accent-text);
  font-weight: 700;
  text-decoration: none;
  box-shadow: 0 4px 14px rgba(0, 0, 0, .2);
}

/* One member */
.hero { text-align: center; padding: 8px 0 4px; }
.hero h2 { margin: 10px 0 6px; overflow-wrap: anywhere; }
.hero .actions { margin-top: 14px; }
.field { display: flex; gap: 12px; padding: 6px 0; }
.field + .field { border-top: 1px solid var(--line); }
.field dt { flex: none; width: 104px; color: var(--muted); font-size: 14px; padding-top: 1px; }
.field dd { margin: 0; flex: 1; min-width: 0; overflow-wrap: anywhere; }

/* Member page: their classes */
.plain { list-style: none; margin: 0 0 12px; padding: 0; }
.line {
  display: flex; flex-direction: column;
  padding: 8px 0;
  color: var(--text); text-decoration: none;
}
.plain li + li .line { border-top: 1px solid var(--line); }
.small-btn { min-height: 40px; font-size: 15px; }

/* Class form: day picker */
.days { border: 0; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; min-width: 0; }
.days legend { font-size: 14px; font-weight: 600; padding: 0; margin-bottom: 6px; }
.day { flex-direction: row; font-weight: 600; font-size: 13px; min-width: 0; }
.day input { position: absolute; opacity: 0; width: 1px; height: 1px; min-height: 0; }
.day span {
  display: grid; place-items: center;
  width: 100%; height: 44px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--bg);
  cursor: pointer;
}
.day input:checked + span { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.day input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 1px; }

/* Payments */
.owes { color: var(--error); font-weight: 600; }
.paid { color: var(--ok); font-weight: 600; }
.tag.ok { background: var(--ok-bg); color: var(--ok); }
.pay-list { margin-top: 8px; border-top: 1px solid var(--line); }
.pay-row { display: flex; align-items: center; gap: 8px; padding: 6px 0; }
.pay-row + .pay-row { border-top: 1px solid var(--line); }
.pay-row .grow span, .grow span.wrap { white-space: normal; }
.family-plan { margin: 8px 0; padding-top: 8px; border-top: 1px solid var(--line); }
.family-plan .pay-row a { color: inherit; }
.pay-none { margin: 8px 0 12px !important; }
.card .small-btn { margin-top: 4px; }
.month-bar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.month-bar strong { font-size: 18px; }
.month-bar .icon-btn { border: 1px solid var(--line); background: var(--card); cursor: pointer; font: inherit; font-size: 22px; }
.totals { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.totals div { display: flex; flex-direction: column; }
.totals strong { font-size: 22px; }
.methods { border: 0; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; min-width: 0; }
.methods legend { font-size: 14px; font-weight: 600; padding: 0; margin-bottom: 6px; }
.method { flex-direction: row; min-width: 0; }
.method input { position: absolute; opacity: 0; width: 1px; height: 1px; min-height: 0; }
.method span {
  display: grid; place-items: center;
  width: 100%; height: 44px;
  border: 1px solid var(--line); border-radius: 10px;
  background: var(--bg); cursor: pointer;
}
.method input:checked + span { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.method input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 1px; }

/* Toast */
#toast {
  position: fixed;
  z-index: 7;
  left: 50%; bottom: calc(140px + env(safe-area-inset-bottom));
  transform: translate(-50%, 20px);
  max-width: calc(100% - 32px);
  padding: 10px 16px;
  border-radius: 10px;
  background: var(--text); color: var(--bg);
  font-size: 15px;
  opacity: 0; pointer-events: none;
  transition: opacity .2s, transform .2s;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }

/* Backup list on the account screen */
.backup-list { margin: 0; }
.backup-list .pay-row { padding: 8px 0; }
.backup-list .small-btn { margin: 0; flex: none; }

/* Member page: their classes don't match their plan */
.mismatch {
  margin: 0 0 8px !important;
  padding: 8px 10px;
  border-radius: 10px;
  background: var(--warn-bg);
  border: 1px solid var(--warn-line);
  font-size: 14px;
}

/* Member page: medical conditions at the top */
.card.medical { background: var(--warn-bg); border-color: var(--warn-line); margin-top: 12px; overflow-wrap: anywhere; }

/* Member form: city, state, zip on one row */
.city-row { display: grid; grid-template-columns: 2fr 1fr 1fr; gap: 12px; }
@media (max-width: 360px) { .city-row { grid-template-columns: 1fr 1fr; } .city-row label:first-child { grid-column: 1 / -1; } }

/* Waivers */
.actions.start { justify-content: flex-start; margin-top: 10px; }
.link-btn { border: 0; background: none; color: var(--accent); font: inherit; font-size: 14px; font-weight: 600; cursor: pointer; padding: 4px; }
.pad-label { display: flex; justify-content: space-between; align-items: center; font-size: 14px; margin-bottom: 4px; }
.sig-pad {
  display: block;
  width: 100%;
  height: 150px;
  background: #fff;                 /* always white, like paper, even in dark mode */
  border: 2px dashed var(--line);
  border-radius: 10px;
  touch-action: none;               /* let fingers draw instead of scrolling the page */
  cursor: crosshair;
}
.waiver-text { max-height: 50vh; overflow-y: auto; font-size: 14px; line-height: 1.5; }
.waiver-text p { margin: 0 0 10px !important; }
.waiver-gym { text-align: center; font-weight: 800; letter-spacing: .04em; }
.waiver-title { text-align: center; margin: 0 0 10px; font-size: 16px; }
.printable { max-height: none; }
.sig-block { display: flex; flex-direction: column; gap: 4px; margin: 12px 0; }
.sig-img { width: 100%; max-width: 360px; background: #fff; border: 1px solid var(--line); border-radius: 8px; }
.photo-btn { position: relative; overflow: hidden; }
.photo-btn input { position: absolute; inset: 0; opacity: 0; cursor: pointer; min-height: 0; }
.paper-preview { width: 100%; border-radius: 10px; border: 1px solid var(--line); }

/* Printing a signed waiver: just the waiver, on white */
@media print {
  body { background: #fff; color: #000; }
  .top, .tabs, .demo, .fab, #toast, .btn, .muted.small.center { display: none !important; }
  .card { border: 0; box-shadow: none; padding: 0; background: #fff; }
  .waiver-text { max-height: none; overflow: visible; font-size: 12pt; }
  /* Class roster on paper: plain rows, no avatars or remove buttons, tags kept readable. */
  .roster .avatar, .roster .remove { display: none !important; }
  .roster .row { border: 0; border-bottom: 1px solid #999; border-radius: 0; box-shadow: none; padding: 6px 0; break-inside: avoid; }
  .roster .tag { border: 1px solid #000; background: #fff; color: #000; }
  .roster .muted, .roster .medical { color: #000; }
  .print-only { display: block !important; }
}
.print-only { display: none; }

/* Delete buttons */
.btn.danger { color: var(--error); border-color: var(--error); background: var(--card); align-self: flex-start; }

/* Class form: one row per day with its own start and end time */
.sessions { border: 0; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.sessions legend { font-size: 14px; font-weight: 600; padding: 0; margin-bottom: 6px; }
.session-row { display: grid; grid-template-columns: 50px 1fr auto 1fr; align-items: center; gap: 4px; min-width: 0; }
.session-row .day span { width: 50px; }
.session-row input[type=time] { min-width: 0; padding: 6px 4px; font-size: 14px; }
.session-row .to { font-size: 13px; color: var(--muted); }
.session-row:not(.on) input[type=time], .session-row:not(.on) .to { visibility: hidden; }

/* Member page: paused plan */
.pause-banner {
  display: flex; flex-direction: column; gap: 2px;
  margin-bottom: 8px; padding: 10px 12px;
  border-radius: 10px;
  background: var(--accent-soft);
  border: 1px solid var(--accent);
}
.pause-banner .actions { margin-top: 6px; }

/* Front desk mode (iPad sign-up station) */
.kiosk-welcome { text-align: center; padding: 56px 8px 24px; display: flex; flex-direction: column; align-items: center; gap: 14px; }
.kiosk-welcome h1 { margin: 8px 0 0; font-size: 28px; }
.kiosk-welcome p { margin: 0; max-width: 460px; font-size: 18px; color: var(--muted); }
.btn.big { min-height: 56px; padding: 0 36px; font-size: 20px; border-radius: 14px; }
.kiosk-staff { margin-top: 48px; }
.kiosk-staff .link-btn { color: var(--muted); font-weight: 400; }
.done-check {
  width: 84px; height: 84px; display: grid; place-items: center;
  border-radius: 50%; background: var(--ok-bg); color: var(--ok);
  font-size: 44px; font-weight: 800;
}
.programs { grid-template-columns: repeat(3, 1fr); }
.programs legend { font-weight: 400; margin-bottom: 8px; }
.tag.new { background: var(--accent-soft); color: var(--accent); }
.card.review { background: var(--accent-soft); border-color: var(--accent); margin-top: 12px; }

/* Tablet form: the parent section stands out once the birthday shows they're under 18 */
.guardian-card.required { background: var(--accent-soft); border-color: var(--accent); }

/* Front desk tablet: language buttons and the Spanish reference translation note */
.lang-buttons { gap: 12px; margin-top: 8px; }
.ref-note {
  margin: 0 0 12px !important;
  padding: 8px 10px;
  border-radius: 8px;
  background: var(--warn-bg);
  border: 1px solid var(--warn-line);
  font-size: 14px;
}

/* Front desk tablet: welcome buttons per language, and the family form's child cards */
.lang-columns { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; width: 100%; max-width: 560px; margin-top: 8px; }
.lang-columns .stack { gap: 10px; }
.lang-columns .btn.big { font-size: 18px; padding: 0 16px; }
@media (max-width: 480px) { .lang-columns { grid-template-columns: 1fr; } }
.child-head { display: flex; justify-content: space-between; align-items: center; }
.child-title { font-size: 17px; }

/* Member edit screen: delete section */
.danger-card { border-color: var(--error); }
.btn.danger:disabled { opacity: .4; cursor: not-allowed; }

/* Bottom tabs: four of them, with a count on Follow-ups */
.tab { font-size: 15px; padding: 14px 2px; white-space: nowrap; }
.tab-badge {
  display: inline-block; min-width: 20px; padding: 0 6px; margin-left: 2px;
  border-radius: 999px; background: var(--accent); color: var(--accent-text);
  font-size: 12px; line-height: 20px; text-align: center; vertical-align: 1px;
}

/* Follow-ups list */
.follow-list { margin-top: 12px; }
.follow-tags { display: flex; flex-wrap: wrap; gap: 4px; margin: 3px 0; }
.call-btn { flex: none; margin-right: 8px; min-height: 40px; }

/* Merging duplicates */
.row.picked { border-color: var(--accent); background: var(--accent-soft); }
.merge-preview { border-color: var(--accent); }
.merge-list { margin: 0; padding-left: 18px; display: flex; flex-direction: column; gap: 4px; }

/* Money report (js/report.js) */
.report-link { display: block; text-align: center; margin: 10px 0 4px; }
.report-hero { display: flex; flex-direction: column; gap: 2px; }
.report-hero strong { font-size: 32px; line-height: 1.15; }
.row-card { display: flex; align-items: center; gap: 8px; color: var(--text); text-decoration: none; }
.bar-rows { margin: 0; }
.bar-rows li { display: grid; grid-template-columns: 7.5em 1fr auto; align-items: center; gap: 8px; padding: 5px 0; }
.bar-label { font-size: 14px; overflow-wrap: anywhere; }
.bar-track { height: 10px; border-radius: 4px; background: var(--line); overflow: hidden; }
.bar-fill { display: block; height: 100%; border-radius: 4px; background: var(--accent); }
.bar-value { font-size: 14px; font-variant-numeric: tabular-nums; text-align: right; }
.trend { display: grid; grid-template-columns: repeat(6, 1fr); gap: 6px; height: 150px; align-items: end; }
.trend-col { display: flex; flex-direction: column; justify-content: flex-end; align-items: center; height: 100%; min-width: 0; }
.trend-bar { width: 70%; max-width: 36px; min-height: 2px; border-radius: 4px 4px 0 0; background: var(--accent); opacity: .4; }
.trend-col.on .trend-bar { opacity: 1; }
.trend-value { font-size: 11px; color: var(--muted); margin-bottom: 3px; white-space: nowrap; font-variant-numeric: tabular-nums; }
.trend-month { font-size: 12px; color: var(--muted); margin-top: 4px; border-top: 1px solid var(--line); width: 100%; text-align: center; padding-top: 3px; }
.trend-col.on .trend-month, .trend-col.on .trend-value { color: var(--text); font-weight: 600; }

/* Class roster (js/classes.js) */
.roster-summary { margin: 0 0 8px; font-weight: 600; font-size: 14px; }
.warn-text { color: var(--text); background: var(--warn-bg); border: 1px solid var(--warn-line); border-radius: 10px; padding: 8px 10px; }
.medical { color: var(--text); }
