/* ── BMD Parent Portal ────────────────────────────────────────────────────────
   Heritage Pulse palette, shared with the staff portal, but a warmer and much
   smaller sheet: this app is two pages on a phone, not an admin console.       */

:root {
  --bg: #f7f9fc;
  --card: #ffffff;
  --card-2: #f2f4f7;
  --ink: #191c1e;
  --muted: #3f4851;
  --faint: #6b7580;
  --accent: #006194;
  --accent-soft: #cce5ff;
  --gold: #fcab28;
  --green: #186a22;
  --line: #e6e8eb;
  --danger: #ba1a1a;
  --danger-soft: #ffdad6;
  --shadow: 0 1px 2px rgba(23,26,43,.04), 0 4px 16px rgba(23,26,43,.05);
  --shadow-lg: 0 8px 28px rgba(0,97,148,.16);
  --font-body: "Inter", -apple-system, "Segoe UI", Roboto, system-ui, sans-serif;
  --font-head: "Hanken Grotesk", var(--font-body);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; max-width: 100%; overflow-x: hidden; }
body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--ink);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  /* Atmospheric wash, matching the staff portal's login. */
  background-image:
    radial-gradient(60rem 40rem at 110% -10%, rgba(0,97,148,.07), transparent 60%),
    radial-gradient(45rem 35rem at -10% 110%, rgba(252,171,40,.10), transparent 60%);
  background-attachment: fixed;
}
a { color: var(--accent); }
button { font-family: inherit; }

.material-symbols-outlined {
  font-family: "Material Symbols Outlined"; font-weight: normal; font-style: normal;
  font-size: 24px; line-height: 1; display: inline-block; vertical-align: middle;
  font-variation-settings: 'FILL' 0, 'wght' 400, 'GRAD' 0, 'opsz' 24;
  -webkit-font-feature-settings: 'liga'; user-select: none;
}
.material-symbols-outlined.sm { font-size: 18px; }

