/* ═══════════════════════════════════════════════════
   JOB CARD PORTAL — Production CSS
   Alpha Style | v2.0
═══════════════════════════════════════════════════ */

/* ── Design Tokens ───────────────────────────────── */
:root {
  --bg:            #edf3fb;
  --panel:         #ffffff;
  --panel-soft:    #f5f8fd;
  --ink:           #0d1f35;
  --ink-2:         #1e3a5f;
  --muted:         #5a7190;
  --muted-2:       #8aa3be;
  --line:          #dce8f5;
  --line-strong:   #c4d8ee;
  --pdf-divider:   #4a5d78;
  --brand:         #0f2742;
  --brand-2:       #1557a0;
  --brand-3:       #1e72d1;
  --brand-soft:    #e6f0fb;
  --accent:        #e8a100;
  --accent-soft:   #fff7e0;
  --danger:        #c94040;
  --danger-soft:   #fdeaea;
  --success:       #1f8a55;
  --success-soft:  #e6f7ef;
  --warning:       #c57a00;
  --warning-soft:  #fff3d6;

  --radius-xs:  8px;
  --radius-sm:  12px;
  --radius-md:  18px;
  --radius-lg:  24px;
  --radius-xl:  32px;

  --shadow-sm:  0 2px 8px rgba(15, 39, 66, 0.06);
  --shadow-md:  0 8px 28px rgba(15, 39, 66, 0.10);
  --shadow-lg:  0 20px 60px rgba(15, 39, 66, 0.12);
  --shadow-top: 0 -4px 20px rgba(15, 39, 66, 0.06);

  --sidebar-w:  280px;
  --topbar-h:   84px;

  --font: "Manrope", "Segoe UI", system-ui, sans-serif;
}

/* ── Reset & Base ────────────────────────────────── */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  scroll-behavior: smooth;
}

body {
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.6;
  color: var(--ink);
  background:
    radial-gradient(ellipse 80% 50% at 110% -10%, rgba(21, 87, 160, 0.13) 0%, transparent 60%),
    radial-gradient(ellipse 60% 40% at -10% 120%, rgba(21, 87, 160, 0.07) 0%, transparent 60%),
    linear-gradient(170deg, #eaf3fc 0%, #f4f9ff 55%, #eef5fb 100%);
  min-height: 100vh;
  min-height: 100dvh; /* dvh overrides vh above on browsers that support it — accounts for mobile browser chrome (address bar) that 100vh doesn't */
}

/* Set/removed by setupDialogScrollLock in app.js whenever any <dialog> is
   open/closed — see the comment there for why this is needed at all
   (native <dialog>.showModal() doesn't stop the page behind it from
   being touch-scrolled on mobile). Each dialog's own content still
   scrolls normally (.dialog-card keeps its own overflow-y:auto) — only
   the page underneath is frozen. */
html.dialog-open,
body.dialog-open {
  overflow: hidden;
  height: 100vh;
  height: 100dvh;
}

button, input, select, textarea {
  font: inherit;
  color: inherit;
}

/* Some browsers render the native <option> popup list with the OS default
   font rather than the author font-family inherited by <select> — set it
   explicitly so dropdown lists match the rest of the UI's typography. */
select, option {
  font-family: var(--font);
}

button {
  cursor: pointer;
}

/* ── Utility ─────────────────────────────────────── */
.hidden { display: none !important; }

.eyebrow {
  display: block;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--brand-3);
  margin-bottom: 6px;
}

.muted {
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.65;
}

/* ════════════════════════════════════════════════════
   AUTH / LOGIN
════════════════════════════════════════════════════ */
.auth-shell {
  min-height: 100vh;
  min-height: 100dvh; /* dvh overrides vh above on browsers that support it — accounts for mobile browser chrome (address bar) that 100vh doesn't */
  display: grid;
  place-items: center;
  padding: 24px;
  position: relative;
}

.auth-shell::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse 55% 45% at 15% 85%, rgba(21, 87, 160, 0.09) 0%, transparent 60%),
    radial-gradient(ellipse 40% 55% at 90% 10%, rgba(14, 38, 68, 0.08) 0%, transparent 60%);
  pointer-events: none;
}

.auth-card {
  position: relative;
  z-index: 1;
  width: min(480px, 100%);
  padding: 40px 36px 36px;
  border-radius: var(--radius-xl);
  background: rgba(255, 255, 255, 0.95);
  border: 1px solid rgba(220, 232, 245, 0.9);
  box-shadow: var(--shadow-lg), 0 1px 0 rgba(255,255,255,0.9) inset;
  backdrop-filter: blur(20px);
}

.auth-logo {
  display: flex;
  justify-content: center;
  margin-bottom: 18px;
}

.auth-logo-img {
  display: block;
  height: 90px;
  width: auto;
  max-width: 100%;
  object-fit: contain;
}

.auth-form {
  display: grid;
  gap: 16px;
}

.auth-hint {
  margin: 0;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  background: var(--brand-soft);
  font-size: 12.5px;
  font-weight: 600;
  color: var(--brand-2);
  border: 1px solid #c4d8f5;
}

.auth-error {
  display: none;
  align-items: center;
  gap: 10px;
  padding: 11px 14px;
  border-radius: var(--radius-sm);
  background: #fef2f2;
  border: 1.5px solid rgba(201, 64, 64, 0.35);
  color: #7f1d1d;
  font-size: 13px;
  font-weight: 600;
  line-height: 1.45;
}

.auth-error:not(:empty) {
  display: flex;
}

.auth-error::before {
  content: "⚠";
  flex-shrink: 0;
  font-size: 14px;
  color: var(--danger);
}

.auth-submit {
  margin-top: 4px;
  width: 100%;
  padding: 14px 20px;
  font-size: 0.95rem;
}

.auth-footer-credit {
  margin: 10px 0 0;
  text-align: center;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.01em;
  color: var(--brand-2);
}

/* ════════════════════════════════════════════════════
   PORTAL TOPBAR
════════════════════════════════════════════════════ */
.portal-shell { min-height: 100vh; min-height: 100dvh; }

/* No overflow:hidden here (there used to be one) — .user-chip-menu is a
   position:absolute dropdown that opens BELOW this bar's own height
   (top: calc(100% + 8px) in its own rule), so clipping this container to
   its own box height cut the entire dropdown off except a sliver of its
   top edge peeking out — reported live: "click the user icon, dropdown
   opens but isn't visible". Nothing else here needs clipping (just the
   hamburger button, brand logo, and the user chip/logout button, all of
   which stay within the bar's own bounds regardless). */
.portal-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 0 28px;
  height: var(--topbar-h);
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 100;
}

/* Groups the hamburger + brand together so .portal-topbar's own
   justify-content:space-between only spreads THIS group apart from
   .topbar-right — without this wrapper, space-between treated the
   hamburger, brand, and topbar-right as three separate items and stretched
   a huge gap between the hamburger and the brand icon instead of keeping
   them together on the left. */
.topbar-left {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

/* Centers the logo within the same width — and the same starting edge —
   as the sidebar column directly below it (desktop only; the mobile
   breakpoint further down hides .brand-block entirely, so this never
   applies there). The negative margin cancels .portal-topbar's own 28px
   left padding, which otherwise shifts this whole box 28px right of the
   sidebar's true left edge (the sidebar itself has no such padding), so
   centering "within topbar-left" and centering "within the sidebar
   column" were two different zones — this makes them the same one. */
@media (min-width: 1001px) {
  .topbar-left {
    width: var(--sidebar-w);
    margin-left: -28px;
    justify-content: center;
  }
}

/* Hamburger button that opens the mobile nav drawer — only ever shown at
   the mobile breakpoint (see @media max-width:1000px below); on desktop the
   full sidebar is always visible, so this stays hidden and out of layout. */
.mobile-nav-toggle {
  display: none;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 4px;
  width: 36px;
  height: 36px;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  cursor: pointer;
  flex-shrink: 0;
}

.mobile-nav-toggle span {
  display: block;
  width: 20px;
  height: 2px;
  border-radius: 2px;
  background: var(--ink);
}

.mobile-nav-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(8, 24, 44, 0.45);
  z-index: 590;
}

body.mobile-nav-open .mobile-nav-backdrop {
  display: block;
}

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

/* Hidden on the No Access screen (see updateView's topbarBrandBlock
   toggle) — .brand-block's own display:flex above otherwise beats the
   browser's [hidden]{display:none} default, same reasoning as
   #packingTabs[hidden] and .priority-filter-popover[hidden] elsewhere in
   this file. */
.brand-block[hidden] {
  display: none;
}

.brand-icon {
  display: block;
  height: 76px;
  width: auto;
  max-width: 220px;
  object-fit: contain;
  flex-shrink: 0;
  margin: 0 14px;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.user-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 14px;
  border-radius: var(--radius-md);
  background: var(--panel-soft);
  border: 1px solid var(--line);
  position: relative;
  cursor: pointer;
}

/* Top-bar shortcut into the sidebar's Settings flyout — same circular
   icon-only shape as the admin nav's own icon tiles, sitting to the left
   of the user chip per explicit request. display:none by default and
   shown by setupTopbarSettingsBtn only when this account can actually see
   at least one of the six sections it opens. */
/* ── Top-bar Settings dropdown (Party/Factory/Priority/Size/Users/
   Permissions) ───────────────────────────────────────────────────────
   A gear icon that opens a plain dropdown list, not a sidebar flyout —
   same shape as the reference screenshot supplied (a "SETTINGS" label
   over a row of plain menu items), and the same open/close mechanics
   .user-chip already uses (toggle an "open" class, close on any outside
   click) rather than a second interaction pattern. */
.topbar-settings-wrap {
  position: relative;
}

.topbar-settings-btn {
  /* NOT display:none here - the button's hidden-by-default state is the
     inline style="display:none;" already on the element in index.html.
     setupTopbarSettingsBtn's show() (shared with the sidebar's own
     visibility toggles) reveals it by clearing that inline style to "",
     which only works because the class itself falls back to a real
     display value - a class-level display:none would have overridden
     that every time, leaving the button permanently invisible regardless
     of permissions. */
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--brand-2);
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.topbar-settings-btn:hover {
  background: var(--panel-soft);
  border-color: var(--brand-3);
}

.topbar-settings-menu {
  display: none;
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  min-width: 210px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  padding: 8px 6px;
  z-index: 55;
}

.topbar-settings-menu.open {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.topbar-settings-menu-label {
  padding: 6px 10px 8px;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
}

/* Overrides the 44px icon-tile / stacked-copy look .admin-nav-btn has in
   the real sidebar — a compact single-line row here instead (small icon,
   label beside it), matching a plain dropdown menu rather than a nav rail. */
.topbar-settings-menu-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  border-left: none;
}

.topbar-settings-menu-item .admin-nav-icon {
  width: 26px;
  height: 26px;
  border-radius: 7px;
  background: transparent;
  color: var(--muted-2, var(--muted));
}

.topbar-settings-menu-item .admin-nav-icon svg {
  width: 17px;
  height: 17px;
}

.topbar-settings-menu-item .admin-nav-copy strong {
  font-size: 13px;
  font-weight: 600;
}

.topbar-settings-menu-item:hover {
  background: var(--brand-soft);
}

.topbar-settings-menu-item:hover .admin-nav-copy strong {
  color: var(--brand-2);
}

/* .active here means "this is the open admin section" (set by the same
   updateAdminPanels() that drives the real sidebar buttons) — tinted the
   same way .user-chip-menu-item:hover is rather than the sidebar's own
   heavier gradient+icon-color treatment, which would look out of place on
   a compact menu row. */
.topbar-settings-menu-item.active {
  background: var(--brand-soft);
}

.topbar-settings-menu-item.active .admin-nav-copy strong {
  color: var(--brand-2);
}

.topbar-settings-menu-item.active .admin-nav-icon {
  color: var(--brand-2);
}

.user-chip-menu {
  display: none;
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  min-width: 190px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  padding: 6px;
  z-index: 50;
}

.user-chip-menu.open {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.user-chip-menu-item {
  display: none;
  text-align: left;
  padding: 9px 12px;
  border: none;
  background: transparent;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
}

.user-chip-menu-item.visible {
  display: block;
}

.user-chip-menu-item:hover {
  background: var(--brand-soft);
  color: var(--brand-2);
}

.user-chip-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--brand-2) 0%, var(--brand-3) 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 12px;
  font-weight: 800;
  flex-shrink: 0;
}

.user-chip-info {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
}

.user-chip-name {
  font-size: 13px;
  font-weight: 700;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-chip-role {
  font-size: 11px;
  font-weight: 600;
  color: var(--brand-3);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.job-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  border-radius: var(--radius-md);
  background: var(--accent-soft);
  border: 1px solid rgba(232, 161, 0, 0.25);
}

.job-chip-label {
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--warning);
}

.job-chip-value {
  font-size: 13px;
  font-weight: 800;
  color: var(--brand);
  letter-spacing: -0.01em;
}

/* ── Topbar logout button ──────────────────────── */
.topbar-logout-btn {
  border: 1.5px solid var(--line-strong);
  padding: 9px 22px;
  border-radius: var(--radius-md);
  background: #fff;
  color: var(--ink);
  font-size: 0.88rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.18s ease;
  white-space: nowrap;
  box-shadow: var(--shadow-sm);
}

.topbar-logout-btn:hover {
  background: var(--danger-soft);
  border-color: rgba(201, 64, 64, 0.3);
  color: var(--danger);
  transform: translateY(-1px);
}

/* ════════════════════════════════════════════════════
   PORTAL MAIN LAYOUT
════════════════════════════════════════════════════ */
.portal-main {
  max-width: 1600px;
  margin: 0 auto;
  padding: 24px 24px 48px;
}

.view-panel {
  display: none;
}

.view-panel.active {
  display: block;
}

/* An account with no Permission Group (or one with every flag off) used to
   silently land on the empty employee Job Cards list — this full, centered
   "nothing to see here" screen replaces that with an actual explanation. */
.no-access-screen {
  min-height: calc(100vh - 160px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 18px;
  padding: 48px 24px;
  background: #fff;
  border-radius: var(--radius-md);
}

.no-access-logo {
  width: 220px;
  height: auto;
  margin-bottom: 8px;
}

.no-access-screen h2 {
  font-size: 1.3rem;
  color: var(--ink);
  margin: 0;
}

.no-access-screen p {
  max-width: 420px;
  margin: 0;
}

/* Forces the wizard panel to lay out off-screen (not display:none) so
   html2canvas can capture .preview-sheet for on-demand PDF regeneration
   without visually disrupting whichever screen is actually on-screen. */
.view-panel.pdf-capture-mode {
  display: block !important;
  position: fixed;
  top: 0;
  left: -10000px;
  z-index: -1;
}

/* Forces one specific wizard step section capturable off-screen regardless
   of which step is actually active — lets the combined PDF capture both the
   Job Card (step 8) and the Cutting Report (step 7) in one pass without
   changing which step the user is actually looking at. */
.step.pdf-force-capturable {
  display: block !important;
  position: fixed;
  top: 0;
  left: -10000px;
  z-index: -1;
}

/* ════════════════════════════════════════════════════
   BUTTONS
════════════════════════════════════════════════════ */
.primary-btn,
.secondary-btn,
.ghost-btn,
.icon-btn,
.mini-btn,
.danger-btn {
  border: none;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: all 0.18s ease;
  white-space: nowrap;
  letter-spacing: -0.01em;
}

.primary-btn {
  padding: 12px 22px;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, var(--brand) 0%, var(--brand-2) 60%, var(--brand-3) 100%);
  color: #fff;
  font-size: 0.9rem;
  box-shadow: 0 6px 20px rgba(15, 39, 66, 0.22);
}

.primary-btn:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 10px 28px rgba(15, 39, 66, 0.28);
}

.primary-btn:active:not(:disabled) {
  transform: translateY(0);
}

.secondary-btn {
  padding: 11px 20px;
  border-radius: var(--radius-md);
  background: #fff;
  color: var(--ink);
  font-size: 0.9rem;
  border: 1.5px solid var(--line-strong);
  box-shadow: var(--shadow-sm);
}

.secondary-btn:hover:not(:disabled) {
  background: var(--brand-soft);
  border-color: rgba(21, 87, 160, 0.3);
  color: var(--brand-2);
  transform: translateY(-1px);
}

/* None of .primary-btn/.secondary-btn/.ghost-btn/.mini-btn had ANY
   disabled styling anywhere in this file — a disabled button rendered
   pixel-identical to an enabled one, reported live on Connect Printer's
   own dialog as "Connect Printer" still looking fully clickable once
   already connected (it's disabled at that point, per
   updateConnectPrinterButtonsUI in app.js) with no visual cue at all.
   Scoped to the base classes (not just the printer dialog) since this
   gap affects every disabled button in the app, not only this one. */
.primary-btn:disabled,
.secondary-btn:disabled,
.ghost-btn:disabled,
.mini-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  box-shadow: none;
  transform: none;
  pointer-events: none;
}

/* Full-size danger button (the shared confirm dialog's "Delete"/"Remove")
   — .danger-btn on its own previously had no color/size at all (only
   .mini-btn.danger-btn, the small in-table variant, was ever styled),
   so it silently fell back to the browser's default gray button. */
.danger-btn {
  padding: 11px 20px;
  border-radius: var(--radius-md);
  background: var(--danger);
  color: #fff;
  font-size: 0.9rem;
  box-shadow: var(--shadow-sm);
}

.danger-btn:hover {
  background: #b53434;
  transform: translateY(-1px);
}

.ghost-btn {
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  background: var(--brand-soft);
  color: var(--brand-2);
  font-size: 0.875rem;
  border: 1px solid rgba(21, 87, 160, 0.15);
}

/* "+ Add Size/Fabric Row" used a plain "+" text glyph — swapped for a
   real SVG (matching every other icon in this app, all inline SVGs
   rather than font/text-glyph icons) with proper spacing from the
   label, instead of the "+" sitting flush against the first letter. */
.add-row-btn {
  gap: 6px;
}

.add-row-btn svg {
  flex-shrink: 0;
}

.ghost-btn:hover:not(:disabled) {
  background: rgba(21, 87, 160, 0.12);
  transform: translateY(-1px);
}

.icon-btn {
  padding: 9px 16px;
  border-radius: var(--radius-sm);
  background: var(--danger-soft);
  color: var(--danger);
  font-size: 0.82rem;
  border: 1px solid rgba(201, 64, 64, 0.15);
}

.icon-btn:hover {
  background: rgba(201, 64, 64, 0.15);
  transform: translateY(-1px);
}

/* Mobile-only per-row "+" (see the max-width:1000px rules further down)
   — hidden here so desktop keeps exactly its current behavior: the
   existing "+ Add Size/Fabric Row" button below the table stays the only
   way to add a row there. Given .add-row shares .icon-btn's base danger/
   red coloring (meant for Remove), it needs its own brand-colored
   look so the two don't read as the same kind of action. */
.add-row {
  display: none;
  background: var(--brand-soft);
  color: var(--brand-2);
  border-color: rgba(21, 87, 160, 0.15);
}

.add-row:hover {
  background: rgba(21, 87, 160, 0.15);
}

.mini-btn {
  padding: 7px 14px;
  border-radius: var(--radius-xs);
  background: var(--brand-soft);
  color: var(--brand-2);
  font-size: 0.8rem;
  border: 1px solid rgba(21, 87, 160, 0.15);
}

.mini-btn:hover:not(:disabled) {
  background: rgba(21, 87, 160, 0.12);
  transform: translateY(-1px);
}

.mini-btn.danger-btn {
  background: var(--danger-soft);
  color: var(--danger);
  border-color: rgba(201, 64, 64, 0.15);
}

.mini-btn.danger-btn:hover {
  background: rgba(201, 64, 64, 0.15);
}

/* Focus-visible accessibility rings */
.primary-btn:focus-visible,
.secondary-btn:focus-visible,
.ghost-btn:focus-visible,
.mini-btn:focus-visible,
.topbar-logout-btn:focus-visible {
  outline: 3px solid rgba(30, 114, 209, 0.55);
  outline-offset: 2px;
}

/* Edit mode indicator banner */
.edit-mode-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  background: linear-gradient(95deg, #fffbeb 0%, #fff7d6 100%);
  border: 1.5px solid rgba(232, 161, 0, 0.35);
  font-size: 13px;
  font-weight: 600;
  color: #92400e;
  margin-bottom: 16px;
}

.edit-mode-banner .edit-mode-icon {
  font-size: 16px;
  flex-shrink: 0;
}

/* ════════════════════════════════════════════════════
   FORM ELEMENTS
════════════════════════════════════════════════════ */
.field {
  display: grid;
  gap: 7px;
}

.field > span,
.field > label > span {
  font-size: 13px;
  font-weight: 700;
  color: var(--ink-2);
  letter-spacing: 0.01em;
}

/* 11.5px wrapped this exact sentence to 2 lines on the Add/Edit User
   dialog's mobile single-column layout (measured available width as
   narrow as 323px there, needing 386.5px unwrapped at 11.5px) — 9px
   measured its real natural width at 302.5px, comfortably under 323px,
   the largest (most legible) size that reliably fits on one line rather
   than an arbitrary shrink. No white-space:nowrap: an even narrower phone
   than measured here should still wrap gracefully (matching the old
   2-line look) instead of overflowing/clipping. */
.field-hint {
  font-size: 9px;
  color: var(--muted);
  margin-top: -2px;
}

input[type="text"],
input[type="password"],
input[type="date"],
input[type="number"],
input[type="email"],
input[type="file"],
select,
textarea {
  width: 100%;
  padding: 13px 16px;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--line);
  background: #fff;
  color: var(--ink);
  font-size: 0.9rem;
  transition: border-color 0.18s ease, box-shadow 0.18s ease;
  appearance: none;
  -webkit-appearance: none;
}

/* `appearance: none` above doesn't reach a number input's spin button in
   Chromium — that lives in its own ::-webkit-*-spin-button pseudo-element,
   which only shows on hover/focus, so identical size-quantity fields look
   inconsistent (some plain, whichever one you last touched showing
   up/down arrows) instead of uniformly plain like every other field. Most
   visible in the Cutting/Packing size grids, where the arrows also eat
   into an already-narrow mobile column. */
input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

input[type="number"] {
  -moz-appearance: textfield;
}

select {
  background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3e%3cpath stroke='%235a7190' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='M6 8l4 4 4-4'/%3e%3c/svg%3e");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 18px;
  padding-right: 36px;
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--brand-3);
  box-shadow: 0 0 0 3.5px rgba(30, 114, 209, 0.13);
}

input[readonly] {
  background: var(--panel-soft);
  color: var(--muted);
}

input[type="file"] {
  padding: 11px 14px;
  cursor: pointer;
}

input[type="range"] {
  width: 100%;
  padding: 0;
  border: none;
  background: none;
  accent-color: var(--brand-3);
  cursor: pointer;
}

.grid {
  display: grid;
  gap: 16px;
}

.grid.two {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

/* ════════════════════════════════════════════════════
   CARDS & PANELS
════════════════════════════════════════════════════ */
.screen-card,
.wizard-card {
  background: rgba(255, 255, 255, 0.97);
  border: 1px solid var(--line);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-md);
}

.screen-card {
  padding: 24px;
}

.screen-card:not(.active) {
  display: none;
}

.screen-card + .screen-card {
  margin-top: 20px;
}

/* ════════════════════════════════════════════════════
   PAGE HEADERS
════════════════════════════════════════════════════ */
.page-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

/* The title block used to size to its own (short) text, leaving a large,
   awkward-looking dead gap before the pill/button on the right at wide
   desktop widths. Letting it grow into the row's available space keeps the
   header feeling like one balanced unit instead of two islands with empty
   space between them. */
.page-header > div:first-child {
  flex: 1;
  min-width: 0;
}

.page-header h2 {
  font-size: 1.6rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  color: var(--ink);
  line-height: 1.15;
}

.page-header .muted {
  margin-top: 4px;
}

.page-header.inner {
  margin-bottom: 0;
}

.section-heading {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.section-heading h3 {
  font-size: 1.15rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--ink);
}

.section-heading .muted {
  margin-top: 3px;
}

.section-heading.compact {
  align-items: start;
}

