@charset "UTF-8";
/* panels-and-lists.css — Pop-up panels (modal), table cells, printout styles, bank details,
   export menu, list links and row action icons.
   Loaded in order by templates/partials/styles.html. */

/* ============================ 20. Modal =================================== */
/* Centred dialog on desktop; a near-full-height sheet on phones so the form
   has room and the keyboard doesn't cover the fields. */
.modal {
  position: fixed;
  inset: 0;
  z-index: 960;
}
.modal[hidden] {
  display: none;
}
.modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(16, 17, 31, 0.55);
  backdrop-filter: blur(2px);
  opacity: 0;
  transition: opacity var(--t);
}
.modal.is-open .modal__backdrop {
  opacity: 1;
}

.modal__panel {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -46%);
  width: min(880px, calc(100vw - 2 * var(--s-4)));
  max-height: min(86vh, 900px);
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-lg);
  opacity: 0;
  transition: opacity var(--t), transform var(--t);
}
.modal.is-open .modal__panel {
  opacity: 1;
  transform: translate(-50%, -50%);
}

.modal__head,
.modal__foot {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  padding: var(--s-4) var(--s-5);
  flex: 0 0 auto;
}
.modal__head {
  justify-content: space-between;
  border-bottom: 1px solid var(--border);
}
.modal__head h2 {
  margin: 0;
  font-size: var(--fs-lg);
}
.modal__foot {
  justify-content: flex-end;
  border-top: 1px solid var(--border);
  padding-bottom: max(var(--s-4), env(safe-area-inset-bottom, 0px));
}

/* the only scrolling region, so head and footer stay put */
.modal__body {
  padding: var(--s-5);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  flex: 1 1 auto;
}

.modal__panel form {
  display: contents;
}

/* auto-fitting columns: 3-up on wide, 2-up on tablet, 1-up on phone,
   with no media query needed for the columns themselves */
.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: var(--s-3) var(--s-4);
}
.form-grid .field--wide {
  grid-column: 1 / -1;
}
.form-grid .req {
  color: var(--danger);
}
.field-error {
  font-size: var(--fs-sm);
  color: var(--danger);
}
.form-alert {
  padding: var(--s-3) var(--s-4);
  margin-bottom: var(--s-4);
  border-radius: var(--r-md);
  background: color-mix(in srgb, var(--danger) 12%, transparent);
  color: var(--danger);
}
.form-grid input[type="file"] {
  width: 100%;
  font-size: var(--fs-sm);
}
/* radios (price inclusive/exclusive) read better stacked */
.form-grid ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: var(--s-3);
}
.form-grid ul label {
  font-weight: 400;
  display: inline-flex;
  align-items: center;
  gap: var(--s-2);
}

@media (max-width: 640px) {
  .modal__panel {
    inset: auto 0 0 0;
    left: 0;
    top: auto;
    transform: translateY(100%);
    width: 100%;
    max-height: 92vh;
    border-radius: var(--r-xl) var(--r-xl) 0 0;
    border-bottom: 0;
  }
  .modal.is-open .modal__panel {
    transform: translateY(0);
  }
  .modal__head,
  .modal__body,
  .modal__foot {
    padding-left: var(--s-4);
    padding-right: var(--s-4);
  }
  .modal__foot .btn {
    flex: 1 1 auto;
    justify-content: center;
  }
}

/* ---- right-hand panel: <div class="modal modal--right"> ---------------------
   Same markup and script as the centred modal, but the panel runs the full
   height of the screen and slides in from the right edge — a short form
   beside the list it adds to. Sits after the phone rules above so it wins at
   every width (on a phone it is a full-width sheet from the right).
   The transition stays under the 300ms that modals.js waits before hiding. */
