/* The buying side, the returns, the estimate and the money owed.
 *
 * All six screens are pages of the same register as everything else — the navy
 * band, the flat toolbar, the ruled grid — so almost nothing here is a look.
 * What IS here is the furniture those six need and no other screen does: the
 * band under a toolbar that names a bill or a supplier, the row of distributors
 * under a line of an order, and the foot that carries a total. */

/* ── The band under the toolbar ──────────────────────────────────────
 * Names the bill being returned against, or the supplier the goods are going
 * back to. It is not the page band above it: that says which page this is,
 * this says which document the page is working on. */
.ret-band {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 7px 12px;
  font-size: 12.5px;
  color: var(--ink);
  background: #f7fffd;
  border-bottom: 1px solid #b9c6dd;
}
.ret-band b { font-weight: 700; }
.ret-band .spacer { flex: 1; }

/* The supplier box, on the purchase voucher and on a purchase return. It
 * anchors the list of distributors that drops out of it, which is why it is
 * positioned at all. */
.pu-supplier { position: relative; }

/* ── Choosing a bill, or a medicine, out of a dialog ─────────────── */
.ret-find {
  width: 100%;
  margin-bottom: 10px;
  padding: 8px 10px;
  font: var(--font);
  font-size: 13px;
  border: 1px solid #c3ccdb;
  border-radius: 3px;
}
.ret-find:focus { outline: none; border-color: var(--accent); }

.ret-bills {
  max-height: 320px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 4px;
}

