/* Vaquero on-site sales — one stylesheet, no build step.
   Mobile-first; widens gracefully on iPad/desktop. */

/* Palette and type taken from the live storefront, beautymix-studio.com:
   headings/nav #4F3F2F · body #74685C · prices #917052 · white background,
   Volkhov (serif) headings + Roboto body. The old navy/gold names are kept as
   aliases so existing rules keep working without a sweeping rename. */
@import url('https://fonts.googleapis.com/css2?family=Volkhov:ital,wght@0,400;0,700;1,400&family=Roboto:wght@300;400;500;700&display=swap');

:root {
  --brown: #4f3f2f;         /* primary — headings, nav, app bar */
  --brown-dark: #3a2e22;
  --brown-soft: #6b5744;
  --bronze: #917052;        /* accent — prices, calls to action */
  --bronze-light: #b89273;
  --taupe: #74685c;         /* body copy */

  /* Aliases so pre-existing --navy/--gold rules pick up the real brand. */
  --navy: var(--brown);
  --navy-dark: var(--brown-dark);
  --navy-soft: var(--brown-soft);
  --gold: var(--bronze);
  --gold-light: var(--bronze-light);

  --ink: #4f3f2f;
  --muted: #74685c;
  --line: #e7e1d9;
  --bg: #faf8f5;            /* warm off-white, closer to the storefront */
  --card: #ffffff;
  --ok: #1c7a4a;
  --warn: #a8341c;
  --radius: 14px;
  --shadow: 0 1px 3px rgba(79, 63, 47, 0.08), 0 6px 18px rgba(79, 63, 47, 0.07);
  --tabbar-h: 62px;
  --serif: 'Volkhov', Georgia, 'Times New Roman', serif;
  --sans: 'Roboto', -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 17px;
  line-height: 1.45;
  -webkit-text-size-adjust: 100%;
}

h1, h2, h3 { font-family: var(--serif); font-weight: 600; letter-spacing: 0.01em; margin: 0 0 .5rem; }
h1 { font-size: 1.5rem; }
h2 { font-size: 1.25rem; }
h3 { font-size: 1.05rem; }
p { margin: 0 0 .75rem; }
a { color: var(--navy); }

/* ------------------------------------------------------------ app shell */
.appbar {
  position: sticky; top: 0; z-index: 40;
  /* White bar with brown type — same as beautymix-studio.com's header, and the
     only background the pale-blue logo badge reads correctly on. */
  background: #fff;
  color: var(--brown);
  padding: max(env(safe-area-inset-top), 10px) 16px 12px;
  display: flex; align-items: center; gap: 12px;
  border-bottom: 1px solid var(--line);
  box-shadow: 0 2px 10px rgba(79, 63, 47, .07);
}
/* The real logo is a pale watercolour badge on an opaque white background, so it
   must sit on white — inverting it or dropping it on a dark bar would wreck it.
   The storefront header is white with dark brown type, so we match that. */
.appbar-logo {
  height: 34px;
  width: auto;
  max-width: 140px;
  object-fit: contain;
  margin-right: 10px;
  flex: 0 0 auto;
}
/* Below ~380px the wordmark plus the logo is too much — keep the logo only. */
@media (max-width: 380px) {
  .appbar .brand-mark span { font-size: 0; }
  .appbar .brand-mark small { font-size: .68rem; }
}

.appbar .brand-mark {
  font-family: var(--serif);
  font-size: 1.15rem;
  line-height: 1.15;
  flex: 1;
  min-width: 0;
}
.appbar .brand-mark small {
  display: block;
  font-family: var(--sans);
  font-size: .72rem;
  letter-spacing: .09em;
  text-transform: uppercase;
  color: var(--bronze);
  margin-top: 2px;
}
.appbar .who { font-size: .78rem; color: var(--taupe); text-align: right; }
.appbar .who button {
  display: block; margin-top: 3px; margin-left: auto;
  background: none; border: 0; color: var(--bronze);
  font-size: .78rem; text-decoration: underline; padding: 4px 0; cursor: pointer;
}

main {
  max-width: 820px;
  margin: 0 auto;
  padding: 16px 14px calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 92px);
}

.view { display: none; }
.view.active { display: block; }

/* ------------------------------------------------------------- tab bar */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 50;
  display: flex;
  background: rgba(255,255,255,.97);
  backdrop-filter: saturate(1.4) blur(8px);
  border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
