/*
  Britepods stock: the one stylesheet. Hand-written, no build step.
  Phone first: everything fits a narrow screen, and wider screens just get more margin.
*/

:root {
  --text: #1a1a1a;
  --muted: #5c5c5c;
  --background: #ffffff;
  --line: #d9d9d9;
  --brand: #0b5cad;
  --local-banner: #ffd400; /* yellow: Tom's Mac */
  --test-banner: #c40000; /* red: the test system */
  --danger: #b00020;
  --success-background: #e7f5ea;
  --warning-background: #fff4d6;
  --error-background: #fde8ea;
  --info-background: #e8f0fb;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 1rem;
  line-height: 1.5;
  color: var(--text);
  background: var(--background);
}

/* Which copy of the system this is (none on live). */
.env-banner {
  padding: 0.5rem 1rem;
  font-weight: 700;
  text-align: center;
  letter-spacing: 0.03em;
}

.env-banner-local {
  background: var(--local-banner);
  color: #000000;
}

.env-banner-test {
  background: var(--test-banner);
  color: #ffffff;
}

.site-header {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1rem;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--line);
}

.site-user {
  display: flex;
  gap: 0.75rem;
  align-items: center;
}

.site-name {
  color: var(--brand);
  font-weight: 700;
  text-decoration: none;
}

.page {
  max-width: 60rem;
  margin: 0 auto;
  padding: 1rem;
}

h1 {
  font-size: 1.5rem;
  margin: 0.5rem 0 1rem;
}

.muted {
  color: var(--muted);
}

.site-footer {
  padding: 1rem;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.875rem;
  text-align: center;
}

/* ------------------------------------------------------------------------
   Messages ("Signed in", "Re-sign-in with your code first" ...)
   ------------------------------------------------------------------------ */

.messages {
  list-style: none;
  margin: 0 0 1rem;
  padding: 0;
}

.message {
  margin: 0 0 0.5rem;
  padding: 0.75rem 1rem;
  border-radius: 0.375rem;
  background: var(--info-background);
}

.message-success {
  background: var(--success-background);
}

.message-warning {
  background: var(--warning-background);
}

.message-error {
  background: var(--error-background);
}

/* A list inside a message box (a reversal's blockers, step 1.9's fix pass): its bullets
   stay inside the box. */
.message ul {
  margin: 0;
  padding-left: 1.25rem;
}

.message li + li {
  margin-top: 0.375rem;
}

/* ------------------------------------------------------------------------
   Forms and buttons (also used by the sign-in and two-step pages)
   ------------------------------------------------------------------------ */

label {
  display: block;
  font-weight: 600;
  margin-bottom: 0.25rem;
}

input[type="text"],
input[type="password"],
input[type="email"],
input[type="number"],
select,
textarea {
  width: 100%;
  max-width: 28rem;
  padding: 0.6rem;
  font-size: 1rem;
  border: 1px solid var(--line);
  border-radius: 0.375rem;
}

button,
.button {
  display: inline-block;
  padding: 0.6rem 1.1rem;
  font-size: 1rem;
  font-weight: 600;
  color: #ffffff;
  background: var(--brand);
  border: 0;
  border-radius: 0.375rem;
  text-decoration: none;
  cursor: pointer;
}

.button-secondary {
  color: var(--brand);
  background: transparent;
  border: 1px solid var(--brand);
}

.button-danger {
  background: var(--danger);
}

.button-small {
  padding: 0.3rem 0.7rem;
  font-size: 0.875rem;
}

/* A button that looks like a link (the "Sign out" button in the header). */
.button-link {
  padding: 0;
  color: var(--brand);
  background: none;
  font-weight: 400;
  text-decoration: underline;
}

.inline-form {
  display: inline;
}

.stacked-form p {
  margin: 0 0 1rem;
}

.link-list li {
  margin-bottom: 0.5rem;
}

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

/* A wide table scrolls sideways inside its box on a phone, instead of widening the page. */
.table-scroll {
  overflow-x: auto;
}

.table th,
.table td {
  padding: 0.5rem;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

/* A short list of name-and-value pairs (the ASL and item quality screens). */
.detail-list {
  margin: 0 0 1rem;
}

.detail-list dt {
  margin-top: 0.5rem;
  font-weight: 600;
}

.detail-list dd {
  margin: 0;
}

/* ------------------------------------------------------------------------
   The factory station (design 6.1): big text and big buttons
   ------------------------------------------------------------------------ */

body.station {
  font-size: 1.25rem;
}

body.station h1 {
  font-size: 2rem;
}

.keyed-by-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: center;
  padding: 0.75rem 1rem;
  background: var(--info-background);
  border-bottom: 1px solid var(--line);
}

