/* AES Service Hub — responsive shell, desktop-first with a real mobile layout */

:root {
  --bg: #f4f6f9;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --border: #dde3ec;
  /* One step darker than a border. The status rail is a thing being read, not
     an edge between two things, and at border weight it was faint enough to
     look like a stray stroke rather than a line joining the steps. */
  --line: #c3cdda;
  --text: #16202e;
  --muted: #5c6b80;
  /* ELGi's red, taken from the dealer portal: #ee3124. It is used neat as the
     colour of the top bar, where the only thing on it is the large white
     wordmark. Everywhere small white text sits on the colour — every button,
     every badge — it is one shade down, because #ee3124 under white text is
     4.1:1 and this interface does not go below 4.5. The two are a hair apart
     on screen and the difference is only ever seen edge to edge. */
  --brand: #e02a1d;
  --brand-bar: #ee3124;
  --brand-dark: #a81b12;
  --brand-tint: #fdeceb;
  --accent: #0f7b6c;
  --warn: #9a5b00;
  --warn-tint: #fff5e5;
  --danger: #b3261e;
  --danger-tint: #fdecea;
  --ok: #0f7b3d;
  --ok-tint: #e7f5ec;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 32, 56, .06), 0 4px 14px rgba(16, 32, 56, .06);
  --font: "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e141b;
    --surface: #151d26;
    --surface-2: #1b2530;
    --border: #2a3644;
    --line: #3d4b5c;
    --text: #e8eef6;
    --muted: #9aa8bb;
    --brand: #ff7f70;
    --brand-bar: #d4261a;
    --brand-dark: #ffa79c;
    --brand-tint: #3a1613;
    --accent: #3fb8a4;
    --warn: #e0a95c;
    --warn-tint: #2e2413;
    --danger: #f08a82;
    --danger-tint: #331917;
    --ok: #5fc98a;
    --ok-tint: #122a1c;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 4px 14px rgba(0, 0, 0, .3);
  }
}

* { box-sizing: border-box; }

/* Everything sizes off this one root value, so the − / + control in the header
   scales the whole interface rather than just the body text. */
html {
  font-size: calc(16px * var(--zoom, 1));
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 1rem;
  line-height: 1.5;
}

h1, h2, h3, h4 { margin: 0 0 .5rem; line-height: 1.25; font-weight: 650; }
h1 { font-size: 1.75rem; }
h2 { font-size: 1.375rem; }
h3 { font-size: 1rem; }
p { margin: 0 0 .75rem; }
a { color: var(--brand); }

.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 1rem; }
.mono { font-family: "Cascadia Mono", Consolas, "SF Mono", ui-monospace, monospace; }
.nowrap { white-space: nowrap; }
.right { text-align: right; }
.spacer { flex: 1 1 auto; }

/* ---------- Login ---------- */

.login-wrap {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 1.25rem;
  background: linear-gradient(160deg, var(--brand-tint), var(--bg) 55%);
}

.login-card {
  width: min(400px, 100%);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--shadow);
  padding: 1.75rem;
}

.login-card .brand { display: flex; align-items: center; gap: .65rem; margin-bottom: 1.25rem; }
.login-card .brand .logo {
  width: 42px; height: 42px; border-radius: 10px; flex: none;
  background: var(--brand); color: #fff;
  display: grid; place-items: center; font-weight: 700; letter-spacing: .5px;
}
.login-card .brand small { display: block; color: var(--muted); font-weight: 400; }

/* ---------- App shell ---------- */

.app { min-height: 100dvh; display: flex; flex-direction: column; }

/* ---------- Which dashboard am I on? ----------
   Every dashboard is ELGi red. There was a colour per role here, which told
   you where you were at a glance but made the four screens look like four
   products; one house colour and one plainly worded plate — AES, DEALER, LAB,
   ELGI — says the same thing without pulling the brand apart. The data-role
   attribute stays on <body> for anything that needs to key off the role. */
body { --role: var(--brand); }

.topbar .plate {
  display: flex; align-items: baseline; gap: .45rem;
  padding: .3rem .85rem;
  border: 1px solid rgba(255, 255, 255, .35);
  border-radius: 999px;
  background: rgba(255, 255, 255, .14);
  white-space: nowrap;
}
.topbar .plate-word { font-weight: 700; letter-spacing: .06em; text-transform: uppercase; }
.topbar .plate-sub { font-size: 1rem; opacity: .8; }

.topbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; gap: 1rem;
  padding: .7rem 1.25rem;
  background: var(--brand-bar); color: #fff;
}
.topbar .logo {
  width: 32px; height: 32px; border-radius: 8px; flex: none;
  background: rgba(255, 255, 255, .17);
  display: grid; place-items: center; font-weight: 700; font-size: 1rem;
}
.topbar .title { font-weight: 650; }
.topbar .title small { display: block; font-weight: 400; font-size: 1rem; opacity: .85; }
.topbar .who { text-align: right; font-size: 1rem; line-height: 1.3; color: #fff; }
.topbar .who strong { display: block; color: #fff; }
.topbar .who .role { color: rgba(255, 255, 255, .85); }

/* Buttons sitting on the blue bar: white text, not the dark body text colour.
   The .ghost selector is repeated so this outranks the generic button rules
   further down the file, which would otherwise win on source order. */
.topbar button, .topbar button.ghost {
  color: #fff;
  background: rgba(255, 255, 255, .14);
  border-color: rgba(255, 255, 255, .45);
}
.topbar button:hover:not(:disabled), .topbar button.ghost:hover:not(:disabled) {
  color: #fff;
  background: rgba(255, 255, 255, .28);
  border-color: #fff;
}
.topbar button:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }

.nav {
  display: flex; gap: .25rem; overflow-x: auto; scrollbar-width: thin;
  padding: 0 .5rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky; top: var(--topbar-h, 46px); z-index: 25;
}
.nav button {
  appearance: none; border: 0; background: none; cursor: pointer;
  color: var(--muted); font: inherit; font-size: 1rem;
  padding: .7rem .8rem; white-space: nowrap;
  border-bottom: 2.5px solid transparent;
}
.nav button:hover { color: var(--text); }
.nav button[aria-current="page"] { color: var(--brand); border-bottom-color: var(--brand-bar); font-weight: 600; }

/* Use the width that is actually there. The cap only stops text running to
   absurd line lengths on very wide monitors. */
main { flex: 1 1 auto; padding: 1rem clamp(.75rem, 2vw, 2rem); max-width: 1900px; width: 100%; margin: 0 auto; }

/* Zoom control in the header */
.zoom { display: flex; align-items: stretch; gap: 0; flex: none; }
.zoom button { padding: .3rem .55rem; border-radius: 0; min-width: 2rem; }
.zoom button:first-child { border-radius: 8px 0 0 8px; }
.zoom button:last-child { border-radius: 0 8px 8px 0; }
.zoom button + button { border-left-width: 0; }
.zoom .zoom-reset { min-width: 3.6rem; font-variant-numeric: tabular-nums; }

/* ---------- Cards, grids ---------- */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1rem;
  margin-bottom: 1rem;
}
.card > h2:first-child, .card > h3:first-child { margin-top: 0; }
.card-head { display: flex; align-items: center; gap: .75rem; flex-wrap: wrap; margin-bottom: .75rem; }
.card-head h2, .card-head h3 { margin: 0; }

.grid { display: grid; gap: 1rem; }
/* A row of tiles is not a card and carries no bottom margin of its own, so
   a card following one used to sit straight against it - the only page
   rhythm on the site with a seam instead of a gap. */
