/* =============================================================================
   JEJOR'S Procurement Cycle Monitoring - "Pay Item"
   2026-09-19, chosen from a seventeen-direction comparison.

   Direction, from the data rather than the subject generally: the item-of-works
   codes already on these slips - 1032(1)A, 1047(7), 405(2)D, 903(2) - are DPWH
   standard pay item numbers. 5,688 of the 6,574 lines carry one. So the app is
   dressed as the specification those clauses come from: a spec document, not a
   ledger and not a drawing. Serif headings over a condensed tabular body, cool
   grey column bands, and a double rule down the left of every table the way a
   bill of quantities is ruled.

   Every shared JCC convention is kept: the same token names, three easings and
   durations, press feedback at scale(0.97), rings only for :focus-visible,
   hover behind @media (hover:hover), right-aligned money, uppercase table
   column headings.

   ONE DEPARTURE, same as the Purchase Ledger direction had: money and quantity
   columns are Roboto Condensed with `font-variant-numeric: tabular-nums
   lining-nums` rather than a monospace face. A bill of quantities sets its
   figures in the document's own type, and tabular figures give the identical
   decimal alignment that the monospace rule exists to provide.

   Type is loaded in src/views/partials/head.ejs.
   ========================================================================== */

:root {
  --bg: #e9e7e1;              /* the document it is printed on */
  --panel: #ffffff;           /* the specification page */
  --panel-2: #eceef3;         /* column band */
  --border: #a9b0bf;          /* the rule */
  --border-soft: #dcdfe6;
  --text: #1b1f28;
  --muted: #5c6473;
  --muted-2: #6c7484;

  --primary: #1e2a44;         /* clause navy */
  --primary-dark: #131c30;
  --primary-light: #e2e6ef;

  /*
   * THE COLOUR OF A LINK, which is NOT the same question as the colour of the
   * top bar - and they were one token until the themes needed them apart.
   *
   * In the light theme both are the clause navy and it reads correctly: a dark
   * bar with white text, dark links on a white page. On a dark ground the same
   * value cannot do both - a navy bar is right and a navy link is invisible.
   * So the bar keeps --primary and the link gets its own, which every theme
   * sets to whatever reads on ITS page.
   */
  --link: #1e2a44;

  /*
   * AND THE INK ON AN INFORMATION STAMP, for the same reason and found the
   * same way - by measuring rather than by looking.
   *
   * `.stamp.info` is `color: var(--primary)` on `background: var(--primary-light)`,
   * which in the light theme is navy on a pale blue tint. On a dark ground
   * --primary is pinned by the top bar, so the tint has to go dark too and the
   * pair stops being a pair: the first dark theme measured 1.0 to 1 - navy on
   * navy, a stamp with nothing on it. tools/themecheck.js failed it before
   * anybody saw it.
   */
  --info-ink: #1e2a44;

  --accent2: #8f2f24;         /* the query mark in the margin */

  --success: #2f6b43;
  --success-light: #e1eee6;
  --warning: #84620f;
  --warning-light: #f2eace;
  --danger: #8f2f24;
  --danger-light: #f2ddd8;

  --radius: 0;                /* a specification is not rounded */

  --ease: cubic-bezier(0.2, 0, 0.2, 1);
  --ease-out: cubic-bezier(0, 0, 0.2, 1);
  --ease-spring: cubic-bezier(0.2, 0.9, 0.3, 1.2);
  --fast: 110ms;
  --normal: 200ms;
  --slow: 320ms;

  --serif: "Spectral", Georgia, "Times New Roman", serif;
  --sans: "Roboto Condensed", system-ui, -apple-system, "Segoe UI", Arial, sans-serif;
  /* Kept under the old name so nothing that still says var(--mono) breaks.
     It is not monospace - see the note at the top of this file. */
  --mono: "Roboto Condensed", system-ui, -apple-system, "Segoe UI", Arial, sans-serif;

  --figures: tabular-nums lining-nums;

  /* One height for every control on a form row. Without it each kind picks its
     own: a date input reserves space for its calendar button, a select for its
     arrow, a button for its text - and a row of them looks ragged. */
  --control-h: 38px;
}

/* ==========================================================================
   THE OTHER FOUR LOOKS.
   ==========================================================================

   Asked for on 14 October. Each block redefines COLOUR ONLY - the rules, the
   type, the spacing and the squared-off corners are the house style and do not
   move, so a person on Pinky and a person on Dark are reading the same drawing
   in different inks.

   WHICH ONE IS ON COMES FROM THE ACCOUNT, as `data-theme` on <html> - see
   src/theme.js. Anything unrecognised renders as the light theme rather than
   as a page with no colours at all.

   TWO RULES THESE HAVE TO KEEP, and tools/themecheck.js asserts both:

     EVERY THEME DEFINES EVERY COLOUR the light one does. Miss one and that
     token keeps its light value - which is how a theme ends up with white text
     on a white panel, and nothing in the page will tell you which token did it.

     THE INK AND THE TINT INVERT TOGETHER. Every status colour is used as a
     pair - `color: var(--success)` on `background: var(--success-light)` - so
     on a dark ground BOTH flip: the ink becomes the pale one and the tint the
     deep one. Flipping only one gives a stamp nobody can read.

   PRINTED DOCUMENTS ARE NOT AFFECTED AT ALL, and not by accident: every
   printed sheet is its own page with its own stylesheet and does not load this
   file. A delivery receipt is black on white in all five.
   ========================================================================== */

/*
 * WRITTEN AS [data-theme="x"], NOT :root[data-theme="x"].
 *
 * :root is the <html> element and nothing else, so a theme block scoped to it
 * can only ever paint the whole page. The swatches on the account page carry
 * the same attribute on a SPAN - which is what lets a tile show its own theme's
 * colours while you are looking at it in another - and under :root they all
 * quietly showed the colours of the theme already on, making the picker look
 * broken and useless at the one job it has.
 *
 * On <html> the two forms behave identically, so nothing is given up.
 */
/* ---------- Dark: the same drawing on a dark ground ---------- */
[data-theme="dark"] {
  --bg: #11151e;
  --panel: #1a1f2b;
  --panel-2: #222938;
  --border: #3b4356;
  --border-soft: #2a3140;
  --text: #e7e9f0;
  --muted: #9aa4b8;
  --muted-2: #8e97aa;

  /* The bar and the filled buttons stay navy - white text on them still
     reads, and the chrome keeping its colour is what stops Dark feeling like
     a different application. */
  --primary: #223052;
  --primary-dark: #18233d;
  --primary-light: #263351;
  --link: #9ec1ff;
  --info-ink: #9ec1ff;

  --accent2: #e08374;

  --success: #7cc99a;
  --success-light: #1c3328;
  --warning: #e0bc6a;
  --warning-light: #332b16;
  --danger: #f0998c;
  --danger-light: #3a1f1b;
}

