/* Stockroom - "The warehouse floor". Layered on Bootstrap 5.3.3.
   Concrete floor, carbon aisle signs, signal-yellow actions, hazard tape for low stock. */

/* 1. Tokens ---------------------------------------------------------------- */

:root {
  --font-ui: "Archivo", "Arial Narrow", Arial, sans-serif;
  --font-stencil: "Big Shoulders Stencil Display", "Archivo", Impact, sans-serif;
  /* Figures use the solid (non-stencil) cut of the same family: the stencil "4" breaks into
     a stem, a wedge and a dot ("4.") and the stencil ₹ loses its bars. Stencil is for words. */
  --font-figure: "Big Shoulders Display", "Archivo", Impact, sans-serif;
  --font-mono: "Chivo Mono", ui-monospace, Consolas, monospace;
  --font-barcode: "Libre Barcode 128";

  --floor: #dce0e1;        /* concrete */
  --floor-deep: #c3c9cb;   /* worn paint, disabled fills */
  --label: #ffffff;        /* label stock: panels, inputs, tags */
  --label-2: #f0f2f2;      /* filter band, hover rows, form footers */
  --carbon: #191b1d;       /* ink, rules, sidebar */
  --carbon-2: #2a2e31;
  --carbon-3: #3b4044;
  --steel: #50585c;        /* secondary text */
  --steel-side: #a3acb0;   /* secondary text on carbon */
  --side-ink: #dde2e4;     /* text on carbon */
  --rule: #b7bec1;         /* hairlines between rows (decorative) */
  --signal: #ffc800;       /* signal yellow */
  --signal-press: #ebb400;
  --signal-wash: #fff0b3;
  --red: #b3121b;
  --green: #2a6b33;
  --blue: #1c4c8a;

  --hazard: repeating-linear-gradient(-45deg, var(--signal) 0 7px, var(--carbon) 7px 14px);
  --keep-clear: repeating-linear-gradient(-45deg, var(--red) 0 7px, #fff 7px 14px);

  --bs-body-font-family: var(--font-ui);
  --bs-body-font-size: 0.9375rem;
  --bs-body-line-height: 1.5;
  --bs-body-color: var(--carbon);
  --bs-body-bg: var(--floor);
  --bs-emphasis-color: var(--carbon);
  --bs-secondary-color: var(--steel);
  --bs-border-color: var(--rule);
  --bs-border-radius: 0;
  --bs-border-radius-sm: 0;
  --bs-border-radius-lg: 0;
  --bs-border-radius-xl: 0;
  --bs-border-radius-xxl: 0;
  --bs-border-radius-pill: 0;
  --bs-link-color: var(--carbon);
  --bs-link-color-rgb: 25, 27, 29;
  --bs-link-hover-color: var(--carbon);
  --bs-link-hover-color-rgb: 25, 27, 29;
  --bs-primary-rgb: 25, 27, 29;
  --bs-danger-rgb: 179, 18, 27;
  --bs-success-rgb: 42, 107, 51;
  --bs-focus-ring-color: var(--carbon);
  --bs-form-invalid-color: var(--red);
  --bs-form-invalid-border-color: var(--red);
}

/* 2. Base ------------------------------------------------------------------ */

body {
  background: var(--floor);
  font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased;
}

a { text-underline-offset: 3px; text-decoration-thickness: 1px; }
a:hover { text-decoration-thickness: 2px; }

.text-muted { color: var(--steel) !important; }
.text-danger { color: var(--red) !important; }
.text-success { color: var(--green) !important; }
.num { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.mono-sm { font-family: var(--font-mono); font-size: 0.8125rem; }
.unit { color: var(--steel); font-size: 0.75rem; font-family: var(--font-mono); }

:focus-visible { outline: 3px solid var(--carbon); outline-offset: 2px; }

/* 3. Shell ----------------------------------------------------------------- */

.app-shell { display: flex; min-height: 100vh; }
.app-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.content { padding: 28px 32px 56px; width: 100%; max-width: 1480px; }

.sidebar {
  --bs-offcanvas-width: 264px;
  --bs-offcanvas-bg: var(--carbon);
  width: 248px;
  flex-shrink: 0;
  color: var(--side-ink);
  display: flex;
  flex-direction: column;
}
.sidebar.offcanvas-lg { background-color: var(--carbon) !important; }
@media (min-width: 992px) { .sidebar { position: sticky; top: 0; height: 100vh; } }

/* Store sign: a painted yellow plank */
.sidebar-brand {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--signal);
  border-bottom: 4px solid var(--carbon);
  padding: 10px 18px 9px;
}
.sidebar-brand .btn-close-white { filter: none; opacity: 1; }
.brand { display: inline-flex; flex-direction: column; text-decoration: none; color: var(--carbon); line-height: 1; }
.brand:hover { color: var(--carbon); }
.brand-mark { display: none; }
.brand-name {
  font-family: var(--font-stencil);
  font-weight: 800;
  font-size: 2rem;
  letter-spacing: 0.035em;
  text-transform: uppercase;
  line-height: 0.95;
}
.brand-sub {
  margin-top: 4px;
  font-family: var(--font-mono);
  font-size: 0.6875rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

/* On short screens the nav scrolls on its own: a thin carbon-3 bar on the carbon sign (never the
   UA's light scrollbar), and app.js brings the active plate into view on load. */
.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 6px 0 16px;
  counter-reset: aisle;
  scrollbar-width: thin;
  scrollbar-color: var(--carbon-3) var(--carbon);
}
.sidebar-nav::-webkit-scrollbar { width: 8px; }
.sidebar-nav::-webkit-scrollbar-track { background: var(--carbon); }
.sidebar-nav::-webkit-scrollbar-thumb { background: var(--carbon-3); }

/* Aisle sign: stencil letter block + section name */
.nav-section {
  counter-increment: aisle;
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 18px 18px 6px;
  font-stretch: 75%;
  font-weight: 700;
  font-size: 0.8125rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--steel-side);
}
.nav-section::before {
  content: counter(aisle, upper-alpha);
  content: counter(aisle, upper-alpha) / ""; /* empty alt text: not read as "A Overview" */
  display: inline-grid;
  place-items: center;
  width: 24px;
  height: 24px;
  background: var(--signal);
  color: var(--carbon);
  font-family: var(--font-stencil);
  font-weight: 800;
  font-size: 1.125rem;
  letter-spacing: 0;
  line-height: 1;
}
.nav-section::after { content: ""; flex: 1; height: 1px; background: var(--carbon-3); }

