/* Designed for the conditions, not for a design review: gloves, one hand, bright
   sun on a cracked screen, and a three-year-old mid-range Android. That means
   large targets, hard contrast, no hairlines, and no colour that has to be
   distinguished from another colour to be understood. */

/* CSC-WORK brand (Graphite & Signal Orange). Orange is for actions only; the
   product's own tag colour marks the job cards and the logo. Corners are 6px
   and lines 1px, but the tap target does not shrink for the brand. */
@font-face {
  font-family: "Figtree";
  src: url('/fonts/figtree.woff2') format('woff2');
  font-weight: 400 700;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Bricolage Grotesque";
  src: url('/fonts/bricolage.woff2') format('woff2');
  font-weight: 600 800;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "JetBrains Mono";
  src: url('/fonts/jetbrains-mono.woff2') format('woff2');
  font-weight: 500;
  font-style: normal;
  font-display: swap;
}

:root {
  color-scheme: dark;
  --bg: #1E2328;          /* graphite */
  --panel: #2A3036;
  --panel-2: #323940;
  --line: #4B5259;
  --ink: #F2F1EE;         /* concrete */
  --ink-dim: #A9AFB5;
  --accent: #E0561B;      /* signal orange — actions and focus only */
  --accent-dark: #C24714;
  --on-accent: #15191D;   /* white on orange fails contrast */
  --link: #7FAED0;
  --tag: #D9A21E;         /* FieldFlow's product colour */
  --ok: #4ec98a;          /* 6.4:1 on --panel */
  --warn: #ffb020;
  --bad: #ff6b6b;         /* 4.8:1 on --panel — AA, kept */
  --tap: 52px;
  --radius: 6px;
  --font-body: "Figtree", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-head: "Bricolage Grotesque", "Figtree", system-ui, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, "SFMono-Regular", Menlo, monospace;
}

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

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 17px/1.45 var(--font-body);
  overscroll-behavior-y: contain;
}

.screen {
  padding: 12px 12px calc(96px + env(safe-area-inset-bottom));
  max-width: 720px;
  margin: 0 auto;
}