/* ---------- Pinky: rose and plum, same ledger rules ---------- */
[data-theme="pinky"] {
  --bg: #fdeef2;
  --panel: #ffffff;
  --panel-2: #fbdfe7;
  --border: #d79cae;
  --border-soft: #f3d2dc;
  --text: #3a1b28;
  --muted: #7d4e60;
  --muted-2: #8a5f72;

  --primary: #8c2f55;
  --primary-dark: #6d2342;
  --primary-light: #fbdce6;
  --link: #8c2f55;
  --info-ink: #8c2f55;

  --accent2: #a8324f;

  --success: #2f6b43;
  --success-light: #e1eee6;
  --warning: #8a5a12;
  --warning-light: #f6e7cd;
  --danger: #a8243f;
  --danger-light: #f8dbe1;
}

/* ---------- Paper: warm sepia, like the printed form ---------- */
[data-theme="paper"] {
  --bg: #e8e0cf;
  --panel: #fbf6ea;
  --panel-2: #f0e8d6;
  --border: #b3a681;
  --border-soft: #ddd3bb;
  --text: #2b2519;
  --muted: #645a44;
  --muted-2: #6d644e;

  --primary: #4a4024;
  --primary-dark: #332e1f;
  --primary-light: #ece2c9;
  --link: #5a4a22;
  --info-ink: #5a4a22;

  --accent2: #8a3b22;

  --success: #40663c;
  --success-light: #e2ead8;
  --warning: #7d5c10;
  --warning-light: #f0e4c4;
  --danger: #8a3b22;
  --danger-light: #efdcd2;
}

/* ---------- High contrast: for a screen in daylight ---------- */
[data-theme="contrast"] {
  --bg: #ffffff;
  --panel: #ffffff;
  --panel-2: #eeeeee;
  /* Near-black rules rather than grey ones: in glare a pale rule disappears
     and the table stops being a table. */
  --border: #000000;
  --border-soft: #555555;
  --text: #000000;
  --muted: #333333;
  --muted-2: #444444;

  --primary: #00204d;
  --primary-dark: #001330;
  --primary-light: #d7e2f3;
  --link: #00308f;
  --info-ink: #00204d;

  --accent2: #8f0000;

  --success: #11491f;
  --success-light: #d7ecd9;
  --warning: #5a3d00;
  --warning-light: #f5e3b8;
  --danger: #8f0000;
  --danger-light: #f6d6d6;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 16px;            /* Roboto Condensed is narrow - this reads as ~15px */
  line-height: 1.5;
}

a { color: var(--link); }

/* Rings only for keyboard users - a mouse click should not leave an outline. */
a:focus-visible, button:focus-visible, input:focus-visible,
select:focus-visible, textarea:focus-visible {
  outline: 2px solid var(--accent2);
  outline-offset: 2px;
}