.nav-item {
  position: relative;
  display: flex;
  align-items: center;
  gap: 11px;
  margin: 0 22px 1px 18px;
  padding: 7px 10px 7px 10px;
  min-height: 36px;
  color: var(--side-ink);
  text-decoration: none;
  font-size: 0.875rem;
  font-weight: 500;
}
.nav-item .bi { font-size: 1rem; width: 18px; text-align: center; color: var(--steel-side); }
.nav-item:hover { background: var(--carbon-2); color: #fff; }
.nav-item:hover .bi { color: var(--side-ink); }

/* "You are here": the active item is a yellow direction sign pointing at the floor */
.nav-item.active {
  background: var(--signal);
  color: var(--carbon);
  font-weight: 700;
  margin-right: 8px;
  padding-right: 24px;
  clip-path: polygon(0 0, calc(100% - 14px) 0, 100% 50%, calc(100% - 14px) 100%, 0 100%);
}
.nav-item.active .bi { color: var(--carbon); }
.nav-item:focus-visible { outline: 2px solid var(--signal); outline-offset: -4px; }
.nav-item.active:focus-visible { outline-color: var(--carbon); }

.nav-badge {
  margin-left: auto;
  min-width: 26px;
  padding: 1px 5px;
  background: var(--signal);
  color: var(--carbon);
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: 700;
  text-align: center;
  line-height: 1.4;
}
.nav-item.active .nav-badge { background: var(--carbon); color: var(--signal); }

.sidebar-footer {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 18px;
  border-top: 1px solid var(--carbon-3);
}
.sidebar-user-name { color: #fff; font-size: 0.875rem; font-weight: 600; line-height: 1.2; }
.sidebar-user-role { font-family: var(--font-mono); font-size: 0.6875rem; letter-spacing: 0.06em; text-transform: uppercase; color: var(--steel-side); }

/* Top bar: solid concrete, ruled off like a floor line */
.topbar {
  position: sticky;
  top: 0;
  z-index: 1020;
  display: flex;
  align-items: center;
  gap: 12px;
  height: 64px;
  padding: 0 32px;
  background: var(--floor);
  border-bottom: 2px solid var(--carbon);
}

/* The search is the part that gives way when the bar is tight (992-1100px with the sidebar):
   min-width 0 lets it shrink below its input's intrinsic width, and the actions never shrink,
   so "Record movement" stays one 38px line beside the 40px bell. */
.topbar-search { position: relative; display: flex; align-items: center; flex: 0 1 420px; min-width: 0; }
.topbar-search .bi { position: absolute; left: 12px; color: var(--carbon); font-size: 1rem; pointer-events: none; }
.topbar-search input {
  width: 100%;
  height: 40px;
  padding: 0 12px 0 40px;
  border: 2px solid var(--carbon);
  border-radius: 0;
  background: var(--label);
  font-size: 0.875rem;
  color: var(--carbon);
}
.topbar-search input::placeholder { color: var(--steel); }
/* Yellow is never a boundary on its own: the ring is yellow with a 2px carbon outer edge,
   and the border doubles (inset), so the focused field changes by far more than 3:1 */
.topbar-search input:focus {
  outline: 3px solid var(--signal);
  outline-offset: 0;
  box-shadow: inset 0 0 0 1px var(--carbon), 0 0 0 5px var(--carbon);
}

.topbar-actions { margin-left: auto; display: flex; flex-shrink: 0; align-items: center; gap: 10px; }
.topbar-actions .btn { white-space: nowrap; }

.btn-icon {
  position: relative;
  width: 40px;
  height: 40px;
  padding: 0;
  display: inline-grid;
  place-items: center;
  border: 2px solid var(--carbon);
  border-radius: 0;
  background: var(--label);
  color: var(--carbon);
  font-size: 1.125rem;
}
.btn-icon:hover, .btn-icon[aria-expanded="true"] { background: var(--signal); border-color: var(--carbon); color: var(--carbon); }

.bell-count {
  position: absolute;
  top: -9px;
  right: -9px;
  min-width: 22px;
  height: 20px;
  padding: 0 4px;
  background: var(--red);
  color: #fff;
  border: 2px solid var(--carbon);
  font-family: var(--font-mono);
  font-size: 0.6875rem;
  font-weight: 700;
  line-height: 16px;
  text-align: center;
  white-space: nowrap; /* anchored right, so 3-digit counts grow left over the bell, not into the user button */
}

.user-menu-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 2px 6px 2px 2px;
  border: 2px solid transparent;
  border-radius: 0;
}
.user-menu-btn:hover, .user-menu-btn[aria-expanded="true"] { border-color: var(--carbon); background: var(--label); }

/* Dropdowns: a plain sign, heavy border, nothing floating. White label stock: Bootstrap's menu
   background falls back to --bs-body-bg (the concrete floor), so it is set explicitly, and the
   label-2 hover reads as the darker tint it is meant to be. */
.dropdown-menu {
  --bs-dropdown-bg: var(--label);
  --bs-dropdown-border-color: var(--carbon);
  --bs-dropdown-border-width: 2px;
  --bs-dropdown-border-radius: 0;
  --bs-dropdown-link-hover-bg: var(--label-2);
  --bs-dropdown-link-active-bg: var(--signal);
  --bs-dropdown-link-active-color: var(--carbon);
  --bs-dropdown-font-size: 0.875rem;
  --bs-dropdown-header-color: var(--steel);
  box-shadow: none;
  padding: 4px;
}
.dropdown-item { display: flex; align-items: center; gap: 9px; padding: 8px 10px; color: var(--carbon); }
.dropdown-item .bi { width: 16px; text-align: center; }
.dropdown-item:focus-visible { outline: 3px solid var(--carbon); outline-offset: -3px; }
.dropdown-divider { border-color: var(--carbon); opacity: 1; margin: 4px 0; }
/* Signed-in-as block in the user menu: name, then a mono "@username · Role" line */
.dropdown-header { padding: 8px 10px 6px; color: var(--carbon); }
.dropdown-header .small { font-family: var(--font-mono); font-size: 0.75rem; color: var(--steel); }
/* The one destructive item (Archive product): red text, and a red prohibition-sign fill on hover/focus */
.dropdown-item.text-danger:hover, .dropdown-item.text-danger:focus { background: var(--red); color: #fff !important; }
form > .dropdown-item { width: 100%; }

.alert-menu { width: 360px; padding: 0; }
.alert-menu-head {
  display: flex;
  flex-direction: column;
  padding: 12px 16px;
  background: var(--carbon);
  color: #fff;
  font-stretch: 75%;
  font-weight: 800;
  font-size: 1rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.alert-menu-head .small { font-stretch: 100%; font-weight: 400; text-transform: none; letter-spacing: 0; color: var(--side-ink) !important; }
.alert-menu-list { max-height: 336px; overflow-y: auto; }
.alert-menu-item {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px 10px 26px;
  border-bottom: 1px solid var(--rule);
  color: var(--carbon);
  text-decoration: none;
  font-size: 0.8125rem;
}
.alert-menu-item:hover { background: var(--label-2); color: var(--carbon); }
.alert-menu-item .status-dot { position: absolute; left: 0; top: 0; bottom: 0; width: 10px; height: auto; margin: 0; border: 0; background: var(--hazard); }
/* 0,3,0 so the tape beats the plain .status-dot.status-low / .status-out fills (0,2,0) declared later */
.alert-menu-item .status-dot.status-low { background: var(--hazard); }
.alert-menu-item .status-dot.status-out { background: var(--keep-clear); }
.alert-menu-name { flex: 1; min-width: 0; line-height: 1.3; font-weight: 600; }
.alert-menu-name small { display: block; color: var(--steel); font-family: var(--font-mono); font-size: 0.6875rem; font-weight: 400; }
.alert-menu-qty { font-family: var(--font-mono); font-size: 0.75rem; white-space: nowrap; }
.alert-menu-empty { padding: 20px 16px; color: var(--steel); font-size: 0.8125rem; }
.alert-menu-footer {
  display: block;
  padding: 10px 16px;
  font-weight: 700;
  font-size: 0.8125rem;
  text-decoration: none;
  color: var(--carbon);
}
.alert-menu-footer:hover { background: var(--signal); color: var(--carbon); }

/* 4. Buttons --------------------------------------------------------------- */

.btn {
  --bs-btn-font-family: var(--font-ui);
  --bs-btn-font-size: 0.875rem;
  --bs-btn-font-weight: 700;
  --bs-btn-border-width: 2px;
  --bs-btn-border-radius: 0;
  --bs-btn-padding-x: 0.95rem;
  --bs-btn-padding-y: 0.4rem;
  --bs-btn-focus-box-shadow: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  font-stretch: 87.5%;
  letter-spacing: 0.01em;
}
/* Hover changes stay under 80ms. Box-shadow is not transitioned at all, so a focus ring's
   carbon outer edge appears with its yellow fill instead of fading in after it. */
.btn, .page-link { transition: color 60ms ease-out, background-color 60ms ease-out, border-color 60ms ease-out; }
.form-control, .form-select { transition: border-color 60ms ease-out; }
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: 3px solid var(--carbon); outline-offset: 2px; box-shadow: none; }
.btn-lg { --bs-btn-font-size: 1rem; --bs-btn-padding-y: 0.65rem; }
.btn-sm { --bs-btn-font-size: 0.8125rem; --bs-btn-padding-x: 0.6rem; --bs-btn-padding-y: 0.22rem; }

.btn-primary {
  --bs-btn-color: var(--carbon);
  --bs-btn-bg: var(--signal);
  --bs-btn-border-color: var(--carbon);
  --bs-btn-hover-color: var(--carbon);
  --bs-btn-hover-bg: #ffd52e;
  --bs-btn-hover-border-color: var(--carbon);
  --bs-btn-active-color: var(--carbon);
  --bs-btn-active-bg: var(--signal-press);
  --bs-btn-active-border-color: var(--carbon);
  --bs-btn-disabled-color: var(--steel);
  --bs-btn-disabled-bg: var(--floor-deep);
  --bs-btn-disabled-border-color: var(--steel);
}
.btn-light, .btn-outline-secondary {
  --bs-btn-color: var(--carbon);
  --bs-btn-bg: var(--label);
  --bs-btn-border-color: var(--carbon);
  --bs-btn-hover-color: var(--carbon);
  --bs-btn-hover-bg: var(--label-2);
  --bs-btn-hover-border-color: var(--carbon);
  --bs-btn-active-color: var(--carbon);
  --bs-btn-active-bg: var(--floor);
  --bs-btn-active-border-color: var(--carbon);
}
.btn-secondary {
  --bs-btn-color: #fff;
  --bs-btn-bg: var(--carbon);
  --bs-btn-border-color: var(--carbon);
  --bs-btn-hover-color: #fff;
  --bs-btn-hover-bg: var(--carbon-3);
  --bs-btn-hover-border-color: var(--carbon);
  --bs-btn-active-bg: #000;
}
.btn-danger {
  --bs-btn-color: #fff;
  --bs-btn-bg: var(--red);
  --bs-btn-border-color: var(--carbon);
  --bs-btn-hover-color: #fff;
  --bs-btn-hover-bg: #95101a;
  --bs-btn-hover-border-color: var(--carbon);
  --bs-btn-active-bg: #7d0d15;
  --bs-btn-active-border-color: var(--carbon);
}
.btn-link { --bs-btn-font-weight: 600; text-decoration: underline; text-underline-offset: 3px; }
.btn-icon-only { width: 40px; padding-left: 0; padding-right: 0; }
.btn-icon-only:hover, .btn-icon-only[aria-expanded="true"] { --bs-btn-hover-bg: var(--signal); --bs-btn-active-bg: var(--signal); background: var(--signal); }
.btn-close { --bs-btn-close-opacity: 0.8; border-radius: 0; }
.btn-close-sm { width: 0.6em; height: 0.6em; }

/* 5. Printed tags ------------------------------------------------------------ */

.status-pill, .kind-pill, .role-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 1px 7px 1px 6px;
  border: 1.5px solid var(--carbon);
  border-radius: 0;
  background: var(--label);
  color: var(--carbon);
  font-stretch: 75%;
  font-size: 0.8125rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  white-space: nowrap;
  line-height: 1.45;
}
/* Status: a printed square marker, not a round icon */
.status-pill .bi { display: none; }
.status-pill::before { content: ""; width: 8px; height: 8px; flex-shrink: 0; background: var(--green); }
.status-pill.status-low { background: var(--signal); }
.status-pill.status-low::before { background: var(--carbon); }
.status-pill.status-out { background: var(--red); color: #fff; }
.status-pill.status-out::before { background: #fff; }

.status-dot { display: inline-block; width: 9px; height: 9px; flex-shrink: 0; margin-right: 6px; border: 1px solid var(--carbon); }
.status-dot.status-in { background: var(--green); }
.status-dot.status-low { background: var(--signal); }
.status-dot.status-out { background: var(--red); }

/* Movement kinds: ledger codes ruled on the left (same language as the dashboard activity list),
   so they never read as buttons or as stock-status tags */
.kind-pill { border: 0; border-left: 4px solid var(--carbon); background: transparent; padding: 0 2px 0 7px; }
.kind-pill .bi { font-size: 0.8rem; }
.kind-pill.kind-in { border-left-color: var(--green); color: var(--green); }
.kind-pill.kind-return { border-left-color: var(--blue); color: var(--blue); }
.kind-pill.kind-adjust { border-left-color: var(--carbon); background: var(--signal); padding-right: 6px; }

/* Roles: site hard-hat colours. White = site manager (admin), blue = supervisor (manager), yellow = floor crew (staff) */
.role-admin { background: var(--label); }
.role-manager { background: var(--blue); color: #fff; }
.role-staff { background: var(--signal); }

.avatar {
  width: 34px;
  height: 34px;
  display: inline-grid;
  place-items: center;
  flex-shrink: 0;
  border: 2px solid var(--carbon);
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--carbon);
}
.avatar-sm { width: 32px; height: 32px; font-size: 0.6875rem; }
.avatar-admin { background: var(--label); }
.avatar-manager { background: var(--blue); color: #fff; }
.avatar-staff { background: var(--signal); }
.sidebar .avatar { border-color: var(--label); }

.qty-change { font-family: var(--font-mono); font-weight: 700; font-size: 0.875rem; }
.qty-change.up { color: var(--green); }
.qty-change.down { color: var(--red); }

/* SKU: a thermal-printed label */
.sku {
  display: inline-block;
  padding: 0 6px;
  border: 1px solid var(--carbon);
  background: var(--label);
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: 500;
  letter-spacing: 0.02em;
  color: var(--carbon);
  white-space: nowrap;
  line-height: 1.6;
}
.sku-sm { font-size: 0.6875rem; padding: 0 5px; }
.location { font-family: var(--font-mono); font-size: 0.8125rem; letter-spacing: 0.02em; }

.barcode {
  font-family: var(--font-barcode);
  font-weight: 400;
  line-height: 1;
  letter-spacing: 0;
  color: var(--carbon);
  white-space: nowrap;
  overflow: hidden;
}

/* 6. Page structure ------------------------------------------------------------ */

.page-header { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 12px 16px; margin-bottom: 22px; }
/* the title keeps at least 26rem; a long product name pushes the actions onto their own line
   instead of being squeezed into a narrow column */
.page-header > div:first-child { flex: 1 1 26rem; min-width: 0; }
.page-title {
  margin: 0;
  overflow-wrap: anywhere; /* 80-character product names wrap instead of pushing the actions off */
  text-wrap: balance;
  font-stretch: 75%;
  font-weight: 800;
  font-size: 2.125rem;
  line-height: 1.05;
  letter-spacing: -0.005em;
}
.page-subtitle { margin: 6px 0 0; color: var(--steel); font-size: 0.9375rem; max-width: 760px; }
.page-actions { display: flex; flex-wrap: wrap; flex-shrink: 0; align-items: center; justify-content: flex-end; gap: 8px; }

.crumbs {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 8px;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  letter-spacing: 0.02em;
  color: var(--steel);
}
.crumbs a { color: var(--carbon); }
.crumbs .bi { font-size: 0.625rem; }

.card {
  --bs-card-border-width: 1px;
  --bs-card-border-color: var(--carbon);
  --bs-card-border-radius: 0;
  --bs-card-inner-border-radius: 0;
  --bs-card-cap-bg: transparent;
  --bs-card-bg: var(--label);
  box-shadow: none;
}
/* Header is a 2-row grid: title + action share row 1 (action pinned right, pulled to the title's
   line height), the subtitle runs full width in row 2. So headers with and without an action are
   the same height and panels side by side start their first row on the same line. The template's
   inner <div> is display: contents (a plain div, no semantics lost). */
.card-header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  column-gap: 12px;
  padding: 14px 18px 12px;
  border-bottom: 2px solid var(--carbon);
}
.card-header > div { display: contents; }
.card-title { grid-column: 1; grid-row: 1; margin: 0; font-stretch: 87.5%; font-weight: 800; font-size: 1.0625rem; line-height: 1.25; }
.card-subtitle { grid-column: 1 / -1; grid-row: 2; margin: 2px 0 0; color: var(--steel); font-size: 0.8125rem; }
.card-header > .card-link { grid-column: 2; grid-row: 1; margin-block: -5px; }
.card-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 8px;
  border: 1.5px solid var(--carbon);
  color: var(--carbon);
  font-stretch: 87.5%;
  font-size: 0.8125rem;
  font-weight: 700;
  text-decoration: none;
  white-space: nowrap;
}
.card-link::after { content: "\f138"; font-family: "bootstrap-icons"; font-size: 0.75rem; }
.card-link:hover { background: var(--signal); color: var(--carbon); }
.card-body { padding: 18px; }
.card-footer { --bs-card-cap-bg: var(--label-2); border-top: 1px solid var(--carbon); }

/* 7. Dashboard ------------------------------------------------------------------- */

/* DOM order = visual order = tab order at every width (no dense auto-placement):
   A-01 stock value (wide), A-02 SKUs, A-03 low, A-04 out, A-05 movements today */
.kpi-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.5fr) repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 16px;
}

