/* Same visual language as the scan page — same product, same palette — but laid
   out for one person checking things on a phone in a noisy hall. */

:root {
  --ink:    #12201C;
  --paper:  #F2F4F0;
  --card:   #FFFFFF;
  --moss:   #2F6F52;
  --moss-d: #24573F;
  --mute:   #6B7A72;
  --rule:   #DCE3DC;
  --alert:  #A3341F;
  --warn:   #8A6412;

  --serif: ui-serif, "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --sans:  system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono:  ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.5;
}

.wrap {
  max-width: 54rem;
  margin: 0 auto;
  padding: 1rem 1rem max(2.5rem, env(safe-area-inset-bottom));
}

a { color: var(--moss); }

/* --- chrome --------------------------------------------------------------- */

.top {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: .35rem 1.1rem;
  padding: .9rem 0;
  border-bottom: 1px solid var(--rule);
  margin-bottom: 1.4rem;
}

.brand {
  font-family: var(--serif);
  font-size: 1.15rem;
  margin-right: auto;
  text-decoration: none;
  color: var(--ink);
}

/* Wraps. Nine links do not fit one line on a phone — the nav measured 505px against
   a 390px viewport, which pushed every page here sideways. Pre-existing, and adding
   the gallery's link made it about 40px worse, so it is fixed rather than noted. */
.top nav { display: flex; flex-wrap: wrap; gap: .45rem 1.1rem; }

.top nav a {
  font-size: .85rem;
  font-weight: 600;
  text-decoration: none;
  color: var(--mute);
}

.top nav a.on, .top nav a:hover { color: var(--ink); }

.who { font-size: .78rem; color: var(--mute); width: 100%; }

/* --- messages ------------------------------------------------------------- */

.flash {
  border: 1px solid var(--rule);
  border-left: 3px solid var(--moss);
  border-radius: 8px;
  background: var(--card);
  padding: .7rem .9rem;
  margin-bottom: 1.1rem;
  font-size: .9rem;
}

.flash.bad { border-left-color: var(--alert); color: var(--alert); }

/* --- the active-event banner ---------------------------------------------
   The one thing on this screen that has to be unmissable. Tagging a day of
   leads with last week's conference happens by forgetting, not by misclicking,
   so the current state gets the whole top of the page. */

.now {
  background: var(--ink);
  color: var(--paper);
  border-radius: 16px;
  padding: 1.5rem 1.4rem;
  margin-bottom: 1.4rem;
}

.now .label {
  font-size: .68rem;
  font-weight: 600;
  letter-spacing: .16em;
  text-transform: uppercase;
  color: #8FB3A2;
  margin: 0 0 .5rem;
}

.now h1 {
  font-family: var(--serif);
  font-weight: 400;
  font-size: clamp(1.8rem, 8vw, 2.6rem);
  line-height: 1.1;
  letter-spacing: -.02em;
  margin: 0 0 .7rem;
}

.now .tag {
  font-family: var(--mono);
  font-size: .82rem;
  color: #8FB3A2;
  word-break: break-all;
}

.now.empty { background: var(--card); color: var(--ink); border: 1px dashed var(--rule); }
.now.empty .label, .now.empty .tag { color: var(--mute); }

.now .row { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: 1.1rem; }

/* --- stats ---------------------------------------------------------------- */

.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(7rem, 1fr));
  gap: .6rem;
  margin-bottom: 1.4rem;
}

.stat {
  background: var(--card);
  border: 1px solid var(--rule);
  border-radius: 10px;
  padding: .8rem .9rem;
}

.stat b {
  display: block;
  font-family: var(--serif);
  font-size: 1.7rem;
  font-weight: 400;
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
}

.stat span {
  font-size: .7rem;
  font-weight: 600;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--mute);
}

.stat.bad b { color: var(--alert); }

/* --- sticky lead bar ------------------------------------------------------- */

/* The controls outlive the scroll: counts, filter and bulk move stay put while
   a long lead table moves under them. Bled to the full width of .wrap so rows
   cannot show alongside it, and given a background for the same reason. */
