/* One stylesheet, no framework. Built thumb-first: the things a worker in
   gloves has to hit are big, and the office tables scroll sideways instead of
   squashing. */

/* Gangbox: deep navy chrome, orange brand, uppercase. The brand lives in the
   header, the sidebar and the sign-in screen, which stay dark in either mode;
   the working area follows the phone's own light or dark setting, because a
   crew reads this in direct sun and the office reads it all day indoors. */
:root {
  --bg: #f1f5f9;
  --card: #ffffff;
  --ink: #0b1a2b;
  --muted: #55708c;
  --line: #dbe4ee;
  /* Gangbox navy and safety orange, measured off the logo artwork.
     Which colour does which job was decided by contrast, not by taste:

       white on navy      12.8:1   buttons, and anything with a label
       white on orange     2.9:1   fails badly, so the orange is never a
                                   background for white text
       orange on white     2.9:1   fails too, so it is never text on light

     That leaves navy carrying everything a person has to read, and the orange
     doing what it is good at: marks, indicators, the logo. These are people
     reading a phone in sunlight, often with forty-year-old eyes. */
  --accent: #1b344d;          /* Gangbox navy */
  --accent-deep: #14263a;
  --accent-ink: #ffffff;
  --brand: #e47c1f;           /* Gangbox orange — never behind white text */

  /* Buttons get their own pair. They are a gradient, and the accent in dark
     mode is a bright orange whose top end cannot carry a white label. */
  --btn: #1b344d;
  --btn-deep: #14263a;
  --good: #147a4b;
  --good-bg: #d8f3e6;
  --bad: #b91c1c;
  --bad-bg: #fee2e2;
  --warn: #9a5b06;
  --warn-bg: #fdf0d5;

  /* Brand chrome — the same in both themes. */
  --chrome: #0a1622;
  --chrome-2: #0f2032;
  --chrome-ink: #eaf3fb;
  --chrome-muted: #8fa9c2;
  --chrome-line: #1b3349;

  --radius: 12px;
  --shadow: 0 1px 2px rgba(10, 22, 34, .07), 0 10px 28px rgba(10, 22, 34, .08);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0a1622;
    --card: #101f30;
    --ink: #e8f1fa;
    --muted: #8fa9c2;
    --line: #1e3448;
    /* On a near-black page the navy is invisible — 1.44:1 against the
       background, so a navy button would not read as a button at all. The
       orange is 6.3:1 here, so on dark it is the orange that carries. */
    --accent: #e47c1f;
    --accent-deep: #c2691a;
    --brand: #e47c1f;
    /* Darkened just far enough that a white label clears 4.5:1 across the
       whole gradient: 4.9:1 at the top, 6.9:1 at the bottom. */
    --btn: #ab5d17;
    --btn-deep: #8a4a12;
    --good: #35c281;
    --good-bg: #0e2e22;
    --bad: #f2686c;
    --bad-bg: #331416;
    --warn: #f0b429;
    --warn-bg: #33270c;
    --shadow: 0 1px 2px rgba(0, 0, 0, .45);
  }
}

* { box-sizing: border-box; }

/* A class with display: grid outranks the browser's own [hidden] rule, and a
   hidden view that still paints is worse than no view at all. */
[hidden] { display: none !important; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-text-size-adjust: 100%;
  padding-bottom: env(safe-area-inset-bottom);
}

h1 { font-size: 1.4rem; margin: 0 0 .25rem; }
h2 {
  font-size: .82rem; margin: 0; font-weight: 800;
  letter-spacing: .12em; text-transform: uppercase; color: var(--muted);
}
a { color: var(--accent); }

.boot { padding: 3rem; text-align: center; color: var(--muted); }
.view.center {
  min-height: 100dvh; display: grid; place-items: center; padding: 1rem;
  background:
    radial-gradient(1100px 620px at 50% -10%, rgba(30, 136, 209, .30), transparent 60%),
    linear-gradient(180deg, var(--chrome-2), var(--chrome));
}
.view.center .card {
  background: rgba(10, 22, 34, .72);
  border-color: var(--chrome-line);
  color: var(--chrome-ink);
  backdrop-filter: blur(6px);
  box-shadow: 0 20px 60px rgba(0, 0, 0, .45);
}
.view.center .card .muted { color: var(--chrome-muted); }
.view.center label { color: var(--chrome-ink); letter-spacing: .06em; text-transform: uppercase; font-size: .72rem; }
.view.center input, .view.center select {
  background: rgba(255, 255, 255, .05); border-color: var(--chrome-line); color: var(--chrome-ink);
}
/* The sign-in card is dark in both themes, so the heading is the orange: 8.2:1
   on it, against the navy's 1.6:1. Painted as a plain colour first and only
   made transparent where the gradient can actually be clipped to the text —
   otherwise a browser without background-clip renders the product's name
   invisible, which is a poor first impression of a product. */
.view.center .brand {
  letter-spacing: .14em; text-transform: uppercase; font-weight: 800;
  color: #f09a45;
}
@supports ((background-clip: text) or (-webkit-background-clip: text)) {
  .view.center .brand {
    background: linear-gradient(100deg, #f5ad5f, #e47c1f 70%);
    -webkit-background-clip: text; background-clip: text; color: transparent;
  }
}
.view.center .linkish { color: #f0a95c; }
/* This card is dark whatever the system theme is, so the button on it takes
   the dark-mode pair regardless. In light mode it would otherwise inherit the
   navy one and sit at 1.4:1 against the card — a button nobody can see. */
.view.center .btn.primary { background: linear-gradient(180deg, #ab5d17, #8a4a12); }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1rem;
  margin: 0 0 .85rem;
}
.narrow { width: min(420px, 100%); }

label { display: block; margin: .7rem 0; font-weight: 600; font-size: .87rem; }
input, select, textarea {
  width: 100%;
  margin-top: .3rem;
  padding: .7rem .75rem;
  font: inherit;
  color: var(--ink);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 10px;
}
input:focus-visible, select:focus-visible, button:focus-visible, a:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--accent) 50%, transparent);
  outline-offset: 1px;
}
input[type=checkbox] { width: auto; margin: 0; }