.inline-actions {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

.panel-note {
  display: inline-flex;
  align-items: center;
  padding: 8px 14px;
  border-radius: 999px;
  background: var(--brand-soft);
  color: var(--brand-2);
  font-size: 12.5px;
  font-weight: 600;
  border: 1px solid rgba(21, 87, 160, 0.12);
}

/* ════════════════════════════════════════════════════
   ADMIN LAYOUT
   The sidebar lives outside both view-panels (see index.html) so it stays
   visible whether the admin is looking at the Admin panel or the Job Card
   wizard — it only ever shows at all for an admin session (body.is-admin,
   toggled in JS right after login/session-restore), never for an employee.
════════════════════════════════════════════════════ */
.app-shell-layout {
  display: block;
}

.admin-sidebar {
  display: none;
}

/* ── Admin Sidebar (sizing/appearance — only visible once body.is-admin
   sets display:flex below; these properties are inert until then) ───── */
.admin-sidebar {
  position: sticky;
  top: calc(var(--topbar-h) + 24px);
  max-height: calc(100vh - var(--topbar-h) - 48px);
  max-height: calc(100dvh - var(--topbar-h) - 48px); /* dvh overrides vh above on browsers that support it — accounts for mobile browser chrome (address bar) that 100vh doesn't */
  overflow-y: auto;
  overflow-x: hidden;
  border-radius: var(--radius-xl);
  background: #fff;
  border: 1px solid var(--line);
  box-shadow: var(--shadow-md);
  flex-direction: column;

  scrollbar-width: thin;
  scrollbar-color: var(--line) transparent;
}

.admin-sidebar::-webkit-scrollbar { width: 4px; }
.admin-sidebar::-webkit-scrollbar-track { background: transparent; }
.admin-sidebar::-webkit-scrollbar-thumb { background: var(--line); border-radius: 4px; }

/* Hidden on desktop, where the topbar right above already shows the same
   logo + company name — shown only inside the mobile drawer (see @media
   max-width:1000px below), which has no topbar brand of its own visible
   once the drawer covers it, so it needs its own header. */
.admin-sidebar-head {
  display: none;
  padding: 12px 18px;
  border-bottom: 1px solid var(--line);
  flex-shrink: 0;
}

.admin-sidebar-head .sidebar-brand {
  display: flex;
  align-items: center;
  justify-content: center;
}

.sidebar-brand-icon {
  display: block;
  height: 52px;
  width: auto;
  max-width: 120px;
  object-fit: contain;
  flex-shrink: 0;
}

/* ── Sidebar Nav ─────────────────────────────────── */
.admin-nav {
  display: flex;
  flex-direction: column;
  padding: 8px 0;
  gap: 0;
  flex: 1;
}

.admin-nav-btn {
  display: flex;
  align-items: center;
  gap: 13px;
  width: 100%;
  border: none;
  border-radius: 0;
  background: transparent;
  color: var(--ink);
  text-align: left;
  padding: 13px 18px 13px 20px;
  cursor: pointer;
  transition: background 0.15s ease;
  position: relative;
  border-left: 3px solid transparent;
}

.admin-nav-btn:hover {
  background: var(--panel-soft);
}

.admin-nav-icon {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #eef4fb;
  color: var(--brand-2);
  flex-shrink: 0;
  transition: background 0.16s ease, color 0.16s ease;
}

.admin-nav-icon svg {
  width: 22px;
  height: 22px;
}

.admin-nav-copy {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  flex: 1;
}

.admin-nav-copy strong {
  display: block;
  font-size: 13.5px;
  font-weight: 700;
  color: var(--ink);
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: color 0.16s ease;
}

.admin-nav-copy span {
  display: block;
  font-size: 11.5px;
  font-weight: 500;
  color: var(--muted);
  line-height: 1.3;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.admin-nav-btn.active {
  background: linear-gradient(95deg, rgba(30, 114, 209, 0.1) 0%, rgba(21, 87, 160, 0.05) 100%);
  box-shadow: inset 0 0 0 1px rgba(30, 114, 209, 0.15);
}

.admin-nav-btn.active::before {
  transform: translateY(-50%) scaleY(1);
}

.admin-nav-btn.active .admin-nav-icon {
  background: linear-gradient(135deg, var(--brand-2) 0%, var(--brand-3) 100%);
  color: #fff;
  box-shadow: 0 3px 8px rgba(21, 87, 160, 0.25);
}

.admin-nav-btn.active .admin-nav-copy strong {
  color: var(--brand-2);
}

.admin-nav-btn.active .admin-nav-copy span {
  color: rgba(21, 87, 160, 0.65);
}

/* ── Sidebar Footer ──────────────────────────────── */
.admin-sidebar-foot {
  margin: 8px 10px 12px;
  padding: 12px 14px;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, var(--panel-soft) 0%, #eef5fb 100%);
  border: 1px solid var(--line);
  flex-shrink: 0;
}

.sidebar-foot-badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 9px;
  border-radius: 999px;
  background: rgba(21, 87, 160, 0.1);
  color: var(--brand-2);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  margin-bottom: 8px;
}

.admin-sidebar-foot strong {
  display: block;
  font-size: 13px;
  font-weight: 700;
  color: var(--ink);
  margin-bottom: 4px;
  letter-spacing: -0.01em;
}

.admin-sidebar-foot p {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.5;
}

/* ════════════════════════════════════════════════════
   ADMIN CONTENT AREA
════════════════════════════════════════════════════ */
.admin-content {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* ── Overview / Stats ────────────────────────────── */
.admin-overview {
  padding: 24px 26px;
  border-radius: var(--radius-xl);
  background: linear-gradient(120deg, rgba(255, 255, 255, 0.98) 0%, rgba(240, 248, 255, 0.9) 100%);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-md);
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 20px;
  align-items: center;
}

.admin-overview-copy h2 {
  font-size: clamp(1.6rem, 2.5vw, 2.2rem);
  font-weight: 800;
  letter-spacing: -0.04em;
  line-height: 1.1;
  color: var(--ink);
  margin-bottom: 6px;
}

.admin-overview-copy .muted {
  max-width: 500px;
  font-size: 0.875rem;
}

.admin-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}

.admin-stat-card {
  padding: 16px 18px;
  border-radius: var(--radius-lg);
  background: #fff;
  border: 1px solid var(--line);
  box-shadow: var(--shadow-sm);
  text-align: center;
  min-width: 100px;
  transition: transform 0.18s ease, box-shadow 0.18s ease;
}

.admin-stat-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.admin-stat-card .stat-label {
  display: block;
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--muted-2);
  margin-bottom: 6px;
}

.admin-stat-card strong {
  display: block;
  font-size: 2rem;
  font-weight: 800;
  letter-spacing: -0.04em;
  line-height: 1;
  color: var(--brand);
  margin-bottom: 5px;
}

.admin-stat-card .stat-desc {
  font-size: 11px;
  color: var(--muted);
  line-height: 1.4;
}

/* ── Admin Panels ────────────────────────────────── */
.admin-panel {
  display: none;
}

.admin-panel.active {
  display: block;
}

.admin-panel-header {
  margin-bottom: 16px;
}

.admin-panel-header h2 {
  font-size: 1.5rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  color: var(--ink);
  margin-bottom: 4px;
}

/* ════════════════════════════════════════════════════
   TOOLBAR / SEARCH
════════════════════════════════════════════════════ */
.toolbar-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 200px auto;
  gap: 10px;
  margin-bottom: 16px;
  align-items: start;
}

.toolbar-grid.admin-toolbar {
  grid-template-columns: minmax(0, 1fr) auto 200px;
}

/* Wraps the Priority filter <select> plus its mobile-only custom
   button+popover (see @media max-width:1000px) — display:contents
   removes the wrapper from layout entirely everywhere else, so the
   select participates in .toolbar-grid exactly as if this wrapper
   didn't exist, and the button/popover (display:none by default,
   below) don't affect anything either. Nothing about desktop changes. */
.priority-filter-wrap {
  display: contents;
}

.priority-filter-btn,
.priority-filter-popover {
  display: none;
}

/* ════════════════════════════════════════════════════
   DATE RANGE FILTER (Job Card list — filter by Issue Date)
════════════════════════════════════════════════════ */
.date-range-filter {
  position: relative;
}

.date-range-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 100%;
  padding: 13px 16px;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--line);
  background: #fff;
  color: var(--ink);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: border-color 0.18s ease;
}

.date-range-btn:hover {
  border-color: var(--brand-3);
}

.date-range-btn svg {
  color: var(--muted-2);
  flex-shrink: 0;
}

.date-range-filter.has-value .date-range-btn {
  border-color: var(--brand-2);
  color: var(--brand-2);
  background: var(--brand-soft);
}

/* ════════════════════════════════════════════════════
   STATUS MULTI-FILTER (Job Card list — Pending/Completed/Delivered,
   any combination at once)
════════════════════════════════════════════════════ */
.status-multi-filter {
  position: relative;
}

/* .status-multi-btn reuses .date-range-btn's box/border/hover styling —
   same pill shape as the Issue Date filter beside it — this only adds the
   bits that differ (a fixed width so the label swapping between "Pending"
   and "3 statuses" doesn't reflow the toolbar, and the same has-value tint
   the date filter gets). */
.status-multi-btn {
  min-width: 148px;
  justify-content: flex-start;
}

.status-multi-btn.has-value {
  border-color: var(--brand-2);
  color: var(--brand-2);
  background: var(--brand-soft);
}

.status-multi-label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.status-multi-popover {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  z-index: 40;
  min-width: 200px;
  padding: 10px;
  border-radius: var(--radius-md);
  border: 1px solid var(--line);
  background: #fff;
  box-shadow: var(--shadow-lg);
}

.status-multi-option {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 8px;
  border-radius: var(--radius-sm);
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--ink);
  cursor: pointer;
}

.status-multi-option:hover {
  background: var(--panel-soft);
}

.status-multi-option input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--brand-2);
}

.status-multi-actions {
  margin-top: 6px;
  padding-top: 8px;
  border-top: 1px solid var(--line);
}

.status-multi-clear-btn {
  width: 100%;
  padding: 8px 10px;
  font-size: 0.82rem;
}

/* ── Panel total badge (Job Card Management: "9 job cards" beside the
   heading) — a plain count of what exists, distinct from a filtered
   result count, so it reads as project scale rather than a search result. */
.panel-total-badge {
  display: inline-block;
  margin: 4px 0 0;
  padding: 3px 10px;
  border-radius: 999px;
  background: var(--panel-soft);
  color: var(--muted-2, var(--muted));
  font-size: 0.78rem;
  font-weight: 700;
}
.panel-total-badge[hidden] {
  display: none;
}

.date-range-popover {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  z-index: 40;
  width: max(320px, 100%);
  padding: 14px;
  border-radius: var(--radius-md);
  border: 1px solid var(--line);
  background: #fff;
  box-shadow: var(--shadow-lg);
}

.date-range-presets {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  margin-bottom: 12px;
}

