/* The only static file this site serves.

   Deliberately one file: no framework, no web font, no background image. style-src 'self'
   in the Content-Security-Policy exists for this file and nothing else, img-src is data:
   only, and there is no script-src at all - so there is no URL in here that could fetch
   anything and nothing on any page that could run.

   NOTHING MAY MOVE TO A style= ATTRIBUTE. style-src 'self' blocks inline styles and inline
   <style> blocks, which is the point: an injected attribute cannot restyle the page into a
   convincing login box. Every rule a page needs lives here.

   The board is read on a phone at the dock and on a desktop in the office. Tables scroll
   sideways rather than reflowing into cards, because a column of net weights the owner can
   run his eye down is the whole point of the page. */

:root {
    --ink: #1d1b16;
    --paper: #f6f4ef;
    --card: #ffffff;
    --rule: #e2ded3;
    --rule-firm: #cdc7b8;
    --quiet: #6e6859;
    --brand: #4a3c1f;      /* the darker of the two tones in the plant's own emblem */
    --brand-ink: #f6f4ef;
    --accent: #8a6d2f;
    --organic: #1f7a34;
    --wrong: #9a2520;
    --live: #1f7a34;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    font-size: 15px;
    line-height: 1.45;
    color: var(--ink);
    background: var(--paper);
}

/* ---- the bar across the top ------------------------------------------------ */

header {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.75rem 1.25rem;
    padding: 0.55rem 1.1rem;
    background: var(--brand);
    color: var(--brand-ink);
    border-bottom: 3px solid var(--accent);
}