.leadbar {
  position: sticky;
  top: 0;
  z-index: 5;
  background: var(--paper);
  margin: 0 -1rem 1.2rem;
  padding: .7rem 1rem .8rem;
  border-bottom: 1px solid var(--rule);
}

/* Numbers read at a glance rather than as headlines — this strip is permanently
   on screen, so every millimetre it takes is one the table loses. */
.stats.tight {
  grid-template-columns: repeat(auto-fit, minmax(6rem, 1fr));
  gap: .45rem;
  margin-bottom: .7rem;
}

.stats.tight .stat { padding: .35rem .6rem; }

.stats.tight .stat b {
  display: inline;
  font-size: 1.05rem;
  margin-right: .3rem;
}

.stats.tight .stat span { font-size: .62rem; }

.leadbar .bulk {
  margin-top: .7rem;
  padding-top: .7rem;
  border-top: 1px dashed var(--rule);
}

/* The caveat sits on its own line under the control it qualifies, not squeezed
   into the flex row beside it. */
.leadbar .bulk .hint { flex: 1 1 100%; margin: 0; }

/* Sticky costs more than it returns on a short screen — the bar would eat the
   table it exists to help you read. */
@media (max-height: 34rem) {
  .leadbar { position: static; }
}

/* --- panels --------------------------------------------------------------- */

.panel {
  background: var(--card);
  border: 1px solid var(--rule);
  border-radius: 12px;
  padding: 1.1rem 1.1rem 1.2rem;
  margin-bottom: 1.2rem;
}

.panel > h2 {
  font-family: var(--serif);
  font-weight: 400;
  font-size: 1.25rem;
  margin: 0 0 .2rem;
}

.panel > p.hint {
  margin: 0 0 1rem;
  font-size: .85rem;
  color: var(--mute);
}

/* --- forms ---------------------------------------------------------------- */

label {
  display: block;
  font-size: .72rem;
  font-weight: 600;
  letter-spacing: .07em;
  text-transform: uppercase;
  color: var(--mute);
  margin-bottom: .3rem;
}

input[type=text], input[type=email], select, textarea {
  width: 100%;
  font: inherit;
  font-size: 1rem;
  color: var(--ink);
  background: var(--card);
  border: 1px solid var(--rule);
  border-radius: 9px;
  padding: .6rem .75rem;
}

textarea { resize: vertical; min-height: 5rem; line-height: 1.5; }

.field { margin-bottom: .9rem; }

.inline { display: flex; flex-wrap: wrap; gap: .6rem; align-items: flex-end; }
.inline .field { flex: 1 1 12rem; margin-bottom: 0; }

:focus-visible { outline: 2px solid var(--moss); outline-offset: 2px; }

/* --- buttons -------------------------------------------------------------- */

.btn {
  display: inline-block;
  font: inherit;
  font-size: .9rem;
  font-weight: 600;
  text-decoration: none;
  text-align: center;
  color: #FFF;
  background: var(--moss);
  border: 1px solid var(--moss);
  border-radius: 9px;
  padding: .6rem 1rem;
  cursor: pointer;
  white-space: nowrap;
}

.btn:hover { background: var(--moss-d); border-color: var(--moss-d); }

.btn.ghost { color: var(--ink); background: transparent; border-color: var(--rule); }
.btn.ghost:hover { background: var(--paper); }