.grid + .card { margin-top: 1rem; }
.grid.cols-2 { grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
.grid.cols-3 { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.grid.cols-4 { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }

.kpi {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: .85rem 1rem;
}
.kpi .n { font-size: 2rem; font-weight: 700; line-height: 1.1; }
.kpi .l { color: var(--muted); font-size: 1rem; }

/* ---------- Forms ---------- */

.field { margin-bottom: .85rem; }
.field > label { display: block; font-size: 1rem; font-weight: 600; color: var(--muted); margin-bottom: .3rem; }
.field .hint { font-size: 1rem; color: var(--muted); margin-top: .25rem; }

/* A box only as wide as what it has to hold. A serial number is a dozen
   characters; a company name is not. These are caps rather than fixed widths,
   so a box still shrinks with its column, and below 760px they come off
   altogether — on a phone the screen is already the limit. */
/* A stock count is four digits at the outside, and a box sized for forty
   characters invites you to wonder what else belongs in it. */
.fw-xs { max-width: 9ch; }
.fw-sm { max-width: 20ch; }
.fw-md { max-width: 30ch; }
.fw-lg { max-width: 42ch; }
@media (max-width: 760px) {
  .fw-sm, .fw-md, .fw-lg { max-width: 100%; }
}

/* ---------- Tags: the products a part fits ----------
   Chips you add and remove, rather than a dropdown that can hold one answer.
   The row they sit in stays put as chips come and go. */
.tags { display: flex; flex-wrap: wrap; align-items: center; gap: .4rem; position: relative; }
.tag {
  display: inline-flex; align-items: center; gap: .3rem;
  padding: .25rem .3rem .25rem .7rem;
  border-radius: 999px;
  background: var(--brand-tint); color: var(--brand-dark);
  border: 1px solid transparent;
  font-size: 1rem; font-weight: 550; white-space: nowrap;
}
.tag-all { padding: .25rem .7rem; background: var(--surface-2); color: var(--muted); font-weight: 500; }
.tag-x {
  appearance: none; border: 0; background: none; cursor: pointer;
  color: inherit; opacity: .65;
  font-size: 1.05rem; line-height: 1; padding: .1rem .3rem; border-radius: 999px;
}
.tag-x:hover { opacity: 1; background: rgba(0, 0, 0, .08); }
.tag-add {
  appearance: none; cursor: pointer;
  width: 2rem; height: 2rem; padding: 0;
  display: inline-grid; place-items: center;
  border: 1px dashed var(--border); border-radius: 999px;
  background: var(--surface); color: var(--muted); font-size: 1rem;
}
.tag-add:hover { border-color: var(--brand); color: var(--brand); }
.tag-menu {
  position: absolute; top: calc(100% + .35rem); left: 0; z-index: 40;
  min-width: 12rem;
  display: flex; flex-direction: column;
  padding: .3rem;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 10px; box-shadow: var(--shadow);
}
.tag-option {
  appearance: none; border: 0; background: none; cursor: pointer;
  text-align: left; padding: .5rem .6rem; border-radius: 6px;
  font: inherit; color: var(--text);
}
.tag-option:hover { background: var(--brand-tint); color: var(--brand-dark); }

/* "Other complaint" sits under the tick list it belongs to. */
.check-grid + .field { margin: .9rem 0 0; }

input[type="text"], input[type="password"], input[type="number"], input[type="date"],
input[type="email"], input[type="search"], select, textarea {
  width: 100%;
  padding: .55rem .65rem;
  font: inherit;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  outline: none;
}

/* The required marker. */
.req { color: var(--danger); font-weight: 700; margin-left: .15rem; }
.warn-text { color: var(--danger); font-weight: 600; }
/* Why a button did nothing, sitting under the field that is missing its
   answer rather than in a corner of the screen nobody is looking at. */
.err-text { color: var(--danger); font-weight: 600; margin-top: .35rem; }

/* The stock page edits in place, so its rows carry live controls. */
td select, td input[type="number"] { padding: .4rem .5rem; }
td .btn-row { flex-wrap: nowrap; gap: .4rem; }

/* A date box only ever holds eleven characters and a calendar icon. The rule
   below stretches every control to the width of its column, which is right
   for a name or an address but leaves a date stranded in a half-empty box
   with its icon marooned at the far end. Dates size to their contents. */
input[type="date"] { width: auto; min-width: 0; max-width: 100%; }


input:focus, select:focus, textarea:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-tint);
}
input[type="checkbox"] { width: 1.05rem; height: 1.05rem; accent-color: var(--brand); }
textarea { min-height: 72px; resize: vertical; }
select { appearance: auto; }

fieldset { border: 1px solid var(--border); border-radius: 8px; padding: .6rem .75rem; margin: 0 0 .85rem; }
legend { font-size: 1rem; font-weight: 600; color: var(--muted); padding: 0 .3rem; }

/* No inner scrollbar: twenty tick boxes cut off halfway read as broken, and
   a scroll box inside a scrolling page is worse still on a phone. */
.check-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: .3rem .9rem; }
.check-grid label { display: flex; align-items: flex-start; gap: .5rem; font-size: 1rem; padding: .2rem 0; cursor: pointer; }
/* One size, whatever the label does. Left to itself a browser scales the box
   with the text around it, so a fault whose name wrapped onto two lines came
   out with a visibly larger box than its neighbour. */
.check-grid input[type="checkbox"] {
  flex: 0 0 auto;
  width: 1.05rem; height: 1.05rem;
  margin: .18rem 0 0;
  accent-color: var(--brand);
}

.row { display: flex; gap: .6rem; flex-wrap: wrap; align-items: flex-end; }
.row > * { flex: 1 1 160px; min-width: 0; }
.row > .tight { flex: 0 0 auto; }

/* An input with its Save button attached. `stretch` makes the button match the
   field's height instead of sitting short and low against its bottom edge. */
.inline-edit { display: flex; gap: .35rem; align-items: stretch; min-width: 0; }
.inline-edit > input { flex: 0 1 8.5rem; min-width: 5rem; text-align: right; }
.inline-edit > button { flex: none; padding: 0 .75rem; }
/* Inside a right-aligned money column the control must sit right too,
   otherwise it floats away from the heading above it. */
.inline-edit.end { justify-content: flex-end; }

