/* ============================================================================
   POSSupplyChain — PAGE LAYER (stage 16/22, page polish)
   Extends themes.css (values) + motion.css (surfaces/motion) with the layout
   patterns the packed screens actually need. Loaded after both, never
   replacing them. Tokens only: every value below resolves to a --m-* variable.
   Logical properties only, so the Arabic RTL render mirrors for free.
   ========================================================================== */

:root {
  --m-pg-gap: var(--m-s-5);
  --m-panel-bg: rgba(255, 255, 255, .035);
  --m-panel-bg-2: rgba(255, 255, 255, .055);
}

/* ------------------------------------------------------------- page canvas */
main[role="main"] {
  padding-block: var(--m-s-5) var(--m-s-7);
}
main > section + section,
main > .card + .card,
main > section + .card,
main > .card + section {
  margin-top: var(--m-pg-gap);
}

/* ------------------------------------------------------------- page header */
/* Every screen opens the same way: an eyebrow, a title, an optional subtitle
   and one action cluster. The hairline gives the ledger look its structure. */
.m-page-header {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: var(--m-s-3) var(--m-s-4);
  padding-block-end: var(--m-s-3);
  margin-block-end: var(--m-s-4);
  border-block-end: 1px solid var(--m-border);
}
.m-page-header__main { min-width: 0; flex: 1 1 18rem; }
.m-page-header h1,
.m-page-header .h1 {
  margin: 0;
  font-size: clamp(1.35rem, 2.2vw, 1.75rem);
  letter-spacing: var(--m-track-tight);
  line-height: var(--m-lh-snug);
}
.m-page-header__sub {
  color: var(--m-muted);
  font-size: var(--m-t-sm);
  margin-block-start: .25rem;
}
.m-page-header__actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--m-s-2);
  align-items: center;
}
.m-eyebrow {
  display: block;
  font-size: var(--m-t-xs);
  letter-spacing: var(--m-track-wide);
  text-transform: uppercase;
  color: var(--m-cyan);
  margin-block-end: .35rem;
}
.m-muted { color: var(--m-muted); }
/* the subtitles the builder already wrote (muted small text under a title) */
.m-page-header .text-muted.small,
.m-page-header__sub {
  color: var(--m-muted);
  font-size: var(--m-t-xs);
}
.m-page-header .text-muted.small .badge { vertical-align: middle; }

/* --------------------------------------------------------------- app shell */
.m-topbar { position: sticky; inset-block-start: 0; z-index: var(--m-z-nav); }
.m-shell { max-width: var(--m-container); }
.m-brandmark {
  display: inline-grid;
  grid-template-columns: repeat(3, 4px);
  align-items: end;
  gap: 3px;
  height: 16px;
  padding-block-end: 1px;
}
.m-brandmark span {
  display: block;
  width: 4px;
  border-radius: 2px;
  background: var(--m-grad);
}
.m-brandmark span:nth-child(1) { height: 9px; opacity: .75; }
.m-brandmark span:nth-child(2) { height: 16px; }
.m-brandmark span:nth-child(3) { height: 12px; opacity: .9; }
.m-brandtext { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.footer .m-footer-region,
.footer .m-footer-links {
  font-size: var(--m-t-xs);
  color: var(--m-muted);
  display: inline-flex;
  gap: .45rem;
  align-items: center;
}
.footer .m-footer-links a { color: var(--m-muted); text-decoration: none; }
.footer .m-footer-links a:hover,
.footer .m-footer-links a:focus-visible { color: var(--m-cyan); text-decoration: underline; text-underline-offset: 3px; }
@media (max-width: 991.98px) {
  .m-footer-region { order: 3; }
}

/* headings that are not inside a .m-page-header still get the same header
   rhythm and hairline, so create/edit screens match the list screens without
   touching their markup */
main > h1,
main > h1.h3 {
  font-size: clamp(1.3rem, 2.1vw, 1.7rem);
  letter-spacing: var(--m-track-tight);
  padding-block-end: var(--m-s-3);
  margin-block-end: var(--m-s-4);
  border-block-end: 1px solid var(--m-border);
}

/* -------------------------------------------------------------- filter bar */
/* The GET filter forms already exist on every list screen; give them a panel
   so the query controls read as one instrument instead of loose inputs. */
form[method="get"].row {
  background: var(--m-panel-bg);
  border: 1px solid var(--m-border);
  border-radius: var(--m-r);
  padding: var(--m-s-3) var(--m-s-3) var(--m-s-2);
  margin-inline: 0 !important;
  backdrop-filter: blur(var(--m-blur));
}
form[method="get"].row > [class*="col-"] { margin-block-end: var(--m-s-2); }

/* ------------------------------------------------------------ section card */
/* Defect fixed in this stage: the pack's one-shot `m-lift-in` entrance left a
   residual translateY(10px) on every card (frozen at its 0% keyframe under
   reduced-motion / headless), which double-painted card content and showed as
   faint ghost rows behind tables. Content must be visible and still at first
   paint; the motion contract keeps the hover lifts and the scroll reveals. */
main .card,
main .m-card { animation: none; }
section.card > .card-header,
.card > .card-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--m-s-2);
  padding: var(--m-s-3) var(--m-s-4);
  border-block-end: 1px solid var(--m-border);
  font-size: var(--m-t-sm);
  letter-spacing: .02em;
}
section.card > .card-header .fw-semibold,
.card > .card-header .fw-semibold {
  font-weight: var(--m-fw-semi);
  letter-spacing: var(--m-track-tight);
}
.card > .card-footer {
  padding: var(--m-s-2) var(--m-s-4);
  font-size: var(--m-t-xs);
  color: var(--m-muted);
  border-block-start: 1px solid var(--m-border);
}
.card > .card-body { padding: var(--m-s-4); }
.card.border-0 > .card-footer { background: transparent; }