.modal--right .modal__panel {
  inset: 0 0 0 auto;
  left: auto;
  top: 0;
  width: min(440px, 100vw);
  height: 100%;
  max-height: none;
  border-radius: var(--r-xl) 0 0 var(--r-xl);
  border-right: 0;
  border-bottom: 1px solid var(--border);
  opacity: 1;
  transform: translateX(100%);
  transition: transform var(--t);
}
.modal--right.is-open .modal__panel {
  transform: translateX(0);
}
@media (max-width: 480px) {
  .modal--right .modal__panel {
    border-radius: 0;
    border-left: 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  .modal__backdrop,
  .modal__panel {
    transition: none;
  }
}


/* ======================= 21. Product table cells ========================== */
.cell-img {
  width: 44px;
  height: 44px;
  object-fit: cover;
  border-radius: var(--r-md);
  border: 1px solid var(--border);
  background: var(--bg);
  display: block;
}

/* keep long descriptions from stretching the row */
.cell-desc {
  max-width: 260px;
  color: var(--text-2);
  font-size: var(--fs-sm);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

@media (max-width: 860px) {
  /* On a phone each row becomes a card, so only the fields worth reading
     there are kept: name, price, stock, status, description. Image, part
     no, brand and unit stay available on the wider layout. */
  .table--stack .hide-sm,
  .table--stack thead .hide-sm {
    display: none !important;
  }

  .table--stack .cell-desc {
    max-width: none;
    -webkit-line-clamp: 3;
    text-align: right;
  }

  /* the name cell carries the brand underneath, so nothing is lost */
  .table--stack .cell-user small {
    display: block;
    color: var(--text-3);
  }
}


/* success variant of the form alert (dealer profile saved, etc.) */
.form-alert--ok {
  background: color-mix(in srgb, var(--success, #16a34a) 12%, transparent);
  color: var(--success, #16a34a);
}


/* ========================= 22. Orders & printout ========================== */
.om-totals {
  margin-left: auto;
  border-collapse: collapse;
  min-width: 260px;
}
.om-totals td {
  padding: var(--s-2) 0 var(--s-2) var(--s-6);
}
.om-totals .num {
  text-align: right;
  font-variant-numeric: tabular-nums;
  /* the same reason as .table .num — a grand total on two lines reads wrong */
  white-space: nowrap;
}
.om-totals__grand td {
  border-top: 1px solid var(--border-strong);
  font-weight: 700;
  font-size: var(--fs-lg);
}

.order-actions {
  display: flex;
  align-items: center;
  gap: var(--s-4);
  flex-wrap: wrap;
  margin-top: var(--s-4);
}

/* the reason a disabled Place Order button is disabled */
.hint--bad {
  display: flex;
  align-items: center;
  gap: var(--s-2);
  color: var(--danger);
}
.hint--bad ion-icon {
  flex: 0 0 auto;
  font-size: 1.1rem;
}

/* ---------------------------------------------------- pre-flight checklist */
/* One row per order line: a tick when the quantity fits what is on the shelf,
   a cross and the shortfall when it does not. */
.checklist {
  list-style: none;
  margin: 0;
  padding: 0;
}

.checklist__row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--s-2) var(--s-3);
  padding: var(--s-3) var(--s-5);
  border-bottom: 1px solid var(--border);
}
.checklist__row:last-child {
  border-bottom: none;
}
.checklist__row.is-short {
  background: var(--danger-bg);
}

.checklist__mark {
  flex: 0 0 auto;
  font-size: 1.25rem;
  color: var(--success);
}
.checklist__row.is-short .checklist__mark {
  color: var(--danger);
}

/* min-width:0 so a long product name wraps instead of shoving the stock
   figures off the end of the row */
.checklist__name {
  flex: 1 1 220px;
  min-width: 0;
  font-weight: 600;
  color: var(--text);
}
.checklist__name small {
  display: block;
  font-weight: 400;
  font-size: var(--fs-sm);
}

.checklist__note {
  flex: 0 1 auto;
  font-size: var(--fs-sm);
  color: var(--text-2);
  font-variant-numeric: tabular-nums;
}
.checklist__row.is-short .checklist__note {
  color: var(--danger);
}

@media (max-width: 560px) {
  .checklist__row {
    padding: var(--s-3);
  }
  .checklist__note {
    flex-basis: 100%;
    padding-left: calc(1.25rem + var(--s-3));
  }
}

/* ------------------------------------------------- invoice / printout ----
   A commercial invoice: letterhead, bill-to, fixed-width line items, totals,
   payment details with the UPI QR, terms and signature. */
.print-page {
  background: var(--bg);
  padding: var(--s-5);
}

.print-sheet {
  box-sizing: border-box;
  width: 100%;
  max-width: 210mm;              /* A4 */
  margin: 0 auto;
  padding: 14mm 16mm;            /* the invoice's own left/right margin */
  background: #fff;
  color: #1f2937;
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  font-size: 12px;
  line-height: 1.5;
}

/* the sheet is always a white page, even in dark mode — it is paper */
.print-sheet h1,
.print-sheet h2,
.print-sheet h3,
.print-sheet strong { color: #111827; }

.print-sheet p { margin: 0; }

/* ---------- letterhead ---------- */
.inv-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  padding-bottom: 12px;
  border-bottom: 2px solid #1d4e89;
}

.inv-brand {
  display: flex;
  gap: 14px;
  align-items: flex-start;
  min-width: 0;
}

.inv-brand__logo {
  width: 68px;
  height: 68px;
  object-fit: contain;
  flex: 0 0 auto;
}

.inv-brand__text { min-width: 0; }

.inv-brand h1 {
  margin: 0 0 4px;
  font-size: 19px;
  line-height: 1.2;
  letter-spacing: -.01em;
}

.inv-brand p {
  font-size: 11px;
  line-height: 1.55;
  color: #4b5563;
}

.inv-brand__gstin {
  margin-top: 4px !important;
  font-weight: 600;
  color: #1f2937 !important;
}

.inv-title { text-align: right; flex: 0 0 auto; }

.inv-title h2 {
  margin: 0 0 6px;
  font-size: 26px;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: #1d4e89;
}

.inv-meta {
  margin-left: auto;
  border-collapse: collapse;
  font-size: 11px;
}

.inv-meta td { padding: 1px 0 1px 12px; text-align: right; white-space: nowrap; }
.inv-meta td:first-child { color: #6b7280; text-align: left; padding-left: 0; }

/* ---------- bill to ---------- */
.inv-bill {
  padding: 10px 0;
  border-bottom: 1px solid #e5e7eb;
}

.inv-bill h3,
.inv-pay h3,
.inv-close h3 {
  margin: 0 0 4px;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: .09em;
  color: #6b7280;
  font-weight: 700;
}

.inv-bill__name { font-size: 14px; font-weight: 700; margin-bottom: 2px !important; }
.inv-bill p { font-size: 11px; line-height: 1.55; color: #4b5563; }

/* ---------- line items ---------- */
/* fixed layout + colgroup widths: the table can never grow past the sheet,
   long product names wrap inside their column instead */
.inv-items {
  width: 100%;
  table-layout: fixed;
  border-collapse: collapse;
  margin-top: 12px;
  font-size: 11px;
}

.inv-items col.c-sr    { width: 4%; }
.inv-items col.c-desc  { width: 30%; }
.inv-items col.c-hsn   { width: 9%; }
.inv-items col.c-qty   { width: 10%; }
.inv-items col.c-rate  { width: 10%; }
.inv-items col.c-net   { width: 11%; }
.inv-items col.c-gstp  { width: 7%; }
.inv-items col.c-gst   { width: 9%; }
.inv-items col.c-total { width: 10%; }

.inv-items th {
  background: #1d4e89;
  color: #fff;
  font-weight: 600;
  text-align: left;
  padding: 7px 6px;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: .04em;
}

.inv-items td {
  padding: 7px 6px;
  border-bottom: 1px solid #e5e7eb;
  vertical-align: top;
  overflow-wrap: anywhere;       /* stop a long code stretching the column */
}

.inv-items .num { text-align: right; font-variant-numeric: tabular-nums; }
.inv-items th.num { text-align: right; }

.inv-items tbody tr:nth-child(even) td { background: #f9fafb; }

.inv-items__name { display: block; font-weight: 600; color: #111827; }
.inv-items__sub { display: block; font-size: 10px; color: #6b7280; margin-top: 1px; }

/* the totals row under the line items */
.inv-items tfoot td {
  padding: 7px 6px;
  background: #eef2f7;
  border-top: 1.5px solid #1d4e89;
  font-weight: 700;
  color: #111827;
}
.inv-items tfoot .num { text-align: right; font-variant-numeric: tabular-nums; }

/* several unit totals on one line — smaller, so "10 SET · 5 BOX · 3 KG"
   still fits the merged HSN+Qty width without wrapping to three rows */
.inv-items__units {
  font-size: 10px;
  letter-spacing: -.01em;
  white-space: normal;
}

/* ---------- tax details ---------- */
/* Narrower and quieter than the line items: this block is read to check the
   tax, not to read the order, so it must not compete with the table above. */
/* Tax details and totals share one row. Stacked, the pair cost about 45mm of
   height and pushed the payment and signature blocks onto a second sheet. */
.inv-close-row {
  display: flex;
  align-items: flex-start;
  gap: 18px;
  margin-top: 14px;
}

.inv-tax { flex: 1 1 auto; min-width: 0; }

.inv-tax h3 {
  margin: 0 0 6px;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: .09em;
  color: #6b7280;
  font-weight: 700;
}

.inv-tax__table {
  width: 100%;
  border-collapse: collapse;
  font-size: 10.5px;
}

.inv-tax__table th {
  padding: 6px 8px;
  text-align: left;
  font-size: 9.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: #4b5563;
  background: #f3f4f6;
  border: 1px solid #e5e7eb;
}

.inv-tax__table td {
  padding: 6px 8px;
  border: 1px solid #e5e7eb;
}

.inv-tax__table .num { text-align: right; font-variant-numeric: tabular-nums; }
.inv-tax__table th.num { text-align: right; }

.inv-tax__table code { font-family: inherit; color: #111827; }

.inv-tax__table tfoot td {
  font-weight: 700;
  color: #111827;
  background: #f9fafb;
}

/* ---------- totals ---------- */
/* flex-none so the tax table takes the leftover width, not this one */
.inv-sum { display: flex; justify-content: flex-end; flex: 0 0 auto; }

.inv-sum__table {
  border-collapse: collapse;
  min-width: 240px;
  font-size: 11.5px;
}

.inv-sum__table td { padding: 4px 0 4px 18px; text-align: right; }
.inv-sum__table td:first-child { text-align: left; color: #6b7280; padding-left: 0; }

.inv-sum__grand td {
  border-top: 1.5px solid #1d4e89;
  padding-top: 7px;
  font-size: 14px;
  font-weight: 700;
  color: #1d4e89;
}

/* Side by side needs the width of a sheet. On a phone the invoice is being
   read rather than printed, so the pair stacks again. */
@media (max-width: 720px) {
  .inv-close-row {
    flex-direction: column;
    gap: 12px;
  }
  .inv-sum {
    align-self: stretch;
  }
}

/* ---------- payment ---------- */
.inv-pay {
  display: flex;
  gap: 18px;
  align-items: flex-start;
  justify-content: space-between;
  margin-top: 16px;
  padding: 10px 12px;
  background: #f9fafb;
  border: 1px solid #e5e7eb;
  border-radius: 6px;
}

.inv-pay__bank { min-width: 0; flex: 1 1 auto; }

.inv-kv { border-collapse: collapse; font-size: 11px; }
.inv-kv td { padding: 2px 14px 2px 0; vertical-align: top; }
.inv-kv td:first-child { color: #6b7280; white-space: nowrap; }
.inv-kv td:last-child { font-weight: 600; overflow-wrap: anywhere; }

.inv-pay__qr { margin: 0; text-align: center; flex: 0 0 auto; }

.inv-pay__qr img {
  width: 104px;
  height: 104px;
  object-fit: contain;
  padding: 5px;
  background: #fff;              /* a QR on a tint will not scan reliably */
  border: 1px solid #e5e7eb;
  border-radius: 6px;
  display: block;
}

.inv-pay__qr figcaption { font-size: 9.5px; color: #6b7280; margin-top: 3px; line-height: 1.4; }

/* ---------- terms + signature ---------- */
.inv-close {
  display: flex;
  gap: 24px;
  justify-content: space-between;
  align-items: flex-end;
  margin-top: 18px;
}

.inv-close__terms { flex: 1 1 auto; min-width: 0; }

.inv-close__terms ol {
  margin: 0;
  padding-left: 16px;
  font-size: 10px;
  color: #4b5563;
  line-height: 1.6;
}

.inv-close__sign {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 42px;
  min-width: 190px;
  font-size: 11px;
}

.inv-close__for { font-weight: 600; }

.inv-close__line {
  width: 100%;
  padding-top: 5px;
  border-top: 1px solid #9ca3af;
  text-align: center;
  color: #6b7280;
  font-size: 10px;
}

.inv-note {
  margin-top: 14px !important;
  padding-top: 8px;
  border-top: 1px solid #e5e7eb;
  font-size: 9.5px;
  color: #9ca3af;
  text-align: center;
}

.print-actions { margin-top: var(--s-5); text-align: right; }

/* ---------- small screens ---------- */
@media (max-width: 720px) {
  .print-page { padding: var(--s-3); }
  .print-sheet { padding: 12px; font-size: 11px; }
  .inv-head { flex-direction: column; }
  .inv-title { text-align: left; }
  .inv-meta { margin-left: 0; }
  .inv-meta td { text-align: left; padding-left: 12px; }
  .inv-pay { flex-direction: column; align-items: stretch; }
  .inv-pay__qr { align-self: center; }
  .inv-close { flex-direction: column; align-items: stretch; }
  .inv-close__sign { align-items: flex-start; margin-top: 24px; }

  /* the item table is the one thing allowed to scroll sideways */
  .inv-items { display: block; overflow-x: auto; white-space: nowrap; }
  .inv-items td { overflow-wrap: normal; }
}

/* ---------- print ---------- */
@media print {
  /* margin:0 removes the browser's own header and footer — the date, time,
     page title and URL it otherwise prints into the page margin. The sheet's
     padding supplies the real margin instead. */
  @page {
    size: A4;
    margin: 0;
  }

  html, body { margin: 0; padding: 0; background: #fff; }

  .no-print { display: none !important; }

  /* a scroll box has no meaning on paper — print the table whole, and never
     let the overflow box clip a column off the edge of the sheet */
  .table-wrap {
    overflow: visible !important;
    min-width: 0 !important;
    /* a capped height would print only the rows that happen to fit */
    max-height: none !important;
  }
  .table-wrap > .table { min-width: 0 !important; }
  /* sticky has no meaning on paper and can reprint the row on every sheet */
  .table-wrap--tall .table tfoot td,
  .table thead th { position: static !important; }

  .print-page { padding: 0; background: #fff; }

  .print-sheet {
    max-width: none;
    width: auto;
    margin: 0;
    padding: 10mm 12mm;
    border: 0;
    border-radius: 0;
    font-size: 10pt;
  }

  .inv-items { font-size: 8.5pt; margin-top: 9px; }
  .inv-items th { padding: 4px 5px; }
  .inv-items td { padding: 4px 5px; }
  .inv-items tfoot td { padding: 5px; }

  .inv-tax__table { font-size: 8pt; }
  .inv-tax__table th,
  .inv-tax__table td { padding: 4px 6px; }

  /* Everything below the line items, tightened. A one-page invoice is the
     point: these blocks are read, not studied, and the space between them
     was the difference between one sheet and two. */
  .inv-head { padding-bottom: 9px; }
  .inv-bill { padding: 8px 0; }
  .inv-close-row { margin-top: 10px; gap: 14px; }
  .inv-tax { margin: 0; }
  .inv-pay { margin-top: 10px; padding: 8px 10px; }
  .inv-pay__qr img { width: 86px; height: 86px; }
  .inv-close { margin-top: 12px; }
  .inv-close__sign { gap: 30px; }
  /* !important only to beat the same flag on the base rule */
  .inv-note { margin-top: 10px !important; }

  /* colours must survive the printer's "no background graphics" default */
  .inv-items th,
  .inv-items tfoot td,
  .inv-pay,
  .inv-tax__table th,
  .inv-tax__table tfoot td,
  .inv-items tbody tr:nth-child(even) td {
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  thead { display: table-header-group; }
  .inv-items tr,
  .inv-pay,
  .inv-close,
  .inv-close-row,
  .inv-tax,
  .inv-sum { page-break-inside: avoid; }
}
/* ====================== 23. Product cards (shop) ==========================
   Horizontal cards: thumbnail on the left, details and the add control on
   the right — the layout a messaging-app catalogue uses. */
.product-grid {
  display: grid;
  /* three across on desktop. minmax(0,…) not minmax(380px,…): the 0 lets a
     column shrink below its content, which is what stops a long product name
     from pushing the row wider than the panel. */
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: var(--s-4);
  padding: var(--s-5);
}

.product-card {
  display: flex;
  align-items: stretch;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  overflow: hidden;
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
}
.product-card:hover {
  border-color: var(--primary-500);
  box-shadow: var(--shadow-lg);
}
.product-card[hidden] {
  display: none;
}

.product-card__media {
  /* roughly 40% of the card — big enough to actually judge the product */
  flex: 0 0 clamp(128px, 40%, 180px);
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--s-2);
}
.product-card__media img {
  width: 100%;
  height: 100%;
  min-height: 158px;
  /* contain, not cover: cover crops the edges off a product photo, which is
     exactly what you must not do in a catalogue */
  object-fit: contain;
  display: block;
}

/* details above, add control pinned to the bottom of the card */
.product-card__main {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: var(--s-3);
  padding: var(--s-4);
  flex: 1 1 auto;
  min-width: 0;
}
.product-card__body {
  display: flex;
  flex-direction: column;
  gap: var(--s-1);
  align-items: flex-start;
  min-width: 0;
}
.product-card__name {
  font-size: var(--fs-md);
  font-weight: 700;
  color: inherit;
  text-decoration: none;
  line-height: 1.3;
  /* two lines max, so one long name can't make its card taller than the row */
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.product-card__body small,
.product-card__name {
  overflow-wrap: anywhere;
}
.product-card__body > small {
  max-width: 100%;
}
.product-card__price {
  display: flex;
  flex-direction: column;
  margin: var(--s-1) 0;
}
.product-card__amount {
  font-size: var(--fs-lg);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.product-card__foot {
  display: flex;
  gap: var(--s-2);
  align-items: center;
  flex-wrap: wrap;          /* qty drops above the button when very narrow */
}
.product-card__foot .input {
  width: 58px;
  flex: 0 0 auto;
  text-align: center;
  min-height: 38px;
  padding-left: var(--s-2);
  padding-right: var(--s-2);
}
.product-card__foot .btn {
  flex: 1 1 88px;
  justify-content: center;
  min-height: 38px;
  padding-left: var(--s-3);
  padding-right: var(--s-3);
}

/* ------------------------------------------------------- live cart panel */
.cart-panel {
  position: sticky;
  bottom: var(--s-3);
  margin-top: var(--s-5);
}

/* compact table — the cart is a glance, not a document */
.table--mini th,
.table--mini td {
  padding: var(--s-2) var(--s-4);
  font-size: var(--fs-sm);
}
.table--mini tfoot td {
  border-top: 1px solid var(--border-strong);
  font-variant-numeric: tabular-nums;
}

/* Three cards need roughly 1180px of viewport once the sidebar is open.
   Below that, drop to two, then to one — the card layout itself is unchanged. */
@media (max-width: 1180px) {
  .product-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 720px) {
  .product-grid {
    grid-template-columns: minmax(0, 1fr);
  }
}

@media (max-width: 560px) {
  .product-grid {
    gap: var(--s-3);
    padding: var(--s-3);
  }
  .product-card__media {
    flex: 0 0 clamp(112px, 34%, 140px);
  }
  .product-card__media img {
    min-height: 124px;
  }
  .product-card__main {
    padding: var(--s-3);
  }
}


/* ==================== 24. Product details (one page) ======================
   Used by products/product_detail.html only — every module links to that
   page rather than repeating the product layout. */
.detail {
  display: grid;
  grid-template-columns: minmax(0, 520px) minmax(0, 1fr);
  gap: var(--s-5);
  padding: var(--s-5);
}

/* front view across the full width, the other three sides as thumbnails */
.detail__media {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: var(--s-3);
  align-content: start;
}
.detail__media .is-main {
  grid-column: 1 / -1;
}

.detail__media figure {
  margin: 0;
  text-align: center;
}

/* the frame clips the image, so scaling it reads as a zoom rather than
   pushing the layout around */
.zoom {
  overflow: hidden;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  cursor: zoom-in;
}
.zoom img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: contain;
  padding: var(--s-2);
  display: block;
  transition: transform var(--t-slow);
}
.zoom:hover img,
.zoom:focus-within img {
  transform: scale(1.9);
}
.detail__media .is-main img {
  aspect-ratio: 4 / 3;
}
.detail__media figcaption {
  font-size: var(--fs-xs);
  padding-bottom: var(--s-1);
}

/* a touch screen has no hover — don't leave the zoom stuck on after a tap */
@media (hover: none) {
  .zoom:hover img,
  .zoom:focus-within img {
    transform: none;
  }
  .zoom {
    cursor: default;
  }
}

@media (prefers-reduced-motion: reduce) {
  .zoom img {
    transition: none;
  }
}

.detail__buy {
  display: flex;
  gap: var(--s-2);
  align-items: center;
  flex-wrap: wrap;
  margin: var(--s-2) 0;
}
.detail__buy .input {
  width: 84px;
  flex: 0 0 auto;
  text-align: center;
}

.detail__info {
  display: flex;
  flex-direction: column;
  gap: var(--s-3);
  min-width: 0;
}
.detail__price {
  display: flex;
  flex-direction: column;
}
.detail__amount {
  font-size: var(--fs-xl);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.detail__specs td:first-child {
  width: 42%;
  color: var(--text-3);
}

@media (max-width: 860px) {
  .detail {
    grid-template-columns: minmax(0, 1fr);
    padding: var(--s-4);
  }
}


/* thumbnails on the details page swap into the large slot when clicked */
.detail__media figure:not(.is-main) {
  cursor: pointer;
}
.detail__media figure:not(.is-main):hover {
  border-color: var(--primary-500);
}

/* the Details column must stay reachable when the table scrolls sideways */
.table .actions .btn {
  opacity: 1;
}


/* stock + New badges sit side by side on a product card */
.card-tags {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s-2);
}


/* ======================== 25. Contact page ================================ */
.contact {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: var(--s-5);
  padding: var(--s-5);
}

.contact__info {
  display: flex;
  flex-direction: column;
  gap: var(--s-4);
  min-width: 0;
}

.contact__info td:first-child {
  width: 34%;
  color: var(--text-3);
  white-space: nowrap;
}

.contact__social {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s-2);
}

/* the map keeps its shape at any width */
.contact__map {
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  overflow: hidden;
  background: var(--bg);
}

.contact__map iframe {
  display: block;
  width: 100%;
  height: 100%;
  min-height: 320px;
  border: 0;
}

@media (max-width: 860px) {
  .contact {
    grid-template-columns: minmax(0, 1fr);
    padding: var(--s-4);
  }

  .contact__map iframe {
    min-height: 240px;
  }
}


/* ========================== 26. About us page ============================= */
.about-hero {
  display: flex;
  align-items: center;
  gap: var(--s-5);
  flex-wrap: wrap;
  padding: var(--s-5);
  border-bottom: 1px solid var(--border);
}

.about-hero__logo img {
  width: clamp(96px, 20vw, 160px);
  aspect-ratio: 1;
  object-fit: contain;
  padding: var(--s-3);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  display: block;
}

.about-hero__text {
  min-width: 0;
  flex: 1 1 240px;
}

.about-hero__text h2 {
  margin: 0 0 var(--s-1);
  font-size: var(--fs-xl);
}

/* a comfortable reading measure rather than the full panel width */
.about-body {
  padding: var(--s-5);
  max-width: 78ch;
}

/* ---- rendered rich text (admin-authored HTML) ---- */
.richtext {
  min-width: 0;
  color: var(--text-2);
  line-height: 1.75;
}

.richtext > :first-child { margin-top: 0; }
.richtext > :last-child { margin-bottom: 0; }

.richtext h1,
.richtext h2,
.richtext h3,
.richtext h4 {
  color: var(--text);
  margin: var(--s-5) 0 var(--s-3);
  line-height: 1.3;
}

.richtext p { margin: 0 0 var(--s-4); }

.richtext ul,
.richtext ol {
  margin: 0 0 var(--s-4);
  padding-left: var(--s-6);
}

.richtext li { margin-bottom: var(--s-2); }

.richtext strong,
.richtext b { color: var(--text); }

.richtext a { color: var(--primary-500); }

.richtext hr {
  margin: var(--s-5) 0;
  border: 0;
  border-top: 1px solid var(--border);
}

.richtext blockquote {
  margin: 0 0 var(--s-4);
  padding: var(--s-2) 0 var(--s-2) var(--s-4);
  border-left: 3px solid var(--primary-500);
  color: var(--text-3);
  font-style: italic;
}

/* images and figures the editor inserts */
.richtext img {
  max-width: 100%;
  height: auto;
  border-radius: var(--r-md);
}

.richtext figure {
  margin: 0 0 var(--s-4);
}

.richtext figcaption {
  margin-top: var(--s-2);
  font-size: var(--fs-sm);
  color: var(--text-3);
  text-align: center;
}

/* tables from the table plugin */
.richtext table {
  width: 100%;
  margin: 0 0 var(--s-4);
  border-collapse: collapse;
}

.richtext th,
.richtext td {
  padding: var(--s-2) var(--s-3);
  border: 1px solid var(--border);
  text-align: left;
}

.richtext th {
  background: var(--bg);
  color: var(--text);
  font-weight: 600;
}

/* code from the codesample plugin */
.richtext pre {
  margin: 0 0 var(--s-4);
  padding: var(--s-4);
  overflow-x: auto;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  font-size: var(--fs-sm);
}

.richtext code {
  font-size: .95em;
}

/* the editor writes alignment as inline styles or these classes */
.richtext .mce-content-body [style*="text-align"] { display: block; }

/* embedded video from the media plugin */
.richtext iframe {
  max-width: 100%;
  border: 0;
  border-radius: var(--r-md);
}

@media (max-width: 760px) {
  .about-hero,
  .about-body {
    padding: var(--s-4);
  }

  .richtext table {
    display: block;
    overflow-x: auto;
  }
}


/* ======================== 27. Bank details ================================ */
.bank {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 260px);
  gap: var(--s-5);
  padding: var(--s-5);
  align-items: start;
}

.bank__info {
  min-width: 0;
}

.bank__info td:first-child {
  width: 38%;
  color: var(--text-3);
  white-space: nowrap;
}

/* the QR must stay on a light ground or phone cameras struggle to read it */
.bank__qr {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--s-2);
  text-align: center;
}

.bank__qr img {
  width: 100%;
  max-width: 240px;
  aspect-ratio: 1;
  object-fit: contain;
  padding: var(--s-3);
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  display: block;
}

@media (max-width: 760px) {
  .bank {
    grid-template-columns: minmax(0, 1fr);
    padding: var(--s-4);
  }

  .bank__qr img {
    max-width: 200px;
    margin: 0 auto;
  }
}


/* ==================== 28. Export dropdown (products) ====================== */
.export-menu {
  position: relative;
}

/* hide the default disclosure triangle */
.export-menu > summary {
  list-style: none;
  cursor: pointer;
}

.export-menu > summary::-webkit-details-marker {
  display: none;
}

/* the second chevron rotates when the menu is open */
.export-menu[open] > summary ion-icon:last-child {
  transform: rotate(180deg);
}

/* Export → "With item images" (a report with pictures: Stock Summary) */
.export-menu__option {
  display: flex;
  align-items: center;
  gap: var(--s-2);
  padding: 7px var(--s-3);
  font-size: var(--fs-md);
  color: var(--text);
  white-space: nowrap;
  cursor: pointer;
  border-radius: var(--r-sm);
}
.export-menu__option:hover {
  background: var(--surface-3);
}
.export-menu__option input {
  width: 16px;
  height: 16px;
  accent-color: var(--primary-600);
  cursor: pointer;
}
.export-menu__option small {
  display: block;
  font-size: var(--fs-xs);
  color: var(--text-3);
}

.export-menu__panel {
  position: absolute;
  right: 0;
  top: calc(100% + var(--s-2));
  z-index: 60;
  min-width: 170px;
  display: block;
  padding: var(--s-2);
}

@media (max-width: 560px) {
  .export-menu__panel {
    right: auto;
    left: 0;
  }
}


/* ============ 29. Segment + pagination: links as well as buttons ==========
   The products toolbar and pager use <a> now that filtering and paging are
   server side; these mirror the existing button rules onto anchors. */
.segment a {
  display: inline-flex;
  align-items: center;
  height: 32px;
  padding: 0 var(--s-4);
  font-size: var(--fs-sm);
  font-weight: 600;
  color: var(--text-2);
  text-decoration: none;
  border-radius: var(--r-sm);
  transition: background-color var(--t-fast), color var(--t-fast);
}

.segment a:hover {
  color: var(--text);
}

.segment a.is-active {
  background: var(--surface);
  color: var(--primary-600);
  box-shadow: var(--shadow-xs);
}

.pagination a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 36px;
  height: 36px;
  padding: 0 var(--s-2);
  font-size: var(--fs-md);
  font-weight: 600;
  color: var(--text-2);
  text-decoration: none;
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--r-sm);
}

.pagination a:hover {
  color: var(--text);
  border-color: var(--border-strong);
}

/* the search box is a form now — keep it laid out like the old div */
.toolbar form.search {
  margin: 0;
}


/* smaller segment for the page-size switch in the table footer */
.segment--sm a {
  height: 26px;
  padding: 0 var(--s-3);
  font-size: var(--fs-xs);
}


/* the row-number column only ever holds 1-3 digits — width:1% makes an auto
   table shrink the column to its content instead of sharing space evenly */
.table .cell-no {
  width: 1%;
  white-space: nowrap;
  padding-left: var(--s-3);
  padding-right: var(--s-2);
  font-size: var(--fs-sm);
}


/* ============ 30. Products table as cards on mobile =======================
   Below 640px .table--stack already turns each row into a block. These rules
   go further and lay that block out like the shop catalogue card: thumbnail
   on the left, details on the right. Desktop is untouched — everything here
   is inside the media query and scoped to #productsTable. */
@media (max-width: 640px) {

  #productsTable tbody tr {
    display: grid;
    grid-template-columns: 104px minmax(0, 1fr);
    align-items: start;
    gap: 2px var(--s-3);
    padding: var(--s-3);
    border-bottom: 8px solid var(--bg);
  }

  /* the picture sits in column 1 and spans the text lines beside it */
  #productsTable .cell-media {
    display: block;
    grid-column: 1;
    grid-row: 1 / span 4;
    padding: 0;
    border: 0;
  }

  #productsTable .cell-media::before {
    display: none;
  }

  #productsTable .cell-media .cell-img {
    width: 100%;
    height: auto;
    aspect-ratio: 1;
    object-fit: contain;
    padding: var(--s-2);
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--r-md);
  }

  /* every other visible cell stacks in column 2 */
  #productsTable tbody td:not(.cell-media) {
    grid-column: 2;
    padding: 1px 0;
    border: 0;
  }

  /* the name leads the card, with no label in front of it */
  #productsTable td[data-label="Name"] {
    display: block;
    text-align: left;
  }

  #productsTable td[data-label="Name"]::before {
    display: none;
  }

  #productsTable td[data-label="Name"] .cell-user {
    gap: 0;
  }

  /* price is the number people scan for */
  #productsTable td[data-label="Price"] {
    font-size: var(--fs-lg);
    font-weight: 700;
    color: var(--text);
  }

  /* status reads better as just the badge */
  #productsTable td[data-label="Status"]::before {
    display: none;
  }

  #productsTable td[data-label="Status"] {
    justify-content: flex-start;
    padding-top: var(--s-2);
  }

  /* the action runs full width under the card, like the shop's Add button */
  #productsTable td.actions {
    grid-column: 1 / -1;
    margin-top: var(--s-3);
  }

  #productsTable td.actions .row-actions {
    display: flex;
    width: 100%;
    gap: var(--s-2);
  }

  /* both actions are icons now — give them wide, thumb-sized targets */
  #productsTable td.actions .icon-btn {
    flex: 1 1 0;
    max-width: 160px;
    width: auto;
    height: 42px;
  }
}