/* Searchable dropdown — always opens BELOW its field. */
.ss { position: relative; min-width: 0; }
.ss-trigger {
  width: 100%; justify-content: space-between; gap: .5rem;
  padding: .55rem .65rem; font-weight: 400; text-align: left;
  background: var(--surface-2); color: var(--text);
  border: 1px solid var(--border); border-radius: 8px;
}
.ss-trigger:hover:not(:disabled) { color: var(--text); border-color: var(--brand); }
.ss-trigger[aria-expanded="true"] { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-tint); }
.ss-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; flex: 1 1 auto; }
.ss-placeholder { color: var(--muted); }
.ss-caret {
  flex: none; width: 0; height: 0;
  border-left: 5px solid transparent; border-right: 5px solid transparent;
  border-top: 6px solid var(--muted);
}
.ss-trigger[aria-expanded="true"] .ss-caret { transform: rotate(180deg); }
.ss-panel {
  position: absolute; top: calc(100% + 4px); left: 0;
  min-width: 100%; width: max-content; max-width: min(30rem, 92vw);
  /* Below the sticky header (25/30) so the header stays on top when scrolled. */
  z-index: 24;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 10px; box-shadow: 0 10px 30px rgba(16, 32, 56, .16);
  padding: .4rem;
}
.ss-search { margin-bottom: .35rem; }
.ss-list { list-style: none; margin: 0; padding: 0; max-height: 17rem; overflow-y: auto; }
.ss-opt {
  padding: .45rem .6rem; border-radius: 6px; cursor: pointer;
  font-size: 1rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.ss-opt.active { background: var(--brand-tint); color: var(--brand); }
.ss-opt.chosen { font-weight: 600; }
/* A part is two facts - what it is, and the number it is ordered by. The
   number goes under the name rather than into it, so the list still reads
   as a list of parts. */
.ss-opt-label { display: block; overflow: hidden; text-overflow: ellipsis; }
.ss-opt-hint {
  display: block; font-size: .8rem; color: var(--muted);
  overflow: hidden; text-overflow: ellipsis;
}
.ss-opt.active .ss-opt-hint { color: inherit; opacity: .75; }
.ss-empty { padding: .5rem .6rem; color: var(--muted); font-size: 1rem; }

/* Quantity stepper: − [ 3 ] + as one joined control. */
.qty { display: flex; align-items: stretch; min-width: 0; }
.qty .qty-btn {
  flex: none; width: 2.2rem; padding: 0;
  font-size: 1.375rem; line-height: 1; font-weight: 600;
  border-radius: 8px 0 0 8px;
}
.qty .qty-btn:last-child { border-radius: 0 8px 8px 0; }
.qty .qty-value {
  width: 100%; min-width: 2.5rem; text-align: center;
  border-radius: 0; border-left-width: 0; border-right-width: 0;
  font-variant-numeric: tabular-nums;
}
.qty .qty-btn:disabled { opacity: .4; }

/* Money fields are plain text inputs, so no browser spinner arrows appear
   and the value cannot gain a third decimal place. */
.money-input { text-align: right; font-variant-numeric: tabular-nums; }
input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
input[type="number"] { -moz-appearance: textfield; appearance: textfield; }

/* Job totals: labels left, figures right, all in one aligned column. */
.totals { margin-top: .9rem; border-top: 1px solid var(--border); padding-top: .6rem; }
.totals-row {
  display: grid; grid-template-columns: 1fr auto;
  gap: .75rem; align-items: center;
  padding: .28rem 0; font-size: 1rem;
}
.totals-row > span:first-child { color: var(--muted); }
.totals-row .amount { font-variant-numeric: tabular-nums; text-align: right; }
.totals-row.grand {
  border-top: 1px solid var(--border); margin-top: .35rem; padding-top: .5rem;
  font-size: 1rem; font-weight: 700;
}
.totals-row.grand > span:first-child { color: var(--text); }

/* Add-a-spare: a grid so the button keeps its place on the row instead of
   wrapping underneath once the other fields have taken the width. */
.spare-form {
  display: grid;
  grid-template-columns: minmax(9rem, 1.4fr) minmax(9rem, 1.4fr) 7.5rem minmax(7rem, 1fr) auto;
  gap: .6rem;
  align-items: stretch;
}
.spare-form.no-price { grid-template-columns: minmax(9rem, 1.4fr) minmax(9rem, 1.4fr) 7.5rem auto; }
.spare-form > * { min-width: 0; }

/* Move-to-next-stage block */
.stage-box { margin-top: 1rem; border-top: 1px solid var(--border); padding-top: .9rem; }
.stage-form { display: grid; gap: .6rem; }
.stage-form .pair { display: grid; grid-template-columns: 1fr 1fr; gap: .6rem; }
.stage-form .act { display: grid; grid-template-columns: 1fr auto; gap: .6rem; align-items: stretch; }
.stage-form .act > button { white-space: nowrap; }

@media (max-width: 620px) {
  .spare-form, .spare-form.no-price, .stage-form .pair, .stage-form .act { grid-template-columns: 1fr; }
}

/* The row of buttons in a card heading, and the zoom cluster on the blue bar,
   both needed daylight between them. */
.card-head { gap: .75rem; }
.card-head button + button { margin-left: .15rem; }
.zoom { gap: .25rem; }
.topbar .zoom { margin-right: .25rem; }

/* The hidden attribute means hidden, whatever else a rule says.

   The browser hides [hidden] with display:none at user-agent weight, which
   any display we set ourselves outranks. Setting button { display:inline-flex }
   therefore quietly made every hidden button visible — the invoicing page was
   showing Select all on tabs where there is nothing to select. Rather than
   remember that at every call site, say it once. */
[hidden] { display: none !important; }

/* ---------- Buttons ---------- */

button, .btn {
  appearance: none; cursor: pointer; font: inherit; font-weight: 550;
  padding: .6rem 1.1rem; border-radius: 8px;
  border: 1px solid var(--border); background: var(--surface-2); color: var(--text);
  display: inline-flex; align-items: center; gap: .4rem; justify-content: center;
  text-decoration: none;
}
button:hover:not(:disabled), .btn:hover { border-color: var(--brand); color: var(--brand); }
button:disabled { opacity: .5; cursor: not-allowed; }
button.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
button.primary:hover:not(:disabled) { background: var(--brand-dark); border-color: var(--brand-dark); color: #fff; }
button.danger { color: var(--danger); border-color: var(--danger); background: var(--danger-tint); }
button.ghost { background: none; }
button.sm { padding: .45rem .9rem; font-size: 1rem; }
button.block { width: 100%; }
.btn-row { display: flex; gap: .5rem; flex-wrap: wrap; }

button.lg, .btn.lg {
  padding: .85rem 2.2rem;
  font-size: 1.0625rem;
  font-weight: 650;
  border-radius: 10px;
}
.btn-row.submit-row { justify-content: center; gap: .9rem; margin-top: 1.2rem; }
/* Full-width stacked buttons on a phone: easier to hit than a centred pair. */
@media (max-width: 560px) {
  .topbar .plate { order: -1; padding: .2rem .6rem; }
  /* The plate leads on a phone, so the square AES mark beside it would just
     say the same thing twice. */
  .topbar .logo { display: none; }
  .topbar .plate-sub { display: none; }
  .btn-row.submit-row { flex-direction: column; align-items: stretch; }
  .btn-row.submit-row button { width: 100%; }
}

/* ---------- Tables ---------- */

.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; border-radius: 8px; }
table { width: 100%; border-collapse: collapse; font-size: 1rem; }
th, td { text-align: left; padding: .55rem .6rem; border-bottom: 1px solid var(--border); vertical-align: top; }
th {
  font-size: 1rem; text-transform: uppercase; letter-spacing: .02em;
  color: var(--muted); background: var(--surface-2);
  position: sticky; top: 0; white-space: nowrap;
}

/* ------------------------------------------------------------------ *
 * The column names stay put while the list scrolls.
 *
 * The rule above has said "sticky" all along and never stuck. A sticky cell
 * sticks to the nearest ancestor that scrolls, and .table-wrap is one:
 * overflow-x makes it a scroll box on both axes. It is never taller than its
 * own table, so it never scrolls downwards, so nothing ever stuck. Hand the
 * scrolling back to the page and the names pin to the window instead.
 *
 * Only above 1100px, which is the width where the list is a table at all.
 * Below it every job is a card and there is no row of names to keep.
 *
 * The offset is measured rather than guessed: the bar and the nav are sized
 * in rem and the display control moves them, so app.js writes their real
 * height into --chrome-h and the names come to rest just under the nav.
 *
 * The line under them is an inset shadow and not the border, because a
 * collapsed border belongs to the table's own grid and scrolls away with the
 * rows - the underline would go the moment the names started doing their job.
 * ------------------------------------------------------------------ */
@media (min-width: 1101px) {
  .table-wrap { overflow: visible; }
  thead th {
    top: var(--chrome-h, 88px); z-index: 10;
    box-shadow: inset 0 -1px 0 var(--border);
  }

  /* More columns than the window has room for. The wrap has to scroll
     sideways again, and a box that scrolls is the box its own heads stick
     to - so it is given a height and the names pin to the top of it
     instead. app.js hangs .sideways on a wrap whose table has outgrown it. */
  .table-wrap.sideways {
    overflow: auto; position: sticky; top: var(--chrome-h, 88px);
    max-height: calc(100vh - var(--chrome-h, 88px) - 7rem);
  }
  .table-wrap.sideways thead th { top: 0; }

  /* A table inside a popup scrolls with the popup and not with the page, so
     it keeps the arrangement it always had. */
  .modal .table-wrap { overflow-x: auto; max-height: none; }
  .modal thead th { top: 0; }
}
tbody tr:hover { background: var(--surface-2); }

/* A serial number that is on more than one job carries a word saying so. The
   badge sits beside the number rather than under it, and wraps instead of
   widening the column: this is a remark about the cell, not a column of its
   own. */
.repeat { display: inline-flex; align-items: baseline; gap: .4rem; flex-wrap: wrap; }
.repeat-list { display: flex; flex-wrap: wrap; gap: .35rem; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
tr.clickable { cursor: pointer; }

/* Identifiers, dates and money read badly when broken across lines; names and
   addresses are the columns that should absorb the remaining width. */
td .mono, td.num, th.num { white-space: nowrap; }
td[data-label="Date"], td[data-label="S.No."], td[data-label="Job No."],
td[data-label="DC No."], td[data-label="Status"], td[data-label="Last login"],
td[data-label="Part no."], td[data-label="Part No."] { white-space: nowrap; }

/* A part is a number and a description side by side, and the description is
   the one that has to stay readable. Given a floor it keeps its words on a
   line; the table scrolls sideways before the words break up, which is what
   the wrap around every table is there for. */
td[data-label="Part no."], td[data-label="Part No."] { width: 1%; }
td[data-label="Spare"], td[data-label="Part"], td[data-label="Part description"] { min-width: 18ch; }

/* Sortable column headers */
th.sortable { padding: 0; }
th.sortable .th-sort {
  width: 100%; background: none; border: 0; border-radius: 0;
  font: inherit; color: inherit; text-transform: inherit; letter-spacing: inherit;
  padding: .55rem .6rem; justify-content: flex-start; cursor: pointer; white-space: nowrap;
}
th.num.sortable .th-sort { justify-content: flex-end; }
th.sortable .th-sort:hover { color: var(--brand); background: var(--brand-tint); border-color: transparent; }

/* ---------- Kind of service ----------
   Two answers, both on screen: a dropdown here would hide half the question,
   and the answer decides whether there is a parts list underneath at all. */
.svc { margin: 0 0 .9rem; }
.svc > .small.muted:first-child { margin-bottom: .35rem; }
.svc p { margin: .4rem 0 0; }
.segmented { display: flex; flex-wrap: wrap; gap: .4rem; }
.seg {
  appearance: none; cursor: pointer;
  padding: .5rem .85rem;
  border: 1px solid var(--border); border-radius: 999px;
  background: var(--surface); color: var(--text);
  font: inherit; font-size: 1rem; font-weight: 500;
  text-align: left;
}
.seg:hover { border-color: var(--role); color: var(--role); }
.seg.on {
  background: var(--role); border-color: var(--role); color: #fff; font-weight: 600;
}
.seg.on:hover { color: #fff; }
@media (max-width: 560px) {
  /* Two long labels side by side wrap to three ragged lines on a phone. */
  .segmented { flex-direction: column; align-items: stretch; }
}

/* Withdrawn spare lines stay visible but plainly struck off. */
tr.voided { opacity: .72; }
tr.voided:hover { opacity: 1; }
.struck { text-decoration: line-through; margin-right: .4rem; }

/* ---------- Badges / pills ---------- */

.badge {
  display: inline-block; padding: .14rem .5rem; border-radius: 999px;
  font-size: 1rem; font-weight: 600; white-space: nowrap;
  background: var(--brand-tint); color: var(--brand);
}
.badge.ok { background: var(--ok-tint); color: var(--ok); }
.badge.warn { background: var(--warn-tint); color: var(--warn); }
.badge.off { background: var(--danger-tint); color: var(--danger); }
.badge.neutral { background: var(--surface-2); color: var(--muted); }

/* A badge that follows text on the same line needs air in front of it. */
strong + .badge, .badge + .badge { margin-left: .4rem; }

/* ---------- Timeline ---------- */

/* The marker sits in the middle of its step, not on the first line of it.
   A step is two lines — what happened, and when — and a dot level with the
   first of them reads as top-heavy against a block of text.

   The rail is drawn per step rather than as one border down the side of the
   list: a border ran past the last dot and stopped in mid-air, which reads as
   a step still to come. Each step draws the segment across its own box and the
   gap below it; the first starts at its dot, the last stops at its dot. Row
   heights can differ (a long label wraps on a phone) and the line still meets
   every dot, because no segment assumes how tall its neighbour is. */
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { position: relative; padding-left: 1.9rem; margin-bottom: .9rem; }
.timeline li:last-child { margin-bottom: 0; }
.timeline li::before {
  content: ""; position: absolute; left: 0; z-index: 1;
  top: 50%; transform: translateY(-50%);
  box-sizing: border-box;
  width: 11px; height: 11px; border-radius: 50%;
  background: var(--surface); border: 2.5px solid var(--border);
}
.timeline li::after {
  content: ""; position: absolute; left: 4.5px; width: 2px; z-index: 0;
  top: 0; bottom: -.9rem;
  background: var(--line);
}
.timeline li:first-child::after { top: 50%; }
.timeline li:last-child::after { bottom: 50%; }
.timeline li.done::before { background: var(--brand); border-color: var(--brand); }
.timeline li .when { font-size: 1rem; color: var(--muted); }

/* ---------- Bar chart ---------- */

.bars { display: grid; gap: .5rem; }
.bar-row {
  display: grid;
  /* minmax(0, …) lets the label column actually shrink; without it a long
     status name overflows its track and sits on top of the bar. */
  grid-template-columns: minmax(0, 15rem) minmax(3rem, 1fr) auto;
  gap: .75rem; align-items: center; font-size: 1rem;
}
.bar-row > .bar-label {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.bar-track { background: var(--surface-2); border-radius: 999px; height: 12px; overflow: hidden; min-width: 0; }
.bar-fill { background: var(--brand); height: 100%; border-radius: 999px; min-width: 2px; }

@media (max-width: 560px) {
  /* Too narrow for a label beside a bar — stack them instead of squashing. */
  .bar-row { grid-template-columns: 1fr auto; row-gap: .15rem; }
  .bar-row > .bar-label { grid-column: 1 / -1; white-space: normal; }
}

/* ---------- Toasts / banners ---------- */

.toast-host { position: fixed; z-index: 100; right: 1rem; bottom: 1rem; display: grid; gap: .5rem; max-width: min(380px, calc(100vw - 2rem)); }
.toast {
  background: var(--surface); border: 1px solid var(--border); border-left: 4px solid var(--brand);
  border-radius: 8px; padding: .65rem .85rem; box-shadow: var(--shadow); font-size: 1rem;
}
.toast.err { border-left-color: var(--danger); }
.toast.ok { border-left-color: var(--ok); }
.toast.warn { border-left-color: var(--warn); }
/* A toast you can press: it takes you to the job it is about. */
.toast.tap { cursor: pointer; }
.toast.tap:hover { background: var(--surface-2, var(--surface)); border-color: var(--brand); }
.toast.tap:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }

.banner { border-radius: 8px; padding: .6rem .8rem; font-size: 1rem; margin-bottom: .85rem; }
.banner.err { background: var(--danger-tint); color: var(--danger); }
.banner.ok { background: var(--ok-tint); color: var(--ok); }
.banner.warn { background: var(--warn-tint); color: var(--warn); }

/* ---------- Modal ---------- */

.modal-host {
  position: fixed; inset: 0; z-index: 90;
  background: rgba(10, 18, 28, .5);
  display: grid; place-items: center; padding: 1rem;
  overflow: auto;
}
.modal {
  background: var(--surface); border-radius: 12px; box-shadow: var(--shadow);
  width: min(560px, 100%); padding: 1.1rem; border: 1px solid var(--border);
  max-height: calc(100dvh - 2rem); overflow: auto;
}
/* A popup built round a table, not round a few fields: the cost sheet.
   At 560px its quantity, rate and amount columns sat behind a sideways
   scroll, which is where nobody looks for the figure they opened it for. */
.modal.wide { width: min(940px, 100%); }

/* ---------- Definition list ---------- */

dl.kv { display: grid; grid-template-columns: max-content 1fr; gap: .3rem .9rem; margin: 0; font-size: 1rem; }
dl.kv dt { color: var(--muted); }
dl.kv dd { margin: 0; word-break: break-word; }

/* ---------- Mobile ---------- */

/* reCAPTCHA widget on the login card (only rendered when keys are configured) */
.captcha-host { margin: 0 0 .85rem; display: flex; justify-content: center; min-height: 78px; }

@media (max-width: 720px) {
  main { padding: .75rem; }
  .topbar .title small { display: none; }
  .topbar .who .role { display: none; }
  .topbar .zoom { display: none; }

  /* On a phone the header runs out of room before the zoom control earns
     its place — pinch-zoom covers it there. */
  .nav { top: var(--topbar-h, 44px); }
  .card { padding: .85rem; }
  .kpi .n { font-size: 1.75rem; }
  dl.kv { grid-template-columns: 1fr; gap: .1rem; }
  dl.kv dd { margin-bottom: .45rem; }
}

/* ------------------------------------------------------------------ *
 * Job tables become cards.
 *
 * Nine columns of 16px text need a good 1100px. Below that a card per job
 * reads far better than a table scrolled sideways, where the status column —
 * the one people are looking for — is the first thing to disappear.
 * ------------------------------------------------------------------ */
@media (max-width: 1100px) {
  table.stack thead { display: none; }
  table.stack, table.stack tbody, table.stack tr, table.stack td { display: block; width: 100%; }
  table.stack tr {
    border: 1px solid var(--border); border-radius: 8px;
    margin-bottom: .6rem; padding: .7rem .85rem; background: var(--surface);
  }
  table.stack tr.clickable:hover { border-color: var(--brand); }
  table.stack td { border: 0; padding: .2rem 0; text-align: left !important; }
  table.stack td::before {
    content: attr(data-label) " ";
    font-size: 1rem; text-transform: uppercase; letter-spacing: .02em;
    color: var(--muted); display: inline-block; min-width: 9.5rem;
  }
  /* Label left, value right, and the value may wrap. A long status badge used
     to run past the edge of the card on a narrow phone. */
  table.stack td { display: flex; gap: .5rem; align-items: baseline; }
  table.stack td > * { min-width: 0; }
  table.stack td::before { flex: 0 0 9.5rem; }
  table.stack td .badge { white-space: normal; }
  table.stack td.headline { display: block; }
  table.stack td.headline::before { display: none; }
  table.stack td.headline { font-weight: 700; font-size: 1.15rem; margin-bottom: .35rem; }
  table.stack td[data-label="Date"] { white-space: normal; }
  table.stack td[data-label="S.No."] { display: none; }

  /* Stacked rows read left-to-right, so the money editors follow suit. */
  table.stack .inline-edit.end { justify-content: flex-start; }
  table.stack .inline-edit > input { text-align: left; }
}

/* ---------- Print (invoice) ---------- */

/* ------------------------------------------------------------------ *
 * Date range picker
 * ------------------------------------------------------------------ */
.daterange {
  display: flex;
  align-items: center;
  gap: .45rem;
  flex-wrap: wrap;
}
/* The shared input rule sets width:100%, which inside a flex row makes each
   control claim a line of its own. These sit side by side instead. */
.daterange select,
.daterange input[type="date"] {
  width: auto;
  flex: 0 0 auto;
}
.daterange select { min-width: 10.5rem; }
/* Sized to "12-Oct-2026" plus the calendar icon, instead of a fixed 9.5rem
   that left half the box empty. */
.daterange input[type="date"] {
  min-width: 0;
  width: auto;
  padding: .55rem .5rem;
}
.daterange .dash { color: var(--muted); font-size: 1rem; }

/* On a phone the preset takes its own line and the two dates share the next,
   which keeps them readable instead of squeezing three controls into one row. */
@media (max-width: 560px) {
  .daterange {
    width: 100%;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
    gap: .45rem;
  }
  .daterange select { grid-column: 1 / -1; width: 100%; min-width: 0; }
  .daterange input[type="date"] { width: 100%; min-width: 0; }
  .daterange .dash { align-self: center; text-align: center; }
}

/* ------------------------------------------------------------------ *
 * Acknowledgement — the dealer confirming the unit arrived
 * ------------------------------------------------------------------ */
.ack {
  margin-top: 1rem;
  border-top: 1px solid var(--border);
  padding-top: .9rem;
}
.ack.done {
  border-top: 0;
  background: var(--ok-tint);
  color: var(--ok);
  border-radius: 8px;
  padding: .6rem .8rem;
}
.ack.done .small { color: inherit; opacity: .85; }
.ack-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: .5rem;
  align-items: center;
  margin-top: .6rem;
}

/* ------------------------------------------------------------------ *
 * Chat
 * ------------------------------------------------------------------ */
.visually-hidden {
  position: absolute;
  width: 1px; height: 1px;
  margin: -1px; padding: 0; border: 0;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  overflow: hidden;
  white-space: nowrap;
}

.chat-card { display: flex; flex-direction: column; }

.chat-tabs {
  display: flex;
  gap: .3rem;
  flex-wrap: wrap;
  margin-bottom: .6rem;
  border-bottom: 1px solid var(--border);
}
.chat-tab {
  background: none;
  border: 0;
  border-bottom: 2px solid transparent;
  padding: .4rem .7rem;
  font: inherit;
  font-size: 1rem;
  color: var(--muted);
  cursor: pointer;
  border-radius: 0;
}
.chat-tab:hover { color: var(--text); }
.chat-tab.on { color: var(--brand); border-bottom-color: var(--brand); font-weight: 600; }

.chat-note .banner {
  background: var(--surface-2);
  color: var(--muted);
  border: 1px solid var(--border);
}

.chat-log {
  flex: 1;
  min-height: 14rem;
  max-height: 26rem;
  overflow-y: auto;
  overscroll-behavior: contain;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: .7rem;
  display: flex;
  flex-direction: column;
  gap: .5rem;
}
.chat-log:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
.chat-empty { margin: auto; text-align: center; }

.chat-msg {
  max-width: min(32rem, 82%);
  /* Without this a wide photo sets the bubble's minimum width and the
     max-width above is simply overruled. */
  min-width: 0;
  padding: .45rem .65rem;
  border-radius: 12px;
  font-size: 1rem;
  line-height: 1.4;
  box-shadow: 0 1px 1px rgba(16, 32, 56, .05);
}
.chat-msg.theirs {
  align-self: flex-start;
  background: var(--surface);
  border: 1px solid var(--border);
  border-bottom-left-radius: 4px;
}
.chat-msg.mine {
  align-self: flex-end;
  background: var(--brand-tint);
  border: 1px solid var(--brand-tint);
  border-bottom-right-radius: 4px;
}
/* Preserves the line breaks someone typed, without allowing any markup. */
.chat-text { white-space: pre-wrap; word-break: break-word; }
.chat-meta {
  margin-top: .2rem;
  font-size: 1rem;
  color: var(--muted);
}

.chat-photo {
  display: block;
  padding: 0;
  border: 0;
  background: none;
  cursor: zoom-in;
  border-radius: 8px;
  overflow: hidden;
  margin-bottom: .35rem;
}
.chat-photo img {
  display: block;
  width: 100%;
  height: auto;
  max-height: 14rem;
  object-fit: cover;
  border-radius: 8px;
}
.chat-full { display: block; max-width: 100%; max-height: 72vh; margin: 0 auto; border-radius: 8px; }

.chat-card { position: relative; }

.chat-dropzone {
  position: absolute;
  inset: .4rem;
  display: none;
  place-items: center;
  border: 2px dashed var(--brand);
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--brand-tint) 88%, transparent);
  z-index: 5;
  pointer-events: none;
}
.chat-card.dropping .chat-dropzone { display: grid; }
.chat-dropzone-inner {
  font-weight: 650;
  color: var(--brand-dark);
  background: var(--surface);
  border-radius: 999px;
  padding: .6rem 1.4rem;
  box-shadow: var(--shadow);
}