.big-choice {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(14rem, 1fr));
  gap: 0.75rem;
}

/* At the station every box is big too: the PC may have a touch screen (design 6.1). */
body.station input[type="text"],
body.station input[type="number"],
body.station select,
body.station textarea {
  padding: 0.75rem;
  font-size: 1.25rem;
}

.button-big {
  min-height: 4rem;
  padding: 1rem;
  font-size: 1.35rem;
  text-align: center;
}

.button-current {
  outline: 4px solid var(--local-banner);
}

/* A second, smaller line inside a big button ("and to mark applied: 2"). */
.button-note {
  display: block;
  font-size: 0.95rem;
  font-weight: 400;
}

/* Receiving (step 1.3 review): a line expired on arrival is marked in the check page's
   table, where the mistake is, not only in the warnings. */
.expired-tag {
  display: inline-block;
  margin-left: 0.4rem;
  padding: 0.1rem 0.4rem;
  color: #fff;
  background: var(--danger);
  font-size: 0.8rem;
  font-weight: 700;
}

/* The station home's area for the capture buttons (they arrive in Phase 1). */
.station-buttons {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(14rem, 1fr));
  gap: 0.75rem;
  margin: 1rem 0;
}

/* ------------------------------------------------------------------------
   Uploads (step 0.5): "Upload a scan" and "Recent uploads"
   ------------------------------------------------------------------------ */

/* The kind picker: one big tappable row per kind. */
.kind-choice {
  margin: 0 0 1rem;
  padding: 0.5rem 1rem;
  border: 1px solid var(--line);
  border-radius: 0.375rem;
}

.kind-choice legend {
  font-weight: 600;
}

.kind-option {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  padding: 0.35rem 0;
  font-weight: 400;
}

body.station .kind-option input[type="radio"],
body.station .kind-option input[type="checkbox"] {
  width: 1.4rem;
  height: 1.4rem;
}

input[type="file"] {
  display: block;
  max-width: 100%;
  padding: 0.5rem 0;
  font-size: 1rem;
}

/* At the station the file chooser is a big target, like the other buttons there. */
body.station input[type="file"] {
  width: 100%;
  padding: 1rem;
  font-size: 1.25rem;
  border: 2px dashed var(--line);
  border-radius: 0.375rem;
}

body.station input[type="file"]::file-selector-button {
  min-height: 3.5rem;
  margin-right: 1rem;
  padding: 0.75rem 1.25rem;
  font-size: 1.25rem;
}

.field-error {
  display: block;
}

/* A SHA-256 fingerprint: 64 characters, which may wrap on a phone. */
.fingerprint {
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 0.85rem;
  word-break: break-all;
}

/* On a phone, each row of these tables is shown as a small card (one line per column,
   its name in front, from each cell's data-label), instead of a wide scrolling table.
   Give a table the class cards-table (the uploads table was the first) to join in. */
@media (max-width: 40rem) {
  .uploads-table thead,
  .cards-table thead {
    display: none;
  }

  .uploads-table tr,
  .cards-table tr {
    display: block;
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--line);
  }

  .uploads-table td,
  .cards-table td {
    display: block;
    padding: 0.25rem 0;
    border-bottom: none;
  }

  .uploads-table td::before,
  .cards-table td::before {
    content: attr(data-label) ": ";
    font-weight: 600;
  }
}

/* ------------------------------------------------------------------------
   Printer tests (step 0.6): the A4 test page and the test label
   ------------------------------------------------------------------------ */

.print-section {
  margin: 0 0 2rem;
}

.reprint-fields {
  margin: 0 0 1rem;
  padding: 0.5rem 1rem;
  border: 1px solid var(--line);
  border-radius: 0.375rem;
}

.reprint-fields input[type="number"] {
  width: 5rem;
}

.print-form input[type="number"] {
  max-width: 6rem;
}

.print-form input[type="text"] {
  width: 100%;
  max-width: 30rem;
}

.print-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
}

/* What zebra.js says: looking for the printer, PRINTED, or why nothing was printed. */
.zebra-status {
  font-weight: 600;
}

