:root {
  --mono: ui-monospace, SFMono-Regular, Menlo, monospace;
  --ink: #14231c;
  --muted: #67756d;
  --paper: #f6f8f4;
  --surface: #ffffff;
  --line: #dde3da;
  --line-soft: #eef1ec;
  --green: #1f7a4d;
  --green-dark: #17603c;
  --green-wash: #e9f4ee;
  --amber: #a35a09;
  --amber-wash: #fdf3e0;
  --red: #a72b1f;
  --red-wash: #fbeceb;
  --radius: 8px;
  --shadow: 0 1px 2px rgba(20, 35, 28, .06), 0 4px 14px rgba(20, 35, 28, .05);
}

* { box-sizing: border-box; }

::selection { background: #b9e2c8; color: var(--ink); }
::-moz-selection { background: #b9e2c8; color: var(--ink); }

/* A number already in a cell is highlighted the moment the cell is clicked, so
   typing replaces it instead of appending to it. */
.rep-table input.cell::selection { background: #b9e2c8; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--green-dark); }

/* Top bar and navigation */
.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 30;
}
.topbar-inner {
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 20px;
  display: flex;
  align-items: center;
  gap: 24px;
  min-height: 58px;
  flex-wrap: wrap;
}
.brand {
  font-weight: 700;
  font-size: 19px;
  letter-spacing: -.2px;
  color: var(--ink);
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 9px;
}
.brand-dot {
  width: 11px; height: 11px; border-radius: 50%;
  background: var(--green);
}
nav.tabs { display: flex; gap: 4px; flex: 1; flex-wrap: wrap; }
nav.tabs a {
  padding: 8px 13px;
  border-radius: var(--radius);
  text-decoration: none;
  color: var(--muted);
  font-weight: 550;
  font-size: 14.5px;
}
nav.tabs a:hover { background: var(--line-soft); color: var(--ink); }
nav.tabs a.on { background: var(--green-wash); color: var(--green-dark); }
.whoami { color: var(--muted); font-size: 13.5px; display: flex; align-items: center; gap: 12px; }

.mode-flag {
  font-size: 12px;
  font-weight: 600;
  padding: 3px 9px;
  border-radius: 100px;
  background: var(--amber-wash);
  color: var(--amber);
  border: 1px solid #f0dcb8;
}

/* Page frame */
main { max-width: 1400px; margin: 0 auto; padding: 22px 20px 120px; }
.page-head {
  display: flex; align-items: flex-end; justify-content: space-between;
  gap: 18px; flex-wrap: wrap; margin-bottom: 16px;
}
h1 { font-size: 24px; margin: 0 0 3px; letter-spacing: -.3px; }
h2 { font-size: 17px; margin: 0 0 12px; }
.sub { color: var(--muted); font-size: 14px; margin: 0; }

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.card + .card { margin-top: 18px; }
.card-head {
  padding: 14px 16px;
  border-bottom: 1px solid var(--line-soft);
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  flex-wrap: wrap;
}
.card-body { padding: 16px; }

/* Controls */
.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
input[type=text], input[type=email], input[type=password], input[type=number], select, textarea {
  font: inherit;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 8px 10px;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(31, 122, 77, .15);
}
.search { min-width: 240px; }
label.field { display: block; margin-bottom: 13px; }
label.field span { display: block; font-size: 13px; color: var(--muted); margin-bottom: 5px; font-weight: 550; }
label.field input, label.field select, label.field textarea { width: 100%; }
.check { display: flex; align-items: center; gap: 8px; font-size: 14.5px; }

.btn {
  font: inherit; font-weight: 600;
  padding: 9px 15px;
  border-radius: 7px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
  text-decoration: none;
  display: inline-flex; align-items: center; gap: 7px;
}
.btn:hover { background: var(--line-soft); }
.btn-primary { background: var(--green); border-color: var(--green); color: #fff; }
.btn-primary:hover { background: var(--green-dark); }
.btn-quiet { border-color: transparent; color: var(--muted); }
.btn-quiet:hover { color: var(--ink); }
.btn-danger { color: var(--red); }

/* Open and Remove in the one cell at the end of a row. A form is a block, so
   without this the second one drops onto a line of its own. */
.row-actions { white-space: nowrap; }
.row-actions form { display: inline-block; margin-left: 6px; }
/* A column of dates reads as a column when the digits line up. */
.date-cell { font-variant-numeric: tabular-nums; white-space: nowrap; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-sm { padding: 5px 10px; font-size: 13px; }

/* Tables */
table { width: 100%; border-collapse: separate; border-spacing: 0; }
.table-wrap { overflow-x: visible; }
th {
  text-align: left;
  position: sticky;
  top: 58px;
  z-index: 10;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--muted);
  font-weight: 650;
  padding: 10px 10px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
  white-space: nowrap;
}
td { padding: 7px 10px; border-bottom: 1px solid var(--line-soft); vertical-align: middle; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: #fbfcfa; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
/* On the replenishment sheet the heading sits over the middle of the number,
   because the numbers themselves are centred in the cell. Everywhere else a
   heading sits over the end of the number, where the digits line up: Justin,
   2026-11-14, on the Quantity column of a purchase order. */
th.ctr { text-align: center; }
.rep-table th.num { text-align: center; }

/* The replenishment grid */
.rep-table td.name { min-width: 190px; }
.rep-table .prod { font-weight: 600; }
.rep-table .unit { color: var(--muted); font-size: 12.5px; font-weight: 500; }
/* The unit he orders in, marked so the right line of a pair is obvious at a
   glance. Half his items carry a second unit he only counts in. The mark sits
   on the unit itself, because the unit is the whole difference between the two
   lines, and it stays clear of the row colours, which already mean needs
   ordering and chosen. */
.uom-order {
  background: #ffd84d;
  color: #3d3000;
  font-weight: 700;
  padding: 1px 5px;
  border-radius: 3px;
}
/* Flowers are their own section of his sheet and he wants them told apart. */
.uom-flower { background: #e8524a; color: #fff; }
/* A number field is the whole cell. Anywhere in the cell is the field, so a
   thumb on a tablet cannot land in the gap beside it, and the sheet behaves
   like the spreadsheet he already counts into. A number reads as part of the
   table until it is touched: 135 rows of bordered boxes is a grid of
   outlines and nothing else. */
.rep-table th.num { width: 86px; }
.rep-table th.min-col, .rep-table th.max-col { width: 72px; }
.rep-table td.num { padding: 0; }
.rep-table input.cell {
  display: block;
  width: 100%;
  min-height: 38px;
  text-align: center;
  font-variant-numeric: tabular-nums;
  padding: 7px 8px;
  background: transparent;
  border-color: transparent;
  border-radius: 0;
}
/* No spinner arrows. Now that the field is the whole cell, the arrows sit at
   the right-hand edge of it, and a thumb landing there on the tablet would
   change a count without him seeing it. */
.rep-table input.cell { -moz-appearance: textfield; appearance: textfield; }
.rep-table input.cell::-webkit-outer-spin-button,
.rep-table input.cell::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.rep-table input.cell:hover { background: #eef5f0; border-color: #dbe6de; }
.rep-table input.cell:focus {
  background: #fff;
  border-color: var(--green);
  /* Inset, because an outer ring on a full-width cell would sit over the
     cells either side of it. */
  box-shadow: inset 0 0 0 2px rgba(31, 122, 77, .3);
}
.rep-table input.cell::placeholder { color: #9aa8a0; }
.rep-table select.sup {
  background: transparent;
  border-color: transparent;
}
.rep-table select.sup:hover { background: #eef5f0; border-color: #dbe6de; }
.rep-table select.sup:focus { background: #fff; border-color: var(--green); }
/* The row being typed into lifts, so his place is never lost. */
.rep-table tr:focus-within { background: #eef6f1; }
.rep-table tr:focus-within td { border-bottom-color: #cfe2d6; }
.cell-derived.negative { color: var(--red); }
/* The vendor box fills its cell too, so the column has one edge rather than
   one per vendor name. The column is held to a width: left to itself it eats
   the space the product names need. */
.rep-table th.ctr { width: 285px; }
.rep-table td.vendor-cell { padding: 2px 10px; }
.rep-table select.sup { width: 100%; min-width: 0; padding: 7px 8px; }
.cell-derived {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  padding: 7px 8px;
  display: block;
  width: 100%;
  min-height: 38px;
  text-align: center;
  /* Worked out, not typed. A wash over whatever colour the row is carrying,
     so it reads as locked on a white, an amber and a green row alike. */
  background: rgba(20, 35, 28, .045);
}
/* Already on today's order. Quiet rather than loud: it is finished, not a
   thing to act on, and it must not read as "to order" any more. */
tr.ordered td { background: var(--green-wash); }
tr.ordered .name a.prod { color: var(--muted); }
tr.needs { background: var(--amber-wash); }
tr.needs:hover { background: #fbeed6; }
tr.needs .suggest { color: var(--amber); }
tr.chosen { background: var(--green-wash) !important; }
.col-div { border-left: 1px solid var(--line); }

/* Action bar */
.actionbar {
  position: fixed; left: 0; right: 0; bottom: 0;
  background: var(--surface);
  border-top: 1px solid var(--line);
  box-shadow: 0 -2px 14px rgba(20, 35, 28, .07);
  padding: 12px 20px;
  z-index: 40;
}
.actionbar-inner {
  max-width: 1400px; margin: 0 auto;
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
}
.count-pill {
  font-weight: 650;
  background: var(--green-wash); color: var(--green-dark);
  padding: 7px 13px; border-radius: 100px; font-size: 14px;
}
.spacer { flex: 1; }
.saving { font-size: 13px; color: var(--muted); min-width: 90px; }

/* Status chips */
.chip {
  display: inline-block; padding: 3px 10px; border-radius: 100px;
  font-size: 12.5px; font-weight: 600; white-space: nowrap;
}
.chip-not_sent { background: var(--line-soft); color: var(--muted); }
.chip-sent { background: var(--green-wash); color: var(--green-dark); }
.chip-reply_received { background: #e7eefb; color: #1d4ed8; }
.chip-sim { background: var(--amber-wash); color: var(--amber); }

/* SMS preview */
.sms {
  background: #f2f5f0;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 13px 15px;
  white-space: pre-wrap;
  font: 14.5px/1.55 var(--mono);
  max-width: 460px;
}
.sms-in { background: #e7eefb; border-color: #cddbf6; }
textarea.sms-edit {
  width: 100%; max-width: 460px; min-height: 220px;
  font: 14.5px/1.55 var(--mono);
}
.to-line { font-size: 13.5px; color: var(--muted); margin: 0 0 8px; }

.notice {
  padding: 11px 14px; border-radius: var(--radius);
  border: 1px solid var(--line); background: var(--surface);
  margin-bottom: 16px; font-size: 14.5px;
}
.notice-ok { background: var(--green-wash); border-color: #bfdfcd; color: var(--green-dark); }
.notice-warn { background: var(--amber-wash); border-color: #f0dcb8; color: var(--amber); }
.notice-bad { background: var(--red-wash); border-color: #f0c8c4; color: var(--red); }

.empty { padding: 40px 20px; text-align: center; color: var(--muted); }
.muted { color: var(--muted); }
.right { text-align: right; }
.stack { display: grid; gap: 16px; }
/* align-items: start, or a card with one line in it is stretched to the
   height of the card beside it and reads as an empty box. */
.two-col { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
           gap: 18px; align-items: start; }
.two-col > .span-all { grid-column: 1 / -1; }

/* One sales rep is one line: who to ask for, their number, whether the order
   goes there, and the way to take them off. */
.rep-line {
  display: flex; gap: 10px; align-items: center; flex-wrap: wrap;
  padding: 9px 0; border-bottom: 1px solid var(--line-soft);
}
.rep-line:last-child { border-bottom: none; }
.rep-fields { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; flex: 1; }
.rep-line input[type=text] { padding: 7px 10px; width: 190px; }
.rep-add { padding-top: 14px; }
.pill-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* Login */
.login-wrap { max-width: 380px; margin: 9vh auto; padding: 0 20px; }
.login-brand { text-align: center; margin-bottom: 22px; }
.login-brand .brand { justify-content: center; font-size: 26px; }
.login-brand p { color: var(--muted); margin: 7px 0 0; font-size: 14px; }

@media (max-width: 1150px) {
  th { position: static; }
  .table-wrap { overflow-x: auto; }
}

@media (max-width: 820px) {
  .two-col { grid-template-columns: 1fr; }
  th { position: static; }
  .table-wrap { overflow-x: auto; }
  main { padding: 16px 12px 130px; }
  .topbar-inner { padding: 8px 14px; gap: 10px; }
  .brand { order: 1; }
  .whoami { order: 2; margin-left: auto; }
  nav.tabs {
    order: 3; flex: 1 0 100%; flex-wrap: nowrap;
    overflow-x: auto; padding-bottom: 4px;
  }
  nav.tabs a { white-space: nowrap; }
  .actionbar-inner { gap: 10px; }
  .actionbar .btn { flex: 1; justify-content: center; }
}

/* The date on the sheet */
.date-field { display: flex; align-items: center; gap: 8px; }
.date-field span { font-size: 13px; color: var(--muted); font-weight: 550; }
.date-field input { padding: 7px 9px; }
.print-date { font-weight: 600; color: var(--ink); }
.print-only { display: none; }

/* The written order. Hidden on screen, and the only thing that prints. */
.order-sheet { display: none; }
.sheet-date { text-align: center; letter-spacing: .02em; }
.sheet-group h3 {
  font-size: 11pt; margin: 0 0 2mm;
  text-transform: uppercase; text-decoration: underline;
}
.sheet-group p { margin: 0 0 0.6mm; }

/* Grip, link and remove, all inside the product cell */
.grip {
  display: inline-block; width: 12px; cursor: grab;
  color: #b7c2bb; letter-spacing: -2px; margin-right: 4px; user-select: none;
}
.grip:active { cursor: grabbing; }
tr.dragging { opacity: .45; }
tr.drop-target td { box-shadow: inset 0 2px 0 var(--green); }
a.prod { color: var(--ink); text-decoration: none; font-weight: 600; }
a.prod:hover { color: var(--green-dark); text-decoration: underline; }
/* Always visible, because a hover-only control does not exist on the tablet
   he uses in the coolroom. Quiet enough not to invite a stray tap. */
button.row-del {
  display: inline-block;
  border: none; background: none; cursor: pointer; color: #d4ddd7;
  font-size: 15px; line-height: 1; padding: 0 3px; margin-left: 3px;
  vertical-align: baseline;
}
tr:hover button.row-del { color: #a6b2ab; }
button.row-del:hover { color: var(--red); }

.add-row {
  display: flex; gap: 8px; align-items: center;
  margin-top: 12px; padding: 0 2px; flex-wrap: wrap;
}
.add-row input[type=text] { padding: 8px 10px; }
.add-row input[name=name] { min-width: 240px; }

/* Printing. Rossi walks the coolroom with this on paper, so the sheet has to
   fit, carry the date, and lose everything he cannot press on paper. */
@media print {
  /* ⚠ THE BROWSER PRINTS ITS OWN HEADER AND FOOTER INTO THE TOP AND BOTTOM
     MARGINS: the date and the page title above, the address and the page
     number below. With no margin there is nowhere to put them and they go.
     Justin, 2026-11-16, who did not want either on a sheet going to a market
     house. The side margins stay, so every page keeps its left and right
     edge, and the body puts the top and bottom space back on the sheet
     itself. */
  @page { size: A4 portrait; margin: 0 10mm; }
  body { background: #fff; font-size: 10pt; padding: 10mm 0; }
  .topbar, .actionbar, .no-print, .toolbar, .notice, form.toolbar,
  .page-head, .card, #rep-form { display: none !important; }

  /* Two columns on A4, and a vendor never splits across them. */
  .order-sheet { display: block; }
  .sheet-date { font-size: 13pt; margin: 0 0 6mm; }
  .sheet-cols { columns: 3; column-gap: 8mm; }
  .sheet-group { break-inside: avoid; page-break-inside: avoid; margin: 0 0 6mm; }
  .sheet-group p { font-size: 9pt; line-height: 1.3; }
  .sheet-group h3 { font-size: 9.5pt; }
  main { max-width: none; padding: 0; }
  .page-head { margin-bottom: 6px; display: block; }
  h1 { font-size: 15pt; margin: 0; }
  .print-date { font-size: 11pt; margin: 2px 0 8px; }
  .card { border: none; box-shadow: none; }
  .table-wrap { overflow: visible; }
  table { font-size: 9pt; }
  th { position: static; padding: 4px 5px; font-size: 7.5pt; border-bottom: 1px solid #000; }
  td { padding: 2px 5px; border-bottom: 1px solid #ddd; }
  tr.needs, tr.chosen { background: #fff !important; }
  .rep-table input.cell, .rep-table input.cell.wide, .rep-table input.cell.narrow {
    width: 46px; border: none; background: transparent; padding: 0; text-align: right;
  }
  /* The header repeats at the top of every printed page. A 135 line sheet
     runs to three or four pages, and a column of numbers with no heading on
     page two is unreadable. */
  thead { display: table-header-group; }
  /* Min and Max are reference figures he sets at a desk. On paper the space
     goes to the boxes he writes counts into. */
  .rep-table td[data-label="Min"], .rep-table td[data-label="Max"],
  .rep-table th:nth-child(6), .rep-table th:nth-child(7) { display: none; }
  .rep-table select.sup { display: none; }
  .print-only { display: inline; }
  .unit { font-size: 7.5pt; }
  tbody tr { page-break-inside: avoid; }
}

/* Tablet. Min and Max are set once and then left alone, so they make way for
   the columns he touches every morning. */
@media (max-width: 1150px) {
  .rep-table td[data-label="Min"], .rep-table th:nth-child(6),
  .rep-table td[data-label="Max"], .rep-table th:nth-child(7) { display: none; }
  .rep-table td.name { min-width: 0; }
  .rep-table select.sup { min-width: 0; width: 100%; }
  th, td { padding-left: 7px; padding-right: 7px; }
}

/* Phone. Counting stock one-handed in a coolroom, so each product is a block
   with big targets, and the columns he only configures are gone. */
@media (max-width: 700px) {
  .rep-table thead { display: none; }
  .grip { display: none; }
  button.row-del { font-size: 20px; padding: 2px 8px; }
  .rep-table, .rep-table tbody, .rep-table tr, .rep-table td { display: block; width: auto; }
  .rep-table tr {
    position: relative;
    border-bottom: 1px solid var(--line);
    padding: 10px 12px 12px;
  }
  .rep-table td { border: none; padding: 0; }
  .rep-table td.name {
    font-size: 15.5px; padding-right: 36px; margin-bottom: 8px;
  }
  .rep-table td[data-label]:not(.name)::before {
    content: attr(data-label);
    display: block;
    font-size: 10.5px; letter-spacing: .04em; text-transform: uppercase;
    color: var(--muted); font-weight: 650; margin-bottom: 2px;
  }
  .rep-table td.num { display: inline-block; width: 24%; vertical-align: top; }
  /* Min and Max are configured once, on a bigger screen. */
  .rep-table td[data-label="Min"], .rep-table td[data-label="Max"] { display: none; }
  .rep-table td.pick-cell { position: absolute; top: 10px; right: 10px; }
  .rep-table td.pick-cell input { width: 22px; height: 22px; }
  /* ⚠ A SELECTOR HERE HAS TO OUT-SPECIFY
     .rep-table td[data-label]:not(.name)::before, which is three classes.
     A plainer rule is dead CSS that looks like it works. */
  .rep-table td.order-cell::before, .rep-table td.po-cell::before { display: none; }
  .rep-table td.order-cell, .rep-table td.po-cell {
    display: inline-block; margin-top: 8px; margin-right: 18px;
  }
  .rep-table input.cell,
  .rep-table input.cell.wide,
  .rep-table input.cell.narrow { width: 100%; min-height: 42px; font-size: 16px; }
  .rep-table .cell-derived { min-height: 42px; line-height: 42px; padding: 0; width: 100%; }
  .rep-table td.vendor-cell { margin-top: 8px; }
  .rep-table select.sup { width: 100%; min-height: 42px; }
  .col-div { border-left: none; }
  .actionbar-inner { gap: 8px; }
  .actionbar .spacer, .actionbar .saving { display: none; }
  .actionbar .btn { flex: 1 1 calc(50% - 4px); justify-content: center; }
  .actionbar .btn-primary { flex: 1 1 100%; }
  .count-pill { flex: 1 1 100%; text-align: center; }
}

/* Settings: the save and test buttons belong on one line, and the sending
   switches are a different kind of thing from the choice above them. */
.actions { display: flex; gap: 10px; align-items: center; margin-top: 4px; }
.actions form { margin: 0; }
hr.rule { border: 0; border-top: 1px solid #e3e8e4; margin: 14px 0; }
.check.pick { align-items: flex-start; gap: 10px; }
.check.pick input { margin-top: 3px; }
.prov-panel[hidden] { display: none; }

/* SMS Gateway: the conversation list, the thread, and the box to write in. */
.thread-list { display: flex; flex-direction: column; }
.thread { display: flex; gap: 12px; padding: 14px 18px; border-bottom: 1px solid #eef1ee;
          text-decoration: none; color: inherit; }
.thread:last-child { border-bottom: 0; }
.thread:hover { background: #f7faf8; }
.avatar { flex: 0 0 38px; height: 38px; border-radius: 50%; background: #1f7a4d; color: #fff;
          display: grid; place-items: center; font-weight: 700; }
.thread-main { display: flex; flex-direction: column; gap: 3px; min-width: 0; flex: 1; }
.thread-top { display: flex; justify-content: space-between; gap: 10px; align-items: baseline; }
.thread-who { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.thread-when { color: #6b7a70; font-size: .85rem; white-space: nowrap; }
.thread-last { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.thread-meta { display: flex; gap: 10px; flex-wrap: wrap; font-size: .85rem; align-items: center; }
.pill { background: #eef1ee; border-radius: 999px; padding: 1px 9px; font-size: .8rem; color: #41524a; }
.pill-warn { background: #ffe9c7; color: #6a4a08; }
.head-actions { display: flex; gap: 8px; }

.chat { display: flex; flex-direction: column; gap: 10px; }
.bubble-row { display: flex; }
.bubble-row.mine { justify-content: flex-end; }
.bubble { max-width: min(560px, 82%); border-radius: 14px; padding: 10px 13px; }
.bubble-row.theirs .bubble { background: #eef1ee; border-bottom-left-radius: 4px; }
.bubble-row.mine .bubble { background: #dcf0e4; border-bottom-right-radius: 4px; }
.bubble-body { white-space: pre-wrap; word-break: break-word; }
.bubble-foot { margin-top: 5px; font-size: .78rem; color: #5a6b60; }
/* A supplier's photograph of what they are holding. Sized to be read at a
   glance in the thread and opened full size in a tab when it matters, which
   is how Rossi uses the pictures on his phone. */
.bubble-photos { display: grid; gap: 4px; }
.bubble-photos:has(+ .bubble-body) { margin-bottom: 7px; }
.bubble-photos img {
  display: block; width: 100%; max-width: 320px; height: auto;
  border-radius: 8px; background: #d7ded9;
}
.avatar-unknown { background: #8a9790; }

/* SMS Gateway: two panes on a desk, one at a time on a phone. */
.sms-layout { display: grid; grid-template-columns: minmax(260px, 360px) 1fr; gap: 16px;
              align-items: start; }
.sms-list { max-height: 72vh; overflow-y: auto; }
.sms-pane { display: flex; flex-direction: column; min-height: 420px; }
.sms-pane .chat { flex: 1; max-height: 52vh; overflow-y: auto; }
.thread.on { background: #e9f3ed; }
.pane-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.back-to-list { display: none; font-size: .9rem; }

.composer { border-top: 1px solid #e3e8e4; padding: 12px 18px 16px; display: flex;
            flex-direction: column; gap: 8px; }
.composer textarea { width: 100%; border: 1px solid #cfd8d2; border-radius: 8px;
                     padding: 9px 11px; font: inherit; resize: vertical; }
.composer .tpl-pick { align-self: flex-start; max-width: 100%; border: 1px solid #cfd8d2;
                      border-radius: 8px; padding: 6px 9px; font: inherit; background: #fff; }
.composer-foot { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.attach { display: inline-flex; align-items: center; gap: 8px; cursor: pointer;
          font-size: .9rem; color: #41524a; border: 1px solid #cfd8d2; background: #fff;
          border-radius: 8px; padding: 8px 13px; white-space: nowrap; }
.attach:hover { background: #f4f7f5; }
/* The browser's own file control is ugly and says the same thing twice, so
   the label is the button and the input is only reachable through it. */
.attach input[type=file] { position: absolute; width: 1px; height: 1px;
                           opacity: 0; pointer-events: none; }

.tpl-row { display: flex; gap: 10px; align-items: flex-start; padding: 10px 0;
           border-bottom: 1px solid #eef1ee; }
.tpl-row:last-child { border-bottom: 0; }
.tpl-edit { display: flex; gap: 8px; align-items: flex-start; flex: 1; flex-wrap: wrap; }
.tpl-edit input[type=text] { flex: 0 0 200px; border: 1px solid #cfd8d2; border-radius: 8px;
                             padding: 8px 10px; font: inherit; }
.tpl-edit textarea { flex: 1; min-width: 220px; border: 1px solid #cfd8d2; border-radius: 8px;
                     padding: 8px 10px; font: inherit; resize: vertical; }

@media (max-width: 860px) {
  .sms-layout { grid-template-columns: 1fr; }
  .sms-layout.has-open .sms-list { display: none; }
  .sms-layout.has-open .back-to-list { display: inline-block; margin-bottom: 4px; }
  .sms-pane .chat { max-height: none; }
}

/* Saved messages: a hint under each box, and a live count of what it costs. */
.tpl-form { display: flex; flex-direction: column; gap: 12px; flex: 1; }
.tpl-form .field { margin: 0; }
.hint { display: block; margin-top: 5px; color: #5a6b60; font-size: .85rem; }
/* .field makes its spans block, which would put the count on its own line. */
.hint .counter { display: inline; font-variant-numeric: tabular-nums; }
.counter-long { color: #9a5b00; font-weight: 600; }
.tpl-buttons { display: inline-flex; gap: 6px; }

/* Saved messages as cards, so a dozen of them fit on one screen. */
.tpl-grid { display: grid; gap: 12px;
            grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); }
.tpl-card { border: 1px solid #e3e8e4; border-radius: 10px; padding: 11px 12px;
            background: #fcfdfc; }
.tpl-card form { display: flex; flex-direction: column; gap: 7px; }
.tpl-name { border: 1px solid transparent; border-radius: 6px; padding: 4px 6px; margin: -4px -6px;
            font: inherit; font-weight: 700; background: transparent; }
.tpl-name:hover { border-color: #dde3df; }
.tpl-name:focus { border-color: #1f7a4d; background: #fff; outline: none; }
.tpl-body { border: 1px solid #dde3df; border-radius: 8px; padding: 7px 9px; font: inherit;
            resize: vertical; background: #fff; }
/* The count sits above the buttons in every card. Side by side, it wraps on
   some and not others and the row of cards looks crooked. */
.tpl-foot { display: flex; flex-direction: column; align-items: flex-start; gap: 7px; }
.tpl-foot .counter { font-size: .8rem; }

/* What the messages screen is connected to, and whether it is awake. */
.link-bar { display: flex; align-items: center; gap: 11px; padding: 10px 14px;
            border: 1px solid var(--line, #e3e8e4); border-radius: 10px;
            background: #fff; margin-bottom: 14px; }
.link-what { display: flex; flex-wrap: wrap; gap: 4px 10px; align-items: baseline; flex: 1;
             min-width: 0; }
.dot { flex: 0 0 10px; height: 10px; border-radius: 50%; background: #c7cfc9; }
.dot-ok { background: #1f7a4d; }
.dot-bad { background: #d08700; }
.dot-wait { background: #c7cfc9; }
/* Which handset, on its own line under the state of it. */
.link-phone { flex-basis: 100%; font-size: 12.5px; }

/* The testing lock is loud on purpose: a lock nobody notices wastes a morning. */
.flag-lock { background: #ffe0e0; color: #8a1c1c; border-color: #f3b9b9; }

/* A pairing code or any other string typed by hand into another device. */
input.code {
  font-family: var(--mono);
  letter-spacing: 0.06em;
}

/* Two quiet columns at the end: order this line, and the order it is on.
   Both are plain words rather than buttons, because the grid is already dense
   and a column of buttons down the side reads as the loudest thing on it. */
.rep-table th.order-col, .rep-table th.po-col { width: 64px; }
.rep-table td.order-cell { white-space: nowrap; }
/* A line can be on two orders. They stack, because side by side they would
   push the grid wider than the screen it is read on. */
.rep-table td.po-cell { white-space: nowrap; line-height: 1.5; }
.rep-table td.po-cell .po-link { display: block; }
.plain-link {
  background: none; border: 0; padding: 0;
  font: inherit; color: var(--green);
  text-decoration: none; cursor: pointer;
}
.plain-link:hover, .plain-link:focus-visible { color: var(--green-dark); }
.plain-link:focus-visible { outline: 2px solid var(--green); outline-offset: 2px; }
.po-link { font-variant-numeric: tabular-nums; }

/* Asking before ordering something a second time. ⚠ THIS IS THE ONLY PLACE
   THE DUPLICATE GUARD CAN BE WAIVED, so it names what it is about to do
   rather than offering a bare yes. */
dialog.ask {
  border: 1px solid var(--line); border-radius: 14px;
  padding: 22px 24px; max-width: 460px; width: calc(100% - 32px);
  color: var(--ink); background: var(--surface);
}
dialog.ask::backdrop { background: rgba(20, 35, 28, .34); }
dialog.ask h2 { margin: 0 0 8px; font-size: 18px; }
dialog.ask p { margin: 0 0 12px; }
.ask-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }

/* The install guide, read on the phone being set up. No menu and no login on
   it, because the person reading it has neither yet. One column, large text,
   and a target big enough for a thumb in a cold market. */
.guide-page { background: var(--surface); }
.guide { max-width: 640px; margin: 0 auto; padding: 22px 18px 56px; }
.guide h1 { font-size: 26px; line-height: 1.2; margin: 0 0 12px; }
.guide h2 {
  font-size: 18px; margin: 30px 0 8px;
  padding-top: 14px; border-top: 1px solid var(--line-soft);
}
.guide p { font-size: 16px; line-height: 1.55; margin: 0 0 10px; }
.guide .lede { font-size: 17px; color: var(--ink); }
.guide code {
  font-family: var(--mono); font-size: 14px;
  background: var(--green-wash); padding: 1px 5px; border-radius: 4px;
}
.guide .get { margin: 18px 0 4px; }
.btn-big { font-size: 17px; padding: 14px 22px; width: 100%; text-align: center; }
.guide-foot { margin-top: 34px; color: var(--muted); }

/* What the handset says about itself. A plain two-column list, because the
   labels are short and the values are sentences. */
table.facts { width: 100%; border-collapse: collapse; margin: 0 0 12px; }
table.facts th {
  position: static; background: none; width: 170px;
  text-align: left; font-weight: 600; color: var(--muted);
  padding: 5px 10px 5px 0; border-bottom: 1px solid var(--line-soft);
  white-space: nowrap; font-size: 13px; text-transform: none; letter-spacing: 0;
}
table.facts td {
  padding: 5px 0; border-bottom: 1px solid var(--line-soft); font-size: 13.5px;
}
table.facts tr:last-child th, table.facts tr:last-child td { border-bottom: none; }
td.fact-bad { color: var(--red); font-weight: 600; }
@media (max-width: 560px) {
  table.facts th, table.facts td { display: block; width: auto; border-bottom: none; }
  table.facts th { padding-bottom: 0; }
  table.facts td { padding-top: 1px; border-bottom: 1px solid var(--line-soft); }
}

/* The conversation list and one conversation are both paged now: the shop
   keeps every message for ever while the handset keeps thirty days. */
.list-more { padding: 12px 18px; border-top: 1px solid #eef1ee; text-align: center; }
.chat-earlier { text-align: center; padding: 4px 0 8px; }
/* Remove, on a message, for an admin. Quiet: it is the rarest thing on the
   screen and the most expensive to press by accident. */
.bubble-del { background: none; border: 0; padding: 0; font: inherit; color: #8a9790;
              cursor: pointer; text-decoration: underline; }
.bubble-del:hover { color: #b3261e; }
.bubble-del[disabled] { opacity: .5; cursor: default; }

/* Which of the open orders to add to. Only shown when there is more than one,
   because one open order is not a choice. */
.repeat-which { margin: 10px 0; padding: 10px 12px; background: #f7faf8;
                border-radius: 8px; }
.repeat-which p { margin: 0 0 6px; }
.repeat-which .check { display: flex; gap: 8px; align-items: center; padding: 3px 0; }
#order-news a { margin-left: 8px; }
#order-news div { margin-top: 4px; }

/* Orders on paper, in the replenishment sheet's own shape: the date across
   the top and vendors in three columns. `.order-sheet` is hidden on screen
   because the replenishment page carries one it only prints; this page is
   the sheet, so it shows. */
.order-sheet-page { display: block; margin-bottom: 24px; }
.order-sheet-page .sheet-cols { columns: 3; column-gap: 24px; }
.order-sheet-page .sheet-group { break-inside: avoid; margin: 0 0 14px; }
.order-sheet-page .sheet-date { margin: 0 0 14px; }
.po-printed { margin-top: 18px; }

/* The day being looked at, on the purchase order toolbar. */
.btn.on { background: #1f7a4d; border-color: #1f7a4d; color: #fff; }
/* Said where the attach button used to be, so it reads as the reason the
   button is missing rather than as a stray note. */
.attach-off { font-size: .85rem; max-width: 38ch; line-height: 1.35; }

/* ═══ A phone, a tablet and a laptop ══════════════════════════════════════
   Justin, 2026-11-18. Rossi reads this standing in a coolroom with a thumb,
   and the shop runs it on a laptop. The grid stays dense on the laptop,
   because density is the point of it; the phone gets room to be pressed. */

/* ⚠ WITHOUT THIS THE MENU RUNS OFF THE RIGHT OF A PHONE AND SETTINGS CANNOT
   BE REACHED AT ALL. A flex item will not shrink below its own content
   unless it is told it may, so six links sat 700px wide inside a 390px bar
   and the wrap that was already asked for never happened. Measured on an
   iPhone 13 profile: three links past the right edge on every screen. */
nav.tabs { min-width: 0; }

@media (pointer: coarse) {
  /* A finger, not a mouse. Both Apple and Google ask for 44px, and a 32px
     button gets missed at four in the morning on a market floor. */
  .btn, .btn-sm { min-height: 40px; }
  input[type="text"], input[type="number"], input[type="date"],
  input[type="password"], input[type="search"], input[type="tel"],
  select, textarea { min-height: 44px; }
  input[type="checkbox"], input[type="radio"] { width: 20px; height: 20px; }
  .check { min-height: 40px; }
  /* The tick on a grid row is the smallest thing on the screen and the one
     most often pressed, so it gets the whole cell. */
  .pick-cell { min-width: 44px; min-height: 44px; }
  .pick-cell input { width: 22px; height: 22px; }

  /* ⚠ THE BOX IS 22px AND A THUMB IS NOT. What has to be 44px is the area
     that answers to a press, not the square that is drawn, so the room comes
     from padding and nothing looks any different. */
  .check { padding: 4px 0; }
  .brand { min-height: 40px; }
  .back-to-list { padding: 9px 4px; display: inline-block; }

  /* A name in a list is how a record is opened on a phone. 18px of text is
     not a target. */
  table.stackable td.lead a,
  .thread-who { display: inline-block; padding: 4px 0; }

  /* Deliberately the quietest thing on the screen, and still has to be
     hittable: a press that misses it hits the message instead. */
  .bubble-del { padding: 7px 2px; }
}

@media (max-width: 700px) {
  /* The heading is the least useful thing on a small screen: the person
     holding the phone knows which page they opened. */
  h1 { font-size: 19px; }
  .page-head { gap: 10px; margin-bottom: 12px; }
  .page-head .sub { font-size: 13px; }
  /* ⚠ ALL SIX VISIBLE, NOT FIVE AND A SWIPE. The bar above turns the menu
     into a sideways scroller below 820px, which on a 390px phone leaves
     Products, Suppliers and Settings off the right edge with nothing to say
     they are there. Two rows of chips costs 38px and hides nothing. */
  nav.tabs {
    flex-wrap: wrap; overflow-x: visible; gap: 3px; row-gap: 3px;
  }
  nav.tabs a { padding: 9px 10px; font-size: 13.5px; }

  /* The vendor, the Order link and the PO it went on share a line. Each one
     on its own row is 60px a card, and there are 154 cards. */
  .rep-table tr { display: flex; flex-wrap: wrap; align-items: center; }
  .rep-table td.name { flex: 1 1 100%; }
  .rep-table td.vendor-cell { flex: 1 1 auto; min-width: 0; margin-top: 6px; }
  .rep-table td.vendor-cell::before { display: none; }
  .rep-table td.order-cell,
  .rep-table td.po-cell { flex: 0 0 auto; margin: 6px 0 0 10px; }
  .rep-table td.vendor-cell select { width: 100%; }
  .topbar-inner { gap: 10px; padding: 0 14px; min-height: 52px; }
  main { padding: 14px 14px 200px; }

  /* ⚠ THE BAR IS FIXED AND IT COVERED THE LAST ROW. Three full width
     buttons stacked is 200px of bar over a list somebody is reading. */
  .actionbar { padding: 10px 14px; }
  .actionbar-inner { gap: 8px; }
  .actionbar .btn { flex: 1; justify-content: center; }
  .count-pill { flex-basis: 100%; text-align: center; }
  .spacer { display: none; }

  /* ⚠ FOUR HUNDRED PIXELS OF FILTERS BEFORE THE FIRST ORDER. The two date
     boxes and five day buttons were taking three full rows, so the thing the
     screen is about started below the fold. The days he actually presses go
     on one line of their own that scrolls, and the two date boxes, which are
     for going back a month, sit quietly under them. */
  /* ⚠ AND THE TOOLBAR ITSELF HAS TO BE ABLE TO SHRINK. A native date box
     will not go below the width of "mm/dd/yyyy" and its calendar icon, so
     two of them side by side pushed the whole bar to 395px inside a 362px
     page and the browser widened the viewport to 409 to fit it. */
  .toolbar { gap: 6px; row-gap: 8px; min-width: 0; max-width: 100%; }
  .toolbar .search { flex: 1 1 100%; }
  .toolbar select { flex: 1 1 100%; min-width: 0; }
  .toolbar .date-field { flex: 1 1 100%; min-width: 0; }
  .toolbar .date-field input { flex: 1; width: 100%; min-width: 0; }
  .toolbar .day-chips {
    flex: 1 1 100%;
    /* ⚠ WITHOUT min-width THE ROW PUSHES THE WHOLE PAGE WIDER. A flex item
       will not shrink below its content unless told, so overflow-x had
       nothing to scroll and the browser widened the viewport to 409px
       instead. The same trap as the menu. */
    min-width: 0;
    display: flex; gap: 6px;
    overflow-x: auto; -webkit-overflow-scrolling: touch;
    padding-bottom: 2px;
  }
  .toolbar .day-chips .btn { white-space: nowrap; padding: 9px 12px; }

  /* ⚠ A TABLE IS NOT A LAYOUT ON A PHONE. These were scrolling sideways
     inside their own box, so a row could never be read in one go: the order
     number and the supplier were never on screen together. Each row becomes
     a block with its headings carried down as labels. */
  table.stackable thead { display: none; }
  table.stackable, table.stackable tbody,
  table.stackable tr, table.stackable td { display: block; width: auto; }
  table.stackable tr {
    border-bottom: 1px solid var(--line);
    padding: 12px 14px;
  }
  table.stackable tr:last-child { border-bottom: 0; }
  table.stackable td { border: none; padding: 1px 0; text-align: left; }
  table.stackable td.num { text-align: left; }
  table.stackable td[data-label]::before {
    content: attr(data-label);
    display: inline-block;
    min-width: 8.5em;
    font-size: 11px; letter-spacing: .04em; text-transform: uppercase;
    color: var(--muted); font-weight: 650;
  }
  /* The name of the thing leads, as it does on paper. */
  table.stackable td.lead { font-size: 15.5px; margin-bottom: 4px; }
  table.stackable td.lead::before { display: none; }
  table.stackable td.right { text-align: left; margin-top: 8px; }
  table.stackable td.right .btn { min-width: 84px; }
  table.stackable td:empty { display: none; }
  /* The tick that chooses a row sits beside its name rather than above it. */
  table.stackable td.pick-cell {
    position: absolute; right: 14px; margin-top: -2px;
  }
  table.stackable tr { position: relative; }
}

@media (max-width: 1100px) and (min-width: 701px) {
  /* Tablet. The grid still fits, the two column panes do not. */
  .toolbar { flex-wrap: wrap; }
}
/* The day buttons read as one group on every size, not only on a phone. */
.day-chips { display: inline-flex; gap: 6px; align-items: center; }

/* ═══ The phone frame ═════════════════════════════════════════════════════
   Justin, 2026-11-18: it has to feel like a phone app, not a desktop page
   made narrow. So the phone gets its own frame. A slim bar saying where you
   are, the places you go under your thumb, and the rest of the menu on a
   sheet. None of this exists above 700px, where the desktop bar is right. */

.appbar, .tabbar, .sheet, .sheet-back { display: none; }

@media (max-width: 700px) {
  :root { --tabbar-h: 58px; }

  /* The six link bar belongs to a mouse. */
  .topbar { display: none; }

  .appbar {
    display: flex; align-items: center; justify-content: space-between;
    gap: 10px;
    position: sticky; top: 0; z-index: 30;
    background: var(--surface);
    border-bottom: 1px solid var(--line);
    padding: 11px 16px;
    /* Under the notch on a phone that has one. */
    padding-top: calc(11px + env(safe-area-inset-top, 0px));
  }
  .appbar-title { font-size: 17px; font-weight: 700; letter-spacing: -.2px; }
  .appbar-right { display: flex; gap: 6px; align-items: center; }

  /* ⚠ THE SCREEN NAME IS ALREADY IN THE BAR ABOVE. Printing it again in 19px
     is ninety pixels of nothing at the top of every page, and on a phone the
     first thing on the screen should be the thing the screen is for. */
  .page-head > div > h1 { display: none; }
  .page-head { margin-bottom: 10px; }
  .page-head .sub { font-size: 13px; margin: 0; }

  main { padding: 12px 0 calc(var(--tabbar-h) + 130px); }
  main:has(.counter) { padding-bottom: 0; }
  /* Edge to edge. A card inside a padded page inside a bordered box is three
     containers before the first row of anything. */
  main > .card, main > .notice, main > .page-head,
  main > form > .card, main > .order-sheet { margin-left: 0; margin-right: 0; }
  main > .page-head, main > .notice, main > p, main > .add-row { padding: 0 16px; }
  .card { border-radius: 0; border-left: 0; border-right: 0; }
  .card-body, .card-head { padding-left: 16px; padding-right: 16px; }

  .tabbar {
    display: grid; grid-template-columns: repeat(5, 1fr);
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
    background: var(--surface);
    border-top: 1px solid var(--line);
    padding-bottom: env(safe-area-inset-bottom, 0px);
  }
  .tabbar a, .tabbar button {
    display: flex; flex-direction: column; align-items: center; gap: 3px;
    padding: 7px 2px 8px;
    min-height: var(--tabbar-h);
    border: 0; background: none; cursor: pointer;
    font: inherit; font-size: 11px; font-weight: 600;
    color: var(--muted); text-decoration: none;
  }
  .tabbar svg {
    width: 23px; height: 23px; fill: none;
    stroke: currentColor; stroke-width: 1.7;
    stroke-linecap: round; stroke-linejoin: round;
  }
  .tabbar circle { fill: currentColor; stroke: none; }
  .tabbar .on { color: var(--green-dark); }
  .tabbar .on svg { stroke-width: 2.1; }

  /* The action bar sits above the tab bar, never on top of it. */
  .actionbar { bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom, 0px)); }

  .sheet-back {
    display: block; position: fixed; inset: 0; z-index: 45;
    background: rgba(18, 30, 24, .38);
  }
  .sheet {
    display: block; position: fixed; left: 0; right: 0; bottom: 0; z-index: 46;
    background: var(--surface);
    border-radius: 16px 16px 0 0;
    padding: 6px 0 calc(10px + env(safe-area-inset-bottom, 0px));
    box-shadow: 0 -8px 28px rgba(20, 35, 28, .18);
  }
  .sheet[hidden], .sheet-back[hidden] { display: none; }
  .sheet-grab {
    width: 38px; height: 4px; border-radius: 2px;
    background: var(--line); margin: 6px auto 10px;
  }
  .sheet-who { margin: 0 20px 6px; font-size: 13px; color: var(--muted); }
  .sheet-item {
    display: block; width: 100%; text-align: left;
    padding: 15px 20px; font: inherit; font-weight: 600;
    color: var(--ink); text-decoration: none;
    background: none; border: 0; border-top: 1px solid var(--line-soft);
    cursor: pointer;
  }
  .sheet-item.on { color: var(--green-dark); background: var(--green-wash); }
  .sheet-out { color: #b3261e; }
  .sheet-close { color: var(--muted); font-weight: 550; }
  body.sheet-up { overflow: hidden; }
}
/* The exact dates are a laptop job. On a phone they wait behind a chip. */
.date-toggle { display: none; }
@media (max-width: 700px) {
  .date-toggle { display: inline-flex; order: -1; }
  .toolbar .day-chips { order: -2; }
  .toolbar .date-field { display: none; }
  .toolbar.dates-open .date-field { display: flex; }
  /* A row that scrolls should look like one. */
  .toolbar .day-chips { scroll-padding-inline: 16px; }
}

/* ═══ Counting, one product at a time ═════════════════════════════════════
   The grid is right on a laptop. In a hand it is thirty metres of scrolling
   and a different product under the thumb on every glance up from the shelf.
   This is the same data, one line at a time, with a keypad that stays put. */
.counter { max-width: 520px; margin: 0 auto; padding: 0 16px; }
.count-top {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  margin-bottom: 8px;
}
.count-where { font-weight: 650; font-size: 13.5px; color: var(--muted); }
.count-progress {
  height: 4px; border-radius: 2px; background: var(--line-soft);
  overflow: hidden; margin-bottom: 14px;
}
.count-progress span {
  display: block; height: 100%; background: var(--green);
  transition: width .18s ease;
}
.count-card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 14px; padding: 16px 16px 14px; margin-bottom: 14px;
}
.count-name {
  margin: 0 0 4px; font-size: 24px; font-weight: 700; letter-spacing: -.3px;
  line-height: 1.15;
}
.count-facts { margin: 0 0 14px; font-size: 13px; color: var(--muted); }
.count-po { margin: 12px 0 0; font-size: 13px; color: var(--green-dark); font-weight: 600; }

.count-fields { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.count-field {
  display: flex; flex-direction: column; align-items: flex-start; gap: 2px;
  padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px;
  background: var(--surface); font: inherit; cursor: pointer; text-align: left;
}
/* ⚠ WHICH BOX THE KEYPAD IS TYPING INTO HAS TO BE OBVIOUS. Three numbers and
   one keypad is a wrong number waiting to happen. */
.count-field.on { border-color: var(--green); box-shadow: inset 0 0 0 1px var(--green); }
.count-label {
  font-size: 10.5px; letter-spacing: .05em; text-transform: uppercase;
  color: var(--muted); font-weight: 650;
}
.count-value { font-size: 26px; font-weight: 700; line-height: 1.1; }
.count-field.empty .count-value { color: var(--line); }

.keypad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.keypad button {
  font: inherit; font-size: 23px; font-weight: 600;
  padding: 10px 0; min-height: 52px;
  border: 1px solid var(--line); border-radius: 12px;
  background: var(--surface); color: var(--ink); cursor: pointer;
}
.keypad button:active { background: var(--green-wash); }

.count-move {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  margin-top: 12px;
}
.count-move .btn { min-height: 48px; padding: 0 22px; }
.count-saved { font-size: 13px; color: var(--muted); }

@media (max-width: 700px) {
  .counter { padding: 0 14px calc(var(--tabbar-h) + 74px); }
  .count-name { font-size: 21px; }
  .count-card { padding: 14px; margin-bottom: 12px; }
  .count-facts { margin-bottom: 12px; }
  .keypad button { min-height: 48px; padding: 8px 0; font-size: 22px; }

  /* ⚠ NEXT IS THE MOST PRESSED CONTROL ON THIS SCREEN AND IT WAS BELOW THE
     FOLD. A hundred and fifty four products means a hundred and fifty four
     presses, so it sits above the tab bar and never moves. */
  .count-move {
    position: fixed; left: 0; right: 0;
    bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom, 0px));
    z-index: 35;
    margin: 0; padding: 9px 14px;
    background: var(--surface); border-top: 1px solid var(--line);
  }
  /* The counting screen has its own bottom row, so the page one is not
     wanted under it. */
  .counter ~ .actionbar { display: none; }
}

/* ⚠ A SCREEN THAT FITS UNTIL IT HAS SOMETHING TO SAY DOES NOT FIT. The
   note naming the order a line is already on is 32px tall and shows only on
   a line that has been bought, so a short phone scrolled by exactly that
   much on the products that matter most. Measured on an iPhone 13, 390 by
   664, where the page ran 24px past the viewport. The keypad stays at the
   44px both Apple and Google ask for. */
@media (max-width: 700px) and (max-height: 720px) {
  .count-progress { margin-bottom: 10px; }
  .count-card { margin-bottom: 10px; }
  .count-po { margin-top: 8px; }
  /* 46px a key: the figure on it sets the height, so the padding is what
     gives way, not the target size. */
  .keypad button { min-height: 44px; line-height: 1; padding: 11px 0; }
}

/* What arrived, beside what was asked for. Two colours and no more: amber
   says the figures differ, red says it went back on the truck. The same two
   the rest of the app already uses for those meanings. */
table.delivery td.num input.cell { max-width: 110px; }
.phone-only { display: none; }
@media (max-width: 700px) { .phone-only { display: inline; } }
table.delivery .line-differs td:first-child { box-shadow: inset 3px 0 0 var(--amber); }
table.delivery .line-returned td:first-child { box-shadow: inset 3px 0 0 var(--red); }
table.delivery .line-returned td.name { color: var(--red); text-decoration: line-through; }
table.delivery .line-returned td.name .uom { text-decoration: none; }

/* On a phone every line is a block, the same treatment the replenishment
   sheet gets, because this is read at a market and not at a desk. */
@media (max-width: 700px) {
  table.delivery thead { display: none; }
  table.delivery, table.delivery tbody, table.delivery tr, table.delivery td { display: block; width: auto; }
  table.delivery tr {
    border-bottom: 1px solid var(--line); padding: 10px 14px 12px;
    display: grid; grid-template-columns: 1fr auto auto; gap: 6px 10px;
    align-items: center;
  }
  table.delivery td { border: 0; padding: 0; }
  table.delivery td.name { grid-column: 1 / -1; font-weight: 600; }
  /* ⚠ A TICK AT A MARKET NEEDS MORE THAN A TICK. The box is 20px and the
     word beside it is the rest of the target. */
  table.delivery td.returned-cell { grid-column: 3; }
  table.delivery td.returned-cell .check {
    min-height: 44px; padding: 0 4px; gap: 7px; white-space: nowrap;
  }
  table.delivery td[data-label]::before {
    content: attr(data-label) " "; color: var(--muted); font-size: 12px;
  }
  table.delivery .line-differs td:first-child,
  table.delivery .line-returned td:first-child { box-shadow: none; }
  table.delivery .line-differs { border-left: 3px solid var(--amber); }
  table.delivery .line-returned { border-left: 3px solid var(--red); }
}

/* The printed sheet says what arrived. ⚠ THE WORDS CARRY IT, NOT THE COLOUR:
   the office printer is black and white, so RETURNED is written out and the
   quantity ordered is written beside the one that came. */
.sheet-group p.sheet-returned { color: var(--red); text-decoration: line-through; }
/* ⚠ A LINE THROUGH TEXT IS DRAWN BY THE ANCESTOR, and a child cannot rub it
   out with text-decoration: none. An inline block starts its own, which is
   what keeps the word RETURNED readable on a struck-through line. */
.sheet-note { display: inline-block; text-decoration: none;
              font-size: .85em; color: var(--amber); font-weight: 600; }
p.sheet-returned .sheet-note { color: var(--red); }
@media print {
  .sheet-group p.sheet-returned, .sheet-note { color: #000; }
  .sheet-note { font-style: italic; }
}
