/* Java Edge. Phone first: managers order from busy kitchens, so big targets, high contrast, nothing extra.
   Brand: red #EB1D24, dark #231F20, cream #F7F1E8, Georgia headings. The commissary green comes from the
   approved prep sheets (#1f5130 / #e6efe6). */
:root {
  --red: #EB1D24;
  --red-ink: #B5121A;      /* red text on cream: 6:1 */
  --dark: #231F20;
  --cream: #F7F1E8;
  --paper: #FFFDF9;
  --rule: #E3D9C8;
  --muted: #5F5853;        /* 6.2:1 on cream */
  --green: #1F5130;
  --green-bg: #E6EFE6;
  --amber: #8A6100;
  --amber-bg: #FFF4D6;
  --focus: #1A5FB4;
  --focus-on-dark: #9CC3FF;  /* 9:1 on dark: the header and the bottom bar */
  --field-line: #8C7F6C;     /* field borders: 3.9:1 on white, the box's only edge on cream */
  --radius: 12px;
  --tap: 48px;
  --bar-h: calc(88px + max(10px, env(safe-area-inset-bottom)));   /* the bottom bar: its height never changes */
  --serif: Georgia, "Times New Roman", serif;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-padding-top: 64px; }   /* focus and #anchors land below a sticky header */
body {
  margin: 0; background: var(--cream); color: var(--dark);
  font: 17px/1.45 var(--sans);
  -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale;
}
h1, h2, h3 { font-family: var(--serif); font-weight: 700; line-height: 1.15; text-wrap: balance; margin: 0; }
h1 { font-size: 28px; }
h2 { font-size: 21px; }
p { margin: 0; text-wrap: pretty; }
a { color: var(--red-ink); text-underline-offset: 3px; }
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; touch-action: manipulation; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 4px; }
.top :focus-visible, .bar :focus-visible { outline-color: var(--focus-on-dark); }
.num, .qty, .money { font-variant-numeric: tabular-nums; }