.chat-preview-text { flex: 1; min-width: 0; }
.chat-preview-text strong {
  display: block;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

.chat-preview {
  display: none;
  align-items: center;
  gap: .6rem;
  margin-top: .6rem;
  padding: .5rem;
  background: var(--surface-2);
  border: 1px dashed var(--border);
  border-radius: 8px;
}
.chat-preview.on { display: flex; }
.chat-preview img { max-height: 4rem; border-radius: 6px; }

.chat-form {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: .5rem;
  align-items: end;
  margin-top: .6rem;
}
.chat-attach {
  width: 2.5rem;
  height: 2.5rem;
  padding: 0;
  font-size: 1.25rem;
  line-height: 1;
  border-radius: 50%;
}
textarea.chat-input {
  resize: none;
  min-height: 2.5rem;
  max-height: 7.5rem;
  padding: .55rem .7rem;
  line-height: 1.35;
}
.chat-send { min-height: 2.5rem; }

@media (max-width: 560px) {
  .chat-msg { max-width: 90%; }
  .ack-form { grid-template-columns: 1fr; }
}

/* Shown only on paper — a title for the printed job list. */
.print-only { display: none; }


/* ------------------------------------------------------------------ *
 * Phone header
 *
 * At a 16px base the brand, the signed-in name and three buttons no longer
 * fit across 375px. Rather than shrink the text back down, the bar wraps on
 * to a second line and the name sits with its buttons.
 * ------------------------------------------------------------------ */
@media (max-width: 560px) {
  .topbar { flex-wrap: wrap; row-gap: .5rem; padding: .6rem .75rem; }
  .topbar .spacer { flex: 1 0 auto; }
  .topbar .who { flex: 1 1 100%; text-align: left; order: 3; }
  .topbar button { order: 4; }
  .topbar .who strong { display: inline; }
}

/* ------------------------------------------------------------------ *
 * Filter toolbar
 *
 * A grid rather than a wrapping row, so the controls line up in columns
 * instead of drifting as the window changes width. Each one is labelled.
 * ------------------------------------------------------------------ */
/* Twelve explicit columns rather than auto-fit: auto-fit works out how many
   columns exist from the available width, so a control spanning two landed
   wherever it happened to fit and the toolbar reshuffled itself as the window
   changed. These spans put each control in the same place every time. */
.filters {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  gap: .9rem 1rem;
  align-items: end;
}
.filters .filter { grid-column: span 3; }
.filters .filter.wide { grid-column: span 6; }

/* Narrower: a wide control takes the full row, the rest pair up. */
@media (max-width: 1180px) {
  .filters .filter { grid-column: span 6; }
  .filters .filter.wide { grid-column: span 12; }
}

.filter { min-width: 0; }
.filter-label {
  display: block;
  font-size: 1rem;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: .3rem;
}
.filter-actions-row {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}
.filter-actions-row label { white-space: nowrap; }

@media (max-width: 760px) {
  .filters .filter,
  .filters .filter.wide { grid-column: span 12; }
}

/* ------------------------------------------------------------------ *
 * Pager under a long table
 *
 * Centred, because the two buttons are a pair and the count belongs between
 * them. It stays one row on a phone: three short things fit, and a pager that
 * wraps looks broken.
 * ------------------------------------------------------------------ */
.pager {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  margin-top: 1rem;
}
.pager button[disabled] {
  opacity: .45;
  cursor: default;
}

/* ------------------------------------------------------------------ *
 * Summary chips above the table
 * ------------------------------------------------------------------ */
.summary {
  display: flex;
  flex-wrap: wrap;
  gap: .5rem;
  margin-bottom: .85rem;
}
.chip {
  display: inline-flex;
  align-items: baseline;
  gap: .4rem;
  padding: .35rem .75rem;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--muted);
}
.chip strong { color: var(--text); font-size: 1.15rem; }
.chip.warn { background: var(--warn-tint); border-color: transparent; color: var(--warn); }
.chip.warn strong { color: var(--warn); }
.chip.err { background: var(--danger-tint); border-color: transparent; color: var(--danger); }
.chip.err strong { color: var(--danger); }
.chip.new { background: var(--brand-tint); border-color: transparent; color: var(--brand-dark); }
.chip.new strong { color: var(--brand-dark); }