.brand { text-decoration: none; letter-spacing: -0.015em; white-space: nowrap; }
.brand-mark { font-size: 1.22rem; font-weight: 700; color: var(--brand-ink); }
.brand-rest { font-size: 1.22rem; font-weight: 300; color: #d8c89a; margin-left: 0.22rem; }

header nav { display: flex; flex-wrap: wrap; gap: 0.2rem; align-items: center; }
header nav a {
    color: #e8e2d2;
    text-decoration: none;
    padding: 0.3rem 0.62rem;
    border-radius: 4px;
    font-size: 0.93rem;
}
header nav a:hover { background: rgba(255, 255, 255, 0.13); color: #fff; }

.who { margin-left: auto; display: flex; align-items: center; gap: 0.6rem; }
.who a { color: #cfc4a6; text-decoration: none; font-size: 0.86rem; }
.who a:hover { color: #fff; text-decoration: underline; }

button.ghost {
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.4);
    color: var(--brand-ink);
    padding: 0.25rem 0.6rem;
    font-size: 0.86rem;
}
button.ghost:hover { background: rgba(255, 255, 255, 0.13); }

main { padding: 1.1rem; max-width: 1500px; }
main.plain { max-width: 24rem; margin: 3rem auto; padding: 1rem; }

/* Sign in, the second factor and enrolment. Layout = null on all three - they carry no
   navigation and nothing that depends on a session - so the wordmark is repeated here
   rather than inherited, and it is the only thing on the page above the form. */
.card {
    background: var(--card);
    border: 1px solid var(--rule);
    border-radius: 9px;
    padding: 1.4rem 1.5rem 1.6rem;
}
.signin-brand { margin: 0 0 1.2rem; text-align: center; }
.signin-brand .brand-mark { color: var(--brand); }
.signin-brand .brand-rest { color: var(--accent); }
main.plain label:first-of-type { margin-top: 0; }
main.plain input { max-width: none; }
main.plain button { width: 100%; padding: 0.55rem; font-size: 1rem; }
main.plain .notice, main.plain .problem { border: 1px solid var(--rule); }

.page-head { margin-bottom: 1rem; }
h1 { font-size: 1.35rem; margin: 0 0 0.25rem; letter-spacing: -0.01em; }
h2 {
    font-size: 0.82rem;
    text-transform: uppercase;
    letter-spacing: 0.09em;
    color: var(--quiet);
    margin: 2rem 0 0.6rem;
}
.page-head p { margin: 0; font-size: 0.88rem; }

/* ---- the four numbers at the top of the board ------------------------------ */

.stats {
    list-style: none;
    display: flex;
    flex-wrap: wrap;
    gap: 0.7rem;
    margin: 0 0 1.3rem;
    padding: 0;
}
.stats li {
    background: var(--card);
    border: 1px solid var(--rule);
    border-radius: 7px;
    padding: 0.6rem 1.1rem;
    min-width: 7.5rem;
}
.stat-n {
    display: block;
    font-size: 1.65rem;
    font-weight: 600;
    line-height: 1.1;
    font-variant-numeric: tabular-nums;
}
.stat-of { font-size: 1rem; font-weight: 400; color: var(--quiet); }
.stat-l {
    display: block;
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    color: var(--quiet);
}

/* ---- one card per order ---------------------------------------------------- */

.order {
    background: var(--card);
    border: 1px solid var(--rule);
    border-radius: 8px;
    margin-bottom: 1.1rem;
    overflow: hidden;
}
.order.empty { padding: 1.2rem; }
.order.empty p { margin: 0 0 0.4rem; }

.order-head {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem 2.2rem;
    padding: 0.7rem 1rem;
    background: #faf8f3;
    border-bottom: 1px solid var(--rule);
}
.order-head .label {
    display: block;
    font-size: 0.68rem;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    color: var(--quiet);
}
.order-head strong { font-size: 1.02rem; font-weight: 600; }
.order-no { font-size: 1.02rem; font-weight: 600; }
.order-at .quiet { font-size: 0.83rem; margin-left: 0.35rem; }
.order-count { margin-left: auto; text-align: right; }

/* ---- tables ---------------------------------------------------------------- */

.scroller { overflow-x: auto; margin-bottom: 1.4rem; }

/* Inside an order card the table is already bounded by the card, so it carries no margin of
   its own - but it still has to scroll. Rendered on a 390px phone without this, the item
   description wrapped to five lines and pushed Count, Gross and NET off the right edge with
   no way to reach them. The net weight is the number the whole page exists to show. */
.scroller.flush { margin-bottom: 0; }
.pallets { min-width: 44rem; }
.pallets td:first-child, .pallets td:nth-child(2) { white-space: nowrap; }

table { border-collapse: collapse; width: 100%; }
.scroller table { margin: 0; }

th, td {
    text-align: left;
    padding: 0.42rem 0.75rem;
    border-bottom: 1px solid var(--rule);
}
th {
    font-weight: 600;
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--quiet);
    background: #faf8f3;
    border-bottom: 1px solid var(--rule-firm);
    white-space: nowrap;
}
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: #fcfbf7; }

/* Every table outside an order card gets the card treatment, so Stations, Alerts, Audit,
   Admins, Backups and Ticket need no styling of their own - they are wrapped in .scroller
   and inherit this. The exception is .flush, which is already inside a card. */
.scroller > table {
    background: var(--card);
    border: 1px solid var(--rule);
    border-radius: 8px;
    overflow: hidden;
}
.scroller.flush > table { border: none; border-radius: 0; }

td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
td.quiet, .quiet { color: var(--quiet); }
td.heavy { font-weight: 600; }
td.row-open { text-align: right; }
td.row-open a { color: var(--accent); font-size: 0.85rem; }
td.stale { color: var(--wrong); }

/* The plant-local timestamp, the ticket number and every weight, in a monospaced face. They
   are shown exactly as the station wrote them - never reformatted, never converted - and a
   fixed-width face is what makes a column of them readable and a reformatting mistake
   visible at a glance. */
td.asgiven, .asgiven {
    font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
    font-size: 0.9em;
}

tr.voided td { color: var(--quiet); }
tr.voided td.asgiven, tr.voided td.heavy { text-decoration: line-through; }

.badge {
    display: inline-block;
    font-size: 0.66rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    padding: 0.08rem 0.36rem;
    border-radius: 3px;
    background: #eceade;
    color: var(--quiet);
    vertical-align: 0.08em;
    margin-left: 0.3rem;
}
.badge.organic { background: #e3f1e4; color: var(--organic); }
.badge.void { background: #f6e3e1; color: var(--wrong); }

/* Whether the station has said it finished this order, beside the order number. Green is
   already "organic" on a pallet row and these never share a line with one, so the colour
   reads as "done" here and as "organic" there without either becoming ambiguous. OPEN is
   deliberately the quiet default: most orders on the board are open, and a board where
   every heading shouts says nothing. */
.badge.complete { background: #e3f1e4; color: var(--organic); }
.badge.open { background: #f1ece0; color: var(--accent); }

/* Paging. Links only - this page has no script-src at all. */
.paging {
    display: flex;
    gap: 1rem;
    align-items: baseline;
    justify-content: space-between;
    flex-wrap: wrap;
    margin: 0.4rem 0 1rem 0;
    padding: 0.5rem 0.75rem;
    background: var(--card);
    border: 1px solid var(--rule);
    border-radius: 4px;
}

/* The muted state of a scale's weight-fault emails, on the Stations page. Red, because the
   question it answers is "why did nobody get told". */
.muted-alerts { color: var(--wrong); }

.dot {
    display: inline-block;
    width: 0.52rem;
    height: 0.52rem;
    border-radius: 50%;
    margin-right: 0.45rem;
}
.dot-live { background: var(--live); }
.dot-quiet { background: #c9c3b4; }

/* ---- forms ----------------------------------------------------------------- */

.filter {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    margin: 0 0 1.2rem;
    flex-wrap: wrap;
}
.filter label {
    margin: 0;
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--quiet);
}
.filter select { width: auto; min-width: 14rem; }

/* THE REPORT FORM IS A GRID AND THE BOARD'S FILTER IS A ROW, because this one has eleven
   controls on it. Wrapped as a flex row they interleave - a label at the end of one line
   and its select at the start of the next - and nobody here can see the rendered page to
   notice. A grid of fixed columns puts every label above its own control at any width.

   Each grid cell is a .field holding one label and its control, so a narrow window drops
   whole controls onto the next row instead of splitting a label away from the box it
   names. */
.filter.report {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(11rem, 1fr));
    gap: 0.35rem 0.9rem;
    align-items: end;
}
.filter.report .field { display: flex; flex-direction: column; gap: 0.2rem; min-width: 0; }
.filter.report label { margin: 0; }
.filter.report select,
.filter.report input { width: 100%; min-width: 0; margin: 0; }
.filter.report .run { grid-column: 1 / -1; justify-self: start; }

/* A REPORT'S PALLET TABLE IS WIDER THAN THE BOARD'S and holds the same kind of row, so it
   scrolls as one block rather than squeezing. Without the nowrap, "Kennett Square 1" and
   every grower name wrapped onto three lines at tablet width and a fourteen-pallet listing
   ran to three screens of mostly white space. The short columns are the ones that must not
   wrap; a grower or an item name is long enough that wrapping it is the right answer. */
.report-pallets { min-width: 58rem; }
.report-pallets th:nth-child(-n+4),
.report-pallets td:nth-child(-n+4) { white-space: nowrap; }

form.inline { display: inline; }

fieldset {
    border: 1px solid var(--rule);
    border-radius: 8px;
    background: var(--card);
    margin: 0 0 1.2rem;
    padding: 0.8rem 1rem 1rem;
}
legend { font-weight: 600; padding: 0 0.35rem; }

label { display: block; margin: 0.7rem 0 0.2rem; font-weight: 600; }
input[type=text], input[type=email], input[type=password], select, textarea {
    font: inherit;
    padding: 0.44rem 0.55rem;
    border: 1px solid var(--rule-firm);
    border-radius: 5px;
    background: #fff;
    width: 100%;
    max-width: 28rem;
}
input:focus, select:focus, textarea:focus, button:focus {
    outline: 2px solid var(--accent);
    outline-offset: 1px;
}

button {
    font: inherit;
    padding: 0.42rem 0.95rem;
    border: 1px solid var(--brand);
    border-radius: 5px;
    background: var(--brand);
    color: var(--brand-ink);
    cursor: pointer;
}
button:hover { background: #5d4c28; }

/* A word inside a table cell, not a banner across the page. .problem is the banner; this
   is the same meaning at the size of a cell, and the two were being used interchangeably -
   which put a full-width bordered block inside one column of the alerts table. */
.warn {
    display: inline-block;
    font-size: 0.8rem;
    color: var(--wrong);
    background: #f8ebe9;
    border-radius: 4px;
    padding: 0.08rem 0.4rem;
}

/* The sentence under a page heading. Every page opens with one and they were running the
   full width of a 1500px screen, which is about 180 characters - roughly three times what
   anybody reads comfortably. */
h1 + p, .page-head p { max-width: 68ch; }

/* A second rank of button, for the ones that sit in a table row rather than at the end of a
   form: Acknowledge, Reveal, Test. Full-weight brown buttons down a column of rows read as
   the most important thing on the page, which they are not. */
button.small, .scroller button {
    font-size: 0.82rem;
    padding: 0.2rem 0.55rem;
    background: var(--card);
    color: var(--ink);
    border-color: var(--rule-firm);
}
button.small:hover, .scroller button:hover { background: #f1eee6; border-color: var(--quiet); }

/* Revoking a key or deleting a backup is not undoable, and should not look like Save. */
button.danger, .scroller button.danger {
    color: var(--wrong);
    border-color: #d8b6b2;
    background: var(--card);
}
button.danger:hover, .scroller button.danger:hover { background: #f8ebe9; }

/* The ticket page: a column of label/value pairs rather than a table of two columns. */
.facts { display: grid; grid-template-columns: max-content 1fr; gap: 0.3rem 1.2rem; margin: 0 0 1.2rem; }
.facts dt { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--quiet); align-self: center; }
.facts dd { margin: 0; }

.notice, .problem {
    border-radius: 6px;
    padding: 0.6rem 0.85rem;
    background: var(--card);
    margin: 0 0 1rem;
}
.notice { border-left: 4px solid var(--organic); }
.problem { border-left: 4px solid var(--wrong); }

/* The key, shown once. Big, monospaced and selectable, because it is being copied into a box
   on a weigh station by somebody reading it off this screen - and there is no second chance:
   the site stores only its hash. */
.secret {
    font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
    font-size: 1.1rem;
    word-break: break-all;
    background: #fff;
    border: 2px solid var(--wrong);
    border-radius: 6px;
    padding: 0.8rem;
    user-select: all;
}

.codes { columns: 2; font-family: ui-monospace, Menlo, Consolas, monospace; }
.qr { border: 1px solid var(--rule); border-radius: 6px; background: #fff; padding: 0.5rem; }

/* ---- the phone at the dock -------------------------------------------------- */

@media (max-width: 640px) {
    main { padding: 0.7rem; }
    .order-head { gap: 0.55rem 1.2rem; }
    .order-count { margin-left: 0; text-align: left; }
    .stats li { flex: 1 1 8rem; min-width: 0; padding: 0.5rem 0.75rem; }
    .stat-n { font-size: 1.35rem; }
    .who { margin-left: 0; }
    th, td { padding: 0.4rem 0.55rem; }
}

/* ---- demo mode ------------------------------------------------------------- */

/* THE POINT OF THIS BLOCK IS THAT IT CANNOT BE MISSED.

   The owner wants to show the system to people without touching real data. The failure that
   would matter is not an ugly banner, it is somebody being unsure which mode they are in -
   showing a customer real weights believing they are invented, or reading a demo total as a
   real one and ordering against it. Somebody who walked away from the screen and came back
   has to be told without looking for anything.

   So three things change at once and they are not subtle: a strip across the top of every
   page, a coloured frame around the whole viewport, and the header bar - which is the one
   element on every screen - changes colour. One of them being missed by a theme, a print
   stylesheet or a narrow phone still leaves the other two.

   It is amber and not red. Red is var(--wrong) and already means "this has gone wrong" on
   the alerts and the voided rows; demo mode is not a fault, and a page of red would train
   the eye to ignore the colour that means a scale has stopped. */

.demo-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.4rem 0.8rem;
    padding: 0.5rem 1.1rem;
    background: #8a4b00;
    color: #fff5e6;
    font-size: 0.92rem;
    border-bottom: 3px solid #ffb64d;

    /* Diagonal hazard stripes, in a gradient rather than an image: img-src is data: only and
       background-image: url(...) would need a second source in the policy. */
    background-image: repeating-linear-gradient(
        135deg,
        rgba(255, 255, 255, 0.00) 0,
        rgba(255, 255, 255, 0.00) 14px,
        rgba(255, 255, 255, 0.07) 14px,
        rgba(255, 255, 255, 0.07) 28px);
}

.demo-tag {
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    font-size: 0.78rem;
    background: #ffb64d;
    color: #3a2000;
    padding: 0.12rem 0.5rem;
    border-radius: 3px;
    white-space: nowrap;
}

.demo-words { flex: 1 1 18rem; }

.demo-exit {
    color: #ffe3b3;
    text-decoration: underline;
    white-space: nowrap;
    margin-left: auto;
}
.demo-exit:hover { color: #fff; }

/* The frame. An inset box-shadow rather than a border on <body>, so it does not move the
   layout by 6px and does not scroll away with the content. */
body.demomode {
    box-shadow: inset 0 0 0 6px #ffb64d;
    min-height: 100vh;
}

/* The header, which is on every page including the ones with nothing else on them. */
body.demomode header {
    background: #5e3200;
    border-bottom-color: #ffb64d;
}

/* Said again where the numbers are. A table of demo weights read in a screenshot, with the
   banner cropped off, is the one way the banner can fail - so the board's own headings carry
   the colour too. */
body.demomode th { background: #fdf3e3; color: #6b4310; }

/* The strip that says demo mode was asked for and could not be entered. Grey, not amber:
   the data below it is real, and the amber means the opposite. */
.demo-bar.demo-broken {
    background: #3a3730;
    background-image: none;
    border-bottom-color: var(--rule-firm);
    color: #f2eee4;
}
.demo-bar.demo-broken .demo-tag { background: #d8cfbb; color: #2a2720; }

@media (max-width: 640px) {
    .demo-bar { padding: 0.45rem 0.7rem; font-size: 0.85rem; }
    .demo-exit { margin-left: 0; }
    body.demomode { box-shadow: inset 0 0 0 4px #ffb64d; }
}