.tabbar button {
  flex: 1; border: 0; background: none;
  padding: 8px 2px 9px;
  font-family: var(--sans);
  font-size: .68rem; letter-spacing: .02em;
  color: var(--muted);
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  min-height: var(--tabbar-h);
  cursor: pointer;
}
.tabbar button .ic { font-size: 1.35rem; line-height: 1; }
.tabbar button.active { color: var(--navy); font-weight: 600; }
.tabbar button.active .ic { transform: translateY(-1px); }
.tabbar button .badge {
  position: absolute; transform: translate(18px, -4px);
  background: var(--gold); color: #fff;
  font-size: .6rem; font-weight: 700;
  border-radius: 999px; padding: 1px 5px;
}

/* --------------------------------------------------------------- cards */
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
  margin-bottom: 14px;
}
.card > h2:first-child, .card > h3:first-child { margin-top: 0; }
.card-head {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  margin-bottom: 10px;
}
.card-head h2, .card-head h3 { margin: 0; }

.step-label {
  font-size: .7rem; text-transform: uppercase; letter-spacing: .12em;
  color: var(--gold); font-weight: 700; margin-bottom: 6px;
}
.hint { color: var(--muted); font-size: .82rem; }
.rule { height: 1px; background: var(--line); border: 0; margin: 14px 0; }

/* -------------------------------------------------------------- inputs */
label { display: block; font-size: .8rem; font-weight: 600; color: var(--navy); margin: 0 0 4px; }

input[type=text], input[type=password], input[type=email], input[type=number],
input[type=date], input[type=search], select, textarea {
  width: 100%;
  font-family: var(--sans);
  font-size: 17px; /* 16px+ stops iOS zoom-on-focus */
  padding: 13px 14px;
  border: 1px solid #ded6cb;
  border-radius: 11px;
  background: #fff;
  color: var(--ink);
  min-height: 48px;
  appearance: none;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--navy);
  box-shadow: 0 0 0 3px rgba(145,112,82,.18);
}
.field { margin-bottom: 12px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 420px) { .grid2 { grid-template-columns: 1fr; } }