/* ================= 31. Row actions (cart + view) ==========================
   The stock rule fades .actions .icon-btn to opacity:0 until the row is
   hovered — fine for a quiet "more" menu, wrong for an Add to cart control
   that has to be visible and tappable on a touch screen. */
.row-actions {
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  gap: var(--s-2);
}

/* the form must not add a line box between the two controls */
.row-actions form {
  display: contents;
}

/* in place of the edit / delete buttons on a locked row (a standard unit) */
.row-lock {
  display: inline-grid;
  place-items: center;
  width: 28px;
  height: 28px;
  font-size: 1.05rem;
  color: var(--text-3);
  cursor: help;
}

/* the stock rule fades these to opacity:0 until the row is hovered */
.table .actions .row-actions .icon-btn {
  opacity: 1;
}

.table .actions .row-actions .icon-btn:disabled {
  cursor: not-allowed;
}


/* ============= 32. Row action icons: view + add to cart ===================
   Both are icon-only now, so each needs its own colour and a visible border
   to read as a button rather than as decoration. */
/* solid buttons — they must read as actions at a glance, with no hover
   needed, which also matters on touch screens where there is no hover */
.icon-btn--view,
.icon-btn--cart {
  border: 1px solid transparent;
  border-radius: var(--r-md);
  color: #fff;
  opacity: 1;
  transition: filter var(--t-fast), box-shadow var(--t-fast);
}