.ret-bill {
  display: grid;
  grid-template-columns: 1.4fr 1.6fr 1fr auto;
  gap: 10px;
  align-items: center;
  width: 100%;
  padding: 7px 10px;
  font: var(--font);
  text-align: left;
  background: none;
  border: 0;
  border-bottom: 1px solid #f2f4f8;
  cursor: pointer;
}
.ret-bill:hover { background: #fff6d8; }
.rb-no { font-weight: 700; font-size: 12.5px; }
.rb-who, .rb-when { font-size: 11.5px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; }
.rb-amt { font-weight: 700; font-size: 12.5px; text-align: right; white-space: nowrap; }

/* ── The foot: why, and what it comes to ─────────────────────────── */
.ret-foot {
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 8px 12px;
  background: var(--surface);
  border-top: 2px solid #b9c6dd;
}
.ret-why { display: flex; align-items: center; gap: 8px; flex: 1; }
.ret-why > span {
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: .07em;
  text-transform: uppercase;
  color: var(--muted);
  white-space: nowrap;
}
.ret-why input {
  flex: 1;
  padding: 6px 9px;
  font: var(--font);
  font-size: 12.5px;
  border: 1px solid #c3ccdb;
  border-radius: 3px;
}
.ret-why input:focus { outline: none; border-color: var(--accent); background: #fff6d8; }

.ret-tot { display: flex; align-items: center; gap: 16px; font-size: 12px; color: var(--muted); }
.ret-tot b { color: var(--ink); font-variant-numeric: tabular-nums; }
/* The one figure the whole screen is for. */
.ret-tot .grand {
  padding: 4px 12px;
  font-size: 12.5px;
  font-weight: 700;
  color: #fff;
  background: #102450;
  border-radius: 3px;
}
.ret-tot .grand b { color: #ffd479; font-size: 16px; margin-left: 6px; }

/* ── Who last supplied a line of the order ───────────────────────── */
.ord-sups { display: flex; flex-wrap: wrap; gap: 4px; }

.ord-sup {
  display: flex;
  align-items: baseline;
  gap: 7px;
  padding: 2px 8px;
  font: var(--font);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 3px;
  cursor: pointer;
}
.ord-sup:hover { background: #fff6d8; border-color: #d8a800; }
/* The cheapest of them, at what it ACTUALLY cost — not the rate on the bill. */
.ord-sup.best { border-color: var(--accent); background: #f0fdfa; }
.os-name { font-size: 11.5px; font-weight: 600; color: var(--ink); }
.os-cost { font-size: 11.5px; font-weight: 700; font-variant-numeric: tabular-nums; }
/* What the shop keeps on it — red is a loss, amber is barely paying for the
 * shelf the medicine sits on. */
.os-margin { font-size: 10.5px; font-weight: 800; color: #15803d; }
.os-margin.thin { color: var(--warn); }
.os-margin.loss { color: var(--danger); }

/* ── Money owed ──────────────────────────────────────────────────── */
.due-now {
  padding: 4px 12px;
  font-size: 13px;
  font-weight: 700;
  color: #7f1d1d;
  background: #fef2f2;
  border: 1px solid #fecaca;
  border-radius: 3px;
  font-variant-numeric: tabular-nums;
}

/* ── The estimate's own two boxes ────────────────────────────────── */
.est-who { flex: 0 1 240px; }
.est-phone { flex: 0 1 150px; }

/* ── The party form ──────────────────────────────────────────────────
 *
 * A distributor and a patient are asked different questions — a firm has a
 * GSTIN and a drug licence, a patient has an age and a prescriber — so the
 * form shows one set or the other rather than twelve boxes of which four
 * apply. What is shared is only the shape of it. */
.dir-form { display: flex; flex-direction: column; gap: 2px; }
/* Age and sex belong on one line: they are read together and neither is
 * wide enough to earn a row of its own. */
.dir-two { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

.modal-actions .spacer { flex: 1; }
.modal-actions .link.danger { color: var(--danger); }

/* ── Narrower than a desktop ────────────────────────────────────── */
@media (max-width: 1080px) {
  /* The reason and the total sit on one line at full width. Narrower, the
   * reason box is squeezed to nothing while the total keeps its own size —
   * so they stack, and the total stays the loud one. */
  .ret-foot { flex-wrap: wrap; row-gap: 8px; }
  .ret-why { flex: 1 1 100%; }
  .ret-tot { flex: 1 1 100%; justify-content: flex-end; }
  .ret-band { flex-wrap: wrap; row-gap: 4px; }
}

@media (max-width: 860px) {
  .ret-bill { grid-template-columns: 1fr auto; row-gap: 2px; }
  .rb-when { grid-column: 1; }
  /* Three distributors under a line of the order become a column: side by
   * side they were three names truncated to four letters each. */
  .ord-sups { flex-direction: column; align-items: stretch; }
  .dir-two { grid-template-columns: 1fr; }
}

/* What a firm will pay for what has just arrived.
 *
 * Asked here because this is the moment the chemist is holding the
 * distributor's bill with the PTR printed on it. Asked later it means
 * finding the medicine and then the batch, which is how it ends up never
 * being set at all. */
.pu-ptr input { color: #0f766e; font-weight: 600; }
.pu-ptr.undercost { background: #fff7ed; }
.pu-ptr.undercost input { color: #b45309; }

/* "Add it from Medicines first" was a dead end.
 *
 * The van is at the counter and the chemist is typing what came off it.
 * Being sent to another screen, told to fill in a form, and asked to come
 * back and start the line again is how a purchase gets entered tomorrow
 * instead of now. */
.sug-new {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  width: 100%;
  padding: 10px 12px;
  font: var(--font);
  text-align: left;
  color: var(--accent);
  background: #f1faf8;
  border: 0;
  border-left: 3px solid var(--accent);
  cursor: pointer;
}
.sug-new:hover { background: #e6f5f2; }
.sug-new .s-name { font-size: 13.5px; font-weight: 700; }
.sug-new .s-sub { font-size: 11.5px; color: var(--muted); }

/* The upload preview, edited in place.
 *
 * A sheet is never quite right: a price out of date, a pack size that says
 * "1*10" where the shop says Strip, a name with the supplier's code stuck on
 * the front. The only answer used to be closing this, fixing the spreadsheet
 * and starting again — for one wrong figure in four hundred rows. */
.ecell {
  width: 100%;
  padding: 3px 5px;
  font: var(--font);
  font-size: 12.5px;
  color: var(--ink);
  background: transparent;
  border: 1px solid transparent;
  border-radius: 4px;
}
.ecell:hover { border-color: var(--line); background: var(--surface); }
.ecell:focus {
  outline: 0;
  background: var(--surface);
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(15, 118, 110, .12);
}
.ecell.num { text-align: right; font-variant-numeric: tabular-nums; }
.ecell.narrow { max-width: 92px; }
.ecell.trade { color: #0f766e; font-weight: 600; }
/* No spinners: they are 20px of nothing on a table of four hundred rows. */
.ecell[type="number"]::-webkit-inner-spin-button,
.ecell[type="number"]::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