/* Bin label: location code, stencil figure, Code-128 strip */
.kpi-card {
  position: relative;
  display: flex;
  flex-direction: column;
  background: var(--label);
  border: 2px solid var(--carbon);
}
/* Every label has a 10px top band so the rows line up; alerts get tape on it */
.kpi-card { padding-top: 10px; }
.kpi-card::before { content: ""; position: absolute; left: 0; right: 0; top: 0; height: 10px; background: var(--carbon); }
.kpi-card.kpi-low::before { background: var(--hazard); border-bottom: 2px solid var(--carbon); }
.kpi-card.kpi-out::before { background: var(--keep-clear); border-bottom: 2px solid var(--carbon); }
.kpi-card.is-zero::before { background: var(--carbon); border-bottom: 0; }

.kpi-label {
  padding: 6px 12px 5px;
  background: var(--carbon);
  color: #fff;
  font-stretch: 75%;
  font-size: 0.875rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.kpi-value {
  margin: 0;
  padding: 10px 14px 2px;
  font-family: var(--font-figure);
  font-weight: 800;
  font-size: 3.5rem;
  line-height: 1;
  letter-spacing: 0.01em;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
  transition: background-color 0.6s ease;
}
/* The value bin sizes its figure to the bin, so a 12-character crore figure (₹1,02,45,890)
   still fits at 1200px. Fallback without container queries: viewport-based clamp. */
.kpi-wide { container-type: inline-size; }
.kpi-wide .kpi-value { font-size: min(3.5rem, calc((100cqi - 32px) / var(--fig-em, 4))); }
.kpi-wide .kpi-value.is-long { --fig-em: 5.2; } /* 11-13 characters (up to ₹99,99,99,999); set by Jinja and setKpis() */
@supports not (width: 1cqi) {
  .kpi-wide .kpi-value { font-size: clamp(2.25rem, 3.4vw, 3.5rem); }
}
.kpi-value.changed { background-color: var(--signal-wash); }
.kpi-code { display: flex; align-items: flex-end; justify-content: space-between; gap: 8px; padding: 0 14px 8px; margin-top: auto; }
.kpi-code .barcode { min-width: 0; font-size: 2.25rem; height: 26px; }
.kpi-code-text { flex-shrink: 0; white-space: nowrap; font-family: var(--font-mono); font-size: 0.6875rem; letter-spacing: 0.08em; color: var(--steel); }
/* Ruled footer row: label column + fixed 18px arrow column, so the arrow never hits the border */
.kpi-link, .kpi-note {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 18px;
  align-items: center;
  column-gap: 6px;
  padding: 7px 12px 7px 14px;
  border-top: 1px solid var(--carbon);
  font-stretch: 87.5%;
  font-size: 0.8125rem;
  font-weight: 700;
  color: var(--carbon);
  text-decoration: none;
}
.kpi-link > span, .kpi-note > span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.kpi-note { grid-template-columns: minmax(0, 1fr); color: var(--steel); font-weight: 500; }
.kpi-link::after { content: "\f138"; font-family: "bootstrap-icons"; font-weight: 400; justify-self: end; }
.kpi-link:hover { background: var(--signal); color: var(--carbon); }

/* Panel-mount status lamp */
.live-pill {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  padding: 6px 12px 6px 8px;
  background: var(--label);
  border: 2px solid var(--carbon);
  font-family: var(--font-mono);
  font-size: 0.75rem;
  letter-spacing: 0.02em;
  color: var(--carbon);
}
.live-dot { width: 12px; height: 12px; border: 2px solid var(--carbon); background: #3fae4c; animation: lamp 2.4s steps(1, end) infinite; }
.live-pill.is-stale .live-dot { background: var(--signal); animation: none; }
.live-pill.is-paused .live-dot { background: var(--floor-deep); animation: none; }
@keyframes lamp { 0%, 82% { background: #3fae4c; } 83%, 100% { background: var(--green); } }

.chart-box { position: relative; height: 240px; }
.chart-box-lg { height: 290px; }
/* A chart in a stretched (h-100) panel grows with the panel instead of leaving a void */
.card.h-100 > .card-body { display: flex; flex-direction: column; }
.card.h-100 > .card-body > .chart-box { flex: 1 1 auto; }

.activity-list, .reorder-list { list-style: none; margin: 0; padding: 0; }
.activity-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 18px;
  border-bottom: 1px solid var(--rule);
}
.activity-item:last-child, .reorder-item:last-child { border-bottom: 0; }

/* Dock-door code instead of an icon tile */
.activity-icon {
  flex-shrink: 0;
  width: 40px;
  padding: 1px 0 1px 7px;
  border-left: 4px solid var(--carbon);
  font-family: var(--font-mono);
  font-size: 0.6875rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  line-height: 1.5;
}
.activity-icon .bi { display: none; }
.activity-icon.kind-in { border-left-color: var(--green); color: var(--green); }
.activity-icon.kind-return { border-left-color: var(--blue); color: var(--blue); }
.activity-icon.kind-adjust { border-left-color: var(--signal); }
/* The code is visual shorthand; the full kind label is a .visually-hidden span inside the icon,
   so the code itself gets empty alt text and the meta line does not repeat "Stock out". */
.activity-icon.kind-out::before { content: "OUT"; content: "OUT" / ""; }
.activity-icon.kind-in::before { content: "IN"; content: "IN" / ""; }
.activity-icon.kind-return::before { content: "RET"; content: "RET" / ""; }
.activity-icon.kind-adjust::before { content: "ADJ"; content: "ADJ" / ""; }
.activity-body { flex: 1; min-width: 0; }
.activity-product {
  display: block;
  color: var(--carbon);
  font-size: 0.875rem;
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.activity-product:hover { text-decoration: underline; }
.activity-meta { font-size: 0.75rem; color: var(--steel); }
.activity-empty { padding: 24px 18px; color: var(--steel); font-size: 0.875rem; }

.reorder-item { position: relative; padding: 11px 18px 12px 30px; border-bottom: 1px solid var(--rule); }
.reorder-item::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 12px; background: var(--hazard); border-right: 1px solid var(--carbon); }
.reorder-item:has(.meter-out)::before { background: var(--keep-clear); }
.reorder-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; margin-bottom: 7px; }
.reorder-name {
  color: var(--carbon);
  font-size: 0.875rem;
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.reorder-name:hover { text-decoration: underline; }
.reorder-qty { font-family: var(--font-mono); font-size: 0.75rem; color: var(--steel); white-space: nowrap; }
.reorder-qty strong { color: var(--carbon); font-weight: 700; }

/* Fastest moving: a ranked pick list instead of a truncated bar chart */
.movers-list { list-style: none; margin: 0; padding: 0; }
.mover-item { display: flex; align-items: flex-start; gap: 14px; padding: 13px 18px 14px; border-bottom: 1px solid var(--rule); }
.mover-item:last-child { border-bottom: 0; }
.mover-rank { flex-shrink: 0; width: 34px; font-family: var(--font-figure); font-weight: 800; font-size: 2rem; line-height: 0.9; }
.mover-body { flex: 1; min-width: 0; }
.mover-head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
.mover-name { color: var(--carbon); font-size: 0.875rem; font-weight: 600; line-height: 1.3; text-decoration: none; }
.mover-name:hover { text-decoration: underline; }
.mover-qty { font-family: var(--font-mono); font-size: 0.75rem; color: var(--steel); white-space: nowrap; }
.mover-qty strong { color: var(--carbon); font-size: 0.875rem; }
.mover-sub { display: flex; align-items: center; gap: 10px; margin-top: 7px; }
.mover-sub .meter { flex: 1; }
.meter-move span { background: var(--signal); border-right: 1px solid var(--carbon); }

/* Gauge: a level strip with tick marks every 10 % */
.meter { position: relative; height: 10px; border: 1px solid var(--carbon); background: var(--label); overflow: hidden; }
.meter::after {
  content: "";
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(90deg, transparent 0 calc(10% - 1px), rgba(25, 27, 29, 0.45) calc(10% - 1px) 10%);
  pointer-events: none;
}
.meter span { display: block; height: 100%; width: 0; transition: width 0.4s ease; }
.meter-in span { background: var(--green); }
.meter-low span { background: var(--signal); border-right: 1px solid var(--carbon); }
/* An empty gauge looks empty: white track, ticks, and a 3px red cap at the zero end.
   (Severity is already on the row edge as keep-clear tape.) */
.meter-out { background: var(--label); box-shadow: inset 3px 0 0 var(--red); }
.meter-out span { background: var(--red); }
.meter-share span { background: var(--carbon); }

/* 8. Tables and filters --------------------------------------------------------- */

/* A positioned scroll box, so absolutely positioned descendants (the .visually-hidden "Actions"
   header label) are clipped by it instead of widening the whole page */
.table-responsive { position: relative; }

.data-table {
  --bs-table-bg: transparent;
  --bs-table-border-color: var(--rule);
  --bs-table-hover-bg: var(--label-2);
  font-size: 0.875rem;
}
.data-table > thead > tr > th {
  background: var(--label);
  color: var(--carbon);
  font-stretch: 75%;
  font-size: 0.8125rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 9px 14px 8px;
  white-space: nowrap;
  border-bottom: 2px solid var(--carbon);
}
.data-table > tbody > tr > td { padding: 10px 14px; }
.data-table > :not(caption) > * > :first-child { padding-left: 18px; }
.data-table > :not(caption) > * > :last-child { padding-right: 18px; }
.data-table > tbody > tr:hover > td { background-color: var(--label-2); }
.data-table > tbody > tr:last-child > td { border-bottom: 0; }
.data-table .num { white-space: nowrap; }
.row-link { cursor: pointer; }
/* Deactivated user: marked, not faded. No opacity on text (it broke AA). The row sits on the
   label-2 band, name and email go steel (6.46:1 on label-2), the hard hat and role tag are
   "out of service" floor-deep with carbon text (10.31:1), and the Deactivated tag says why. */
.row-muted > td, .data-table > tbody > tr.row-muted:hover > td { background-color: var(--label-2); }
.row-muted .user-cell .fw-semibold, .row-muted .cell-sub { color: var(--steel); }
.row-muted .avatar, .row-muted .role-pill { background: var(--floor-deep); color: var(--carbon); }

.sort-link { display: inline-flex; align-items: center; gap: 5px; color: inherit; text-decoration: none; }
.sort-link .bi { font-size: 0.7rem; opacity: 0.4; }
.sort-link:hover, .sort-link.active { text-decoration: underline; text-underline-offset: 4px; }
.sort-link.active .bi { opacity: 1; }
.text-end .sort-link { flex-direction: row-reverse; }

.cell-product { min-width: 220px; }
/* Products list: the Category column appears from 1400px (d-xxl-table-cell); below that the
   category rides in the sub-line after the supplier, so names get one line (rows ~62px at 1366). */
.products-table > tbody > tr > td:nth-child(3) { white-space: nowrap; }
/* With the sidebar (992+) the panel is ~680-970px: Stock value gets its own column at 1200
   (d-xl-table-cell) and Location at 1280, and the name column gives up 40px below 1200, so no
   column scrolls. Below that both are folded, not dropped (see "Folded columns" below). */
@media (max-width: 1279.98px) { .products-table .col-location { display: none !important; } }
@media (min-width: 992px) and (max-width: 1199.98px) { .products-table .cell-product { min-width: 180px; } }

/* Folded columns. At laptop and tablet widths (768-1279; with the sidebar the panel is only
   ~680-970px) a few columns step out rather than scroll sideways, but their data stays on screen:
   it rides in a steel sub-line under a neighbouring figure, shown only in the band where its
   column is out. The header names it on a second line (.th-fold), or the line labels itself
   (.fold-label, in the UI face so the figure stays the mono one).
   - Products: Location under the SKU label (below 1280); Stock value under the Price (below
     1200, d-xl-none), and the Price header's second line keeps the Stock value sort.
   - Transactions: "by {user}" under the time (768-1199, d-md-block d-xl-none).
   - Alerts: the level gauge under On hand (768-1279); "N sold in 30 days" under the status tag,
     which has room to spare below the pill (768-1199).
   - Reports: the share under Value at cost (768-1279); Potential margin under Value at selling
     price (768-1099). Screen only: the printed stock sheet has every column. */
.th-fold { display: block; margin-top: 3px; color: var(--steel); }
.fold-label { font-family: var(--font-ui); }
.fold-location, .fold-meter, .fold-share, .fold-margin { display: none; }
@media (max-width: 1279.98px) {
  .products-table .fold-location { display: block; }
}
.products-table td > .fold-location { margin-top: 4px; }
.alerts-table .fold-sold { margin-top: 5px; white-space: nowrap; }
.when-by { font-family: var(--font-ui); white-space: normal; }
@media screen and (min-width: 768px) and (max-width: 1279.98px) {
  /* the folded gauge spans the figures above it (width auto adds nothing to the column) */
  .alerts-table td > .fold-meter { display: block; width: auto; margin: 7px 0 1px; }
  .report-table .fold-share { display: block; }
}
@media screen and (min-width: 768px) and (max-width: 1099.98px) {
  .report-table .fold-margin { display: block; }
}
.report-table tfoot .cell-sub { font-weight: 500; }
.cell-sub { font-size: 0.75rem; color: var(--steel); margin-top: 3px; }
.product-link { color: var(--carbon); font-weight: 600; text-decoration: none; }
.product-link:hover { color: var(--carbon); text-decoration: underline; }
.cell-details { font-size: 0.8125rem; max-width: 340px; }
.cell-meter { min-width: 140px; }
.suggested { font-weight: 700; }
.cell-details span { display: inline-block; margin-right: 8px; }
.cell-details .ref { font-family: var(--font-mono); font-size: 0.75rem; }
.cell-details .reason { font-weight: 700; }
.cell-details .note { color: var(--steel); font-style: italic; }

.filter-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 10px;
  padding: 12px 18px;
  background: var(--label-2);
  border-bottom: 1px solid var(--carbon);
}
.filter-bar .form-select { width: auto; max-width: 240px; }
.filter-search { position: relative; flex: 1 1 240px; max-width: 340px; }
.filter-search .bi { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--carbon); font-size: 0.9rem; }
.filter-search .form-control { padding-left: 36px; }
.filter-field { display: flex; flex-direction: column; min-width: 140px; }
.filter-field label { font-stretch: 87.5%; font-size: 0.75rem; font-weight: 700; color: var(--carbon); margin-bottom: 4px; }
.filter-bar-wrap .form-select { max-width: none; width: 100%; }
.filter-field-wide { flex: 1 1 220px; max-width: 320px; }
.filter-buttons { display: flex; gap: 4px; }

/* Segmented: one strip of switch positions */
.segmented { display: inline-flex; flex-wrap: wrap; border: 2px solid var(--carbon); background: var(--label); }
.segmented-item {
  display: inline-flex;
  align-items: center;
  padding: 6px 14px;
  border-right: 1px solid var(--carbon);
  color: var(--carbon);
  font-stretch: 87.5%;
  font-size: 0.8125rem;
  font-weight: 700;
  text-decoration: none;
}
.segmented-item:last-child { border-right: 0; }
.segmented-item:hover { background: var(--label-2); color: var(--carbon); }
.segmented-item.active { background: var(--signal); }
.segmented-item:focus-visible { position: relative; z-index: 1; }

.table-footer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 18px;
  border-top: 2px solid var(--carbon);
  font-family: var(--font-mono);
  font-size: 0.75rem;
}
.pagination {
  --bs-pagination-color: var(--carbon);
  --bs-pagination-bg: var(--label);
  --bs-pagination-border-color: var(--carbon);
  --bs-pagination-border-radius: 0;
  --bs-pagination-hover-color: var(--carbon);
  --bs-pagination-hover-bg: var(--label-2);
  --bs-pagination-hover-border-color: var(--carbon);
  --bs-pagination-active-color: var(--carbon);
  --bs-pagination-active-bg: var(--signal);
  --bs-pagination-active-border-color: var(--carbon);
  --bs-pagination-disabled-color: var(--steel);
  --bs-pagination-disabled-bg: var(--label-2);
  --bs-pagination-disabled-border-color: var(--carbon);
  --bs-pagination-focus-box-shadow: none;
  font-family: var(--font-mono);
}