.icon-btn--view {
  background: var(--primary-600);
}

.icon-btn--cart {
  background: var(--accent-600, var(--primary-600));
}

.icon-btn--view:hover,
.icon-btn--cart:hover:not(:disabled) {
  filter: brightness(1.12);
  color: #fff;
}

/* keyboard focus must be obvious on both */
.icon-btn--view:focus-visible,
.icon-btn--cart:focus-visible {
  outline: none;
  border-color: var(--primary-500);
  box-shadow: var(--ring);
}

/* the tick shown for a moment after a successful add */
.icon-btn.is-added {
  color: #fff;
  background: var(--success, #16a34a);
  border-color: var(--success, #16a34a);
}

/* Order-row actions: continue, view/edit and print, all icon-only.
   Outlined rather than solid like --view above: --success and --text-2 both
   flip to light shades in dark mode, where a white glyph on them would be
   unreadable. Tinting the border and the glyph instead works in both. */
.icon-btn--resume,
.icon-btn--print {
  border: 1px solid;
  border-radius: var(--r-md);
  opacity: 1;
  transition: filter var(--t-fast), background-color var(--t-fast),
    color var(--t-fast), box-shadow var(--t-fast);
}

.icon-btn--resume {
  border-color: var(--success);
  background: var(--success-bg);
  color: var(--success);
}
.icon-btn--resume:hover {
  filter: brightness(1.06);
  color: var(--success);
}

.icon-btn--print {
  border-color: var(--border-strong);
  background: var(--surface);
  color: var(--text-2);
}
.icon-btn--print:hover {
  background: var(--surface-3);
  color: var(--text);
}

.icon-btn--resume:focus-visible,
.icon-btn--print:focus-visible {
  outline: none;
  border-color: var(--primary-500);
  box-shadow: var(--ring);
}

/* These are a row's real actions, not incidental ones, so they stay visible
   without hover — the only way they work on a touch screen. The earlier
   ".table .actions .icon-btn { opacity: 0 }" rule hides every icon in an
   actions cell until the row is hovered, and it outranks the opacity:1 each
   variant sets on itself; this matches its specificity and comes later. */
.table .actions .icon-btn--view,
.table .actions .icon-btn--cart,
.table .actions .icon-btn--resume,
.table .actions .icon-btn--print {
  opacity: 1;
}

/* and the same specificity is needed to size them down in a fixed table */
.table--fixed .actions .icon-btn {
  width: 30px;
  height: 30px;
}

/* still a filled button, just clearly inactive */
.icon-btn--cart:disabled {
  background: var(--surface-3);
  color: var(--text-3);
  border-color: var(--border-strong);
  border-style: dashed;
  opacity: 1;
}