.skip { position: absolute; left: 8px; top: -60px; background: var(--paper); padding: 10px 14px; z-index: 50; border-radius: 8px; }
.skip:focus { top: 8px; }
.vh { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden;
      clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

/* ── header ── */
.top { background: var(--dark); color: #fff; display: flex; flex-wrap: wrap; align-items: center;
       gap: 4px 12px; padding: 8px 16px; padding-top: max(8px, env(safe-area-inset-top)); }
.brand { font-family: var(--serif); font-weight: 700; font-size: 22px; letter-spacing: .5px; color: #fff;
         text-decoration: none; padding: 8px 0; margin-right: auto; }
.brand span { color: var(--red); }
.top nav { order: 3; flex-basis: 100%; display: flex; gap: 4px; margin: 0 -10px; }
.top nav a, .signout button {
  color: #fff; text-decoration: none; min-height: 44px; display: inline-flex; align-items: center;
  padding: 0 12px; border-radius: 8px; font-size: 16px;
}
.top nav a[aria-current="page"] { background: var(--red-ink); }   /* white on it: 6.9:1 */
.top nav a:hover { background: rgba(255,255,255,.12); }
.top nav a[aria-current="page"]:hover { background: var(--red-ink); }
.signout { margin: 0; }
.signout button { background: none; border: 1px solid rgba(255,255,255,.35); }
.signout button:hover { background: rgba(255,255,255,.12); }
.who { color: #CFC7BC; font-size: 14px; }
@media (max-width: 479px) { .who { display: none; } }
@media (min-width: 760px) {
  .top nav { order: 0; flex-basis: auto; margin: 0; }
  .brand { margin-right: 12px; }
  .who { margin-left: auto; }
}

/* ── page frame ── */
main { max-width: 760px; margin: 0 auto; padding: 16px 16px 40px; }
main.wide { max-width: 1400px; }
/* pages with the fixed bar: room to scroll the end of the page above it, and focus never lands under it */
html.has-bar { scroll-padding-bottom: calc(var(--bar-h) + 12px); }
.has-bar main { padding-bottom: calc(var(--bar-h) + 40px); }
.page-head { margin: 4px 0 16px; display: grid; gap: 6px; }
.back { font-size: 16px; display: inline-flex; align-items: center; min-height: 44px; margin: -8px 0 -6px; }
.back::before { content: "\2039"; font-size: 24px; line-height: 1; margin-right: 6px; }
.meta { color: var(--muted); font-size: 16px; }
.meta strong { color: var(--dark); }

.flashes { max-width: 760px; margin: 12px auto 0; padding: 0 16px; display: grid; gap: 8px; }
.flash { background: var(--green-bg); color: var(--green); border-radius: 10px; padding: 12px 14px; font-weight: 600; }
.flash-error { background: #FDECEA; color: var(--red-ink); }

.notice { border-radius: 10px; padding: 12px 14px; margin: 0 0 14px; background: var(--paper);
          box-shadow: inset 0 0 0 1px var(--rule); }
.notice.warn { background: var(--amber-bg); color: #5A4000; box-shadow: none; }
.notice.done { background: var(--green-bg); color: var(--green); box-shadow: none; }

/* ── buttons ── */
.btn {
  min-height: var(--tap); padding: 0 18px; border-radius: 10px; border: 0; display: inline-flex;
  align-items: center; justify-content: center; gap: 8px; font-weight: 600; text-decoration: none;
  background: var(--paper); color: var(--dark); box-shadow: inset 0 0 0 1.5px var(--dark);
  transition-property: transform, background-color; transition-duration: .12s; transition-timing-function: ease-out;
}
.btn:active { transform: scale(.97); }
.btn-primary { background: var(--red); color: #fff; box-shadow: none; font-size: 19px; font-weight: 700; }
.btn-primary:hover { background: #D3141B; }
.btn-dark { background: var(--dark); color: #fff; box-shadow: none; }
.btn[disabled], .btn[aria-disabled="true"] { opacity: .55; cursor: default; transform: none; }

/* ── status badges ── */
.badge { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: 14px; font-weight: 700;
         background: var(--paper); box-shadow: inset 0 0 0 1px var(--rule); color: var(--muted); white-space: nowrap; }
.s-OPEN { background: var(--amber-bg); color: var(--amber); box-shadow: none; }
.s-SUBMITTED { background: var(--green-bg); color: var(--green); box-shadow: none; }
.s-PICKED { background: var(--green); color: #fff; box-shadow: none; }
.s-SHIPPED { background: var(--dark); color: #fff; box-shadow: none; }
.s-RECEIVED { background: #E9E4DC; color: var(--muted); box-shadow: none; }
.s-MISSING { background: #FDECEA; color: var(--red-ink); box-shadow: none; }

/* ── store picker ── */
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 16px; }
.chips a { min-height: 44px; display: inline-flex; align-items: center; padding: 0 16px; border-radius: 999px;
           background: var(--paper); color: var(--dark); text-decoration: none; box-shadow: inset 0 0 0 1px var(--rule); }
.chips a[aria-current="page"] { background: var(--dark); color: #fff; box-shadow: none; }

/* ── this cycle: the two order cards ── */
.cards { list-style: none; padding: 0; margin: 0 0 28px; display: grid; gap: 12px; }
@media (min-width: 560px) { .cards { grid-template-columns: 1fr 1fr; } }
.order-card {
  display: grid; gap: 4px; padding: 16px 18px; border-radius: 14px; background: var(--paper); color: var(--dark);
  text-decoration: none; box-shadow: 0 0 0 1px var(--rule), 0 1px 2px rgba(35,31,32,.06);
  position: relative; min-height: 132px;
}
.order-card:active { transform: scale(.99); }
.order-card .oc-top { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.order-card .oc-kind { font-family: var(--serif); font-size: 24px; font-weight: 700; }
.order-card .oc-meta { color: var(--muted); }
.order-card .oc-cta { margin-top: auto; font-weight: 700; color: var(--red-ink); padding-top: 8px; }
.order-card.todo { box-shadow: inset 0 0 0 2px var(--red), 0 1px 2px rgba(35,31,32,.06); }

.list { list-style: none; padding: 0; margin: 8px 0 0; background: var(--paper); border-radius: 14px;
        box-shadow: 0 0 0 1px var(--rule); }
.list > li { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px; padding: 12px 16px; border-top: 1px solid var(--rule); }
.list > li:first-child { border-top: 0; }
.list .grow { flex: 1 1 180px; min-width: 0; }
.empty { color: var(--muted); padding: 10px 0; }
.list .empty { padding: 16px; }
.nowrap { white-space: nowrap; }

/* ── order screen ── */
.search { margin: 0 0 16px; }
.add-item { margin: 0 0 16px; }
.add-item > summary { list-style: none; cursor: pointer; display: inline-flex; align-items: center; gap: 8px;
  min-height: 44px; font-weight: 600; color: var(--red-ink); }
.add-item > summary::-webkit-details-marker { display: none; }
.add-item > summary::before { content: "+"; font-size: 22px; line-height: 1; width: 28px; height: 28px; border-radius: 50%;
  display: grid; place-items: center; background: var(--red-ink); color: #fff; font-weight: 600; }
.add-item[open] > summary { margin-bottom: 8px; }
.add-item .search { margin-bottom: 12px; }
.search label { display: block; font-weight: 600; margin-bottom: 6px; }
.search-row { display: flex; gap: 8px; }
.search-row input { flex: 1; min-width: 0; }
input.field, textarea.field, .search-row input {
  min-height: var(--tap); border: 1.5px solid var(--field-line); border-radius: 10px; background: #fff; padding: 10px 12px;
  font-size: 17px;
}
textarea.field { width: 100%; resize: vertical; }
.results { margin: -4px 0 18px; }

.sec { margin: 0 0 12px; background: var(--paper); border-radius: 14px; box-shadow: 0 0 0 1px var(--rule); overflow: clip; }
.sec > summary {
  list-style: none; display: flex; align-items: center; gap: 10px; min-height: 52px; padding: 8px 16px;
  cursor: pointer; font-weight: 700; letter-spacing: .2px; background: #EFE7DA; position: sticky; top: 0; z-index: 2;
}
.sec > summary:focus-visible { outline-offset: -4px; border-radius: 10px; }   /* inside: .sec clips anything outside */
.sec > summary::-webkit-details-marker { display: none; }
.sec > summary::before { content: ""; width: 9px; height: 9px; border-right: 2.5px solid var(--dark);
  border-bottom: 2.5px solid var(--dark); transform: rotate(45deg) translate(-2px, -2px); flex: none;
  transition: transform .15s ease-out; }
.sec:not([open]) > summary::before { transform: rotate(-45deg); }
.sec-name { flex: 1; min-width: 0; }
.sec-count { font-size: 14px; font-weight: 600; color: var(--muted); white-space: nowrap; }
.sec-count.on { color: var(--red-ink); }

.lines { list-style: none; margin: 0; padding: 0; }
.line { border-top: 1px solid var(--rule); }
.line:first-child { border-top: 0; }
.line-form, .line-row { display: flex; align-items: center; gap: 10px; padding: 10px 12px 10px 16px; position: relative; }
.line.has-qty .line-form::before, .line.has-qty .line-row::before {
  content: ""; position: absolute; left: 0; top: 8px; bottom: 8px; width: 4px; border-radius: 0 3px 3px 0; background: var(--red);
}
.line-text { flex: 1; min-width: 0; display: grid; gap: 2px; }
.item { font-weight: 600; overflow-wrap: anywhere; }
.line-meta { color: var(--muted); font-size: 15px; display: flex; flex-wrap: wrap; gap: 0 12px; }
.line-meta b { color: var(--dark); font-weight: 600; }
.line.late .item::after { content: "late"; margin-left: 8px; font-size: 12px; font-weight: 700; color: var(--amber);
  background: var(--amber-bg); border-radius: 999px; padding: 1px 7px; vertical-align: 2px; }

.stepper { display: flex; align-items: center; gap: 4px; flex: none; }
.step {
  width: var(--tap); height: var(--tap); border-radius: 12px; border: 0; background: #EFE7DA; color: var(--dark);
  font-size: 26px; font-weight: 600; line-height: 1; display: grid; place-items: center;
  transition-property: transform, background-color; transition-duration: .1s; transition-timing-function: ease-out;
}
.step:hover { background: #E6DBC9; }
.step:active { transform: scale(.92); background: #DCCFB9; }
.step.plus { background: var(--dark); color: #fff; }
.step.plus:hover { background: #3A3435; }
input.qty {
  width: 64px; height: var(--tap); text-align: center; font-size: 20px; font-weight: 700; border-radius: 10px;
  border: 1.5px solid var(--field-line); background: #fff; padding: 0 4px;
}
input.qty[aria-invalid="true"] { border-color: var(--red-ink); box-shadow: 0 0 0 1.5px var(--red-ink); }
.line-msg { margin: -4px 12px 10px 16px; color: var(--red-ink); font-size: 15px; font-weight: 600; }

/* Save per line: only without JS (with JS a line saves itself). It takes its own row on a phone. */
.line-save { display: none; }
.no-js .line-form { flex-wrap: wrap; }
.no-js .line-form .line-text { flex-basis: 140px; }
.no-js .line-save { display: inline-flex; margin-left: auto; min-height: 44px; }
input.qty::placeholder { color: #B1A796; font-weight: 500; }
.line.has-qty input.qty { border-color: var(--dark); }
.qty-ro { font-size: 20px; font-weight: 700; min-width: 48px; text-align: right; }
@media (max-width: 400px) {             /* keep the stepper beside the name on small phones */
  .line-form, .line-row { gap: 8px; padding-right: 10px; }
  .stepper { gap: 3px; }
  .step { width: 44px; height: 44px; }
  input.qty { width: 54px; height: 44px; }
}

.notes-box { margin: 20px 0 0; display: grid; gap: 8px; }
.notes-box label, .notes-box .notes-head { font: 700 17px/1.45 var(--sans); }
.notes-box .btn { justify-self: start; }

/* the bar at the bottom: total, save status, Submit */
.bar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10; background: var(--dark); color: #fff;
  padding: 10px 16px; padding-bottom: max(10px, env(safe-area-inset-bottom));
  box-shadow: 0 -6px 20px rgba(35,31,32,.18);
}
.bar-in { max-width: 760px; margin: 0 auto; display: flex; align-items: center; gap: 6px 12px; flex-wrap: wrap; }
.bar-total { display: grid; line-height: 1.2; margin-right: auto; }
.bar-total strong { font-size: 24px; font-variant-numeric: tabular-nums; }
.bar-total span { font-size: 14px; color: #CFC7BC; font-variant-numeric: tabular-nums; }
/* the save status: one line of its own above the total, so a long message can't grow the bar
   (the full text is in the live region; the line itself says what went wrong) */
.save-status { order: -1; flex: 0 0 100%; height: 20px; line-height: 20px; font-size: 14px; color: #CFC7BC;
               white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
@media (min-width: 600px) { .save-status { order: 0; flex: 1 1 0; min-width: 0; text-align: right; } }
.save-status.err { color: #FFB4B0; font-weight: 600; }
.bar .btn-primary { min-height: 52px; padding: 0 22px; }
.bar-done { font-weight: 700; color: #BFE3C6; }

/* ── receive ── */
.recv .line-row { flex-wrap: wrap; }
.recv-in { display: flex; align-items: center; gap: 8px; }
.recv-in label { font-size: 14px; color: var(--muted); }
.short { color: var(--red-ink); font-weight: 600; }

/* ── board (also on a TV) ── */
.board-head { display: flex; flex-wrap: wrap; align-items: end; gap: 10px 16px; margin: 4px 0 16px; }
.board-head h1 { font-size: clamp(26px, 3vw, 44px); margin-right: auto; }
.pager { display: flex; gap: 8px; flex-wrap: wrap; }
.board-count { font-size: clamp(17px, 1.6vw, 26px); color: var(--muted); }
.board-count strong { color: var(--dark); }
/* minmax(0, 1fr): a tile may be narrower than its longest word, so the board never scrolls sideways */
.board { display: grid; gap: 14px; grid-template-columns: minmax(0, 1fr); }
.board-row { display: grid; gap: 10px; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); align-items: stretch; }
.board-row h2 { grid-column: 1 / -1; display: flex; align-items: baseline; gap: 12px; font-size: clamp(22px, 2.2vw, 34px); }
.board-row h2 a { font-family: var(--sans); font-size: 15px; font-weight: 600; display: inline-flex; align-items: center;
                  min-height: 44px; }
@media (min-width: 1000px) {
  .board-row { grid-template-columns: minmax(180px, .7fr) minmax(0, 1fr) minmax(0, 1fr); }
  .board-row h2 { grid-column: auto; flex-direction: column; justify-content: center; gap: 4px; }
}
.tile {
  border-radius: 16px; padding: 14px 16px; background: var(--paper); box-shadow: 0 0 0 1px var(--rule);
  display: grid; gap: 4px; align-content: start; min-height: 128px; color: var(--dark); text-decoration: none;
}
.tile .t-kind { font-size: clamp(15px, 1.3vw, 20px); font-weight: 600; color: var(--muted); }
.tile .t-status { font-family: var(--serif); font-weight: 700; font-size: clamp(26px, 2.6vw, 44px); line-height: 1.05; }
@media (max-width: 400px) { .tile .t-status { font-size: 22px; } }   /* "Submitted" fits a 360 px phone */
.tile .t-meta { font-size: clamp(14px, 1.2vw, 19px); font-variant-numeric: tabular-nums; }
.tile.s-MISSING { background: var(--paper); box-shadow: inset 0 0 0 2px var(--red); color: var(--dark); }
.tile.s-MISSING .t-status { color: var(--red-ink); }
.tile.s-OPEN { background: var(--amber-bg); color: #4A3500; box-shadow: none; }
.tile.s-SUBMITTED { background: var(--green-bg); color: var(--green); box-shadow: none; }
.tile.s-PICKED { background: var(--green); color: #fff; box-shadow: none; }
.tile.s-SHIPPED { background: var(--dark); color: #fff; box-shadow: none; }
.tile.s-RECEIVED { background: #E9E4DC; color: var(--muted); box-shadow: none; }
.tile.s-PICKED .t-kind, .tile.s-SHIPPED .t-kind { color: rgba(255,255,255,.75); }
.tile.s-SUBMITTED .t-kind, .tile.s-OPEN .t-kind { color: inherit; opacity: .8; }

/* ── toolbar above the printable sheets ── */
.toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 0 0 16px; }
.toolbar .spacer { flex: 1; }
[data-print][hidden] { display: none; }

/* ── printable sheets: the approved legacy layout (commissary_prep_send.py CSS) ── */
.sheet { background: #fff; color: #111; font-family: Helvetica, Arial, sans-serif; padding: 16px;
         border-radius: 6px; box-shadow: 0 0 0 1px var(--rule); }
.sheet h1 { font-family: Helvetica, Arial, sans-serif; font-size: 20px; margin: 0 0 2px; text-wrap: initial; }
.sheet .sub { color: #555; font-size: 11px; margin-bottom: 8px; }
.sheet-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.prep-table { border-collapse: collapse; width: 100%; font-size: 12.5px; }
.prep-table th, .prep-table td { border-bottom: 1px solid #ddd; padding: 3px 6px; text-align: right; }
.prep-table th { background: #1f5130; color: #fff; font-size: 11.5px; white-space: nowrap; }
.prep-table td.n, .prep-table th.n { text-align: left; }
.prep-table td.u { text-align: left; color: #666; font-size: 11px; }
.prep-table td.t { font-weight: 700; font-size: 14px; background: #fff7d6; }
.prep-table td { font-variant-numeric: tabular-nums; }
.prep-table tr.cat td { background: #e6efe6; color: #1f5130; font-weight: 700; font-size: 12px; text-align: left;
                        padding-top: 6px; letter-spacing: .3px; }
.prep-table thead { display: table-header-group; }
.prep-table tr { break-inside: avoid; }
.sheet-notes { border: 2px solid #c0392b; background: #fdecea; padding: 6px 9px; margin: 0 0 9px; font-size: 12.5px;
               border-radius: 4px; white-space: pre-line; }
.sheet-notes b { color: #c0392b; }

.pack-page + .pack-page { margin-top: 20px; }
.cols { column-count: 2; column-gap: 20px; column-rule: 1px solid #ccc; }
@media (max-width: 640px) { .cols { column-count: 1; } }
.pc { font-size: 11.5px; font-weight: 700; color: #1f5130; background: #e6efe6; padding: 1px 6px; margin-top: 3px;
      letter-spacing: .3px; break-after: avoid; }
.it { display: flex; align-items: center; gap: .5em; font-size: 13px; line-height: 1.25; padding: 1px 4px;
      border-bottom: 1px solid #e8e8e8; break-inside: avoid; }
.it .b { font-size: 1.1em; color: #888; width: 1.1em; flex: none; }
.it .nm { flex: 1; min-width: 0; }
.it .q { font-weight: 700; font-size: 1.13em; min-width: 2.3em; text-align: right; font-variant-numeric: tabular-nums; }
.it .u { color: #666; font-size: .88em; min-width: 5.6em; }
.it .pk { flex: none; }
.it .pk input { width: 64px; height: 44px; font-size: 16px; text-align: center; border: 1.5px solid var(--field-line);
                border-radius: 8px; font-variant-numeric: tabular-nums; }
.it.short-pack .q { color: #c0392b; }
.pack-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 12px; }

/* ── catalog ── */
.cat-item { display: grid; gap: 2px; }
.cat-packs { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 15px; }
.cat-packs .off { color: var(--muted); text-decoration: line-through; }

/* ── sign in ── */
.auth { max-width: 420px; margin: 8vh auto 0; background: var(--paper); border-radius: 16px; padding: 24px 20px;
        box-shadow: 0 0 0 1px var(--rule), 0 8px 30px rgba(35,31,32,.08); display: grid; gap: 14px; }
.auth label { display: grid; gap: 6px; font-weight: 600; }
.auth .field { width: 100%; }
.auth .btn-primary { width: 100%; }
.auth .error { color: var(--red-ink); font-weight: 600; }
.error-page { text-align: center; margin-top: 10vh; display: grid; gap: 12px; justify-items: center; }
.error-page .code { font-family: var(--serif); font-size: 64px; color: var(--red); line-height: 1; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: 0s !important; }
}

/* ── print (Letter): only the sheet, as the legacy PDFs ── */
@page { size: Letter; margin: 9mm 8mm; }
@media print {
  body { background: #fff; font-size: 12px; }
  .top, .flashes, .toolbar, .skip, .screen-only, .bar, .pack-actions { display: none !important; }
  main, main.wide { max-width: none; padding: 0; margin: 0; }
  .sheet { padding: 0; box-shadow: none; border-radius: 0; }
  .sheet-scroll { overflow: visible; }
  .cols { column-count: 2 !important; }
  .pack-page { break-after: page; margin: 0 !important; }
  .pack-page:last-child { break-after: auto; }
  .it .pk { display: none; }
  * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}