.date-range-presets button {
  padding: 9px 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: var(--panel-soft);
  color: var(--ink);
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  text-align: left;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.date-range-presets button:hover {
  background: var(--brand-soft);
  border-color: var(--brand-3);
}

.date-range-custom {
  display: grid;
  gap: 10px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.date-range-custom label {
  display: block;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--muted);
}

.date-range-custom input[type="text"] {
  margin-top: 4px;
  padding: 9px 10px;
  font-size: 0.85rem;
}

.date-range-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.date-range-actions button {
  padding: 8px 14px;
  font-size: 0.82rem;
}

/* ════════════════════════════════════════════════════
   DATA TABLE
════════════════════════════════════════════════════ */
.table-shell {
  /* overflow-x only (not the old plain "overflow: auto") — this still
     scrolls wide tables horizontally on narrow screens, but no longer
     clips content that deliberately overflows vertically, like the
     Packaging List's "Don't Edit" tooltip (.dont-edit-tooltip-wrap),
     which renders below its checkbox and was getting cut off mid-sentence
     whenever that checkbox was in the table's last (or only) row. */
  overflow-x: auto;
  overflow-y: visible;
  border-radius: var(--radius-lg);
  border: 1px solid var(--line);
  background: #fff;
  box-shadow: var(--shadow-sm);
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 700px;
}

th {
  padding: 13px 16px;
  text-align: left;
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--muted);
  background: linear-gradient(180deg, var(--panel-soft) 0%, #eef5fb 100%);
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}

td {
  padding: 13px 16px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
  font-size: 0.88rem;
  color: var(--ink);
}

tbody tr:hover {
  background: #f8fcff;
}

/* The cutting report is a fixed printable template — it must look identical
   whether or not the mouse happens to be hovering a row when a PDF is
   captured, so it's excluded from the generic row-hover highlight. */
.cutting-report-table tbody tr:hover {
  background: inherit;
}

tbody tr:last-child td {
  border-bottom: none;
}

.actions-col {
  min-width: 230px;
}

/* Address/Email/GST truncation is handled in JS now (renderClampableCell —
   see .clamp-text/.clamp-toggle below), which actually clips the DOM text
   rather than relying on CSS text-overflow. A CSS-only max-width/ellipsis
   approach was tried here first but doesn't work at all in an auto-layout
   table (the browser sizes columns to fit content BEFORE overflow rules
   ever apply, so nothing was ever actually clipped), and forcing
   white-space:nowrap on the cell fights the JS clamp's own inline-block
   wrapping besides. */

.row-actions {
  display: flex;
  gap: 6px;
  flex-wrap: nowrap;
  align-items: center;
}

.row-actions .mini-btn {
  white-space: nowrap;
}

/* ── Overview Reports ────────────────────────────── */
/* Its own scroll wrapper (not .table-shell) — this table has real
   rowspan-ned cells (3 rows per job) that .table-shell's card-collapse
   CSS (built for simple flat rows) isn't set up to handle, so it stays a
   plain scrollable table at every width for now rather than half-broken
   inside a layout designed for something else. */
/* A thin, brand-tinted scrollbar instead of the browser's native one —
   which on several platforms renders as a thick, near-black bar, reported
   live as looking heavier/darker than the rest of this app's light,
   rounded design language. */
.overview-report-scroll,
.overview-report-scroll-top {
  scrollbar-width: thin;
  scrollbar-color: var(--line-strong, #b9c8dc) transparent;
}

.overview-report-scroll::-webkit-scrollbar,
.overview-report-scroll-top::-webkit-scrollbar {
  height: 8px;
}

.overview-report-scroll::-webkit-scrollbar-track,
.overview-report-scroll-top::-webkit-scrollbar-track {
  background: transparent;
}

.overview-report-scroll::-webkit-scrollbar-thumb,
.overview-report-scroll-top::-webkit-scrollbar-thumb {
  background: var(--line-strong, #b9c8dc);
  border-radius: 999px;
}

.overview-report-scroll {
  overflow-x: auto;
  border-radius: var(--radius-lg);
  border: 1px solid var(--line);
  border-top: none;
  background: #fff;
}

/* See the HTML comment above #overviewReportScrollTop — a slim duplicate
   scrollbar directly above the table, synced to the real one below by
   syncOverviewReportTopScroll in app.js, so the scroll affordance is
   visible immediately instead of only at the very bottom of a table that
   can run to 20+ columns. */
.overview-report-scroll-top {
  overflow-x: auto;
  overflow-y: hidden;
  height: 14px;
  border: 1px solid var(--line);
  border-bottom: none;
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  background: #fff;
}

.overview-report-scroll-top #overviewReportScrollTopInner {
  height: 1px;
}

.overview-report-table {
  width: 100%;
  min-width: 900px;
  border-collapse: collapse;
}

.overview-report-table th,
.overview-report-table td {
  border-bottom: 1px solid var(--line);
  padding: 10px 12px;
  text-align: center;
  vertical-align: middle;
  font-size: 0.82rem;
  white-space: nowrap;
}

.overview-report-table th {
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 10px;
  font-weight: 700;
  color: var(--muted);
  background: linear-gradient(180deg, var(--panel-soft) 0%, #eef5fb 100%);
}

/* Job No./Order No. read as regular table content elsewhere in the app
   (left-aligned) — kept that way here too. Targeted by class, not
   :nth-child(1)/(2) — those only ever lined up with the right cell on a
   fabric's own top row (the only row with all 5 leading cells present);
   every other row shifts earlier cells left, so nth-child there landed on
   a random column instead. */
.overview-report-table td.overview-report-jobno,
.overview-report-table td.overview-report-orderno {
  text-align: left;
  white-space: normal;
}

/* Headers over the left-aligned text columns (Job No., Job Card Name,
   Party Name, Order No., Process) — a centred header above a
   left-aligned value read as a column out of line, which is exactly
   what it was. */
.overview-report-table th.overview-report-text-head {
  text-align: left;
}

/* The rowspan-ned job columns sit against the top of the block they
   span rather than floating in the middle of three process rows, so
   each job's name lines up with its own first row. */
.overview-report-table td.overview-report-jobno,
.overview-report-table td.overview-report-orderno,
.overview-report-table td.overview-report-fabric {
  vertical-align: middle;
}

/* Both header rows share one baseline treatment: the SIZE group header
   spans the size columns on row 1 while every other header spans both
   rows, and without this the tall rowspan headers pushed their text to
   the middle while SIZE sat at the top. */
.overview-report-table thead th {
  vertical-align: middle;
}

/* Fabric Name/Design No's own column is sized for its 2-line header, which
   left short fabric names (most of them, in practice) hugging the left
   edge with a big dead gap on the right when left-aligned the same way as
   Job No./Order No. — reported live as looking like the column had split
   into two conflicting halves. Centered like the neighboring MTR/Avg.
   Pcs. columns instead. */
.overview-report-table td.overview-report-fabric {
  text-align: center;
  white-space: normal;
}

.overview-report-row-bottom td {
  border-bottom: 2px solid var(--line);
}

/* The line between two fabrics of the SAME job and the line between two
   DIFFERENT jobs used to look identical (both just this 2px --line
   border), so a job with several fabric lines gave no visual cue for
   where it actually ended and the next job began — reported live as hard
   to tell apart. Only the last fabric block's own Damage row (the true
   end of a job, right before Job No./Order No. change) gets this darker,
   thicker border; every fabric boundary within the same job keeps the
   lighter one above. */
.overview-report-row-bottom.overview-report-job-end td {
  border-bottom: 2px solid var(--ink);
}

.overview-report-process {
  text-align: left !important;
  font-weight: 700;
  color: var(--ink);
}

.overview-report-process-cutting {
  color: var(--brand-2);
}

.overview-report-process-damage {
  color: var(--danger);
}

.overview-report-damage-positive {
  color: var(--danger);
  font-weight: 700;
}

/* ── Tags / Pills ────────────────────────────────── */
.tag {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 4px 12px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: 0.02em;
  white-space: nowrap;
}

.tag.high  { background: var(--danger-soft);  color: var(--danger);  }
.tag.medium{ background: var(--warning-soft); color: var(--warning); }
.tag.low   { background: var(--success-soft); color: var(--success); }
.tag.default { background: var(--brand-soft); color: var(--brand-2); }

/* Cutting job list's Pending/Completed toggle — a real <button> styled as
   the same pill as every other .tag, since it needs to actually be
   clickable (not permission-gated, see update_cutting_status in main.py —
   anyone who can see this list can flip it in either direction). */
.tag-status-toggle {
  border: none;
  cursor: pointer;
  font-family: inherit;
  font-weight: 700;
  transition: filter 0.15s ease;
}

.tag-status-toggle:hover {
  filter: brightness(0.94);
}

.permission-cell { font-size: 0.82rem; font-weight: 700; }
.permission-yes  { color: var(--success); }
.permission-no   { color: var(--danger);  }

.empty-state td {
  padding: 40px 16px;
  text-align: center;
  color: var(--muted);
  font-weight: 600;
  font-size: 0.88rem;
}

/* ════════════════════════════════════════════════════
   EMPLOYEE / JOB CARD WIZARD
════════════════════════════════════════════════════ */
.step-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.step-pill {
  border: 1.5px solid var(--line);
  background: #fff;
  color: var(--muted);
  border-radius: 999px;
  padding: 5px 14px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.18s ease;
  white-space: nowrap;
}

.step-pill:hover {
  border-color: var(--brand-3);
  color: var(--brand-2);
  background: var(--brand-soft);
}

.step-pill.active {
  background: linear-gradient(135deg, var(--accent) 0%, #f7a800 100%);
  color: #fff;
  border-color: transparent;
  box-shadow: 0 3px 10px rgba(232, 161, 0, 0.35);
}

.wizard-progress {
  height: 4px;
  background: var(--line);
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  overflow: hidden;
}

.wizard-progress-bar {
  height: 100%;
  width: 14.28%;
  background: linear-gradient(90deg, var(--accent) 0%, #ef7342 100%);
  transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

form {
  padding: 22px 24px;
}

.step {
  display: none;
}

.step.active {
  display: block;
}

.wizard-actions {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 24px 20px;
  border-top: 1px solid var(--line);
  background: var(--panel-soft);
}

/* Full label shows by default (desktop, and mobile above the 2-button
   steps that already fit) — the mobile media query further down swaps
   which of this pair is visible, only for the 3-button final step
   where the full labels don't fit. */
.btn-label-short {
  display: none;
}

/* ════════════════════════════════════════════════════
   PARTY / FACTORY SELECT
════════════════════════════════════════════════════ */
/* Flexbox, not CSS Grid — grid's fr-unit/implicit-track sizing has known
   inconsistencies on older or budget Android WebViews, which showed up here
   as a stray empty box next to the dropdown on a real device. Flexbox has
   much more mature, uniform support across low-end mobile browsers. */
.option-select-row {
  display: flex;
  align-items: stretch;
  gap: 8px;
}

.option-select-row select {
  flex: 1 1 auto;
  min-width: 0;
}

.option-select-row .ghost-btn {
  flex: 0 0 auto;
}

/* ════════════════════════════════════════════════════
   DATE PICKER (Issue Date / Due Date)
   Plain text inputs (DD/MM/YYYY) with a calendar dropdown attached —
   native <input type="date"> can't be forced into DD/MM/YYYY display in
   Chrome, so typing stays the source of truth and this popup is just a
   faster way to fill it in.
════════════════════════════════════════════════════ */
.date-input-wrap {
  position: relative;
}

.date-input-wrap input {
  padding-right: 42px;
}

.date-picker-toggle {
  position: absolute;
  top: 50%;
  right: 6px;
  transform: translateY(-50%);
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border: none;
  background: transparent;
  color: var(--muted);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}

.date-picker-toggle:hover {
  background: var(--brand-soft);
  color: var(--brand-2);
}

.password-input-wrap {
  position: relative;
}

.password-input-wrap input {
  padding-right: 42px;
}

.password-toggle-btn {
  position: absolute;
  top: 50%;
  right: 6px;
  transform: translateY(-50%);
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border: none;
  background: transparent;
  color: var(--muted);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}

.password-toggle-btn:hover {
  background: var(--brand-soft);
  color: var(--brand-2);
}

.date-picker-panel {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  z-index: 40;
  width: 280px;
  padding: 14px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  font-size: 0.85rem;
}

.date-picker-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.date-picker-header .date-picker-month {
  font-weight: 700;
  color: var(--ink);
}

.date-picker-nav {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: var(--radius-sm);
  cursor: pointer;
  color: var(--brand-2);
  transition: background 0.15s ease;
}

.date-picker-nav:hover {
  background: var(--brand-soft);
}

.date-picker-weekdays,
.date-picker-days {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 2px;
  text-align: center;
}

.date-picker-weekdays span {
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  padding: 4px 0;
}

.date-picker-day {
  border: none;
  background: transparent;
  padding: 7px 0;
  border-radius: var(--radius-sm);
  cursor: pointer;
  color: var(--ink);
  font-size: 0.85rem;
}

.date-picker-day:hover {
  background: var(--brand-soft);
}

.date-picker-day.is-outside-month {
  color: var(--muted-2);
  opacity: 0.55;
}

.date-picker-day.is-today {
  border: 1.5px solid var(--accent);
}

.date-picker-day.is-selected {
  background: var(--brand);
  color: #fff;
  font-weight: 700;
}

.date-picker-footer {
  display: flex;
  justify-content: center;
  margin-top: 10px;
}

.date-picker-today-btn {
  border: none;
  background: transparent;
  color: var(--brand-2);
  font-weight: 700;
  font-size: 12.5px;
  cursor: pointer;
  padding: 4px 8px;
}

.date-picker-today-btn:hover {
  text-decoration: underline;
}

/* ════════════════════════════════════════════════════
   BOXED PANELS (Size/Fabric rows)
════════════════════════════════════════════════════ */
.boxed-panel {
  padding: 18px;
  border-radius: var(--radius-lg);
  border: 1.5px solid var(--line);
  background: var(--panel-soft);
}

.table-head,
.table-row {
  display: grid;
  gap: 12px;
  align-items: center;
}

.table-head {
  padding: 0 4px 10px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--muted);
  border-bottom: 1px solid var(--line);
  margin-bottom: 10px;
}

.table-row {
  margin-bottom: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-md);
  border: 1.5px solid var(--line);
  background: #fff;
  transition: border-color 0.15s ease;
}

.table-row:hover {
  border-color: var(--line-strong);
}

.table-row:last-child {
  margin-bottom: 12px;
}

/* Two columns only: Size rows come from the Size master, so they carry no
   Remove/+ buttons (unlike fabric rows, which still do). Sized to their
   content rather than split across the full width — a 1.4fr/1fr split
   stretched the size-name input right across the screen and left a wide
   dead strip between it and the ratio buttons, and another to their
   right. max-content on the ratio column makes it exactly as wide as the
   five buttons need. */
.size-grid   { grid-template-columns: minmax(0, 260px) max-content; gap: 16px; justify-content: start; }

/* ...and the panel around them stops at the rows instead of running the
   full width of the step. Scoped to Step 2: Step 6's fabric rows have
   more columns and still want the room. */
.step[data-step="2"] .boxed-panel {
  max-width: 560px;
  padding: 14px;
}

.step[data-step="2"] .table-row {
  margin-bottom: 8px;
  padding: 8px 10px;
}
.fabric-grid { grid-template-columns: 0.8fr 0.7fr 1.6fr 100px; }

.row-cell {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

/* Only shown once the row collapses to a single column (see the 520px
   breakpoint) — on desktop/tablet the grid columns line up with .table-head
   above them instead, so an inline label would just be a redundant echo. */
.row-cell-label {
  display: none;
}

/* ════════════════════════════════════════════════════
   RICH TEXT EDITOR
════════════════════════════════════════════════════ */
.editor-shell {
  overflow: hidden;
  border-radius: var(--radius-md);
  border: 1.5px solid var(--line);
  background: #fff;
  transition: border-color 0.18s ease;
}

.editor-shell:focus-within {
  border-color: var(--brand-3);
  box-shadow: 0 0 0 3.5px rgba(30, 114, 209, 0.13);
}

.editor-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  background: var(--panel-soft);
  border-bottom: 1px solid var(--line);
}

.editor-toolbar-group {
  display: inline-flex;
  gap: 4px;
}

.editor-toolbar-divider {
  width: 1px;
  align-self: stretch;
  min-height: 22px;
  background: var(--line);
  margin: 0 2px;
}

.editor-toolbar button {
  border: 1.5px solid var(--line);
  background: #fff;
  border-radius: var(--radius-xs);
  min-width: 30px;
  height: 30px;
  padding: 0 10px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 700;
  color: var(--ink);
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s ease;
}

.editor-toolbar button:hover {
  background: var(--brand-soft);
  border-color: rgba(21, 87, 160, 0.25);
  color: var(--brand-2);
}

.editor-toolbar button.is-active {
  background: var(--brand-2);
  border-color: var(--brand-2);
  color: #fff;
}

.editor-select {
  height: 30px;
  padding: 0 8px;
  border: 1.5px solid var(--line);
  border-radius: var(--radius-xs);
  background: #fff;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
  cursor: pointer;
}

.color-picker {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 5px 10px;
  border-radius: var(--radius-xs);
  border: 1.5px solid var(--line);
  background: #fff;
  font-size: 13px;
  font-weight: 600;
}

.color-picker input[type="color"] {
  width: 22px;
  height: 22px;
  padding: 0;
  border: none;
  border-radius: 4px;
  cursor: pointer;
}

.editor {
  min-height: 200px;
  padding: 14px 16px;
  outline: none;
  line-height: 1.75;
  font-size: 0.9rem;
}

/* The global `* { margin:0; padding:0; }` reset also zeroes out <ul>/<ol>'s
   marker indent, which otherwise pushes the bullet/number itself flush
   against the container's edge with no gap before the text. Applies to both
   the editable box and the read-only preview/PDF, since both render the
   same sanitized HTML. */
.editor ul, .editor ol,
.preview-description ul, .preview-description ol {
  padding-left: 1.5em;
  margin: 0.5em 0;
}

.editor li, .preview-description li {
  margin: 0.2em 0;
}

/* ════════════════════════════════════════════════════
   IMAGE UPLOAD CARDS
════════════════════════════════════════════════════ */
.cards-grid { align-items: start; }

.upload-card {
  padding: 18px;
  border-radius: var(--radius-lg);
  border: 1.5px solid var(--line);
  background: var(--panel-soft);
}

.upload-header h4 {
  font-size: 1rem;
  font-weight: 800;
  color: var(--ink);
  margin-bottom: 4px;
}

.upload-header p {
  margin: 0 0 14px;
  color: var(--muted);
  font-size: 0.85rem;
}

.image-stage {
  height: 260px;
  margin-bottom: 12px;
  border-radius: var(--radius-md);
  border: 2px dashed var(--line-strong);
  background: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  position: relative;
  transition: border-color 0.15s ease;
  cursor: pointer;
}

.image-stage:hover,
.image-stage.dragover {
  border-color: var(--brand-3);
  background: rgba(13, 31, 53, 0.02);
}

/* Product photos display as a square tile (see .photo-card), unlike the
   rectangular Main Label/Hang Tag frame — the editor stage matches that
   aspect ratio so dragging/zooming on screen reflects the actual crop. */
#productPhotoStage {
  height: auto;
  aspect-ratio: 1 / 1;
}

.image-placeholder {
  font-size: 13px;
  font-weight: 600;
  color: var(--muted-2);
}

.image-stage img {
  display: none;
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #fff;
  position: absolute;
  inset: 0;
}

.image-stage.has-image img {
  display: block;
}

.image-stage.has-image .image-placeholder {
  display: none;
}

.image-stage.has-image {
  cursor: grab;
  touch-action: none;
}

.image-stage.has-image.dragging {
  cursor: grabbing;
}

.image-drag-hint {
  display: none;
  position: absolute;
  bottom: 8px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(15, 39, 66, 0.72);
  color: #fff;
  font-size: 11px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 999px;
  pointer-events: none;
  z-index: 2;
}

.image-stage.has-image .image-drag-hint {
  display: block;
}

/* Corner crop-marks reinforce that this frame is the crop boundary — only
   what's inside these marks is kept when the image is baked/saved. */
.image-stage.has-image::before,
.image-stage.has-image::after {
  content: "";
  position: absolute;
  width: 16px;
  height: 16px;
  pointer-events: none;
  z-index: 2;
  border-color: var(--brand-3);
  border-style: solid;
}

.image-stage.has-image::before {
  top: 6px;
  left: 6px;
  border-width: 2px 0 0 2px;
}

.image-stage.has-image::after {
  bottom: 6px;
  right: 6px;
  border-width: 0 2px 2px 0;
}

.image-stage-remove {
  display: none;
  z-index: 3;
}

.image-stage.has-image .image-stage-remove {
  display: flex;
}

.image-controls {
  display: grid;
  gap: 10px;
}

.button-row {
  display: flex;
  gap: 10px;
}

.button-row .secondary-btn {
  flex: 1;
}

/* ════════════════════════════════════════════════════
   PHOTO GRID
════════════════════════════════════════════════════ */
.photo-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

/* .preview-photo-grid deliberately uses flexbox, not CSS Grid — WeasyPrint's
   grid engine has a known bug in this same file (see the .preview-job note
   further down) where grid-template-columns combined with an item's own
   max-width/centering mis-positions items; empty photo slots (no <img> to
   otherwise size them) hit exactly that combination and rendered shifted
   off the right edge of the page. Flex-wrap with an explicit per-cell width
   avoids CSS Grid here entirely and lays out identically on screen. Sizing
   each tile bigger than the old 5-across layout, but capped so all 3 rows
   plus captions still fit on the Product Photos page's one dedicated
   sheet instead of spilling onto a stray extra page. */
.preview-photo-grid {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
}

.preview-photo-grid .preview-photo-cell {
  width: calc(50% - 5px);
  max-width: 68mm;
}

/* Wraps each photo tile with its optional name caption underneath — the
   grid item is this cell, not .preview-photo itself, so the caption sits
   below the square tile instead of inside its fixed aspect-ratio box. */
.preview-photo-cell {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.preview-photo-name {
  font-size: 11.5px;
  font-weight: 600;
  color: var(--muted);
  text-align: center;
  overflow-wrap: anywhere;
}

.photo-name-input {
  width: 100%;
  font-size: 13px;
  padding: 8px 10px;
}

.photo-card,
.preview-photo {
  aspect-ratio: 1 / 1;
  border-radius: var(--radius-md);
  border: 2px dashed var(--line-strong);
  background: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  color: var(--muted-2);
  font-size: 20px;
  font-weight: 300;
  transition: border-color 0.15s ease;
  position: relative;
  cursor: pointer;
}

.photo-card:hover { border-color: var(--brand-3); }

.photo-remove-btn {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: none;
  background: rgba(15, 39, 66, 0.72);
  color: #fff;
  font-size: 15px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 2;
}

.photo-remove-btn:hover {
  background: var(--danger);
}

.photo-card img,
.preview-photo img,
.image-stage img,
.preview-image-box img,
.preview-photo img {
  max-width: none;
}

.photo-card img,
.preview-photo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* ════════════════════════════════════════════════════
   JOB CARD PREVIEW SHEET
════════════════════════════════════════════════════ */
/* The wizard card around it is a normal responsive container, but the A4
   page itself must not shrink to fit inside it — that's what was making the
   preview look like a squashed little widget instead of a real page. This
   wrapper lets the page render at true size and simply scrolls (both axes)
   when the viewport is narrower than 210mm, instead of compressing it. */
.a4-preview-scroll {
  width: 100%;
  overflow: auto;
  background: var(--panel-soft);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 24px;
}

.a4-preview-center {
  width: max-content;
  margin: 0 auto;
}

.preview-sheet {
  /* Real A4 width, and a MINIMUM height (not a fixed height) — a fixed
     height combined with overflow:hidden below would silently clip any job
     whose content runs longer than one page, which is a real regression we
     hit and fixed before. Short content still reads as a full A4 page;
     long content simply grows taller instead of losing content. */
  width: 210mm;
  min-height: 297mm;
  background: #fff;
  border-radius: var(--radius-lg);
  border: 1.5px solid var(--pdf-divider);
  box-shadow: var(--shadow-sm);
}

.preview-header {
  display: grid;
  /* minmax(0, 1fr), not plain 1fr — a plain 1fr column's minimum width is
     its content's min-content size, so a long Job Card Name value forced
     this column wider than its fair share, overlapping the centered "JOB
     CARD" title instead of wrapping within its own column. */
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: center;
  padding: 20px 24px 18px;
  border-bottom: 2px solid var(--pdf-divider);
  background: #fff;
  /* .preview-sheet no longer clips via overflow:hidden (a fixed height +
     hidden overflow would silently cut off long content), so the header
     rounds its own top corners directly to keep the card's rounded look. */
  border-top-left-radius: calc(var(--radius-lg) - 2px);
  border-top-right-radius: calc(var(--radius-lg) - 2px);
}

.preview-brand {
  justify-self: start;
}

.preview-logo {
  display: block;
  height: 72px;
  width: auto;
}

.preview-brand-name {
  margin-top: 2px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
  text-align: center;
}

.preview-title {
  justify-self: center;
  font-size: 2.2rem;
  font-weight: 800;
  color: var(--ink);
  letter-spacing: -0.02em;
  line-height: 1;
  text-transform: uppercase;
  white-space: nowrap;
}

.preview-job {
  justify-self: end;
  text-align: right;
  min-width: 0;
  max-width: 100%;
}

.preview-job span {
  display: block;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.15em;
  color: var(--ink-2);
  margin-bottom: 4px;
}

.preview-job strong {
  display: block;
  font-family: "IBM Plex Mono", monospace;
  font-size: 1.4rem;
  font-weight: 600;
  color: var(--ink);
  letter-spacing: 0.01em;
  /* Extra breathing room below the job number before the priority pill —
     the wizard's own "Download PDF" button screenshots this exact on-screen
     element (see buildCombinedJobPdf in app.js), so its spacing is at the
     mercy of whatever font metrics/zoom/DPI the browser it's captured in
     happens to use; a tighter margin left less room for that variance to
     push the pill up against the number. */
  margin-bottom: 14px;
}

.preview-job strong.preview-job-name {
  font-family: inherit;
  font-size: 1rem;
  margin-bottom: 4px;
}

.priority-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  background: var(--danger-soft);
  color: var(--danger);
}

.priority-pill::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
}

.priority-pill.medium { background: var(--warning-soft); color: var(--warning); }
.priority-pill.low    { background: var(--success-soft); color: var(--success); }

/* A single-line strip (Party | Factory | Issued | Due) with thin vertical
   dividers between fields, instead of four separate boxes stacked 2-by-2 —
   the box grid used a full row of vertical space just for these 4 labels,
   which pushed a long Product Description further down the page and
   toward the multi-page pagination edge cases below. */
.preview-meta {
  display: flex;
  border-bottom: 1.5px solid var(--pdf-divider);
  padding: 0 24px;
}

/* Vertical padding lives on the columns (not on .preview-meta itself) so
   each column's border-left — a flex child stretches to the full height of
   its container by default — reaches all the way from .preview-header's
   bottom border down to .preview-meta's own bottom border, instead of
   stopping short and leaving a visible gap at the top and bottom of the
   divider line. */
.preview-meta > div {
  flex: 1;
  min-width: 0;
  padding: 12px 20px;
  border-left: 1.5px solid var(--pdf-divider);
}

.preview-meta > div:first-child {
  padding-left: 0;
  border-left: none;
}

.preview-meta span {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--ink-2);
  margin-bottom: 4px;
}

.preview-meta-icon {
  flex-shrink: 0;
}

.preview-meta strong {
  display: block;
  font-size: 1rem;
  font-weight: 700;
  color: var(--ink);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#previewIssued,
#previewDue {
  font-family: "IBM Plex Mono", monospace;
  font-weight: 600;
}

.preview-meta .due-text { color: var(--danger); }

.preview-main {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 240px;
  border-bottom: 1.5px solid var(--pdf-divider);
}

.preview-left { padding: 20px 22px; }

.preview-right {
  padding: 16px 18px;
  border-left: 1.5px solid var(--pdf-divider);
  background: var(--panel-soft);
}

.preview-block { margin-bottom: 20px; }

.preview-block h4 {
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--ink-2);
  margin-bottom: 10px;
}

/* Each size (plus Total/Average) gets its own equal-width bordered box,
   rather than one continuous colored table — matches the plain, boxed
   reference design and drops the same solid-color fill removed from the
   header above. */
.preview-size-boxes {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  gap: 6px;
}

.preview-size-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  min-width: 0;
  padding: 10px 4px;
  text-align: center;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: #fff;
}

.preview-size-box-label {
  font-size: max(8px, calc(10px * var(--size-scale, 1)));
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 100%;
}

.preview-size-box-value {
  font-family: "IBM Plex Mono", monospace;
  font-size: max(10px, calc(1.2rem * var(--size-scale, 1)));
  font-weight: 700;
  color: var(--ink);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 100%;
}

.preview-description {
  line-height: 1.75;
  font-size: 0.88rem;
  /* A long run of typed text with no spaces (or a URL/code-like string)
     doesn't have anywhere the browser's normal word-wrap would break it,
     so it overflowed straight through .preview-left's width into the
     Main Label image column next to it instead of wrapping. */
  overflow-wrap: anywhere;
}

.preview-description h3 {
  font-size: 1.1rem;
  font-weight: 800;
  color: var(--ink);
  margin-bottom: 6px;
  overflow-wrap: anywhere;
}

/* Cutting Report — Step 7's own standalone document with its own PDF
   download (not part of the job card preview/PDF), styled after the
   factory's physical cutting-report form (yellow background, heavy
   borders) so the on-screen preview matches the printed PDF exactly. */
.cutting-report-panel {
  background: #fff;
}

/* Locked to the real A4 ratio (595.28 : 841.89 pt) so the on-screen box is
   proportioned exactly like the exported page — the table then stretches
   via flex to fill that box top-to-bottom, so row height responds to
   however tall the page actually is instead of a fixed padding guess that
   leaves a dead zone below a short table.

   Fixed width, not max-width — same reasoning as .preview-sheet: shrinking
   to fit a narrow viewport (via max-width) turned this into an unreadably
   tiny miniature on a phone instead of a real, legible page. Wrapped in
   the same .a4-preview-scroll/.a4-preview-center pair the job card preview
   uses, so a narrow screen scrolls to see it at full size instead of
   squashing it. */
#cuttingReportPrintable {
  aspect-ratio: 595.28 / 841.89;
  width: 210mm;
  display: flex;
  flex-direction: column;
  background: #fff;
  padding: 16px;
  border-radius: var(--radius-sm);
}

.cutting-report-title-bar {
  flex-shrink: 0;
  border: 2px solid #1a1a1a;
  border-radius: var(--radius-sm);
  background: #fff;
  color: #1a1a1a;
  font-weight: 800;
  font-size: 1.1rem;
  letter-spacing: 0.03em;
  text-align: center;
  text-transform: uppercase;
  padding: 12px;
  margin-bottom: 14px;
}

.cutting-report-table-wrap {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  /* The table's columns need real minimum widths to stay readable, so on
     narrow screens it can end up wider than this wrapper — scroll
     horizontally to reach every column instead of clipping them
     permanently (overflow-y stays hidden purely to mask the rounded
     corners against the table underneath, matching .preview-header's
     corner-radius approach elsewhere). */
  overflow-x: auto;
  overflow-y: hidden;
  border-radius: var(--radius-sm);
  border: 2px solid #1a1a1a;
}

.cutting-report-table {
  width: 100%;
  height: 100%;
  table-layout: fixed;
  border-collapse: collapse;
  background: #fff;
  font-size: 0.82rem;
}

.cutting-report-table th,
.cutting-report-table td {
  border: 1.5px solid #1a1a1a;
  padding: 8px 10px;
  text-align: center;
  vertical-align: middle;
  color: #1a1a1a;
  white-space: nowrap;
  background: #fff;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cutting-report-table thead th {
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  font-size: 0.78rem;
  padding: 14px 8px;
  white-space: normal;
}

/* Each size column's header is two stacked cells — its name (a <th> in
   #cuttingReportHeadRow) and its ratio (a <td> in
   #cuttingReportHeadBottomRow right below it) — which need to read as one
   evenly-split box, matching the equal top/bottom split used for the
   Total/Average and size cells in the body. Without a matching explicit
   height they rendered unevenly: the name row inherited thead th's taller
   14px padding while the ratio row fell back to the generic 8px cell
   padding, so the two halves visibly didn't match. */
#cuttingReportHeadRow th:not([rowspan]),
#cuttingReportHeadBottomRow td {
  height: 26px;
  padding: 8px;
  font-size: 0.78rem;
}

/* Blank spacer row between the header and the first data row, with no
   vertical rulings — matches the physical form's own separation, which
   uses a border-less gap instead of an unbroken grid line straight through
   from header to body. */
.cutting-report-table tr.header-separator td {
  padding: 4px 0;
  border-left: none;
  border-right: none;
}

/* MTR/MPP/Fabric Name are hand-typed free text with no length limit — a
   long value (or a single unbroken word with no spaces to wrap on, e.g. a
   design code) needs to break mid-word and wrap onto a second line inside
   its own cell instead of overflowing past the column border into the size
   columns next to it. text-overflow:ellipsis (the base rule) would clip it
   instead, silently hiding real data. */
.cutting-report-table td:nth-child(2),
.cutting-report-table td:nth-child(3),
.cutting-report-table td:nth-child(4) {
  white-space: normal;
  overflow: visible;
  text-overflow: clip;
  overflow-wrap: anywhere;
  word-break: break-word;
  font-size: 0.76rem;
  line-height: 1.25;
}

.cutting-report-table tbody td.cutting-report-swatch {
  font-size: 0.72rem;
  font-weight: 400;
  /* Explicit Devanagari-covering font for this Hindi label — Manrope (the
     rest of the app's font) has no glyphs for this script at all, so this
     text was silently at the mercy of whatever fallback font happened to
     be installed on whatever machine rendered the page/PDF, which is not
     guaranteed to include Devanagari coverage on a bare server. */
  font-family: "Noto Sans Devanagari", var(--font);
  /* Was 0.45 opacity — legible for Latin text, but the thin strokes and
     conjunct shapes in this Devanagari instructional label read as
     blurry/smudged at that low a contrast against white. Darkened just
     enough to render crisply while still staying visually secondary to
     real entered data. */
  color: rgba(26, 26, 26, 0.7);
  white-space: normal;
  /* The physical form left-aligns this instructional label (it starts right
     at the cell's left edge) instead of centering it like the other
     columns. It's a hand-writing prompt, not real data, so it's styled to
     recede like placeholder text rather than compete with actual entries. */
  text-align: left;
  padding-left: 12px;
}

/* Each fabric row is two real <tr>s (top/bottom) with the Fabric Cut / MTR /
   Fabric Name / Total cells rowspan-ned across both — a blank top half for
   a hand-written layer/bundle count, and a bottom half showing the
   computed piece count once fabric data exists. Top and bottom now split
   the row exactly evenly (equal height AND equal padding); an earlier
   ~1:2 split read as visually inconsistent with the header's own
   size-name/ratio split directly above it, which is (and needs to stay)
   an even 50/50 box. */
.cutting-report-table tr.cutting-report-row-top td,
.cutting-report-table tr.cutting-report-row-bottom td {
  height: 30px;
  padding: 12px 10px;
}

.cutting-report-table tbody td:nth-child(2),
.cutting-report-table tbody td:nth-child(3) {
  font-weight: 700;
}

.cutting-report-table tfoot td {
  font-weight: 800;
  background: #f5f5f5;
  /* Chromium doesn't give tfoot rows a share of the table's stretched
     height the way it does tbody rows under height:100% — without an
     explicit padding boost the TOTAL row renders far shorter than every
     other row (measured ~32px vs ~106px+ for data rows). */
  padding: 26px 10px;
}

/* The form restates "TOTAL" in the final column's footer cell instead of a
   computed sum, faded relative to the main TOTAL label. */
.cutting-report-table td.cutting-report-total-echo {
  color: rgba(26, 26, 26, 0.45);
}

.preview-image-box {
  /* Stacking 4 of these (Main Label, Hang Tag, Main Label 2, Hang Tag 2)
     instead of the original 2. A flex-grow chain (sheet -> main -> right
     column -> each block -> image box) was tried to have them dynamically
     fill whatever blank space the full-page .preview-sheet min-height
     adds beyond the real content, but WeasyPrint's flex support doesn't
     reliably distribute space through that many nested levels — confirmed
     by isolating the exact chain in standalone test renders. A generous
     fixed height is a predictable middle ground: noticeably bigger than
     before (closing most of the gap under typical content) without
     depending on that unreliable distribution, and still comfortably
     leaves all 4 on one page even with a longer description. This only
     affects the read-only preview/PDF box (the Step 4 upload/crop stage
     is a separate, larger .image-stage), so it doesn't touch the actual
     cropping experience. */
  height: 145px;
  border-radius: var(--radius-sm);
  border: 1.5px dashed var(--line-strong);
  background: #fff;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 10px;
}

.preview-image-box img {
  display: none;
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #fff;
}

.preview-image-box img.has-image {
  display: block;
}

.image-box-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  color: var(--muted-2);
}

.image-box-placeholder small {
  font-size: 11px;
  font-weight: 600;
}

.preview-image-box:has(img.has-image) .image-box-placeholder {
  display: none;
}

.preview-photos {
  padding: 16px 22px 22px;
  margin-bottom: 0;
}

.preview-footer {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 22px 16px;
  border-top: 1.5px solid var(--pdf-divider);
  color: var(--muted-2);
  font-size: 12px;
  font-weight: 600;
  background: var(--panel-soft);
  /* .preview-sheet doesn't clip its children via overflow:hidden (a long
     description needs to be free to run past a fixed-height box instead of
     being cut off), so this being the LAST element on a sheet means its own
     square corners sit past where the sheet's rounded corner arcs in —
     visible as a small solid rectangle poking out past the curve. Matches
     .preview-header's identical fix for the opposite (top) corners. */
  border-bottom-left-radius: calc(var(--radius-lg) - 2px);
  border-bottom-right-radius: calc(var(--radius-lg) - 2px);
}