/* ledger tables sit inside a card without doubling the frame */
.card > .table-responsive {
  border: 0;
  border-radius: 0;
  background: transparent;
}

/* ---------------------------------------------------------------- tables */
/* Zebra striping muddies a glass surface: hairline rows + numeric alignment
   carry the scan instead. Applied to the existing .table markup, no view edit. */
.table-striped > tbody > tr:nth-of-type(odd) > * {
  --bs-table-accent-bg: transparent;
  box-shadow: none;
  background: transparent;
}
.table > tbody > tr + tr > * { border-block-start: 1px solid rgba(255, 255, 255, .045); }
.table > tbody > tr:hover > * { background: rgba(255, 255, 255, .04); }
.table td .small,
.table .small { font-size: var(--m-t-xs); color: var(--m-muted); }
.table tbody td:first-child { font-weight: var(--m-fw-medium); }
.table tbody td:first-child a { color: var(--m-text); text-decoration: none; }
.table tbody td:first-child a:hover { color: var(--m-cyan); text-decoration: underline; text-underline-offset: 3px; }
.table .font-monospace { font-family: var(--m-font-mono); font-size: var(--m-t-xs); color: var(--m-muted); }
.table td.text-end,
.table td .num { font-variant-numeric: tabular-nums; }
.table tfoot td:first-child { color: var(--m-muted); }

/* ------------------------------------------------------------ empty state */
/* An empty table body is not an empty state. This block gives every list
   screen a glyph, a title and one line of direction, centred in the ledger. */
.m-empty-cell { padding: 0 !important; }
.m-empty {
  display: grid;
  justify-items: center;
  gap: .35rem;
  padding: var(--m-s-7) var(--m-s-4);
  text-align: center;
}
.m-empty__glyph {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  border: 1px solid var(--m-border-strong);
  background:
    linear-gradient(180deg, transparent 8px, var(--m-border-strong) 8px, var(--m-border-strong) 9px, transparent 9px),
    linear-gradient(180deg, transparent 20px, var(--m-border-strong) 20px, var(--m-border-strong) 21px, transparent 21px),
    linear-gradient(180deg, transparent 32px, var(--m-border-strong) 32px, var(--m-border-strong) 33px, transparent 33px);
  opacity: .8;
  margin-block-end: .4rem;
}
.m-empty__title {
  margin: 0;
  font-weight: var(--m-fw-semi);
  color: var(--m-text);
  font-size: var(--m-t-sm);
}
.m-empty__hint {
  margin: 0;
  max-width: 46ch;
  color: var(--m-muted);
  font-size: var(--m-t-xs);
  line-height: var(--m-lh);
}

/* -------------------------------------------------------------- stat cards */
/* Detail screens open with a row of figures (price, on hand, variants...). */
.card .fs-4, .card .fs-5, .card .fs-3 {
  font-variant-numeric: tabular-nums;
  letter-spacing: var(--m-track-num);
  line-height: var(--m-lh-tight);
}
.card .fs-4 { font-size: clamp(1.15rem, 1.6vw, 1.45rem); }
main .row.g-3 > [class*="col-"] > .card { height: 100%; }

/* --------------------------------------------------------------- details */
/* Detail views render label/value pairs in the same shape everywhere. */
.m-details {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: var(--m-s-3) var(--m-s-4);
  margin: 0;
}
.m-details dt {
  font-size: var(--m-t-xs);
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--m-muted);
  font-weight: var(--m-fw-regular);
}
.m-details dd {
  margin: 0;
  font-size: var(--m-t-sm);
  color: var(--m-text);
  overflow-wrap: anywhere;
}

