/* WVCS Staff — visual language taken from the check-in page, which Derek named
   as the reference. Everything below is either lifted from it or built to sit
   beside it: same greys, same blue, same card, same 8/10px radii, same
   16px-minimum inputs (below that iOS Safari zooms on focus).
   Tokens live here so later UX passes are one file, not a hunt. */

:root {
  --bg:        #f5f5f5;
  --surface:   #ffffff;
  --ink:       #222222;
  --ink-soft:  #777777;
  --ink-faint: #999999;
  --line:      #eeeeee;
  --line-soft: #f0f0f0;
  --blue:      #1a73e8;
  --blue-pale: #e8f0fe;
  --good:      #137333;
  --good-pale: #e6f4ea;
  --bad:       #c5221f;
  --bad-pale:  #fce4e4;
  --warn-pale: #fff8e1;
  --warn-line: #ffe082;
  --warn-ink:  #b26a00;

  --pad:       18px;
  --radius:    10px;
  --radius-sm: 8px;
  --bar-h:     56px;

  --shadow:    0 1px 3px rgba(0,0,0,.1);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box }
/* NOT height:100%. That caps how far a sticky child can stick — to one screen
   — so on a long client record the app bar unstuck and scrolled away while the
   client name kept sticking, leaving a gap with content showing through. */
html, body { min-height: 100% }
body {
  margin: 0; font-family: var(--font); background: var(--bg); color: var(--ink);
  -webkit-text-size-adjust: 100%;
}

/* ── App bar ─────────────────────────────────────────────────────────── */
/* Deliberately NOT sticky. On a client record the branding scrolls away and
   the client's name takes the top — which is the thing you actually need
   anchored while reading 31 fields on a phone. */
.appbar {
  display: flex; align-items: center; gap: 4px;
  height: calc(var(--bar-h) + env(safe-area-inset-top));
  padding: env(safe-area-inset-top) 8px 0;
  background: var(--surface); border-bottom: 1px solid var(--line);
}
/* Tapping the mark refetches — the cheapest possible "reload" on a device
   where pull-to-refresh does nothing useful inside a standalone app. */
.brand {
  display: flex; align-items: center; gap: 8px; min-width: 0;
  background: none; border: 0; font: inherit; color: inherit;
  padding: 6px 8px; margin-left: -4px; border-radius: var(--radius-sm); cursor: pointer;
}
.brand:active { background: var(--bg) }
.brand.busy { opacity: .5 }
.brand-mark { width: 26px; height: 26px; display: block }
.brand-name { font-weight: 700; font-size: 17px; letter-spacing: .01em }
.appbar-right { margin-left: auto; display: flex; align-items: center; gap: 8px; padding-right: 4px }

.icon-btn {
  appearance: none; border: 0; background: transparent; color: var(--ink);
  width: 44px; height: 44px;              /* 44px is the tap-target floor */
  display: grid; place-items: center; border-radius: 50%; cursor: pointer;
}
.icon-btn:active { background: var(--line) }

.badge {
  display: inline-block; padding: 4px 12px; background: var(--blue-pale);
  border-radius: 16px; font-size: 13px; color: var(--blue); white-space: nowrap;
  max-width: 45vw; overflow: hidden; text-overflow: ellipsis;
}

/* ── Tabs ────────────────────────────────────────────────────────────────
   Replaces the drawer. Always visible, no hidden state, nothing to toggle.
   `[hidden]` is asserted below with !important precisely because the drawer's
   `display: flex` silently beat it and left the thing sitting open. */
[hidden] { display: none !important }

.tabs {
  display: flex; gap: 4px; padding: 0 var(--pad);
  background: var(--surface); border-bottom: 1px solid var(--line);
  overflow-x: auto; -webkit-overflow-scrolling: touch;
}
.tabs:empty { display: none }
.tabs a {
  padding: 12px 4px; margin-right: 16px; white-space: nowrap; text-decoration: none;
  color: var(--ink-soft); font-size: 15px; border-bottom: 2px solid transparent;
}
.tabs a.current { color: var(--blue); font-weight: 600; border-bottom-color: var(--blue) }

.footline {
  padding: 4px var(--pad) calc(20px + env(safe-area-inset-bottom));
  font-size: 11px; color: #bbb; line-height: 1.6; word-break: break-word;
}

/* ── Screens ─────────────────────────────────────────────────────────── */
main { padding: var(--pad); padding-bottom: calc(var(--pad) + env(safe-area-inset-bottom)) }
h2 { margin: 0 0 14px; font-size: 20px }

.card {
  background: var(--surface); border-radius: var(--radius); padding: 12px 14px;
  margin-bottom: 16px; box-shadow: var(--shadow);
}