/* ════════════════════════════════════════════════════
   PACKING ENTRY (Packing User's own screen)
════════════════════════════════════════════════════ */
/* #packingTabs carries an inline display:flex (see index.html), which
   otherwise beats the browser's [hidden]{display:none} default on
   specificity alone — same bug already hit once this session with
   .priority-filter-popover. */
#packingTabs[hidden] {
  display: none;
}

.packing-box-toggle {
  display: flex;
  gap: 10px;
  margin: 14px 0 16px;
}

.pill-toggle-btn {
  padding: 10px 20px;
  border-radius: 999px;
  border: 1.5px solid var(--line-strong);
  background: #fff;
  color: var(--brand-2);
  font-weight: 700;
  font-size: 0.9rem;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.pill-toggle-btn.active {
  background: var(--brand-2);
  border-color: var(--brand-2);
  color: #fff;
}

#packingSearchInput {
  width: 100%;
  padding: 13px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line-strong);
  font-size: 0.95rem;
  background: #fff;
}

.packing-search-combo {
  position: relative;
}

/* Plain in-flow list. #cuttingAddSearchResults on the Add Cutting Details
   screen reuses this class for exactly that, so the dropdown treatment
   below is scoped to the packing combo rather than applied to the bare
   class — making this absolute took the cutting list out of flow and
   positioned it against an unrelated ancestor, so that search rendered its
   matches nowhere visible. */
.packing-search-results {
  margin-top: 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* Floats over what follows instead of displacing it — the Sample/Normal
   toggle and the entry form below no longer jump down and back up as
   results arrive and clear. Mirrors .packing-fabric-combo-list, the
   fabric/design dropdown already on this screen. */
.packing-search-combo .packing-search-results {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  z-index: 30;
  margin-top: 0;
  max-height: 320px;
  overflow-y: auto;
  padding: 6px;
  gap: 6px;
  background: #fff;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-md);
}

/* [hidden] ties with the display:flex above on specificity, and the author
   rule would otherwise win — the same trap this file has hit before. */
.packing-search-combo .packing-search-results[hidden] {
  display: none;
}

.packing-search-result-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: #fff;
  cursor: pointer;
  text-align: left;
  width: 100%;
  font: inherit;
  color: inherit;
}

.packing-search-result-item:hover {
  border-color: var(--brand-3);
  background: var(--brand-soft);
}

.packing-search-result-item strong {
  display: block;
  color: var(--ink);
}

.packing-search-result-item span {
  color: var(--ink-2);
  font-size: 0.85rem;
}

.packing-search-result-item-right {
  text-align: right;
}

.packing-search-empty {
  color: var(--ink-2);
  font-size: 0.9rem;
  padding: 10px 2px;
}

.packing-entry-form {
  margin-top: 18px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

.packing-entry-form-head {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 10px;
}

.packing-grand-total {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--brand-2);
}

.packing-entry-card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 16px 18px;
  margin-bottom: 14px;
  box-shadow: var(--shadow-sm);
}

.packing-entry-card-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  flex-wrap: wrap;
  gap: 12px;
  padding-bottom: 14px;
  margin-bottom: 14px;
  border-bottom: 1px solid var(--line);
}

/* The order number this card belongs to, sitting directly above the
   fabric/design search. Enlarged and darkened per explicit request — at
   0.75rem in the muted ink it read as a faint caption above the input,
   easy to lose track of when packing box after box. */
.packing-entry-card-order {
  display: block;
  font-size: 0.95rem;
  font-weight: 800;
  color: var(--ink);
  letter-spacing: 0.02em;
  margin-bottom: 8px;
}

/* The order banner at the very top of the Packing Entry screen (see
   openPackingEntryForm/closePackingEntryForm) — a highlighted pill rather
   than plain text, the same visual language the Order Report's own
   "ORDER NO. : ..." heading uses, so it reads as important at a glance
   instead of blending into the page-header's other muted captions. */
.packing-entry-order-banner {
  display: inline-block;
  margin: 6px 0 0;
  padding: 4px 12px;
  border-radius: 999px;
  background: var(--brand-soft);
  color: var(--brand-2);
  font-size: 0.85rem;
  font-weight: 800;
  letter-spacing: 0.02em;
}

.packing-fabric-select {
  padding: 9px 12px;
  border-radius: var(--radius-xs);
  border: 1.5px solid var(--ink);
  font-weight: 700;
  font-size: 0.9rem;
  min-width: 220px;
  width: 100%;
  background: #fff;
}

/* Searchable fabric/design combobox (text input + its own filtered
   dropdown) — a plain <select> had no way to search once an order has
   more than a handful of fabrics. */
.packing-fabric-combo {
  position: relative;
  display: inline-block;
  min-width: 220px;
}

.packing-fabric-combo-list {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  max-height: 260px;
  overflow-y: auto;
  background: #fff;
  border: 1.5px solid var(--ink);
  border-radius: var(--radius-xs);
  box-shadow: var(--shadow-md);
  z-index: 20;
}

.packing-fabric-combo-option {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 9px 12px;
  border: none;
  background: none;
  text-align: left;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--ink);
  cursor: pointer;
}

.packing-fabric-combo-option:hover {
  background: var(--brand-soft);
}

.packing-fabric-combo-option.is-used {
  color: var(--muted-2);
  font-style: italic;
}

.packing-fabric-combo-used-tag {
  flex: 0 0 auto;
  font-size: 0.68rem;
  font-weight: 700;
  color: var(--danger);
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

.packing-fabric-combo-empty {
  padding: 10px 12px;
  margin: 0;
  color: var(--muted);
  font-size: 0.85rem;
}

.packing-entry-card-actions {
  display: flex;
  gap: 8px;
}

.packing-size-table-title {
  text-align: center;
  display: block;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--ink-2);
  letter-spacing: 0.05em;
  margin-bottom: 10px;
}

.packing-size-row {
  display: grid;
  grid-template-columns: 90px 1fr 90px;
  align-items: center;
  gap: 12px;
}

/* Packing Entry's own variant — the +Add/Remove buttons used to sit up in
   the card header, disconnected from the Total they actually affect (and
   leaving the space to Total's own left empty on a phone, where the
   header's buttons live in a completely different part of the stacked
   layout). Moved into the same row as Total, immediately to its left,
   with the last column widened from a bare 90px (just enough for the
   number) to fit both. Cutting Details reuses this same .packing-size-row
   markup for its own read-only fabric cards and "Total Cut Quantity"
   summary — those never add the has-actions modifier, so they keep the
   original 90px column untouched. */
.packing-size-row.has-actions {
  grid-template-columns: 90px 1fr auto;
}

.packing-card-total-wrap {
  display: flex;
  align-items: center;
  gap: 16px;
  justify-content: flex-end;
}

.packing-size-row-label {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--ink-2);
  text-transform: uppercase;
}


.packing-size-inputs {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(70px, 1fr));
  gap: 10px;
}

.packing-size-field {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.packing-size-field span {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--ink-2);
  text-transform: uppercase;
}

.packing-size-field input {
  width: 100%;
  padding: 10px 8px;
  border-radius: var(--radius-xs);
  border: 1px solid var(--line-strong);
  font-size: 0.95rem;
  text-align: center;
}

/* A quantity above what was cut for that size — flagged as it's typed by
   checkPackingAgainstCutting, with the reason spelled out in
   .packing-size-error below the card. */
.packing-size-field input.is-over-cut {
  border-color: var(--danger, #dc2626);
  background: #fef2f2;
  color: var(--danger, #dc2626);
  font-weight: 700;
}

.packing-size-error {
  margin: 10px 0 0;
  padding: 9px 12px;
  border-radius: var(--radius-xs);
  border: 1px solid var(--danger, #dc2626);
  background: #fef2f2;
  color: var(--danger, #dc2626);
  font-size: 0.85rem;
  font-weight: 600;
  line-height: 1.45;
}

.packing-card-total {
  text-align: center;
}

.packing-card-total span {
  display: block;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--ink-2);
  text-transform: uppercase;
  margin-bottom: 6px;
}

.packing-card-total strong {
  font-size: 1.1rem;
  color: var(--brand-2);
}

/* ── Label Print View — every label is exactly 4in x 6in, on screen and
   when printed. ── */
.packing-label-pages {
  display: flex;
  flex-wrap: wrap;
  gap: 24px;
}

.packing-label {
  width: 4in;
  height: 6in;
  flex: 0 0 auto;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 0.22in;
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  font-size: 0.84rem;
}

.packing-label-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
  padding-bottom: 10px;
  margin-bottom: 12px;
  border-bottom: 1.5px solid var(--ink);
}

/* flex:1/min-width:0 lets this shrink instead of pushing .packing-label-auto-no
   out of the row; the line-clamp caps a long party name to a fixed 2-line
   height (ellipsis beyond that) so it can never grow the header taller than
   budgeted and shove the table below past .packing-label's own
   overflow:hidden 4in x 6in box — that push-down was clipping the last row's
   Total cell off the bottom of the label, reported live as the Total "going
   outside the label". */
.packing-label-party {
  flex: 1 1 auto;
  min-width: 0;
  /* Party Name and Box No. are one pair of header fields, so both read
     at ONE size — label and value alike, on both sides. Weight is what
     separates the value from its label, not size. */
  font-size: 0.8rem;
  line-height: 1.25;
  font-weight: 800;
  color: var(--ink);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  word-break: break-word;
}

/* Box No. sits here now — the label's own identifier, and what a packer
   reads first. The factory number it replaced moved down into the meta
   row, beside Order No. and Total Qty. */
.packing-label-box-no {
  flex: 0 0 auto;
  white-space: nowrap;
  font-size: 0.8rem;
  font-weight: 700;
  /* Black like the rest of the header — the blue now belongs to the
     factory number in the meta row, which is the one value meant to be
     picked out at a glance. */
  color: var(--ink);
}

/* The bare factory number: no caption, and the only coloured value on
   the label. */
.packing-label-factory-no {
  font-weight: 800;
  color: var(--brand-3);
}

/* Totals row under the fabric rows: same weight as a header so it reads
   as a summary line rather than one more fabric. */
.packing-label-total-row td {
  font-weight: 800;
  border-top: 1.5px solid var(--ink);
  background: var(--panel-soft);
}

.packing-label-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 18px;
  margin-bottom: 12px;
  color: var(--ink-2);
  font-size: 0.78rem;
}

.packing-label-meta strong {
  color: var(--ink);
  font-size: 0.85rem;
}

.packing-label-table {
  width: 100%;
  border-collapse: collapse;
  /* Needed for the <colgroup> percentage widths (see
     buildPackingLabelPagesHtml) to actually hold — without this, an auto-
     layout table can grow wider than its 100% parent whenever it has
     enough columns/content to demand it, and since .packing-label clips
     overflow (a fixed 4in x 6in label), extra size columns beyond
     whatever fit were silently cut off entirely instead of just
     rendering narrower. */
  table-layout: fixed;
  /* The real culprit, found by rendering this in an actual browser and
     measuring the table's computed width: the global `table { min-width:
     700px; }` rule below (meant for the wide admin data tables, which sit
     in their own horizontally-scrollable .table-shell) applies to EVERY
     <table> with no scoping, this one included — min-width always wins
     over width/table-layout, so it silently forced this table to 700px
     inside a 384px-wide (4in) label no matter what width/colgroup math was
     tried, and .packing-label's overflow:hidden clipped everything past
     that — exactly the "only the first 2 size columns show" bug reported
     live, confirmed by measuring an actual rendered table width of 700px
     against the label's own 384px. */
  min-width: 0;
}

.packing-label-table th,
.packing-label-table td {
  border: 1px solid var(--line);
  padding: 7px 7px;
  overflow-wrap: break-word;
  /* The global `th { white-space: nowrap }` rule above (meant for the wide
     admin data tables) applies to every <th> with no scoping — it has
     lower specificity than this selector, but neither rule here declared
     white-space at all, so nothing was actually overriding it. That's
     what silently defeated overflow-wrap/word-break below on a long,
     unbreakable size name like a literal "XXXL4XL": nowrap forces one
     line no matter what, so it just visually overflowed into the next
     column instead of wrapping, reported live as it looking merged with
     its neighbor. */
  white-space: normal;
  text-align: center;
  font-size: 0.76rem;
}

.packing-label-table th {
  background: var(--brand-soft);
  color: var(--ink-2);
  font-weight: 700;
  text-transform: uppercase;
  font-size: 0.66rem;
}

/* A job with 6+ distinct sizes (or one long literal size name like
   "XXXL4XL") gets a smaller share of the row per size column at the
   normal padding/font-size — tighter padding and a smaller header font
   hand back just enough room for a long size name to wrap onto 2 clean
   lines instead of looking squeezed against its neighbors. */
.packing-label-table.has-many-sizes th,
.packing-label-table.has-many-sizes td {
  padding: 4px 2px;
}

.packing-label-table.has-many-sizes th {
  font-size: 0.5rem;
  /* overflow-wrap:break-word (set on every th/td above) only breaks
     mid-word as a last resort at normal break opportunities — a size
     name with no spaces/hyphens at all (a literal "XXXL4XL" typed as one
     size) never got one of those and just visually overflowed into the
     next column instead of wrapping, reported live as it looking merged
     with its neighbor. break-all forces a hard break wherever needed. */
  word-break: break-all;
}

.packing-label-table td:first-child,
.packing-label-table th:first-child {
  text-align: left;
  font-weight: 700;
  color: var(--ink);
}

.packing-label-table th:last-child,
.packing-label-table td.packing-label-row-total {
  border-left: 1.5px solid var(--ink);
}

.packing-label-table td.packing-label-row-total {
  font-weight: 800;
  color: var(--brand-2);
  background: var(--brand-soft);
  white-space: nowrap;
}

.packing-label-group-head td {
  background: var(--brand-soft);
}

/* ── Packaging Report (Packing User tab + admin nav item) — design only
   for now, rendered from a hardcoded sample in app.js until the real
   requirements/logic doc is provided. ── */
.packaging-report-card {
  background: #fff;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--line);
  padding: 22px 24px;
  margin-bottom: 20px;
}

/* Icon-only Edit/Reprint Label/Remove buttons — replaced 3 stacked text
   buttons per box row, reported live as wanting a more compact, "proper"
   fit in the Actions cell. Verify Pending/Verified (rendered as a sibling
   of this row, not inside it) stays a labeled button/tag since its own
   text IS the state it shows. */
.packaging-icon-actions {
  display: flex;
  gap: 6px;
  justify-content: center;
}

.packaging-icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: #fff;
  color: var(--brand-2);
  cursor: pointer;
  padding: 0;
}

.packaging-icon-btn:hover {
  background: var(--brand-soft);
}

.packaging-icon-btn-danger {
  color: var(--danger);
  border-color: rgba(201, 64, 64, 0.3);
}

.packaging-icon-btn-danger:hover {
  background: var(--danger-soft);
}

.packaging-report-table-wrap {
  overflow-x: auto;
}

/* A real bordered/grid table — every cell boxed, not just a bottom rule
   per row — reported live as wanting a more clearly ruled-off table now
   that it holds this many columns (Factory Box No./Order Box No./Fabric-
   DNFN/several sizes/Total/Actions) at once. border-collapse:collapse
   keeps adjoining cells' borders from doubling up into a visibly thicker
   line where they touch. */
.packaging-report-table {
  width: 100%;
  border-collapse: collapse;
  border: 1px solid var(--line);
}

.packaging-report-table th,
.packaging-report-table td {
  padding: 12px 14px;
  text-align: center;
  font-size: 0.9rem;
  border: 1px solid var(--line);
}

.packaging-report-table thead th {
  background: #f4f8fd;
  color: var(--ink-2);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  text-align: left;
}

/* Box-wise summary table (one row per box — Order No./Party Name/Factory
   Box No./Order Box No./Box Type/QTY/Actions — QTY itself is the toggle
   that reveals that box's own fabric/DNFN detail table below it, see
   .packaging-qty-toggle). Columns 1 and 2 (Order No./Party Name) read as
   left-aligned text like the old table's own leading columns did,
   everything else stays centered from the shared .packaging-report-table
   base above. */
.packaging-box-summary-table th:nth-child(1),
.packaging-box-summary-table th:nth-child(2),
.packaging-box-summary-table td:nth-child(1),
.packaging-box-summary-table td:nth-child(2) {
  text-align: left;
}

/* Every header past Order No./Party Name needs its own explicit center —
   .packaging-report-table's own thead th rule left-aligns ALL headers by
   default (needed for Order No./Party Name above), and a stale rule that
   used to re-center columns 4+ for the OLD 3-leading-column table (Factory
   Box No./Order Box No./Fabric-DNFN) was actively left-aligning THIS
   table's column 3 (Factory Box No.) instead — its own badge+factory-name
   sat flush left in its cell instead of centered under the header,
   reported live. */
.packaging-box-summary-table th:nth-child(n+3) {
  text-align: center;
}

/* QTY itself is the desktop toggle now (a leading chevron-only column was
   removed per explicit request) — the quantity number with a small arrow
   right next to it reads as "click to break this quantity down", which is
   exactly what it does. */
.packaging-qty-toggle {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  border: none;
  background: none;
  padding: 4px 8px;
  border-radius: var(--radius-xs);
  cursor: pointer;
  color: var(--brand-2);
}

.packaging-qty-toggle:hover {
  background: var(--brand-soft);
}

.packaging-qty-toggle strong {
  font-size: 0.95rem;
  color: var(--ink);
}

.packaging-qty-toggle svg {
  transition: transform 0.18s ease;
}

.packaging-qty-toggle.is-expanded svg {
  transform: rotate(180deg);
}

.packaging-box-detail-row td {
  background: #fafcff;
  padding: 14px !important;
}

/* The fabric/DNFN + per-size breakdown a box's own chevron reveals —
   same shape as the old rowspan table's inner rows, just self-contained
   per box now (no Factory/Order Box No. columns to span, those already
   live on the summary row above it). */
.packaging-report-detail-table {
  width: 100%;
  border-collapse: collapse;
  border: 1px solid var(--line);
}

.packaging-report-detail-table th,
.packaging-report-detail-table td {
  padding: 9px 12px;
  text-align: center;
  font-size: 0.85rem;
  border: 1px solid var(--line);
}

.packaging-report-detail-table th {
  background: #f4f8fd;
  color: var(--ink-2);
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.packaging-report-detail-table th:first-child,
.packaging-report-detail-table td:first-child {
  text-align: left;
}

/* A pill rather than a fixed 30px circle: the factory box number used to
   be a single digit, but now carries the party prefix ("TP-07"), which a
   circle wrapped onto two cramped lines. */
.packaging-report-box-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 30px;
  height: 26px;
  padding: 0 10px;
  border-radius: 999px;
  background: var(--brand-2);
  color: #fff;
  font-weight: 800;
  font-size: 0.8rem;
  white-space: nowrap;
}

.packaging-report-box-total-row td {
  background: var(--brand-soft);
  color: var(--brand-2);
  font-weight: 800;
}

.packaging-report-box-factory {
  margin-top: 4px;
  font-size: 0.68rem;
  font-weight: 700;
  color: var(--ink-2);
  text-align: center;
}

.packaging-report-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
  min-width: 90px;
}

/* Smaller than a normal .mini-btn — reported live as reading oversized
   stacked four-deep in this one column (Edit/Reprint Label/Remove/Verify
   Pending), unlike everywhere else .mini-btn is used one or two at a
   time. */
.packaging-report-actions .mini-btn {
  padding: 5px 10px;
  font-size: 0.72rem;
}

/* A confirmed/positive state ("Verified" — this order's contents have
   been checked and locked from further edits), not a warning, so this
   uses the app's success palette rather than the danger one it had back
   when this same tag read "Locked". */
.packaging-report-locked-tag {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--success-soft);
  color: var(--success);
  font-size: 0.72rem;
  font-weight: 700;
  text-align: center;
}

/* The interactive "Verify Pending" / "Verified" button (shown to whoever
   can actually flip it — everyone else, if the box is locked, gets the
   read-only tag above instead). Pending state borrows .mini-btn's own
   default look; :checked-equivalent Verified state switches to the same
   success palette as the read-only tag, so both read consistently as
   "this box is verified" regardless of which one a given viewer sees. */
.packaging-verify-btn.is-verified {
  background: var(--success-soft);
  border-color: var(--success);
  color: var(--success);
}

/* Mobile-only compact per-box cards — hidden on desktop by default, where
   .packaging-report-table-wrap's rowspan table is shown instead. Swapped
   the other way around at mobile width below: that wide table would need
   horizontal scrolling per box on a phone, so this shows the exact same
   data (Factory Box No., Order Box No., every fabric/DNFN line's own
   per-size breakdown, each box's own subtotal, and the order's overall
   total) restructured to read top-to-bottom instead of left-to-right —
   reported live as an earlier version of this card collapsing all of
   that down to a single QTY number, losing real data the desktop table
   still had. */
.packaging-report-mobile-cards {
  display: none;
}

@media (max-width: 768px) {
  .packaging-report-table-wrap {
    display: none;
  }

  .packaging-report-mobile-cards {
    display: block;
  }

  /* .packaging-report-card sits inside #packagingListView, which is
     itself a .screen-card — its own bg/border/radius/shadow (see
     styles.css) already gives the whole Packaging List one outer card.
     On desktop .packaging-report-card's matching chrome around the table
     reads as a second, intentional tier; on mobile it became a THIRD
     nested box on top of that (.screen-card -> .packaging-report-card ->
     each .packaging-report-mobile-card), reported live as "box inside box
     inside box" — three stacked borders/shadows/paddings squeezing the
     actual data smaller each layer in. Stripping this middle layer's own
     chrome leaves exactly two: the outer .screen-card ("front") and each
     box's own .packaging-report-mobile-card ("inner", where the data
     actually is).
  */
  .packaging-report-card {
    padding: 0;
    border: none;
    border-radius: 0;
    box-shadow: none;
    background: transparent;
  }

  .packaging-report-mobile-card {
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: var(--radius-md);
    background: #fff;
  }

  .packaging-report-mobile-card + .packaging-report-mobile-card {
    margin-top: 12px;
  }

  .packaging-report-mobile-ids {
    display: flex;
    justify-content: space-between;
    gap: 12px;
  }

  /* Each mobile box card now stacks 3 of these (Order/Party, Factory Box
     No./Order Box No., Box Type/QTY) instead of the original single row —
     spacing between them so they read as separate fields, not run
     together. */
  .packaging-report-mobile-ids + .packaging-report-mobile-ids {
    margin-top: 8px;
  }

  .packaging-report-mobile-ids > div {
    display: flex;
    flex-direction: column;
    gap: 2px;
  }

  /* :not(:first-child) matters. These rows normally hold a PAIR - one
     field left, one right - but the Verify Status row holds a single
     field, which is then both first and last child and was being
     right-aligned on its own. Its label sat pushed inwards while every
     other left-hand label was flush with the card's edge. */
  .packaging-report-mobile-ids > div:last-child:not(:first-child) {
    text-align: right;
  }

  .packaging-report-mobile-ids span {
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--muted);
  }

  .packaging-report-mobile-ids strong {
    font-size: 0.95rem;
    color: var(--ink);
  }

  /* Order No./Party Name is the one field pair long enough to actually
     wrap on a phone (a long party name, or an order number with a
     trailing suffix) — reported live as reading oversized once it wraps
     to two lines. A smaller size + break-word keeps a long value from
     dominating the card instead of sitting flush with the rest of its
     row. */
  .packaging-report-mobile-card > .packaging-report-mobile-ids:first-child strong {
    font-size: 0.82rem;
    line-height: 1.3;
    overflow-wrap: anywhere;
  }

  .packaging-report-mobile-factory {
    margin-top: 4px;
    font-size: 0.78rem;
    color: var(--muted);
  }

  /* Edit/Reprint/Remove icons + Verify Pending in one row — reported live
     as the icons sitting on their own row with empty space beside them
     while Verify Pending dropped to a second row underneath, instead of
     all four controls sitting inline the way this row is meant to read.
     nowrap plus shrinking each control below (icon buttons + the verify
     button/tag) is what actually keeps all of them on one line even on a
     narrow phone — flex-wrap alone just wrapped the row once the two
     pieces (icons block + verify button) genuinely didn't fit at their
     full desktop size. */
  .packaging-report-mobile-actions {
    display: flex;
    flex-wrap: nowrap;
    align-items: center;
    gap: 6px;
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid var(--line);
  }

  .packaging-report-mobile-actions .packaging-icon-actions {
    flex: 0 0 auto;
    gap: 5px;
  }

  .packaging-report-mobile-actions .packaging-icon-btn {
    width: 26px;
    height: 26px;
  }

  .packaging-report-mobile-actions .packaging-verify-btn,
  .packaging-report-mobile-actions .packaging-report-locked-tag {
    flex: 0 1 auto;
    padding: 5px 8px;
    font-size: 0.68rem;
    white-space: nowrap;
    min-width: 0;
  }

  /* Mobile's QTY toggle reuses .packaging-qty-toggle as-is (same size as
     desktop reads fine at this width) — just right-aligned like the rest
     of this row's second column, and given a little top margin since it
     no longer replaces a separate full-width button below. */
  .packaging-qty-toggle-mobile {
    margin-top: 2px;
  }
}