/* 9. Floor bays: empty states and error pages ------------------------------------ */

.bay, .empty-state {
  --mark: var(--signal);
  --len: 30px;
  --w: 6px;
  position: relative;
  text-align: center;
  background:
    linear-gradient(var(--mark) 0 0) top left / var(--len) var(--w) no-repeat,
    linear-gradient(var(--mark) 0 0) top left / var(--w) var(--len) no-repeat,
    linear-gradient(var(--mark) 0 0) top right / var(--len) var(--w) no-repeat,
    linear-gradient(var(--mark) 0 0) top right / var(--w) var(--len) no-repeat,
    linear-gradient(var(--mark) 0 0) bottom left / var(--len) var(--w) no-repeat,
    linear-gradient(var(--mark) 0 0) bottom left / var(--w) var(--len) no-repeat,
    linear-gradient(var(--mark) 0 0) bottom right / var(--len) var(--w) no-repeat,
    linear-gradient(var(--mark) 0 0) bottom right / var(--w) var(--len) no-repeat;
}
.empty-state { margin: 20px; padding: 44px 24px 40px; }
.empty-icon { margin: 0 auto 10px; color: var(--carbon); font-size: 1.75rem; line-height: 1; }
.empty-state h3 { font-stretch: 75%; font-size: 1.375rem; font-weight: 800; margin-bottom: 4px; }
.empty-state p { color: var(--steel); font-size: 0.875rem; max-width: 420px; margin: 0 auto 16px; }

/* 10. Forms ------------------------------------------------------------------------ */