.btn.onDark { color: var(--ink); background: var(--paper); border-color: var(--paper); }
.btn.onDark:hover { background: #FFF; border-color: #FFF; }

.btn.ghost.onDark { color: var(--paper); background: transparent; border-color: #47645A; }
.btn.ghost.onDark:hover { background: #1B2E28; }

.btn.danger { color: var(--alert); background: transparent; border-color: var(--rule); }
.btn.danger:hover { background: #FBF1EF; border-color: var(--alert); }

.btn.small { font-size: .78rem; padding: .35rem .65rem; }

/* --- tables --------------------------------------------------------------- */

.scroll { overflow-x: auto; margin: 0 -1.1rem; padding: 0 1.1rem; }

/* min-width, not just width:100% — otherwise a narrow screen squashes the
   columns and breaks email addresses mid-word instead of scrolling. */
table { width: 100%; min-width: 46rem; border-collapse: collapse; font-size: .88rem; }

th {
  text-align: left;
  font-size: .68rem;
  font-weight: 600;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--mute);
  padding: 0 .6rem .5rem 0;
  white-space: nowrap;
}

td {
  padding: .6rem .6rem .6rem 0;
  border-top: 1px solid var(--rule);
  vertical-align: top;
}

td.tight { white-space: nowrap; }

tr.live td { background: #F4F9F5; }

.name { font-weight: 600; white-space: nowrap; }
.sub { font-size: .8rem; color: var(--mute); overflow-wrap: anywhere; }

/* A HighLevel error is one long unbreakable-looking string. Left uncapped it
   wins the column-width fight and squashes every other column into wrapping. */
.sub.err { max-width: 20rem; }

/* Contact details read as one unit; the table scrolls before they wrap. */
td.who .sub { white-space: nowrap; }

.mono { font-family: var(--mono); font-size: .8rem; word-break: break-all; }

/* Same treatment as the scan page's field labels: quiet and italic, so
   "optional" reads as an aside rather than as part of the label. */
.optional { font-style: italic; font-weight: 400; color: var(--mute); }

/* A checkbox and its words are one target, so the label wraps the input rather
   than sitting beside it. */
.check {
  display: flex;
  gap: .5rem;
  align-items: center;
  font-size: .85rem;
  color: var(--mute);
}
.check input { margin: 0; }

/* The QR sits on white whatever the page background is: a scanner needs the
   quiet zone to be light, and the code is rendered to be photographed. */
.qr {
  display: inline-block;
  margin: 1rem 0;
  padding: .5rem;
  background: #FFF;
  border: 1px solid var(--rule);
  border-radius: 4px;
}
.qr svg { display: block; width: min(15rem, 60vw); height: auto; }

/* --- placeholder guide ---------------------------------------------------- */

/* Reference material, not the task. Set behind a rule and quieter than the form
   so it reads as something to consult rather than something to fill in. */
.guide {
  margin-top: 1.6rem;
  padding-top: 1.2rem;
  border-top: 1px solid var(--rule);
}

.guide h3 {
  font-family: var(--sans);
  font-size: .7rem;
  font-weight: 600;
  letter-spacing: .09em;
  text-transform: uppercase;
  color: var(--mute);
  margin: 1.3rem 0 .5rem;
}

.guide h3:first-child { margin-top: 0; }

.guide dl { margin: 0 0 .9rem; }
.guide dt { margin-top: .5rem; }

.guide dd {
  margin: .1rem 0 0;
  font-size: .82rem;
  color: var(--mute);
  line-height: 1.5;
}

.guide dd b { color: var(--ink); font-weight: 600; }

/* Recovery, not a primary action — it sits under the defaults it restores. */
.guide form { margin: .7rem 0 0; }

/* Sample output. Quoted rather than boxed — one more card here would compete
   with the form it is explaining. */
.preview-line {
  margin: .35rem 0;
  padding-left: .75rem;
  border-left: 2px solid var(--rule);
  font-family: var(--serif);
  font-size: .9rem;
  line-height: 1.5;
  overflow-wrap: anywhere;
}

/* --- pills ---------------------------------------------------------------- */

.pill {
  display: inline-block;
  font-size: .68rem;
  font-weight: 600;
  letter-spacing: .06em;
  text-transform: uppercase;
  border-radius: 999px;
  padding: .18rem .55rem;
  border: 1px solid var(--rule);
  color: var(--mute);
  white-space: nowrap;
}

.pill.ok      { color: var(--moss);  border-color: #B8D6C4; background: #F1F8F3; }
.pill.bad     { color: var(--alert); border-color: #E6C3BA; background: #FBF1EF; }
.pill.waiting { color: var(--warn);  border-color: #E4D3A6; background: #FBF6E8; }

.empty-note {
  margin: 0;
  padding: 1.4rem 0;
  text-align: center;
  color: var(--mute);
  font-size: .9rem;
}

/* --- login ---------------------------------------------------------------- */

.gate {
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.gate .panel { max-width: 22rem; width: 100%; text-align: center; margin: 0; }
.gate h1 { font-family: var(--serif); font-weight: 400; font-size: 1.6rem; margin: 0 0 .4rem; }
.gate p { color: var(--mute); font-size: .9rem; margin: 0 0 1.2rem; }
.gate .btn { width: 100%; }

/* --- photos ---------------------------------------------------------------- */

/* Used standing up, one-handed, with someone waiting. Both controls are full
   width on a phone and sit side by side once there is room. */
.photo-form {
  display: flex;
  flex-wrap: wrap;
  gap: .5rem;
  margin-top: 1.1rem;
}
.photo-form > * { flex: 1 1 12rem; justify-content: center; }

/* The label is the visible control; the input only has to stay reachable, so it
   is collapsed rather than display:none — a hidden input is skipped by some
   assistive tech and by Safari's file picker. */
.photo-input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.now .meta { color: #8FB3A2; font-size: .85rem; margin: 0; }

.others {
  border: 1px solid var(--rule);
  border-radius: 12px;
  background: var(--card);
  padding: .4rem .9rem;
  margin-bottom: 1.4rem;
}
.others summary {
  padding: .6rem 0;
  cursor: pointer;
  font-size: .9rem;
  color: var(--moss);
}
.other { padding: .8rem 0; border-top: 1px solid var(--rule); }
.other .who-line { display: flex; flex-wrap: wrap; gap: .5rem; align-items: baseline; }
.other .meta { color: var(--mute); font-size: .82rem; }
.other .photo-form { margin-top: .6rem; }

/* Square and cropped: a face is recognisable at 44px, a letterboxed photo is
   not. */
.thumb {
  width: 44px;
  height: 44px;
  border-radius: 8px;
  object-fit: cover;
  display: block;
  background: var(--paper);
}

/* --- template gallery ------------------------------------------------------
   Each tile holds a live iframe of the scan page at ?preview=<slug>. The iframe
   is laid out at a phone's logical width and scaled down, because a page reflowed
   into a 300px frame is a different page — the whole reason to preview is to see
   the type and spacing that will actually ship.

   The iframe is always 390x556 — a phone's logical size. --shot-scale shrinks the
   picture of it, and the wrapper derives its own box from the same number so the two
   cannot drift. 390 * .72 = 281.

   The narrow-screen rule is not cosmetic. This page is opened on a phone, Kirk's is
   an Android, and a 360px viewport leaves 289px after the wrap and panel padding —
   which a fixed 281px tile clears by 8px and a 320px viewport does not clear at all.
   A fixed width there would push the whole admin page sideways. */

.gallery {
  list-style: none;
  margin: 1.2rem 0 0;
  padding: 0;
  display: grid;
  gap: 1.1rem;
  /* min() so a column may go narrower than a tile rather than forcing the page
     wider than the screen. */
  grid-template-columns: repeat(auto-fill, minmax(min(281px, 100%), 1fr));
}

.tile {
  border: 1px solid var(--rule);
  border-radius: 12px;
  background: var(--card);
  overflow: hidden;
}

/* The chosen one is marked by a moss ring rather than by colour alone, so it does
   not depend on telling two greens apart. */
.tile.on { border-color: var(--moss); box-shadow: 0 0 0 2px #D6E7DD; }

.tile-shot {
  --shot-scale: .72;
  width: calc(390px * var(--shot-scale));
  height: calc(556px * var(--shot-scale));
  margin: 0 auto;
  overflow: hidden;
  border-bottom: 1px solid var(--rule);
  background: var(--paper);
}

@media (max-width: 400px) {
  .tile-shot { --shot-scale: .58; }
}

.tile-shot iframe {
  width: 390px;
  height: 556px;
  border: 0;
  display: block;
  transform: scale(var(--shot-scale));
  transform-origin: top left;
  /* A tile is for looking at. The preview's own buttons are disabled server-side
     as well; this stops a stray tap scrolling or focusing inside a tile. */
  pointer-events: none;
}

.tile-say { padding: .85rem 1rem 1rem; }

.tile-say h3 {
  margin: 0 0 .25rem;
  font-size: .95rem;
  display: flex;
  align-items: center;
  gap: .5rem;
}

.tile-say p {
  margin: 0 0 .7rem;
  font-size: .84rem;
  color: var(--mute);
  line-height: 1.45;
}

/* --- colour fields ---------------------------------------------------------
   A hex box that submits, and a swatch that only picks. The native colour picker
   on Windows offers R/G/B spinners and no hex field at all, so pasting a brand
   colour was impossible — the text box is the fix, and the swatch stays for
   choosing one by eye. */

.colour-pair { display: flex; align-items: stretch; gap: .5rem; }

.colour-hex {
  flex: 1 1 auto;
  min-width: 0;
  font-family: var(--mono);
  text-transform: lowercase;
}

/* Sized to match the text box beside it rather than left at the browser's default,
   which is about 50px tall and sits oddly against a 44px input. */
.colour-swatch {
  flex: 0 0 3rem;
  width: 3rem;
  height: auto;
  min-height: 2.6rem;
  padding: 2px;
  border: 1px solid var(--rule);
  border-radius: 8px;
  background: var(--card);
  cursor: pointer;
}

.colour-swatch::-webkit-color-swatch-wrapper { padding: 0; }
.colour-swatch::-webkit-color-swatch { border: 0; border-radius: 5px; }
.colour-swatch::-moz-color-swatch { border: 0; border-radius: 5px; }

/* --- image previews --------------------------------------------------------
   A file input cannot show what is already stored on the server, so both of these
   fetch it. That is the only way to tell whether a save worked. */

/* The same round frame and the same object-position as .portrait on the scan page,
   deliberately: a preview that crops differently from the real thing is a second
   opinion, and the point of a preview is to be the first one. */
.portrait-preview {
  width: 88px;
  height: 88px;
  border-radius: 50%;
  object-fit: cover;
  object-position: 50% 35%;
  /* --moss rather than the Setter's --rule, for the same reason the scan page's ring
     is --field: a hairline at 1.3:1 leaves the circle with no visible edge. This page
     has no per-template palette, so one visible value is enough. */
  border: 1px solid var(--moss);
  background: var(--paper);
  display: block;
}

/* Pre-existing: the template has always carried this class and the stylesheet never
   did, so the logo held its shape only from its width and height attributes — which
   distorts any logo that is not 2:1. `contain` letterboxes instead. */
.logo-preview {
  max-width: 120px;
  height: auto;
  max-height: 60px;
  object-fit: contain;
  display: block;
}

/* --- the HighLevel scope checklist -----------------------------------------
   The literal strings HighLevel shows, so somebody can run a finger down them
   against the scope list on screen.

   `columns: 12rem` rather than `columns: 2`: the longest string,
   locations/tags.readonly, measures about 10.75rem, and two columns inside a card on
   a 390px phone gives each one under 10 — which broke it into "reado / nly". A
   column *width* lets the browser fit one column on a phone and two on a laptop,
   and neither one splits a scope name. */

.scopes {
  margin: .3rem 0 .6rem;
  padding: 0 0 0 1.1rem;
  columns: 12rem;
  column-gap: 1.4rem;
  font-size: .8rem;
  color: var(--mute);
}

.scopes li { break-inside: avoid; }

.scopes code {
  font-family: var(--mono);
  font-size: .78rem;
  color: var(--ink);
  /* break-word, not anywhere: a scope name is only broken when it cannot fit a line
     on its own, rather than wherever it happens to run out of room. */
  overflow-wrap: break-word;
}