/* ----------------------------------------------------------------- forms */
/* Create/Edit screens: one panel, a labelled grid, actions pinned to the end. */
.card > .card-body > form > .row.g-3 { row-gap: var(--m-s-3); }
.card > .card-body > form > .row.g-3 > [class*="col-"] { margin-block-end: 0; }
.card > .card-body > form > .mt-3,
.card > .card-body > form > .mt-4 {
  margin-block-start: var(--m-s-4) !important;
  padding-block-start: var(--m-s-3);
  border-block-start: 1px solid var(--m-border);
  display: flex;
  flex-wrap: wrap;
  gap: var(--m-s-2);
}
.form-check + .form-check { margin-block-start: .35rem; }
.form-text { color: var(--m-muted); font-size: var(--m-t-xs); }
select.form-select option { background: #0b1020; color: var(--m-text); }

/* ------------------------------------------------------------- status rail */
.m-status-rail {
  display: flex;
  flex-wrap: wrap;
  gap: var(--m-s-2);
  align-items: center;
  padding: var(--m-s-2) var(--m-s-3);
  border: 1px solid var(--m-border);
  border-radius: var(--m-r);
  background: var(--m-panel-bg);
  font-size: var(--m-t-xs);
  margin-block-end: var(--m-s-4);
}
.m-status-rail .ms-auto { margin-inline-start: auto; }

/* --------------------------------------------------------------- POS grid */
/* Checkout is a workbench, not a page: cart + totals stay together, the
   tender panel is a rail on wide screens and stacks on 390. */
.pos-workbench { display: grid; grid-template-columns: minmax(0, 1fr) 20rem; gap: var(--m-s-4); align-items: start; }
/* the builder's column wrappers stay in the markup; the grid owns sizing */
.pos-workbench > [class*="col-"] { width: auto !important; max-width: none !important; padding: 0; }
.pos-workbench__rail { position: sticky; inset-block-start: calc(var(--m-s-6) + 1rem); display: grid; gap: var(--m-s-3); }
.pos-total-row { display: flex; justify-content: space-between; gap: var(--m-s-2); font-size: var(--m-t-sm); }
.pos-total-row + .pos-total-row { margin-block-start: .4rem; }
.pos-total-row.is-grand {
  margin-block-start: var(--m-s-3);
  padding-block-start: var(--m-s-3);
  border-block-start: 1px solid var(--m-border-strong);
  font-size: var(--m-t-lg);
  font-weight: var(--m-fw-bold);
  font-variant-numeric: tabular-nums;
  letter-spacing: var(--m-track-num);
}
@media (max-width: 991.98px) {
  .pos-workbench { grid-template-columns: minmax(0, 1fr); }
  .pos-workbench__rail { position: static; }
}

/* an empty ledger should not need horizontal scrolling on a phone: when the
   only content is the empty state, the dense-table min-width is dropped so the
   hint is fully readable instead of clipped by the scroll container. */
@media (max-width: 575.98px) {
  .table-responsive:has(.m-empty) > .table { min-width: 0; }
  /* the pack's ledger headers are nowrap; with an empty body that alone keeps
     the table wider than a phone, so they may wrap when nothing is listed */
  .table-responsive:has(.m-empty) > .table thead th { white-space: normal; }
  .pos-workbench .m-empty { padding-block: var(--m-s-4); }
  .pos-workbench .m-empty__hint { max-width: 30ch; }
}

/* ---------------------------------------------------------------- receipt */
.m-receipt {
  max-width: 32rem;
  margin-inline: auto;
  background: var(--m-surface);
  border: 1px solid var(--m-border);
  border-radius: var(--m-r);
  padding: var(--m-s-5);
  font-variant-numeric: tabular-nums;
}
.m-receipt__rule { border: 0; border-block-start: 1px dashed var(--m-border-strong); margin-block: var(--m-s-3); }
.m-receipt__row { display: flex; justify-content: space-between; gap: var(--m-s-3); font-size: var(--m-t-sm); }

/* ------------------------------------------------------------------ hero */
/* Landing composition. No invented figures: the panel is pure CSS chrome. */
.m-hero {
  position: relative;
  overflow: hidden;
  border: 1px solid var(--m-border);
  border-radius: var(--m-r-lg);
  background:
    radial-gradient(620px 320px at 88% -10%, rgba(46, 230, 197, .16), transparent 62%),
    radial-gradient(520px 300px at 8% 108%, rgba(91, 140, 255, .18), transparent 66%),
    var(--m-panel-bg);
  padding: var(--m-s-6) var(--m-s-5);
  margin-block-end: var(--m-pg-gap);
}
.m-hero__grid {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(0, .85fr);
  gap: var(--m-s-5);
  align-items: center;
}
.m-hero__title {
  margin: 0;
  font-size: clamp(1.9rem, 4.2vw, 3.1rem);
  line-height: 1.04;
  letter-spacing: -.02em;
  background: linear-gradient(180deg, #ffffff 12%, rgba(234, 240, 255, .68) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.m-hero__lead {
  color: var(--m-muted);
  font-size: var(--m-t-md);
  max-width: 46ch;
  margin-block: var(--m-s-3) var(--m-s-4);
  line-height: var(--m-lh);
}
.m-hero__actions { display: flex; flex-wrap: wrap; gap: var(--m-s-2); }
.m-hero__panel { display: grid; gap: .5rem; }
.m-hero__strip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--m-s-3);
  padding: .6rem var(--m-s-3);
  border: 1px solid var(--m-border);
  border-radius: var(--m-r-sm);
  background: rgba(255, 255, 255, .03);
  font-size: var(--m-t-xs);
  letter-spacing: .03em;
  color: var(--m-muted);
}
.m-hero__strip b { color: var(--m-text); font-weight: var(--m-fw-semi); }
.m-hero__strip i {
  display: block;
  height: 4px;
  flex: 1;
  border-radius: 4px;
  background: var(--m-grad);
  opacity: .55;
}
@media (max-width: 991.98px) {
  .m-hero__grid { grid-template-columns: minmax(0, 1fr); }
  .m-hero { padding: var(--m-s-5) var(--m-s-4); }
}