.form-label { font-stretch: 87.5%; font-size: 0.8125rem; font-weight: 700; color: var(--carbon); margin-bottom: 5px; }
.form-text { font-size: 0.75rem; color: var(--steel); }
.form-control, .form-select {
  border: 1px solid var(--carbon);
  border-radius: 0;
  background-color: var(--label);
  font-size: 0.9rem;
  padding-top: 0.45rem;
  padding-bottom: 0.45rem;
  color: var(--carbon);
}
.form-select { --bs-form-select-bg-img: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='%23191b1d' stroke-linecap='square' stroke-width='2.5' d='m2 5 6 6 6-6'/%3e%3c/svg%3e"); }
.form-control::placeholder { color: #6b7377; }
.form-control-lg { font-size: 1rem; padding-top: 0.6rem; padding-bottom: 0.6rem; }
/* Focus: border doubles (inset), then a 3px yellow ring with a 2px carbon outer edge.
   Yellow on white is only 1.55:1, so the carbon edge (17.27:1) is what carries the 3:1 change. */
.form-control:focus, .form-select:focus {
  background-color: var(--label); /* Bootstrap uses --bs-body-bg here, which is the concrete floor */
  border-color: var(--carbon);
  box-shadow: inset 0 0 0 1px var(--carbon), 0 0 0 5px var(--carbon);
  outline: 3px solid var(--signal);
  outline-offset: 0;
}
/* Dates are figures: mono, with a square carbon calendar plate instead of the UA glyph */
.form-control[type="date"] { font-family: var(--font-mono); font-size: 0.8125rem; }
.form-control[type="date"]::-webkit-calendar-picker-indicator {
  width: 22px;
  height: 22px;
  margin-right: -4px;
  padding: 0;
  cursor: pointer;
  opacity: 1;
  background: var(--label) url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 22 22'%3e%3cpath d='M4 6h14v12H4z' fill='none' stroke='%23191b1d' stroke-width='2'/%3e%3cpath d='M4 6h14v3H4z' fill='%23191b1d'/%3e%3cpath d='M8 3v4M14 3v4' stroke='%23191b1d' stroke-width='2'/%3e%3cpath d='M7 12h3v2H7zM12 12h3v2h-3z' fill='%23191b1d'/%3e%3c/svg%3e") center / 18px no-repeat;
}
.form-control[type="date"]::-webkit-calendar-picker-indicator:hover { background-color: var(--signal); }
.form-control.is-invalid, .form-select.is-invalid {
  border-color: var(--red);
  box-shadow: inset 0 0 0 1px var(--red);
  background-image: none;
  padding-right: 0.75rem;
}
.invalid-feedback { color: var(--red); font-size: 0.8125rem; font-weight: 600; }
.invalid-feedback::before { content: ""; display: inline-block; width: 8px; height: 8px; margin-right: 6px; background: var(--red); vertical-align: 1px; }
.form-check-input {
  --bs-form-check-bg: var(--label); /* Bootstrap falls back to --bs-body-bg, the concrete floor */
  width: 1.15em;
  height: 1.15em;
  border: 2px solid var(--carbon);
  border-radius: 0 !important;
}
.form-check-input:checked {
  background-color: var(--signal);
  border-color: var(--carbon);
  --bs-form-check-bg-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20'%3e%3cpath fill='none' stroke='%23191b1d' stroke-linecap='square' stroke-width='3' d='m5 10 3.5 3.5L15 6'/%3e%3c/svg%3e");
}
.form-check-input:focus { border-color: var(--carbon); box-shadow: none; outline: 3px solid var(--carbon); outline-offset: 2px; }
/* Bootstrap's focus glows (blue, or soft red) never show */
/* Invalid + focused: red border thickens from 2px to 3px, plus the same yellow/carbon ring */
.form-control.is-invalid:focus, .form-select.is-invalid:focus {
  border-color: var(--red);
  box-shadow: inset 0 0 0 2px var(--red), 0 0 0 5px var(--carbon);
  outline: 3px solid var(--signal);
  outline-offset: 0;
}
.btn-close { --bs-btn-close-focus-shadow: none; }
.btn-close:focus-visible { outline: 3px solid var(--carbon); outline-offset: 2px; }
.page-link:focus-visible { outline: 3px solid var(--carbon); outline-offset: 1px; z-index: 3; }
.pagination { --bs-pagination-focus-bg: var(--label-2); --bs-pagination-focus-color: var(--carbon); }

/* Inline error box (#qm-error is a bare .alert-danger filled by product.js) */
.alert { --bs-alert-border-radius: 0; }
.alert-danger:not(.auth-alert) {
  padding: 9px 12px;
  background: var(--label);
  color: var(--carbon);
  border: 2px solid var(--carbon);
  border-left: 10px solid var(--red);
  font-size: 0.875rem;
  font-weight: 600;
}
.input-group-text { background: var(--label-2); border: 1px solid var(--carbon); border-radius: 0; color: var(--carbon); font-family: var(--font-mono); }
#sku { text-transform: uppercase; font-family: var(--font-mono); }
.form-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }
.form-footer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 12px 18px;
  background: var(--label-2);
  border-top: 1px solid var(--carbon);
}

/* 11. Notices ---------------------------------------------------------------------- */

