/* Logistics: the delivery cash remittance form.
   Owned by public/js/stock.js and loaded after /styles.css. Class names here belong to this module;
   a look shared by several modules goes in /styles.css (npm run check-styles enforces this). */

/* ---------- month count ---------- */
.count-row { padding: .7rem 0; border-bottom: 1px solid var(--border); }
.count-row:last-child { border-bottom: 0; }
.count-main { display: grid; grid-template-columns: minmax(8rem, 1fr) 6rem minmax(14rem, 1.4fr) 6rem 7rem; gap: .75rem; align-items: center; }
.count-figure { display: flex; flex-direction: column; text-align: right; }
.count-entry { display: flex; gap: .4rem; align-items: center; }
.count-input { flex: 1; min-width: 0; text-align: right; }
.count-loads { margin-top: .4rem; font-size: .85rem; }
.count-loads .check { display: flex; gap: .4rem; margin: .25rem 0; }
@media (max-width: 640px) {
  .count-main { grid-template-columns: 1fr 1fr; }
  .count-name, .count-entry { grid-column: 1 / -1; }
  .count-figure { text-align: left; }
}

/* ---------- delivery cash remittance ---------- */
.given-cell { white-space: nowrap; }
.given-input { width: 6.5rem; padding: .3rem .45rem; text-align: right; }
.given-cell .btn { margin-left: .25rem; }
tr.given-row td { background: var(--accent-soft); }
.form-head { justify-content: space-between; align-items: flex-end; gap: 1rem; border-bottom: 3px solid #1b2a5e; padding-bottom: .5rem; margin-bottom: .6rem; }
.form-head .p-company { color: #1b2a5e; font-weight: 800; font-size: 1.2rem; }
.form-title { text-align: right; }
.form-title h2 { margin: 0; color: #8a1c27; letter-spacing: .04em; }
.form-foot { margin-top: 1.5rem; }

/* The remittance form has many columns, so it alone prints landscape */
@page remit { size: landscape; margin: 10mm; }

/* Bricks received: one card per manufacturer, then its own deliveries and prices */
.price-change { font-size: .8em; font-weight: 600; }
.price-change.up { color: var(--danger); }
.price-change.down { color: var(--ok); }
.back-btn { padding: 0; margin-bottom: .4rem; }

/* Changes to bricks received waiting for Finance and the CEO */
.stock-changes { border-left: 4px solid var(--copper); }
.stock-change { display: flex; flex-wrap: wrap; justify-content: space-between; gap: .5rem 1rem; padding: .6rem 0; border-top: 1px solid var(--border); }
.stock-change:first-of-type { border-top: 0; }

/* ---------- Balances as cards (Stock › Balances) ---------- */
/* The card keeps its own width whatever the figures (one column that may shrink), and is the size the figures
   inside follow (cqi = 1% of the card's width), so big numbers get smaller instead of running past the edge */
.bal-card { border-top: 3px solid var(--ok); grid-template-columns: minmax(0, 1fr); container-type: inline-size; }
.bal-card.bal-short { border-top-color: var(--danger); }
.bal-card.bal-empty { border-top-color: var(--border); }
.bal-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-end; gap: .3rem .75rem; }
.bal-big { font-size: clamp(1.4rem, 10cqi, 1.9rem); font-weight: 800; line-height: 1.1; letter-spacing: -.01em; }
.bal-worth { text-align: right; margin-left: auto; }
.bal-worth strong { font-size: clamp(.95rem, 5.5cqi, 1.1rem); }
.bal-share { height: 6px; border-radius: 999px; background: var(--surface-2); overflow: hidden; }
.bal-share span { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--accent), var(--ok)); }
.bal-flow { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: .25rem; padding: .55rem .5rem; border-radius: 8px; background: var(--surface-2); }
.bal-step { display: grid; gap: .1rem; text-align: center; min-width: 0; }
.bal-step strong { font-size: clamp(.74rem, 4.1cqi, .95rem); font-variant-numeric: tabular-nums; white-space: nowrap; }
/* A very narrow card: Opening and In above, Out and Closing below */
@container (max-width: 270px) { .bal-flow { grid-template-columns: repeat(2, minmax(0, 1fr)); row-gap: .45rem; } }
.bal-others { margin-top: .8rem; }
.bal-others h3 { margin: 0 0 .2rem; }
.bal-others-list { display: flex; flex-wrap: wrap; gap: .4rem .9rem; }
/* A company in the list, with management's switch beside it */
.bal-other { display: inline-flex; align-items: center; gap: .35rem; }