/* ------------------------------------------------------------------ *
 * Unread markers
 * ------------------------------------------------------------------ */
.jobno { display: inline-flex; align-items: center; gap: .5rem; flex-wrap: nowrap; }

.unread,
.nav-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.5rem;
  height: 1.5rem;
  padding: 0 .4rem;
  border-radius: 999px;
  background: var(--danger);
  color: #fff;
  font-size: 1rem;
  font-weight: 700;
  line-height: 1;
}
.nav-badge { margin-left: .5rem; }

/* ------------------------------------------------------------------ *
 * Date boxes — the whole control is clickable, so it should look it
 * ------------------------------------------------------------------ */
input[type="date"] { cursor: pointer; }
input[type="date"]::-webkit-calendar-picker-indicator {
  cursor: pointer;
  opacity: .75;
  padding: .15rem;
}
input[type="date"]:hover::-webkit-calendar-picker-indicator { opacity: 1; }

/* ------------------------------------------------------------------ *
 * Chat: a friendlier empty state
 * ------------------------------------------------------------------ */
.chat-empty {
  margin: auto;
  text-align: center;
  max-width: 24rem;
  line-height: 1.5;
}

/* Landscape by default: the job list is a wide table, and portrait was
   cutting the right-hand columns off. The person printing can still switch
   it back in the print dialog. */