/* ------------------------------------------------------------- buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font-family: var(--sans); font-size: 17px; font-weight: 600;
  min-height: 50px; padding: 12px 20px;
  border-radius: 12px; border: 1px solid transparent;
  background: var(--navy); color: #fff;
  cursor: pointer; text-decoration: none;
  transition: filter .12s ease, transform .05s ease;
}
.btn:active { transform: translateY(1px); }
.btn:hover { filter: brightness(1.08); }
.btn[disabled] { opacity: .45; cursor: default; transform: none; filter: none; }
.btn.gold { background: var(--gold); }
.btn.ghost { background: #fff; color: var(--brown); border-color: #ded6cb; }
.btn.danger { background: #fff; color: var(--warn); border-color: #e3c3bc; }
.btn.block { width: 100%; }
.btn.sm { min-height: 40px; padding: 8px 13px; font-size: .88rem; border-radius: 10px; }
.btn-row { display: flex; flex-wrap: wrap; gap: 10px; }
.btn-row .btn { flex: 1 1 140px; }

.icon-btn {
  flex: 0 0 auto;
  width: 52px; height: 48px;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 1.35rem;
  background: var(--navy); color: #fff;
  border: 0; border-radius: 11px; cursor: pointer;
}
.icon-btn.ghost { background: #fff; color: var(--brown); border: 1px solid #ded6cb; }

/* --------------------------------------------------------- search list */
.search-wrap { position: relative; }
.results {
  list-style: none; margin: 8px 0 0; padding: 0;
  border: 1px solid var(--line); border-radius: 12px;
  background: #fff; overflow: hidden;
  max-height: 300px; overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
.results:empty { display: none; }
.results li {
  padding: 13px 14px; border-bottom: 1px solid #f0f1f4;
  cursor: pointer; display: flex; justify-content: space-between; gap: 10px;
  align-items: baseline;
}
.results li:last-child { border-bottom: 0; }
.results li:active { background: #eef1f7; }
.results li .r-main { font-weight: 600; }
.results li .r-sub { color: var(--muted); font-size: .78rem; }
.results li .r-right { color: var(--navy); font-weight: 600; white-space: nowrap; }
.results li.empty { color: var(--muted); cursor: default; font-style: italic; justify-content: flex-start; }

/* ---------------------------------------------------- selected member */
.selected-member {
  background: linear-gradient(180deg, #f4f6fb, #eef1f8);
  border: 1px solid #d8deea;
  border-radius: 12px;
  padding: 13px 14px;
  display: flex; justify-content: space-between; align-items: flex-start; gap: 12px;
}
.selected-member .sm-name { font-family: var(--serif); font-size: 1.1rem; color: var(--navy); }
.selected-member .sm-meta { font-size: .8rem; color: var(--muted); margin-top: 2px; }

/* --------------------------------------------------------------- lines */
.lines { list-style: none; margin: 0; padding: 0; }
.lines li {
  display: flex; align-items: center; gap: 10px;
  padding: 11px 0; border-bottom: 1px solid var(--line);
}
.lines li:last-child { border-bottom: 0; }
.lines .l-info { flex: 1; min-width: 0; }
.lines .l-name { font-weight: 600; overflow-wrap: anywhere; }
.lines .l-sub { font-size: .78rem; color: var(--muted); }
.lines .l-total { font-weight: 700; min-width: 74px; text-align: right; }
.qty-stepper { display: flex; align-items: center; gap: 0; border: 1px solid #ded6cb; border-radius: 10px; overflow: hidden; }
.qty-stepper button {
  width: 38px; height: 40px; border: 0; background: #f4f5f8;
  font-size: 1.15rem; color: var(--navy); cursor: pointer;
}
.qty-stepper .q { min-width: 34px; text-align: center; font-weight: 700; font-size: .95rem; }
.remove-line {
  border: 0; background: none; color: var(--warn);
  font-size: 1.2rem; padding: 6px 4px; cursor: pointer; line-height: 1;
}

/* --------------------------------------------------------- sticky total */
.total-bar {
  position: fixed; left: 0; right: 0;
  bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom));
  z-index: 45;
  background: var(--navy-dark); color: #fff;
  padding: 10px 14px 12px;
  display: none;
  box-shadow: 0 -3px 14px rgba(0,0,0,.16);
}
.total-bar.show { display: block; }
.total-bar .tb-row { display: flex; align-items: center; gap: 12px; max-width: 820px; margin: 0 auto; }
.total-bar .tb-amt { flex: 1; }
.total-bar .tb-amt .tb-label { font-size: .68rem; text-transform: uppercase; letter-spacing: .12em; color: var(--gold-light); }
.total-bar .tb-amt .tb-num { font-family: var(--serif); font-size: 1.5rem; line-height: 1.1; }
.total-bar .btn { background: var(--gold); border: 0; }

/* --------------------------------------------------------------- table */
.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; margin: 0 -4px; }
table { width: 100%; border-collapse: collapse; font-size: .88rem; }
th, td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { font-size: .7rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); font-weight: 700; }
td.num, th.num { text-align: right; }
tbody tr:active { background: #f2f4f9; }
td .tiny { font-size: .74rem; color: var(--muted); }

.pill {
  display: inline-block; font-size: .68rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: .06em;
  padding: 3px 9px; border-radius: 999px;
}
.pill.unpaid { background: #fdeeea; color: var(--warn); }
/* A failed automatic price sync must not read like ordinary small print. */
.hint.warn { color: var(--warn); font-weight: 600; }
.pill.paid { background: #e8f5ee; color: var(--ok); }
.pill.gold { background: #f8f0e2; color: var(--gold); }

/* ------------------------------------------------------------ big total */
.big-total {
  text-align: center; padding: 6px 0 10px;
}
.big-total .bt-label { font-size: .7rem; text-transform: uppercase; letter-spacing: .13em; color: var(--muted); }
.big-total .bt-num { font-family: var(--serif); font-size: 2.4rem; color: var(--navy); line-height: 1.1; }
.big-total .bt-sub { font-size: .8rem; color: var(--muted); }

/* ------------------------------------------------------------ signature */
.sig-pad {
  width: 100%; height: 190px;
  background: #fff;
  border: 2px dashed #c3c9d4;
  border-radius: 12px;
  touch-action: none; /* required so drawing doesn't scroll the page */
  display: block;
}
.sig-line { text-align: center; font-size: .76rem; color: var(--muted); margin-top: 6px; }
.sig-img { max-width: 240px; border-bottom: 1px solid var(--ink); display: block; }

/* --------------------------------------------------------------- toast */
#toast {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 80px);
  z-index: 90;
  background: var(--navy-dark); color: #fff;
  padding: 12px 18px; border-radius: 12px;
  font-size: .9rem; max-width: 90vw; text-align: center;
  box-shadow: var(--shadow);
  opacity: 0; pointer-events: none; transition: opacity .2s ease;
}
#toast.show { opacity: 1; }
#toast.err { background: var(--warn); }
#toast.ok { background: var(--ok); }

/* --------------------------------------------------------------- modal */
.modal {
  position: fixed; inset: 0; z-index: 80;
  background: rgba(16,22,36,.62);
  display: none; align-items: center; justify-content: center;
  padding: 16px;
}
.modal.show { display: flex; }
.modal-box {
  background: #fff; border-radius: 16px;
  width: 100%; max-width: 460px;
  max-height: 88vh; overflow-y: auto;
  padding: 18px;
  box-shadow: 0 20px 50px rgba(0,0,0,.3);
}
#scanner-target { width: 100%; border-radius: 12px; overflow: hidden; background: #000; min-height: 240px; }
#scanner-target video { width: 100% !important; height: auto !important; display: block; }

/* --------------------------------------------------------------- login */
body.login-page {
  display: flex; align-items: center; justify-content: center;
  min-height: 100vh; min-height: 100dvh;
  background: linear-gradient(160deg, #6b5744 0%, #4f3f2f 55%, #3a2e22 100%);
  padding: 24px;
}
.login-card {
  background: #fff; border-radius: 18px;
  width: 100%; max-width: 400px;
  padding: 30px 26px 26px;
  box-shadow: 0 24px 60px rgba(0,0,0,.35);
  text-align: center;
}
/* Real storefront logo. Kept as .crest as well so the old selector still
   applies if the image ever fails to load and a text fallback is used. */
.login-card .brand-logo,
.login-card .crest {
  display: block;
  width: auto; height: 52px;
  max-width: 210px;
  margin: 0 auto 16px;
  object-fit: contain;
  border: 0; border-radius: 0;
}
.login-card h1 { font-size: 1.4rem; margin-bottom: 2px; color: var(--navy); }
.login-card .sub {
  font-size: .72rem; text-transform: uppercase; letter-spacing: .13em;
  color: var(--gold); margin-bottom: 22px;
}
.login-card form { text-align: left; }
.login-err { color: var(--warn); font-size: .85rem; margin-top: 10px; min-height: 1.2em; }

.empty-state { text-align: center; color: var(--muted); padding: 22px 6px; font-size: .9rem; }

/* Wider screens: same bottom bar, just roomier and centred. */
@media (min-width: 760px) {
  .tabbar { justify-content: center; }
  .tabbar button { flex: 0 1 150px; font-size: .78rem; flex-direction: row; gap: 8px; }
  .tabbar button .ic { font-size: 1.15rem; }
}

/* ------------------------------------------------- consent + prepurchased */
/* The wording the member agrees to by signing. Deliberately not muted grey —
   it is a legal statement, so it has to be readable. */
.consent {
  font-size: .82rem;
  line-height: 1.4;
  color: var(--ink);
  background: #fbf7ee;
  border-left: 3px solid var(--gold);
  padding: 9px 11px;
  border-radius: 8px;
  margin: 0 0 12px;
}

.check-row {
  display: flex; align-items: flex-start; gap: 10px;
  font-size: .86rem; line-height: 1.35;
  margin: 0 0 14px;
}
.check-row input[type="checkbox"] { width: 22px; height: 22px; margin: 0; flex: 0 0 auto; }

/* Per-line "Vaquero prepurchased" toggle inside a sale line. */
.lines .pp-toggle {
  display: inline-flex; align-items: center; gap: 7px;
  font-size: .78rem; color: var(--muted);
  margin-top: 5px;
}
.lines .pp-toggle input[type="checkbox"] { width: 18px; height: 18px; margin: 0; }
.lines .pp-note { font-size: .74rem; color: var(--muted); margin-top: 2px; }
.lines .pp-note.flag { color: var(--gold); font-weight: 600; }

/* The reimbursement-invoice preview: mirrors the club's paper form, so it
   stays readable at small sizes and never wraps a column. */
.form-table { font-size: .8rem; }
.form-table th, .form-table td { padding: 7px 6px; }
.form-table tfoot td {
  border-bottom: 0; border-top: 1px solid var(--line);
  font-weight: 700;
}
.form-table tfoot tr.grand td { font-size: .95rem; color: var(--navy); }
.form-table td.note-cell { font-size: .72rem; color: var(--gold); white-space: normal; max-width: 110px; }

/* ------------------------------------------------------- barcode scanner */
/* The preview is our own <video>, not a library widget, so it needs styling.
   Fixed aspect box keeps the modal from jumping as the camera starts. */
#scanner-target {
  position: relative;
  width: 100%;
  aspect-ratio: 4 / 3;
  background: #1b1714;
  border-radius: 12px;
  overflow: hidden;
}
#scanner-target:empty::after {
  content: 'Camera off';
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  color: #a79a8c; font-size: .85rem;
}
.scan-video {
  width: 100%; height: 100%;
  object-fit: cover;
  display: block;
}
/* Wide, short guide — matches the shape of a retail barcode and the band we
   actually decode, so what she lines up is what gets read. */
.scan-guide {
  position: absolute;
  left: 6%; right: 6%; top: 29%; height: 42%;
  border: 2px solid rgba(255,255,255,.9);
  border-radius: 8px;
  box-shadow: 0 0 0 100vmax rgba(0,0,0,.35);
  pointer-events: none;
}
/* Variant (shade / size) in a product pick-list. Emphasised because it is the
   thing that tells two otherwise identical rows apart. */
.r-variant {
  display: inline-block;
  font-size: .8rem;
  color: var(--bronze);
  font-weight: 600;
}