.notice {
  display: flex;
  align-items: stretch;
  border: 1px solid var(--carbon);
  background: var(--label);
  font-size: 0.875rem;
}
.notice > .bi { display: grid; place-items: center; width: 44px; flex-shrink: 0; font-size: 1.1rem; background: var(--carbon); color: var(--signal); }
.notice > div { padding: 11px 14px; }
.notice-info > .bi { background: var(--blue); color: #fff; }

/* 12. Low-stock alerts: hazard tape down the leading edge of every row ----------------- */

.alerts-table > tbody > tr > td:first-child {
  padding-left: 32px;
  background-image: var(--hazard);
  background-size: 12px 100%;
  background-repeat: no-repeat;
  box-shadow: inset 13px 0 0 -12px var(--carbon);
}
.alerts-table > tbody > tr:has(.status-out) > td:first-child { background-image: var(--keep-clear); }
.alerts-table > thead > tr > th:first-child { padding-left: 32px; }
/* Dense rows (≤64px): the product column takes about a third, the figure columns shrink to
   their content, headers may break onto two lines (like a printed pick sheet). */
.alerts-table > thead > tr > th { min-width: 5rem; white-space: normal; text-wrap: balance; vertical-align: bottom; line-height: 1.2; }
.alerts-table .cell-product { width: 38%; min-width: 17rem; }
.alerts-table .cell-product .cell-sub {
  contain: inline-size; /* never widens the column; the supplier ellipsizes instead */
  display: flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}
.alerts-table .cell-product .cell-sub > span:last-child { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.alerts-table .cell-meter { min-width: 0; width: 124px; }
.alerts-table .meter { width: 96px; }
.alerts-table > thead > tr > th, .alerts-table > tbody > tr > td { padding-left: 10px; padding-right: 10px; }
.alerts-table > thead > tr > th:last-child, .alerts-table > tbody > tr > td:last-child { padding-right: 18px; }
.alerts-table > tbody > tr > td { padding-top: 9px; padding-bottom: 9px; }
/* Tablets and small laptops (768-1279): seven columns don't fit, so two step out and Suggested
   order and Receive (the page's action) always stay in view. Their data stays: below 1280 the
   Level gauge moves under the on-hand figures (.fold-meter); below 1200 Sold, 30 days moves under
   the status tag (.fold-sold, d-xl-none in the template). See "Folded columns" in 8. Below 768
   the rows become pick tickets (end of file). */
@media (max-width: 1279.98px) {
  .alerts-table .cell-meter { display: none !important; }
  .alerts-table .cell-product { min-width: 12rem; }
}

/* 13. Product detail: the shelf tag ------------------------------------------------------ */

.shelf-tag { position: relative; padding-top: 10px; }
.shelf-tag::before { content: ""; position: absolute; left: 0; right: 0; top: 0; height: 10px; background: var(--carbon); }
.shelf-tag[data-status="low"]::before { background: var(--hazard); border-bottom: 2px solid var(--carbon); }
.shelf-tag[data-status="out"]::before { background: var(--keep-clear); border-bottom: 2px solid var(--carbon); }
.shelf-loc {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 18px 9px;
  background: var(--carbon);
  color: var(--signal);
  font-family: var(--font-mono);
  font-size: 1.625rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  line-height: 1.1;
}
.shelf-loc small { color: var(--steel-side); font-size: 0.6875rem; font-weight: 400; letter-spacing: 0.1em; text-transform: uppercase; }
/* No location recorded: the band stays, the location reads as an unpainted blank */
.shelf-loc.is-empty { color: var(--steel-side); font-size: 1rem; font-weight: 600; letter-spacing: 0.02em; }
.onhand { padding-bottom: 14px; margin-bottom: 14px; border-bottom: 1px solid var(--carbon); }
.onhand-label { font-stretch: 75%; font-size: 0.875rem; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; }
.onhand-value { font-family: var(--font-figure); font-weight: 800; font-size: 4.5rem; line-height: 0.95; }
.onhand-value small { font-family: var(--font-mono); font-size: 0.875rem; font-weight: 500; color: var(--steel); letter-spacing: 0.02em; }
.onhand-note { font-family: var(--font-mono); font-size: 0.75rem; color: var(--steel); }
.shelf-barcode { display: flex; flex-direction: column; align-items: flex-start; margin-top: 12px; }
.shelf-barcode .barcode { font-size: 3.25rem; height: 38px; }
.shelf-barcode-text { font-family: var(--font-mono); font-size: 0.75rem; letter-spacing: 0.22em; margin-top: 2px; }
.facts { display: grid; grid-template-columns: auto 1fr; gap: 7px 16px; margin: 0; font-size: 0.875rem; }
.facts dt { font-weight: 400; color: var(--steel); }
.facts dd { margin: 0; text-align: right; font-weight: 600; }
.facts dd.num { font-weight: 500; }
.facts-wide dd { text-align: left; }
.product-notes { margin: 14px 0 0; padding-top: 12px; border-top: 1px solid var(--carbon); font-size: 0.875rem; }
.readonly-qty {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 14px;
  border: 1px dashed var(--carbon);
  background: var(--label-2);
}
.readonly-qty .fw-semibold { font-family: var(--font-mono); font-weight: 700; }
.quick-product {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  overflow-wrap: anywhere;
  gap: 8px;
  padding: 10px 12px;
  margin-bottom: 16px;
  background: var(--label-2);
  border: 1px solid var(--carbon);
  font-size: 0.875rem;
}
.history-new > td { animation: flash-row 2.4s ease-out; }
@keyframes flash-row { from { background-color: var(--signal-wash); } to { background-color: transparent; } }
.when { font-family: var(--font-mono); font-size: 0.8125rem; white-space: nowrap; }

/* Movement form: four dock doors */
.kind-picker { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
.kind-option {
  display: grid;
  align-content: start;
  gap: 2px;
  padding: 12px 14px;
  border: 2px solid var(--carbon);
  background: var(--label);
  cursor: pointer;
}
.kind-option .bi { font-size: 1.25rem; margin-bottom: 4px; color: var(--carbon); }
.kind-option-title { font-stretch: 75%; font-size: 1.0625rem; font-weight: 800; }
.kind-option-text { font-size: 0.75rem; color: var(--steel); line-height: 1.35; }
.kind-option:hover { background: var(--label-2); }
.btn-check:checked + .kind-option { background: var(--signal); }
.btn-check:checked + .kind-option .kind-option-text { color: var(--carbon); }
.btn-check:focus-visible + .kind-option { position: relative; z-index: 1; outline: 3px solid var(--carbon); outline-offset: 2px; }
.product-peek { display: flex; flex-wrap: wrap; gap: 6px 18px; margin-top: 8px; font-size: 0.8125rem; color: var(--steel); }
.product-peek strong { color: var(--carbon); font-family: var(--font-mono); font-weight: 600; }
.product-peek.is-low #peek-qty { background: var(--signal); padding: 0 4px; outline: 1px solid var(--carbon); }
.help-card .card-body { padding: 0; }
.help-card .card-title { margin: 0 !important; padding: 10px 18px; background: var(--carbon); color: #fff; }
.help-list { padding: 16px 18px 0; margin: 0; }
.help-list dt { font-stretch: 87.5%; font-size: 0.875rem; font-weight: 800; }
.help-list dd { font-size: 0.8125rem; color: var(--steel); margin-bottom: 12px; }
.help-card .card-body > p { padding: 0 18px 16px; }

/* Users and audit */
.role-strip { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); border: 1px solid var(--carbon); background: var(--label); }
.role-card { padding: 14px 16px; border-right: 1px solid var(--carbon); }
.role-card:last-child { border-right: 0; }
.role-card p { margin: 8px 0 0; font-size: 0.8125rem; color: var(--steel); }
.user-cell { display: flex; align-items: center; gap: 12px; }
.you-tag { padding: 0 5px; background: var(--carbon); color: var(--signal); font-family: var(--font-mono); font-size: 0.625rem; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; vertical-align: 2px; }
.state-tag { display: inline-flex; align-items: center; gap: 6px; font-size: 0.8125rem; font-weight: 600; white-space: nowrap; }
.state-on { color: var(--green); }
.state-off { color: var(--carbon); padding: 0 6px 0 4px; border: 1.5px solid var(--steel); background: var(--label); }
.state-locked { color: var(--red); }
.state-pending { color: var(--carbon); }
.state-pending .bi { background: var(--signal); outline: 1px solid var(--carbon); padding: 0 3px; }
.event-tag { display: inline-block; padding: 0 6px; border: 1px solid var(--carbon); font-family: var(--font-mono); font-size: 0.75rem; white-space: nowrap; }
.event-bad { background: var(--red); border-color: var(--carbon); color: #fff; }
.event-auth { background: var(--label); color: var(--carbon); }
.event-change { background: var(--label); border-color: var(--blue); color: var(--blue); }
.change-list { list-style: none; margin: 0; padding: 0; font-size: 0.8125rem; }
.change-list li { white-space: nowrap; }
.change-key { color: var(--steel); margin-right: 6px; }
.change-old { color: var(--steel); text-decoration: line-through; font-family: var(--font-mono); font-size: 0.75rem; }
.change-new { color: var(--carbon); font-weight: 600; font-family: var(--font-mono); font-size: 0.75rem; }
.change-list .bi { font-size: 0.7rem; color: var(--steel); margin: 0 3px; }

/* Reports: one ruled summary strip, like the header boxes of a printed stock sheet */
.summary-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 0; border: 2px solid var(--carbon); background: var(--label); }
.summary-card { padding: 14px 18px 16px; border-right: 1px solid var(--carbon); }
.summary-card:last-child { border-right: 0; }
.summary-label { font-stretch: 75%; font-size: 0.875rem; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; }
.summary-value { font-family: var(--font-mono); font-size: 1.5rem; font-weight: 600; letter-spacing: -0.01em; margin: 8px 0 4px; white-space: nowrap; }
.summary-note { font-size: 0.75rem; color: var(--steel); }
.health-row { display: flex; flex-wrap: wrap; gap: 4px 14px; margin: 10px 0 8px; font-size: 0.875rem; font-weight: 600; }
.health-row > span { display: inline-flex; align-items: center; }
.share { display: flex; align-items: center; gap: 10px; }
.share .meter { width: 120px; }
.share-label { font-family: var(--font-mono); font-size: 0.75rem; min-width: 44px; }
.report-table tfoot th { background: var(--label-2); border-top: 3px solid var(--carbon); border-bottom: 0; padding: 11px 14px; font-weight: 800; }
.report-table tfoot th.num { font-weight: 700; }
.print-only { display: none; }

/* 14. Staff entry (login) ---------------------------------------------------------- */

/* The painted lettering gets its own band below the bay (the bottom padding), so it is never cut
   by the viewport or hidden behind the sign. Its size: the phrase is 6.7em wide, so 13.4vw keeps
   the whole of it on a 360px floor; it also shrinks with the viewport height so that, with the
   ~752px sign, the bay and the whole phrase fit one screen (108px at 900 tall); 11rem caps it.
   When the sign is taller than the screen (flashes, short laptops) the floor grows and the
   lettering stays whole at the bottom of the page. */
.auth-floor {
  --paint: clamp(2.75rem, min(13.4vw, (100vh - 800px) * 1.08), 11rem);
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 32px 16px calc(var(--paint) * 0.92 + 16px);
  position: relative;
  overflow: hidden;
}
.auth-floor::after {
  /* painted floor lettering, worn into the concrete */
  content: "STAFF ENTRANCE";
  position: absolute;
  left: 50%;
  bottom: 0.12em;
  transform: translateX(-50%);
  font-family: var(--font-stencil);
  font-weight: 900;
  font-size: var(--paint);
  line-height: 0.8; /* the line box is the cap height (0.81em), so the caps sit 0.12em off the edge */
  letter-spacing: 0.04em;
  white-space: nowrap;
  color: var(--floor-deep);
  pointer-events: none;
}
.entry-zone { --len: 40px; --w: 8px; position: relative; z-index: 1; width: 100%; max-width: 468px; padding: 22px; }
.entry-sign { background: var(--label); border: 2px solid var(--carbon); text-align: left; }
.entry-head {
  display: flex;
  flex-wrap: wrap; /* on the narrowest phones the store line drops under STOCKROOM, whole */
  align-items: flex-end;
  justify-content: space-between;
  gap: 4px 12px;
  padding: 12px 20px 10px;
  background: var(--signal);
  border-bottom: 4px solid var(--carbon);
}
.entry-head .brand-name { font-size: 2.5rem; }
.entry-head .entry-store { font-family: var(--font-mono); font-size: 0.6875rem; letter-spacing: 0.08em; text-transform: uppercase; text-align: right; line-height: 1.35; white-space: nowrap; }
.entry-body { padding: 22px 24px 20px; }
.entry-body h1 { font-stretch: 75%; font-weight: 800; font-size: 1.875rem; line-height: 1.05; margin: 0 0 4px; }
.auth-sub { color: var(--steel); margin-bottom: 20px; font-size: 0.9375rem; }
.auth-alert {
  display: flex;
  align-items: stretch;
  gap: 0;
  padding: 0;
  border: 2px solid var(--carbon);
  border-radius: 0;
  background: var(--label);
  color: var(--carbon);
  font-size: 0.875rem;
}
.auth-alert > .bi { display: grid; place-items: center; width: 40px; flex-shrink: 0; color: #fff; background: var(--blue); }
.auth-alert > span { padding: 9px 12px; }
.auth-alert.alert-danger > .bi { background: var(--red); }
.auth-alert.alert-success > .bi { background: var(--green); }
.auth-alert.alert-warning > .bi { background: var(--signal); color: var(--carbon); }
.auth-help { margin: 18px 0 0; font-size: 0.8125rem; color: var(--steel); }
.password-group .btn { border: 1px solid var(--carbon); border-left: 0; background: var(--label); color: var(--carbon); }
.password-group .btn:hover { background: var(--signal); }
.entry-rules { border-top: 2px solid var(--carbon); padding: 14px 24px 16px; background: var(--label-2); }
.entry-rules h2 { font-stretch: 75%; font-weight: 800; font-size: 0.875rem; letter-spacing: 0.08em; text-transform: uppercase; margin: 0 0 8px; }
.entry-rules ol { list-style: none; counter-reset: rule; margin: 0 0 10px; padding: 0; display: grid; gap: 5px; }
.entry-rules li { counter-increment: rule; display: grid; grid-template-columns: 22px 1fr; gap: 8px; font-size: 0.8125rem; line-height: 1.4; }
.entry-rules li::before {
  content: counter(rule);
  display: grid;
  place-items: center;
  width: 20px;
  height: 20px;
  background: var(--carbon);
  color: var(--signal);
  font-family: var(--font-mono);
  font-size: 0.6875rem;
  font-weight: 700;
}
.auth-foot { font-family: var(--font-mono); font-size: 0.6875rem; letter-spacing: 0.02em; color: var(--steel); margin: 0; }

/* 15. Errors, toasts, modals -------------------------------------------------------- */

/* Bottom-end, so toasts never cover the page actions (Stock in / Stock out / more), the title
   or the breadcrumb while staff record the next movement. New toasts stack at the bottom. */
#toast-stack { top: auto; bottom: 0; z-index: 1090; }
@media (max-width: 575.98px) {
  #toast-stack { left: 0; padding: 8px !important; }
  #toast-stack .app-toast { width: 100%; }
}
.app-toast { --bs-toast-max-width: 380px; border: 2px solid var(--carbon); border-radius: 0; background: var(--label); box-shadow: none; }
.app-toast .toast-body { display: flex; align-items: stretch; gap: 0; padding: 0; font-size: 0.875rem; }
.app-toast .toast-body > .bi { display: grid; place-items: center; width: 42px; flex-shrink: 0; font-size: 1.05rem; background: var(--blue); color: #fff; }
.app-toast .toast-body > span { flex: 1; padding: 11px 12px; }
.app-toast .btn-close { margin: 12px 12px 0 0; }
.toast-success .toast-body > .bi { background: var(--green); }
.toast-danger .toast-body > .bi { background: var(--red); }
.toast-warning .toast-body > .bi { background: var(--signal); color: var(--carbon); }

/* White body (Bootstrap's --bs-modal-bg falls back to --bs-body-bg, the concrete floor), so the
   label-2 footer and .quick-product strip read as the darker band under it */
.modal { --bs-modal-bg: var(--label); --bs-modal-border-radius: 0; --bs-modal-inner-border-radius: 0; --bs-modal-border-width: 2px; --bs-modal-border-color: var(--carbon); --bs-modal-box-shadow: none; }
.modal-backdrop { --bs-backdrop-bg: #191b1d; --bs-backdrop-opacity: 0.6; }
.offcanvas-backdrop { background-color: var(--carbon); }
.offcanvas-backdrop.show { opacity: 0.6; }
.modal-header { background: var(--carbon); color: #fff; border-bottom: 4px solid var(--signal); padding: 12px 18px; }
.modal-title { font-stretch: 75%; font-weight: 800; font-size: 1.375rem; }
.modal-header .btn-close { filter: invert(1) grayscale(100%) brightness(200%); }
.modal-footer { border-top: 1px solid var(--carbon); background: var(--label-2); }
.confirm-icon {
  width: 46px;
  height: 40px;
  margin-bottom: 12px;
  background: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 46 40'%3e%3cpath d='M23 2 44 38H2Z' fill='%23ffc800' stroke='%23191b1d' stroke-width='3.5' stroke-linejoin='miter'/%3e%3cpath d='M23 14v12' stroke='%23191b1d' stroke-width='4.5'/%3e%3crect x='20.75' y='29' width='4.5' height='4.5' fill='%23191b1d'/%3e%3c/svg%3e") center / contain no-repeat;
}
.confirm-icon .bi { display: none; }

.error-page { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.error-card { max-width: 520px; margin: 56px auto; padding: 40px 32px 36px; text-align: center; }
.error-code {
  font-family: var(--font-figure);
  font-weight: 900;
  font-size: 9rem;
  line-height: 0.85;
  letter-spacing: 0.02em;
  color: var(--carbon);
  margin-bottom: 14px;
}
.error-card h1 { font-stretch: 75%; font-weight: 800; font-size: 1.875rem; }
.error-card p { color: var(--steel); margin-bottom: 22px; }

/* 16. Motion --------------------------------------------------------------------------- */

@media (prefers-reduced-motion: reduce) {
  .live-dot { animation: none; }
  .kpi-value, .meter span { transition: none; }
  .btn:active { transform: none; }
  .btn, .page-link, .form-control, .form-select { transition: none; }
  .history-new > td { animation: none; background: var(--signal-wash); }
}

/* 17. Responsive ------------------------------------------------------------------------- */

@media (max-width: 1279.98px) {
  /* Below 1280 five bins are too narrow for "MOVEMENTS TODAY" and the link labels.
     Two rows, still in DOM order: value + SKUs, then low + out + movements. */
  .kpi-grid { grid-template-columns: repeat(6, minmax(0, 1fr)); }
  .kpi-card { grid-column: span 2; }
  .kpi-card:nth-child(1), .kpi-card:nth-child(2) { grid-column: span 3; }
}

@media (max-width: 991.98px) {
  .content { padding: 20px 16px 40px; }
  .topbar { padding: 0 12px; height: 60px; }
  .topbar-search { flex: 1 1 auto; }
  .sidebar-brand { padding: 12px 18px; }
}

@media (max-width: 767.98px) {
  .page-header { flex-direction: column; align-items: stretch; }
  .page-header > div:first-child { flex: 0 0 auto; } /* the 26rem basis is for rows, not this column */
  .page-actions { justify-content: flex-start; }
  .page-title { font-size: 1.875rem; }
  /* value bin full width first, then SKUs | Low, Out | Movements: visual order = DOM order */
  .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .kpi-card, .kpi-card:nth-child(1), .kpi-card:nth-child(2) { grid-column: span 1; }
  .kpi-card.kpi-wide { grid-column: span 2; }
  .kpi-value { font-size: 2.75rem; padding: 8px 12px 2px; }
  .kpi-code { padding: 0 12px 6px; }
  .kpi-code .barcode { font-size: 1.75rem; height: 20px; }
  .kpi-link, .kpi-note { padding: 6px 12px; font-size: 0.75rem; }
  .data-table > :not(caption) > * > :first-child { padding-left: 14px; }
  .data-table > :not(caption) > * > :last-child { padding-right: 14px; }
  .chart-box-lg { height: 240px; }
  .entry-zone { padding: 14px; --len: 28px; --w: 6px; }
  .entry-head .brand-name { font-size: 2rem; }
  .entry-body { padding: 18px 18px 16px; }
  .entry-rules { padding: 12px 18px 14px; }
}

@media (max-width: 380px) {
  .topbar-search input { font-size: 0.8125rem; }
}
/* Login plank on a small phone: the store line keeps its two whole lines beside STOCKROOM (as in
   the mock) by closing up the plank's side padding and the mono tracking. Below 360 there isn't
   room, so it drops under STOCKROOM (flex-wrap) and reads from the left. */
@media (max-width: 399.98px) {
  .entry-head { padding-left: 14px; padding-right: 14px; column-gap: 10px; }
  .entry-head .entry-store { letter-spacing: 0.04em; }
}
@media (max-width: 359.98px) {
  .entry-head .entry-store { text-align: left; }
}

/* Short laptop screens (a 1366x768 browser leaves about 650px): the aisle signs and plates tighten
   so the admin nav fits at 768 and scrolls less below that. Desktop only, so phone touch targets
   keep their 36px. */
@media (min-width: 992px) and (max-height: 820px) {
  .nav-section { margin: 10px 18px 4px; }
  .nav-item { min-height: 32px; padding-top: 5px; padding-bottom: 5px; }
  .sidebar-footer { padding: 10px 18px; }
}

/* The strip is four cells only where a 13-character figure (₹10,40,210.00 at 1.5rem mono, ~190px)
   fits each cell: with the sidebar that is from 1280. Below that, two by two (print keeps four). */
@media screen and (max-width: 1279.98px) {
  .summary-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .summary-card:nth-child(2) { border-right: 0; }
  .summary-card:nth-child(-n + 2) { border-bottom: 1px solid var(--carbon); }
}
@media (max-width: 767.98px) {
  .role-strip { grid-template-columns: 1fr; }
  .role-card { border-right: 0; border-bottom: 1px solid var(--carbon); }
  .role-card:last-child { border-bottom: 0; }
  .kind-picker { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  /* Filter band stacks in DOM order: search full width, two selects side by side, button.
     In filter-field bands, From/To dates pair up and every select gets a full row. */
  .filter-bar { padding: 12px 14px; }
  .filter-search { max-width: none; flex: 1 1 100%; }
  .filter-bar > .form-select { max-width: none; flex: 1 1 calc(50% - 5px); min-width: 0; }
  .filter-field, .filter-field-wide { flex: 1 1 100%; max-width: none; min-width: 0; }
  .filter-field:has(input[type="date"]) { flex-basis: calc(50% - 5px); }
  .filter-buttons { flex: 1 1 100%; }
  .cell-product { min-width: 160px; }
  .alerts-table > tbody > tr > td:first-child, .alerts-table > thead > tr > th:first-child { padding-left: 26px; }
  .onhand-value { font-size: 3.75rem; }
}
@media (max-width: 575.98px) {
  /* Form footers: buttons stretch to a full-width thumb target */
  .form-footer > .btn, .form-actions > .btn { flex: 1 1 auto; }
  .form-actions { flex-wrap: wrap; }
  /* Status switch on a phone: a ruled 3-up grid (1px carbon gaps are the dividers).
     Staff see 4 positions (last one full width); managers see 5 (last two halves). */
  .segmented { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 1px; background: var(--carbon); }
  .segmented-item { grid-column: span 2; justify-content: center; border-right: 0; background: var(--label); padding: 8px 6px; }
  .segmented-item.active { background: var(--signal); }
  .segmented-item:nth-child(4):last-child { grid-column: span 6; }
  .segmented-item:nth-child(4):nth-last-child(2), .segmented-item:nth-child(5):last-child { grid-column: span 3; }
  .summary-grid { grid-template-columns: 1fr; }
  .summary-card { border-right: 0; border-bottom: 1px solid var(--carbon); }
  .summary-card:last-child { border-bottom: 0; }
}

/* 18. Print: the valuation report becomes a stock sheet ------------------------------ */

@media print {
  .sidebar, .topbar, .no-print, .toast-container, .page-actions, .modal { display: none !important; }
  body { background: #fff; font-size: 10pt; color: #000; }
  .content { padding: 0; max-width: none; }
  .print-only { display: block; }
  .print-header {
    display: flex;
    align-items: baseline;
    gap: 6pt;
    border-bottom: 3pt solid #000;
    padding-bottom: 4pt;
    margin-bottom: 12pt;
    font-family: var(--font-mono);
    font-size: 8.5pt;
  }
  .print-header strong { font-family: var(--font-stencil); font-weight: 800; font-size: 20pt; letter-spacing: 0.04em; text-transform: uppercase; }
  .page-title { font-size: 18pt; }
  .page-header { margin-bottom: 10pt; }
  .card, .summary-grid, .kpi-card { break-inside: avoid; border-color: #000; }
  .summary-grid { border-width: 2pt; }
  .card-header { border-bottom-width: 2pt; border-color: #000; }
  .summary-grid { grid-template-columns: repeat(4, 1fr); }
  .data-table > thead > tr > th { border-bottom: 2pt solid #000; }
  .data-table > tbody > tr > td { border-color: #999; }
  .report-table tfoot th { border-top: 3pt solid #000; }
  .data-table > thead > tr > th, .report-table tfoot th, .meter, .meter span, .status-pill, .status-dot, .kpi-card::before, .alerts-table td:first-child {
    print-color-adjust: exact;
    -webkit-print-color-adjust: exact;
  }
  a { color: inherit; text-decoration: none; }
}

/* Low-stock alerts on a phone or a portrait tablet (below 768): each row restacks into a pick
   ticket so On hand, Suggested order and Receive stay on screen (the page a floor worker uses
   while receiving goods). */
@media screen and (max-width: 767.98px) {
  .alerts-table > thead {
    /* hidden visually, still there for screen readers (with explicit ARIA table roles in the template) */
    position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap;
  }
  .alerts-table, .alerts-table > tbody { display: block; }
  .alerts-table > tbody > tr {
    display: grid;
    /* the action track never shrinks below the Receive button (min-content of a nowrap button is
       its full width), so the button can't slide over the Suggested caption on a 360px phone; the
       figure columns give way instead. (Not max-content: that track would also soak up the
       one-line width of the product cell spanning all three, and push the ticket off screen.) */
    grid-template-columns: auto auto minmax(min-content, 1fr);
    align-items: end;
    gap: 8px 12px;
    padding: 12px 14px 13px 28px;
    border-bottom: 1px solid var(--rule);
    background: var(--hazard) left top / 12px 100% no-repeat;
  }
  .alerts-table > tbody > tr:has(.status-out) { background-image: var(--keep-clear); }
  .alerts-table > tbody > tr > td,
  .alerts-table > tbody > tr > td:first-child,
  .alerts-table > tbody > tr > td:last-child { /* the 18px end inset on Receive comes back from 380 (below) */
    display: block;
    padding: 0;
    border: 0;
    background: none;
    box-shadow: none;
    text-align: left !important;
  }
  .alerts-table > tbody > tr:has(.status-out) > td:first-child { background-image: none; }
  .alerts-table > tbody > tr > td:nth-child(1) { grid-column: 1 / -1; width: auto; min-width: 0; }
  .alerts-table > tbody > tr > td:nth-child(2) { grid-column: 1 / -1; }
  .alerts-table > tbody > tr > td:last-child { grid-column: 3; grid-row: 3; justify-self: safe end; }
  .alerts-table td[data-label]::before {
    content: attr(data-label);
    display: block;
    white-space: normal;
    margin-bottom: 2px;
    font-family: var(--font-ui);
    font-stretch: 75%;
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--steel);
  }
}

/* Receive keeps the table's 18px end inset on the ticket from 380px (as in the mock); narrower
   phones need that room for the figures, so there the button sits on the ticket's own padding. */
@media screen and (min-width: 380px) and (max-width: 767.98px) {
  .alerts-table > tbody > tr > td:last-child { padding-right: 18px; }
}
/* Below 360 (a 320px phone) the ticket's figure columns close up a little so "12 / 25 pcs",
   Suggested and Receive still share one line without the row overflowing. */
@media screen and (max-width: 359.98px) {
  .alerts-table > tbody > tr { column-gap: 8px; padding-left: 26px; }
}

/* Transaction log on a phone: each movement becomes one ledger line.
   Row 1: date + time (mono) and the kind code; row 2: product and SKU, with the signed change
   on the right. The hidden columns (before/after, by, details) are already d-none below md. */
@media (max-width: 575.98px) {
  .movements-table > thead {
    position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap;
  }
  .movements-table, .movements-table > tbody { display: block; }
  .movements-table > tbody > tr {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: 5px 12px;
    padding: 10px 14px 11px;
    border-bottom: 1px solid var(--rule);
  }
  .movements-table > tbody > tr:last-child { border-bottom: 0; }
  .movements-table > tbody > tr > td,
  .movements-table > :not(caption) > * > :first-child,
  .movements-table > :not(caption) > * > :last-child { display: block; padding: 0; border: 0; }
  .movements-table > tbody > tr > td:nth-child(1) { grid-area: 1 / 1; font-family: var(--font-mono); font-size: 0.75rem; color: var(--steel); }
  .movements-table > tbody > tr > td:nth-child(1) > div { display: inline; margin: 0 6px 0 0; font-size: inherit; }
  .movements-table > tbody > tr > td:nth-child(2) { grid-area: 2 / 1; min-width: 0; }
  .movements-table > tbody > tr > td:nth-child(3) { grid-area: 1 / 2; justify-self: end; }
  .movements-table > tbody > tr > td:nth-child(4) { grid-area: 2 / 2; justify-self: end; }
  .movements-table .qty-change { font-size: 1rem; }
}

/* Products list on a phone: each product is one ledger line. The product (name, SKU label,
   supplier) on the left; on hand over the status tag on the right. The header stays visible
   as a compact sort bar (Product, On hand), so sorting still works on a phone. */
@media (max-width: 575.98px) {
  .products-table, .products-table > thead, .products-table > tbody { display: block; }
  .products-table > thead > tr { display: flex; align-items: center; gap: 14px; padding: 8px 14px 7px; border-bottom: 2px solid var(--carbon); }
  .products-table > thead > tr > th { display: block; padding: 0; border: 0; }
  .products-table > thead > tr > th:nth-child(2) { flex: 1; }
  .products-table > tbody > tr {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 4px 14px;
    padding: 10px 14px 11px;
    border-bottom: 1px solid var(--rule);
  }
  .products-table > tbody > tr:last-child { border-bottom: 0; }
  .products-table > tbody > tr:hover { background: var(--label-2); }
  .products-table > tbody > tr > td { display: block; padding: 0; border: 0; min-width: 0; }
  .products-table > tbody > tr > td:nth-child(2) { grid-area: 1 / 1 / span 2 / 2; }
  .products-table > tbody > tr > td:nth-child(4) { grid-area: 1 / 2; justify-self: end; }
  .products-table > tbody > tr > td:nth-child(5) { grid-area: 2 / 2; justify-self: end; align-self: start; }
}

/* Audit log on a phone: line 1 is the time and the event tag, line 2 the user and the target.
   Details and IP stay desktop-only (already d-none below lg / md). */
@media (max-width: 575.98px) {
  .audit-table > thead {
    position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap;
  }
  .audit-table, .audit-table > tbody { display: block; }
  .audit-table > tbody > tr {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: 5px 12px;
    padding: 10px 14px 11px;
    border-bottom: 1px solid var(--rule);
  }
  .audit-table > tbody > tr:last-child { border-bottom: 0; }
  .audit-table > tbody > tr > td,
  .audit-table > :not(caption) > * > :first-child,
  .audit-table > :not(caption) > * > :last-child { display: block; padding: 0; border: 0; }
  .audit-table > tbody > tr > td:nth-child(1) { grid-area: 1 / 1; font-family: var(--font-mono); font-size: 0.75rem; color: var(--steel); }
  .audit-table > tbody > tr > td:nth-child(1) > div { display: inline; margin: 0 6px 0 0; font-size: inherit; }
  .audit-table > tbody > tr > td:nth-child(2) { grid-area: 1 / 2; justify-self: end; }
  .audit-table > tbody > tr > td:nth-child(3) { grid-area: 2 / 1; font-weight: 600; }
  .audit-table > tbody > tr > td:nth-child(4) { grid-area: 2 / 2; justify-self: end; }
}

/* Product movement history on a phone: one ledger line per movement, like the transaction log.
   Line 1: the time (mono) and the kind code; line 2: who, then before -> after and the signed change.
   Details stay desktop-only (already d-none below md). New rows from product.js carry the same
   roles and land in the same grid, and the signal-wash flash moves from the cells to the line. */
@media (max-width: 575.98px) {
  .history-table > thead {
    position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap;
  }
  .history-table, .history-table > tbody { display: block; }
  .history-table > tbody > tr {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto auto;
    align-items: center;
    gap: 5px 12px;
    padding: 10px 14px 11px;
    border-bottom: 1px solid var(--rule);
  }
  .history-table > tbody > tr:last-child { border-bottom: 0; }
  .history-table > tbody > tr > td,
  .history-table > :not(caption) > * > :first-child,
  .history-table > :not(caption) > * > :last-child { display: block; padding: 0; border: 0; }
  .history-table > tbody > tr:hover > td { background-color: transparent; }
  .history-table > tbody > tr > td:nth-child(1) { grid-area: 1 / 1; font-size: 0.75rem; color: var(--steel); }
  .history-table > tbody > tr > td:nth-child(2) { grid-area: 1 / 2 / 2 / 4; justify-self: end; }
  .history-table > tbody > tr > td:nth-child(5) { grid-area: 2 / 1; min-width: 0; font-size: 0.8125rem; font-weight: 600; }
  .history-table > tbody > tr > td:nth-child(4) { grid-area: 2 / 2; font-size: 0.75rem; }
  .history-table > tbody > tr > td:nth-child(3) { grid-area: 2 / 3; justify-self: end; }
  .history-table .qty-change { font-size: 1rem; }
  .history-table > tbody > tr.history-new { animation: flash-row 2.4s ease-out; }
  .history-table > tbody > tr.history-new > td { animation: none; background: transparent; }
}
@media (max-width: 575.98px) and (prefers-reduced-motion: reduce) {
  .history-table > tbody > tr.history-new { animation: none; background: var(--signal-wash); }
}
/* 576-767 it is still a table: "Before -> after" may break over two lines so it fits the panel */
@media (max-width: 767.98px) {
  .history-table > thead > tr > th { white-space: normal; vertical-align: bottom; line-height: 1.2; }
}

/* Valuation report on a phone or portrait tablet (screens below 768; print keeps the stock sheet):
   one block per category (and one for the total): the name, then the figures, each captioned
   through data-label, two to a row on a phone and four on a small tablet. No share meter here. */
@media screen and (max-width: 767.98px) {
  .report-table > thead {
    position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap;
  }
  .report-table, .report-table > tbody, .report-table > tfoot { display: block; }
  .report-table > tbody > tr, .report-table > tfoot > tr {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(9rem, 1fr));
    gap: 8px 14px;
    padding: 11px 14px 12px;
    border-bottom: 1px solid var(--rule);
  }
  .report-table > tbody > tr:last-child { border-bottom: 0; }
  .report-table > tbody > tr > td,
  .report-table > tfoot > tr > th,
  .report-table > :not(caption) > * > :first-child,
  .report-table > :not(caption) > * > :last-child {
    display: block; min-width: 0; padding: 0; border: 0; background: none; text-align: left !important;
  }
  .report-table > tbody > tr:hover > td { background-color: transparent; }
  .report-table > * > tr > :first-child { grid-column: 1 / -1; font-size: 0.9375rem; }
  .report-table > tfoot > tr { background: var(--label-2); border-top: 3px solid var(--carbon); border-bottom: 0; }
  .report-table > tfoot > tr > :first-child { font-stretch: 75%; font-weight: 800; letter-spacing: 0.06em; text-transform: uppercase; }
  .report-table [data-label]::before {
    content: attr(data-label);
    display: block;
    margin-bottom: 1px;
    font-family: var(--font-ui);
    font-stretch: 75%;
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--steel);
  }
}
/* As a table (768 up, and in print) the category column keeps each name on one line ("Monitors &
   Webcams"); the figure headers may break onto two balanced lines instead (like a printed stock
   sheet), so the columns size to their figures. With the sidebar the panel is narrower than the
   sheet: below 1280 the share column steps out (its figure moves under Value at cost) and below
   1100 Potential margin does (it moves under Value at selling price), so no column scrolls and
   no figure is lost. */
.report-table .share .meter { width: 96px; }
@media print, (min-width: 768px) {
  .report-table > tbody > tr > td:first-child { white-space: nowrap; }
  .report-table > thead > tr > th { white-space: normal; text-wrap: balance; vertical-align: bottom; line-height: 1.2; }
}
@media screen and (min-width: 768px) and (max-width: 1365.98px) {
  /* inner cells 11px a side (the 18px panel edges stay), so "Margin %" never breaks off its % */
  .report-table > thead > tr > th, .report-table > tbody > tr > td, .report-table > tfoot > tr > th { padding-left: 11px; padding-right: 11px; }
}
@media screen and (min-width: 768px) and (max-width: 1279.98px) { .report-table .col-share { display: none !important; } }
@media screen and (min-width: 768px) and (max-width: 1099.98px) { .report-table .col-margin { display: none !important; } }

/* .stack-table (categories, suppliers, users) on a phone: the first cell (name / user) leads,
   the other visible cells stack under it (numbers captioned through data-label), and the last
   cell, the 32px icon actions, stays pinned top-right. */
@media (max-width: 575.98px) {
  .stack-table > thead {
    position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap;
  }
  .stack-table, .stack-table > tbody { display: block; }
  .stack-table > tbody > tr {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 3px 12px;
    padding: 11px 14px 12px;
    border-bottom: 1px solid var(--rule);
  }
  .stack-table > tbody > tr:last-child { border-bottom: 0; }
  .stack-table > tbody > tr > td,
  .stack-table > :not(caption) > * > :first-child,
  .stack-table > :not(caption) > * > :last-child { display: block; padding: 0; border: 0; text-align: left !important; }
  .stack-table > tbody > tr > td:first-child { grid-column: 1; }
  .stack-table > tbody > tr > td:last-child { grid-column: 2; grid-row: 1 / span 3; align-self: start; }
  .stack-table .user-cell { align-items: flex-start; }
  .stack-table > tbody > tr.row-muted { background: var(--label-2); }
  .stack-table > tbody > tr.row-muted > td { background: transparent; }
  .stack-table .role-pill, .stack-table .state-tag { margin-top: 3px; }
  .stack-table td[data-label]::before {
    content: attr(data-label);
    margin-right: 6px;
    font-family: var(--font-ui);
    font-stretch: 75%;
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--steel);
  }
}