/* Minimum prices below what the bricks now cost (Stock › Balances) */
.min-check { border-left: 4px solid var(--copper); margin-bottom: .8rem; }
.min-check h3 { margin: 0 0 .2rem; }
.min-check-list { list-style: none; margin: .4rem 0 0; padding: 0; display: grid; gap: .45rem; }
.min-check-list li { display: flex; justify-content: space-between; align-items: center; gap: .75rem; flex-wrap: wrap; }

/* Remittance form: notes kept short on screen; the two blank sheets start on their own page with tall rows to write in */
.remit-note { min-width: 11rem; max-width: 16rem; }
@media print {
  .remit-blank { break-before: page; }
  .remit-blank h3 { font-size: 11pt; margin: 0 0 .4rem; }
  /* About 1 cm per load (the CEO, 10 November 2026): room to write the amount given and sign by hand */
  .remit-table tbody tr:not(.subtotal) td { height: 10mm; vertical-align: top; }
  .remit-blank td { height: 10mm; }
}

/* The CEO's corrections in the Dispatch file; bricks received without the manufacturer's receipt (GAKA 1.77.0) */
.receipt-warn { margin: .5rem 0; padding: .6rem .8rem; border-radius: 10px; background: color-mix(in srgb, var(--warn, #d97706) 14%, transparent); color: var(--text); font-size: .9rem; }
.corrected-mark { margin-left: .35rem; cursor: help; }
.removed-lines { margin-top: .75rem; padding-top: .5rem; border-top: 1px dashed var(--border); }
.removed-lines h3 { font-size: .95rem; margin: 0 0 .3rem; }
.removed-lines p { margin: .2rem 0; }
.icon-btn.tiny.danger { color: var(--danger, #e5484d); }

/* A receipt's picture, small, in the Dispatch file and Bricks received (GAKA 1.80.6): pressing it opens the viewer */
.receipt-thumb { display: inline-block; margin: .2rem .3rem 0 0; vertical-align: middle; }
.receipt-thumb img { width: 56px; height: 56px; object-fit: cover; border-radius: 8px; border: 1px solid var(--border); display: block; }
.receipt-thumb:hover img { border-color: var(--accent); }

/* Bricks received waiting for the CEO (GAKA 1.81.0) */
.stock-waiting { border-left: 4px solid var(--warn, #d97706); }
.stock-waiting-list { display: grid; gap: .5rem; }
.stock-waiting-row { display: flex; align-items: center; gap: .8rem; flex-wrap: wrap; padding: .6rem .7rem; border-radius: 10px; background: var(--surface-2); }
.stock-waiting-main { flex: 1; min-width: 200px; display: grid; gap: .15rem; }

/* Bricks received in the Dispatch file: a green row with a green left edge, an IN badge, the bricks in bold green (GAKA 1.82.8) */
tr.row-in td { background: color-mix(in srgb, var(--ok) 22%, transparent); }
tr.row-in td:first-child { box-shadow: inset 4px 0 0 var(--ok); }
.in-badge { display: inline-block; padding: .1rem .5rem; border-radius: 999px; background: var(--ok); color: #fff; font-weight: 800; font-size: .78rem; letter-spacing: .04em; }
td.in-qty { color: var(--ok); font-weight: 800; }
@media print { tr.row-in td { background: #e6f4ea; } .in-badge { background: #1e7a46; } td.in-qty { color: #1e7a46; } }

/* GAKA 1.88.6: Change beside a receipt picture */
.receipt-change { margin-left: .4rem; vertical-align: middle; }
/* GAKA 1.88.7: "Stock not held by us" chips wrap on a phone instead of running off the screen */
.bal-other { max-width: 100%; }
.bal-other .chip { white-space: normal; text-align: left; max-width: 100%; overflow-wrap: anywhere; }

/* Possible duplicates (GAKA 1.145.0): each pair side by side, the earlier load (kept) and the later one, with why they
   look the same and the three answers */
.dup-list { display: grid; gap: .9rem; }
.dup-pair { display: grid; gap: .75rem; padding: 1rem; border-left: 4px solid var(--copper, #d08a3c); }
.dup-pair.strong { border-left-color: var(--danger); }
.dup-pair-head { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem .8rem; }
.dup-reasons { display: flex; flex-wrap: wrap; gap: .3rem; }
.dup-reasons .chip { cursor: default; font-size: .78rem; padding: .15rem .6rem; }
.dup-sides { display: grid; grid-template-columns: 1fr auto 1fr; gap: .6rem; align-items: stretch; }
.dup-vs { align-self: center; font-size: 1.4rem; font-weight: 800; color: var(--muted); }
.dup-load { display: grid; gap: .45rem; padding: .75rem .85rem; border: 1px solid var(--border); border-radius: 12px; background: var(--surface-2); min-width: 0; }
.dup-load.keep { background: var(--surface); }
.dup-load-head { display: flex; flex-wrap: wrap; align-items: center; gap: .4rem; }
.dup-id { font-weight: 800; font-size: 1.02rem; }
.dup-facts { display: grid; gap: .2rem; font-size: .88rem; }
.dup-facts small { display: inline-block; min-width: 4.6rem; }
.dup-actions { display: flex; flex-wrap: wrap; gap: .45rem; }
.tab-count:not(:empty) { margin-left: .35rem; padding: 0 .45rem; border-radius: 999px; background: var(--danger); color: #fff; font-size: .75rem; font-weight: 700; }
@media (max-width: 640px) {
  .dup-sides { grid-template-columns: 1fr; }
  .dup-vs { justify-self: center; line-height: 1; }
}

/* Dispatch file (GAKA 1.151.1): the manufacturer drop-down, first in the toolbar */
.file-toolbar { align-items: center; gap: .6rem; }
.file-supplier { display: inline-flex; align-items: center; gap: .55rem; padding: .25rem .3rem .25rem .85rem; border: 1px solid var(--accent); border-radius: 12px;
  background: color-mix(in srgb, var(--accent) 10%, var(--surface)); }
.file-supplier-label { font-size: .78rem; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); }
.file-supplier-select { min-width: 13rem; padding: .5rem 2.2rem .5rem .8rem; border: 0; border-radius: 9px; background-color: var(--surface); color: var(--text);
  font: inherit; font-size: 1.05rem; font-weight: 700; cursor: pointer; }
.file-supplier-select:focus-visible { outline: 3px solid color-mix(in srgb, var(--accent) 45%, transparent); outline-offset: 1px; }
@media (max-width: 560px) { .file-supplier { width: 100%; } .file-supplier-select { flex: 1; min-width: 0; } }

/* How long stock lasts (GAKA 1.147.0): the most urgent first, coloured by how soon it runs out */
.forecast-card { margin: .6rem 0 1rem; }
.forecast-card .task-top { display: flex; flex-wrap: wrap; align-items: baseline; gap: .3rem 1rem; }
.fc-badge { font-weight: 700; white-space: nowrap; }
.fc-badge.bad { background: color-mix(in srgb, var(--danger) 18%, transparent); color: var(--danger); }
.fc-badge.warn { background: color-mix(in srgb, var(--copper, #d08a3c) 20%, transparent); color: var(--copper, #d08a3c); }
.fc-badge.ok { background: color-mix(in srgb, var(--ok) 16%, transparent); color: var(--ok); }
.forecast-card tr.fc-out td, .forecast-card tr.fc-low td { background: color-mix(in srgb, var(--danger) 6%, transparent); }


/* How long stock lasts, the table (GAKA 1.151.2): fixed, even columns, every row the same height, numbers on one edge */
.fc-table { table-layout: fixed; width: 100%; }
.fc-table th, .fc-table td { padding: .65rem .7rem; vertical-align: middle; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fc-table th:nth-child(1) { width: 15%; }
.fc-table th:nth-child(2), .fc-table th:nth-child(3), .fc-table th:nth-child(4), .fc-table th:nth-child(5) { width: 10%; }
.fc-table th:nth-child(6) { width: 8%; }
.fc-table th:nth-child(7) { width: 9%; }
.fc-table th:nth-child(8) { width: 14%; }
.fc-table th:nth-child(9) { width: 14%; }
.fc-table th { white-space: normal; overflow: visible; text-overflow: clip; vertical-align: bottom; line-height: 1.25; }
.fc-table .fc-status { text-align: center; }
.fc-table td.neg { color: var(--danger); }
.fc-foot { margin: .6rem 0 0; }
@media (max-width: 900px) {
  /* A smaller screen: manufacturer, available, how long, order and status */
  .fc-table th:nth-child(2), .fc-table td:nth-child(2), .fc-table th:nth-child(3), .fc-table td:nth-child(3),
  .fc-table th:nth-child(5), .fc-table td:nth-child(5), .fc-table th:nth-child(7), .fc-table td:nth-child(7) { display: none; }
  .fc-table th:nth-child(1) { width: 26%; } .fc-table th:nth-child(4) { width: 20%; } .fc-table th:nth-child(6) { width: 14%; }
  .fc-table th:nth-child(8) { width: 20%; } .fc-table th:nth-child(9) { width: 20%; }
}
@media (max-width: 560px) {
  /* A phone: manufacturer, available, how long; the level shows as the colour of "Lasts" */
  .fc-table th:nth-child(8), .fc-table td:nth-child(8), .fc-table th:nth-child(9), .fc-table td:nth-child(9) { display: none; }
  .fc-table th:nth-child(1) { width: 42%; } .fc-table th:nth-child(4) { width: 30%; } .fc-table th:nth-child(6) { width: 28%; }
  .fc-table td.fc-lasts.bad { color: var(--danger); } .fc-table td.fc-lasts.warn { color: var(--copper, #d08a3c); } .fc-table td.fc-lasts.ok { color: var(--ok); }
  .fc-table th, .fc-table td { padding: .55rem .4rem; font-size: .9rem; }
}

/* Dispatch file ledger: when each line was recorded, under its date (GAKA 1.151.4) */
.ledger-time { display: block; margin-top: .15rem; font-size: .76rem; font-weight: 500; color: var(--muted); }

/* The buying-price check (GAKA 1.152.0): a question per manufacturer, with its two answers */
.price-check { border-left: 4px solid var(--copper, #d08a3c); margin-bottom: 1rem; }
.price-check-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: .3rem 1rem; margin-bottom: .4rem; }
.price-check-head h2 { margin: 0; }
.price-check-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .6rem 1rem; padding: .75rem 0; border-top: 1px solid var(--border); }
.price-check-row.out .price-check-text strong { color: var(--danger); }
.price-check-text { flex: 1 1 22rem; min-width: 0; }
.price-check-text .block { margin-top: .2rem; }
.price-check-actions { display: flex; flex-wrap: wrap; gap: .5rem; }
@media (max-width: 560px) { .price-check-actions, .price-check-actions .btn { width: 100%; } .price-check-actions .btn { flex: 1; } }