/* The Backup log (step 0.7): an error of several lines keeps its line breaks. */
.preserve-lines {
  white-space: pre-line;
  overflow-wrap: anywhere;
}

/* ------------------------------------------------------------------------
   Stock on hand, near expiry and the lot history (step 1.6)
   ------------------------------------------------------------------------ */

/* The stock filters sit side by side on a wide screen, one under another on a phone. */
.filter-boxes {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(14rem, 1fr));
  gap: 0 1rem;
}

.filter-form {
  margin: 0 0 1rem;
}

.report-actions {
  margin: 0 0 1rem;
}

/* An "as at" figure below zero, and a stored file that no longer matches its SHA-256. */
.negative-tag,
.file-mismatch {
  color: var(--danger);
  font-weight: 700;
}

/* The report pages (stock on hand, near expiry, the lot history, the printed stock
   records) have wide tables: they use the whole width of the screen, at the station too
   (its big letters would otherwise push "Available" and "Value" off the right edge). */
.page.page-wide {
  max-width: none;
}

/* The filters fold away under "Filters" (open when one is set), so a phone shows the
   stock without scrolling past seven boxes first. */
.filter-form summary {
  cursor: pointer;
  font-weight: 600;
  margin: 0 0 0.5rem;
}

.filter-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin: 0.5rem 0 0;
}

/* The lot history's scan box sits above its facts: scan the next label straight away. */
.scan-form {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: end;
  margin: 0 0 1rem;
}

.scan-form label {
  display: block;
}

/* The lot history's timeline has many columns: smaller letters on a wide screen. */
.timeline {
  font-size: 0.875rem;
}

body.station .timeline {
  font-size: 1rem;
}

/* On a phone, a card shows only the timeline's columns that say something, and not the
   Lot column when it is the page's own lot. */
@media (max-width: 40rem) {
  .timeline td:empty,
  .timeline td.this-lot {
    display: none;
  }
}

/* ------------------------------------------------------------------------
   The count pages (step 1.7, the independent review's fix pass)
   ------------------------------------------------------------------------ */

/* A row's boxes on one line at the station (Full packs, Part, the tick, Save), so a
   row of the entry table is about one line high instead of four. */
.row-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}

.row-controls label {
  display: inline-flex;
  gap: 0.3rem;
  align-items: center;
}

body.station .row-controls input[type="text"] {
  width: 6.5rem;
  padding: 0.5rem;
}

/* The row the clerk just worked on, reached by its #row-n anchor. */
.count-row:target {
  outline: 3px solid var(--brand);
}

/* A folded section (the header once saved, a row's entries): the summary is the line. */
.fold summary {
  cursor: pointer;
  font-weight: 600;
  margin: 0 0 0.5rem;
}

/* An opening load's line warnings: a full-width row under the line (step 1.8 fix pass),
   never squeezed into a narrow last column. */
.line-warnings td {
  padding-top: 0;
  font-size: 0.9rem;
}

.line-warnings ul {
  margin: 0;
  padding-left: 1.2rem;
}

/* A SHA-256 is 64 letters with no break: it wraps anywhere, never widening a phone page. */
.hash {
  overflow-wrap: anywhere;
  word-break: break-all;
}

/* A row's entries, as keyed (who, when). */
.entry-trail {
  margin: 0.25rem 0 0;
  padding-left: 1.2rem;
  font-size: 0.9rem;
}

/* The decision page's rows that agree with the book: one compact list. */
.agree-list td,
.agree-list th {
  padding: 0.3rem 0.5rem;
}

/* ------------------------------------------------------------------------
   The exceptions screen (step 1.10): one block per group, one line per row
   ------------------------------------------------------------------------ */

.exception-group {
  margin: 0 0 2rem;
  padding-top: 0.5rem;
  border-top: 2px solid var(--line);
}

.exception-check h3 {
  margin: 1rem 0 0.25rem;
  font-size: 1.05rem;
}

.exception-rows {
  margin: 0;
  padding: 0;
  list-style: none;
}

.exception-rows li {
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--line);
}

.exception-age,
.exception-who {
  color: var(--muted);
  margin-left: 0.25rem;
}

.exception-rows .button {
  margin-left: 0.5rem;
}

/* On a phone each part of a row takes its own line. */
@media (max-width: 40rem) {
  .exception-text,
  .exception-age,
  .exception-who {
    display: block;
    margin-left: 0;
  }

  .exception-rows .button {
    margin: 0.25rem 0 0;
  }
}