/* 10-rows-per-page controls under the flat, ungrouped box list (reported
   live as wanting "page 1, 2, 3" instead of one long scroll of every box
   at once). Sits inside .packaging-report-card, below both the desktop
   table and the mobile cards, so one set of controls serves whichever one
   is visible at the current width. */
.packaging-pagination {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.packaging-pagination-info {
  font-size: 0.78rem;
  color: var(--muted);
}

.packaging-pagination-pages {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.packaging-page-btn {
  min-width: 34px;
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: #fff;
  color: var(--ink-2);
  font-size: 0.8rem;
  font-weight: 700;
  cursor: pointer;
}

.packaging-page-btn:hover:not(:disabled) {
  border-color: var(--brand-2);
  color: var(--brand-2);
}

.packaging-page-btn.is-active {
  background: var(--brand-2);
  border-color: var(--brand-2);
  color: #fff;
  cursor: default;
}

.packaging-page-btn:disabled:not(.is-active) {
  opacity: 0.45;
  cursor: not-allowed;
}

/* Packaging List's "Don't Edit" checkbox — a plain [title] attribute gives
   a native browser tooltip, but the reference design shows a specific
   dark speech-bubble style. This used to be a pure-CSS ::after positioned
   relative to .dont-edit-tooltip-wrap, but stayed visibly cut off in
   practice even after .table-shell's own overflow was fixed — see
   wireUpBodyTooltips in app.js, which replaced it with a JS-positioned,
   body-appended tooltip (.body-tooltip below) immune to any ancestor's
   overflow/clipping. This wrap now only needs to lay out its checkbox. */
.dont-edit-tooltip-wrap {
  display: inline-flex;
}

.body-tooltip {
  display: none;
  position: fixed;
  width: max-content;
  max-width: 240px;
  padding: 8px 12px;
  border-radius: var(--radius-xs);
  background: var(--ink);
  color: #fff;
  font-size: 0.78rem;
  font-weight: 600;
  line-height: 1.35;
  text-align: left;
  box-shadow: var(--shadow-md);
  z-index: 1000;
  pointer-events: none;
}

/* ════════════════════════════════════════════════════
   CUTTING ENTRY (Cutting User's own screen)
════════════════════════════════════════════════════ */
.cutting-shell {
  display: flex;
  align-items: flex-start;
  gap: 20px;
}

.cutting-sidebar {
  width: 220px;
  flex-shrink: 0;
  border-radius: var(--radius-xl);
  background: #fff;
  border: 1px solid var(--line);
  box-shadow: var(--shadow-md);
  padding: 10px;
}

.cutting-sidebar .admin-nav-btn {
  cursor: default;
}

/* getsAdminShell() now gives every Cutting/Packing User the real sidebar
   too (their own Permission Group can grant real admin sections
   alongside their module) — this mini lookalike sidebar would just be a
   second, competing one in that case, so it only renders on the rare
   fallback where body.is-admin isn't set at all. */
body.is-admin .cutting-sidebar {
  display: none;
}

.cutting-main {
  flex: 1;
  min-width: 0;
}

.cutting-fabric-card-design {
  display: block;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--brand-3);
  margin-bottom: 2px;
}

.cutting-fabric-card-name {
  display: block;
  font-size: 1rem;
  font-weight: 800;
  color: var(--ink);
}

.cutting-total-card {
  background: var(--brand-soft);
  border-color: var(--brand-3);
}

@media (max-width: 768px) {
  /* .cutting-shell's base align-items:flex-start is meant for the desktop
     ROW layout (sidebar/main just aligned to the top, each free to be a
     different height) — but flex-direction:column below flips which axis
     align-items controls to the HORIZONTAL one, so flex-start then shrinks
     .cutting-main to its own content width and left-aligns it instead of
     stretching it across the row. .cutting-main's flex:1 (main-axis sizing)
     no longer fills width once the main axis is vertical, so nothing else
     was filling that gap either — the result was a large dead strip of
     empty page down the right side of every phone screen, reported live.
     Restoring stretch here makes both children (.cutting-sidebar already
     forces width:100% itself above; .cutting-main didn't have an
     equivalent) fill the full row width again. */
  .cutting-shell {
    flex-direction: column;
    align-items: stretch;
  }
  .cutting-sidebar {
    width: 100%;
  }

  /* Cutting Details' title ("Cutting Details — <job no.>") is the one
     .page-header h2 in the app with real dynamic content after the dash —
     every other screen's heading is a short static label that never needed
     shrinking. At the default 1.6rem it wrapped across 3-4 lines on a
     phone, reported live as pushing the "Back to Job Cards" button and the
     whole card list awkwardly far down. Scoped to this one screen so no
     other .page-header on mobile changes size. */
  #cuttingDetailsScreen .page-header h2 {
    font-size: 1.05rem;
  }

  /* .packing-size-row's desktop grid (90px label | flexible inputs | 90px
     total) reserves 180px of fixed columns before the size-input grid gets
     anything — on a phone that left so little middle width that
     .packing-size-inputs' own auto-fit(minmax(70px,...)) had room for only
     one column, stacking every size input full-width and making each
     fabric card very tall (reported live on the Cutting Details screen;
     Packing Entry uses this same row markup so gets the same fix). Restack
     to label, then the size grid (now free to actually fit 2-3 columns
     across), then the total — instead of squeezing all three side by
     side. */
  .packing-size-row {
    grid-template-columns: 1fr;
    row-gap: 10px;
  }

  /* .has-actions's own desktop-only 3-column grid (90px 1fr auto) has
     higher specificity (two classes) than the plain .packing-size-row
     rule right above — without repeating it here, that single-column
     collapse silently lost to .has-actions even inside this same media
     query, squeezing +Add/Remove into the size-inputs column instead of
     stacking cleanly below them. */
  .packing-size-row.has-actions {
    grid-template-columns: 1fr;
  }

  .packing-size-row-label {
    text-align: left;
  }

  /* Cutting Details' own fabric cards render this label empty (the fabric
     name is already the card's title just above) rather than omitting it,
     so every other usage sharing this same row markup (Packing Entry's
     "Quantity", the totals row's "All DNFN") keeps working unchanged. Safe
     to collapse ONLY here, inside this same rule block that just switched
     .packing-size-row to a single stacked column above — desktop's grid
     (90px label | 1fr inputs | 90px total) still needs this element
     present as a real (if blank) grid item to keep the inputs/total cells
     in their own tracks; display:none on desktop would instead shift the
     inputs into the label's 90px column and the total into the inputs'
     wide one, breaking the whole row (confirmed live). On mobile, where
     the row is already one column, an empty-but-present label instead
     just claimed a stacked row's worth of line-height plus row-gap for
     nothing: dead space between the card's title divider and its actual
     S/M/L/XL fields. :empty only matches when there's truly no text, so
     this can't hide a label that actually says something either way. */
  .packing-size-row-label:empty {
    display: none;
  }

  /* auto-fit (not auto-fill) so existing boxes stretch to fill the row
     instead of leaving dead space when there are fewer than fit — with the
     smaller 46px floor below (was 64px) and the field's own smaller mobile
     font/padding just below, up to ~6 sizes now sit in one inline row on a
     ~360-390px phone instead of 4 fitting and a 5th/6th wrapping onto an
     awkward lone row by itself (reported live); any size beyond that wraps
     as a normal extra row. */
  .packing-size-inputs {
    grid-template-columns: repeat(auto-fit, minmax(46px, 1fr));
    gap: 6px;
  }

  .packing-size-field span {
    font-size: 0.68rem;
  }

  .packing-size-field input {
    padding: 6px 2px;
    font-size: 0.8rem;
    /* The padding above alone leaves each box ~27px tall — comfortably
       under the ~44px touch target every other control on this page gets,
       and the smallest, fussiest-to-tap thing on the whole screen since
       these sit in the narrowest columns too. Height is independent of
       the column-width tuning above (auto-fit still fits the same ~6
       across), so this only makes each box easier to tap, not wider. */
    min-height: 42px;
  }

  /* Fabric cards (test1, test2, ...) used to sit only 14px apart — the
     same gap as everywhere else on desktop, but on a phone, stacked
     one-per-row with nothing beside them for contrast, they read as one
     long unbroken column rather than distinct cards. A bit more air
     between them (and a touch more internal padding) is the difference
     between "list of cards" and "wall of boxes" at this width. */
  .packing-entry-card {
    padding: 14px;
    margin-bottom: 12px;
  }

  /* +Add/Remove become small icon buttons here, matching the same compact
     icon treatment already used for Edit/Reprint/Remove on the Packaging
     List (.packaging-icon-btn) — reported live as wanting these smaller
     and "proper" instead of full pill buttons crowding this row next to
     Total. Markup/JS are unchanged (still real .secondary-btn elements
     with their original accessible text/aria-label) — this is a pure
     visual reskin: the text is visually hidden (font-size:0) and a small
     SVG icon takes its place; screen readers still read the button's
     real accessible name regardless of its visual font-size. */
  .packing-entry-card-actions {
    gap: 6px;
  }

  .packing-entry-card-actions .secondary-btn {
    width: 30px;
    height: 30px;
    padding: 0;
    border-radius: var(--radius-sm);
    font-size: 0;
    background-repeat: no-repeat;
    background-position: center;
    background-size: 15px;
  }

  .packing-entry-card-actions [data-packing-add] {
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%231557a0' stroke-width='2.2' stroke-linecap='round'%3e%3cpath d='M12 5v14M5 12h14'/%3e%3c/svg%3e");
  }

  .packing-entry-card-actions [data-packing-remove] {
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23c94040' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='3 6 5 6 21 6'/%3e%3cpath d='M19 6l-1 14a2 2 0 0 1-2 2H8a2 2 0 0 1-2-2L5 6'/%3e%3cpath d='M10 11v6'/%3e%3cpath d='M14 11v6'/%3e%3cpath d='M9 6V4a1 1 0 0 1 1-1h4a1 1 0 0 1 1 1v2'/%3e%3c/svg%3e");
  }

  .packing-entry-card-head {
    padding-bottom: 10px;
    margin-bottom: 10px;
  }

  /* A top divider here mirrors .packing-entry-card-head's own bottom
     divider under the title — title / rule / sizes / rule / total reads
     as one consistent, evenly-punctuated structure instead of the total
     just trailing off after the inputs with only a margin to imply it's a
     new section. Grouped and pushed to the right (flex-end, small gap)
     rather than the space-between/label-left-value-right split used
     elsewhere — "Total" reads as one compact label+value unit that lines
     up under the size values above it, instead of the word "Total" alone
     floating at the far left with nothing near it, reported live as
     looking unbalanced once this row was the narrowest line in the card. */
  .packing-card-total {
    display: flex;
    flex-wrap: nowrap;
    align-items: baseline;
    justify-content: flex-end;
    gap: 8px;
    text-align: right;
    padding-top: 10px;
    border-top: 1px solid var(--line);
  }

  .packing-card-total span {
    margin-bottom: 0;
    flex-shrink: 0;
  }

  .packing-card-total strong {
    flex-shrink: 0;
    white-space: nowrap;
  }
}

@media print {
  body * {
    visibility: hidden;
  }
  .packing-label-pages, .packing-label-pages * {
    visibility: visible;
  }
  .packing-label-pages {
    position: absolute;
    inset: 0;
    gap: 0;
  }
  .packing-label {
    box-shadow: none;
    border: none;
    page-break-after: always;
  }
  @page {
    size: 4in 6in;
    margin: 0;
  }
}

/* screen-only (never print — the label's 4in page width would otherwise
   also match this max-width and hide the very thing @media print needs
   visible): a real 4in x 6in label (384px wide) is wider than the
   available content width on a phone, in both places .packing-label
   shows up — the main post-Save/Reprint "Label Print View" screen
   (#packingLabelScreen) and Admin's Reprint Label dialog
   (#packingBoxDetailDialog). Making it fluid (width:100%, height:auto)
   would fix the clipping but lose the actual look of a 4x6 label —
   wanted shown "full size" (i.e. its real proportions/appearance), just
   fitted to the screen rather than reflowed into a differently-shaped
   box. `zoom` (set via fitPackingLabelsToMobile in app.js, which
   measures each container's own real available width) shrinks the whole
   4in x 6in box — and everything in it — by one uniform factor, the same
   as a photocopier reduction, so it still reads as a real label just
   smaller. Screen-only: printing still needs the untouched 4in x 6in box.
   (#packingLabelPages used to be force-hidden here entirely, from back
   when it also doubled as a now-removed listing preview below a search
   panel — since removed, that rule was silently hiding the only real
   label view on mobile, reported live as the screen just showing blank.) */
@media screen and (max-width: 768px) {
  .packing-label {
    zoom: var(--packing-label-mobile-zoom, 1);
  }
}

/* ════════════════════════════════════════════════════
   DIALOGS / MODALS
════════════════════════════════════════════════════ */
dialog {
  border: none;
  background: transparent;
  padding: 0;
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  margin: 0;
  max-height: calc(100vh - 64px);
  max-height: calc(100dvh - 64px); /* dvh overrides vh above on browsers that support it — accounts for mobile browser chrome (address bar) that 100vh doesn't */
  max-width: calc(100vw - 32px);
  overflow: visible;
}

dialog::backdrop {
  background: rgba(8, 24, 44, 0.52);
  backdrop-filter: blur(4px);
}

.dialog-card {
  width: min(480px, calc(100vw - 32px));
  max-height: calc(100vh - 64px);
  max-height: calc(100dvh - 64px); /* dvh overrides vh above on browsers that support it — accounts for mobile browser chrome (address bar) that 100vh doesn't */
  overflow-y: auto;
  padding: 22px 24px;
  border-radius: var(--radius-xl);
  background: #fff;
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--line);
}

.dialog-card h3 {
  font-size: 1.25rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  color: var(--ink);
  margin-bottom: 20px;
}

.dialog-card-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 20px;
}

.dialog-card-head h3 {
  margin-bottom: 0;
}

.packing-box-detail-card {
  width: min(900px, calc(100vw - 32px));
}

@media (max-width: 480px) {
  /* Same fabric/size breakdown popup, but on a phone every pixel of
     width matters for fitting every size column without its own
     horizontal scrollbar (reported live as "client say they not need
     mobile inside to scroller") — tighter dialog padding and a
     noticeably more compact table (smaller font/padding, no forced
     min-width) buy back as much of that width as possible. A box with
     an unusually large number of sizes can still overflow at some
     point no matter how compact the text gets, so .dialog-card's own
     overflow-y:auto — extended to x here — is the fallback, not the
     primary plan. */
  .packing-box-detail-card {
    width: calc(100vw - 16px);
    padding: 16px 14px;
  }

  .packing-box-detail-card .dialog-card-head h3 {
    font-size: 1.05rem;
  }

  /* table-layout:fixed (plus a first-column width below) is what actually
     keeps this within the dialog's own width — auto layout just grows the
     table past its container and relies on scrolling to reach the rest,
     exactly what this is meant to avoid. Long fabric names wrap onto a
     second line instead of pushing the table wider. min-width:0 overrides
     the global `table { min-width: 700px; }` rule (meant for the wide
     admin data tables in their own horizontally-scrollable .table-shell) —
     it applies to every <table> with no scoping, min-width always wins
     over width/table-layout, and silently forced this one to 700px
     regardless — same root cause already documented on .packing-label-
     table above, confirmed here the same way (measuring the actual
     rendered table at 700px against the dialog's ~330px content width). */
  .packing-box-detail-card .packaging-report-detail-table {
    table-layout: fixed;
    width: 100%;
    min-width: 0;
  }

  /* Trimmed from 28% — every extra point given to the Fabric/DNFN column
     is a point taken from the up-to-7 size columns + Total sharing the
     rest, and those are the ones actually tight for room (reported live
     as "XXXL"/"TOTAL" wrapping mid-word: "XXX"/"L", "TOT"/"AL"). */
  .packing-box-detail-card .packaging-report-detail-table th:first-child,
  .packing-box-detail-card .packaging-report-detail-table td:first-child {
    width: 22%;
    overflow-wrap: anywhere;
  }

  .packing-box-detail-card .packaging-report-detail-table th,
  .packing-box-detail-card .packaging-report-detail-table td {
    padding: 6px 2px;
    font-size: 0.7rem;
  }

  /* The site-wide `th { white-space: nowrap }` rule (meant for the wide
     admin data tables) applies here too with no scoping, and a more
     specific rule needs to actually declare white-space to override it —
     font-size/padding alone don't touch it. With table-layout:fixed
     splitting a narrow dialog's width across up to 8 columns (S/M/L/XL/
     XXL/XXXL/4XL/Total), nowrap forced "TOTAL" to stay one line no matter
     how small the font got, so it visibly spilled outside its own cell
     (and the table/dialog bounds) instead of just wrapping. white-space:
     normal fixed that overflow, but on its own just moved the problem —
     "XXXL"/"TOTAL" now wrapped mid-word ("XXX"/"L", "TOT"/"AL") instead of
     spilling over. Smaller font + tighter padding (both below) buys real
     size columns like "XXXL" enough room to fit on one line without
     wrapping at all in the first place.
  */
  .packing-box-detail-card .packaging-report-detail-table th {
    font-size: 0.52rem;
    padding: 6px 1px;
    white-space: normal;
    overflow-wrap: anywhere;
  }

  /* "Total" specifically still doesn't reliably fit even at that smaller
     size once there are 7 real size columns ahead of it splitting up the
     same fixed-width row — abbreviated to "TOT" here rather than letting
     it wrap mid-word, per explicit request ("if not fit its smaller
     version place in label like tot"). The real word stays in the DOM/
     accessible name (only visually hidden via font-size:0) — this is a
     visual swap for this one compact context, not a rename of the column
     everywhere else (the desktop table and every other screen still show
     the full word "Total"). */
  .packing-box-detail-card .packaging-report-detail-table th:last-child {
    font-size: 0;
  }

  .packing-box-detail-card .packaging-report-detail-table th:last-child::after {
    content: "TOT";
    font-size: 0.52rem;
  }
}

.pdf-view-dialog-card {
  width: min(900px, calc(100vw - 32px));
  height: calc(100vh - 64px);
  height: calc(100dvh - 64px);
  display: flex;
  flex-direction: column;
}

.pdf-view-pages {
  flex: 1 1 auto;
  width: 100%;
  overflow-y: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: #f4f6f9;
  padding: 16px;
  text-align: center;
  /* pan-y (not none) — keeps normal single-finger vertical scrolling
     through multi-page PDFs working natively, while still suppressing
     the browser's own two-finger pinch gesture on this element, so a
     pinch here drives setupPdfPinchZoom's own transform on just
     .pdf-view-pages-inner below instead of zooming the whole dialog
     (title/Close button included) the way native pinch-zoom otherwise
     would — reported live as wanting to zoom in on fine print without
     the dialog's own chrome growing too. */
  touch-action: pan-y;
}

/* Only this wrapper (the actual rendered pages), not .pdf-view-pages
   itself, gets the scale/pan transform — keeping the transform off the
   scrollable container avoids fighting its own overflow-y:auto scroll
   position math. */
.pdf-view-pages-inner {
  transform-origin: 0 0;
  will-change: transform;
}

.pdf-view-page {
  display: block;
  max-width: 100%;
  height: auto;
  margin: 0 auto 16px;
  box-shadow: var(--shadow-sm);
  background: #fff;
}

.pdf-view-page:last-child {
  margin-bottom: 0;
}

/* Add/Edit User dialog has grown past the standard single-column dialog
   width (User Type/Factory/Role were added on top of the original fields),
   so on desktop it now needs to lay fields out two-per-row instead of
   scrolling internally. The width itself stays safe on narrow screens via
   min() — calc(100vw - 32px) always wins there, same as every other
   dialog — so only the column count needs a desktop-only media guard. */
#employeeDialog .dialog-card {
  width: min(640px, calc(100vw - 32px));
}

/* Add/Edit Group dialog has grown the same way (Overview Reports/
   Packaging List/Cutting/Packing added on top of the original 6 CRUD
   categories) — same width fix as the User dialog above, so its
   .permission-groups grid gets room for more than 2-3 boxes per row
   instead of scrolling through a long single column. */
#userDialog .dialog-card {
  width: min(640px, calc(100vw - 32px));
}

@media (min-width: 1001px) {
  .employee-form-grid {
    grid-template-columns: 1fr 1fr;
    gap: 4px 16px;
  }
  .employee-form-grid .field-full,
  .employee-form-grid > .auth-error,
  /* Without this, Chrome's grid auto-placement backfills the hint's own
     empty second column with the NEXT field in DOM order (Role) instead
     of moving it to a fresh row — reported live as Role/Permission Group
     landing stacked instead of paired side by side. Spanning the full
     row here, same as .auth-error right after it, leaves no leftover
     open cell for a later field to accidentally reclaim. */
  .employee-form-grid > .field-hint {
    grid-column: 1 / -1;
  }
}

.avatar-upload {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  margin: 0 auto 14px;
  cursor: pointer;
  width: fit-content;
}

.avatar-preview-wrap {
  position: relative;
}

.avatar-preview {
  width: 88px;
  height: 88px;
  border-radius: 50%;
  border: 2px solid var(--line-strong);
  background: var(--brand-soft);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 38px;
  color: var(--brand-2);
  overflow: hidden;
  transition: border-color 0.15s ease;
}

.avatar-upload:hover .avatar-preview {
  border-color: var(--brand-3);
}

.avatar-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.avatar-edit-badge {
  position: absolute;
  bottom: -2px;
  right: -2px;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--brand-2);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  border: 2.5px solid #fff;
  box-shadow: 0 3px 8px rgba(15, 39, 66, 0.28);
}

.avatar-upload-hint {
  font-size: 13px;
  font-weight: 700;
  color: var(--brand-2);
}

.link-btn {
  display: block;
  margin: -14px auto 18px;
  padding: 0;
  border: none;
  background: none;
  font-size: 12.5px;
  font-weight: 700;
  color: var(--danger);
  cursor: pointer;
}

.link-btn:hover {
  text-decoration: underline;
}

/* A long Address/Email/GST value, clamped to a short preview with a
   "more"/"less" toggle (see renderClampableCell in app.js). inline-block on
   the text span is the key fix here — without it, an unbroken long value
   wider than the cell got hard-wrapped by the browser mid-word, and the
   toggle button (a separate inline sibling) landed wherever that wrap
   happened to fall, visually splicing "more" into the middle of the word
   instead of appearing cleanly after it. As an atomic inline-block box, the
   whole span wraps internally on its own but the button always follows it,
   never interleaves inside it. */
.clamp-text {
  display: inline-block;
  max-width: 100%;
  overflow-wrap: anywhere;
  vertical-align: top;
}

.clamp-toggle {
  display: inline;
  margin-left: 4px;
  padding: 0;
  border: none;
  background: none;
  font-size: 12px;
  font-weight: 700;
  color: var(--brand-2);
  cursor: pointer;
  text-decoration: underline;
  white-space: nowrap;
}

.table-avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--panel-soft);
  overflow: hidden;
  margin-right: 8px;
  font-size: 14px;
  vertical-align: middle;
}

.table-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.color-swatch {
  display: inline-block;
  width: 20px;
  height: 20px;
  border-radius: var(--radius-xs);
  border: 1px solid var(--line);
  vertical-align: middle;
}

/* ── Size master: many sizes under one title ──────────────────────────
   The dialog's size entry (a box of chips plus one input) and the same
   chips read-only in the listing's Size column. */
.size-chip-input {
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-xs);
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: var(--surface, #fff);
}

.size-chip-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

/* Collapses to nothing until the first size is added, so an empty box
   isn't padded out by a row that holds no chips. */
.size-chip-list:empty {
  display: none;
}