/* Label left, value right — the check-in row, reused for client fields. */
.row {
  display: flex; justify-content: space-between; gap: 12px;
  padding: 10px 0; border-bottom: 1px solid var(--line-soft);
}
.row:last-child { border-bottom: 0 }
.row .k { color: var(--ink-soft); flex: 1 }
.row .v { text-align: right; flex: 2; word-break: break-word }
.row .v.empty { color: #ccc; font-style: italic }
.row .v.multiline { white-space: pre-wrap; text-align: left }

.section-header {
  font-weight: 700; font-size: 12px; text-transform: uppercase; letter-spacing: .04em;
  color: var(--ink-soft); margin: 20px 0 8px; padding-bottom: 4px; border-bottom: 1px solid var(--line);
}

/* Client name follows the branding up and then holds the very top.
   Negative side margins + matching padding make it span the full width, so
   nothing scrolls past in the gutters beside it. */
.sticky-head {
  position: sticky; top: 0; z-index: 20;
  background: var(--bg);
  margin: -18px calc(var(--pad) * -1) 4px;
  padding: 12px var(--pad) 10px;
  border-bottom: 1px solid var(--line);
  display: flex; align-items: baseline; gap: 10px;
}
.sticky-head .name { font-size: 18px; font-weight: 700; flex: 1; min-width: 0 }
.sticky-head .id   { color: var(--ink-faint); font-size: 13px; white-space: nowrap }

/* ── Controls ────────────────────────────────────────────────────────── */
.btn {
  appearance: none; display: inline-block; width: 100%;
  padding: 14px 20px; font-size: 17px; font-weight: 600; font-family: inherit;
  color: #fff; background: var(--blue); border: 0; border-radius: var(--radius-sm); cursor: pointer;
}
.btn:disabled { background: #9bbef0 }
.btn.quiet { background: transparent; color: var(--blue); border: 1px solid var(--line) }
.btn.danger { background: transparent; color: var(--bad); border: 1px solid #f5c6cb }
.btn + .btn { margin-top: 8px }

.field { margin-bottom: 12px }
.field label { display: block; margin: 0 0 6px; font-weight: 600; font-size: 14px }
input[type=text], input[type=email], input[type=search] {
  width: 100%; padding: 12px; font-size: 16px; font-family: inherit;   /* 16px: no iOS zoom */
  border: 1px solid #ccc; border-radius: var(--radius-sm); background: var(--surface); color: var(--ink);
}

.back { display: inline-block; padding: 10px 4px; color: var(--blue); font-weight: 500; cursor: pointer }

/* ── Search results ──────────────────────────────────────────────────── */
.results { list-style: none; padding: 0; margin: 8px 0 0 }
.results li {
  padding: 14px 12px; background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius-sm); margin-bottom: 6px; cursor: pointer;   /* ~46px tap target */
}
.results li.active { background: var(--blue-pale); border-color: var(--blue) }
.results li.needs-id { color: var(--ink-faint); border-style: dashed }
.tag {
  float: right; font-size: 11px; color: var(--warn-ink); background: var(--warn-pale);
  border: 1px solid var(--warn-line); border-radius: 10px; padding: 1px 8px;
}
.more-note { text-align: center; color: var(--ink-faint); font-size: 12px; padding: 8px }

/* ── Feedback ────────────────────────────────────────────────────────── */
.note    { border-radius: var(--radius-sm); padding: 12px; margin-bottom: 16px; font-size: 14px;
           line-height: 1.5; word-break: break-word; user-select: text; -webkit-user-select: text }
.note.err  { background: var(--bad-pale); border: 1px solid #f5c6cb; color: var(--bad) }
.note.ok   { background: var(--good-pale); border: 1px solid #b7e1c2; color: var(--good) }
.note.warn { background: var(--warn-pale); border: 1px solid var(--warn-line); color: var(--warn-ink) }
.note-hint { margin-top: 8px; font-size: 11px; opacity: .65 }

.empty { text-align: center; padding: 40px 20px; color: var(--ink-faint) }
.empty .big { font-size: 32px }
.spinner {
  width: 20px; height: 20px; margin: 40px auto; border: 3px solid var(--line);
  border-top-color: var(--blue); border-radius: 50%; animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg) } }

.mono { font-family: ui-monospace, Menlo, monospace; font-size: 12px; word-break: break-all;
        background: var(--surface); border: 1px solid var(--line); border-radius: 6px;
        padding: 8px; margin-top: 8px; user-select: all; -webkit-user-select: all }
.diag { font-size: 11px; color: #bbb; margin-top: 28px; line-height: 1.5; word-break: break-word }

@media (prefers-reduced-motion: reduce) {
  .drawer { animation: none } .spinner { animation-duration: 2s }
}