/* ------------------------------------------------------------- area cards */
/* The five product areas as a bento, numbered — not three identical tiles. */
.m-areas {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: var(--m-s-3);
  margin-block-end: var(--m-pg-gap);
}
.m-area {
  display: grid;
  gap: var(--m-s-2);
  padding: var(--m-s-4);
  border: 1px solid var(--m-border);
  border-radius: var(--m-r);
  background: var(--m-panel-bg);
  transition: border-color var(--m-base) var(--m-ease), background var(--m-base) var(--m-ease),
              transform var(--m-base) var(--m-ease);
}
.m-area:hover { border-color: var(--m-border-strong); background: var(--m-panel-bg-2); transform: translateY(-2px); }
.m-area__idx {
  font-family: var(--m-font-mono);
  font-size: var(--m-t-xs);
  color: var(--m-cyan);
  letter-spacing: .12em;
}
.m-area__title { margin: 0; font-size: var(--m-t-md); letter-spacing: var(--m-track-tight); }
.m-area__body { margin: 0; color: var(--m-muted); font-size: var(--m-t-sm); line-height: var(--m-lh); }
.m-area__links { display: flex; flex-wrap: wrap; gap: .35rem; margin-block-start: auto; }
.m-area__links a {
  font-size: var(--m-t-xs);
  color: var(--m-text);
  text-decoration: none;
  border: 1px solid var(--m-border);
  border-radius: var(--m-r-pill);
  padding: .2rem .6rem;
  transition: border-color var(--m-fast) linear, color var(--m-fast) linear, background var(--m-fast) linear;
}
.m-area__links a:hover { border-color: var(--m-cyan); color: var(--m-cyan); background: rgba(46, 230, 197, .08); }

/* ------------------------------------------------------------ prose block */
.m-prose { max-width: 68ch; }
.m-prose h2 {
  font-size: var(--m-t-lg);
  letter-spacing: var(--m-track-tight);
  margin-block: var(--m-s-5) var(--m-s-2);
}
.m-prose h2:first-child { margin-block-start: 0; }
.m-prose p, .m-prose li { color: var(--m-muted); font-size: var(--m-t-sm); line-height: var(--m-lh); }
.m-prose ul { padding-inline-start: 1.1rem; }
.m-prose strong { color: var(--m-text); }

/* ----------------------------------------------------------------- 390px */
@media (max-width: 575.98px) {
  main[role="main"] { padding-block-start: var(--m-s-4); }
  .m-page-header { align-items: flex-start; }
  .m-page-header__actions { width: 100%; }
  .m-page-header__actions .btn { flex: 1 1 auto; text-align: center; }
  .m-empty { padding: var(--m-s-5) var(--m-s-3); }
  .m-hero__strip i { display: none; }
  .m-areas { grid-template-columns: minmax(0, 1fr); }
}