.size-chip-entry {
  display: flex;
  gap: 8px;
}

.size-chip-entry input {
  flex: 1 1 auto;
  min-width: 0;
}

.size-chip-entry .secondary-btn {
  flex: 0 0 auto;
}

.size-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--brand-soft);
  color: var(--brand-2);
  border: 1px solid var(--brand-2);
  font-size: 0.82rem;
  font-weight: 700;
  line-height: 1.5;
}

/* Removable chips (the dialog) get a visible affordance; the listing's
   are plain labels. */
button.size-chip {
  cursor: pointer;
}

button.size-chip::after {
  content: "×";
  font-size: 1rem;
  line-height: 1;
  opacity: 0.75;
}

button.size-chip:hover,
button.size-chip:focus-visible {
  background: var(--brand-2);
  color: #fff;
}

/* The two Job Card lists carry four controls - search, Issue Date,
   Priority and now Status - where the shared admin template has three
   columns, so Status wrapped onto a full-width row of its own. Its own
   template keeps all four inline, the search still taking the leftover
   width so the row fills the card edge to edge (same treatment as the
   Box Report toolbar below). Scoped by the status filter's id so the
   Cutting toolbar, which has three controls and fits, is untouched. */
.toolbar-grid:has(#listingStatusFilter),
.toolbar-grid:has(#employeeListingStatusFilter) {
  grid-template-columns: minmax(0, 1fr) auto 170px 170px;
}

/* Box Report's Order No. / Party Name filters — labelled so it is clear
   they narrow the list. This toolbar carries three filters where every
   other one carries a single dropdown, so the shared admin template
   (1fr auto 200px) left the verification filter wrapped onto a row of
   its own; its own template keeps all four on one line. */
.toolbar-grid.admin-toolbar:has(#packagingListSearch) {
  /* The search box takes whatever the three filters leave, so the row
     fills the card edge to edge with no dead space — neither a gap in
     the middle nor a stretch of nothing on the right. It is still far
     narrower than before, since the filters now take the room. */
  grid-template-columns: minmax(0, 1fr) 160px 180px 160px;
  /* The two labelled filters are taller than the bare input and select
     (they carry a caption), so line the row up on the controls
     themselves rather than on the tops of the boxes. */
  align-items: end;
}

.packaging-list-filter {
  min-width: 0;
}

.packaging-list-filter > span {
  /* The caption sits above the control, so without this it can end up
     flush against the card's own top edge. */
  padding-top: 2px;
  font-size: 10.5px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

/* Step 2's Size Master dropdown — sits above the size rows it fills in. */
.size-master-pick {
  margin-bottom: 16px;
  max-width: 420px;
}

/* Each title in the picker's dropdown also shows the sizes it holds, so
   the right set can be recognised without opening the Size screen. */
.size-master-option-sizes {
  color: var(--ink-2);
  font-weight: 500;
  font-size: 0.82rem;
}

/* Ratio as clickable 1-5 buttons instead of a typed number. */
.ratio-picker {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.ratio-option {
  min-width: 38px;
  padding: 7px 10px;
  border-radius: var(--radius-xs);
  border: 1px solid var(--line-strong);
  background: var(--surface, #fff);
  color: var(--ink);
  font-size: 0.9rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  cursor: pointer;
  transition: background .15s ease, color .15s ease, border-color .15s ease;
}

.ratio-option:hover {
  border-color: var(--brand-2);
  color: var(--brand-2);
}

.ratio-option:focus-visible {
  outline: 2px solid var(--brand-2);
  outline-offset: 1px;
}

.ratio-option.is-selected {
  background: var(--brand-2);
  border-color: var(--brand-2);
  color: #fff;
}

/* A sample box is called out under its box number, on the order detail
   and so on the Packing Slip PDF cloned from it — a normal box carries
   no tag at all rather than saying "normal". */
.overview-sample-tag {
  display: block;
  margin-top: 2px;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--ink-2);
  white-space: nowrap;
}

.size-cell-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

/* A second copy of the swatch sits inline right next to the priority
   name itself (mobile only, see below) — hidden here so desktop, which
   still shows Color as its own table column, doesn't display it twice. */
.color-swatch-inline {
  display: none;
}

/* Name column with an avatar should never wrap — a long name (e.g. "System
   Admin") breaking to two lines makes that row taller than its neighbours
   and throws off the whole table's vertical alignment. */
#userTableBody td:first-child,
#employeeTableBody td:first-child {
  white-space: nowrap;
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

/* Cutting Details' own Cancel/Save bar — a fabric card list can run long
   enough to need scrolling, and Save sitting at the very bottom used to
   mean scrolling all the way down every time just to save. Sticking it to
   the viewport bottom keeps it reachable at any scroll position; the
   solid background + top shadow (instead of just a border) keeps
   whatever's scrolling underneath from visually poking through the gap a
   plain border would leave. Rounded top corners + a real border (not just
   border-top) + horizontal padding matching .packing-entry-card's own —
   without these it was flat, square-cornered, and edge-to-edge with no
   side inset, reading as a plain slapped-on rectangle instead of a card
   consistent with every other card on this screen (reported live as
   wanting its "box design/corners" fixed). No border-bottom/bottom
   radius — it sits flush against the viewport's own bottom edge, where
   neither would ever actually be visible. */
.cutting-details-actions-sticky {
  position: sticky;
  bottom: 0;
  z-index: 40;
  background: #fff;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-bottom: none;
  border-top-left-radius: var(--radius-md);
  border-top-right-radius: var(--radius-md);
  box-shadow: var(--shadow-top);
}

/* Shared confirm dialog (showConfirmDialog in app.js) — a smaller, centered
   layout instead of every other dialog's left-aligned title+body, since
   this one is just an icon + one line + two buttons. */
.confirm-dialog-card {
  width: min(360px, calc(100vw - 32px));
  text-align: center;
}

.confirm-dialog-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 52px;
  height: 52px;
  margin: 0 auto 16px;
  border-radius: 50%;
  background: var(--danger-soft, #fdeaea);
  color: var(--danger);
}

.confirm-dialog-message {
  font-size: 1rem;
  font-weight: 600;
  color: var(--ink);
  line-height: 1.45;
}

.confirm-dialog-actions {
  justify-content: center;
}

/* ════════════════════════════════════════════════════
   TOGGLE / CHECKBOX GRID
════════════════════════════════════════════════════ */
.toggle-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin-bottom: 4px;
}

.toggle-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border-radius: var(--radius-md);
  border: 1.5px solid var(--line);
  background: var(--panel-soft);
  cursor: pointer;
  transition: all 0.15s ease;
  font-size: 13px;
  font-weight: 600;
}

.toggle-card:hover {
  border-color: var(--brand-3);
  background: var(--brand-soft);
}

.toggle-card input[type="checkbox"] {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  accent-color: var(--brand-2);
  cursor: pointer;
}

.permission-section-label {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted);
  margin: 16px 0 8px;
}

/* ── Applies To radio group (Add Group) ── */
.applies-to-radio-group {
  display: flex;
  gap: 10px;
}

.applies-to-radio {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line-strong);
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--ink);
}

.applies-to-radio:has(input:checked) {
  border-color: var(--brand-3);
  background: var(--brand-soft);
  color: var(--brand-2);
}

/* Category + action checkbox tree for the Add/Edit User permission form —
   one bordered box per feature (Job Card/User/Party/Factory/Priority),
   a bold category checkbox up top, its specific actions (Add/Edit/
   Delete/Active-Deactivate) indented below. The category checkbox is a
   "select all in this box" convenience toggle wired in app.js, not its
   own separate permission. */
.permission-groups {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(128px, 1fr));
  gap: 8px;
  margin-bottom: 8px;
}

.permission-group {
  border: 1.5px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--panel-soft);
  padding: 10px 12px;
}

.permission-group-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 800;
  color: var(--ink);
  cursor: pointer;
  padding-bottom: 8px;
  margin-bottom: 8px;
  border-bottom: 1px solid var(--line);
}

.permission-group-title input[type="checkbox"] {
  width: 15px;
  height: 15px;
  flex-shrink: 0;
  accent-color: var(--brand-2);
  cursor: pointer;
}

.permission-group-items {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.permission-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--muted-2);
  cursor: pointer;
}

.permission-item input[type="checkbox"] {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
  accent-color: var(--brand-2);
  cursor: pointer;
}

/* ════════════════════════════════════════════════════
   RESPONSIVE
════════════════════════════════════════════════════ */
@media (max-width: 1200px) {
  :root { --sidebar-w: 230px; }

  .admin-overview {
    grid-template-columns: 1fr;
  }

  .admin-stats {
    grid-template-columns: repeat(3, 1fr);
  }
}

@media (max-width: 1000px) {
  .portal-topbar {
    padding: 0 14px;
    gap: 10px;
  }

  /* Keeps the logo and the avatar/logout together on one row instead of
     wrapping onto a second line — the full company name + a name/role
     text stack + a logout button together don't fit a phone's width, so
     the less essential text (company subtitle, active user's name/role)
     gives way; the icon, avatar, and Logout button (what you actually need
     to tap) stay put. */
  .mobile-nav-toggle {
    display: flex;
  }

  /* The logo already reappears in the drawer's own header once it's open
     (see .admin-sidebar-head) — showing it a second time in the topbar
     next to the hamburger just crowds an already-tight mobile width. */
  .brand-block {
    display: none;
  }

  /* The name/role text used to hide unconditionally for the entire
     mobile range — but the sidebar collapsing into the hamburger drawer
     at this same breakpoint frees up plenty of width, so most phones
     (anything wider than ~480px) genuinely have room to keep showing it
     too, reported live as an empty gap next to the avatar. See the
     narrower max-width:480px rule further down for where it actually
     needs to go icon-only. */
  .user-chip {
    padding: 6px;
  }

  .topbar-right {
    gap: 8px;
  }

  .app-shell-layout {
    grid-template-columns: 1fr;
  }

  /* Off-canvas drawer instead of an in-flow icon grid — closed by default
     (translated fully off the left edge), slid into view only once
     body.mobile-nav-open is set by the hamburger button. Freed from normal
     document flow, it no longer pushes the actual page content down. */
  .admin-sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: min(280px, 82vw);
    height: 100vh;
    height: 100dvh;
    max-height: none;
    border-radius: 0;
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    z-index: 600;
  }

  body.mobile-nav-open .admin-sidebar {
    transform: translateX(0);
  }

  .admin-nav {
    flex-direction: column;
    padding: 0 0 8px;
    gap: 0;
  }

  .admin-nav-btn {
    min-width: 0;
    padding: 13px 18px;
  }

  .admin-sidebar-head { display: block; padding: 10px 16px; }
  .admin-sidebar-foot { margin: 0 10px 10px; }

  .toolbar-grid,
  .toolbar-grid.admin-toolbar,
  .grid.two {
    grid-template-columns: 1fr;
  }

  /* Every .grid.two field-pair in the wizard collapses to full-width
     stacked by the rule above — right for pairs whose content genuinely
     needs the room (Job Card Name, Party/Factory dropdowns holding a
     potentially long selected name), but Job No./Priority and Issue
     Date/Due Date are all short, fixed-format values (an ID string, a
     3-option dropdown, two DD/MM/YYYY fields) that stacking just wastes
     vertical space on, reported live. Keeping these two pairs specifically
     side by side — :has() targets them by a field only each pair has,
     not by position, so this can't silently start matching the wrong
     pair if the form's field order ever changes. */
  .grid.two:has(#jobNoInput),
  .grid.two:has(#issueDate) {
    grid-template-columns: 1fr 1fr;
    gap: 10px;
  }

  /* At half this row's original width, the reserved right-padding for
     the calendar-icon button (originally sized for a full-width field)
     left too little room for "DD/MM/YYYY" to render without its last
     character running under the icon. Tightening both reclaims just
     enough space to show the full placeholder/typed date. */
  .grid.two:has(#issueDate) input {
    padding-right: 34px;
    font-size: 0.85rem;
  }

  .grid.two:has(#issueDate) .date-picker-toggle {
    right: 2px;
    width: 28px;
    height: 28px;
  }

  /* Size/Fabric rows' compact icon-button Remove treatment used to only
     kick in below 520px — between that and 1000px, .size-grid's 2-column
     collapse (further down, since removed) left "Remove" as a full-text
     button auto-placed into its own implicit grid row with nothing in
     the column beside it, a big dead gap next to a good chunk of unused
     row, reported live. Applying the same compact 3-column-with-icon
     treatment across the WHOLE mobile range (not just below 520px)
     closes that gap instead of only fixing it at the narrowest widths —
     the same fix already applied to .wizard-actions and the Job Cards
     toolbar earlier in this pass, for the same underlying reason. */
  /* Size name and the 1-5 buttons on ONE line while both fit, dropping the
     buttons to the line below only when they don't — a long size name
     (XXXL, XXXLX) or a very narrow screen. Laid out as a wrapping flex row
     rather than a grid so that happens on its own: each side states the
     least width it can live with, and the browser wraps at exactly the
     point they stop fitting. Tighter buttons here than on desktop so the
     inline case survives down to a small phone.
     The head row is hidden on mobile — each row reads clearly without it
     once the two fields sit side by side. */
  .size-grid { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
  .table-head.size-grid { display: none; }
  .step[data-step="2"] .boxed-panel { max-width: none; padding: 12px; }
  /* Both sides declare a small basis and share what's there, so the
     browser keeps them on one line wherever the two minimums fit and
     wraps only when they genuinely don't. The five buttons split their
     own cell evenly rather than each holding a fixed width, which is what
     lets the pair stay inline on a normal phone. */
  /* The input grows with the size name it holds (field-sizing, Chrome
     123+), so a long one like XXXLX widens the first cell and pushes the
     buttons onto the line below by itself — which is the point: short
     names sit inline, long ones get their own line. Bounded so it can
     neither collapse nor run off the screen, and browsers without
     field-sizing simply keep the 64px basis and stay inline. */
  /* auto basis, so the cell is as wide as the input inside it, and the
     input grows with its own value (field-sizing, Chrome 123+). A short
     size keeps the cell small and the buttons stay on the same line; a
     long one like XXXLX widens it until the pair no longer fits and the
     buttons drop to the line below by themselves. Bounded so the cell can
     neither collapse nor run off the screen; browsers without
     field-sizing fall back to the input's own width and stay inline. */
  .size-grid .row-cell:first-child { flex: 0 1 auto; min-width: 56px; max-width: 100%; }
  .size-grid .size-name { field-sizing: content; min-width: 56px; max-width: 100%; }
  .size-grid .row-cell:last-child { flex: 1 1 130px; min-width: 130px; }
  .size-grid .ratio-picker { gap: 4px; flex-wrap: nowrap; width: 100%; }
  .size-grid .ratio-option { flex: 1 1 0; min-width: 26px; padding: 7px 2px; font-size: 0.85rem; }
  /* Fabric has 4 real fields (MTR/MPP/Fabric Name) plus now 2 icon
     buttons instead of Size's 2+2 — smaller icon buttons here (28px, vs
     Size's 34px) claw back just enough room that MTR/MPP stop clipping
     their own placeholder text down to a single character. */
  .fabric-grid { grid-template-columns: 0.65fr 0.55fr 1fr 28px 28px; gap: 4px; }

  .fabric-grid .remove-row,
  .fabric-grid .add-row {
    width: 28px;
    height: 28px;
    min-width: 28px;
  }

  .fabric-grid .remove-row::after {
    font-size: 16px;
  }

  .fabric-grid .add-row svg {
    width: 13px;
    height: 13px;
  }

  .fabric-grid input {
    padding: 9px 6px;
    font-size: 0.75rem;
  }

  .table-head.size-grid,
  .table-head.fabric-grid {
    padding-bottom: 6px;
    margin-bottom: 6px;
    font-size: 9px;
  }

  .table-row.size-grid,
  .table-row.fabric-grid {
    padding: 8px;
    margin-bottom: 8px;
  }

  .remove-row {
    font-size: 0;
    padding: 0;
    width: 34px;
    height: 34px;
    min-width: 34px;
    border-radius: 50%;
  }

  .remove-row::after {
    content: "×";
    font-size: 20px;
    line-height: 1;
  }

  /* Adding a row per-row (this button) replaces the separate full-width
     "+ Add Size/Fabric Row" button below the table on mobile — requested
     live, so it's hidden here instead of just left redundant. */
  #addSizeRow,
  #addFabricRow {
    display: none;
  }

  .add-row {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    width: 34px;
    height: 34px;
    min-width: 34px;
    border-radius: 50%;
  }

  .size-grid input {
    padding: 9px 10px;
    font-size: 0.82rem;
  }

  /* Any toolbar with a real filter next to its search box (Issue Date,
     Priority, Users' Role, Overview Reports' Fabric, ...) gets this same
     collapsed layout — a plain search-only toolbar (Party/Factory/
     Priority Management/Packaging List/...) still reads fine full-width
     and single-column, so this is scoped by
     :has(.date-range-filter, .priority-filter-wrap), the two wrapper
     classes every one of those filters uses regardless of which screen
     it's on. Every control shares a single row: the search input takes
     whatever space is left, and each filter shrinks to a small
     fixed-width icon button at its end — their text labels ("Issue
     Date: All", "All priorities", "All roles", "All fabrics") don't fit
     at this width at any reasonable font size, so rather than truncate
     them illegibly, they become icon-only, matching a standard mobile
     filter-bar pattern. Each stays fully functional (same button/select
     underneath, same click target, same popover/native picker) — only
     its appearance shrinks. */
  .toolbar-grid.admin-toolbar:has(.date-range-filter, .priority-filter-wrap) {
    display: flex;
    align-items: stretch;
    gap: 8px;
  }

  /* Box Report only: three filters plus a search box cannot share one
     phone-width line, so the search takes the first line and the two
     labelled filters share the next. */
  .toolbar-grid.admin-toolbar:has(#packagingListSearch) {
    flex-wrap: wrap;
    align-items: end;
  }

  .toolbar-grid.admin-toolbar:has(#packagingListSearch) #packagingListSearch {
    flex: 1 1 100%;
    max-width: none;
  }

  /* Narrow enough that both filters and the verification button share
     one line instead of pushing the button onto a third. */
  .packaging-list-filter {
    flex: 1 1 110px;
  }

  /* Job Card lists: four controls never fit one phone-width line, so the
     search takes the first and Issue Date / Priority / Status share the
     next. */
  .toolbar-grid.admin-toolbar:has(#listingStatusFilter),
  .toolbar-grid.admin-toolbar:has(#employeeListingStatusFilter) {
    flex-wrap: wrap;
  }

  /* One line, not two: the three filters are icon buttons of 48px, so the
     search box only has to give up ~170px to sit beside them. A full-width
     search pushed all three onto a row of their own. */
  .toolbar-grid.admin-toolbar:has(#listingStatusFilter) > input,
  .toolbar-grid.admin-toolbar:has(#employeeListingStatusFilter) > input {
    flex: 1 1 120px;
    min-width: 0;
  }

  .toolbar-grid.admin-toolbar:has(#listingStatusFilter),
  .toolbar-grid.admin-toolbar:has(#employeeListingStatusFilter) {
    align-items: center;
  }

  /* Icon-only 48px square like Issue Date/Priority: the row has no room for
     the text label (it squeezed to "P…"). The has-value tint still signals
     an active filter. */
  .status-multi-btn {
    width: 48px;
    min-width: 0;
    height: 44px;
    padding: 0;
    justify-content: center;
  }

  .status-multi-label {
    display: none;
  }

  /* The button is the row's last item, so a left-anchored popover ran off
     the right edge and widened the whole page. */
  .status-multi-popover {
    left: auto;
    right: 0;
  }

  .toolbar-grid.admin-toolbar:has(.date-range-filter, .priority-filter-wrap) > input {
    flex: 1 1 auto;
    min-width: 0;
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%235a7190' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3e%3ccircle cx='11' cy='11' r='7'/%3e%3cpath d='M21 21l-4.35-4.35'/%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: left 14px center;
    background-size: 18px;
    padding-left: 42px;
  }

  .toolbar-grid.admin-toolbar:has(.date-range-filter, .priority-filter-wrap) > .date-range-filter {
    flex: 0 0 auto;
  }

  .toolbar-grid.admin-toolbar:has(.date-range-filter, .priority-filter-wrap) .date-range-btn {
    width: 48px;
    /* Same collapse as .priority-filter-btn above, same fix. */
    height: 44px;
    padding: 0;
    justify-content: center;
  }

  /* The active-filter tint (border/background when a custom date range is
     set) already exists on .date-range-filter.has-value — it's the only
     "is a filter currently applied" cue left once the text label with the
     actual date range in it ("Issue Date: 01/08 - 15/08") is hidden, so
     it's more load-bearing here than it was at full width. */
  .toolbar-grid.admin-toolbar:has(.date-range-filter, .priority-filter-wrap) .date-range-label {
    display: none;
  }

  /* The popover normally opens flush with its trigger button's LEFT edge
     (.date-range-popover's left:0) — fine when that button spans most of
     the toolbar's width, but this button is now a 48px icon near the
     right edge of the toolbar, so anchoring the popover to ITS edges
     directly (whichever side) leaves too little room on one side or the
     other and runs off-screen regardless. Making the whole toolbar row
     the positioning context instead (position:relative here, with the
     narrow .date-range-filter itself reset to static so it's no longer
     the nearest positioned ancestor) gives the popover the toolbar's
     full width to anchor within, which — unlike the 48px button — really
     does reach close to the screen edge, leaving enough room either way. */
  .toolbar-grid.admin-toolbar:has(.date-range-filter, .priority-filter-wrap) {
    position: relative;
  }

  .toolbar-grid.admin-toolbar:has(.date-range-filter, .priority-filter-wrap) > .date-range-filter {
    position: static;
  }

  .toolbar-grid.admin-toolbar:has(.date-range-filter, .priority-filter-wrap) .date-range-popover {
    left: auto;
    right: 0;
    width: min(320px, 100%);
  }

  /* Two attempts at shrinking #listingPriorityFilter itself to an
     icon-sized box (text-indent:-999px, then text-indent:100% + clipped
     overflow, then even just an invisible full-size overlay) each still
     left mobile Chrome's native option-list popup anchoring itself
     somewhere other than the visible flag icon — confirmed live on a
     real phone every time, including the "untouched, just invisible"
     version, which ruled out box distortion as the actual cause.
     This replaces the native picker on mobile entirely with a small
     custom button+popover (setupPriorityFilterMenus in app.js) — the
     exact same pattern already working correctly for Issue Date's
     button+popover just above. The real <select> stays in the DOM,
     completely untouched, still the one thing renderJobsTableInto reads
     its value from either way — just hidden on mobile, with the custom
     popover setting its value programmatically when an option is
     tapped. Zero native picker involved, so there's nothing left for a
     phone's browser to mis-anchor. */
  .toolbar-grid.admin-toolbar:has(.date-range-filter, .priority-filter-wrap) .priority-filter-wrap {
    display: block;
    position: relative;
    flex: 0 0 auto;
    width: 48px;
  }

  .toolbar-grid.admin-toolbar:has(.date-range-filter, .priority-filter-wrap) .priority-filter-wrap select {
    display: none;
  }

  .toolbar-grid.admin-toolbar:has(.date-range-filter, .priority-filter-wrap) .priority-filter-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 48px;
    /* A definite height, not 100%. The percentage had nothing to resolve
       against - the wrapper is display:contents and the toolbar does not
       stretch its items - so the button collapsed to the height of the
       icon inside it, 19px, and read as a stray pill next to the 44px
       search box and dropdowns. */
    height: 44px;
    padding: 0;
    border: 1.5px solid var(--line);
    border-radius: var(--radius-sm);
    background: #fff;
    color: var(--muted);
    cursor: pointer;
  }

  /* Same "a filter is actually applied" cue .date-range-filter.has-value
     already gets — load-bearing here since the text label doesn't show
     at all in icon-only form. Toggled in JS (setupPriorityFilterMenus),
     since there's no real select value for :has() to read anymore once
     the select itself is hidden and out of the interaction entirely. */
  .toolbar-grid.admin-toolbar:has(.date-range-filter, .priority-filter-wrap) .priority-filter-btn.has-value {
    border-color: var(--brand-2);
    background-color: var(--brand-soft);
    color: var(--brand-2);
  }

  .toolbar-grid.admin-toolbar:has(.date-range-filter, .priority-filter-wrap) .priority-filter-popover {
    display: block;
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    z-index: 40;
    width: 170px;
    padding: 6px;
    border-radius: var(--radius-md);
    border: 1px solid var(--line);
    background: #fff;
    box-shadow: var(--shadow-lg);
  }

  /* The `display: block` above (needed to override the base
     .priority-filter-popover{display:none} outside mobile) otherwise
     also overrides the browser's own `[hidden]{display:none}` default —
     an author style always wins over that regardless of specificity —
     so toggling the `hidden` attribute in JS stopped actually hiding
     the popover: tapping an option correctly set the filter but visibly
     left the list open. This restores hidden's effect explicitly. */
  .toolbar-grid.admin-toolbar:has(.date-range-filter, .priority-filter-wrap) .priority-filter-popover[hidden] {
    display: none;
  }

  .toolbar-grid.admin-toolbar:has(.date-range-filter, .priority-filter-wrap) .priority-filter-option {
    display: block;
    width: 100%;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    border: none;
    background: none;
    text-align: left;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--ink);
    cursor: pointer;
  }

  .toolbar-grid.admin-toolbar:has(.date-range-filter, .priority-filter-wrap) .priority-filter-option:hover {
    background: var(--panel-soft);
  }

  .toolbar-grid.admin-toolbar:has(.date-range-filter, .priority-filter-wrap) .priority-filter-option.active {
    background: var(--brand-soft);
    color: var(--brand-2);
  }

  .admin-overview {
    grid-template-columns: 1fr;
  }

  /* .preview-main/.preview-meta are NOT collapsed here even on a narrow
     viewport — .preview-sheet is always a fixed 210mm (A4) box regardless
     of screen size (see .preview-sheet below), so it always has room for
     the desktop 2-column layout. Media queries key off the viewport, not
     the container, so without this exclusion, viewing or generating a PDF
     from a phone forced this fixed-width sheet into the narrow-screen
     single-column stack anyway — producing a much taller capture with a
     completely different page layout than the same job viewed on desktop,
     and consequently a differently (and badly) paginated PDF. */

  /* The wizard's Previous/Next row only got a mobile treatment below
     520px (full-width stacked buttons) — from 521-1000px it fell back to
     the desktop justify-content:space-between with buttons sized to
     their own text, which the long "← Back to Admin" label combined with
     no flex-wrap left cramped/overlapping at some widths in that gap.
     Keeping both buttons on one row, evenly split, across the WHOLE
     mobile range (matching the breakpoint every other mobile change in
     this pass uses) closes that gap with one consistent layout instead
     of two different ones either side of an arbitrary 520px line. */
  .wizard-actions {
    flex-wrap: nowrap;
    gap: 8px;
  }

  .wizard-actions button {
    flex: 1 1 0;
    min-width: 0;
    padding-left: 12px;
    padding-right: 12px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  /* The overflow/ellipsis safety net above was still visibly truncating
     "Download PDF" and "Update Job Card" to unreadable fragments on a
     real phone — the final wizard step shows 3 buttons in this same row
     (Previous/Download PDF/Save-or-Update) instead of the usual 2, and
     even split evenly there isn't room for both full labels at a
     legible size. Swapping to the short label (set up as a sibling span
     in the HTML/JS, see #downloadPdfBtn and nextBtn's innerHTML in
     app.js) shows real, complete words instead of an ellipsis-cut one. */
  .btn-label-full {
    display: none;
  }

  .btn-label-short {
    display: inline;
  }

  /* Every data table (Job Cards / Employees / User Access) becomes a
     column of self-labeled cards instead of a wide table — no horizontal
     scroll needed at all, and every column's full value stays visible
     (each row's own td::before echoes that column's header as a label,
     since <thead> itself is hidden here).
     This used to only kick in below 520px — between that and this
     block's 1000px, the table fell back to its bare desktop column
     layout (thead visible, no card conversion), overflowing sideways on
     anything in that range, reported live. Moved here to apply across
     the whole mobile range this app treats as mobile everywhere else,
     same fix already applied to several other components this pass. */
  .table-shell table {
    min-width: 0;
  }

  .table-shell thead {
    display: none;
  }

  .table-shell table,
  .table-shell tbody,
  .table-shell tr {
    display: block;
    width: 100%;
  }

  /* A visible card, not just a bordered block — the search/filter panel
     above already reads as an elevated surface (shadow + radius), so a
     plain 1px-bordered row underneath looked flat and disconnected by
     comparison. Matching that elevation ties the whole page together.
     display:grid (2 columns) instead of a single stacked column — the
     card's title (first field) and Actions (last field) each still span
     the full width below, but the fields in between (Username/Phone/
     Email/Group, Mobile/Address/Email/GST, etc.) pair up 2-per-row
     instead of each getting its own full-width row, reported live as
     wasting a lot of vertical space on fields short enough to easily
     share a line. */
  .table-shell tr:not(.empty-state) {
    display: grid;
    grid-template-columns: 1fr 1fr;
    column-gap: 16px;
    margin-bottom: 14px;
    padding: 14px 16px;
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    background: #fff;
    box-shadow: var(--shadow-sm);
  }

  .table-shell tr:not(.empty-state) td:first-child,
  .table-shell tr:not(.empty-state) td:last-child {
    grid-column: 1 / -1;
  }

  /* A table with exactly one field between the title and Actions (Priority
     Management's Color, Factory Management's Address) left that one field
     sitting alone in the left column with nothing to pair it with, an
     empty gap beside it — reported live. td:nth-child(2):nth-last-child(2)
     only ever matches when a row has exactly 3 cells total (title + 1
     middle field + Actions), so this can't accidentally start spanning a
     real middle field on a table that has 2+ of them (Users, Party, ...),
     where pairing 2-per-row is still what's wanted. */
  .table-shell tr:not(.empty-state) td:nth-child(2):nth-last-child(2) {
    grid-column: 1 / -1;
  }

  /* The Order Wise Package Report listing is the one card table whose
     cells are mostly action buttons, and a button's natural width is its
     whole label ("Job Card Wise Detail Report"). A grid item does not
     shrink below its content, so those buttons ran straight past the
     card's right edge. The cell is allowed to shrink and the button fills
     it, wrapping its label instead of overflowing. */
  #overviewOrderListScreen .table-shell td {
    min-width: 0;
  }

  #overviewOrderListScreen .table-shell td .mini-btn {
    display: block;
    width: 100%;
    white-space: normal;
    text-align: center;
  }

  /* Priority Management's Color is small enough (a 20px swatch, no text)
     that it doesn't need a row of its own even after the fix above —
     showing it right next to the priority name it belongs to instead is
     more compact still, and reads more like "this name IS this color"
     than a separate labeled field does. The standalone Color cell (kept
     in the DOM for desktop's table column) is hidden here in favor of
     the inline copy that lives inside the title cell itself. */
  .table-shell tr:not(.empty-state) td[data-label="Color"] {
    display: none;
  }

  .table-shell tr:not(.empty-state) td:first-child .color-swatch-inline {
    display: inline-block;
    margin-left: 10px;
  }

  .table-shell tr:not(.empty-state):last-child {
    margin-bottom: 0;
  }

  /* Label-left/value-right (space-between) on one line forced every long
     value (a job card name, an address, an email) to either wrap into a
     ragged right-aligned block or squeeze against its own label — neither
     reads well. Label-above/value-below stacks cleanly regardless of
     value length, and matches how a form field is read (top-to-bottom),
     not a table cell (left-to-right).
     Block layout (not flex-column) on purpose: a few of these cells hold
     more than one inline child — the Users table's avatar icon plus name,
     for instance — and flex-direction:column would stack every direct
     child of the cell on its own line, breaking the icon away from the
     name it belongs next to. A block label followed by inline content
     keeps those multi-part cells reading as one line, same as they did
     before this cell became label-above/value-below. */
  .table-shell td {
    display: block;
    padding: 8px 0;
    border: none !important;
    border-bottom: 1px solid var(--line);
    text-align: left;
    overflow-wrap: anywhere;
  }

  .table-shell tr:not(.empty-state) td:last-child {
    border-bottom: none;
    padding-bottom: 0;
  }

  .table-shell td::before {
    content: attr(data-label);
    display: block;
    margin-bottom: 4px;
    font-weight: 700;
    font-size: 10.5px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--muted);
  }

  /* The first cell (Job No. / Party Name / Factory Name / User Name / ...)
     is what actually identifies this card at a glance while scrolling a
     long list — sized and set apart like a card title instead of blending
     in as just one more field in the stack. */
  .table-shell tr:not(.empty-state) td:first-child {
    padding-top: 0;
    padding-bottom: 12px;
    margin-bottom: 4px;
    border-bottom: 1px solid var(--line);
    font-size: 1.05rem;
  }

  .table-shell tr:not(.empty-state) td:first-child::before {
    font-size: 10px;
    color: var(--muted-2, var(--muted));
  }

  .table-shell td[data-label="Actions"] {
    padding-top: 12px;
  }

  .table-shell td[data-label="Actions"]::before {
    margin-bottom: 8px;
  }

  /* Equal-width buttons instead of right-packed ones — a thumb reaching
     for "Delete" on a narrow phone screen benefits from a full, predictable
     tap target far more than the group does from staying compact. */
  .table-shell td[data-label="Actions"] .row-actions {
    flex-wrap: wrap;
    width: 100%;
  }

  .table-shell td[data-label="Actions"] .row-actions .mini-btn {
    flex: 1 1 0;
    text-align: center;
    padding: 9px 8px;
  }

  .table-shell tr.empty-state {
    padding: 16px;
  }

  .table-shell tr.empty-state td {
    display: block;
    text-align: center;
    border-bottom: none;
  }

  .table-shell tr.empty-state td::before {
    content: none;
  }

  /* Shrinks the Edit/Delete footprint in every admin table so less of the
     row needs to scroll into view to reach them. */
  .row-actions .mini-btn {
    padding: 6px 10px;
    font-size: 0.75rem;
  }
}