/* A job list is twelve columns wide and needs the long edge. A report is five
   or six and reads better down a portrait page — printed landscape it left a
   third of the sheet empty. The named page is how a single document asks for
   both; a browser that does not support it keeps the default. */
@page { size: A4 landscape; margin: 10mm; }
@page upright { size: A4 portrait; margin: 12mm 12mm 14mm; }
body.printing-portrait { page: upright; }

@media print {
  /* The display-size control scales the whole interface through the root font
     size, and it was scaling paper with it — a sheet printed while the screen
     was at 110% came out with 18px table headings. Paper has one size. */
  html { font-size: 16px !important; }

  /* The table scrolls sideways on screen, and a long one scrolls downwards
     with its column names pinned. On paper it has neither a height of its own
     nor a top to stick to: it simply lays out, and thead repeats the names at
     the top of each sheet. */
  .table-wrap { overflow: visible !important; max-height: none !important; position: static !important; }
  thead th { position: static !important; box-shadow: none !important; }
  table { table-layout: auto; }
  td, th { overflow-wrap: anywhere; }

  .topbar, .nav, .btn-row, .no-print, .toast-host { display: none !important; }
  main { padding: 0; max-width: none; }
  .card { box-shadow: none; border: 0; margin: 0; }
  body { background: #fff; color: #000; font-size: 13px; }
  table { font-size: 12.5px; }
  th { background: #eee !important; color: #000 !important; }

  /* Cost sheet: print the sheet alone, not the job page behind the popup. */
  body.printing-sheet #root { display: none !important; }
  body.printing-sheet .modal-host {
    position: static !important; background: none !important; padding: 0 !important;
    display: block !important; overflow: visible !important;
  }
  body.printing-sheet .modal {
    width: 100% !important; max-width: none !important; max-height: none !important;
    box-shadow: none !important; border: 0 !important; padding: 0 !important; overflow: visible !important;
  }
  body.printing-sheet .modal .card-head button { display: none !important; }
  body.printing-sheet .modal .card-head h2 { font-size: 16px; margin-bottom: 12px; }
  /* The "not a tax invoice" note must survive onto paper, where it matters most. */
  body.printing-sheet .modal .banner {
    background: none !important; color: #000 !important;
    border: 1px solid #999; font-size: 10.5px; padding: 4px 8px;
  }

  /* ---------------------------------------------------------------- *
   * The printed sheet.
   *
   * Everything here is in px, on purpose. The rest of the interface is sized
   * in rem so the display-size control can scale it, and that control was
   * scaling the paper too — a sheet printed at 110% came out with 18px table
   * headings. Paper has one size, and this is it.
   * ---------------------------------------------------------------- */
  /* Paper is about 790px wide, which trips the narrow-screen card layout: the
     table would print as one card per row with its column names repeated in
     every cell. A printed list is a table — that is the whole point of it. */
  table.stack { display: table !important; }
  table.stack thead { display: table-header-group !important; }
  table.stack tbody { display: table-row-group !important; }
  table.stack tr {
    display: table-row !important;
    border: 0 !important; border-radius: 0 !important;
    margin: 0 !important; padding: 0 !important; background: none !important;
  }
  table.stack tbody, table.stack tr, table.stack td { width: auto !important; }
  table.stack { width: 100% !important; }
  table.stack td { display: table-cell !important; }
  table.stack td::before { content: none !important; display: none !important; }
  table.stack td.headline { margin: 0 !important; }

  body.printing-list { font-family: Arial, "Helvetica Neue", Helvetica, sans-serif; }
  body.printing-list .print-only { display: block !important; }
  body.printing-list .modal-host { display: none !important; }

  /* Heading: who it is from, what it is, and what it covers — in that order
     of importance, which is the order of these three sizes. */
  body.printing-list .print-head { margin: 0 0 9px; }
  body.printing-list .print-brand {
    font-size: 11px; font-weight: 700; letter-spacing: .06em;
    text-transform: uppercase; color: #444; margin: 0 0 3px;
  }
  body.printing-list .print-head h2 { font-size: 18px; font-weight: 700; margin: 0 0 2px; }
  body.printing-list .print-head .small { font-size: 9.5px; color: #555; }

  body.printing-list h3 { font-size: 14.5px; font-weight: 700; margin: 0 0 6px; }
  body.printing-list .card { padding: 0 !important; margin: 0 0 12px !important; }
  body.printing-list p.small { font-size: 9.5px; color: #555; margin: 0 0 5px; }

  body.printing-list table {
    width: 100%; border-collapse: collapse; table-layout: auto;
    font-size: 11px;
  }
  body.printing-list .report-parts table { table-layout: fixed; }
  body.printing-list th {
    font-size: 10.5px; font-weight: 700;
    text-transform: uppercase; letter-spacing: .03em;
    background: #f1f3f6 !important; color: #000 !important;
    border: 1px solid #c8ccd2 !important;
    padding: 6px 8px !important;
    text-align: left !important; vertical-align: bottom;
    /* A column name may wrap between words, but "DISPATCHED" must not come out
       as "DISPATC HED" — which is what the global anywhere-break does to it. */
    white-space: normal !important;
    overflow-wrap: normal !important; word-break: keep-all !important;
  }
  body.printing-list td {
    font-size: 11px; color: #000;
    border: 1px solid #dadde2 !important;
    padding: 5px 8px !important;
    text-align: left !important; vertical-align: top;
  }
  /* A column of numbers is read down its last digit. */
  body.printing-list th.num, body.printing-list td.num { text-align: right !important; }
  /* A sortable heading is a button on screen; on paper it is a heading, and it
     was carrying the button's own 16px with it. */
  body.printing-list th.sortable { padding: 0 !important; }
  body.printing-list th.sortable .th-sort {
    display: block; width: 100%;
    font: inherit; font-size: 10.5px; font-weight: 700;
    text-transform: uppercase; letter-spacing: .03em;
    padding: 6px 8px !important; text-align: left;
  }
  body.printing-list th.num.sortable .th-sort { text-align: right; }
  body.printing-list td.headline { font-weight: 600 !important; font-size: 11px !important; }
  /* A status badge is a coloured pill on screen because the eye picks it out
     of a long list. On paper it is just the status: a pill prints as a grey
     block, takes two lines and makes every row taller than it needs to be. */
  body.printing-list .badge {
    background: none !important; color: #000 !important;
    border: 0 !important; padding: 0 !important;
    font-size: 11px !important; font-weight: 600;
    white-space: normal !important;
  }
  body.printing-list tbody tr:nth-child(even) td { background: #fafbfc !important; }
  body.printing-list tr { page-break-inside: avoid; }
  body.printing-list thead { display: table-header-group; }

  /* Components used — column widths proportionate to what each one holds.
     Without this the part names wrap to three lines while "Unit" keeps a
     column wide enough for a paragraph. */
  body.printing-list .report-parts th:nth-child(1),
  body.printing-list .report-parts td:nth-child(1) { width: 7%; }
  body.printing-list .report-parts th:nth-child(2),
  body.printing-list .report-parts td:nth-child(2) { width: 44%; }
  body.printing-list .report-parts th:nth-child(3),
  body.printing-list .report-parts td:nth-child(3) { width: 9%; }
  body.printing-list .report-parts th:nth-child(4),
  body.printing-list .report-parts td:nth-child(4) { width: 18%; }
  body.printing-list .report-parts th:nth-child(5),
  body.printing-list .report-parts td:nth-child(5) { width: 22%; }

  .unread, .nav-badge, .summary { display: none !important; }
}

/* ---------- The bell ---------- */

.bell-wrap { position: relative; display: flex; }
.bell {
  position: relative;
  padding: .3rem .5rem;
  line-height: 1;
}
.bell-icon { display: block; }
.bell-count {
  position: absolute; top: -.3rem; right: -.3rem;
  min-width: 1.15rem; height: 1.15rem; padding: 0 .25rem;
  border-radius: 999px;
  background: #fff; color: var(--brand-bar);
  font-size: .8rem; font-weight: 700; line-height: 1.15rem;
  text-align: center;
  box-shadow: 0 0 0 1.5px var(--brand-bar);
}
.bell-panel {
  position: absolute; z-index: 60; top: calc(100% + .45rem); right: 0;
  width: min(23rem, calc(100vw - 2rem));
  background: var(--surface); color: var(--text);
  border: 1px solid var(--border); border-radius: 10px;
  box-shadow: var(--shadow);
  padding: .7rem .8rem;
  text-align: left;
}
.bell-head { display: flex; align-items: baseline; justify-content: space-between; gap: .5rem; margin-bottom: .4rem; }
.bell-list { display: grid; gap: .1rem; max-height: 60vh; overflow: auto; }
.bell-item {
  display: flex; align-items: flex-start; gap: .5rem;
  width: 100%; padding: .45rem .4rem;
  background: none; border: 0; border-radius: 8px;
  font: inherit; color: inherit; text-align: left; cursor: pointer;
}
/* The panel hangs off a button in the top bar, where every button is white
   text on red. Inside the panel it is a page again. */
.topbar .bell-panel button, .topbar .bell-panel button.ghost {
  color: var(--text); background: none; border: 0;
}
.topbar .bell-panel button:hover:not(:disabled) { background: var(--surface-2); color: var(--text); }
.bell-item:hover, .bell-item:focus-visible { background: var(--surface-2); }
.bell-dot {
  flex: 0 0 auto; width: 8px; height: 8px; margin-top: .45rem;
  border-radius: 50%; background: var(--brand);
}
.bell-item.msg .bell-dot { background: var(--accent); }
.bell-text { flex: 1 1 auto; min-width: 0; display: grid; }
.bell-why { margin-top: .05rem; }

/* "Mark all as read" sits with the panel's heading, quiet until wanted. */
.topbar .bell-panel button.bell-clear,
.bell-clear {
  padding: 0; background: none; border: 0;
  font: inherit; font-size: 1rem;
  color: var(--brand); cursor: pointer; white-space: nowrap;
}
.topbar .bell-panel button.bell-clear:hover:not(:disabled),
.bell-clear:hover { text-decoration: underline; background: none; }

/* The breakdown panel above the job list: folded shut so a search is still the
   first thing on the page, and open for anyone reviewing a whole period. */
.period-shape { margin: .85rem 0 0; }
.period-shape > summary {
  cursor: pointer; padding: .55rem .75rem;
  background: var(--surface); border: 1px solid var(--line); border-radius: .5rem;
  font-weight: 600; font-size: .95rem;
}
.period-shape > summary:hover { background: var(--surface-2); }
.period-shape[open] > summary { border-bottom-left-radius: 0; border-bottom-right-radius: 0; }

/* A tick in the cost column, and the bar that acts on the ticks.
   ELGi agree a run of jobs in one sitting, so the row control is a tick and
   the single button sits above the table rather than repeating on every row. */
.tick {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  cursor: pointer;
  font-size: .8125rem;
  color: var(--muted);
  user-select: none;
}
.tick input { width: 1.05rem; height: 1.05rem; margin: 0; accent-color: var(--brand); cursor: pointer; }
.tick:hover { color: var(--text); }
.tick-bar {
  display: flex;
  align-items: center;
  gap: .6rem;
  flex-wrap: wrap;
  margin-bottom: .75rem;
}
.tick-bar > span { margin-right: auto; }

/* ------------------------------------------------------------------ *
 * The dealer's manual
 * ------------------------------------------------------------------ */

/* Prose wants a narrower column than a table does. Left-aligned rather than
   centred, so it lines up with every other card on the page. */
.manual { max-width: 56rem; }
.manual p { max-width: 68ch; }

.manual-toc {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: .9rem 1.1rem;
  margin: 1rem 0 1.75rem;
}
.manual-toc h3 { margin: 0 0 .5rem; font-size: 1rem; }
.manual-toc ol { margin: 0; padding-left: 1.3rem; columns: 2; column-gap: 2rem; }
.manual-toc li { margin: .2rem 0; break-inside: avoid; }
.manual-toc a { color: var(--brand); text-decoration: none; }
.manual-toc a:hover, .manual-toc a:focus-visible { text-decoration: underline; }

.manual-section { margin-top: 1.75rem; }
/* The brand rule marks where one section ends and the next begins, which a
   bold heading alone did not do once the page ran past a screenful. */
.manual-section h3 {
  margin: 0 0 .6rem;
  padding-left: .6rem;
  border-left: 4px solid var(--brand);
  font-size: 1.15rem;
  scroll-margin-top: 1rem;
}

/* Each step is an instruction and then the reason for it. The instruction is
   what someone scanning the page follows; the reason is for the first time
   through only, so it sits underneath in quieter type. */
.manual-steps > li { margin-bottom: .85rem; }

.manual-stages { margin: .5rem 0 0; padding-left: 1.4rem; }
.manual-stages > li { margin-bottom: .3rem; font-weight: 600; }

.manual-note {
  background: var(--surface-2);
  border-left: 3px solid var(--line);
  border-radius: 0 var(--radius) var(--radius) 0;
  padding: .6rem .85rem;
  margin: .75rem 0 0;
  font-size: .925rem;
  color: var(--muted);
}

@media (max-width: 640px) {
  .manual-toc ol { columns: 1; }
}

/* Printing is how a manual ends up pinned above the counter, so the screen
   furniture comes off and the sections are kept whole across page breaks. */
@media print {
  .topbar, .nav, .manual .card-head button { display: none !important; }
  body, .card { background: #fff; }
  .manual { max-width: none; box-shadow: none; border: 0; }
  .manual-section { break-inside: avoid; }
  .manual-section h3 { break-after: avoid; }
  .manual-steps > li { break-inside: avoid; }
}

/* The pictures in the manual, and the numbered list that reads the red arrows
   in them. Added when the manual gained screenshots. */
.manual-figure {
  margin: 1rem 0 0;
  padding: 0;
}
.manual-figure img {
  display: block;
  width: 100%;
  height: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  /* Screenshots are mostly white; without this they bleed into the card. */
  box-shadow: var(--shadow);
}
.manual-figure figcaption { margin-top: .6rem; }

/* The numbers here are the numbers on the arrows in the picture above, so the
   list is numbered and the counter is never restyled away. */
.manual-marks {
  margin: 0;
  padding-left: 1.5rem;
  font-size: .925rem;
  color: var(--muted);
}
.manual-marks > li { margin: .2rem 0; }
.manual-marks > li::marker { color: var(--brand); font-weight: 700; }

/* A step is one instruction, so it needs no second line of explanation. */

@media print {
  /* A picture split across two sheets is worse than a smaller picture. */
  .manual-figure { break-inside: avoid; }
  .manual-figure img { box-shadow: none; max-height: 11cm; width: auto; max-width: 100%; }
}

/* ------------------------------------------------------------------ *
 * Numbered steps, and the questions at the end
 * ------------------------------------------------------------------ */

/* A bare "1." was not enough structure for people following the guide with
   one hand on the keyboard: the steps now say "Step 1", "Step 2" out loud.
   A counter rather than text in the content, so the numbers cannot fall out
   of order when a step is added or removed. */
.manual-steps {
  counter-reset: step;
  list-style: none;
  margin: .85rem 0;
  padding-left: 0;
}
.manual-steps > li {
  counter-increment: step;
  position: relative;
  min-height: 1.9rem;
  padding: .35rem 0 .35rem 5.6rem;
  margin-bottom: .3rem;
}
.manual-steps > li::before {
  content: "Step " counter(step);
  position: absolute;
  left: 0;
  top: .3rem;
  width: 4.7rem;
  text-align: center;
  padding: .18rem 0;
  border-radius: 999px;
  background: var(--brand-tint);
  color: var(--brand-dark);
  border: 1px solid #f3cfcc;
  font-size: .78rem;
  font-weight: 700;
  letter-spacing: .02em;
  text-transform: uppercase;
}

/* The marks under a picture are not steps, so they keep plain numbers. The
   colour matches the arrows drawn on the screenshots, which are blue because
   the dashboard itself is red. */
.manual-marks > li::marker { color: #0b5fff; font-weight: 700; }

/* The questions are an accordion: the whole list fits on one screen, and a
   reader opens only the one that applies to them. */
.manual-faq { margin: .9rem 0 0; }
.faq-item {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--card);
  margin-top: .45rem;
}
.faq-item + .faq-item { margin-top: .4rem; }
.faq-item > summary {
  cursor: pointer;
  list-style: none;
  font-weight: 600;
  padding: .6rem 2.2rem .6rem .8rem;
  position: relative;
  border-radius: var(--radius);
}
.faq-item > summary::-webkit-details-marker { display: none; }
/* A chevron drawn from two borders, so no icon font and no image. */
.faq-item > summary::after {
  content: "";
  position: absolute;
  right: .95rem;
  top: 50%;
  width: .48rem;
  height: .48rem;
  margin-top: -.34rem;
  border-right: 2px solid var(--brand);
  border-bottom: 2px solid var(--brand);
  transform: rotate(45deg);
  transition: transform .15s ease;
}
.faq-item[open] > summary::after { transform: rotate(-135deg); margin-top: -.12rem; }
.faq-item > summary:hover { background: var(--brand-tint); }
.faq-item > summary:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
.faq-item[open] > summary { border-bottom: 1px solid var(--border); border-radius: var(--radius) var(--radius) 0 0; }
.faq-item > p {
  margin: 0;
  padding: .65rem .8rem .75rem;
  color: var(--muted);
  max-width: 68ch;
}

@media (max-width: 560px) {
  /* The label goes above the step rather than squeezing the text to nothing. */
  .manual-steps > li { padding: 1.6rem 0 .35rem 0; }
  .manual-steps > li::before { top: 0; }
}

@media print {
  .manual-steps > li { break-inside: avoid; }
  /* On paper every answer is visible, open or not. */
  .faq-item { break-inside: avoid; }
  .faq-item > summary::after { display: none; }
}