/* ---------- top bar: the title sheet ---------- */
header.bar {
  background: var(--primary);
  color: #eef1f7;
  padding: 0 20px;
  display: flex;
  align-items: center;
  gap: 22px;
  flex-wrap: wrap;
}
.brand {
  font-family: var(--serif);
  font-weight: 600;
  font-size: 17px;
  padding: 12px 0;
  margin-right: 4px;
}
.brand span {
  display: block;
  font-family: var(--sans);
  font-size: 10px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: #9fabc2;
  font-weight: 700;
}
header.bar nav { display: flex; gap: 2px; flex-wrap: wrap; margin-right: auto; }
header.bar nav a {
  color: #9fabc2;
  text-decoration: none;
  padding: 14px 11px;
  font-size: 15px;
  border-bottom: 2px solid transparent;
  transition: color var(--fast) var(--ease);
}
@media (hover: hover) { header.bar nav a:hover { color: #fff; } }
header.bar nav a.on { color: #fff; border-bottom-color: var(--accent2); }
.whoami { font-size: 14px; color: #9fabc2; display: flex; align-items: center; gap: 10px; }

/*
 * THE MENU BUTTON, which only a phone ever shows.
 *
 * The checkbox is the whole mechanism - no script, because the bar is the one
 * thing on the page that has to work before anything else does, and a menu
 * that needs JavaScript is a menu that is sometimes a wall of forty links.
 * Kept out of sight rather than `display: none` so it can still be tabbed to
 * and the button can show a focus ring for it.
 */
.navopen {
  position: absolute; width: 1px; height: 1px;
  opacity: 0; pointer-events: none;
}
.navbtn { display: none; }
.whoami a { color: #ccd6e6; }
.whoami form { display: inline; }
.linkbtn {
  background: none; border: 0; color: #ccd6e6; cursor: pointer;
  font: inherit; padding: 0; text-decoration: underline;
}

main { max-width: 1280px; margin: 0 auto; padding: 14px 20px 40px; }

/* ---------- headings: the clause hierarchy ---------- */
h1 {
  font-family: var(--serif);
  font-size: 25px;
  font-weight: 600;
  letter-spacing: -0.005em;
  margin: 0 0 5px;
}
h2 { font-family: var(--serif); font-size: 19px; font-weight: 400; margin: 26px 0 10px; }
h3 {
  font-size: 12.5px; margin: 20px 0 8px; text-transform: uppercase;
  letter-spacing: 0.12em; color: var(--muted-2); font-weight: 700;
}
.sub { color: var(--muted); margin: 0 0 8px; }
.pagehead { display: flex; align-items: flex-start; gap: 16px; flex-wrap: wrap; margin-bottom: 8px; }
.pagehead .grow { flex: 1 1 320px; }

/* ---------- panels: a section of the specification ---------- */
.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 10px;
}
.panel > h2, .panel > .panel-head {
  margin: 0;
  padding: 6px 12px;
  border-bottom: 1px solid var(--border);
  background: var(--panel-2);
  font-family: var(--serif);
  font-weight: 400;
  font-size: 16px;
  letter-spacing: 0.01em;
  text-transform: none;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 12px;
}
.panel-body { padding: 10px 12px; }
.panel-head .right { margin-left: auto; font-family: var(--sans); font-size: 14px; }

/* ---------- tables: ruled like a bill of quantities ---------- */
.tscroll { overflow-x: auto; }

/*
 * A SECOND SCROLL BAR, ABOVE THE TABLE.
 *
 * A wide table's only way across was the bar under it, which on a 200-row order
 * screen means scrolling to the bottom of the page to move sideways, then back
 * up to read what you moved. Asked for on 14 October, on the purchase order
 * screen, and given to every wide table because the complaint is true of all of
 * them.
 *
 * The rail is built by the script in partials/foot.ejs and only for a table
 * that actually overflows - a bar that scrolls nothing is furniture.
 *
 * The scrollbar is asked for explicitly rather than left to the browser: the
 * rail holds nothing but a 1px strut, and an overlay scrollbar over an empty
 * strip is invisible until it is grabbed, which is no use as a thing to grab.
 */
.tscroll-rail {
  overflow-x: auto;
  overflow-y: hidden;
  /* So it reads as part of the table below rather than a stray strip. */
  border-bottom: 1px solid var(--border-soft);
  scrollbar-width: thin;
}
.tscroll-rail > .strut { height: 1px; }
.tscroll-rail::-webkit-scrollbar { height: 11px; }
.tscroll-rail::-webkit-scrollbar-thumb {
  background: var(--muted);
  border-radius: 6px;
  /* Narrows the thumb inside its track without changing the grab area. */
  border: 3px solid transparent;
  background-clip: content-box;
}
table {
  border-collapse: collapse;
  width: 100%;
  /*
   * 14px, not 15. A table is a column of part numbers and quantities read by
   * scanning, not prose read by the line - and the point of the smaller size
   * is not the size: it is that a long item description now fits on ONE line
   * where it used to wrap, and a wrapped cell doubles the height of its whole
   * row.
   */
  font-size: 14px;
  /* The double rule a BOQ draws down the edge of its item column. */
  border-left: 3px double var(--border);
}
thead th {
  text-align: left;
  padding: 3px 8px;
  white-space: nowrap;
  background: var(--panel-2);
  border-bottom: 1px solid var(--border);
  font-family: var(--sans);
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted-2);
  font-weight: 700;
}

/*
 * A HEADING YOU CAN CLICK TO SORT BY.
 *
 * It inherits the heading's own type and colour rather than looking like a
 * link, because a row of eight blue underlined words along the top of a table
 * reads as navigation to somewhere else. What marks it as clickable is that it
 * lifts on hover and that the column being sorted is darker and carries an
 * arrow.
 *
 * The whole cell is the target, not just the word: a 10px heading is a small
 * thing to hit, and padding the link to the cell's own edges turns it into a
 * button the size of the column.
 */
.sortlink {
  display: block;
  margin: -3px -8px;
  padding: 3px 8px;
  color: inherit;
  text-decoration: none;
  font: inherit;
  letter-spacing: inherit;
}
/* The heading band is --panel-2, so hovering to --panel is a visible change in
   every one of the five themes without needing a colour of its own. */
.sortlink:hover { color: var(--ink); background: var(--panel); }
/* The column currently sorted on: darker than its neighbours, and the arrow
   says which way. Never the arrow alone - the title attribute says it in
   words, because a glyph reaches a screen reader as nothing. */
.sortlink.on { color: var(--ink); }
th[aria-sort] { background: var(--panel); }

tbody td {
  padding: 2px 8px;
  border-bottom: 1px solid var(--border-soft);
  vertical-align: top;
  /*
   * 1.3, against the body's 1.5.
   *
   * The body line height is set for reading sentences and a table is not
   * sentences. On its own this was the single largest saving here: 15px text at
   * 1.5 is 22.5px of line box before a pixel of padding, which is more than the
   * whole row is meant to be.
   */
  line-height: 1.3;
}
tbody tr:last-child td { border-bottom: 0; }
@media (hover: hover) { tbody tr:hover td { background: #f5f6f9; } }

/* Quantities and pesos align on the decimal. Tabular lining figures do that
   without leaving the document's own typeface. */
td.num, th.num {
  text-align: right;
  font-variant-numeric: var(--figures);
  font-feature-settings: "tnum", "lnum";
  white-space: nowrap;
}
/* A field inside a table row sits in a tighter space than one on a form, so it
   drops the form height and takes the row's own. Numbers align right, the way
   every printed quantity in this app already does, so a column of them reads
   down the decimal instead of wandering. */
tbody td {
  /* Redefining the variable rather than the height. The rule that sets the
     height is a long :not() chain and so outranks anything reasonable written
     here - setting `height` on `tbody td input` simply lost, and table fields
     came out 38px while the selects beside them obeyed at 32. Changing the
     variable sidesteps the fight: the same rule applies, it just reads a
     smaller number inside a cell. */
  /*
   * 24px inside a cell, against 32 before and 38 outside one.
   *
   * This is the floor on every screen that has fields in its rows, so it is
   * also the reason those rows cannot reach 20px however tight the padding
   * gets: a date field needs room for its calendar icon and a button needs
   * room to be hit. 24 is the smallest that stays usable.
   */
  --control-h: 24px;
}
tbody td input, tbody td select { padding: 0 5px; font-size: 13.5px; }
tbody td input[type="number"] { text-align: right; }

/* Two widths for the columns people type into, rather than a number picked per
   screen - these were 90, 100, 105, 110 and 120px across the app for the same
   kind of column. Money gets the wider one: it carries two decimals and runs
   into the tens of thousands. Both are sized so the longest value that belongs
   there is fully visible, which is what "11,000" showing as "110(" was about. */
th.col-qty, td.col-qty { width: 112px; }
th.col-money, td.col-money { width: 128px; }

/* AND ONE WIDTH FOR THE ITEM COLUMN, for the same reason and with the same
   history: it was 200, 210, 220, 230, 240, 260 and 280px across the app for the
   identical column.

   300px because that is where a real description stops wrapping. Measured, not
   chosen - "PLAIN SHEET GAUGE 16 (1.2MM) - RS 442717" takes three lines in a
   140px column and one in 300, and on the busiest screen the item column is the
   ONLY thing still setting the row height: everything beside it is 24px. Rows
   went from 105px to 41 on cell padding alone, and to 29 once the description
   fits on one line.

   A min-width rather than a width, so a longer description still wraps instead
   of pushing every other column off the screen. */
th.col-item, td.col-item { min-width: 300px; }
/*
 * BUT NOT ON A SMALL SCREEN.
 *
 * 300px for the description is what stops a part number wrapping onto three
 * lines, and it is worth having. It is not worth having at the cost of pushing
 * the last column off the edge, which is what widening the delivery screen's
 * remarks box did at 1024px - one fix paid for with another fault.
 *
 * Below 1200px the description gives the room back and wraps instead. A wrapped
 * description costs a row's height; an unreachable box costs the feature.
 */
@media (max-width: 1200px) {
  th.col-item, td.col-item { min-width: 200px; }
}

td.code {
  font-variant-numeric: var(--figures);
  font-feature-settings: "tnum", "lnum";
  white-space: nowrap;
  color: var(--muted);
}
.peso::before { content: "\20B1"; color: var(--muted-2); margin-right: 2px; }

/* ---------- status marks ---------- */
.stamp {
  display: inline-block; font-family: var(--sans); font-size: 11px;
  letter-spacing: 0.07em; text-transform: uppercase; font-weight: 700;
  padding: 1px 7px; border: 1px solid currentColor; border-radius: var(--radius);
  white-space: nowrap;
}
.stamp.ok { color: var(--success); background: var(--success-light); }
.stamp.warn { color: var(--warning); background: var(--warning-light); }
.stamp.bad { color: var(--danger); background: var(--danger-light); }
.stamp.info { color: var(--info-ink); background: var(--primary-light); }
.stamp.plain { color: var(--muted); background: var(--panel-2); }

/*
 * A STAMP THAT IS ALSO A WAY IN - the front page's source table.
 *
 * No underline at rest: a line drawn under a bordered box reads as a fault
 * rather than as a link, and the stamp keeps its own colour because `.stamp.ok`
 * out-weighs the bare `a` rule. The affordance is the ring under the pointer,
 * and the row carries a plain button as well for anybody who does not hover.
 */
.stamplink { text-decoration: none; }
.stamplink:hover .stamp, .stamplink:focus-visible .stamp {
  box-shadow: 0 0 0 2px var(--border);
}

/* A figure that opens to explain itself.
   A BUTTON wearing a link's clothes, not a link: it goes nowhere, and an <a>
   with no href is unreachable by keyboard and silent to a screen reader. It
   keeps the table's own font and alignment so the column still reads as a
   column of money - the dotted underline is the only thing marking it. */
.linkish {
  background: none;
  border: 0;
  padding: 0;
  font: inherit;
  color: var(--link);
  cursor: pointer;
  text-decoration: underline dotted;
  text-underline-offset: 2px;
}
.linkish:hover, .linkish:focus-visible { text-decoration: underline; }

/* ---------- figures: the quantities column ---------- */
.figures { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 1px; background: var(--border-soft); }
.figure { background: var(--panel); padding: 12px 15px; }
.figure .n {
  font-family: var(--serif); font-size: 24px; display: block; line-height: 1.2;
  font-variant-numeric: var(--figures); font-feature-settings: "tnum", "lnum";
}
.figure .k {
  font-family: var(--sans); font-size: 10px; letter-spacing: 0.14em;
  text-transform: uppercase; color: var(--muted-2); font-weight: 700;
}
.figure.quiet .n { color: var(--muted-2); }
/*
 * A FIGURE THAT IS ALSO THE WAY IN.
 *
 * On the expenses register each figure opens the rows behind it. It must not
 * look like a link - a page of underlined blue numbers is unreadable - so it
 * keeps the figure's own type and says it is clickable by lifting under the
 * pointer, with the current one underscored.
 */
a.figure { display: block; text-decoration: none; color: inherit; }
a.figure:hover, a.figure:focus-visible { background: var(--panel-2); }
a.figure.on { box-shadow: inset 0 -3px 0 var(--primary); }

/* ---------- forms ---------- */
label { display: block; font-size: 14px; color: var(--muted); margin-bottom: 3px; }
/* Everything a person types into, listed by what it is NOT.
   The old rule named types one by one and so missed `<input>` written without
   a type attribute - which is most of them in this app, 72 at the last count.
   Those fell back to the browser's own box: a different height, a different
   border, no padding. Next to a date field or a select they looked broken,
   because they were. Excluding the handful of inputs that are buttons or ticks
   catches every text-like field, including any type added later. */
input:not([type="checkbox"]):not([type="radio"]):not([type="submit"]):not([type="button"]):not([type="reset"]):not([type="file"]):not([type="image"]):not([type="range"]):not([type="color"]),
select, textarea {
  font: inherit; font-size: 15.5px; padding: 6px 9px;
  border: 1px solid var(--border); border-radius: var(--radius);
  background: #fff; color: var(--text); width: 100%;
  font-variant-numeric: var(--figures);
}

/* Height is set apart from padding so a textarea, which grows, is left out. */
input:not([type="checkbox"]):not([type="radio"]):not([type="file"]):not([type="range"]),
select, button, .btn {
  height: var(--control-h);
}

/* The little up/down arrows on a number field cost 15-20px of a column that is
   already tight, and nobody nudges a quantity one unit at a time - they type
   it. Removing them is what lets "11,000" fit where "110(" was showing. */
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; }
input:disabled, select:disabled { background: var(--panel-2); color: var(--muted-2); }
.field { margin-bottom: 12px; }
/* Controls line up along their bottom edge, so a label that wraps to two lines
   lifts its own label rather than dropping its field below the others. */
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; margin-bottom: 6px; }
.row:last-child { margin-bottom: 0; }
/* min-width:0 is what makes these widths mean anything. A flex item's automatic
   minimum is its content's own size, and an <input> reports roughly 20
   characters - so every field silently sat at ~177px whatever basis it was
   given, and a row of them came out ragged. */
.row > * { flex: 1 1 160px; min-width: 0; }
.row > .narrow { flex: 0 1 150px; }
/* A field that holds only a button: sized to its content, never squeezed to a
   column width that wraps the button's own label. */
.row > .shrink { flex: 0 0 auto; }
/* A field that takes a line of its own, below the rest of the row. For the box
   that appears when a choice needs explaining - squeezed into a column beside
   four others it reads as an afterthought, and its note wraps to six lines. */
.row > .own-line { flex: 1 1 100%; }
.check { display: flex; align-items: center; gap: 7px; font-size: 15px; color: var(--text); }
.check input { width: auto; accent-color: var(--primary); }

button, .btn {
  font: inherit; font-size: 15.5px; padding: 6px 15px; cursor: pointer;
  border: 1px solid var(--primary-dark); border-radius: var(--radius);
  background: var(--primary); color: #eef1f7; text-decoration: none; display: inline-block;
  white-space: nowrap;
  transition: background var(--fast) var(--ease), transform var(--fast) var(--ease);
}
@media (hover: hover) { button:hover, .btn:hover { background: var(--primary-dark); } }
button:active, .btn:active { transform: scale(0.97); }
button.secondary, .btn.secondary {
  background: var(--panel); color: var(--text); border-color: var(--border);
}
@media (hover: hover) {
  button.secondary:hover, .btn.secondary:hover { background: var(--panel-2); }
}
button.small, .btn.small { font-size: 14px; padding: 3px 10px; }

/* ---------- flash ---------- */
.flash {
  padding: 9px 14px; border: 1px solid var(--border); border-left-width: 3px;
  background: var(--panel); margin-bottom: 16px; border-radius: var(--radius);
}
.flash.ok { border-left-color: var(--success); background: var(--success-light); }
.flash.warn { border-left-color: var(--warning); background: var(--warning-light); }
.flash.bad { border-left-color: var(--danger); background: var(--danger-light); }

/* A passcode shown once and never again - deliberately conspicuous. */
.issued {
  border: 2px solid var(--accent2); background: #fbf1ef;
  padding: 12px 15px; margin-bottom: 16px; border-radius: var(--radius);
}
.issued .pw {
  font-family: var(--mono); font-size: 23px; letter-spacing: 0.1em;
  font-weight: 700; margin: 4px 0 6px;
}

/*
 * Anywhere a passcode is typed. Monospace and wide tracking because these get
 * copied off a card character by character, and a passcode that has been
 * mistyped should be obvious before the button is pressed.
 */
/* A box holding a code that is written in capitals - a passcode tag, a project
   code. The uppercasing is display only; what was typed is what gets sent, and
   the server matches case-insensitively. */
.passcode-input, .code-input {
  font-family: var(--mono); letter-spacing: 0.12em; text-transform: uppercase;
}
.passcode-input::placeholder, .code-input::placeholder { letter-spacing: 0.06em; text-transform: none; }

/* ---------- login ---------- */

/*
 * The sign-in screen sits on a photograph of the company's own work. It is the
 * one page in the app with a picture on it, and it earns that by being the one
 * page nobody is trying to get work done on.
 *
 * The photograph is dark blue water and bright sky, so nothing is legible
 * against it unevenly. Two things fix that: a gradient scrim weighted towards
 * the bottom, where the text sits, and a solid paper-coloured card for the form
 * itself. The card is deliberately NOT translucent - a passcode being typed
 * character by character should sit on paper, not on the sea.
 */
body.signin {
  /* The colour shows while the photograph loads, and if it never does. */
  background: var(--primary-dark);
  /* A column so the credit line can be pushed to the bottom of the window
     instead of floating in the middle of the sea under a short form. */
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
body.signin main { flex: 1 0 auto; }
body.signin .foot { flex-shrink: 0; }
body.signin::before {
  content: "";
  position: fixed; inset: 0; z-index: -2;
  background: url("/img/login.jpg") center / cover no-repeat;
}
body.signin::after {
  content: "";
  position: fixed; inset: 0; z-index: -1;
  /* Darkest at the very top, where the title sits over pale sky and paler
     mountains, and again at the bottom under the credit line. The middle is
     left alone - the card supplies its own contrast. */
  background: linear-gradient(
    to bottom,
    rgba(12, 21, 38, 0.62) 0%,
    rgba(12, 21, 38, 0.42) 18%,
    rgba(12, 21, 38, 0.16) 45%,
    rgba(12, 21, 38, 0.30) 78%,
    rgba(12, 21, 38, 0.66) 100%
  );
}
body.signin main { padding-bottom: 24px; }

/* The wrapper is wide enough for the title to stay on one line; the card
   inside it keeps the narrow measure a single field deserves. */
.loginwrap { max-width: 620px; margin: 8vh auto 0; }
.loginwrap .panel { max-width: 380px; margin-left: auto; margin-right: auto; }
.loginwrap .brandmark { text-align: center; margin-bottom: 20px; color: #fff; }
.loginwrap .brandmark strong {
  display: block; font-family: var(--serif); font-size: 27px; font-weight: 600;
  /* Two shadows: a tight one for edge definition against the mountains, and a
     wide soft one to lift the whole word off the sky behind it. */
  text-shadow: 0 1px 2px rgba(8, 14, 26, 0.85), 0 2px 22px rgba(8, 14, 26, 0.7);
}
.loginwrap .brandmark span {
  /* This line was the worst of it: small, widely tracked, and sitting exactly
     on the ridge line. Full white, a size larger, with the same double shadow. */
  font-family: var(--sans); font-size: 11.5px; letter-spacing: 0.18em;
  text-transform: uppercase; font-weight: 700;
  color: #fff;
  text-shadow: 0 1px 2px rgba(8, 14, 26, 0.9), 0 2px 16px rgba(8, 14, 26, 0.75);
  margin-top: 4px;
}
.loginwrap .panel {
  box-shadow: 0 18px 50px rgba(8, 16, 32, 0.38);
  border-color: rgba(255, 255, 255, 0.5);
}
/* The footer is furniture; on this page it stays out of the photograph's way.
   The stage chain and the brand line are both said better by the card above,
   so only the credit line stays - and it keeps a shadow, because it sits on
   open water rather than on a scrim. */
body.signin .foot-row { display: none; }
body.signin .foot {
  border-top: 0;
  padding-bottom: 20px;
}
body.signin .foot-legal {
  border-top: 0;
  margin-top: 0;
  padding-top: 0;
  color: #fff;
  text-shadow: 0 1px 2px rgba(8, 14, 26, 0.9), 0 2px 14px rgba(8, 14, 26, 0.75);
}

/* A phone shows a tall crop of a landscape photograph, so the card is given
   more of the screen and less of the sea. */
@media (max-width: 560px) {
  .loginwrap { margin-top: 4vh; }
  .loginwrap .brandmark strong { font-size: 22px; }
  .loginwrap .brandmark span { font-size: 10.5px; letter-spacing: 0.14em; }
}

/* ---------- project codes ---------- */
/*
 * A project code is shown on its own; the contract name sits behind it as a
 * tooltip. Marked so people know to hover - an underline nobody can see is the
 * same as no tooltip at all. Only codes that HAVE a name get the treatment, so
 * the marking also says which ones are still unnamed.
 */
.pcode {
  border-bottom: 1px dotted var(--muted-2);
  cursor: help;
}
@media (hover: hover) {
  .pcode:hover { border-bottom-color: var(--accent2); color: var(--accent2); }
}

/*
 * An equipment body number, wherever it is shown. Set apart from the item
 * description beside it - a tag, not more description - and marked red like a
 * project code when the company's list does not carry it.
 */
.eqcode {
  display: inline-block;
  font-family: var(--mono, "Roboto Condensed", monospace);
  font-variant-numeric: tabular-nums lining-nums;
  font-size: 12.5px;
  font-weight: 600;
  letter-spacing: 0.04em;
  padding: 0 5px;
  border: 1px solid var(--border);
  background: var(--panel-2);
  color: var(--muted);
  border-radius: 2px;
  white-space: nowrap;
  cursor: help;
}
.eqcode.off-list { border-color: var(--accent2); color: var(--accent2); background: transparent; }
@media (hover: hover) {
  .eqcode:hover { border-color: var(--link); color: var(--link); }
  .eqcode.off-list:hover { border-color: var(--accent2); color: var(--accent2); }
}

/*
 * The confirmation. Deliberately plain and deliberately in the way: something
 * about to be removed should cost a moment's attention, and a dialog that
 * slides prettily out of a corner does not buy that moment.
 */
.askbox {
  position: fixed; inset: 0; z-index: 90;
  background: rgba(27, 31, 40, 0.55);
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
}
/*
 * THIS RULE IS NOT OPTIONAL. The `hidden` attribute is only `display: none`
 * from the browser's own stylesheet, and ANY class rule outranks it - so the
 * `display: flex` above beat it and the dialog sat open, empty, on every page
 * in the app including the sign-in screen. Hiding by attribute needs the
 * attribute to win.
 */
.askbox[hidden] { display: none; }
.askbox-sheet {
  background: var(--panel);
  border: 1px solid var(--border);
  box-shadow: 0 10px 40px rgba(27, 31, 40, 0.3);
  max-width: 460px; width: 100%;
  padding: 20px 22px;
}
.askbox-q {
  font-family: var(--serif, Georgia, serif);
  font-size: 18px; font-weight: 600; line-height: 1.3;
  color: var(--text);
}
.askbox-note { margin-top: 8px; font-size: 14px; color: var(--muted); }
.askbox-do { display: flex; gap: 8px; justify-content: flex-end; margin-top: 18px; }
button.danger {
  background: var(--accent2); border-color: var(--accent2); color: #fff;
}
@media (hover: hover) {
  button.danger:hover { filter: brightness(1.08); }
}

/* ---------- pagination ---------- */
.pager { display: flex; gap: 8px; align-items: center; margin-top: 14px; font-size: 14.5px; }
.pager .spacer { margin-left: auto; color: var(--muted); }

/* ---------- misc ---------- */
.muted { color: var(--muted); }
.small { font-size: 14px; }
.nowrap { white-space: nowrap; }
.foot {
  max-width: 1280px; margin: 0 auto; padding: 14px 20px 30px;
  color: var(--muted-2); font-size: 11px;
  letter-spacing: 0.13em; text-transform: uppercase; font-weight: 700;
  border-top: 1px solid var(--border-soft);
}
.foot-row { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
/* The credit line is a sentence, not a label - it keeps its own casing and
   spacing rather than inheriting the footer's small-caps treatment. */
.foot-legal {
  margin-top: 12px; padding-top: 11px;
  border-top: 1px solid var(--border-soft);
  text-align: center; text-transform: none;
  letter-spacing: 0.01em; font-weight: 400; font-size: 12.5px;
  color: var(--muted);
}
.empty { padding: 26px 15px; text-align: center; color: var(--muted); }

/* ---------------------------------------------------------------------------
   THE CLAUSE REFERENCE - this direction's whole reason for existing.

   `item_of_works` is not a note, it is a pay item number: 1032(1)A, 405(2)D,
   903(2). 5,688 lines carry one. Everywhere it appears it is now set as a
   formal reference rather than as muted grey commentary - bordered, in the
   document's serif, always upper case so the 33 codes recorded in two
   different cases read as the one clause they actually are.
   --------------------------------------------------------------------------- */
.clause {
  display: inline-block;
  font-family: var(--serif);
  font-size: 12.5px;
  line-height: 1.35;
  padding: 0 5px;
  border: 1px solid var(--border);
  border-left: 3px solid var(--primary);
  background: var(--panel-2);
  color: var(--text);
  text-transform: uppercase;
  white-space: nowrap;
  font-variant-numeric: var(--figures);
}
a.clause { text-decoration: none; }
@media (hover: hover) { a.clause:hover { background: var(--primary-light); } }

/* ---------------------------------------------------------------------------
   The margin query mark. A specification queries anything that departs from
   what was specified; this app already knows two such things from its own
   data, so both carry it:

     .over  a PO unit price above the budgeted unit price for that line
     .under a stock balance below zero

   Both are stated in words too - colour is never the only carrier.
   --------------------------------------------------------------------------- */
td.num.over, td.num.under, .over, .under {
  color: var(--accent2);
  font-weight: 700;
}
td.num.over::after { content: " \25B2"; font-size: 9px; vertical-align: 1px; }
td.num.under::after { content: " \25BC"; font-size: 9px; vertical-align: 1px; }

/* ---------------------------------------------------------------------------
   Grouped navigation, by the department that owns each stage - Purchasing,
   Central Warehouse, Project Warehouse. The panel reads as a contents list
   pulled out of the specification.
   --------------------------------------------------------------------------- */
.menu { position: relative; }
.menu-t {
  font: inherit;
  font-size: 15px;
  color: #9fabc2;
  background: none;
  border: 0;
  border-bottom: 2px solid transparent;
  border-radius: 0;
  padding: 14px 11px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: color var(--fast) var(--ease);
}
@media (hover: hover) { .menu-t:hover { color: #fff; background: none; } }
.menu-t:active { transform: none; }
.menu-t.on { color: #fff; border-bottom-color: var(--accent2); }
/* The caret, drawn rather than typed so it never turns into an emoji. */
.menu-t i {
  width: 0; height: 0; display: inline-block;
  border-left: 3.5px solid transparent;
  border-right: 3.5px solid transparent;
  border-top: 4px solid currentColor;
  opacity: 0.78;
  transition: transform var(--fast) var(--ease);
}
.menu.open .menu-t i { transform: rotate(180deg); }

.menu-p {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  z-index: 40;
  min-width: 250px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-top: 3px solid var(--accent2);
  border-radius: 0;
  padding: 6px 0;
  box-shadow: 0 7px 20px rgba(30, 42, 68, 0.2);
}
.menu.open .menu-p { display: block; }
/* Keyboard users never trigger the JS toggle, so focus alone opens it too. */
.menu:focus-within .menu-p { display: block; }

.menu-g { padding: 5px 0; }
.menu-g + .menu-g { border-top: 1px solid var(--border-soft); }

/* These sit INSIDE `header.bar nav`, whose own link colour is a pale blue
   chosen for the dark bar. That selector is (0,1,3) and beat a plain
   `.menu-p a` at (0,1,1), so the dropdown was drawing bar-coloured text on a
   white panel - 2.31:1, and the active item was white on near-white at 1.16:1.
   Prefixing with `header.bar` lifts these to (0,2,3) so the panel controls its
   own colours, and every pair below clears 4.5:1. */
header.bar .menu-h {
  display: block;
  padding: 6px 15px 4px;
  font-size: 11px;
  letter-spacing: 0.13em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 700;
}
header.bar .menu-p a {
  display: block;
  padding: 6px 15px;
  font-size: 15.5px;
  color: var(--text);
  text-decoration: none;
  border-left: 3px solid transparent;
}
@media (hover: hover) {
  header.bar .menu-p a:hover { color: var(--text); background: var(--panel-2); }
}
header.bar .menu-p a.on {
  border-left-color: var(--accent2);
  font-weight: 700;
  color: var(--accent2);
  background: var(--panel-2);
}

/* On a phone the bar stacks, so a floating panel would fall off the screen.
   The menus become plain inline sections instead - everything visible, nothing
   to tap twice. */
@media (max-width: 760px) {
  .menu { width: 100%; }
  .menu-t { display: none; }
  .menu-p {
    display: block;
    position: static;
    min-width: 0;
    background: none;
    border: 0;
    border-top: 1px solid rgba(255, 255, 255, 0.16);
    box-shadow: none;
    padding: 4px 0 8px;
  }
  .menu-g + .menu-g { border-top: 0; }
  /* On the bar itself, so light-on-dark - the opposite of the desktop panel. */
  header.bar .menu-h { color: #b6c1d4; padding-left: 0; }
  header.bar .menu-p a { color: #dbe3ef; padding: 5px 0; border-left: 0; }
  header.bar .menu-p a.on { background: none; color: #fff; font-weight: 700; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}

/* A number typed into a table cell that is not a browser number input -
   the budget box takes arithmetic, so it has to be plain text. */
tbody td input.num-input { text-align: right; }

/* A fact that is shown rather than typed: the same size and rhythm as the box
   it replaces, so a panel of read-only detail lines up with one of inputs. */
.readout {
  min-height: var(--control-h);
  display: flex;
  align-items: center;
  font-weight: 600;
  padding: 4px 0;
}
.readout .muted { font-weight: 400; }
/*
 * A READ-ONLY VALUE THAT TAKES TWO LINES.
 *
 * `.readout` is a flex row so a value sits centred against a control of the
 * same height beside it. That makes a <br> inside it do NOTHING: the two
 * halves of "AW-CAMIGUIN / Area Warehouse - Camiguin" became side-by-side
 * flex items instead, the name was squeezed into whatever width was left, and
 * it wrapped through three lines and into the next column's label. The
 * template had said "stacked, not wrapped" for months; the stylesheet was
 * quietly overruling it.
 */
.readout.stacked { flex-direction: column; align-items: flex-start; gap: 1px; }
/*
 * AND A ROW OF FACTS LINES UP AT THE TOP, not along the bottom.
 *
 * `.row` aligns to flex-end so a row of INPUTS sits on one baseline whatever
 * the labels do. In a row of read-only facts that is backwards: one value
 * taking two lines pushed its own label upward, so six labels that should
 * read as a header sat at two different heights.
 */
.row.facts { align-items: flex-start; }

/*
 * A table whose columns are declared rather than negotiated.
 *
 * The default shares space out by content, which is right for a list of text
 * and wrong for a row of form controls: a <select> has no text of its own
 * until it is opened, so it collapses to nothing while a long description
 * takes the room. Declaring the widths in a <colgroup> gives every control the
 * space it needs to be read.
 */
table.fixed { table-layout: fixed; width: 100%; }
table.fixed td, table.fixed th { overflow: hidden; }
/* Controls fill the column they were given, rather than each carrying its own
   width and drifting out of line with the heading above it. */
table.fixed td input:not([type="checkbox"]),
table.fixed td select { width: 100%; }

/*
 * Something that is not on the master data it should have come from: a
 * project code, an item, a supplier that nobody has matched to the SAP list.
 *
 * Red and underlined rather than red alone. Colour on its own is no use to
 * somebody who cannot tell these two reds apart, and none to anybody at all on
 * a photocopy.
 */
.off-list {
  color: var(--danger);
  text-decoration: underline;
  text-decoration-style: dotted;
  text-underline-offset: 2px;
}

/* A heading row inside a table body: one item, with the sites asking for it
   listed under it. Shaded rather than bold alone, because the rows beneath it
   are the detail and the eye has to be able to tell where one item's sources
   end and the next begins. */
tbody tr.groupline td {
  background: var(--panel-2);
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}
@media (hover: hover) { tbody tr.groupline:hover td { background: var(--panel-2); } }

/* A row of controls inside a table cell. The page-level row is sized for a
   form panel: in a cell its 12px gap and 160px field basis push the action
   buttons out of sight. The button field is .shrink, so it keeps its own
   label's width and the text box takes whatever is left. */
.row.tight { gap: 6px; margin: 0 0 4px; flex-wrap: nowrap; align-items: flex-end; }
.row.tight > * { flex: 1 1 90px; }
/*
 * AND `shrink` STILL MEANS SHRINK INSIDE A TIGHT ROW.
 *
 * `.row > .shrink` already says flex: 0 0 auto, and it loses here: the two
 * selectors carry the same weight, so the one further down the file wins and
 * that is the stretch rule above. The symptom was an export button a third of
 * the screen wide to say "Excel" - naming the class did nothing and the only
 * clue was the button itself.
 */
.row.tight > .shrink { flex: 0 0 auto; }
.row.tight input { padding: 4px 8px; font-size: 14px; }
.row.tight:last-child { margin-bottom: 0; }

/* ---------------------------------------------------------------- demo ---
 * A STRIPE NOBODY CAN MISS, and one that stays put when the page scrolls.
 *
 * Amber rather than red: red in this app means something is wrong, and a demo
 * is not wrong - it is just not real. It has to be unmistakable without
 * reading as an error, because an error people learn to dismiss.
 */
.demobar {
  position: sticky; top: 0; z-index: 1000;
  background: #7d5c0c; color: #fff;
  padding: 6px 14px; font-size: 13px; line-height: 1.35;
  display: flex; gap: 14px; align-items: baseline; flex-wrap: wrap;
  border-bottom: 2px solid #4a3607;
}
.demobar strong { letter-spacing: .06em; white-space: nowrap; }
.demobar span { opacity: .92; }
.demobar .db { font-family: ui-monospace, Consolas, monospace; font-size: 12px; opacity: .8; }

/* ===================================================== incident photographs ==
 * Evidence on an incident report: what arrived wrong, and what was done about
 * it. A grid rather than a list because people scan photographs, and a column
 * of them is a page nobody reaches the bottom of.
 */
.photo-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 10px;
}
.photo-item { margin: 0; }
.photo-item img {
  width: 100%;
  /* A FIXED HEIGHT WITH object-fit, so a row of portrait and landscape
     photographs lines up instead of stepping. The whole picture is one click
     away at full size, so nothing is lost by cropping the thumbnail. */
  height: 118px;
  object-fit: cover;
  display: block;
  border: 1px solid #c8cedb;
  background: #f3f4f7;
}
.photo-item figcaption {
  font-size: 11px;
  line-height: 1.35;
  margin-top: 3px;
  word-break: break-word;
}
.photo-item figcaption form { margin-top: 3px; }

/* The chooser, before anything is sent. Same shape as the grid above so what
   is about to be attached looks like what is already attached. */
.photo-previews {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 8px;
  margin-top: 7px;
}
.photo-preview img {
  width: 100%;
  height: 92px;
  object-fit: cover;
  display: block;
  border: 1px solid #c8cedb;
}
.photo-preview input { width: 100%; margin-top: 3px; }
.photo-picker input[type="file"] { display: block; margin-top: 3px; }

/*
 * A LINE A PURCHASE ORDER WROTE ONTO A SLIP.
 *
 * Blue, because the company already reads blue ink on a paper slip as
 * "added after the fact" - the screen is borrowing a convention the
 * storekeepers brought with them rather than inventing a new one.
 *
 * Not a stamp: the stamps say what STATE a thing is in, and they are
 * read as something that can change. This says where the line CAME
 * FROM, which never changes, so it is set as ink rather than as a
 * badge. Colour is not carrying it alone - the words say it too, for
 * anyone who cannot tell the blue from the grey.
 */
.added-on-po {
  color: #1d4ed8;
  font-size: 12px;
  font-weight: 600;
}

/* ---------- choosing a look, on My account ---------- */
/*
 * The tiles are laid out as cards rather than a dropdown because a dropdown
 * shows one option at a time, and the whole difficulty here is comparing five.
 */
.themepick { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 10px; }
.themecard {
  display: block; cursor: pointer; padding: 9px;
  border: 1px solid var(--border); background: var(--panel);
  transition: border-color var(--fast) var(--ease);
}
.themecard.on { border-color: var(--accent2); box-shadow: inset 0 0 0 1px var(--accent2); }
.themecard input { margin: 0 0 6px; width: auto; }
.themecard .themename { display: block; font-weight: 700; margin-top: 6px; }
/*
 * THE SWATCH IS PAINTED BY THE THEME ITSELF - data-theme on this element, the
 * same attribute the page is keyed from, so a tile cannot advertise a colour
 * its theme does not use.
 */
.themepick .swatch {
  display: block; height: 58px; border: 1px solid var(--border);
  background: var(--bg); overflow: hidden;
}
.themepick .s-bar { display: block; height: 14px; background: var(--primary); }
.themepick .s-page { display: block; padding: 6px; }
.themepick .s-panel {
  display: block; height: 10px; background: var(--panel); border: 1px solid var(--border-soft);
}
.themepick .s-stamp {
  display: block; width: 46px; height: 9px; margin-top: 5px;
  background: var(--warning-light); border: 1px solid var(--warning);
}
/* The grid is wider than one card on a phone, so the cards stack instead. */
@media (max-width: 480px) { .themepick { grid-template-columns: 1fr; } }

/* ---------- picking several names from one box ---------- */
/*
 * The browser's own multiple-choice list needs the control key held down to
 * pick a second item, which is not a thing most people know and not a thing a
 * label can explain. This is ordinary tick boxes behind a summary that says
 * how many are ticked, so the filter row stays one line until it is opened.
 */
.pickmany { position: relative; }
.pickmany > summary {
  height: var(--control-h);
  display: flex; align-items: center; gap: 6px;
  padding: 0 10px; cursor: pointer;
  border: 1px solid var(--border); background: var(--panel);
  font-size: 15.5px; white-space: nowrap;
}
.pickmany > summary::after { content: "▾"; margin-left: auto; color: var(--muted); }
.pickmany[open] > summary::after { content: "▴"; }
.pickmany > summary:focus-visible { outline: 2px solid var(--accent2); outline-offset: 2px; }
/*
 * OVER the rest of the form rather than pushing it down: opening a filter must
 * not move the Show button out from under somebody's cursor.
 */
.pickmany-list {
  position: absolute; z-index: 20; min-width: 240px; max-height: 320px;
  overflow-y: auto; padding: 8px 10px;
  border: 1px solid var(--border); background: var(--panel);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.18);
}
.pickmany-list .check { padding: 3px 0; }
/* On a phone there is nowhere to float it, so it opens in place. */
@media (max-width: 620px) {
  .pickmany-list { position: static; min-width: 0; box-shadow: none; }
}

/*
 * EVERYTHING BELOW IS THE PHONE, and it is at the FOOT of the file on
 * purpose. A media query carries no extra weight of its own: `.row.tight`
 * inside one still loses to `.row.tight` written later in the file, which is
 * how the first draft of this block left two buttons unable to wrap and the
 * reports index scrolling sideways. Overrides go last.
 */
/*
 * ======================== A PHONE ========================
 *
 * THE BAR WAS 1,357 PIXELS TALL.
 *
 * The rule below this one turns every drop-down into a plain inline list -
 * "everything visible, nothing to tap twice", which was the right instinct and
 * the wrong result: forty links, six headings and the account line, all of it
 * ABOVE the page, on every screen in the app. Measured on a 375px phone the
 * title of the purchase order register did not appear until you had scrolled
 * past three and a half screens of menu.
 *
 * So the whole lot now sits behind one button, and the page starts where the
 * page should start. Opened, it is still the same flat list - the instinct
 * survives, one tap away.
 */
@media (max-width: 760px) {
  /*
   * A tighter bar, because it is now a bar and not a contents page - and one
   * that stays put. The button is the only way to the other screens, and a bar
   * that scrolls away means scrolling a 150-row receiving list back to the top
   * to reach it.
   */
  header.bar { padding: 0 14px; gap: 10px; position: sticky; top: 0; z-index: 30; }
  /*
   * The brand gives way rather than pushing the button onto a second line.
   *
   * Both have to share 375px, and until the web font arrives the company name
   * is set in whatever the phone has - which is wider. Measured with the
   * fallback the bar came to 112px, two lines of it, and that is what somebody
   * on a slow connection sees first. So the name shrinks and, if it has to,
   * trails off; the button keeps its size, because it is the only way off this
   * screen.
   */
  /*
   * `flex: 1 1 0` and not `0 1 auto`, which is the thing worth writing down: a
   * wrapping flex line WRAPS before it shrinks, so an item that is merely
   * allowed to shrink never does - it goes to a second row and takes the
   * button with it. Starting from a basis of nothing and growing into what is
   * left means there is never a line to wrap.
   */
  .brand { font-size: 15.5px; padding: 10px 0; flex: 1 1 0; min-width: 0; }
  .brand span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

  .navbtn {
    display: inline-flex; align-items: center; gap: 8px;
    margin-left: auto; cursor: pointer; flex: 0 0 auto;
    font-family: var(--sans); font-size: 14px; font-weight: 700;
    letter-spacing: 0.08em; text-transform: uppercase;
    color: #dbe3ef;
    /* A real target for a thumb, not a 14px word. */
    padding: 9px 12px; margin-right: -4px;
    border: 1px solid rgba(255, 255, 255, 0.22);
    border-radius: var(--radius);
  }
  .navbtn::after {
    content: ""; border: 5px solid transparent;
    border-top-color: currentColor; margin-top: 4px;
  }
  .navopen:focus-visible + .navbtn {
    outline: 2px solid var(--accent2); outline-offset: 2px;
  }

  /* Shut on arrival, every time: a page load is not a request for the menu. */
  header.bar nav, header.bar .whoami { display: none; }
  /*
   * Opened, the list is 1,300px of links. It scrolls INSIDE itself rather than
   * pushing the page down by that much - otherwise opening the menu loses your
   * place on the page, and closing it means scrolling back to find the button.
   * The room left over is for the account line below it.
   */
  .navopen:checked ~ nav {
    display: flex;
    max-height: calc(100vh - 150px);
    overflow-y: auto;
    overscroll-behavior: contain;
  }
  /* Who you are and the way out belong with the menu, not on the bar. */
  .navopen:checked ~ .whoami {
    display: flex; flex: 1 1 100%; flex-wrap: wrap;
    padding: 8px 0 10px; border-top: 1px solid rgba(255, 255, 255, 0.16);
  }
  .navopen:checked + .navbtn::after { transform: rotate(180deg); }

  /* Links a thumb can hit. 5px of padding is a line of text, not a target.
     And room between the two that share the top row - at the bar's 2px gap
     "Overview" and "Find an item" read as one phrase. */
  header.bar nav { column-gap: 18px; }
  header.bar nav > a { padding: 9px 0; }

  /*
   * THE PAGE'S OWN MARGIN. 20px either side of a 375px screen spends a ninth
   * of it on nothing, and the thing being squeezed is a table of quantities.
   */
  main { padding: 12px 14px 32px; }

  /*
   * AND THE ONE THAT DECIDES WHETHER THE APP CAN BE TYPED INTO AT ALL.
   *
   * Safari on iPhone zooms the page in whenever a box smaller than 16px takes
   * focus, and does not zoom back out. Every box here was 15.5px, and the ones
   * in a table 13.5px - so tapping a quantity threw the storekeeper into a
   * magnified page they then had to pinch their way out of, on every line.
   * Nobody would report this as a bug; they would just stop using the phone.
   */
  input:not([type="checkbox"]):not([type="radio"]):not([type="submit"]):not([type="button"]):not([type="reset"]):not([type="file"]):not([type="image"]):not([type="range"]):not([type="color"]),
  select, textarea,
  tbody td input, tbody td select,
  /* `.small` is a 14px helper and beats a bare `select` on specificity, so the
     deliberately small boxes - a unit beside a quantity, the bulk-source
     picker - have to be named or they go on zooming the page. */
  input.small, select.small, textarea.small,
  .row.tight input { font-size: 16px; }

  /*
   * A "tight" row is told not to wrap, which is right on a filter bar with
   * room for it and wrong here: the two buttons at the head of the reports
   * index came to 13px more than the screen, and took the whole page sideways.
   * A row that cannot wrap has to fit, and on a phone it does not.
   */
  .row.tight { flex-wrap: wrap; }
  /*
   * And its children take the width they need rather than half the row each.
   * `flex: 1 1 90px` shares the row out evenly, which on a phone gave "See
   * what has been raised" 148px to say it in - and a button is told never to
   * wrap its label, so the words ran 40px past the edge and took the page with
   * them. Natural width, no squeezing, wrap when the row runs out.
   */
  .row.tight > * { flex: 0 0 auto; max-width: 100%; }

  /*
   * A LABEL MAY WRAP HERE, which it may not on a laptop. The rule exists so a
   * button is never a word broken across two lines mid-phrase; on a 375px
   * screen the alternative is worse - a button wider than the screen.
   */
  button, .btn { white-space: normal; }

  /* A tick box on a receiving line, big enough to hit with a thumb. */
  tbody td input[type="checkbox"], .check input[type="checkbox"] {
    width: 20px; height: 20px;
  }
}