@media (max-width: 768px) {
  .portal-main,
  form {
    padding: 16px;
  }

  .screen-card {
    padding: 16px;
  }

  /* The Create Job Card wizard's outer wrapper (#employeeCreateScreen,
     shared by both the admin and Employee Workspace flows) is a
     .screen-card that wraps a .wizard-card directly — and both classes
     share the exact same box styling (background/border/radius/shadow).
     At this narrower width the two boxes' borders/padding sit far enough
     apart to read as a card nested inside a near-identical outer card
     rather than one unified panel, reported live. Stripping the OUTER
     box's own chrome here (leaving only the inner .wizard-card visible)
     removes the redundant frame — every other .screen-card on this page
     is untouched by :has() scoping to this specific case (the
     Job/User/Party/Factory/Priority/Cutting lists' own double-boxing,
     via .table-shell rather than .wizard-card, gets the same fix just
     below instead). */
  .screen-card:has(.wizard-card) {
    background: none;
    border: none;
    border-radius: 0;
    box-shadow: none;
    padding: 0;
    margin: 0;
  }

  /* Same double-boxing, one layer deeper: .screen-card wraps .table-shell,
     and .table-shell carries its own border/radius/shadow/background too
     (needed on desktop, where it's a plain scrollable table with no
     per-row framing) — but every .table-shell row becomes its own
     individually-bordered card just below this block on mobile, so a
     Job/User/Party/Factory/Priority/Cutting list on mobile nested three
     frames (outer .screen-card, then .table-shell, then every row) around
     the same content: wasted padding, and faint doubled border lines
     wherever two of those frames' edges landed close enough to touch,
     reported live as visual overlap right at the seam between rows.
     Stripping the outer two here leaves only the row cards — same
     reasoning as the .wizard-card fix above. */
  .screen-card:has(.table-shell) {
    background: none;
    border: none;
    border-radius: 0;
    box-shadow: none;
    padding: 0;
  }

  .table-shell {
    border: none;
    border-radius: 0;
    box-shadow: none;
    background: none;
  }

  /* .size-grid used to collapse to a 2-column grid here — removed: with
     only 2 explicit columns but 3 real fields per row (Size Name/Ratio/
     Remove), the Remove button got auto-placed into its own implicit
     row with nothing beside it, leaving a big dead gap next to it (see
     the max-width:1000px block above, which now handles .size-grid's
     compact layout across this whole range instead). */

  .photo-grid {
    grid-template-columns: 1fr;
  }

  /* .preview-photo-grid stays at its base 2-column layout even here — it's
     inside .preview-sheet, which is always a fixed A4 width regardless of
     the viewport (see the .preview-main/.preview-meta note above for why). */

  .admin-stats {
    grid-template-columns: repeat(3, 1fr);
  }

  .toggle-grid {
    grid-template-columns: 1fr;
  }

  .topbar-right {
    flex-wrap: wrap;
    gap: 8px;
  }

  /* "+ Add Cutting Details" / "+ Create Job Card" / "+ Add User" / "Back to
     Job Cards" etc — any .primary-btn or .secondary-btn living in a
     .page-header — keep their desktop padding/font (11-12px/20-22px,
     0.9rem) once they drop to their own row on mobile
     (.page-header > div:first-child's min-width forces that wrap below),
     reading as an oversized slab next to the same-row search bar
     underneath. Smaller padding/font here is still a comfortably tappable
     button, just sized like the rest of the mobile UI instead of towering
     over it. */
  .page-header .primary-btn,
  .page-header .secondary-btn {
    padding: 9px 14px;
    font-size: 0.82rem;
  }
}

@media (max-width: 520px) {
  .auth-card { padding: 24px 20px; }

  /* Only truly narrow phones need to drop to icon-only — anything wider
     (most phones, once the sidebar's already collapsed into the
     hamburger drawer above) has room to keep the name/role text next to
     the avatar too, which used to be hidden unconditionally across the
     whole mobile range regardless of how much space was actually free. */
  .user-chip-info {
    display: none;
  }

  /* The Party/Factory dropdown plus its +Add/Edit buttons don't fit
     comfortably on one line at this width — put the dropdown on its own
     full-width row, then +Add and Edit share the row below it side by
     side (not each stacked as a separate full-width row, which wasted
     vertical space for no reason). */
  .option-select-row {
    flex-wrap: wrap;
  }

  .option-select-row select {
    flex-basis: 100%;
  }

  .option-select-row .ghost-btn {
    flex: 1 1 calc(50% - 4px);
  }

  .admin-stats {
    grid-template-columns: 1fr;
  }

  /* Size/Fabric rows' compact layout (icon-only Remove, tighter padding)
     now lives in the max-width:1000px block above, applied across the
     whole mobile range instead of just below this width — this used to
     duplicate that same block here. */

  /* The editor toolbar's 15+ controls can't all fit on a ~350px-wide
     screen at full size (they don't even all fit on this line at desktop
     width without wrapping once or twice) — shrink every control and swap
     the wordiest buttons (List/Link/Color) down to icon-only so it wraps
     to 2 rows instead of 4-5. */
  .editor-toolbar {
    padding: 6px 8px;
    gap: 4px;
  }

  .editor-toolbar-group {
    gap: 2px;
  }

  .editor-toolbar-divider {
    display: none;
  }

  .editor-toolbar button,
  .editor-select {
    height: 26px;
    min-width: 24px;
    font-size: 11px;
    padding: 0 5px;
  }

  #editorFormatBlock {
    max-width: 78px;
    padding: 0 20px 0 6px;
    background-position: right 6px center;
    background-size: 14px;
  }

  .editor-toolbar button[data-command="insertUnorderedList"],
  .editor-toolbar button[data-command="insertOrderedList"],
  #editorLinkBtn {
    font-size: 0;
    padding: 0;
    width: 28px;
  }

  .editor-toolbar button[data-command="insertUnorderedList"]::after {
    content: "•";
    font-size: 16px;
  }

  .editor-toolbar button[data-command="insertOrderedList"]::after {
    content: "1.";
    font-size: 12px;
  }

  #editorLinkBtn::after {
    content: "🔗";
    font-size: 13px;
  }

  .color-picker {
    padding: 3px 5px;
    gap: 4px;
  }

  .color-picker span {
    display: none;
  }

  .color-picker input[type="color"] {
    width: 18px;
    height: 18px;
  }

  /* .row-cell-label stays hidden — the column header row above already
     labels each field now that rows no longer stack to 1 column. */

  /* Size/Fabric panels were double-boxed on mobile — the outer .screen-card
     plus this inner .boxed-panel border+background, both with their own
     padding, ate space and read as two nested cards instead of one compact
     block. Drop the inner box; the individual .table-row cards underneath
     already give each row its own visible border. */
  .boxed-panel {
    padding: 0;
    border: none;
    background: transparent;
    border-radius: 0;
  }

  .photo-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  /* flex-wrap/flex:1 1 100% (full-width stacked buttons) used to live
     here — removed in favor of the inline, evenly-split layout applied
     across the whole mobile range above (max-width:1000px), so this
     doesn't re-stack them back to two full rows below 520px specifically
     and undo that. Only the tighter padding for this narrower width
     stays. */
  .wizard-actions {
    padding: 14px 16px 18px;
  }

  #employeeTabs {
    flex-wrap: wrap;
  }

  /* Used to force this into 2 stacked rows (heading, then button) on
     every mobile width — but the header's base rule already wraps if a
     given heading+button combo genuinely doesn't fit one line (flex-wrap
     on .page-header), so stacking unconditionally left a big, pointless
     empty gap next to shorter headings like "Job Card Management" that
     had clear room for the button beside them, reported live. Letting it
     stay a normal inline row (falling back to wrap only when actually
     needed) fills that space instead of leaving it empty by default. */
  .page-header {
    row-gap: 10px;
  }

  /* .page-header > div:first-child's own min-width:0 (needed on desktop so
     it can share space with a wide pill/button instead of leaving a dead
     gap) has no floor on a phone — it'll keep shrinking the title down to
     an unreadable sliver instead of ever actually wrapping to its own row,
     since flex-wrap only kicks in once a row genuinely can't fit both
     children at their minimum width. A long action label next to it
     ("+ Add Cutting Details", "+ Add Packaging") never fit next to a
     multi-word heading on a phone even before those buttons existed here,
     reported live as the heading squeezed into a narrow wrapped column
     right beside the button instead of sitting on its own full-width line
     above it. A real (if modest) floor restores the "wrap the whole row"
     behavior the base rule already assumed would happen. */
  .page-header > div:first-child {
    min-width: 260px;
  }

  /* The Packaging panel's own short "Packaging" title + "+ Add Packaging"
     button — reported live as the title padded out to the 260px floor
     (leaving a big empty gap beside the short word "Packaging") while the
     button got shoved down onto its own row below, instead of the two
     sitting inline like a title+button header normally does. */
  .page-header:has(#packagingListAddBtn) > div:first-child {
    min-width: 0;
  }

  .user-chip-menu {
    right: -8px;
  }

  .avatar-upload {
    margin-left: auto;
    margin-right: auto;
  }

  /* .preview-header/.preview-job/.preview-footer/.cutting-report-title-bar
     are NOT collapsed here even on a narrow viewport, for the same reason
     .preview-main/.preview-meta/.preview-photo-grid aren't (see the note
     near .preview-sheet below): .preview-sheet and #cuttingReportPrintable
     are always a fixed 210mm (A4) box regardless of screen size, so they
     always have the room these rules assumed a phone screen didn't have.
     An earlier version of this file stacked them at this breakpoint, which
     made the on-screen mobile preview AND the PDF generated from a phone
     (a flattened capture of this same markup) look different from — and
     visually broken compared to — the desktop version. */

  /* The admin nav now lives in the off-canvas drawer (see @media max-width:
     1000px) at every mobile width, including this one — its own width is
     capped at min(280px, 82vw) regardless of how narrow the phone is, which
     is plenty of room for icon + full label side by side like desktop, so
     unlike the old in-flow icon grid this no longer needs its own
     narrower-screen fallback layout. */

  /* The subtitle line and "Employee mode" badge are purely descriptive —
     on a phone they push the actually-useful Job Cards table further down
     the screen than the extra context is worth. Same reasoning for the
     Cutting Report step's own explanatory line ("Auto-generated from
     Fabric Details...") and each Label Images upload card's own "Upload
     the ... image, then crop it to the frame below." line — read-only
     instructions the upload area itself already makes obvious, reported
     live as just taking up room above the actual upload frame on a
     phone. */
  .page-header .muted,
  .panel-note,
  .section-heading .muted,
  .upload-header p {
    display: none;
  }

  .page-header {
    margin-bottom: 12px;
  }
}

/* ════════════════════════════════════════════════════
   MODERN DASHBOARD LAYOUT & WIZARD POLISH
   (Sidebar attached to left/top and hidden step pills)
   ════════════════════════════════════════════════════ */

/* Hide step pills, wizard progress bar, and step eyebrows as requested.
   Scoped to .section-heading (the "Step N of 8" labels) rather than every
   .eyebrow under .step, since other .eyebrow text inside a .step (e.g.
   inside .preview-meta) must stay visible. */
.step-pills,
.wizard-progress,
.section-heading .eyebrow {
  display: none !important;
}

/* Let the admin layout span full screen width and height — this whole
   group is keyed off body.is-admin (toggled in JS right after login/session
   restore, see setAuthenticatedUser), NOT which view-panel is active, so
   the sidebar+full-bleed layout stays exactly the same whether an admin is
   looking at the Admin panel or the Job Card wizard. An employee session
   never gets this class, so .admin-sidebar (display:none by default) never
   appears for them regardless of which view-panel they're on. */
body.is-admin .portal-main {
  max-width: 100% !important;
  padding: 0 !important;
  margin: 0 !important;
}

body.is-admin .app-shell-layout {
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
  gap: 0 !important;
  min-height: calc(100vh - var(--topbar-h));
  min-height: calc(100dvh - var(--topbar-h)); /* dvh overrides vh above on browsers that support it — accounts for mobile browser chrome (address bar) that 100vh doesn't */
  align-items: stretch;
}

body.is-admin .admin-sidebar {
  display: flex;
  flex-direction: column;
  position: sticky;
  top: var(--topbar-h);
  height: calc(100vh - var(--topbar-h));
  height: calc(100dvh - var(--topbar-h)); /* dvh overrides vh above on browsers that support it — accounts for mobile browser chrome (address bar) that 100vh doesn't */
  max-height: calc(100vh - var(--topbar-h));
  max-height: calc(100dvh - var(--topbar-h)); /* dvh overrides vh above on browsers that support it — accounts for mobile browser chrome (address bar) that 100vh doesn't */
  border-radius: 0 !important;
  border-top: none !important;
  border-left: none !important;
  border-bottom: none !important;
  border-right: 1px solid var(--line) !important;
  box-shadow: none !important;
  margin: 0 !important;
}

/* The scrollable column next to the sidebar — holds whichever view-panel
   is currently active (employee wizard or admin panels). Replaces what
   used to be .admin-content's job when the sidebar only ever wrapped the
   admin panels; .admin-content below now only needs its own padding. */
body.is-admin .app-shell-content {
  min-width: 0;
  max-height: calc(100vh - var(--topbar-h));
  max-height: calc(100dvh - var(--topbar-h)); /* dvh overrides vh above on browsers that support it — accounts for mobile browser chrome (address bar) that 100vh doesn't */
  overflow-y: auto;
}

body.is-admin .admin-content {
  padding: 32px 40px 48px;
}

/* .admin-content (above) only wraps the actual admin-panel sections — the
   Job Card wizard lives in the employee view-panel, a separate sibling
   inside .app-shell-content that gets none of that padding. That's
   invisible for a real employee session (.portal-main still has its own
   default padding there), but for an admin — whose .portal-main padding is
   forced to 0 above, to let the sidebar sit flush and full-bleed — it left
   the wizard's own header and content flush against the sidebar with no
   breathing room at all, while every other admin screen had proper
   padding. Match .admin-content's padding here so the wizard looks
   consistent with the rest of the admin experience. */
body.is-admin [data-view-panel="employee"] {
  padding: 32px 40px 48px;
}

/* Same reasoning as [data-view-panel="employee"] above — a Cutting/
   Packing User now always gets the real admin shell too (getsAdminShell
   in app.js), so their own screens need the same breathing room as every
   other admin-shell screen instead of sitting flush against the sidebar. */
body.is-admin [data-view-panel="cuttingEntry"],
body.is-admin [data-view-panel="packingEntry"] {
  padding: 32px 40px 48px;
}

/* The rules above are unscoped (no media query) and use a higher-
   specificity body.is-admin selector, so they silently overrode the
   @media (max-width: 1000px) sidebar-collapse rules above at every
   viewport — including phones, where a fixed 230px sidebar left only ~140px
   for actual content. This block wins the same way (same selector prefix,
   declared later) to restore the single-column collapse on small screens. */