h1 { font: 800 22px/1.2 var(--font-head); margin: 4px 0 2px; }
h2 { font: 800 18px/1.25 var(--font-head); margin: 20px 0 8px; color: var(--ink-dim); }
a { color: var(--link); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
p { margin: 6px 0; }
.dim { color: var(--ink-dim); }

/* ---- banner: the first thing that must be true on screen ---- */
.banner {
  position: sticky; top: 0; z-index: 5;
  padding: 10px 14px; font-weight: 600;
  background: var(--warn); color: #241a00;
}
.banner.bad { background: var(--bad); color: #2a0000; }

/* ---- job cards ---- */
.card {
  display: block; width: 100%; text-align: left;
  background: var(--panel); border: 1px solid var(--line);
  border-left: 6px solid var(--tag);
  border-radius: var(--radius); padding: 14px; margin: 10px 0;
  color: inherit; font: inherit; min-height: var(--tap);
}
.card:active { background: var(--panel-2); }
.card .when { font-size: 20px; font-weight: 700; }
.card .who { font-size: 18px; font-weight: 600; margin-top: 2px; }
.card .where, .card .why { color: var(--ink-dim); margin-top: 4px; }
.card.done { border-left-color: var(--ok); }
.card.stuck { border-left-color: var(--bad); }

.chip {
  display: inline-block; padding: 3px 10px; border-radius: 999px;
  font: 500 12px/1.5 var(--font-mono); letter-spacing: 1px; text-transform: uppercase;
  background: var(--panel-2); color: var(--ink-dim); border: 1px solid var(--line);
}
.chip.ok { background: rgba(78,201,138,.15); color: var(--ok); border-color: var(--ok); }
.chip.bad { background: rgba(255,107,107,.15); color: var(--bad); border-color: var(--bad); }

/* ---- detail ---- */
.block { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; margin: 10px 0; }
.row { display: flex; justify-content: space-between; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.row:last-child { border-bottom: 0; }
.row .qty { font-variant-numeric: tabular-nums; white-space: nowrap; }
.short { color: var(--bad); font-weight: 700; }
.have { color: var(--ok); font-weight: 700; }

.action, .ghost, .link {
  min-height: var(--tap); border-radius: var(--radius); font: inherit; font-weight: 700;
  padding: 0 18px; border: 1px solid var(--line);
}
.action { background: var(--accent); color: var(--on-accent); border-color: var(--accent); }
.action:hover { background: var(--accent-dark); border-color: var(--accent-dark); }
.ghost { background: transparent; color: var(--ink-dim); }
.link {
  display: flex; align-items: center; justify-content: center;
  background: var(--panel-2); color: var(--ink); text-decoration: none; flex: 1;
}
.links { display: flex; gap: 10px; margin-top: 10px; }

/* ---- bottom bar: thumb reach, always ---- */
.bar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 5;
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px calc(10px + env(safe-area-inset-bottom));
  background: var(--panel); border-top: 1px solid var(--line);
}
.bar .synced { flex: 1; color: var(--ink-dim); font-size: 14px; }

/* ---- sign-in: the CSC-WORK layout every Flow product shares (brand.js) ----
   A layer over the whole page, so the office topbar and the device's sync bar
   are not behind it asking to be tapped. */
.signin {
  position: fixed; inset: 0; z-index: 20; overflow-y: auto;
  display: flex; flex-direction: column;
  background: var(--bg); border-top: 4px solid var(--tag);
}
body:has(.signin) .topbar, body:has(.signin) .vendor-notice { display: none; }
.signin-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 16px 20px;
}
.lockup { display: flex; align-items: center; gap: 10px; min-width: 0; }
.lockup .login-logo { max-height: 28px; max-width: 160px; margin: 0; padding: 2px; }
.product {
  font: 800 20px/1.2 var(--font-head); padding-bottom: 2px;
  border-bottom: 3px solid var(--tag);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.mark {
  flex: 0 0 auto; display: inline-flex; align-items: center; justify-content: center;
  width: 28px; height: 28px; border-radius: 4px;
  background: var(--tag); color: #15191D;
  font: 800 13px/1 var(--font-head); letter-spacing: -.02em;
}
.byline { flex: 0 0 auto; display: flex; align-items: center; gap: 6px;
          color: var(--ink-dim); font-size: 13px; }
.wm { font: 800 14px/1 var(--font-head); color: var(--ink); white-space: nowrap; }
.wm i { display: inline-block; width: 10px; height: 4px; margin: 0 2px;
        background: #E0561B; vertical-align: middle; }
.signin-main {
  flex: 1 0 auto; display: flex; flex-direction: column; align-items: center;
  padding: 6vh 16px 32px;
}
.signin-card {
  width: 100%; max-width: 420px; padding: 32px;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
}
.signin-card h1 { font-size: 26px; margin: 4px 0 6px; }
.signin-card > .dim { margin: 0 0 16px; }
.eyebrow {
  margin: 0; color: var(--ink-dim);
  font: 500 12px/1.4 var(--font-mono); text-transform: uppercase; letter-spacing: 1.5px;
}
.signin-foot { margin: 16px 0 0; color: var(--ink-dim); font-size: 13px; text-align: center; }
.signin-foot a { color: var(--link); }
@media (max-width: 420px) {
  .signin-card { padding: 24px 18px; }
  .signin-head { padding: 14px 16px; }
  .byline > :first-child { display: none; }
}

.login { margin: 0; }
.login label { display: block; margin-top: 12px; color: var(--ink-dim); font-size: 14px; font-weight: 600; }
.login input {
  display: block; width: 100%; min-height: var(--tap); margin: 6px 0 0;
  padding: 0 14px; font: inherit; font-size: 17px; font-weight: 400;
  background: #15191D; color: var(--ink);
  border: 1px solid var(--line); border-radius: var(--radius);
}
.login input:focus { border-color: var(--accent); outline: none; }
.login .error { margin-top: 10px; }
.login .action { width: 100%; margin-top: 8px; }
.error { color: var(--bad); font-weight: 600; min-height: 24px; }

/* Actions added with recording work. `wide` is a full-width primary — the one
   thing a gloved thumb should not have to aim at. */
.action.wide { width: 100%; margin-top: 12px; }
.ghost.tiny { min-height: 40px; padding: 0 12px; margin-left: 6px; }
select.link, input.link { padding: 0 12px; }
input.link { max-width: 90px; text-align: center; }
label.link { cursor: pointer; }

/* The signature pad. White, because a customer signs on white, and big enough
   that a finger is not trying to write in a slot. */
.pad {
  width: 100%; height: 200px; margin: 10px 0;
  background: #fff; border-radius: var(--radius); border: 1px solid var(--line);
  touch-action: none;   /* the page must not scroll while someone is signing */
}
.link.wide, .ghost.wide { width: 100%; margin-top: 10px; }
input.link.wide { max-width: none; text-align: left; }

/* ---- the office console -------------------------------------------------
   A different audience on a different device: a desk, a mouse, and a person
   who wants to see everything wrong at once rather than one card at a time. */
body.office .wide { max-width: 1180px; margin: 0 auto; padding: 16px 16px 60px; }
.topbar {
  display: flex; align-items: center; gap: 14px;
  padding: 10px 16px; background: var(--panel);
  border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5;
}
.topbar strong { font: 800 19px/1.2 var(--font-head); margin-left: -6px; }
.topbar .ghost { min-height: 38px; }
.topbar #who { flex: 1; }

/* The vendor's word on this release — deprecated, end of life. Advisory:
   nothing here is disabled by it, which is why it is a strip and not a wall. */
.vendor-notice { padding: 8px 16px; font-size: 14px; border-bottom: 1px solid var(--line); }
.vendor-notice.warning { background: #fff7e6; color: #7a4b00; }
.vendor-notice.critical { background: #fdecec; color: #8a1c1c; }
.vendor-notice.info { background: #eef4ff; color: #1d3f7a; }
.vendor-notice code { font-size: 13px; }

.tiles { display: flex; flex-wrap: wrap; gap: 12px; margin: 14px 0 4px; }
.tile {
  flex: 1 1 200px; background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 14px; display: flex; flex-direction: column; gap: 4px;
}
.tile.warn { border-color: var(--warn); }
.tile .big { font-size: 30px; font-weight: 700; font-variant-numeric: tabular-nums; }

table.grid { width: 100%; border-collapse: collapse; margin: 6px 0 18px; }
table.grid th {
  text-align: left; font: 500 11px/1.4 var(--font-mono); letter-spacing: 1.5px; text-transform: uppercase;
  color: var(--ink-dim); padding: 8px 10px; border-bottom: 1px solid var(--line);
}
table.grid td {
  padding: 10px; border-bottom: 1px solid var(--line); vertical-align: top;
  font-variant-numeric: tabular-nums;
}
table.grid tr:hover td { background: var(--panel); }
table.grid code { font-size: 12px; word-break: break-all; }

/* A session somebody else is driving. Loud on purpose: the customer has to be
   able to tell at a glance, and so does the operator. */
.impersonating {
  flex: 1; font-weight: 700; color: #2a0000;
  background: var(--bad); padding: 6px 12px; border-radius: var(--radius);
}

/* Setup is a form, and a form is a grid of labelled fields. Two columns on a
   desk, one on anything narrower — an admin does occasionally do this on a
   phone, in a van, on the first morning. */
.fields { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 12px; margin: 8px 0 14px; }
.fields label { display: flex; flex-direction: column; gap: 4px; color: var(--ink-dim); font-size: 14px; }
.fields label.inline { flex-direction: row; align-items: center; gap: 8px; }
.fields input, .fields select {
  min-height: 42px; padding: 0 12px; font: inherit;
  background: var(--panel-2); color: var(--ink);
  border: 1px solid var(--line); border-radius: var(--radius);
}
.fields input[type="checkbox"] { min-height: 0; width: 20px; height: 20px; }
h3 { margin: 4px 0 8px; font-size: 15px; }
.link-plain { display: inline-flex; align-items: center; text-decoration: none; padding: 0 14px; }

textarea.wide-input {
  width: 100%; margin-top: 6px; padding: 10px 12px; font: inherit;
  background: var(--panel-2); color: var(--ink);
  border: 1px solid var(--line); border-radius: var(--radius); resize: vertical;
}
details summary { cursor: pointer; padding: 8px 0; }

/* ---- the dispatch board ----
   A lane per technician, a column per day. The grid scrolls sideways rather than
   squeezing: a week of six technicians does not fit a laptop, and a squeezed cell
   is one a dispatcher misreads. */
.board { width: 100%; border-collapse: separate; border-spacing: 6px; }
.board thead th { font-size: 13px; color: var(--ink-dim); font-weight: 600;
                  text-align: left; padding: 4px 6px; }
.board th.lane { width: 160px; text-align: left; vertical-align: top;
                 padding: 10px 6px; font-weight: 600; }
.board .cell { vertical-align: top; min-width: 180px; padding: 8px;
               background: var(--panel); border: 1px solid var(--line);
               border-radius: var(--radius); }
/* No van is not a warning, it is the reason a drop will be refused — so the cell
   says so before anyone aims at it. */
.board .cell.novan { background: transparent; border-style: dashed; }
.board .cellhead { display: flex; justify-content: space-between;
                   font-size: 12px; margin-bottom: 4px; }
.board .card { margin: 6px 0; padding: 10px; cursor: grab; }
/* Picked is said twice — an outline as well as a colour — because the tag gold
   and a warning amber are too close to tell apart in sun. */
.board .card.picked { border-left-color: var(--accent); outline: 2px solid var(--accent); outline-offset: 1px; }
.rail { display: flex; flex-wrap: wrap; gap: 10px; }
.rail .card { width: min(320px, 100%); cursor: grab; }
.why { color: var(--ink-dim); font-size: 13px; margin-top: 6px; }

/* ---- sectioned setup ----
   A rail of named sections with a line saying what each is for, the way
   CollectFlow's settings are. One long scroll makes "where do I set the labour
   item?" a hunt, and an administrator who is hunting is one on the phone. */
.split { display: flex; gap: 18px; align-items: flex-start; }
.rail-nav { flex: 0 0 240px; display: flex; flex-direction: column; gap: 6px;
            position: sticky; top: 12px; }
.railitem { display: flex; flex-direction: column; gap: 2px; text-align: left;
            padding: 10px 12px; border-radius: var(--radius); cursor: pointer;
            background: transparent; border: 1px solid transparent;
            color: inherit; font: inherit; }
.railitem:hover { background: var(--panel); }
.railitem.on { background: var(--panel); border-color: var(--line);
               border-left: 3px solid var(--accent); }
.railitem .dim { font-size: 12px; }
.pane { flex: 1 1 auto; min-width: 0; }
.pane h2:first-child { margin-top: 0; }
@media (max-width: 820px) {
  .split { flex-direction: column; }
  .rail-nav { flex-direction: row; flex-wrap: wrap; position: static; width: 100%; }
  .railitem { flex: 1 1 140px; }
  .railitem .dim { display: none; }
}

/* Setup → Connections: billed-slot cap bar and the "scheduled" state chip. */
.chip.warn { background: rgba(255,176,32,.15); color: var(--warn); border-color: var(--warn); }
.slotbar { max-width: 460px; margin: 8px 0 14px; font-size: 14px; }
.slotbar-track { height: 4px; background: var(--line, rgba(127,127,127,.3)); border-radius: 2px; overflow: hidden; margin-top: 4px; }
.slotbar-fill { height: 100%; }
.slotbar-fill.ok { background: var(--ok); }
.slotbar-fill.warn { background: var(--warn); }
.slotbar-fill.bad { background: var(--bad); }

/* ---- Setup → Branding / Email templates (setup-mail.js) ---- */
.brand-logo { max-height: 56px; max-width: 220px; background: #fff; border-radius: 6px; padding: 4px; }
pre.mail-preview { white-space: pre-wrap; font: inherit; margin: 8px 0 0; padding: 10px 12px;
  background: var(--panel-2); border: 1px solid var(--line); border-radius: var(--radius); }
.login-logo { display: block; max-height: 64px; max-width: 240px; margin: 0 auto 8px;
  background: #fff; border-radius: 6px; padding: 4px; }

/* ---- Support (support.js): the ticket list, the thread, the reply box ----
   The customer's side of the conversation on the right, support's on the left,
   the way every messaging app has taught people to read one. */
.support-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 8px 0; }
.support-bar h3 { margin: 0; }
.support-bar .spacer { flex: 1; }
.ghost.tiny.on { color: var(--ink); border-color: var(--accent); }
table.grid tr.clickable { cursor: pointer; }
.thread { display: flex; flex-direction: column; gap: 10px; margin: 10px 0; }
.msg { max-width: min(640px, 88%); padding: 10px 14px; border-radius: var(--radius);
       border: 1px solid var(--line); background: var(--panel); }
.msg.mine { align-self: flex-end; background: var(--panel-2); border-color: var(--accent); }
.msg.agent { align-self: flex-start; }
.msg-head { font-size: 13px; margin-bottom: 4px; }
.msg-body { white-space: pre-wrap; overflow-wrap: anywhere; }
.att-row { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.att-chip { font: inherit; font-size: 13px; padding: 4px 10px; border-radius: 999px;
            cursor: pointer; background: transparent; color: var(--ink);
            border: 1px solid var(--line); }
.att-chip:hover { border-color: var(--accent); }
.att-pick { display: flex; flex-direction: column; gap: 4px; margin: 10px 0; font-size: 14px; }
