/* Inventory > Batches & expiry and its pop-ups, in the Sales page family (bt4, 13 Nov 2026).
   The page is .ord2.sl4.bt4: the orders and sales kits (pages-business.css)
   with the table kept. A money card (Stock that may go to waste, with
   Expired, Expires soon, Good and No expiry date), a strip naming the one
   batch to deal with first, state tabs, What the colours mean, then the .lt
   table with a Next step column. The batch, Write off, Correct the count,
   Edit details and Add a batch pop-ups are not inside .bt4, so their rules
   are not scoped to the page. Built in assets/js/app/batches-recurring.js
   (_bt4* helpers).

   Five states, one colour each, everywhere (chips, tabs, table, pop-ups,
   help): Expired red, Expires soon amber, Good green, No expiry date grey
   (dashed: something is missing), Used up grey. Text on every fill is
   4.5:1 or better. */

/* ---- The state chip (page and pop-ups) ---- */
.bt4-chip {
    display: inline-flex; align-items: center; gap: 5px; padding: 3px 10px; border-radius: 999px;
    font-size: .74rem; font-weight: 900; line-height: 1.3; white-space: nowrap; border: 1.5px solid transparent;
}
.bt4-chip i { font-size: .78em; }
.bt4-chip.is-expired { background: #fee2e2; color: #991b1b; border-color: #fecaca; }
.bt4-chip.is-expiring { background: #fef3c7; color: #78350f; border-color: #fde68a; }
.bt4-chip.is-ok { background: #d1fae5; color: #064e3b; border-color: #a7f3d0; }
.bt4-chip.is-nodate { background: #fff; color: #1f2937; border: 1.5px dashed #6b7280; }
.bt4-chip.is-empty { background: #e5e7eb; color: #374151; }
.bt4-unknown { font-weight: 700; color: #4b5563; }

/* ---- The money card ---- */
.bt4 .bt4-hero-note { position: relative; z-index: 1; margin: 2px 0 0; font-size: .78rem; font-weight: 650; color: rgba(255, 255, 255, .92); }
.bt4 .bt4-stats { grid-template-columns: repeat(auto-fit, minmax(132px, 1fr)); }
.bt4 .bt4-stats > .bt4-fig {
    display: block; min-width: 0; padding: 10px 12px; border: 0; border-radius: 14px;
    background: rgba(255, 255, 255, .13); color: #fff; font: inherit; text-align: left; cursor: pointer;
}
.bt4 .bt4-stats > .bt4-fig:hover { background: rgba(255, 255, 255, .2); }
.bt4 .bt4-stats > .bt4-fig:focus-visible { outline: 3px solid #fff; outline-offset: 2px; }
.bt4 .bt4-stats .bt4-fig-l { display: block; font-size: .74rem; font-weight: 800; color: rgba(255, 255, 255, .92); }
.bt4 .bt4-stats .ord2-hero-fig { display: block; font-size: clamp(.98rem, 2.6vw, 1.12rem); line-height: 1.2; overflow-wrap: anywhere; }
.bt4 .bt4-stats small { display: block; margin-top: 2px; font-size: .72rem; font-weight: 700; color: rgba(255, 255, 255, .9); }
/* A small mark of each state's colour beside its label on the card. */
.bt4 .bt4-fig .bt4-fig-l::before { content: ""; display: inline-block; width: 8px; height: 8px; margin-right: 6px; border-radius: 50%; vertical-align: 1px; background: #fff; }
.bt4 .bt4-fig.is-expired .bt4-fig-l::before { background: #fecaca; box-shadow: 0 0 0 2px #fff; }
.bt4 .bt4-fig.is-expiring .bt4-fig-l::before { background: #fcd34d; }
.bt4 .bt4-fig.is-ok .bt4-fig-l::before { background: #6ee7b7; }
.bt4 .bt4-fig.is-nodate .bt4-fig-l::before { background: transparent; border: 1.5px dashed #fff; box-sizing: border-box; }
.bt4 .bt4-hero-nocost { position: relative; z-index: 1; display: flex; gap: 6px; align-items: flex-start; margin: 10px 0 0; font-size: .76rem; font-weight: 700; line-height: 1.4; color: #fff; }

/* ---- The strip: the batch to deal with first ----
   Red while a batch has expired, amber while one expires soon, green when
   nothing is at risk, teal for an invitation. The buttons sit on their own row. */
.bt4 .bt4-strip { flex-wrap: wrap; align-items: flex-start; align-content: space-between; row-gap: 12px; }
.bt4 .bt4-strip > div:not(.bt4-strip-acts) { flex: 1 1 0; min-width: 0; }
.bt4 .bt4-strip b { line-height: 1.3; overflow-wrap: anywhere; }
.bt4 .bt4-strip > div > span { display: block; margin-top: 2px; line-height: 1.45; }
.bt4 .bt4-strip-acts { flex: 1 1 100%; display: flex; flex-wrap: wrap; gap: 8px; }
.bt4 .ord2-strip .bt4-strip-acts button { flex: 1 1 auto; }
.bt4 .ord2-strip .bt4-strip-acts button.is-ghost { background: #fff; color: #78350f; border: 1px solid #fcd34d; }
.bt4 .bt4-strip.is-late { background: #fef2f2; border-color: #fca5a5; }
.bt4 .bt4-strip.is-late .ord2-strip-ic { background: #fee2e2; color: #b91c1c; }
.bt4 .bt4-strip.is-late b { color: #7f1d1d; }
.bt4 .bt4-strip.is-late span { color: #991b1b; }
.bt4 .ord2-strip.is-late .bt4-strip-acts button:not(.is-ghost) { background: #b91c1c; }
.bt4 .ord2-strip.is-late .bt4-strip-acts button.is-ghost { color: #7f1d1d; border-color: #fca5a5; }
.bt4 .ord2-strip.is-late .bt4-strip-acts button:focus-visible { outline-color: #fca5a5; }
.bt4 .bt4-strip.is-done { background: #ecfdf5; border-color: #a7f3d0; }
.bt4 .bt4-strip.is-done .ord2-strip-ic { background: #d1fae5; color: #047857; }
.bt4 .bt4-strip.is-done b { color: #064e3b; }
.bt4 .bt4-strip.is-done span { color: #065f46; }
.bt4 .ord2-strip.is-done .bt4-strip-acts button:not(.is-ghost) { background: #047857; }
.bt4 .ord2-strip.is-done .bt4-strip-acts button.is-ghost { color: #064e3b; border-color: #6ee7b7; }
.bt4 .ord2-strip.is-done .bt4-strip-acts button:focus-visible { outline-color: #6ee7b7; }
.bt4 .bt4-strip.is-start { background: #f0fdfa; border-color: #99f6e4; }
.bt4 .bt4-strip.is-start .ord2-strip-ic { background: #ccfbf1; color: #0f766e; }
.bt4 .bt4-strip.is-start b { color: #134e4a; }
.bt4 .bt4-strip.is-start span { color: #115e59; }
.bt4 .ord2-strip.is-start .bt4-strip-acts button:not(.is-ghost) { background: #0f766e; }
.bt4 .ord2-strip.is-start .bt4-strip-acts button.is-ghost { color: #134e4a; border-color: #5eead4; }
.bt4 .ord2-strip.is-start .bt4-strip-acts button:focus-visible { outline-color: #5eead4; }

/* ---- Tabs: Expired turns red while anything has expired ---- */
.bt4 .ord2-tab.is-late:not(.is-on) { border-color: #fca5a5; color: #991b1b; }
.bt4 .ord2-tab.is-on.is-late { background: #991b1b; border-color: #991b1b; }

/* ---- What the colours mean ---- */
.bt4 .bt4-legend { margin: 0 0 14px; border: 1px solid #e3e7ef; border-radius: 16px; background: #fff; }
.bt4 .bt4-legend > summary {
    display: flex; align-items: center; gap: 8px; min-height: 44px; padding: 0 14px; list-style: none; cursor: pointer;
    font-size: .86rem; color: #000;
}
.bt4 .bt4-legend > summary::-webkit-details-marker { display: none; }
.bt4 .bt4-legend > summary > i { color: #be123c; }
.bt4 .bt4-legend > summary b { flex: 1; font-weight: 900; }
.bt4 .bt4-legend > summary::after { content: ""; flex: none; width: 8px; height: 8px; margin-top: -4px; border-right: 2.5px solid #111827; border-bottom: 2.5px solid #111827; transform: rotate(45deg); }
.bt4 .bt4-legend[open] > summary::after { margin-top: 4px; transform: rotate(-135deg); }
.bt4 .bt4-legend > summary:focus-visible { outline: 3px solid #93c5fd; outline-offset: 2px; border-radius: 16px; }
.bt4 .bt4-legend-in { padding: 2px 14px 12px; border-top: 1px solid #eef0f5; }
.bt4 .bt4-legend ul { list-style: none; margin: 0; padding: 10px 0 4px; display: grid; gap: 8px; }
.bt4 .bt4-legend li { display: flex; align-items: center; gap: 10px; font-size: .84rem; font-weight: 700; line-height: 1.35; color: #000; }
.bt4 .bt4-legend li .bt4-chip { flex: none; min-width: 128px; justify-content: flex-start; box-sizing: border-box; }
.bt4 .bt4-legend p { display: flex; gap: 8px; align-items: flex-start; margin: 6px 0 0; font-size: .82rem; font-weight: 700; line-height: 1.4; color: #1f2937; }
.bt4 .bt4-legend p i { flex: none; margin-top: 1px; color: #be123c; }
@media (min-width: 900px) {
    .bt4 .bt4-legend ul { grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: 18px; }
}

/* ---- The table ---- */
.bt4 .lt-sub { color: #4b5563; }
.bt4 .lt-sub .bt4-no { color: #1f2937; }
.bt4 .lt-sub .bt4-from { font-weight: 650; overflow-wrap: anywhere; }
.bt4 .bt4-exp { display: inline-flex; flex-direction: column; line-height: 1.25; }
.bt4 .bt4-exp b { font-weight: 800; color: #000; }
.bt4 .bt4-exp.is-none b { font-weight: 700; color: #374151; }
.bt4 .bt4-exp small { margin-top: 2px; font-size: .72rem; font-weight: 800; color: #374151; }
.bt4 .bt4-exp small.is-expired { color: #b91c1c; }
.bt4 .bt4-exp small.is-expiring { color: #92400e; }
.bt4 .bt4-exp small.is-ok { color: #047857; }
.bt4 .bt4-left { color: #374151; }
.bt4 .bt4-left b { font-weight: 900; color: #000; }
.bt4 .lt-dim .bt4-chip { opacity: .85; }
/* Next step: Write off is red, Add date is outlined blue. */
.bt4 .sl4-pay.bt4-go.is-off { background: linear-gradient(180deg, #dc2626, #b91c1c); }
.bt4 .sl4-pay.bt4-go.is-off:focus-visible { outline-color: #fca5a5; }
.bt4 .sl4-pay.bt4-go.is-date { background: #fff; color: #1e3a8a; border: 1.5px solid #93c5fd; }
.bt4 .sl4-pay.bt4-go.is-date:focus-visible { outline-color: #93c5fd; }
.bt4 .sx-act.sl4-act-pay.bt4-act-off { background: #b91c1c; border-color: #b91c1c; color: #fff; }
.bt4 .sx-act.sl4-act-pay.bt4-act-date { background: #eff6ff; border-color: #93c5fd; color: #1e3a8a; }
.bt4 .sx-act.bt4-act-del { color: #991b1b; border-color: #fecaca; }
.bt4 .sl4-sum { margin-bottom: 12px; }
/* On a phone: product, expiry and how many are left fit across; the Status
   chip steps aside and the countdown carries the state's icon and colour. */
.bt4 .bt4-exp small i { display: none; margin-right: 4px; font-size: .9em; }
@media (max-width: 560px) {
    #page-content .bt4 .lt-table .lt-main { min-width: 120px; max-width: 132px; }
    #page-content .bt4 .lt-table th, #page-content .bt4 .lt-table td { padding-left: 9px; padding-right: 9px; }
    #page-content .bt4 .lt-table .bt4-stc { display: none; }
    .bt4 .bt4-left .bt4-of { display: none; }
    .bt4 .bt4-exp small i { display: inline; }
}

/* ---- One batch ---- */
/* Where it stands, and what to do, in the state's colour. */
.bt4-state { display: flex; flex-direction: column; gap: 10px; padding: 14px; border-radius: 16px; border: 1.5px solid; }
.bt4-state-top { display: flex; align-items: center; gap: 12px; }
.bt4-state-top > div { flex: 1; min-width: 0; }
.bt4-state-ic { flex: none; width: 46px; height: 46px; display: grid; place-items: center; border-radius: 14px; font-size: 1.3rem; }
.bt4-state b { display: block; font-size: 1.22rem; font-weight: 900; line-height: 1.2; }
.bt4-state-top > div > span { display: block; margin-top: 2px; font-size: .86rem; font-weight: 800; }
.bt4-state p { margin: 0; font-size: .9rem; font-weight: 700; line-height: 1.45; }
.bt4-state.is-expired { background: #fef2f2; border-color: #fca5a5; color: #7f1d1d; }
.bt4-state.is-expired .bt4-state-ic { background: #b91c1c; color: #fff; }
.bt4-state.is-expiring { background: #fffbeb; border-color: #fcd34d; color: #78350f; }
.bt4-state.is-expiring .bt4-state-ic { background: #fef3c7; color: #92400e; box-shadow: inset 0 0 0 1.5px #f59e0b; }
.bt4-state.is-ok { background: #ecfdf5; border-color: #a7f3d0; color: #064e3b; }
.bt4-state.is-ok .bt4-state-ic { background: #d1fae5; color: #047857; }
.bt4-state.is-nodate { background: #f8fafc; border-style: dashed; border-color: #6b7280; color: #111827; }
.bt4-state.is-nodate .bt4-state-ic { background: #e5e7eb; color: #1f2937; }
.bt4-state.is-empty { background: #f3f4f6; border-color: #d1d5db; color: #111827; }
.bt4-state.is-empty .bt4-state-ic { background: #e5e7eb; color: #374151; }

/* The shelf-life bar: received, today and the expiry date on one line. */
.bt4-tl { position: relative; padding: 0 2px; }
.bt4-tl-top { position: relative; height: 22px; }
.bt4-tl-now { position: absolute; bottom: 4px; transform: translateX(-50%); padding: 1px 7px; border-radius: 999px; background: #111827; color: #fff; font-size: .7rem; font-weight: 900; white-space: nowrap; }
.bt4-tl-now.is-l { transform: none; }
.bt4-tl-now.is-r { transform: translateX(-100%); }
.bt4-tl-bar { position: relative; height: 16px; border-radius: 999px; background: #e5e7eb; overflow: visible; }
.bt4-tl-bar > i { position: absolute; top: 0; bottom: 0; display: block; }
.bt4-tl-warn { background: repeating-linear-gradient(135deg, #fde68a 0 5px, #fcd34d 5px 10px); border-radius: 0 999px 999px 0; }
.bt4-tl-fill { left: 0; border-radius: 999px; background: #059669; }
.bt4-tl.is-expiring .bt4-tl-fill { background: #d97706; }
.bt4-tl.is-expired .bt4-tl-fill { background: #dc2626; border-radius: 999px 0 0 999px; }
.bt4-tl-over { background: repeating-linear-gradient(135deg, #b91c1c 0 5px, #f87171 5px 10px); border-radius: 0 999px 999px 0; }
.bt4-tl-end { width: 3px; margin-left: -1.5px; top: -4px !important; bottom: -4px !important; border-radius: 2px; background: #7f1d1d; }
.bt4-tl-mark { width: 4px; margin-left: -2px; top: -6px !important; bottom: -6px !important; border-radius: 2px; background: #111827; box-shadow: 0 0 0 2px #fff; }
.bt4-tl-ends { position: relative; height: 38px; margin-top: 8px; }
.bt4-tl-ends > span { position: absolute; top: 0; display: flex; flex-direction: column; line-height: 1.2; white-space: nowrap; }
.bt4-tl-ends .is-start { left: 0; }
.bt4-tl-ends .is-end { text-align: right; align-items: flex-end; }
.bt4-tl-ends small { font-size: .7rem; font-weight: 800; color: #374151; }
.bt4-tl-ends b { font-size: .86rem; font-weight: 900; color: #000; }
.bt4-tl.is-expired .bt4-tl-ends .is-end small, .bt4-tl.is-expired .bt4-tl-ends .is-end b { color: #991b1b; }
.bt4-tl-cap { margin: 0; font-size: .88rem; font-weight: 800; color: #000; }
.bt4-tl-key { display: flex; flex-wrap: wrap; gap: 6px 14px; margin: 0; font-size: .74rem; font-weight: 700; color: #374151; }
.bt4-tl-key span { display: inline-flex; align-items: center; gap: 6px; }
.bt4-tl-key i { display: inline-block; width: 18px; height: 10px; border-radius: 4px; }
.bt4-tl-key i.is-warn { background: repeating-linear-gradient(135deg, #fde68a 0 4px, #fcd34d 4px 8px); }
.bt4-tl-key i.is-over { background: repeating-linear-gradient(135deg, #b91c1c 0 4px, #f87171 4px 8px); }

/* Facts, one per row: what it is on the left, the answer on the right. */
.bt4-facts { margin: 0; display: flex; flex-direction: column; }
.bt4-facts > div { display: grid; grid-template-columns: minmax(0, 7.5rem) minmax(0, 1fr); gap: 10px; padding: 8px 0; border-top: 1px solid #eef0f5; }
.bt4-facts > div:first-child { border-top: 0; padding-top: 0; }
.bt4-facts dt { font-size: .8rem; font-weight: 800; color: #374151; }
.bt4-facts dd { margin: 0; min-width: 0; font-size: .88rem; font-weight: 700; color: #000; overflow-wrap: anywhere; }
.bt4-facts dd b { font-weight: 900; }
.bt4-facts .ord2-link { font-size: .84rem; }

/* What happened to it, newest first. */
.bt4-moves { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.bt4-mv { display: flex; gap: 10px; align-items: flex-start; padding: 8px 0; border-top: 1px solid #eef0f5; }
.bt4-mv:first-child { border-top: 0; padding-top: 0; }
.bt4-mv > div { flex: 1; min-width: 0; }
.bt4-mv b { display: block; font-size: .86rem; font-weight: 800; color: #000; overflow-wrap: anywhere; }
.bt4-mv > div > span { display: block; margin-top: 1px; font-size: .74rem; font-weight: 700; color: #4b5563; }
.bt4-mv-ic { flex: none; width: 30px; height: 30px; display: grid; place-items: center; border-radius: 9px; font-size: .9rem; background: #f3f4f6; color: #374151; }
.bt4-mv.is-in .bt4-mv-ic { background: #d1fae5; color: #047857; }
.bt4-mv.is-out .bt4-mv-ic { background: #dbeafe; color: #1d4ed8; }
.bt4-mv.is-off .bt4-mv-ic { background: #fee2e2; color: #b91c1c; }

.bt4-det .rec-by { margin: 0; }
.bt4-det .ord2-panel-h span { overflow-wrap: anywhere; }
body .modal-overlay .modal-actions.ord2-det-acts .ord2-go.bt4-go-off { background: linear-gradient(180deg, #dc2626, #b91c1c); box-shadow: 0 8px 18px -10px rgba(185, 28, 28, .7); }
body .modal-overlay .modal-actions.ord2-det-acts .ord2-go.bt4-go-off:focus-visible { outline-color: #fca5a5; }
body .modal-overlay .modal-actions.ord2-det-acts > .ord2-two.bt4-acts3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
body .modal-overlay .modal-actions.ord2-det-acts > .bt4-acts3 .ord2-btn { padding: 0 8px; }
@media (max-width: 420px) {
    body .modal-overlay .modal-actions.ord2-det-acts > .ord2-two.bt4-acts3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    body .modal-overlay .modal-actions.ord2-det-acts > .bt4-acts3 .ord2-btn:last-child { grid-column: 1 / -1; }
}

/* ---- Write off, Correct the count, Edit details, Add a batch (.fm4) ---- */
.bt4-form .bt4-head .bt4-chip { flex: none; }
.bt4-form .bt4-head span { overflow-wrap: anywhere; }
.bt4-form .bt4-some { display: flex; flex-direction: column; gap: 6px; padding-top: 2px; }
.bt4-form .bt4-some[hidden], .bt4-form .bt4-add-form[hidden] { display: none; }
.bt4-form .bt4-some .fm4-hint { margin: 0; }
.bt4-form .bt4-add-form { display: flex; flex-direction: column; gap: 14px; }
.bt4-form .bt4-count-row { display: flex; align-items: center; flex-wrap: wrap; gap: 8px 12px; }
.bt4-form .bt4-unit { font-size: .9rem; font-weight: 900; color: #374151; }
.bt4-form .bt4-diff { margin: 0; padding: 4px 10px; border-radius: 999px; background: #f3f4f6; color: #1f2937; font-size: .82rem; font-weight: 900; }
.bt4-form .bt4-diff.is-less { background: #fee2e2; color: #991b1b; }
.bt4-form .bt4-diff.is-more { background: #d1fae5; color: #064e3b; }
.bt4-form .fm4-card > .fm4-hint { margin: 0; }
.bt4-form .fm4-note b { margin-bottom: 2px; }
.bt4-form #bt4-add-chosen[hidden], .bt4-form #bt4-add-find[hidden] { display: none; }
.bt4-form .fm4-chosen .fm4-link { flex: none; }
/* Save tapped with a question unanswered (App._fm4Need): a red ring on that card. */
.bt4-form .fm4-card.is-need { border-color: #dc2626; box-shadow: 0 0 0 2px #dc2626; animation: fm4-need .32s ease; }
@media (prefers-reduced-motion: reduce) { .bt4-form .fm4-card.is-need { animation: none; } }