@media (max-width: 1000px) {
  body.is-admin .app-shell-layout {
    grid-template-columns: 1fr !important;
    min-height: 0 !important;
  }

  /* Off-canvas drawer, same as the unscoped .admin-sidebar mobile rule
     above — restated here with !important because body.is-admin's own
     unscoped position:sticky/height rules (declared earlier, no media
     query) otherwise win on specificity at every viewport, including
     phones. */
  body.is-admin .admin-sidebar {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    width: min(280px, 82vw) !important;
    height: 100vh !important;
    height: 100dvh !important;
    max-height: none !important;
    border-right: none !important;
    border-bottom: none !important;
    transform: translateX(-100%);
    transition: transform 0.25s ease;
  }

  body.mobile-nav-open .admin-sidebar {
    transform: translateX(0) !important;
  }

  body.is-admin .app-shell-content {
    max-height: none !important;
    overflow-y: visible !important;
  }

  body.is-admin .admin-content {
    padding: 20px !important;
  }

  /* Matches .admin-content's own mobile reduction just above — without
     this, the wizard (reached via "+ Create Job Card") kept its desktop
     32px/40px padding while every other admin screen dropped to 20px, and
     that padding stacked with #employeeCreateScreen's own fixed 32px
     padding below (also !important) to leave barely 200px of a 390px
     phone screen for the actual form — the Fabric Details row's MTR/MPP
     inputs were rendered too narrow to show more than one clipped digit. */
  body.is-admin [data-view-panel="employee"] {
    padding: 20px !important;
  }

  /* Same gap as [data-view-panel="employee"] just above: the unscoped
     32px/40px/48px rule for these two panels (added when Cutting/Packing
     Users started always getting the admin shell) never got a mobile
     reduction, so on a phone it alone was eating most of the screen width
     before the card content inside even started — reported live as the
     Cutting Details fabric cards' SIZE/CUT QTY grid collapsing to a single
     cramped column. */
  body.is-admin [data-view-panel="cuttingEntry"],
  body.is-admin [data-view-panel="packingEntry"] {
    padding: 20px !important;
  }
}

/* Center employee/client view card nicely since main padding was removed */
#employeeCreateScreen {
  max-width: 1200px;
  margin: 24px auto !important;
  padding: 32px !important;
}

/* #employeeCreateScreen above hardcodes its padding/margin with
   !important on an ID selector — the same specificity as the override
   below, so source order (this rule coming later) is what makes the
   mobile version win, not the media query alone. Without this, the
   wizard's own card stayed at a fixed 32px padding + 24px auto margin on
   every screen size, stacking with the admin shell's own mobile-reduced
   padding to leave barely half a 390px phone screen for the actual form
   — the Fabric Details step's MTR/MPP inputs were too narrow to show
   more than one clipped digit. */
@media (max-width: 768px) {
  #employeeCreateScreen {
    padding: 16px !important;
    margin: 12px auto !important;
  }
}

/* Contenteditable Placeholder */
.editor:empty::before {
  content: attr(placeholder);
  color: var(--muted-2);
  font-style: normal;
  cursor: text;
  pointer-events: none;
  display: block;
}

/* ── Connect Printer dialog ──────────────────────────────────────────── */
.connect-printer-card {
  width: min(440px, calc(100vw - 32px));
}

/* Connect Printer / Disconnect / Advanced settings / Print Test Label mix
   three different base button classes (.primary-btn/.secondary-btn/
   .ghost-btn), each bringing its own padding, font-size, border and
   margin. Laying them out as two flex rows meant their size and position
   depended on all of that: widths drifted (189/190/191px) and a leftover
   `margin: 14px 0 0` on .printer-advanced-toggle pushed it 14px below the
   button beside it in the same row, reported live as the four buttons
   sitting at different heights and not lining up.

   A 2x2 grid removes the whole class of problem: cells are equal by
   construction, so alignment no longer depends on which base class a
   button uses or how long its label is. Everything that varies per class
   is then neutralised below. */
.connect-printer-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 14px;
}

.connect-printer-actions button {
  /* width:100% + a fixed height make each button fill its cell exactly,
     so all four are pixel-identical regardless of label length. margin:0
     is what actually kills the stray top margin described above. */
  width: 100%;
  height: 36px;
  min-height: 0;
  max-height: 36px;
  margin: 0;
  padding: 0 10px;
  box-sizing: border-box;
  border-radius: var(--radius-xs);
  /* Matches .mini-btn's compact size — the same small PDF/Edit/Delete
     row-action buttons used elsewhere in the app. */
  font-size: 0.78rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.printer-method-toggle {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
}

.printer-method-btn {
  flex: 1 1 0;
  padding: 10px 12px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: #fff;
  color: var(--ink-2);
  font-weight: 700;
  font-size: 0.85rem;
  cursor: pointer;
}

.printer-method-btn span {
  display: block;
  font-weight: 500;
  font-size: 0.72rem;
  color: var(--muted);
}

.printer-method-btn.active {
  border-color: var(--brand-2);
  background: var(--brand-soft);
  color: var(--brand-2);
}

.printer-status-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--panel-soft);
  margin-bottom: 14px;
}

.printer-status-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--muted-2);
  flex-shrink: 0;
}

.printer-status-dot.connecting {
  background: var(--warning);
}

.printer-status-dot.connected {
  background: var(--success);
}

.printer-status-dot.error {
  background: var(--danger);
}

.printer-status-text {
  font-weight: 700;
  color: var(--ink);
}

.printer-status-detail {
  font-size: 0.8rem;
  color: var(--muted);
  word-break: break-word;
}

/* Sits inline with Print Test Label in the same .button-row now (reported
   live as wanting the two side by side instead of stacked) — flex:1
   (same as .button-row .secondary-btn) shares the row evenly instead of
   the old standalone full-width bar. */
/* Sizing and spacing come from the .connect-printer-actions grid — this
   button previously carried `flex: 1` and `margin: 14px 0 0` from when it
   sat on its own line, and that margin was what knocked it out of
   alignment with the button beside it once it moved into a shared row. */
.printer-advanced-toggle {
  text-align: center;
}

.printer-advanced-toggle.ghost-btn {
  border: 1px solid var(--line-strong);
}

.printer-advanced-panel {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* .printer-advanced-panel's own display:flex above (and .field's
   display:grid, for #printerCustomUuidGroup inside it) ties the browser's
   built-in `[hidden]{display:none}` on specificity (both are single-class/
   attribute selectors) — an author rule winning that tie is what silently
   kept both permanently visible regardless of their `hidden` attribute,
   reported live as the whole dialog reading as "one very long form"
   instead of Advanced settings actually starting collapsed. Same fix
   already used for .priority-filter-popover[hidden] elsewhere in this
   file. */
.printer-advanced-panel[hidden],
.field[hidden] {
  display: none;
}

.printer-log {
  margin-top: 14px;
  max-height: 140px;
  overflow-y: auto;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: #0f172a;
  font-family: ui-monospace, monospace;
  font-size: 0.72rem;
  color: #c9d6e8;
}

.printer-log:empty::before {
  content: "Log messages will appear here once you connect.";
  color: #64748b;
}

.printer-log .log-entry.err {
  color: #ff8a8a;
}

.printer-log .log-entry.info {
  color: #8ecbff;
}

/* Real progress fill directly on the "Print to Label Printer" button
   (both Label Print View and the Reprint Label dialog use this exact
   button — see printLabelElementNow in app.js) — BLE's tiny per-write
   payload means a single 4x6 label can take a minute or more to
   transmit, and a static "Printing…" label with nothing visibly moving
   for that long read as stuck rather than working, reported live as
   wanting "proper loading" shown on the print action itself. The
   ::before fill is inserted before the button's own text in paint order,
   so the text always renders on top of it with no extra markup/z-index
   needed. */
.printer-progress-btn {
  position: relative;
  overflow: hidden;
}

.printer-progress-btn::before {
  content: "";
  position: absolute;
  inset: 0;
  width: var(--print-progress, 0%);
  background: rgba(255, 255, 255, 0.3);
  transition: width 0.2s ease;
}

/* An absolutely-positioned ::before paints ABOVE plain in-flow text by
   default (positioned content always stacks above static content,
   regardless of source order) — this span's own explicit stacking
   context is what actually keeps the button's label readable on top of
   the fill instead of covered by it. */
.printer-progress-btn-label {
  position: relative;
  z-index: 1;
}



/* ── Overview Reports: order listing + per-order box detail ───────────── */
.overview-order-row {
  cursor: pointer;
}

.overview-order-row:hover,
.overview-order-row:focus-visible {
  background: var(--brand-soft);
  outline: none;
}

/* Qualified with .page-header.inner rather than left as a bare class:
   ".page-header.inner { margin-bottom: 0 }" is more specific than a single
   class, so a plain .overview-detail-head margin was silently dropped and
   the order heading sat flush against the first box card with no gap at
   all. */
.page-header.inner.overview-detail-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 22px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--line);
}

/* One flat list for the whole order rather than a card per box: every row
   is a fabric line, with Box No./Factory Box No./Factory Name spanning the
   lines that belong to the same box, the sizes to the right, and the row
   total last. Deliberately NOT the expandable Packaging listing - that
   screen's rows open and close, this one is a report that shows everything
   at once. */
.overview-report-list td,
.overview-report-list th {
  text-align: center;
  vertical-align: middle;
}

/* The two text columns are the only non-numeric ones — left-aligning them
   keeps long fabric names readable against the centred size figures.
   Targeted by CLASS, not position: the Packing Slip PDF removes the two
   factory columns, which moved the fabric header from child 4 to child 2.
   A positional rule stopped matching it there, so the header re-centred
   while its values stayed left-aligned and the column read as if the
   values sat under the wrong heading. */
.overview-report-list td:first-child,
.overview-report-list th:first-child,
.overview-report-list td.overview-report-fabric-cell,
.overview-report-list th.overview-report-fabric-head {
  text-align: left;
}

.overview-report-list td.overview-report-fabric-cell {
  font-weight: 700;
  white-space: nowrap;
}

/* A visible rule wherever a new box starts, so the eye can tell one box's
   lines from the next without hunting for where Box No. changes. */
.overview-report-list tbody tr.overview-report-box-start > td {
  border-top: 2px solid var(--line-strong);
}

.overview-report-list td.overview-report-row-total {
  font-weight: 800;
  color: var(--brand-2);
}

/* The whole box's figure, spanning its lines — tinted and ruled off so it
   reads as a box-level total rather than another per-line one. */
.overview-report-list td.overview-report-box-total {
  font-weight: 800;
  color: var(--ink);
  background: var(--brand-soft);
  border-left: 2px solid var(--line-strong);
}


/* Summary under the Overview Report's box list: one row per job card the
   order was packed against. Deliberately narrow and left-aligned rather
   than stretched to the full width of the box list above it — it is three
   short columns, and a full-bleed table would read as a second report. */
.overview-program-summary {
  margin-top: 24px;
  max-width: 560px;
}

/* The global "table { min-width: 700px }" (meant for the wide admin data
   tables, which live in their own scrollable shells) applies to every
   table with no scoping, and min-width beats max-width — so this three
   column summary was forced to 700px inside a narrower shell and its last
   column sat behind a horizontal scrollbar. */
.overview-program-table {
  min-width: 0;
  width: 100%;
}

.overview-program-table td,
.overview-program-table th {
  text-align: center;
}

.overview-program-table td.overview-program-jobno {
  font-weight: 800;
  color: var(--ink);
}


/* ── Packing Slip sheet (Overview Report PDF only) ────────────────────── */
/* Built and captured off-screen by downloadOverviewOrderPdf, never shown in
   the app. Real A4 width so html2canvas's page slicing lines up with the
   A4 pages jsPDF writes into; min-height (not height) so a long order grows
   onto further pages rather than being clipped — the same reasoning as
   .preview-sheet. */
.packing-slip-sheet {
  width: 210mm;
  min-height: 297mm;
  background: #fff;
  box-sizing: border-box;
}

.packing-slip-sheet .preview-header {
  border-radius: 0;
}

/* The job card's number is monospace at 1.4rem; a party name is ordinary
   prose and can be long, so it gets the page font and wraps instead of
   running into the centred title. */
.packing-slip-sheet .preview-job strong.packing-slip-party {
  font-family: var(--font);
  font-size: 1rem;
  font-weight: 800;
  white-space: normal;
  overflow-wrap: break-word;
}

.packing-slip-body {
  padding: 20px 24px 24px;
}

/* The on-screen tables sit in scrollable shells; on paper they must print
   in full instead of being cut at a scroll edge. */
.packing-slip-body .table-shell {
  overflow: visible;
}

.packing-slip-body table {
  width: 100%;
  /* The global "table { min-width: 700px }" is for the wide admin tables in
     their own scrollable shells; on an A4 sheet there is nowhere to scroll,
     so the table must fit the page instead. */
  min-width: 0;
  font-size: 10px;
}

.packing-slip-body table th,
.packing-slip-body table td {
  padding: 5px 4px;
}

/* On screen the fabric name is nowrap inside a scrollable shell. On paper
   that single unbreakable column was pushing an 11-column table out to
   950px inside a 746px page, so it wraps here instead. */
.packing-slip-body .overview-report-list td.overview-report-fabric-cell {
  white-space: normal;
  word-break: break-word;
}

.packing-slip-body .overview-program-summary {
  margin-top: 20px;
  max-width: 380px;
}


/* Below 1000px the app collapses .table-shell tables into stacked cards so
   they read on a phone (see that media block). A PDF page is always A4
   regardless of which device generated it, so that collapse must not reach
   the slip — without these overrides, generating the slip on a phone
   produced a column of cards instead of the report table. Higher
   specificity than the collapse rules, so it wins at any viewport without
   needing its own media query. */
.packing-slip-sheet .table-shell table {
  display: table;
  width: 100%;
}

.packing-slip-sheet .table-shell thead {
  display: table-header-group;
}

.packing-slip-sheet .table-shell tbody {
  display: table-row-group;
}

.packing-slip-sheet .table-shell tr,
.packing-slip-sheet .table-shell tr:not(.empty-state) {
  display: table-row;
  width: auto;
  margin: 0;
  padding: 0;
  border: none;
  border-radius: 0;
  box-shadow: none;
  background: none;
  column-gap: 0;
}

.packing-slip-sheet .table-shell td,
.packing-slip-sheet .table-shell th {
  display: table-cell;
}

/* The card layout prints each cell's column name above its value; a real
   table already has a header row, so those labels must not come back. */
.packing-slip-sheet .table-shell td::before {
  content: none;
  display: none;
}


/* ── Package Report on small screens ──────────────────────────────────── */
/* Below 1000px the app collapses .table-shell tables into stacked cards.
   The order DETAIL screen must not: its meaning is in the column alignment
   (a size's figure only means anything under its size heading), and its
   box list uses rowspan cells a card layout cannot represent at all — the
   result was a column of bare, unlabelled numbers. It therefore keeps a
   REAL table at every width and scrolls sideways instead. Scoped by screen
   id so it outranks the collapse rules without restating the media query.
   The order LISTING is excluded from this: it was three short columns when
   this was written and is now nine (four values plus five action buttons),
   which at phone width broke its headings one letter per line. It is a
   flat list like any other, so it takes the ordinary card layout. */
#overviewOrderDetailScreen .table-shell table {
  display: table;
  width: 100%;
}

#overviewOrderDetailScreen .table-shell thead {
  display: table-header-group;
}

#overviewOrderDetailScreen .table-shell tbody {
  display: table-row-group;
}

#overviewOrderDetailScreen .table-shell tr,
#overviewOrderDetailScreen .table-shell tr:not(.empty-state) {
  display: table-row;
  width: auto;
  margin: 0;
  padding: 0;
  border: none;
  border-radius: 0;
  box-shadow: none;
  background: none;
  column-gap: 0;
}

#overviewOrderDetailScreen .table-shell td,
#overviewOrderDetailScreen .table-shell th {
  display: table-cell;
}

/* The card layout prints each cell's column name above its value; a real
   table already has a header row, so those labels must not reappear. */
#overviewOrderDetailScreen .table-shell td::before {
  content: none;
  display: none;
}

/* The scrollable window itself. */
#overviewOrderDetailScreen .table-shell {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

@media (max-width: 1000px) {
  /* The box list keeps its full width and scrolls; the three-column order
     listing and the summary are narrow enough to simply fit, so they get
     no scrollbar. */
  #overviewOrderDetailScreen .overview-report-list {
    min-width: 720px;
  }

  #overviewOrderDetailScreen .overview-program-table {
    min-width: 0;
  }

  /* The box list is the wide one: its columns stay on single lines and it
     scrolls sideways. */
  #overviewOrderDetailScreen .table-shell th,
  #overviewOrderDetailScreen .table-shell td {
    padding: 8px 10px;
    font-size: 0.8rem;
    white-space: nowrap;
  }

}


/* Mobile strips .table-shell's background/border/shadow (and the
   .screen-card around it) because every row there normally becomes its own
   framed card, making the outer frames redundant. These two screens keep
   real tables instead, so stripping them left the report sitting directly
   on the page gradient with no white surface behind the text. Restored to
   the same panel the table has on desktop. */
#overviewOrderDetailScreen .table-shell {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}

/* The detail screen's heading and its Back/PDF buttons sit outside that
   shell, so they need the panel back too — otherwise only the tables look
   like part of the report. */
/* A panel's heading and its one action button ("+ Add Party", "+ Create
   Job Card", ...) wrapped onto separate lines on a phone whenever the two
   together were wider than the screen - which depended on how long the
   heading happened to be, so some panels showed them side by side and
   others stacked. Always side by side now: the heading shrinks and wraps
   its own text instead of pushing the button down. */
@media (max-width: 768px) {
  .page-header.admin-panel-header {
    flex-wrap: nowrap;
    align-items: center;
    gap: 12px;
  }

  .page-header.admin-panel-header h2 {
    font-size: 1.25rem;
    line-height: 1.25;
  }

  /* The button keeps its own width; only the heading gives ground. */
  .page-header.admin-panel-header > .primary-btn {
    flex: 0 0 auto;
    white-space: nowrap;
  }

  /* Lifts the 260px floor set on .page-header > div:first-child further
     up. That floor existed to make a long heading wrap the WHOLE row
     rather than squeeze into a sliver beside the button - but with the row
     no longer wrapping, it just pushed the button off the right edge. The
     smaller heading above is what keeps a shrunk title readable now: it
     wraps its own text over two lines instead of stealing the row. */
  .page-header.admin-panel-header > div:first-child {
    min-width: 0;
  }
}

@media (max-width: 768px) {
  .screen-card#overviewOrderDetailScreen {
    background: #fff;
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    padding: 14px;
  }

  /* One frame, not two: the outer panel above is now the report's surface,
     so the shell inside it drops back to a plain scroll container. */
  #overviewOrderDetailScreen .table-shell {
    border: none;
    border-radius: 0;
    box-shadow: none;
  }
}


/* [hidden] loses to .priority-filter-wrap's own display:contents (equal
   specificity, author rule later) and to the mobile
   ".toolbar-grid...:has(...) .priority-filter-wrap { display: block }"
   override, so hiding this filter from JS needs an explicit rule — the
   same trap this file has hit before with [hidden] elements that set
   their own display. */
.priority-filter-wrap[hidden] {
  display: none !important;
}

/* Verify sits in its own Verify Status column rather than beside the icon
   actions. */
.packaging-report-status-cell,
.packaging-report-mobile-status {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
}

.packaging-report-mobile-status {
  flex-direction: row;
  flex-wrap: wrap;
  margin-top: 10px;
}



/* Delivered reads as a finished state rather than another pending action,
   matching how .is-verified marks a verified box. */
.packaging-deliver-btn.is-delivered {
  background: var(--brand-soft);
  color: var(--brand-2);
  border-color: var(--brand-2);
  font-weight: 800;
}

/* [hidden] on a <th> loses to the table's own display rules, same trap as
   elsewhere in this file. */
#overviewOrderTable th[hidden] {
  display: none;
}


/* Overall total of the Box Total column, in the table's own footer so it
   stays attached to the rows it sums. Built cell-per-column rather than
   with a colspan: the Packing Slip PDF removes the two factory columns,
   and a colspan would not shrink with them. */
.overview-report-list tfoot .overview-report-grand-row > td {
  border-top: 2px solid var(--line-strong);
  background: var(--brand-soft);
  font-weight: 800;
  padding-top: 10px;
  padding-bottom: 10px;
}

.overview-report-list tfoot td.overview-report-grand-label {
  text-align: left;
  color: var(--ink);
  letter-spacing: 0.02em;
}

.overview-report-list tfoot td.overview-report-grand-total {
  color: var(--brand-2);
  font-size: 0.95rem;
}


/* Packing Entry's running total on a phone: centred and given a real
   surface of its own. Right-aligned at body text size it read as a small
   caption floating above the fabric card, easy to miss on the one screen
   where it is the number being watched while quantities are typed. */
@media (max-width: 768px) {
  .packing-entry-form-head {
    justify-content: center;
    margin-bottom: 14px;
  }

  .packing-grand-total {
    display: inline-flex;
    align-items: baseline;
    gap: 8px;
    padding: 8px 20px;
    border-radius: 999px;
    background: var(--brand-soft);
    border: 1px solid var(--brand-2);
    color: var(--brand-2);
    font-size: 0.95rem;
    letter-spacing: 0.02em;
  }

  .packing-grand-total strong {
    font-size: 1.25rem;
    font-weight: 800;
    color: var(--ink);
  }

  /* Cancel / Save & Print / Save, on a phone. .dialog-actions is
     justify-content:flex-end and these three buttons don't shrink, so once
     their natural widths (89 + 128 + 77 px plus gaps) pass the card's own
     width the row overflows to the LEFT — Cancel ends up drawn outside the
     white card, and at 320px its left edge measures -10px, i.e. off the
     screen entirely. Reported live from a phone. Sharing the row equally
     (flex:1 with min-width:0) keeps all three inside the card at any width
     instead; they get narrower rather than escaping. */
  .packing-entry-form .dialog-actions {
    justify-content: stretch;
    gap: 8px;
  }

  .packing-entry-form .dialog-actions button {
    flex: 1 1 0;
    min-width: 0;
    padding-left: 4px;
    padding-right: 4px;
    font-size: 0.82rem;
    white-space: nowrap;
  }
}

/* Order No. Management toolbar: search + one status filter, so two
   columns rather than the three .admin-toolbar lays out for. Stacks on
   phones like every other admin toolbar. */
.toolbar-grid.admin-toolbar:has(#orderNoStatusFilter) {
  grid-template-columns: minmax(0, 1fr) 200px;
}

@media (max-width: 1000px) {
  .toolbar-grid.admin-toolbar:has(#orderNoStatusFilter) {
    grid-template-columns: 1fr;
  }
}

/* Edit-mode Save button in the job card page header (see
   updateEditSaveButton in app.js). Faded and inert until the card
   actually differs from how it was opened; full brand blue once it does. */
.edit-save-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  transition: opacity 0.2s ease, box-shadow 0.2s ease, filter 0.2s ease;
}

.edit-save-btn[hidden] {
  display: none;
}

.edit-save-btn:disabled {
  opacity: 0.4;
  filter: grayscale(0.6);
  box-shadow: none;
  cursor: not-allowed;
}

.edit-save-btn.is-dirty:not(:disabled):hover {
  filter: brightness(1.08);
}

/* Windowed pager (pagerItems in app.js): one row, never wrapping onto a
   second line. The window itself is sized so it fits — 2 neighbours each
   side on desktop, 1 on phones — and the "Prev"/"Next" words drop to
   arrows on the narrowest screens. */
.packaging-pagination-pages {
  flex-wrap: nowrap;
  align-items: center;
}

.packaging-page-gap {
  min-width: 22px;
  text-align: center;
  color: var(--muted);
  font-weight: 700;
  letter-spacing: 1px;
  user-select: none;
}

.packaging-page-step {
  white-space: nowrap;
}

@media (max-width: 720px) {
  .packaging-pagination {
    flex-direction: column;
    align-items: stretch;
  }
  .packaging-pagination-info {
    text-align: center;
  }
  .packaging-pagination-pages {
    justify-content: center;
    gap: 4px;
  }
  .packaging-page-btn {
    min-width: 32px;
    padding: 6px 8px;
  }
}

@media (max-width: 400px) {
  .packaging-page-step-label {
    display: none;
  }
}