.btn {
  font: inherit;
  font-weight: 650;
  padding: .7rem 1rem;
  min-height: 44px;
  border-radius: 11px;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--ink);
  cursor: pointer;
}
.btn:active { transform: translateY(1px); }
.btn.primary {
  background: linear-gradient(180deg, var(--btn), var(--btn-deep));
  color: var(--accent-ink); border-color: transparent;
  text-transform: uppercase; letter-spacing: .08em; font-size: .86rem;
}
.btn.ghost { background: transparent; }
.btn.small { padding: .35rem .6rem; min-height: 36px; font-size: .85rem; }
.btn.block { width: 100%; margin-top: .6rem; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.btn.danger { color: var(--bad); border-color: color-mix(in srgb, var(--bad) 40%, transparent); }

.btn.punch {
  width: 100%;
  margin-top: 1rem;
  min-height: 68px;
  font-size: 1.25rem;
  border: 0;
  color: #fff;
  background: var(--good);
  box-shadow: 0 6px 18px color-mix(in srgb, var(--good) 30%, transparent);
}
.btn.punch.out { background: var(--bad); box-shadow: 0 6px 18px color-mix(in srgb, var(--bad) 30%, transparent); }

.row { display: flex; align-items: center; }
.row.between { justify-content: space-between; }
.row.gap { gap: .5rem; }
.row.wrap { flex-wrap: wrap; gap: .5rem; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.error { color: var(--bad); font-size: .9rem; margin: .6rem 0 0; }
.ok { color: var(--good); font-size: .9rem; margin: .6rem 0 0; font-weight: 600; }
/* Between the two: not a refusal, but not nothing either — "three of your crew
   cannot be sent here". There was no class for this and it was being written
   as `warn`, which only exists on a pill, so it came out as plain body text. */
.notice { color: var(--warn); font-size: .9rem; margin: .6rem 0 0; font-weight: 600; }
.view.center .ok { color: #4ddc9a; }
.brand { font-size: 1.5rem; }
.linkish {
  background: none; border: 0; padding: 0; font: inherit; font-weight: 600;
  color: var(--accent); text-decoration: underline; cursor: pointer;
}

.topbar {
  position: sticky; top: 0; z-index: 5;
  display: flex; justify-content: space-between; align-items: center;
  gap: .5rem; padding: .7rem .9rem;
  padding-top: calc(.7rem + env(safe-area-inset-top));
  background: var(--chrome); color: var(--chrome-ink);
  border-bottom: 1px solid var(--chrome-line);
}
.company {
  font-weight: 800; letter-spacing: .12em; text-transform: uppercase;
  font-size: 1.05rem;
  background: linear-gradient(100deg, #f5ad5f, #e47c1f 60%);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.brand-logo { height: 30px; width: auto; display: block; }
.who { color: var(--chrome-muted); font-size: .78rem; letter-spacing: .02em; }
.topbar .btn.ghost {
  color: var(--chrome-ink); border-color: var(--chrome-line); background: transparent;
}
.topbar .btn.ghost:hover { background: rgba(255, 255, 255, .06); }
main { padding: .9rem; max-width: 900px; margin: 0 auto 5rem; }

/* status ------------------------------------------------------------------ */
.status { text-align: center; }
.status-head {
  display: flex; align-items: center; justify-content: center; gap: .5rem;
  font-weight: 800; text-transform: uppercase; letter-spacing: .1em; font-size: .8rem; color: var(--muted);
}
.dot { width: 11px; height: 11px; border-radius: 50%; background: var(--muted); }
.dot.on { background: var(--good); box-shadow: 0 0 0 5px color-mix(in srgb, var(--good) 22%, transparent); }
.elapsed { font-size: 2.9rem; font-weight: 700; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.queued { margin: .6rem 0 0; color: var(--warn); font-size: .85rem; }

.switch { position: relative; width: 52px; height: 30px; flex: none; margin: 0; }
.switch input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; z-index: 1; }
.switch span {
  position: absolute; inset: 0; background: var(--line); border-radius: 999px; transition: background .15s;
}
.switch span::after {
  content: ""; position: absolute; top: 3px; left: 3px; width: 24px; height: 24px;
  border-radius: 50%; background: #fff; transition: transform .15s; box-shadow: 0 1px 3px rgba(0,0,0,.3);
}
.switch input:checked + span { background: var(--good); }
.switch input:checked + span::after { transform: translateX(22px); }

.stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: .6rem; margin-bottom: .85rem; }
@media (min-width: 640px) { .stats { grid-template-columns: repeat(4, 1fr); } }
.stat {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: .7rem; display: flex; flex-direction: column; box-shadow: var(--shadow);
}
.stat .k { font-size: .7rem; color: var(--muted); text-transform: uppercase; letter-spacing: .1em; font-weight: 700; }
.stat .v { font-size: 1.5rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.stat .u { font-size: .78rem; color: var(--muted); }

/* lists ------------------------------------------------------------------- */
.day, .listrow {
  display: flex; justify-content: space-between; gap: .6rem;
  padding: .6rem 0; border-top: 1px solid var(--line);
}
.day:first-of-type, .listrow:first-of-type { border-top: 0; }
.listrow.tappable { cursor: pointer; }
.listrow.tappable:hover { background: color-mix(in srgb, var(--accent) 5%, transparent); }
.day .name { font-weight: 600; }
.entries { margin: .25rem 0 0; padding: 0; list-style: none; color: var(--muted); font-size: .85rem; }
.entries li { display: flex; gap: .4rem; flex-wrap: wrap; }
.nums { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.nums .h { font-weight: 700; }
.nums .pd { color: var(--good); font-size: .85rem; display: block; }

.pill {
  font-size: .75rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em;
  padding: .2rem .55rem; border-radius: 999px; background: var(--line); color: var(--muted);
}
.pill.good { background: var(--good-bg); color: var(--good); }
.pill.warn { background: var(--warn-bg); color: var(--warn); }
.pill.bad { background: var(--bad-bg); color: var(--bad); }

.scroll-x { overflow-x: auto; margin: .6rem -1rem 0; padding: 0 1rem; }
table.grid { border-collapse: collapse; width: 100%; font-size: .87rem; }
table.grid th, table.grid td { padding: .45rem .5rem; text-align: right; white-space: nowrap; border-top: 1px solid var(--line); }
table.grid th:first-child, table.grid td:first-child { text-align: left; position: sticky; left: 0; background: var(--card); }
table.grid thead th { color: var(--muted); font-size: .74rem; text-transform: uppercase; letter-spacing: .04em; border-top: 0; }
table.grid tbody tr:hover td { background: color-mix(in srgb, var(--accent) 6%, transparent); }
table.grid .zero { color: var(--muted); }
.totals { margin-top: .7rem; display: flex; gap: 1rem; flex-wrap: wrap; font-weight: 600; }
.export { margin-top: .6rem; }
.pager { margin-top: .6rem; }
.pager input[type=search] { flex: 1 1 10rem; margin-top: 0; }
.pager .muted { flex: 1 0 auto; }

/* tab bar ----------------------------------------------------------------- */
.tabs {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 6;
  display: flex; background: var(--card); border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
/* The bar scrolls rather than squashing. An admin has ten of these and a
   phone is 414px wide: with `flex: 1` and no overflow the last tab was clipped
   to "Ru" and could not be reached at all. Each button now keeps a width it
   can be read at, and the bar swipes. selectTab() scrolls the current one into
   view, so you always see where you are. */
.tabs { overflow-x: auto; scrollbar-width: none; scroll-snap-type: x proximity; }
.tabs::-webkit-scrollbar { display: none; }
.tabs button {
  flex: 1 0 auto; min-width: 4.1rem; scroll-snap-align: center;
  border: 0; background: none; color: var(--muted);
  font: inherit; font-size: .78rem; font-weight: 600; padding: .55rem .35rem .6rem; cursor: pointer;
}
.tabs button .ic { display: block; width: 22px; height: 22px; margin: 0 auto .15rem; }
.tabs button[aria-current="true"] { color: var(--accent); }

/* Phone: the bar carries what fits and More carries the rest. The headings and
   the other buttons are still in the markup — one set of buttons, two shapes,
   rather than two renderers that drift apart and leave a screen reachable on a
   laptop and nowhere on a phone. */
.tabs .navgroup { display: none; }
.tabs button[data-bar="0"] { display: none; }
.morebtn {
  position: fixed; bottom: 0; right: 0; z-index: 7;
  display: flex; flex-direction: column; align-items: center;
  min-width: 4.1rem; border: 0; border-top: 1px solid var(--line);
  border-left: 1px solid var(--line);
  background: var(--card); color: var(--muted);
  font: inherit; font-size: .78rem; font-weight: 600;
  padding: .55rem .35rem calc(.6rem + env(safe-area-inset-bottom)); cursor: pointer;
}
.morebtn .ic { display: block; width: 22px; height: 22px; margin: 0 auto .15rem; }
/* The bar must not slide under More, or its last tab is unreachable — the
   clipped "Ru" bug in a different costume. */
.tabs { padding-right: 4.1rem; }

.moresheet { border: 0; padding: 0; background: none; max-width: 100%; width: 100%; }
.moresheet::backdrop { background: rgba(8, 15, 26, .55); }
.moresheet-panel {
  position: fixed; left: 0; right: 0; bottom: 0;
  background: var(--card); border-top-left-radius: 16px; border-top-right-radius: 16px;
  padding: .9rem 1rem calc(1rem + env(safe-area-inset-bottom));
  max-height: 85dvh; overflow-y: auto;
}
.moresheet-panel h2 { margin: .1rem 0 .4rem; font-size: 1.05rem; }
.moresheet-panel .navgroup {
  margin: .9rem 0 .25rem; font-size: .72rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: .09em; color: var(--muted);
}
.moresheet-panel button[data-tab] {
  display: flex; align-items: center; gap: .7rem; width: 100%;
  border: 0; background: none; color: var(--ink);
  font: inherit; font-size: 1rem; font-weight: 600;
  padding: .7rem .4rem; border-radius: 10px; cursor: pointer; text-align: left;
}
.moresheet-panel button[data-tab] .ic { width: 20px; height: 20px; flex: none; }
.moresheet-panel button[aria-current="true"] { color: var(--accent); background: color-mix(in srgb, var(--accent) 10%, transparent); }

.toast {
  position: fixed; left: 50%; bottom: 5.2rem; transform: translateX(-50%);
  background: var(--ink); color: var(--bg); padding: .6rem 1rem; border-radius: 999px;
  font-size: .9rem; z-index: 20; max-width: 90vw; text-align: center;
}
.toast.bad { background: var(--bad); color: #fff; }

/* map ---------------------------------------------------------------------- */
.map-box {
  position: relative;
  height: 260px;
  margin: .7rem 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  background: #dfe5ec;
}
@media (min-width: 1000px) { .map-box { height: 380px; } }
.map { position: absolute; inset: 0; cursor: grab; touch-action: none; user-select: none; }
.map:active { cursor: grabbing; }
.map-tiles { position: absolute; inset: 0; }
.map-tiles img { position: absolute; top: 0; left: 0; width: 256px; height: 256px; pointer-events: none; }
.map-overlay { position: absolute; inset: 0; pointer-events: none; }
.map-overlay .fence { fill: color-mix(in srgb, #e47c1f 20%, transparent); stroke: #e47c1f; stroke-width: 2; }
.map-overlay .fence.off { fill: none; stroke: #94a3b8; stroke-dasharray: 5 4; }
.map-overlay .pin { fill: #1b344d; stroke: #fff; stroke-width: 2; }
.map-overlay .person { fill: #15803d; stroke: #fff; stroke-width: 2; }
.map-overlay .person.stale { fill: #b45309; }
.map-overlay .acc { fill: color-mix(in srgb, #15803d 14%, transparent); stroke: none; }
.map-overlay .label {
  font: 600 12px system-ui, sans-serif; fill: #0f172a; text-anchor: middle;
  paint-order: stroke; stroke: #fff; stroke-width: 3px; stroke-linejoin: round;
}
.map-credit {
  position: absolute; right: 0; bottom: 0; z-index: 2;
  background: rgba(255, 255, 255, .8); color: #334155;
  font-size: .68rem; padding: .1rem .35rem; border-radius: 6px 0 0 0;
}
.map-hint { font-size: .8rem; color: var(--muted); margin: .35rem 0 0; }
.map-warning {
  position: absolute; left: 50%; top: 12px; transform: translateX(-50%); z-index: 3;
  max-width: 90%; text-align: center; font-size: .82rem;
  background: #fef3c7; color: #7c4a02; border: 1px solid #f0c674;
  padding: .35rem .7rem; border-radius: 999px;
}
.map-empty { position: absolute; inset: 0; display: grid; place-items: center; color: var(--muted); font-size: .9rem; z-index: 2; }

fieldset { border: 1px solid var(--line); border-radius: var(--radius); margin: .9rem 0; padding: .3rem .9rem .9rem; }
legend {
  padding: 0 .45rem; font-weight: 800; font-size: .72rem;
  letter-spacing: .12em; text-transform: uppercase; color: var(--accent);
}
.handout { margin: .6rem 0; display: grid; gap: .35rem; }
.handout > div { display: flex; gap: .6rem; align-items: baseline; flex-wrap: wrap; }
.handout .k {
  min-width: 9rem; font-size: .7rem; font-weight: 700; letter-spacing: .1em;
  text-transform: uppercase; color: var(--muted);
}
.handout .v { font-weight: 700; font-size: 1.02rem; word-break: break-all; }
.grid2 { display: grid; gap: .2rem 1rem; grid-template-columns: 1fr; }
@media (min-width: 560px) { .grid2 { grid-template-columns: 1fr 1fr; } }
.inline { display: flex; align-items: center; gap: .5rem; margin: .7rem 0; font-weight: 600; font-size: .87rem; }
.inline input { width: auto; }

/* Day picker: seven small toggles instead of asking anybody to type "1,2,3". */
.days { margin-top: .35rem; }
.daychip {
  display: inline-flex; align-items: center; gap: .25rem; margin: 0;
  padding: .3rem .5rem; border: 1px solid var(--line); border-radius: 999px;
  font-size: .82rem; font-weight: 600; cursor: pointer; background: var(--bg);
}
.daychip:has(input:checked) { background: color-mix(in srgb, var(--accent) 15%, transparent); border-color: var(--accent); }
.daychip input { margin: 0; }


/* ==========================================================================
   Laptops. Below this width the layout above stands unchanged — it is what a
   phone in a glove gets. Above it, the office is sitting at a desk all day:
   the navigation moves to the side, the content uses the width it has, and
   the lists sit beside the form that edits them.
   ========================================================================== */

@media (min-width: 1000px) {
  #app {
    display: grid;
    grid-template-columns: 232px minmax(0, 1fr);
    /* The header hugs its content; the main area takes everything left over.
       Without this the auto rows share the height and the header floats in the
       middle of a very tall band. */
    grid-template-rows: auto minmax(0, 1fr);
    grid-template-areas: "nav head" "nav main";
    min-height: 100dvh;
  }

  .topbar { grid-area: head; }
  main {
    grid-area: main;
    max-width: 1500px;
    margin: 0;
    padding: 1.1rem 1.4rem 2rem;
  }

  /* The tab bar becomes a sidebar: same buttons, same markup, read top to
     bottom instead of left to right. */
  .tabs {
    grid-area: nav;
    position: sticky;
    top: 0;
    align-self: start;
    height: 100dvh;
    flex-direction: column;
    gap: .15rem;
    padding: .9rem .6rem;
    border-top: 0;
    background: var(--chrome);
    border-right: 1px solid var(--chrome-line);
  }
  /* Laptop: the whole thing, with its headings, read top to bottom. Nothing is
     behind More because there is room for all of it. */
  .tabs { padding-right: .6rem; }
  .tabs .navgroup {
    display: block; margin: .9rem .7rem .3rem; font-size: .68rem; font-weight: 700;
    text-transform: uppercase; letter-spacing: .1em; color: var(--chrome-muted); opacity: .75;
  }
  .tabs .navgroup:first-child { margin-top: .2rem; }
  .tabs button[data-bar="0"] { display: flex; }
  .morebtn { display: none; }

  .tabs button { color: var(--chrome-muted); text-transform: uppercase; letter-spacing: .08em; font-size: .78rem; }
  .tabs button:hover { background: rgba(255, 255, 255, .06); color: var(--chrome-ink); }
  .tabs button[aria-current="true"] {
    background: linear-gradient(90deg, rgba(30, 136, 209, .28), rgba(30, 136, 209, .06));
    color: #f0a95c;
    box-shadow: inset 3px 0 0 var(--accent);
  }
  .tabs button {
    display: flex;
    align-items: center;
    gap: .65rem;
    flex: 0 0 auto;
    padding: .6rem .7rem;
    border-radius: 10px;
    font-size: .95rem;
    text-align: left;
  }
  .tabs button .ic { width: 19px; height: 19px; margin: 0; flex: none; }
  .tabs button:hover { background: color-mix(in srgb, var(--accent) 8%, transparent); }
  .tabs button[aria-current="true"] { background: color-mix(in srgb, var(--accent) 12%, transparent); }

  /* A wide table has no reason to clip: let the card carry it, and keep the
     day headings in view while scrolling a long crew. */
  .scroll-x { margin: .6rem 0 0; padding: 0; }
  table.grid thead th {
    position: sticky;
    top: 0;
    z-index: 1;
    background: var(--card);
  }
  /* Tighter cells so a seven-day grid fits a small laptop without sideways
     scrolling; it still scrolls inside the card if a company uses long names. */
  table.grid { font-size: .82rem; }
  table.grid td, table.grid th { padding: .45rem .45rem; }
  /* Let a long name wrap rather than forcing the whole grid sideways. */
  table.grid td:first-child, table.grid th:first-child { white-space: normal; min-width: 7.5rem; }

  .toast { bottom: 1.5rem; left: auto; right: 1.5rem; transform: none; }
}

/* Wider still: the list and the form it edits sit side by side, so adding five
   job sites does not mean scrolling up and down five times. */
@media (min-width: 1200px) {
  #tab-people, #tab-sites {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: .85rem;
    align-items: start;
  }
  #tab-people .card, #tab-sites .card { margin: 0; }
  /* Nothing open to edit: the list takes the whole width back. */
  #tab-people:has(#person-form-card[hidden]),
  #tab-sites:has(#site-form-card[hidden]) { grid-template-columns: minmax(0, 1fr); }
}

/* Why the fence is doing nothing. Shown only when something is actually wrong,
   so it reads as a fault to fix and not as decoration. */
.geo-problem {
  margin-top: .75rem;
  padding: .75rem .85rem;
  border: 1px solid var(--warn);
  border-left-width: 4px;
  border-radius: 8px;
  background: var(--warn-bg);
  color: var(--ink);
}
.geo-problem strong { display: block; color: var(--warn); }
.geo-problem p { margin: .35rem 0 0; font-size: .9rem; }
.geo-problem ul { margin: .5rem 0 0; padding-left: 1.1rem; font-size: .85rem; color: var(--muted); }
.geo-problem li + li { margin-top: .3rem; }

/* The office view of the same thing, one row per person. */
.geo-status { display: grid; gap: .5rem; }
.geo-status .who { display: flex; justify-content: space-between; gap: .75rem; align-items: baseline; flex-wrap: wrap; }
.geo-row {
  padding: .6rem .75rem;
  border: 1px solid var(--line);
  border-left: 4px solid var(--ok, var(--line));
  border-radius: 8px;
}
.geo-row.trouble { border-left-color: var(--warn); background: var(--warn-bg); }
.geo-row .why { font-size: .85rem; color: var(--muted); margin-top: .2rem; }
.geo-row .facts { font-size: .8rem; color: var(--muted); margin-top: .25rem; }

/* Days off. One request per row, readable at a glance on a phone. */
.requests { display: grid; gap: .6rem; }
.request {
  padding: .7rem .8rem;
  border: 1px solid var(--line);
  border-left: 4px solid var(--line);
  border-radius: 8px;
}
.request.pending { border-left-color: var(--warn); }
.request.approved { border-left-color: var(--good); }
.request.denied { border-left-color: var(--bad); }
.request.cancelled { opacity: .65; }
.request .who { display: flex; justify-content: space-between; gap: .75rem; align-items: baseline; flex-wrap: wrap; }
.request .when { font-size: .9rem; margin-top: .15rem; }
.request .facts { font-size: .82rem; color: var(--muted); margin-top: .25rem; }
.request .note { font-size: .85rem; margin-top: .35rem; }
.request .row { margin-top: .55rem; }
.stack { display: grid; gap: .75rem; }

/* A note under a settings box saying the value there is being overridden. */
.field-warn {
  margin: .35rem 0 0;
  padding: .45rem .6rem;
  font-size: .82rem;
  border-left: 3px solid var(--warn);
  background: var(--warn-bg);
  border-radius: 0 6px 6px 0;
}
.field-warn strong { color: var(--warn); }

/* Editable punches in the payroll drill-down. */
.entries .punch { list-style: none; padding: .45rem 0; border-top: 1px solid var(--line); }
.entries .punch:first-child { border-top: 0; }
.entries .punch.adding { background: var(--warn-bg); border-radius: 6px; padding: .5rem; }
/* What happened to a punch, written under it. Deliberately quiet: this is read
   when somebody rings up asking why Tuesday says fourteen hours, and it must
   not compete with the times and the site above it. The dash markers are drawn
   rather than using list bullets, because `.entries li` is a flex row and a
   real bullet would sit on the wrong line. */
.entries .story {
  /* `.entries li` is a flex row, so without this the story wraps up beside the
     hours when it happens to fit and drops below them when it does not — the
     same screen laid out two ways depending on the length of a site name. */
  flex: 0 0 100%;
  margin: .3rem 0 0;
  padding: 0 0 0 .95rem;
  list-style: none;
}
.entries .story li {
  display: block;
  position: relative;
  color: var(--muted);
  font-size: .8rem;
  line-height: 1.45;
}
.entries .story li::before {
  content: '\2013';
  position: absolute;
  left: -.95rem;
}

/* A punch worth opening rather than scrolling past: away from every job site,
   no location at all, closed by the server rather than by the worker, changed
   by hand, or placed from a fix too vague to tell one end of a site from the
   other. The bar is on the left edge so a column of punches can be scanned
   down without reading any of them. */
.entries .punch.look {
  border-left: 3px solid var(--warn);
  padding-left: .55rem;
}
.entries .punch.look .story li::before { color: var(--warn); }

.entries .punch input[type=date] { width: 9.5rem; }
.entries .punch input[type=time] { width: 8.75rem; }
.entries .punch select { max-width: 11rem; }
.entries .punch .row { align-items: center; }

/* Who is off, as a wall calendar. Seven columns whatever the width; on a phone
   the whole grid scrolls sideways rather than squeezing a name into 40px. */
.cal {
  display: grid;
  grid-template-columns: repeat(7, minmax(7.5rem, 1fr));
  gap: 1px;
  background: var(--line);
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  min-width: 52rem;
}
.cal-head {
  background: var(--card);
  padding: .4rem .5rem;
  font-size: .75rem;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--muted);
  text-align: center;
}
.cal-day {
  background: var(--card);
  min-height: 5.5rem;
  padding: .35rem .4rem .45rem;
  display: flex;
  flex-direction: column;
  gap: .2rem;
}
.cal-day .n { font-size: .8rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.cal-day.spill { opacity: .45; }
.cal-day.rest { background: var(--bg); }
.cal-day.today { outline: 2px solid var(--accent); outline-offset: -2px; }
.cal-day.today .n { color: var(--accent); font-weight: 700; }

.chip {
  display: block;
  font-size: .74rem;
  line-height: 1.25;
  padding: .12rem .35rem;
  border-radius: 4px;
  border-left: 3px solid transparent;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.chip.approved { background: var(--good-bg); color: var(--good); border-left-color: var(--good); }
.chip.pending { background: var(--warn-bg); color: var(--warn); border-left-color: var(--warn); }
.chip.more { color: var(--muted); }
.cal-key { display: flex; gap: .5rem; align-items: center; margin-top: .6rem; }
.cal-key .chip { display: inline-block; }

/* The status board: three colours, readable from across an office. */
.tallies { display: grid; grid-template-columns: repeat(auto-fit, minmax(8rem, 1fr)); gap: .6rem; margin: .8rem 0 1rem; }
.tally {
  padding: .7rem .85rem;
  border: 1px solid var(--line);
  border-left: 5px solid var(--line);
  border-radius: 8px;
  display: flex; flex-direction: column; gap: .1rem;
}
.tally .count { font-size: 1.9rem; font-weight: 700; line-height: 1; font-variant-numeric: tabular-nums; }
.tally .what { font-size: .78rem; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }
.tally.green { border-left-color: var(--good); } .tally.green .count { color: var(--good); }
.tally.blue  { border-left-color: var(--accent); } .tally.blue .count { color: var(--accent); }
.tally.red   { border-left-color: var(--bad); } .tally.red .count { color: var(--bad); }

.board { display: grid; gap: .1rem; }
.board h3.group {
  font-size: .78rem; letter-spacing: .1em; text-transform: uppercase;
  margin: 1.1rem 0 .4rem; padding-bottom: .3rem; border-bottom: 1px solid var(--line);
}
.board h3.group.green { color: var(--good); }
.board h3.group.blue { color: var(--accent); }
.board h3.group.red { color: var(--bad); }
.board .person { display: flex; gap: .65rem; align-items: center; padding: .45rem .2rem; border-bottom: 1px solid var(--line); }
.board .person:last-child { border-bottom: 0; }
.board .person .dot { width: .7rem; height: .7rem; border-radius: 50%; flex: none; background: var(--muted); }
.board .person.green .dot { background: var(--good); }
.board .person.blue .dot { background: var(--accent); }
.board .person.red .dot { background: var(--bad); }
.board .person .name { font-weight: 600; }
#board-search { width: 100%; }

/* A message from the office, on the crew's clock screen. */
.card.notice { border-left: 4px solid var(--accent); background: var(--accent-soft, var(--card)); }
.card.notice p { margin: .4rem 0 .7rem; }

/* Testing the map tile address from the browser that has to load them. */

/* The fence, chosen in words. Each option carries its own sentence, so they
   are laid out as cards rather than a list of radio buttons with labels. */
.presets { display: grid; gap: .5rem; margin-bottom: 1rem; }
.preset {
  display: grid; grid-template-columns: auto 1fr; gap: .65rem; align-items: start;
  padding: .7rem .8rem; border: 1px solid var(--line, #d7dee8); border-radius: .5rem;
  cursor: pointer; background: #fff;
}
.preset:hover { border-color: #9db4d4; }
.preset:has(input:checked) { border-color: #1b344d; background: #f6f8fa; box-shadow: inset 0 0 0 1px #1b344d; }
.preset input { margin-top: .2rem; }
.preset span span { display: block; margin-top: .15rem; }
.preset-custom { margin: 0; }

/* Settings that exist for the rare site that needs them, out of the way of
   the ones everybody needs. */
.tuning { margin-top: 1rem; border-top: 1px solid var(--line, #d7dee8); padding-top: .75rem; }
.tuning > summary { cursor: pointer; font-weight: 600; font-size: .95rem; }
.tuning > p { margin: .5rem 0 .75rem; }

/* On the sign-in page the product's name is the heading and the company's name
   sits under it — so somebody who followed a stale link to the wrong customer
   sees it before their third failed password.

   The colour has to come from the chrome palette, not --ink. This card is dark
   in both themes, while --ink flips with the theme: it was invisible in light
   mode and fine in dark, which is the worst way for a bug like this to behave. */
.view.center .card #login-company {
  margin: -.35rem 0 .5rem;
  font-weight: 600;
  color: var(--chrome-ink);
}

/* ---------------------------------------------------- the person card popup */

/* A name you can click. Styled as the text it replaces, not as a button: the
   office should not have to hunt for a control, the name IS the control. The
   underline only on hover and focus keeps a roster of fifty from looking like
   a page of links. */
.namelink {
  background: none;
  border: 0;
  padding: 0;
  font: inherit;
  color: inherit;
  text-align: left;
  cursor: pointer;
}
.name.namelink { font-weight: 600; }
.namelink:hover { text-decoration: underline; }
.namelink:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 3px; }
.gridname { white-space: nowrap; }

.personcard {
  width: min(34rem, calc(100vw - 2rem));
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 1.1rem 1.2rem 1.3rem;
  background: var(--card);
  color: var(--ink);
  box-shadow: 0 24px 60px rgba(0, 0, 0, .28);
}
.personcard::backdrop { background: rgba(8, 18, 30, .55); }

.cardhead { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; }
.cardhead h2 { margin: 0 0 .15rem; }

.cardstatus { display: flex; align-items: center; gap: .55rem; margin: .8rem 0; font-weight: 600; }
.cardstatus .dot { width: .7rem; height: .7rem; border-radius: 50%; flex: none; background: var(--muted); }
.cardstatus.green .dot { background: var(--good); }
.cardstatus.blue .dot { background: var(--accent); }
.cardstatus.red .dot { background: var(--bad); }

.cardsub { margin: 1.1rem 0 .35rem; font-size: .8rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }

/* Label and value on one row, the labels in a column of their own so the eye
   can run down the values. Wraps to two lines on a phone rather than
   squeezing a long site name into nothing. */
.cardlines { display: grid; gap: .3rem; }
.cardline { display: grid; grid-template-columns: 11rem 1fr; gap: .5rem; align-items: baseline; }
.cardline .k { color: var(--muted); font-size: .85rem; }
.cardline .v { word-break: break-word; }
.cardline a.v { color: var(--accent); }
@media (max-width: 30rem) {
  .cardline { grid-template-columns: 1fr; gap: 0; }
  .cardline .k { font-size: .75rem; }
}

.cardpills { margin-top: .9rem; }
.cardactions { margin-top: 1.1rem; padding-top: .9rem; border-top: 1px solid var(--line); }

/* Eight weeks as eight bars. The shape is the point — five days, five days,
   nothing, five days is a different fact from an average of four, and nobody
   reads eight numbers in a column looking for it. */
.record { margin-top: .6rem; }
.weekbars { display: grid; gap: .3rem; margin-top: .9rem; }
.weekbar { display: grid; grid-template-columns: 3.2rem 1fr 3.6rem 3.2rem; gap: .5rem; align-items: center; }
/* Why a short week was short. Without it, a holiday fortnight and a fortnight
   somebody did not turn up draw exactly the same picture. */
.weekbar .off { color: var(--accent); font-size: .72rem; white-space: nowrap; }
.weekbar .wk { color: var(--muted); font-size: .75rem; font-variant-numeric: tabular-nums; }
.weekbar .hrs { color: var(--muted); font-size: .78rem; text-align: right; font-variant-numeric: tabular-nums; }
.weekbar .bar { background: var(--line); border-radius: 999px; height: .5rem; overflow: hidden; }
.weekbar .bar i { display: block; height: 100%; background: var(--accent); border-radius: 999px; }
/* A week with nothing in it draws no bar at all rather than a sliver that
   could be mistaken for a short week. */
.weekbar .bar i.none { width: 0 !important; }

/* What has happened to an account. The bar down the left says who at a glance:
   the office, the person themselves, or the server — which is the first thing
   somebody wants to know and the slowest thing to read out of a sentence. */
.trail { list-style: none; margin: .7rem 0 0; padding: 0; display: grid; gap: .1rem; }
.trail li {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: .6rem;
  align-items: baseline;
  padding: .4rem .55rem;
  border-left: 3px solid var(--line);
  border-radius: 0 4px 4px 0;
}
.trail li .what { font-size: .85rem; }
.trail li .when { color: var(--muted); font-size: .72rem; white-space: nowrap; font-variant-numeric: tabular-nums; }
.trail li.byoffice { border-left-color: var(--accent); }
.trail li.bythem { border-left-color: var(--good); }
.trail li.bysystem { border-left-color: var(--muted); }
@media (max-width: 30rem) {
  .trail li { grid-template-columns: 1fr; gap: 0; }
}

/* The one name in the app that has to advertise itself. Everywhere else a name
   sits in a list an office person is already working through, so an underline
   on hover is enough. Here it is a crew member's only route to their own card,
   on a screen they open to clock in and nothing else — nobody is going to
   guess it is tappable, so it says so. */
.who .namelink {
  text-decoration: underline;
  text-decoration-style: dotted;
  text-underline-offset: 2px;
}
.who .namelink:hover { text-decoration-style: solid; }

/* The three things on your own card that are yours to change. */
.personcard form.mine { margin-top: .5rem; display: grid; gap: .55rem; }
.personcard form.mine label { display: grid; gap: .2rem; font-size: .8rem; color: var(--muted); }
.personcard form.mine input { font-size: .95rem; }

/* ------------------------------------------------------------- scheduling */

/* A planned shift. The bar down the left is the answer, because "has he said
   yes?" is the only thing an office scanning a fortnight is looking for. */
.listrow.plan { border-left: 3px solid var(--line); padding-left: .6rem; }

/* On a phone the two answer buttons were squeezed into whatever width was left
   beside the shift, wrapping the answer onto three lines. A crew member
   answering this is standing somewhere with gloves on; the buttons stack and
   go full width instead. */
@media (max-width: 30rem) {
  #my-shifts-list .listrow.plan { flex-direction: column; align-items: stretch; }
  #my-shifts-list .listrow.plan .row.gap { margin-top: .6rem; }
  #my-shifts-list .listrow.plan .row.gap .btn { flex: 1; text-align: center; }
}
.listrow.plan.warn { border-left-color: var(--warn); }
.listrow.plan.good { border-left-color: var(--good); }
.listrow.plan.bad { border-left-color: var(--bad); }

/* The form for putting somebody on a shift, inside the schedule card. */
.subcard {
  margin: .8rem 0;
  padding: 1rem;
  background: var(--warn-bg);
  border-radius: 10px;
}
.subcard h3 { margin-top: 0; }

/* ------------------------------------------------------------------ Today */
/* The operational screen: tiles across the top, then one row per person with
   the schedule beside the punch. Built to be read across an office at ten past
   six, which means the numbers are large and the one that matters is red. */

.tilerow {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(7.5rem, 1fr);
  gap: .55rem;
  overflow-x: auto;
  margin: .8rem -1rem .4rem;
  padding: 0 1rem .3rem;
  scroll-snap-type: x proximity;
}
.tile {
  border: 1px solid var(--line);
  border-radius: .7rem;
  padding: .6rem .75rem;
  background: var(--card);
  scroll-snap-align: start;
}
.tile .n { font-size: 1.6rem; font-weight: 700; line-height: 1.1; }
.tile .l { color: var(--muted); font-size: .76rem; margin-top: .15rem; }
/* The only tile allowed to shout. Everything else is a count; this one is
   somebody standing on nothing, and the eye should land on it first. */
.tile.alert { border-color: var(--bad); background: var(--bad-bg); }
.tile.alert .n, .tile.alert .l { color: var(--bad); }
.tile.alert .l { font-weight: 600; }

/* Regular + overtime + paid time off = total. The operators are there because
   a row of four numbers with no arithmetic between them is four facts; with
   the plus signs it is one sentence. */
.hoursbar {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: .5rem .7rem;
  padding: .55rem .7rem;
  border: 1px solid var(--line);
  border-radius: .7rem;
  font-size: .82rem;
  margin-bottom: .8rem;
}
.hoursbar .fig { font-weight: 700; font-variant-numeric: tabular-nums; }
.hoursbar .lab { color: var(--muted); }
.hoursbar .op { color: var(--muted); font-weight: 700; }
.hoursbar .sum .fig { color: var(--accent); }

.avatar {
  width: 1.85rem; height: 1.85rem; border-radius: 50%;
  display: inline-grid; place-items: center;
  font-size: .68rem; font-weight: 700; letter-spacing: .02em;
  color: #fff; flex: none;
}
/* Eight fixed colours rather than a generated hue, so every one of them can be
   checked against white text once. All clear 4.5:1. */
.avatar.t0 { background: #1b344d; }
.avatar.t1 { background: #0f6f54; }
.avatar.t2 { background: #8a3d8f; }
.avatar.t3 { background: #a4501a; }
.avatar.t4 { background: #1d5f8a; }
.avatar.t5 { background: #7a3030; }
.avatar.t6 { background: #3f4e8c; }
.avatar.t7 { background: #55611b; }

.who { display: flex; align-items: center; gap: .5rem; }
.who .nm { font-weight: 600; }
.who .sub { color: var(--muted); font-size: .72rem; }

/* How late, in the clock-in column. Grey when they turned up anyway, red when
   nobody has. */
.late { font-size: .7rem; padding: .05rem .3rem; border-radius: .3rem; background: var(--line); color: var(--muted); }
.late.bad { background: var(--bad-bg); color: var(--bad); font-weight: 700; }

.pin { background: none; border: 0; cursor: pointer; color: var(--line); padding: .1rem .25rem; font-size: .9rem; }
.pin.on { color: var(--brand); }
.pin:focus-visible { outline: 2px solid var(--accent); border-radius: .3rem; }

table.grid tr.pinned td { background: color-mix(in srgb, var(--brand) 7%, var(--card)); }
table.grid td .dash { color: var(--muted); }

@media print {
  /* Printing the Today screen is a sign-in sheet. */
  .tilerow, .pin, #today-search, #today-nav { display: none !important; }
}

/* Breaks on a punch: the sentences, then whatever can be done about them. */
.breakblock {
  display: flex; flex-wrap: wrap; align-items: center; gap: .35rem .6rem;
  margin-top: .4rem; padding-top: .4rem; border-top: 1px dashed var(--line);
}
.breakblock .muted { flex-basis: 100%; }

/* Sitting down to lunch is neither working nor gone. */
.status-head .dot.resting { background: var(--warn); }
/* The status card is centred, so the break buttons under it are too. */
#break-row { justify-content: center; margin-top: .6rem; }

/* A month of somebody's punches, week by week. */
.monthnav { margin: .5rem 0; }
.monthtotals { margin: .3rem 0 .8rem; }
.monthtotals b { font-size: 1.15rem; }
.monthweek { border-top: 1px solid var(--line); padding: .55rem 0; }
.monthweek .weekhead { font-size: .85rem; margin-bottom: .3rem; }
.monthdays { list-style: none; margin: 0; padding: 0; display: grid; gap: .35rem; }
.monthdays > li { padding-left: .1rem; }
.monthdays .daykey { font-weight: 600; min-width: 4.2rem; display: inline-block; }
/* A day from the month before, shown because the week was paid for it. */
.monthdays > li.outside { opacity: .62; }

/* The tick-and-approve bar over the payroll grid. */
.selbar {
  align-items: center; margin: .5rem 0; padding: .5rem .7rem;
  border: 1px solid var(--accent); border-radius: .7rem;
  background: color-mix(in srgb, var(--accent) 7%, transparent);
}
table.grid td input[type="checkbox"], table.grid th input[type="checkbox"] { width: 18px; height: 18px; }

/* The import review: problems in red, things worth knowing in amber. */
#import-card textarea { width: 100%; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .8rem; }
#import-card ul.bad li { color: var(--bad); }
#import-card ul.warn li { color: var(--warn); }
#import-card details { margin: .4rem 0; }

/* "Needs you": one line per thing, each a way in. */
.needs { margin: .7rem 0 .2rem; }
.needlist { display: grid; gap: .35rem; }
.needitem {
  display: flex; align-items: center; gap: .6rem; width: 100%;
  text-align: left; font: inherit; font-size: .88rem; cursor: pointer;
  padding: .5rem .7rem; border-radius: .6rem;
  border: 1px solid color-mix(in srgb, var(--warn) 35%, transparent);
  background: var(--warn-bg); color: var(--ink);
}
.needitem:hover { border-color: var(--warn); }
.needitem .needcount {
  font-weight: 700; font-variant-numeric: tabular-nums; color: var(--warn);
  min-width: 1.6rem; text-align: right;
}

/* Said before the browser's permission box, not after it. */
.geo-why { margin-top: .6rem; padding-top: .6rem; border-top: 1px solid var(--line); }
.geo-why ul { margin: .4rem 0 .5rem; padding-left: 1.1rem; }
.geo-why li { margin: .2rem 0; }

/* The company's own page. Two pictures side by side on a laptop and stacked on
   a phone, with the preview boxed so an uploaded logo on a white background
   does not look like a hole in the card. */
.pagepics { display: grid; gap: 1rem; grid-template-columns: 1fr; }
@media (min-width: 720px) { .pagepics { grid-template-columns: 1fr 1fr; } }
.pagepic { display: flex; flex-direction: column; gap: .5rem; min-width: 0; }
.pagepic img {
  display: block; max-width: 100%; border: 1px solid var(--line); border-radius: 8px;
  background: #fff; padding: .4rem; object-fit: contain;
}
#page-logo { max-height: 140px; width: auto; align-self: flex-start; }
#page-banner { max-height: 160px; width: 100%; }

/* Certifications under a personnel file. The form sits inside a dialog that
   already scrolls, so it stacks rather than gridding. */
.credblock { margin-top: 1rem; }
.credform { display: flex; flex-direction: column; gap: .6rem; margin-top: .5rem; }
.credform h4 { margin: 0; }

/* The gate requirements on a job site. A column on a phone, two or three
   across on a laptop, so fifteen tickets are not fifteen screens of scrolling. */
.gatebox { margin-top: 1rem; }
.gategrid { display: grid; gap: .35rem .9rem; grid-template-columns: 1fr; }
@media (min-width: 560px) { .gategrid { grid-template-columns: 1fr 1fr; } }
@media (min-width: 900px) { .gategrid { grid-template-columns: 1fr 1fr 1fr; } }

/* The public page. One column, nothing to navigate: somebody who followed a
   link here is deciding whether to ring this company. */
.publicpage { background: var(--bg); min-height: 100vh; }
.pagewrap { max-width: 44rem; margin: 0 auto; padding: 1.5rem 1rem 0; }
.pagecard { overflow: hidden; }
.pagebanner { display: block; width: 100%; height: auto; border-radius: 8px; margin-bottom: 1rem; }
.pagehead { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; }
.pagelogo { width: 72px; height: 72px; object-fit: contain; background: #fff; border-radius: 8px; padding: .3rem; }
.pagename { margin: 0; font-size: 1.6rem; }
.pageabout { margin: 1rem 0 0; line-height: 1.55; white-space: pre-line; }
.pagecard .cardlines { margin-top: 1.25rem; }
.pagecard .cardlines + p { margin-top: 1rem; }
.pagefoot { max-width: 44rem; margin: 0 auto; padding: 1rem; text-align: center; }

/* The help assistant. A button that sits out of the way and a panel that does
   not cover the screen it is being asked about. */
.helpbtn {
  position: fixed; right: 1rem; bottom: 1rem; z-index: 40;
  display: flex; align-items: center; gap: .4rem;
  padding: .55rem .9rem; border-radius: 999px; border: 1px solid var(--line);
  background: var(--card); color: var(--ink); box-shadow: var(--shadow);
  font: inherit; font-weight: 600; cursor: pointer;
}
.helpbtn:hover { border-color: var(--accent); }
/* On a phone the tab bar owns the bottom of the screen, so the button lifts
   clear of it rather than sitting on top of Today. */
@media (max-width: 900px) { .helpbtn { bottom: 5.2rem; } }

.helppanel {
  position: fixed; right: 1rem; bottom: 1rem; z-index: 41;
  width: min(26rem, calc(100vw - 2rem)); max-height: min(34rem, 80vh);
  display: flex; flex-direction: column;
  background: var(--card); border: 1px solid var(--line); border-radius: 12px;
  box-shadow: var(--shadow); overflow: hidden;
}
@media (max-width: 900px) { .helppanel { bottom: 5.2rem; max-height: 70vh; } }
.helphead {
  display: flex; align-items: flex-start; justify-content: space-between; gap: .75rem;
  padding: .75rem .9rem; border-bottom: 1px solid var(--line);
}
.helplog { flex: 1; overflow-y: auto; padding: .75rem .9rem; display: flex; flex-direction: column; gap: .6rem; }
.helpturn { max-width: 90%; padding: .5rem .7rem; border-radius: 10px; line-height: 1.45; white-space: pre-wrap; }
.helpturn.you { align-self: flex-end; background: var(--accent-bg, var(--bg)); border: 1px solid var(--line); }
.helpturn.them { align-self: flex-start; background: var(--bg); border: 1px solid var(--line); }
.helpturn.bad { align-self: flex-start; background: var(--bad-bg); color: var(--bad); }
.helpask { display: flex; gap: .5rem; padding: .75rem .9rem; border-top: 1px solid var(--line); }
.helpask input { flex: 1; min-width: 0; }

/* The directory. A search form that has to be usable one-handed on a phone and
   not sprawl across a desk monitor, and a list of cards whose first line is the
   one thing somebody is scanning for: the name and how far away they are. */
.hubform { display: grid; gap: .75rem; }
@media (min-width: 720px) {
  .hubform { grid-template-columns: 2fr 1fr 1fr 1fr; align-items: end; }
  .hubform > :last-child { grid-column: 1 / -1; }
}
.hubitem {
  display: flex; flex-direction: column; gap: .4rem;
  padding: .8rem 0; border-top: 1px solid var(--line); min-width: 0;
}
.hubitem:first-child { border-top: 0; }
.hubitem p { margin: 0; }
.hubitem a { color: var(--accent); font-weight: 600; }
/* Long trade labels wrap rather than pushing the card sideways: "Controls /
   instrumentation" beside "Fire protection" is wider than a phone. */
.hubitem .trades { row-gap: .3rem; }
/* The trades on a public page: pills under the name, wrapping on a phone. */
.pagetrades { display: flex; flex-wrap: wrap; gap: .4rem; margin: .9rem 0 .6rem; }
/* Two fields that belong together — a latitude and its longitude. Side by side
   where there is room, one above the other on a phone, and each the full width
   of whatever it is in, which a wrapping row does not give. */
.pairfields { display: grid; gap: .75rem; grid-template-columns: 1fr; }
@media (min-width: 560px) { .pairfields { grid-template-columns: 1fr 1fr; } }