/* ── Boot ─────────────────────────────────────────────────────────────────── */
.boot { min-height: 100vh; display: grid; place-items: center; }
.spinner {
  width: 30px; height: 30px; border-radius: 50%;
  border: 3px solid var(--accent-soft); border-top-color: var(--accent);
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Login / picker ───────────────────────────────────────────────────────── */
.login-host {
  min-height: 100vh; display: grid; place-items: center;
  padding: 24px 18px calc(24px + env(safe-area-inset-bottom));
}
.login-card {
  width: 100%; max-width: 400px; background: var(--card);
  border: 1px solid var(--line); border-radius: 20px; box-shadow: var(--shadow-lg);
  padding: 34px 26px 28px; text-align: center;
}
.login-logo { width: 68px; height: 68px; object-fit: contain; margin-bottom: 14px; }
.login-title {
  font-family: var(--font-head); font-size: 25px; font-weight: 800;
  color: var(--accent); margin: 0 0 4px; line-height: 1.2;
}
.login-sub { margin: 0 0 26px; color: var(--faint); font-size: 14px; }
.login-form { display: block; }
.login-label {
  display: block; font-size: 13px; font-weight: 600; color: var(--muted);
  margin-bottom: 12px;
}
.digits { display: flex; gap: 10px; justify-content: center; margin-bottom: 18px; }
.digit {
  width: 56px; height: 66px; text-align: center;
  font-family: var(--font-head); font-size: 28px; font-weight: 700; color: var(--ink);
  border: 2px solid var(--line); border-radius: 14px; background: var(--card-2);
  transition: border-color .15s, background .15s, box-shadow .15s;
}
.digit:focus {
  outline: none; border-color: var(--accent); background: #fff;
  box-shadow: 0 0 0 4px rgba(0,97,148,.12);
}
.login-err {
  margin: 0 0 16px; padding: 11px 13px; border-radius: 11px; text-align: left;
  background: var(--danger-soft); color: #7a1414; font-size: 13.5px; line-height: 1.45;
}
.login-help { margin: 20px 0 0; font-size: 13px; color: var(--faint); }

.btn {
  border: 1px solid var(--line); background: var(--card); color: var(--ink);
  border-radius: 12px; padding: 13px 18px; font-size: 15px; font-weight: 700;
  cursor: pointer; transition: background .15s, transform .06s, box-shadow .15s;
}
.btn:active { transform: scale(.985); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; box-shadow: 0 6px 16px rgba(0,97,148,.22); }
.btn.primary:hover { background: #007bb9; }
.btn.primary:disabled { opacity: .6; cursor: default; }
.btn.block { width: 100%; }
.linkbtn {
  background: none; border: none; color: var(--faint); font-size: 13.5px;
  text-decoration: underline; cursor: pointer; padding: 10px; margin-top: 8px;
}
.linkbtn:hover { color: var(--accent); }

.pick-list { display: flex; flex-direction: column; gap: 9px; margin-top: 4px; }
.pick-item {
  display: flex; align-items: center; gap: 13px; width: 100%; text-align: left;
  padding: 13px 15px; border: 1px solid var(--line); border-radius: 14px;
  background: var(--card-2); cursor: pointer; transition: border-color .15s, background .15s;
}
.pick-item:hover { border-color: var(--accent); background: #fff; }
.pick-avatar {
  width: 40px; height: 40px; flex: none; border-radius: 50%;
  display: grid; place-items: center; background: var(--accent-soft);
  color: var(--accent); font-weight: 800; font-size: 14px;
}
.pick-avatar.sm { width: 30px; height: 30px; font-size: 12px; }
.pick-name { flex: 1; font-weight: 700; font-size: 16px; }
.pick-chev { color: var(--faint); }

/* ── Shell ────────────────────────────────────────────────────────────────── */
.topbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 11px 16px; padding-top: calc(11px + env(safe-area-inset-top));
  background: rgba(255,255,255,.92); backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.tb-brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.tb-logo { width: 34px; height: 34px; object-fit: contain; flex: none; }
.tb-brandtext { display: flex; flex-direction: column; line-height: 1.15; min-width: 0; }
.tb-name { font-family: var(--font-head); font-weight: 800; font-size: 16px; color: var(--accent); }
.tb-sub { font-size: 11px; color: var(--faint); }

.camper-chip {
  display: flex; align-items: center; gap: 9px; flex: none;
  border: 1px solid var(--line); background: var(--card); border-radius: 999px;
  padding: 5px 10px 5px 5px; cursor: default; max-width: 58vw;
}
.camper-chip:disabled { opacity: 1; color: var(--ink); }
.camper-chip.switchable { cursor: pointer; }
.camper-chip.switchable:hover { border-color: var(--accent); }
.chip-avatar {
  width: 32px; height: 32px; flex: none; border-radius: 50%;
  display: grid; place-items: center; background: var(--accent); color: #fff;
  font-weight: 800; font-size: 12px;
}
.chip-text { display: flex; flex-direction: column; line-height: 1.15; min-width: 0; text-align: left; }
.chip-name { font-weight: 700; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chip-sub { font-size: 11px; color: var(--faint); }
.chip-chev { color: var(--faint); font-size: 20px; }

.switch-menu {
  position: absolute; right: 14px; top: calc(100% + 6px); z-index: 50;
  background: var(--card); border: 1px solid var(--line); border-radius: 14px;
  box-shadow: var(--shadow-lg); padding: 6px; min-width: 180px;
  display: flex; flex-direction: column; gap: 2px;
}
.switch-item {
  display: flex; align-items: center; gap: 10px; width: 100%; text-align: left;
  padding: 9px 11px; border: none; background: none; border-radius: 10px;
  font-size: 14.5px; font-weight: 600; cursor: pointer;
}
.switch-item:hover { background: var(--card-2); }
.switch-item.on { color: var(--accent); }
.switch-item .material-symbols-outlined:last-child { margin-left: auto; }

.tabs {
  position: sticky; top: 0; z-index: 20;
  display: flex; gap: 4px; padding: 10px 14px 0;
  max-width: 940px; margin: 0 auto;
}
.tab {
  flex: 1; display: flex; align-items: center; justify-content: center; gap: 7px;
  padding: 11px 10px; border-radius: 12px 12px 0 0; text-decoration: none;
  color: var(--muted); font-size: 14.5px; font-weight: 600;
  border-bottom: 3px solid transparent; transition: color .15s, background .15s;
}
.tab:hover { background: rgba(0,97,148,.05); }
.tab.active { color: var(--accent); font-weight: 800; border-bottom-color: var(--accent); }
.tab .material-symbols-outlined { font-size: 21px; }

.content {
  max-width: 940px; margin: 0 auto; padding: 22px 16px 8px;
  min-height: 46vh;
}
/* The Pictures page only — a gallery capped at 940px fits just three photos a row. */
.content.wide { max-width: 1500px; }
.page-head { margin-bottom: 18px; }
.page-head h2 {
  font-family: var(--font-head); font-size: 26px; font-weight: 800;
  margin: 0 0 4px; letter-spacing: -.01em;
}
.page-head p { margin: 0; color: var(--faint); font-size: 14.5px; }

.card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: 16px; box-shadow: var(--shadow); padding: 18px;
}
.kv { display: flex; flex-direction: column; gap: 2px; }
.kv-row { display: flex; justify-content: space-between; gap: 16px; padding: 9px 0; border-bottom: 1px solid var(--line); }
.kv-row:last-child { border-bottom: none; }
.kv-k { color: var(--faint); font-size: 13.5px; }
.kv-v { font-weight: 700; font-size: 14.5px; text-align: right; }

.soon {
  margin-top: 16px; text-align: center; padding: 46px 24px;
  background: var(--card); border: 1px dashed #cfd6de; border-radius: 18px;
}
.soon-icon { font-size: 46px; color: var(--accent); opacity: .55; }
.soon h3 { font-family: var(--font-head); font-size: 19px; margin: 12px 0 6px; }
.soon p { margin: 0 auto; max-width: 42ch; color: var(--faint); font-size: 14.5px; line-height: 1.55; }

.foot {
  max-width: 940px; margin: 0 auto; text-align: center;
  padding: 28px 20px calc(30px + env(safe-area-inset-bottom));
}
.foot p { margin: 0 auto; max-width: 56ch; font-size: 12px; color: var(--faint); line-height: 1.6; }

/* ── Tipping ──────────────────────────────────────────────────────────────── */
.tip-hero { margin-bottom: 20px; }
.tip-hero h2 {
  font-family: var(--font-head); font-size: 26px; font-weight: 800;
  margin: 0 0 3px; letter-spacing: -.015em; color: var(--accent);
}
.tip-hero-bunk { color: var(--faint); font-weight: 700; }
.tip-hero p { margin: 0; font-size: 14px; color: var(--faint); }
.tip-progress { margin-top: 3px !important; color: var(--green) !important; font-weight: 600; }

/* One quiet heading per role; the context rides alongside, not below. */
.tip-sect {
  display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap;
  font-family: var(--font-head); font-size: 12.5px; font-weight: 800;
  text-transform: uppercase; letter-spacing: .07em;
  color: var(--faint); margin: 24px 0 8px;
}
.tip-sect-ctx {
  font-family: var(--font-body); font-size: 12px; font-weight: 500;
  text-transform: none; letter-spacing: 0; color: var(--faint); opacity: .85;
}
.tip-suggest-line { margin: -4px 0 8px; font-size: 13px; font-weight: 700; color: var(--green); }

.tip-cards {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 12px;
}
.tipcard {
  background: var(--card); border: 1px solid var(--line); border-radius: 16px;
  box-shadow: var(--shadow); padding: 14px;
  display: flex; flex-direction: column; gap: 10px;
  transition: border-color .15s, background .15s;
}
.tipcard.tipped { border-color: #b9dcc0; background: #f7fbf8; }

.tipcard-head { display: flex; align-items: center; gap: 11px; }
.tipcard-photo { width: 40px; height: 40px; flex: none; border-radius: 50%; object-fit: cover; }
.tipcard-who { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.tipcard-name {
  font-family: var(--font-head); font-weight: 800; font-size: 16.5px;
  color: var(--ink); line-height: 1.25;
}
.tipcard-ctx { font-size: 12px; color: var(--faint); }
.tipcard-check {
  display: flex; align-items: center; gap: 5px; flex: none; cursor: pointer;
  font-size: 11.5px; color: var(--faint);
}
.tipcard-check input { width: 18px; height: 18px; accent-color: var(--green); }
.tipcard-note { margin: 0; font-size: 12.5px; color: var(--muted); }
.tipcard-thanks {
  margin: 0; padding-left: 10px; border-left: 3px solid var(--accent-soft);
  font-size: 13px; color: var(--muted); font-style: italic;
}

/* Payment rows: uniform mark, label + handle stacked inside, action hint right. */
.paylist { display: flex; flex-direction: column; gap: 7px; }
.paybtn {
  display: flex; align-items: center; gap: 11px; width: 100%;
  padding: 10px 12px; border-radius: 11px;
  border: 1px solid var(--line); background: var(--card-2);
  color: var(--ink); font-family: inherit; text-decoration: none;
  cursor: pointer; text-align: left;
  transition: border-color .12s, background .12s, transform .06s;
}
.paybtn:hover { border-color: var(--accent); background: #fff; }
.paybtn:active { transform: scale(.995); }
.paybtn.pref { background: #fff; border-color: #cfd8e3; box-shadow: 0 1px 2px rgba(23,26,43,.05); }
.paymark { flex: none; display: block; border-radius: 6px; }
.paytext { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.25; }
.paylabel { font-size: 14.5px; font-weight: 700; }
.payhandle {
  font-size: 12px; color: var(--faint);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.paypref {
  flex: none; font-size: 10px; font-weight: 800; text-transform: uppercase;
  letter-spacing: .06em; color: var(--faint);
}
.paychev { flex: none; font-size: 18px; color: #aab3bd; }

.tip-actions { margin-top: 26px; }
.tip-actions .btn { display: inline-flex; align-items: center; gap: 8px; }
.tip-foot { margin: 12px 0 0; font-size: 12px; color: var(--faint); }

@media print {
  .topbar, .tabs, .foot, .tip-actions, .tipcard-check, .paychev { display: none !important; }
  body { background: #fff; }
  .tipcard { break-inside: avoid; box-shadow: none; }
  .tip-cards { grid-template-columns: 1fr 1fr; }
}

/* ── Pictures gallery ─────────────────────────────────────────────────────── */
.gal-head { margin-bottom: 14px; }
.gal-head h2 {
  font-family: var(--font-head); font-size: 26px; font-weight: 800;
  margin: 0 0 3px; letter-spacing: -.015em; color: var(--accent);
}
.gal-head p { margin: 0; font-size: 14px; color: var(--faint); }

/* Justified rows, as in Google Photos: every row fills the width edge to edge,
   photos keep their proportions, and the gaps are hairline.
   Each tile grows in proportion to its aspect ratio (--ar), with a basis of
   ar x row-height, so a row's tiles share the width the way their shapes want.
   The ::after spacer stops a short last row from stretching across the page. */
.gal-grid {
  --row-h: 170px;
  display: flex; flex-wrap: wrap; gap: 4px;
}
.gal-grid::after { content: ""; flex-grow: 999999; }
.gal-tile {
  position: relative; height: var(--row-h);
  flex-grow: var(--ar, 1.333);
  flex-basis: calc(var(--ar, 1.333) * var(--row-h));
  padding: 0; border: none; border-radius: 3px; overflow: hidden;
  background: var(--card-2); cursor: pointer;
  transition: filter .12s;
}
.gal-tile img { width: 100%; height: 100%; object-fit: cover; display: block; }
.gal-tile:hover { filter: brightness(1.06); }
.gal-tile:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

@media (min-width: 1000px) { .gal-grid { --row-h: 185px; } }

.gal-more {
  margin-top: 20px; display: flex; flex-direction: column;
  align-items: center; gap: 8px;
}
.gal-spinner {
  width: 22px; height: 22px; border-radius: 50%;
  border: 2px solid var(--accent-soft); border-top-color: var(--accent);
  animation: spin .8s linear infinite;
}
.gal-count { margin: 0; font-size: 13px; color: var(--faint); }
.gal-foot { margin: 22px 0 0; font-size: 12.5px; color: var(--faint); line-height: 1.6; }

/* ── Full-size viewer ─────────────────────────────────────────────────────── */
body.no-scroll { overflow: hidden; }
.viewer {
  position: fixed; inset: 0; z-index: 200; background: rgba(10,13,16,.94);
  display: flex; flex-direction: column;
  padding-top: env(safe-area-inset-top); padding-bottom: env(safe-area-inset-bottom);
}
.vw-bar {
  display: flex; align-items: center; gap: 8px; padding: 10px 14px; flex-wrap: wrap;
}
.vw-count { color: #cfd6dd; font-size: 13px; }
.vw-btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 9px 13px; border-radius: 10px; cursor: pointer;
  border: 1px solid rgba(255,255,255,.22); background: rgba(255,255,255,.08);
  color: #fff; font-family: inherit; font-size: 13.5px; font-weight: 700;
  text-decoration: none;
}
.vw-btn:hover { background: rgba(255,255,255,.16); }
.vw-btn.danger { border-color: rgba(255,140,130,.45); color: #ffb3ab; }
.vw-close {
  display: grid; place-items: center; width: 38px; height: 38px; border-radius: 10px;
  border: 1px solid rgba(255,255,255,.22); background: rgba(255,255,255,.08);
  color: #fff; cursor: pointer;
}
.vw-stage {
  flex: 1; min-height: 0; position: relative;
  display: flex; align-items: center; justify-content: center; padding: 0 8px 14px;
}
.vw-img {
  max-width: 100%; max-height: 100%; object-fit: contain;
  border-radius: 10px; background: #000;
}
.vw-nav {
  position: absolute; top: 50%; transform: translateY(-50%);
  display: grid; place-items: center; width: 44px; height: 44px; border-radius: 50%;
  border: 1px solid rgba(255,255,255,.2); background: rgba(20,24,28,.72);
  color: #fff; cursor: pointer;
}
.vw-nav.prev { left: 10px; }
.vw-nav.next { right: 10px; }
.vw-nav:disabled { opacity: .28; cursor: default; }

@media (max-width: 460px) {
  .gal-grid { --row-h: 130px; gap: 3px; }
  .gal-head h2 { font-size: 22px; }
}

/* ── Toast ────────────────────────────────────────────────────────────────── */
#toast {
  position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 20px);
  background: var(--ink); color: #fff; padding: 12px 18px; border-radius: 12px;
  font-size: 14px; box-shadow: var(--shadow-lg); z-index: 100;
  opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s;
  max-width: calc(100vw - 40px);
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }
#toast.err { background: var(--danger); }

/* ── Small screens ────────────────────────────────────────────────────────── */
@media (max-width: 460px) {
  .digit { width: 52px; height: 62px; font-size: 26px; }
  .login-card { padding: 28px 20px 24px; }
  .page-head h2 { font-size: 22px; }
  .tb-sub { display: none; }
}
